Skip to content

Commit 839dc12

Browse files
author
Ivan G
authored
increase resoltuion in api.h (#29)
1 parent aaa6ac5 commit 839dc12

File tree

12 files changed

+62
-54
lines changed

12 files changed

+62
-54
lines changed

.github/workflows/build.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
name: '🏦 Build'
22

33
env:
4-
VERSION: 1.6.3
4+
VERSION: 1.7.0
55
# PACKAGE_SUFFIX: '-pre.1'
66
PACKAGE_SUFFIX: ''
77
ASM_VERSION: 1.0.0
88
BUILD_TYPE: Release
9-
VCPKG_HASH: 0f88ecb8528605f91980b90a2c5bad88e3cb565f
9+
VCPKG_HASH: f33cc491c85a7d643c5ab6da1667c1458e6d7abf
1010

1111
on:
1212
push:
@@ -26,7 +26,7 @@ jobs:
2626
strategy:
2727
matrix:
2828
include:
29-
- os: ubuntu-20.04
29+
- os: ubuntu-22.04
3030
name: Linux x64
3131
arch: x64
3232
vcpkg_triplet: x64-linux
@@ -39,7 +39,7 @@ jobs:
3939
vcpkg_config: RelWithDebInfo
4040
dotnet_rid: linux-musl-x64
4141
cmake_options: -D CMAKE_C_FLAGS="-static -Os"
42-
- os: ubuntu-20.04
42+
- os: ubuntu-22.04
4343
name: Linux ARM
4444
arch: arm64
4545
vcpkg_triplet: arm64-linux
@@ -86,11 +86,13 @@ jobs:
8686
with:
8787
submodules: true
8888

89-
- name: Linux ARM
89+
- name: Linux ARM (cross-compile deps)
9090
if: runner.os == 'Linux' && matrix.arch == 'arm64'
9191
run: |
9292
sudo apt-get update
93-
sudo apt-get --yes install g++-aarch64-linux-gnu pkg-config-aarch64-linux-gnu
93+
sudo apt-get --yes install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu pkg-config qemu-user-static
94+
# Set PKG_CONFIG_LIBDIR for ARM64 cross-compilation
95+
echo "PKG_CONFIG_LIBDIR=/usr/aarch64-linux-gnu/pkgconfig:/usr/lib/aarch64-linux-gnu/pkgconfig" >> $GITHUB_ENV
9496
9597
- uses: friendlyanon/setup-vcpkg@v1
9698
# seems like the absense of commit hash expects vcpkg submodule, i don't want that
@@ -164,8 +166,6 @@ jobs:
164166
strategy:
165167
matrix:
166168
include:
167-
- os: ubuntu-20.04
168-
dotnet_rid: linux-x64
169169
- os: ubuntu-22.04
170170
dotnet_rid: linux-x64
171171
- os: windows-2022
@@ -198,7 +198,6 @@ jobs:
198198
uses: actions/setup-dotnet@v4
199199
with:
200200
dotnet-version: |
201-
6.0.x
202201
8.0.x
203202
204203
- name: build
@@ -234,7 +233,6 @@ jobs:
234233
uses: actions/setup-dotnet@v4
235234
with:
236235
dotnet-version: |
237-
6.0.x
238236
8.0.x
239237
240238
- name: Build

docs/release-notes.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 1.7.0
2+
3+
- Add ` /guard:cf` by @johnthcall in #26.
4+
- Where possible, increase "buffer size" variable resolution to `int64_t` (#28).
5+
- Native and managed dependencies upgraded to the latest versions.
6+
17
## 1.6.3
28

39
- Native build for Linux [musl](https://wiki.musl-libc.org/projects-using-musl.html) runtime.

managed/IronCompress.Benchmarks/IronCompress.Benchmarks.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
11+
<PackageReference Include="BenchmarkDotNet" Version="0.15.2" />
1212
</ItemGroup>
1313

1414
<ItemGroup>

managed/IronCompress.Test/IronCompress.Test.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
<PropertyGroup>
44
<IsPackable>false</IsPackable>
55
<LangVersion>latest</LangVersion>
6-
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
6+
<TargetFrameworks>net8.0</TargetFrameworks>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
11-
<PackageReference Include="xunit" Version="2.9.1" />
12-
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
11+
<PackageReference Include="xunit" Version="2.9.3" />
12+
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.1">
1313
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1414
<PrivateAssets>all</PrivateAssets>
1515
</PackageReference>
16-
<PackageReference Include="coverlet.collector" Version="6.0.2">
16+
<PackageReference Include="coverlet.collector" Version="6.0.4">
1717
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1818
<PrivateAssets>all</PrivateAssets>
1919
</PackageReference>

managed/IronCompress/Iron.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public Iron(ArrayPool<byte>? allocPool = null) {
7272
public IronCompressResult Compress(
7373
Codec codec,
7474
ReadOnlySpan<byte> input,
75-
int? outputLength = null,
75+
long? outputLength = null,
7676
CompressionLevel compressionLevel = CompressionLevel.Optimal) {
7777

7878
if(ForcePlatform != null) {
@@ -96,7 +96,7 @@ public IronCompressResult Compress(
9696
public IronCompressResult Decompress(
9797
Codec codec,
9898
ReadOnlySpan<byte> input,
99-
int? outputLength = null) {
99+
long? outputLength = null) {
100100

101101
if(ForcePlatform != null) {
102102
if(ForcePlatform == Platform.Native) {
@@ -132,9 +132,9 @@ private IronCompressResult NativeCompressOrDecompress(
132132
Codec codec,
133133
ReadOnlySpan<byte> input,
134134
CompressionLevel compressionLevel,
135-
int? outputLength = null) {
135+
long? outputLength = null) {
136136

137-
int len = 0;
137+
long len = 0;
138138
int level = ToNativeCompressionLevel(compressionLevel);
139139
unsafe {
140140
fixed(byte* inputPtr = input) {
@@ -150,9 +150,9 @@ private IronCompressResult NativeCompressOrDecompress(
150150
len = outputLength.Value;
151151
}
152152

153-
byte[] output = _allocPool == null
153+
byte[] output = (_allocPool == null || len > int.MaxValue)
154154
? new byte[len]
155-
: _allocPool.Rent(len);
155+
: _allocPool.Rent((int)len);
156156

157157
fixed(byte* outputPtr = output) {
158158
try {
@@ -181,7 +181,7 @@ private IronCompressResult ManagedCompressOrDecompress(
181181
Codec codec,
182182
ReadOnlySpan<byte> input,
183183
CompressionLevel compressionLevel,
184-
int? outputLength = null) {
184+
long? outputLength = null) {
185185

186186
byte[] result;
187187

managed/IronCompress/IronCompress.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@
3636

3737
<ItemGroup>
3838
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
39-
<PackageReference Include="Snappier" Version="1.1.6" />
40-
<PackageReference Include="ZstdSharp.Port" Version="0.8.1" />
39+
<PackageReference Include="Snappier" Version="1.2.0" />
40+
<PackageReference Include="ZstdSharp.Port" Version="0.8.5" />
4141
</ItemGroup>
4242

4343
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
44-
<PackageReference Include="System.Buffers" Version="4.5.1" />
45-
<PackageReference Include="System.Memory" Version="4.5.5" />
44+
<PackageReference Include="System.Buffers" Version="4.6.1" />
45+
<PackageReference Include="System.Memory" Version="4.6.3" />
4646
</ItemGroup>
4747

4848

managed/IronCompress/IronCompressResult.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace IronCompress {
66
/// </summary>
77
public class IronCompressResult : IDisposable {
88
private readonly byte[] _data;
9-
private readonly int _dataSize;
9+
private readonly long _dataSize;
1010
private ArrayPool<byte>? _arrayPool;
1111

1212
/// <summary>
@@ -15,15 +15,15 @@ public class IronCompressResult : IDisposable {
1515
/// <param name="data">Data referenced by result.</param>
1616
/// <param name="dataSize">If data size is difference from input array size, pass the size explicitly.</param>
1717
/// <param name="arrayPool">When passed, will return to pool on dispose</param>
18-
public IronCompressResult(byte[] data, Codec codec, bool nativeUsed, int dataSize = -1, ArrayPool<byte>? arrayPool = null) {
18+
public IronCompressResult(byte[] data, Codec codec, bool nativeUsed, long dataSize = -1, ArrayPool<byte>? arrayPool = null) {
1919
_data = data;
2020
Codec = codec;
2121
NativeUsed = nativeUsed;
2222
_dataSize = dataSize;
2323
_arrayPool = arrayPool;
2424
}
2525

26-
public int Length => _dataSize == -1 ? _data.Length : _dataSize;
26+
public long Length => _dataSize == -1 ? _data.Length : _dataSize;
2727

2828
/// <summary>
2929
/// Compression codec used
@@ -35,8 +35,12 @@ public IronCompressResult(byte[] data, Codec codec, bool nativeUsed, int dataSiz
3535
/// </summary>
3636
public bool NativeUsed { get; }
3737

38+
/// <summary>
39+
/// TODO: might overflow
40+
/// </summary>
41+
/// <returns></returns>
3842
public Span<byte> AsSpan() =>
39-
_data.AsSpan(0, Length);
43+
_data.AsSpan(0, (int)Length);
4044

4145
public static implicit operator Span<byte>(IronCompressResult r) => r.AsSpan();
4246

managed/IronCompress/Native.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ private static IntPtr DllImportResolver(string libraryName, Assembly assembly, D
4141
internal static extern unsafe bool iron_compress(bool compress,
4242
int codec,
4343
byte* inputBuffer,
44-
int inputBufferSize,
44+
long inputBufferSize,
4545
byte* outputBuffer,
46-
int* outputBufferSize,
46+
long* outputBufferSize,
4747
int compressionLevel);
4848

4949
[DllImport(LibName)]

native/api.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@ bool lzo_initialised{ false };
3434
bool compress_snappy(
3535
bool compress,
3636
char* input_buffer,
37-
int input_buffer_size,
37+
int64_t input_buffer_size,
3838
char* output_buffer,
39-
int* output_buffer_size) {
39+
int64_t* output_buffer_size) {
4040
if(output_buffer == nullptr) {
4141
if(compress)
42-
*output_buffer_size = snappy::MaxCompressedLength(input_buffer_size);
42+
*output_buffer_size = static_cast<int64_t>(snappy::MaxCompressedLength(input_buffer_size));
4343
else {
4444
size_t length;
4545
if(snappy::GetUncompressedLength(input_buffer, input_buffer_size, &length)) {
46-
*output_buffer_size = length;
46+
*output_buffer_size = static_cast<int64_t>(length);
4747
} else {
4848
*output_buffer_size = 0;
4949
return false;
@@ -69,15 +69,15 @@ bool compress_snappy(
6969
bool compress_zstd(
7070
bool compress,
7171
char* input_buffer,
72-
int input_buffer_size,
72+
int64_t input_buffer_size,
7373
char* output_buffer,
74-
int* output_buffer_size,
74+
int64_t* output_buffer_size,
7575
compression_level compression_level) {
7676
if(output_buffer == nullptr) {
7777
if(compress) {
78-
*output_buffer_size = ZSTD_compressBound(input_buffer_size);
78+
*output_buffer_size = static_cast<int64_t>(ZSTD_compressBound(input_buffer_size));
7979
} else {
80-
*output_buffer_size = ZSTD_getFrameContentSize(input_buffer, input_buffer_size);
80+
*output_buffer_size = static_cast<int64_t>(ZSTD_getFrameContentSize(input_buffer, input_buffer_size));
8181
}
8282
return true;
8383
}
@@ -159,9 +159,9 @@ bool compress_zstd(
159159
bool compress_brotli(
160160
bool compress,
161161
char* input_buffer,
162-
int input_buffer_size,
162+
int64_t input_buffer_size,
163163
char* output_buffer,
164-
int* output_buffer_size,
164+
int64_t* output_buffer_size,
165165
compression_level compression_level) {
166166

167167
if(output_buffer == nullptr) {
@@ -201,9 +201,9 @@ bool compress_brotli(
201201
bool compress_lzo(
202202
bool compress,
203203
char* input_buffer,
204-
int input_buffer_size,
204+
int64_t input_buffer_size,
205205
char* output_buffer,
206-
int* output_buffer_size)
206+
int64_t* output_buffer_size)
207207
{
208208
//minilzo sample: https://github.com/nemequ/lzo/blob/master/minilzo/testmini.c
209209

@@ -272,9 +272,9 @@ bool compress_lzo(
272272
bool compress_lz4(
273273
bool compress,
274274
char* input_buffer,
275-
int input_buffer_size,
275+
int64_t input_buffer_size,
276276
char* output_buffer,
277-
int* output_buffer_size,
277+
int64_t* output_buffer_size,
278278
compression_level compression_level) {
279279
if(output_buffer == nullptr) {
280280
if(compress) {
@@ -304,8 +304,8 @@ bool compress_lz4(
304304
return false;
305305
}
306306

307-
bool iron_compress(bool compress, compression_codec codec, char* input_buffer, int32_t input_buffer_size,
308-
char* output_buffer, int32_t* output_buffer_size, compression_level compression_level) {
307+
bool iron_compress(bool compress, compression_codec codec, char* input_buffer, int64_t input_buffer_size,
308+
char* output_buffer, int64_t* output_buffer_size, compression_level compression_level) {
309309

310310
if(!iron_is_supported(codec)) return false;
311311

native/api.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ extern "C"
4444
bool compress,
4545
compression_codec codec,
4646
char* input_buffer,
47-
int32_t input_buffer_size,
47+
int64_t input_buffer_size,
4848
char* output_buffer,
49-
int32_t* output_buffer_size,
49+
int64_t* output_buffer_size,
5050
compression_level compression_level);
5151

5252
/**

0 commit comments

Comments
 (0)