From f3949372f831255002107fc85eeda9074298cb93 Mon Sep 17 00:00:00 2001 From: Oleg Stepanischev Date: Thu, 18 May 2023 22:17:48 +0300 Subject: [PATCH] IL2CPP compatibility --- src/ZstdSharp/Unsafe/ZstdCompress.cs | 6 +++--- src/ZstdSharp/Unsafe/ZstdDecompress.cs | 2 +- src/ZstdSharp/Unsafe/ZstdInternal.cs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ZstdSharp/Unsafe/ZstdCompress.cs b/src/ZstdSharp/Unsafe/ZstdCompress.cs index 50521ef..3a3009a 100644 --- a/src/ZstdSharp/Unsafe/ZstdCompress.cs +++ b/src/ZstdSharp/Unsafe/ZstdCompress.cs @@ -3221,7 +3221,7 @@ private static nuint ZSTD_buildSeqStore(ZSTD_CCtx_s* zc, void* src, nuint srcSiz ZSTD_matchState_t* ms = &zc->blockState.matchState; assert(srcSize <= 1 << 17); ZSTD_assertEqualCParams(zc->appliedParams.cParams, ms->cParams); - if (srcSize < 1 + 1 + ZSTD_blockHeaderSize + 1 + 1) + if (srcSize < (nuint)(1 + 1) + ZSTD_blockHeaderSize + 1 + 1) { if (zc->appliedParams.cParams.strategy >= ZSTD_strategy.ZSTD_btopt) { @@ -4422,7 +4422,7 @@ private static nuint ZSTD_compress_frameChunk(ZSTD_CCtx_s* cctx, void* dst, nuin { ZSTD_matchState_t* ms = &cctx->blockState.matchState; uint lastBlock = lastFrameChunk & (uint)(blockSize >= remaining ? 1 : 0); - if (dstCapacity < ZSTD_blockHeaderSize + (1 + 1) + 1) + if (dstCapacity < ZSTD_blockHeaderSize + (nuint)(1 + 1) + 1) { return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_dstSize_tooSmall)); } @@ -7103,7 +7103,7 @@ private static nuint ZSTD_compressSequences_internal(ZSTD_CCtx_s* cctx, void* ds } blockSize -= additionalByteAdjustment; - if (blockSize < 1 + 1 + ZSTD_blockHeaderSize + 1 + 1) + if (blockSize < (nuint)(1 + 1) + ZSTD_blockHeaderSize + 1 + 1) { cBlockSize = ZSTD_noCompressBlock(op, dstCapacity, ip, blockSize, lastBlock); { diff --git a/src/ZstdSharp/Unsafe/ZstdDecompress.cs b/src/ZstdSharp/Unsafe/ZstdDecompress.cs index 36fe2b8..f298345 100644 --- a/src/ZstdSharp/Unsafe/ZstdDecompress.cs +++ b/src/ZstdSharp/Unsafe/ZstdDecompress.cs @@ -1780,7 +1780,7 @@ public static nuint ZSTD_freeDStream(ZSTD_DCtx_s* zds) /* *** Initialization *** */ public static nuint ZSTD_DStreamInSize() { - return (1 << 17) + ZSTD_blockHeaderSize; + return (nuint)(1 << 17) + ZSTD_blockHeaderSize; } public static nuint ZSTD_DStreamOutSize() diff --git a/src/ZstdSharp/Unsafe/ZstdInternal.cs b/src/ZstdSharp/Unsafe/ZstdInternal.cs index c28476b..94852f3 100644 --- a/src/ZstdSharp/Unsafe/ZstdInternal.cs +++ b/src/ZstdSharp/Unsafe/ZstdInternal.cs @@ -14,7 +14,7 @@ public static unsafe partial class Methods public static readonly uint* repStartValue = GetArrayPointer(new uint[3] { 1, 4, 8 }); public static readonly nuint* ZSTD_fcs_fieldSize = GetArrayPointer(new nuint[4] { 0, 2, 4, 8 }); public static readonly nuint* ZSTD_did_fieldSize = GetArrayPointer(new nuint[4] { 0, 1, 2, 4 }); - public const nuint ZSTD_blockHeaderSize = 3; + public const uint ZSTD_blockHeaderSize = 3; public static readonly byte* LL_bits = GetArrayPointer(new byte[36] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }); public static readonly short* LL_defaultNorm = GetArrayPointer(new short[36] { 4, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 1, 1, 1, 1, 1, -1, -1, -1, -1 }); public const uint LL_defaultNormLog = 6;