zstd-ruby 1.5.4.1 → 1.5.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 20843652df6bf499ef8cbf75a75e9b9c2bf1a445d7dc1ae9fc48faa07e8af768
4
- data.tar.gz: 52939d134568bf22f7633a28624ebb1574b72cc33711759c62da8a7971828a57
3
+ metadata.gz: ae3a3eda181783c9e14f147718c560c01e24a9f649feda4c52dcd76cb5e918e3
4
+ data.tar.gz: b02161ceee8747f2f061b235168f8dfedb761db1f303796a4fd75ce6da646706
5
5
  SHA512:
6
- metadata.gz: 4eee9c6badff4d9cbd516b94ec5ec488bff58d25a59ec9a6de9e7aa5afcb117b8eb6e69bc319e9dd8a8f69b8c5dbd1504e0001cf7e312b27fad8c0ed63bdcf64
7
- data.tar.gz: 518fffdbde3535b6e104d0733529db99db98304b99f3b0cc5d27edfabfe3c5922d05d0e0e4cb7cf1bc051dfb4651a886921b3faf5a61b24dec2a99f472150551
6
+ metadata.gz: 906616393e8f417aff8fa2bac393f5b1215a0f8928cb222f2bcc505b5097d91c69f2179d3fde5c6935112d5c3c167990468d3fd697215c61670fbdd7b1376a17
7
+ data.tar.gz: 15b6a06a46cbf76a2cb725d3fb0ab70b9f8ca9891a04ac013f2043cd2a5b8eff124e19c4c4a1d920410e6d65414c404d3e8e913d3c722f34880960d8e6c126b3
data/.gitignore CHANGED
@@ -19,3 +19,5 @@ vendor/
19
19
  .rspec_status
20
20
 
21
21
  .ruby-version
