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
2 changes: 1 addition & 1 deletion src/ZstdSharp/Unsafe/Bitstream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace ZstdSharp.Unsafe
{
public static unsafe partial class Methods
{
#if NET8_0_OR_GREATER
#if NET7_0_OR_GREATER
private static ReadOnlySpan<uint> Span_BIT_mask => new uint[32]
{
0,
Expand Down
2 changes: 1 addition & 1 deletion src/ZstdSharp/Unsafe/FseCompress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ private static nuint FSE_normalizeM2(short* norm, uint tableLog, uint* count, nu
return 0;
}

#if NET8_0_OR_GREATER
#if NET7_0_OR_GREATER
private static ReadOnlySpan<uint> Span_rtbTable => new uint[8]
{
0,
Expand Down
2 changes: 1 addition & 1 deletion src/ZstdSharp/Unsafe/ZstdCompress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2015,7 +2015,7 @@ public static nuint ZSTD_estimateCCtxSize_usingCParams(ZSTD_compressionParameter
}
}

#if NET8_0_OR_GREATER
#if NET7_0_OR_GREATER
private static ReadOnlySpan<ulong> Span_srcSizeTiers => new ulong[4]
{
16 * (1 << 10),
Expand Down
2 changes: 1 addition & 1 deletion src/ZstdSharp/Unsafe/ZstdCompressSequences.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace ZstdSharp.Unsafe
{
public static unsafe partial class Methods
{
#if NET8_0_OR_GREATER
#if NET7_0_OR_GREATER
private static ReadOnlySpan<uint> Span_kInverseProbabilityLog256 => new uint[256]
{
0,
Expand Down
4 changes: 2 additions & 2 deletions src/ZstdSharp/Unsafe/ZstdDecompressBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ private static nuint ZSTD_decodeSeqHeaders(ZSTD_DCtx_s* dctx, int* nbSeqPtr, voi
return (nuint)(ip - istart);
}

#if NET8_0_OR_GREATER
#if NET7_0_OR_GREATER
private static ReadOnlySpan<uint> Span_dec32table => new uint[8]
{
0,
Expand All @@ -752,7 +752,7 @@ private static nuint ZSTD_decodeSeqHeaders(ZSTD_DCtx_s* dctx, int* nbSeqPtr, voi

private static readonly uint* dec32table = GetArrayPointer(new uint[8] { 0, 1, 2, 1, 4, 4, 4, 4 });
#endif
#if NET8_0_OR_GREATER
#if NET7_0_OR_GREATER
private static ReadOnlySpan<int> Span_dec64table => new int[8]
{
8,
Expand Down
6 changes: 3 additions & 3 deletions src/ZstdSharp/Unsafe/ZstdDecompressInternal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace ZstdSharp.Unsafe
{
public static unsafe partial class Methods
{
#if NET8_0_OR_GREATER
#if NET7_0_OR_GREATER
private static ReadOnlySpan<uint> Span_LL_base => new uint[36]
{
0,
Expand Down Expand Up @@ -52,7 +52,7 @@ public static unsafe partial class Methods

private static readonly uint* LL_base = GetArrayPointer(new uint[36] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20, 22, 24, 28, 32, 40, 48, 64, 0x80, 0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000, 0x8000, 0x10000 });
#endif
#if NET8_0_OR_GREATER
#if NET7_0_OR_GREATER
private static ReadOnlySpan<uint> Span_OF_base => new uint[32]
{
0,
Expand Down Expand Up @@ -134,7 +134,7 @@ public static unsafe partial class Methods

private static readonly byte* OF_bits = GetArrayPointer(new byte[32] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 });
#endif
#if NET8_0_OR_GREATER
#if NET7_0_OR_GREATER
private static ReadOnlySpan<uint> Span_ML_base => new uint[53]
{
3,
Expand Down
6 changes: 3 additions & 3 deletions src/ZstdSharp/Unsafe/ZstdInternal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace ZstdSharp.Unsafe
{
public static unsafe partial class Methods
{
#if NET8_0_OR_GREATER
#if NET7_0_OR_GREATER
private static ReadOnlySpan<uint> Span_repStartValue => new uint[3]
{
1,
Expand Down Expand Up @@ -73,7 +73,7 @@ public static unsafe partial class Methods

private 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 });
#endif
#if NET8_0_OR_GREATER
#if NET7_0_OR_GREATER
private static ReadOnlySpan<short> Span_LL_defaultNorm => new short[36]
{
4,
Expand Down Expand Up @@ -244,7 +244,7 @@ public static unsafe partial class Methods
private static readonly short* ML_defaultNorm = GetArrayPointer(new short[53] { 1, 4, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1) });
#endif
private const uint ML_defaultNormLog = 6;
#if NET8_0_OR_GREATER
#if NET7_0_OR_GREATER
private static ReadOnlySpan<short> Span_OF_defaultNorm => new short[29]
{
1,
Expand Down
2 changes: 1 addition & 1 deletion src/ZstdSharp/Unsafe/ZstdLdmGeartab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace ZstdSharp.Unsafe
{
public static unsafe partial class Methods
{
#if NET8_0_OR_GREATER
#if NET7_0_OR_GREATER
private static ReadOnlySpan<ulong> Span_ZSTD_ldm_gearTab => new ulong[256]
{
0xf5b8f72c5f77775c,
Expand Down
4 changes: 2 additions & 2 deletions src/ZstdSharp/Unsafe/ZstdOpt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private static uint ZSTD_scaleStats(uint* table, uint lastEltIndex, uint logTarg
return ZSTD_downscaleStats(table, lastEltIndex, ZSTD_highbit32(factor), base_directive_e.base_1guaranteed);
}

#if NET8_0_OR_GREATER
#if NET7_0_OR_GREATER
private static ReadOnlySpan<uint> Span_baseLLfreqs => new uint[36]
{
4,
Expand Down Expand Up @@ -132,7 +132,7 @@ private static uint ZSTD_scaleStats(uint* table, uint lastEltIndex, uint logTarg

private static readonly uint* baseLLfreqs = GetArrayPointer(new uint[36] { 4, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });
#endif
#if NET8_0_OR_GREATER
#if NET7_0_OR_GREATER
private static ReadOnlySpan<uint> Span_baseOFCfreqs => new uint[32]
{
6,
Expand Down
4 changes: 3 additions & 1 deletion src/ZstdSharp/UnsafeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,13 @@ public static void free(void* ptr)
public static T* GetArrayPointer<T>(T[] array) where T : unmanaged
{
var size = (uint)(sizeof(T) * array.Length);
#if NET5_0_OR_GREATER
#if NET9_0_OR_GREATER
// This function is used to allocate memory for static data blocks.
// We have to use AllocateTypeAssociatedMemory and link the memory's
// lifetime to this assembly, in order to prevent memory leaks when
// loading the assembly in an unloadable AssemblyLoadContext.
// While introduced in .NET 5, we call this only in .NET 9+, because
// it's not implemented in the Mono runtime until then.
var destination = (T*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(UnsafeHelper), (int)size);
#else
var destination = (T*)malloc(size);
Expand Down