Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/common/bitstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ pub(crate) unsafe fn BIT_closeCStream(bitC: *mut BIT_CStream_t) -> size_t {
/// * Local register size is 64-bits on 64-bits systems, 32-bits on 32-bits systems.
/// * You can then retrieve bitFields stored into the local register, **in reverse order**.
/// * Local register is explicitly reloaded from memory by the [`reload`] method.
/// * A reload guarantee a minimum of ((8*sizeof(bitD->bitContainer))-7) bits when its result is BIT_DStream_unfinished.
/// * A reload guarantee a minimum of ((8*sizeof(bitD->bitContainer))-7) bits when its result is [`StreamStatus::Unfinished`].
/// * Otherwise, it can be less than that, so proceed accordingly.
/// * Checking if DStream has reached its end can be performed with BIT_endOfDStream().
/// * Checking if `DStream` has reached its end can be performed with [`BIT_endOfDStream`].
#[derive(Debug, Copy, Clone)]
#[repr(C)]
pub(crate) struct BIT_DStream_t<'a> {
Expand Down
6 changes: 3 additions & 3 deletions lib/common/huf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub(crate) const HUF_BLOCKSIZE_MAX: usize = 128 * 1024;

pub(crate) const HUF_WORKSPACE_SIZE: usize = (8 << 10) + 512;

/// Max runtime value of tableLog (due to static allocation); can be modified up to HUF_TABLELOG_ABSOLUTEMAX.
/// Max runtime value of tableLog (due to static allocation); can be modified up to [`HUF_TABLELOG_ABSOLUTEMAX`].
pub(crate) const HUF_TABLELOG_MAX: usize = 12;
/// Default tableLog value when none specified
pub(crate) const HUF_TABLELOG_DEFAULT: u32 = 11;
Expand All @@ -16,7 +16,7 @@ pub(crate) const HUF_SYMBOLVALUE_MAX: u32 = 255;
pub(crate) const HUF_CTABLE_WORKSPACE_SIZE_U32: usize =
(4 * (HUF_SYMBOLVALUE_MAX as usize + 1)) + 192;

/// Absolute limit of HUF_MAX_TABLELOG. Beyond that value, code does not work
/// Absolute limit of [`HUF_MAX_TABLELOG`]. Beyond that value, code does not work
const HUF_TABLELOG_ABSOLUTEMAX: usize = 12;
const _: () = assert!(
HUF_TABLELOG_MAX <= HUF_TABLELOG_ABSOLUTEMAX,
Expand All @@ -39,7 +39,7 @@ pub(crate) const HUF_OPTIMAL_DEPTH_THRESHOLD: core::ffi::c_int = ZSTD_btultra as
pub(crate) type HUF_repeat = core::ffi::c_uint;
/// Cannot use the previous table
pub(crate) const HUF_repeat_none: HUF_repeat = 0;
/// Can use the previous table but it must be checked. Note : The previous table must have been constructed by HUF_compress{1, 4}X_repeat
/// Can use the previous table but it must be checked. Note : The previous table must have been constructed by `HUF_compress{1, 4}X_repeat`
pub(crate) const HUF_repeat_check: HUF_repeat = 1;
/// Can use the previous table and it is assumed to be valid
pub(crate) const HUF_repeat_valid: HUF_repeat = 2;
Expand Down
6 changes: 3 additions & 3 deletions lib/common/zstd_internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ pub(crate) enum Overlap {
OverlapSrcBeforeDst,
}

/// Custom version of ZSTD_memcpy(), can over read/write up to WILDCOPY_OVERLENGTH bytes (if length==0)
/// Custom version of [`ZSTD_memcpy`], can over read/write up to [`WILDCOPY_OVERLENGTH`] bytes (if length==0)
///
/// The `ovtype` controls the overlap detection
/// - ZSTD_no_overlap: The source and destination are guaranteed to be at least WILDCOPY_VECLEN bytes apart.
/// - ZSTD_overlap_src_before_dst: The src and dst may overlap, but they MUST be at least 8 bytes apart.
/// - [`Overlap::NoOverlap`]: The source and destination are guaranteed to be at least [`WILDCOPY_VECLEN`] bytes apart.
/// - [`Overlap::OverlapSrcBeforeDst`]: The src and dst may overlap, but they MUST be at least 8 bytes apart.
/// The src buffer must be before the dst buffer.
#[inline(always)]
pub(crate) unsafe fn ZSTD_wildcopy(
Expand Down
4 changes: 2 additions & 2 deletions lib/decompress/huf_decompress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1943,8 +1943,8 @@ enum Decoder {
/// Tells which decoder is likely to decode faster,
/// based on a set of pre-computed metrics.
///
/// @return : 0==HUF_decompress4X1, 1==HUF_decompress4X2 .
/// Assumption : 0 < dst_size <= 128 KB */
/// @return : `0==HUF_decompress4X1`, `1==HUF_decompress4X2` .
/// Assumption : 0 < `dst_size` <= 128 KB */
fn HUF_selectDecoder(dst_size: usize, src_size: usize) -> Decoder {
let D256 = (dst_size >> 8) as u32;

Expand Down
4 changes: 2 additions & 2 deletions lib/decompress/zstd_ddict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ pub unsafe extern "C" fn ZSTD_createDDict_advanced(
/// The `dict`'s content is copied inside the [`ZSTD_DDict`], so `dict` can be released after
/// [`ZSTD_DDict`] creation.
///
/// The DDict can be freed using [`ZSTD_freeDDict`].
/// The [`ZSTD_DDict`] can be freed using [`ZSTD_freeDDict`].
///
/// # Returns
///
Expand Down Expand Up @@ -341,7 +341,7 @@ pub const extern "C" fn ZSTD_estimateDDictSize(
///
/// # Returns
///
/// - the size of the DDict, including the size of the DDict's `dictBuffer` if present
/// - the size of the [`ZSTD_DDict`], including the size of the [`ZSTD_DDict`]'s `dictBuffer` if present
/// - 0 if the `ddict` is NULL
#[cfg_attr(feature = "export-symbols", export_name = crate::prefix!(ZSTD_sizeof_DDict))]
pub unsafe extern "C" fn ZSTD_sizeof_DDict(ddict: *const ZSTD_DDict) -> size_t {
Expand Down
12 changes: 6 additions & 6 deletions lib/decompress/zstd_decompress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ fn ZSTD_initDCtx_internal(dctx: &mut MaybeUninit<ZSTD_DCtx>) {
/// # Limitations
///
/// - currently not compatible with internal dictionary creation, triggered by [`ZSTD_initDStream_usingDict`]
/// - static DCtx is incompatible with legacy support
/// - static `DCtx` is incompatible with legacy support
///
/// # Returns
///
Expand Down Expand Up @@ -2848,7 +2848,7 @@ pub unsafe extern "C" fn ZSTD_initDStream(zds: *mut ZSTD_DStream) -> size_t {
/// This function is deprecated, and is equivalent to first using [`ZSTD_DCtx_reset`] to reset the
/// decompression context and then using [`ZSTD_DCtx_refDDict`] to reference the dictionary.
///
/// Note: DDict will just be referenced, and must outlive decompression session
/// Note: `DDict` will just be referenced, and must outlive decompression session
#[cfg_attr(feature = "export-symbols", export_name = crate::prefix!(ZSTD_initDStream_usingDDict))]
pub unsafe extern "C" fn ZSTD_initDStream_usingDDict(
dctx: *mut ZSTD_DStream,
Expand Down Expand Up @@ -2885,7 +2885,7 @@ pub unsafe extern "C" fn ZSTD_resetDStream(dctx: *mut ZSTD_DStream) -> size_t {
/// active for decompression of future frames using same [`ZSTD_DCtx`] decompression context.
///
/// If called with [`ZSTD_dParameter::ZSTD_d_refMultipleDDicts`] enabled, repeated calls of this
/// function will store the [`ZSTD_DDict`] references in a table, and the DDict used for
/// function will store the [`ZSTD_DDict`] references in a table, and the `DDict` used for
/// decompression will be determined at decompression time, as per the dict ID in the frame. The
/// memory for the table is allocated on the first call to [`ZSTD_DCtx_refDDict`], and can be freed
/// with [`ZSTD_freeDCtx`].
Expand All @@ -2894,7 +2894,7 @@ pub unsafe extern "C" fn ZSTD_resetDStream(dctx: *mut ZSTD_DStream) -> size_t {
/// dictionary will be managed, and referencing a dictionary effectively "discards" any previous
/// one.
///
/// Referencing a NULL DDict means "return to no-dictionary mode".
/// Referencing a NULL `DDict` means "return to no-dictionary mode".
///
/// # Returns
///
Expand All @@ -2903,7 +2903,7 @@ pub unsafe extern "C" fn ZSTD_resetDStream(dctx: *mut ZSTD_DStream) -> size_t {
///
/// # Safety
///
/// The DDict is just referenced, its lifetime must outlive its usage from [`ZSTD_DCtx`].
/// The `DDict` is just referenced, its lifetime must outlive its usage from [`ZSTD_DCtx`].
#[cfg_attr(feature = "export-symbols", export_name = crate::prefix!(ZSTD_DCtx_refDDict))]
pub unsafe extern "C" fn ZSTD_DCtx_refDDict(
dctx: *mut ZSTD_DCtx,
Expand Down Expand Up @@ -3297,7 +3297,7 @@ pub extern "C" fn ZSTD_decodingBufferSize_min(
/// Instead of providing the `windowSize` manually, you can also deduce it from a valid frame
/// header using [`ZSTD_estimateDStreamSize_fromFrame`]
///
/// Note: if streaming is initialized with [`ZSTD_initDStream_usingDict`], an internal DDict
/// Note: if streaming is initialized with [`ZSTD_initDStream_usingDict`], an internal `DDict`
/// will be created, whose additional size is not estimated here. In this case, get total size by
/// adding [`crate::ZSTD_estimateDDictSize`].
#[cfg_attr(feature = "export-symbols", export_name = crate::prefix!(ZSTD_estimateDStreamSize))]
Expand Down
16 changes: 8 additions & 8 deletions lib/decompress/zstd_decompress_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1068,14 +1068,14 @@ unsafe fn ZSTD_overlapCopy8(op: &mut *mut u8, ip: &mut *const u8, offset: size_t
debug_assert!(unsafe { (*op).offset_from(*ip) } >= 8);
}

/// Specialized version of memcpy() that is allowed to READ up to WILDCOPY_OVERLENGTH past the input buffer
/// and write up to 16 bytes past oend_w (op >= oend_w is allowed).
/// Specialized version of `memcpy` that is allowed to READ up to [`WILDCOPY_OVERLENGTH`] past the input buffer
/// and write up to 16 bytes past `oend_w` (op >= `oend_w` is allowed).
/// This function is only called in the uncommon case where the sequence is near the end of the block. It
/// should be fast for a single long sequence, but can be slow for several short sequences.
///
/// @param ovtype controls the overlap detection
/// - Overlap::NoOverlap: The source and destination are guaranteed to be at least WILDCOPY_VECLEN bytes apart.
/// - Overlap::OverlapSrcBeforeDst: The src and dst may overlap and may be any distance apart.
/// - [`Overlap::NoOverlap`]: The source and destination are guaranteed to be at least [`WILDCOPY_VECLEN`] bytes apart.
/// - [`Overlap::OverlapSrcBeforeDst`]: The src and dst may overlap and may be any distance apart.
/// The src buffer must be before the dst buffer.
unsafe fn ZSTD_safecopy(
mut op: *mut u8,
Expand Down Expand Up @@ -1131,7 +1131,7 @@ unsafe fn ZSTD_safecopy(
}

/// This version allows overlap with dst before src, or handles the non-overlap case with dst after src
/// Kept separate from more common ZSTD_safecopy case to avoid performance impact to the safecopy common case */
/// Kept separate from more common [`ZSTD_safecopy`] case to avoid performance impact to the safecopy common case */
unsafe fn ZSTD_safecopyDstBeforeSrc(mut op: *mut u8, mut ip: *const u8, length: size_t) {
let diff = op.offset_from(ip) as ptrdiff_t;
let oend = op.add(length);
Expand Down Expand Up @@ -1168,7 +1168,7 @@ unsafe fn ZSTD_safecopyDstBeforeSrc(mut op: *mut u8, mut ip: *const u8, length:
/// and unlikely cases, we can speed up the common cases.
///
/// NOTE: This function needs to be fast for a single long sequence, but doesn't need
/// to be optimized for many small sequences, since those fall into ZSTD_execSequence().
/// to be optimized for many small sequences, since those fall into [`ZSTD_execSequence`].
#[inline(never)]
unsafe fn ZSTD_execSequenceEnd(
mut op: *mut u8,
Expand Down Expand Up @@ -1558,8 +1558,8 @@ fn ZSTD_updateFseStateWithDInfo(
DStatePtr.state = usize::from(nextState) + lowBits;
}

/// We need to add at most (ZSTD_WINDOWLOG_MAX_32 - 1) bits to read the maximum
/// offset bits. But we can only read at most STREAM_ACCUMULATOR_MIN_32
/// We need to add at most `(ZSTD_WINDOWLOG_MAX_32 - 1)` bits to read the maximum
/// offset bits. But we can only read at most [`STREAM_ACCUMULATOR_MIN_32`]
/// bits before reloading. This value is the maximum number of bytes we read
/// after reloading when we are decoding long offsets.
const LONG_OFFSETS_MAX_EXTRA_BITS_32: i32 =
Expand Down
4 changes: 2 additions & 2 deletions lib/dictBuilder/zdict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct EStats_ress_t {
dict: *mut ZSTD_CDict,
/// working context
zc: *mut ZSTD_CCtx,
/// must be ZSTD_BLOCKSIZE_MAX allocated
/// must be [`ZSTD_BLOCKSIZE_MAX`] allocated
workPlace: Box<[MaybeUninit<u8>]>,
}

Expand Down Expand Up @@ -734,7 +734,7 @@ fn ZDICT_insertSortCount(
}

/// Rewrite `countLit` to contain a mostly flat but still compressible distribution of literals.
/// Necessary to avoid generating a non-compressible distribution that HUF_writeCTable() cannot encode.
/// Necessary to avoid generating a non-compressible distribution that [`HUF_writeCTable`] cannot encode.
fn ZDICT_flatLit(countLit: &mut [core::ffi::c_uint; 256]) {
countLit.fill(2);

Expand Down
4 changes: 2 additions & 2 deletions lib/legacy/zstd_v06.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2340,11 +2340,11 @@ unsafe fn ZSTDv06_frameHeaderSize(src: *const core::ffi::c_void, srcSize: size_t
ZSTDv06_frameHeaderSize_min.wrapping_add(*ZSTDv06_fcs_fieldSize.as_ptr().offset(fcsId as isize))
}

/// ZSTDv06_getFrameParams() :
/// [`ZSTDv06_getFrameParams`] :
/// decode Frame Header, or provide expected `srcSize`.
/// @return : 0, `fparamsPtr` is correctly filled,
/// >0, `srcSize` is too small, result is expected `srcSize`,
/// or an error code, which can be tested using ZSTDv06_isError()
/// or an error code, which can be tested using [`ZSTDv06_isError`]
pub(crate) unsafe fn ZSTDv06_getFrameParams(
fparamsPtr: *mut ZSTDv06_frameParams,
src: *const core::ffi::c_void,
Expand Down
16 changes: 8 additions & 8 deletions lib/zstd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ pub type ZSTD_allocFunction =
pub struct ZSTD_format_e(u32);

impl ZSTD_format_e {
/// zstd frame format, specified in zstd_compression_format.md (default)
/// zstd frame format, specified in `zstd_compression_format.md` (default)
pub const ZSTD_f_zstd1: Self = Self(Format::ZSTD_f_zstd1 as u32);

/// Variant of zstd frame format, without initial 4-bytes magic number.
Expand Down Expand Up @@ -359,8 +359,8 @@ impl ZSTD_dParameter {
/// Experimental parameter: if enabled and [`ZSTD_DCtx`] is allocated on the heap, then
/// additional memory will be allocated to store references to multiple [`ZSTD_DDict`]. That
/// is, multiple calls of [`ZSTD_DCtx_refDDict`] using a given [`ZSTD_DCtx`], rather than
/// overwriting the previous DDict reference, will instead store all references. At
/// decompression time, the appropriate `dictID` is selected from the set of DDicts based on
/// overwriting the previous `DDict` reference, will instead store all references. At
/// decompression time, the appropriate `dictID` is selected from the set of `DDict`s based on
/// the `dictID` in the frame.
///
/// **Warning:** Enabling this parameter and calling [`ZSTD_DCtx_refDDict`] will trigger memory
Expand Down Expand Up @@ -506,21 +506,21 @@ impl ZSTD_ResetDirective {
///
/// Zstd currently supports the use of a [`ZSTD_CDict`] in three ways:
///
/// - The contents of the CDict can be copied into the working context. This
/// - The contents of the `CDict` can be copied into the working context. This
/// means that the compression can search both the dictionary and input
/// while operating on a single set of internal tables. This makes
/// the compression faster per byte of input. However, the initial copy of
/// the CDict's tables incurs a fixed cost at the beginning of the
/// the `CDict`'s tables incurs a fixed cost at the beginning of the
/// compression. For small compressions (< 8 KB), that copy can dominate
/// the cost of the compression.
///
/// - The CDict's tables can be used in-place. In this model, compression is
/// - The `CDict`'s tables can be used in-place. In this model, compression is
/// slower per input byte, because the compressor has to search two sets of
/// tables. However, this model incurs no start-up cost (as long as the
/// working context's tables can be reused). For small inputs, this can be
/// faster than copying the CDict's tables.
/// faster than copying the `CDict`'s tables.
///
/// - The CDict's tables are not used at all, and instead we use the working
/// - The `CDict`'s tables are not used at all, and instead we use the working
/// context alone to reload the dictionary and use params based on the source
/// size. See [`ZSTD_compress_insertDictionary`] and [`ZSTD_compress_usingDict`].
/// This method is effective when the dictionary sizes are very small relative
Expand Down
2 changes: 1 addition & 1 deletion programs/fileio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5231,7 +5231,7 @@ unsafe fn FIO_getLargestFileSize(
maxFileSize
}

/// FIO_compressMultipleFilenames() :
/// [`FIO_compressMultipleFilenames`] :
/// compress nbFiles files
/// into either one destination (outFileName),
/// or into one file each (outFileName == NULL, but suffix != NULL),
Expand Down