22
+
23
+ .vscode
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/zstd-ruby.svg)](https://badge.fury.io/rb/zstd-ruby)
2
- ![Build Status](https://github.com/SpringMT/zstd-ruby/actions/workflows/ruby.yml/badge.svg?branch=master)
2
+ ![Build Status](https://github.com/SpringMT/zstd-ruby/actions/workflows/ruby.yml/badge.svg?branch=main)
3
3
 
4
4
  # zstd-ruby
5
5
 
@@ -10,7 +10,7 @@ See https://github.com/facebook/zstd
10
10
  Fork from https://github.com/jarredholman/ruby-zstd.
11
11
 
12
12
  ## Zstd version
13
- v1.5.4 (https://github.com/facebook/zstd/tree/v1.5.4)
13
+ v1.5.5 (https://github.com/facebook/zstd/tree/v1.5.5)
14
14
 
15
15
  ## Installation
16
16
 
@@ -87,7 +87,7 @@ result << stream.decompress(cstr[0, 10])
87
87
  result << stream.decompress(cstr[10..-1])
88
88
  ```
89
89
 
90
- ### Skippable flame
90
+ ### Skippable frame
91
91
 
92
92
  ```ruby
93
93
  compressed_data_with_skippable_frame = Zstd.write_skippable_frame(compressed_data, "sample data")
@@ -1,5 +1,7 @@
1
1
  require "mkmf"
2
2
 
3
+ have_func('rb_gc_mark_movable')
4
+
3
5
  $CFLAGS = '-I. -O3 -std=c99 -DZSTD_STATIC_LINKING_ONLY'
4
6
  $CPPFLAGS += " -fdeclspec" if CONFIG['CXX'] =~ /clang/
5
7
 
@@ -0,0 +1,55 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under both the BSD-style license (found in the
6
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
7
+ * in the COPYING file in the root directory of this source tree).
8
+ * You may select, at your option, one of the above-listed licenses.
9
+ */
10
+
11
+ /* This file provides custom allocation primitives
12
+ */
13
+
14
+ #define ZSTD_DEPS_NEED_MALLOC
15
+ #include "zstd_deps.h" /* ZSTD_malloc, ZSTD_calloc, ZSTD_free, ZSTD_memset */
16
+
17
+ #include "mem.h" /* MEM_STATIC */
18
+ #define ZSTD_STATIC_LINKING_ONLY
19
+ #include "../zstd.h" /* ZSTD_customMem */
20
+
21
+ #ifndef ZSTD_ALLOCATIONS_H
22
+ #define ZSTD_ALLOCATIONS_H
23
+
24
+ /* custom memory allocation functions */
25
+
26
+ MEM_STATIC void* ZSTD_customMalloc(size_t size, ZSTD_customMem customMem)
27
+ {
28
+ if (customMem.customAlloc)
29
+ return customMem.customAlloc(customMem.opaque, size);
30
+ return ZSTD_malloc(size);
31
+ }
32
+
33
+ MEM_STATIC void* ZSTD_customCalloc(size_t size, ZSTD_customMem customMem)
34
+ {
35
+ if (customMem.customAlloc) {
36
+ /* calloc implemented as malloc+memset;
37
+ * not as efficient as calloc, but next best guess for custom malloc */
38
+ void* const ptr = customMem.customAlloc(customMem.opaque, size);
39
+ ZSTD_memset(ptr, 0, size);
40
+ return ptr;
41
+ }
42
+ return ZSTD_calloc(1, size);
43
+ }
44
+
45
+ MEM_STATIC void ZSTD_customFree(void* ptr, ZSTD_customMem customMem)
46
+ {
47
+ if (ptr!=NULL) {
48
+ if (customMem.customFree)
49
+ customMem.customFree(customMem.opaque, ptr);
50
+ else
51
+ ZSTD_free(ptr);
52
+ }
53
+ }
54
+
55
+ #endif /* ZSTD_ALLOCATIONS_H */
@@ -17,7 +17,7 @@ MEM_STATIC unsigned ZSTD_countTrailingZeros32_fallback(U32 val)
17
17
  {
18
18
  assert(val != 0);
19
19
  {
20
- static const int DeBruijnBytePos[32] = {0, 1, 28, 2, 29, 14, 24, 3,
20
+ static const U32 DeBruijnBytePos[32] = {0, 1, 28, 2, 29, 14, 24, 3,
21
21
  30, 22, 20, 15, 25, 17, 4, 8,
22
22
  31, 27, 13, 23, 21, 19, 16, 7,
23
23
  26, 12, 18, 6, 11, 5, 10, 9};
@@ -30,7 +30,7 @@ MEM_STATIC unsigned ZSTD_countTrailingZeros32(U32 val)
30
30
  assert(val != 0);
31
31
  # if defined(_MSC_VER)
32
32
  # if STATIC_BMI2 == 1
33
- return _tzcnt_u32(val);
33
+ return (unsigned)_tzcnt_u32(val);
34
34
  # else
35
35
  if (val != 0) {
36
36
  unsigned long r;
@@ -69,7 +69,7 @@ MEM_STATIC unsigned ZSTD_countLeadingZeros32(U32 val)
69
69
  assert(val != 0);
70
70
  # if defined(_MSC_VER)
71
71
  # if STATIC_BMI2 == 1
72
- return _lzcnt_u32(val);
72
+ return (unsigned)_lzcnt_u32(val);
73
73
  # else
74
74
  if (val != 0) {
75
75
  unsigned long r;
@@ -92,7 +92,7 @@ MEM_STATIC unsigned ZSTD_countTrailingZeros64(U64 val)
92
92
  assert(val != 0);
93
93
  # if defined(_MSC_VER) && defined(_WIN64)
94
94
  # if STATIC_BMI2 == 1
95
- return _tzcnt_u64(val);
95
+ return (unsigned)_tzcnt_u64(val);
96
96
  # else
97
97
  if (val != 0) {
98
98
  unsigned long r;
@@ -123,7 +123,7 @@ MEM_STATIC unsigned ZSTD_countLeadingZeros64(U64 val)
123
123
  assert(val != 0);
124
124
  # if defined(_MSC_VER) && defined(_WIN64)
125
125
  # if STATIC_BMI2 == 1
126
- return _lzcnt_u64(val);
126
+ return (unsigned)_lzcnt_u64(val);
127
127
  # else
128
128
  if (val != 0) {
129
129
  unsigned long r;
@@ -172,4 +172,29 @@ MEM_STATIC unsigned ZSTD_highbit32(U32 val) /* compress, dictBuilder, decodeCo
172
172
  return 31 - ZSTD_countLeadingZeros32(val);
173
173
  }
174
174
 
175
+ /* ZSTD_rotateRight_*():
176
+ * Rotates a bitfield to the right by "count" bits.
177
+ * https://en.wikipedia.org/w/index.php?title=Circular_shift&oldid=991635599#Implementing_circular_shifts
178
+ */
179
+ MEM_STATIC
180
+ U64 ZSTD_rotateRight_U64(U64 const value, U32 count) {
181
+ assert(count < 64);
182
+ count &= 0x3F; /* for fickle pattern recognition */
183
+ return (value >> count) | (U64)(value << ((0U - count) & 0x3F));
184
+ }
185
+
186
+ MEM_STATIC
187
+ U32 ZSTD_rotateRight_U32(U32 const value, U32 count) {
188
+ assert(count < 32);
189
+ count &= 0x1F; /* for fickle pattern recognition */
190
+ return (value >> count) | (U32)(value << ((0U - count) & 0x1F));
191
+ }
192
+
193
+ MEM_STATIC
194
+ U16 ZSTD_rotateRight_U16(U16 const value, U32 count) {
195
+ assert(count < 16);
196
+ count &= 0x0F; /* for fickle pattern recognition */
197
+ return (value >> count) | (U16)(value << ((0U - count) & 0x0F));
198
+ }
199
+
175
200
  #endif /* ZSTD_BITS_H */
@@ -396,7 +396,7 @@ MEM_STATIC BIT_DStream_status BIT_reloadDStreamFast(BIT_DStream_t* bitD)
396
396
  * This function is safe, it guarantees it will not read beyond src buffer.
397
397
  * @return : status of `BIT_DStream_t` internal register.
398
398
  * when status == BIT_DStream_unfinished, internal register is filled with at least 25 or 57 bits */
399
- MEM_STATIC BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD)
399
+ MEM_STATIC FORCE_INLINE_ATTR BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD)
400
400
  {
401
401
  if (bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8)) /* overflow detected, like end of stream */
402
402
  return BIT_DStream_overflow;
@@ -311,6 +311,10 @@ void __msan_poison(const volatile void *a, size_t size);
311
311
  /* Returns the offset of the first (at least partially) poisoned byte in the
312
312
  memory range, or -1 if the whole range is good. */
313
313
  intptr_t __msan_test_shadow(const volatile void *x, size_t size);
314
+
315
+ /* Print shadow and origin for the memory range to stderr in a human-readable
316
+ format. */
317
+ void __msan_print_shadow(const volatile void *x, size_t size);
314
318
  #endif
315
319
 
316
320
  #if ZSTD_ADDRESS_SANITIZER && !defined(ZSTD_ASAN_DONT_POISON_WORKSPACE)
@@ -10,9 +10,9 @@
10
10
 
11
11
 
12
12
  /* ====== Dependencies ======= */
13
+ #include "../common/allocations.h" /* ZSTD_customCalloc, ZSTD_customFree */
13
14
  #include "zstd_deps.h" /* size_t */
14
15
  #include "debug.h" /* assert */
15
- #include "zstd_internal.h" /* ZSTD_customCalloc, ZSTD_customFree */
16
16
  #include "pool.h"
17
17
 
18
18
  /* ====== Compiler specifics ====== */
@@ -47,7 +47,7 @@ static unsigned __stdcall worker(void *arg)
47
47
  void* (*start_routine)(void*);
48
48
  void* thread_arg;
49
49
 
50
- /* Inialized thread_arg and start_routine and signal main thread that we don't need it
50
+ /* Initialized thread_arg and start_routine and signal main thread that we don't need it
51
51
  * to wait any longer.
52
52
  */
53
53
  {
@@ -14,7 +14,6 @@
14
14
  * Dependencies
15
15
  ***************************************/
16
16
  #define ZSTD_DEPS_NEED_MALLOC
17
- #include "zstd_deps.h" /* ZSTD_malloc, ZSTD_calloc, ZSTD_free, ZSTD_memset */
18
17
  #include "error_private.h"
19
18
  #include "zstd_internal.h"
20
19
 
@@ -47,37 +46,3 @@ ZSTD_ErrorCode ZSTD_getErrorCode(size_t code) { return ERR_getErrorCode(code); }
47
46
  /*! ZSTD_getErrorString() :
48
47
  * provides error code string from enum */
49
48
  const char* ZSTD_getErrorString(ZSTD_ErrorCode code) { return ERR_getErrorString(code); }
50
-
51
-
52
-
53
- /*=**************************************************************
54
- * Custom allocator
55
- ****************************************************************/
56
- void* ZSTD_customMalloc(size_t size, ZSTD_customMem customMem)
57
- {
58
- if (customMem.customAlloc)
59
- return customMem.customAlloc(customMem.opaque, size);
60
- return ZSTD_malloc(size);
61
- }
62
-
63
- void* ZSTD_customCalloc(size_t size, ZSTD_customMem customMem)
64
- {
65
- if (customMem.customAlloc) {
66
- /* calloc implemented as malloc+memset;
67
- * not as efficient as calloc, but next best guess for custom malloc */
68
- void* const ptr = customMem.customAlloc(customMem.opaque, size);
69
- ZSTD_memset(ptr, 0, size);
70
- return ptr;
71
- }
72
- return ZSTD_calloc(1, size);
73
- }
74
-
75
- void ZSTD_customFree(void* ptr, ZSTD_customMem customMem)
76
- {
77
- if (ptr!=NULL) {
78
- if (customMem.customFree)
79
- customMem.customFree(customMem.opaque, ptr);
80
- else
81
- ZSTD_free(ptr);
82
- }
83
- }
@@ -350,11 +350,6 @@ typedef struct {
350
350
  const seqStore_t* ZSTD_getSeqStore(const ZSTD_CCtx* ctx); /* compress & dictBuilder */
351
351
  int ZSTD_seqToCodes(const seqStore_t* seqStorePtr); /* compress, dictBuilder, decodeCorpus (shouldn't get its definition from here) */
352
352
 
353
- /* custom memory allocation functions */
354
- void* ZSTD_customMalloc(size_t size, ZSTD_customMem customMem);
355
- void* ZSTD_customCalloc(size_t size, ZSTD_customMem customMem);
356
- void ZSTD_customFree(void* ptr, ZSTD_customMem customMem);
357
-
358
353
 
359
354
  /* ZSTD_invalidateRepCodes() :
360
355
  * ensures next compression will not use repcodes from previous block.