extlz4 0.2.5 → 0.3

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.
@@ -57,8 +57,8 @@ Q.Score is a measure of quality of the hash function.
57
57
  It depends on successfully passing SMHasher test set.
58
58
  10 is a perfect score.
59
59
 
60
- A 64-bits version, named XXH64, is available since r35.
61
- It offers much better speed, but for 64-bits applications only.
60
+ A 64-bit version, named XXH64, is available since r35.
61
+ It offers much better speed, but for 64-bit applications only.
62
62
  Name Speed on 64 bits Speed on 32 bits
63
63
  XXH64 13.8 GB/s 1.9 GB/s
64
64
  XXH32 6.8 GB/s 6.0 GB/s
@@ -80,18 +80,19 @@ typedef enum { XXH_OK=0, XXH_ERROR } XXH_errorcode;
80
80
 
81
81
 
82
82
  /* ****************************
83
- * API modifier
84
- ******************************/
85
- /** XXH_PRIVATE_API
86
- * This is useful to include xxhash functions in `static` mode
87
- * in order to inline them, and remove their symbol from the public list.
88
- * Methodology :
89
- * #define XXH_PRIVATE_API
90
- * #include "xxhash.h"
91
- * `xxhash.c` is automatically included.
92
- * It's not useful to compile and link it as a separate module.
93
- */
94
- #ifdef XXH_PRIVATE_API
83
+ * API modifier
84
+ ******************************/
85
+ /** XXH_INLINE_ALL (and XXH_PRIVATE_API)
86
+ * This is useful to include xxhash functions in `static` mode
87
+ * in order to inline them, and remove their symbol from the public list.
88
+ * Inlining can offer dramatic performance improvement on small keys.
89
+ * Methodology :
90
+ * #define XXH_INLINE_ALL
91
+ * #include "xxhash.h"
92
+ * `xxhash.c` is automatically included.
93
+ * It's not useful to compile and link it as a separate module.
94
+ */
95
+ #if defined(XXH_INLINE_ALL) || defined(XXH_PRIVATE_API)
95
96
  # ifndef XXH_STATIC_LINKING_ONLY
96
97
  # define XXH_STATIC_LINKING_ONLY
97
98
  # endif
@@ -102,23 +103,24 @@ typedef enum { XXH_OK=0, XXH_ERROR } XXH_errorcode;
102
103
  # elif defined(_MSC_VER)
103
104
  # define XXH_PUBLIC_API static __inline
104
105
  # else
105
- # define XXH_PUBLIC_API static /* this version may generate warnings for unused static functions; disable the relevant warning */
106
+ /* this version may generate warnings for unused static functions */
107
+ # define XXH_PUBLIC_API static
106
108
  # endif
107
109
  #else
108
110
  # define XXH_PUBLIC_API /* do nothing */
109
- #endif /* XXH_PRIVATE_API */
110
-
111
- /*!XXH_NAMESPACE, aka Namespace Emulation :
112
-
113
- If you want to include _and expose_ xxHash functions from within your own library,
114
- but also want to avoid symbol collisions with other libraries which may also include xxHash,
115
-
116
- you can use XXH_NAMESPACE, to automatically prefix any public symbol from xxhash library
117
- with the value of XXH_NAMESPACE (therefore, avoid NULL and numeric values).
118
-
119
- Note that no change is required within the calling program as long as it includes `xxhash.h` :
120
- regular symbol name will be automatically translated by this header.
121
- */
111
+ #endif /* XXH_INLINE_ALL || XXH_PRIVATE_API */
112
+
113
+ /*! XXH_NAMESPACE, aka Namespace Emulation :
114
+ *
115
+ * If you want to include _and expose_ xxHash functions from within your own library,
116
+ * but also want to avoid symbol collisions with other libraries which may also include xxHash,
117
+ *
118
+ * you can use XXH_NAMESPACE, to automatically prefix any public symbol from xxhash library
119
+ * with the value of XXH_NAMESPACE (therefore, avoid NULL and numeric values).
120
+ *
121
+ * Note that no change is required within the calling program as long as it includes `xxhash.h` :
122
+ * regular symbol name will be automatically translated by this header.
123
+ */
122
124
  #ifdef XXH_NAMESPACE
123
125
  # define XXH_CAT(A,B) A##B
124
126
  # define XXH_NAME2(A,B) XXH_CAT(A,B)
@@ -149,18 +151,18 @@ regular symbol name will be automatically translated by this header.
149
151
  ***************************************/
150
152
  #define XXH_VERSION_MAJOR 0
151
153
  #define XXH_VERSION_MINOR 6
152
- #define XXH_VERSION_RELEASE 2
154
+ #define XXH_VERSION_RELEASE 5
153
155
  #define XXH_VERSION_NUMBER (XXH_VERSION_MAJOR *100*100 + XXH_VERSION_MINOR *100 + XXH_VERSION_RELEASE)
154
156
  XXH_PUBLIC_API unsigned XXH_versionNumber (void);
155
157
 
156
158
 
157
159
  /*-**********************************************************************
158
- * 32-bits hash
160
+ * 32-bit hash
159
161
  ************************************************************************/
160
- typedef unsigned int XXH32_hash_t;
162
+ typedef unsigned int XXH32_hash_t;
161
163
 
162
164
  /*! XXH32() :
163
- Calculate the 32-bits hash of sequence "length" bytes stored at memory address "input".
165
+ Calculate the 32-bit hash of sequence "length" bytes stored at memory address "input".
164
166
  The memory between input & input+length must be valid (allocated and read-accessible).
165
167
  "seed" can be used to alter the result predictably.
166
168
  Speed on Core 2 Duo @ 3 GHz (single thread, SMHasher benchmark) : 5.4 GB/s */
@@ -177,26 +179,25 @@ XXH_PUBLIC_API XXH_errorcode XXH32_update (XXH32_state_t* statePtr, const void*
177
179
  XXH_PUBLIC_API XXH32_hash_t XXH32_digest (const XXH32_state_t* statePtr);
178
180
 
179
181
  /*
180
- These functions generate the xxHash of an input provided in multiple segments.
181
- Note that, for small input, they are slower than single-call functions, due to state management.
182
- For small input, prefer `XXH32()` and `XXH64()` .
183
-
184
- XXH state must first be allocated, using XXH*_createState() .
185
-
186
- Start a new hash by initializing state with a seed, using XXH*_reset().
187
-
188
- Then, feed the hash state by calling XXH*_update() as many times as necessary.
189
- Obviously, input must be allocated and read accessible.
190
- The function returns an error code, with 0 meaning OK, and any other value meaning there is an error.
191
-
192
- Finally, a hash value can be produced anytime, by using XXH*_digest().
193
- This function returns the nn-bits hash as an int or long long.
194
-
195
- It's still possible to continue inserting input into the hash state after a digest,
196
- and generate some new hashes later on, by calling again XXH*_digest().
197
-
198
- When done, free XXH state space if it was allocated dynamically.
199
- */
182
+ * Streaming functions generate the xxHash of an input provided in multiple segments.
183
+ * Note that, for small input, they are slower than single-call functions, due to state management.
184
+ * For small inputs, prefer `XXH32()` and `XXH64()`, which are better optimized.
185
+ *
186
+ * XXH state must first be allocated, using XXH*_createState() .
187
+ *
188
+ * Start a new hash by initializing state with a seed, using XXH*_reset().
189
+ *
190
+ * Then, feed the hash state by calling XXH*_update() as many times as necessary.
191
+ * The function returns an error code, with 0 meaning OK, and any other value meaning there is an error.
192
+ *
193
+ * Finally, a hash value can be produced anytime, by using XXH*_digest().
194
+ * This function returns the nn-bits hash as an int or long long.
195
+ *
196
+ * It's still possible to continue inserting input into the hash state after a digest,
197
+ * and generate some new hashes later on, by calling again XXH*_digest().
198
+ *
199
+ * When done, free XXH state space if it was allocated dynamically.
200
+ */
200
201
 
201
202
  /*====== Canonical representation ======*/
202
203
 
@@ -205,22 +206,22 @@ XXH_PUBLIC_API void XXH32_canonicalFromHash(XXH32_canonical_t* dst, XXH32_hash_t
205
206
  XXH_PUBLIC_API XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canonical_t* src);
206
207
 
207
208
  /* Default result type for XXH functions are primitive unsigned 32 and 64 bits.
208
- * The canonical representation uses human-readable write convention, aka big-endian (large digits first).
209
- * These functions allow transformation of hash result into and from its canonical format.
210
- * This way, hash values can be written into a file / memory, and remain comparable on different systems and programs.
211
- */
209
+ * The canonical representation uses human-readable write convention, aka big-endian (large digits first).
210
+ * These functions allow transformation of hash result into and from its canonical format.
211
+ * This way, hash values can be written into a file / memory, and remain comparable on different systems and programs.
212
+ */
212
213
 
213
214
 
214
215
  #ifndef XXH_NO_LONG_LONG
215
216
  /*-**********************************************************************
216
- * 64-bits hash
217
+ * 64-bit hash
217
218
  ************************************************************************/
218
219
  typedef unsigned long long XXH64_hash_t;
219
220
 
220
221
  /*! XXH64() :
221
- Calculate the 64-bits hash of sequence of length "len" stored at memory address "input".
222
+ Calculate the 64-bit hash of sequence of length "len" stored at memory address "input".
222
223
  "seed" can be used to alter the result predictably.
223
- This function runs faster on 64-bits systems, but slower on 32-bits systems (see benchmark).
224
+ This function runs faster on 64-bit systems, but slower on 32-bit systems (see benchmark).
224
225
  */
225
226
  XXH_PUBLIC_API XXH64_hash_t XXH64 (const void* input, size_t length, unsigned long long seed);
226
227
 
@@ -241,48 +242,82 @@ XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src
241
242
  #endif /* XXH_NO_LONG_LONG */
242
243
 
243
244
 
245
+
244
246
  #ifdef XXH_STATIC_LINKING_ONLY
245
247
 
246
248
  /* ================================================================================================
247
- This section contains definitions which are not guaranteed to remain stable.
249
+ This section contains declarations which are not guaranteed to remain stable.
248
250
  They may change in future versions, becoming incompatible with a different version of the library.
249
- They shall only be used with static linking.
250
- Never use these definitions in association with dynamic linking !
251
+ These declarations should only be used with static linking.
252
+ Never use them in association with dynamic linking !
251
253
  =================================================================================================== */
252
254
 
253
- /* These definitions are only meant to allow allocation of XXH state
254
- statically, on stack, or in a struct for example.
255
- Do not use members directly. */
256
-
257
- struct XXH32_state_s {
258
- unsigned total_len_32;
259
- unsigned large_len;
260
- unsigned v1;
261
- unsigned v2;
262
- unsigned v3;
263
- unsigned v4;
264
- unsigned mem32[4]; /* buffer defined as U32 for alignment */
265
- unsigned memsize;
266
- unsigned reserved; /* never read nor write, will be removed in a future version */
267
- }; /* typedef'd to XXH32_state_t */
268
-
269
- #ifndef XXH_NO_LONG_LONG
270
- struct XXH64_state_s {
271
- unsigned long long total_len;
272
- unsigned long long v1;
273
- unsigned long long v2;
274
- unsigned long long v3;
275
- unsigned long long v4;
276
- unsigned long long mem64[4]; /* buffer defined as U64 for alignment */
277
- unsigned memsize;
278
- unsigned reserved[2]; /* never read nor write, will be removed in a future version */
279
- }; /* typedef'd to XXH64_state_t */
255
+ /* These definitions are only present to allow
256
+ * static allocation of XXH state, on stack or in a struct for example.
257
+ * Never **ever** use members directly. */
258
+
259
+ #if !defined (__VMS) \
260
+ && (defined (__cplusplus) \
261
+ || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) )
262
+ # include <stdint.h>
263
+
264
+ struct XXH32_state_s {
265
+ uint32_t total_len_32;
266
+ uint32_t large_len;
267
+ uint32_t v1;
268
+ uint32_t v2;
269
+ uint32_t v3;
270
+ uint32_t v4;
271
+ uint32_t mem32[4];
272
+ uint32_t memsize;
273
+ uint32_t reserved; /* never read nor write, might be removed in a future version */
274
+ }; /* typedef'd to XXH32_state_t */
275
+
276
+ struct XXH64_state_s {
277
+ uint64_t total_len;
278
+ uint64_t v1;
279
+ uint64_t v2;
280
+ uint64_t v3;
281
+ uint64_t v4;
282
+ uint64_t mem64[4];
283
+ uint32_t memsize;
284
+ uint32_t reserved[2]; /* never read nor write, might be removed in a future version */
285
+ }; /* typedef'd to XXH64_state_t */
286
+
287
+ # else
288
+
289
+ struct XXH32_state_s {
290
+ unsigned total_len_32;
291
+ unsigned large_len;
292
+ unsigned v1;
293
+ unsigned v2;
294
+ unsigned v3;
295
+ unsigned v4;
296
+ unsigned mem32[4];
297
+ unsigned memsize;
298
+ unsigned reserved; /* never read nor write, might be removed in a future version */
299
+ }; /* typedef'd to XXH32_state_t */
300
+
301
+ # ifndef XXH_NO_LONG_LONG /* remove 64-bit support */
302
+ struct XXH64_state_s {
303
+ unsigned long long total_len;
304
+ unsigned long long v1;
305
+ unsigned long long v2;
306
+ unsigned long long v3;
307
+ unsigned long long v4;
308
+ unsigned long long mem64[4];
309
+ unsigned memsize;
310
+ unsigned reserved[2]; /* never read nor write, might be removed in a future version */
311
+ }; /* typedef'd to XXH64_state_t */
312
+ # endif
313
+
314
+ # endif
315
+
316
+
317
+ #if defined(XXH_INLINE_ALL) || defined(XXH_PRIVATE_API)
318
+ # include "xxhash.c" /* include xxhash function bodies as `static`, for inlining */
280
319
  #endif
281
320
 
282
- # ifdef XXH_PRIVATE_API
283
- # include "xxhash.c" /* include xxhash function bodies as `static`, for inlining */
284
- # endif
285
-
286
321
  #endif /* XXH_STATIC_LINKING_ONLY */
287
322
 
288
323
 
@@ -504,7 +504,7 @@ blkenc_update(int argc, VALUE argv[], VALUE enc)
504
504
  int s = p->traits->update(p->context, srcp, RSTRING_PTR(dest), srcsize, maxsize, p->level);
505
505
  if (s <= 0) {
506
506
  rb_raise(extlz4_eError,
507
- "destsize too small (given destsize is %zu)",
507
+ "destsize too small (given destsize is %"PRIuSIZE")",
508
508
  rb_str_capacity(dest));
509
509
  }
510
510
  p->prefixsize = p->traits->savedict(p->context, p->prefix, sizeof(p->prefix));
@@ -684,7 +684,7 @@ blkenc_s_encode(int argc, VALUE argv[], VALUE lz4)
684
684
  size_t srcsize = RSTRING_LEN(src);
685
685
  if (srcsize > LZ4_MAX_INPUT_SIZE) {
686
686
  rb_raise(extlz4_eError,
687
- "source size is too big for lz4 encode (given %zu, but max %zu bytes)",
687
+ "source size is too big for lz4 encode (given %"PRIuSIZE", but max %"PRIuSIZE" bytes)",
688
688
  srcsize, (size_t)LZ4_MAX_INPUT_SIZE);
689
689
  }
690
690
  aux_str_reserve(dest, maxsize);
@@ -3,29 +3,6 @@
3
3
  #endif
4
4
 
5
5
  #include "../contrib/lz4/lib/lz4.c"
6
-
7
- #define LZ4_isLittleEndian amalg_LZ4_isLittleEndian
8
- #define LZ4_read16 amalg_LZ4_read16
9
- #define LZ4_read32 amalg_LZ4_read32
10
- #define LZ4_read_ARCH amalg_LZ4_read_ARCH
11
- #define LZ4_write16 amalg_LZ4_write16
12
- #define LZ4_write32 amalg_LZ4_write32
13
- #define LZ4_readLE16 amalg_LZ4_readLE16
14
- #define LZ4_writeLE16 amalg_LZ4_writeLE16
15
- #define LZ4_copy8 amalg_LZ4_copy8
16
- #define LZ4_wildCopy amalg_LZ4_wildCopy
17
- #define LZ4_minLength amalg_LZ4_minLength
18
- #define LZ4_NbCommonBytes amalg_LZ4_NbCommonBytes
19
- #define LZ4_count amalg_LZ4_count
20
- #define limitedOutput amalg_limitedOutput
21
- #define limitedOutput_directive amalg_limitedOutput_directive
22
- #define unalign amalg_unalign
23
6
  #include "../contrib/lz4/lib/lz4hc.c"
24
-
25
- #undef ALLOCATOR
26
- #undef KB
27
- #undef MB
28
- #undef GB
29
7
  #include "../contrib/lz4/lib/lz4frame.c"
30
-
31
8
  #include "../contrib/lz4/lib/xxhash.c"
data/gemstub.rb CHANGED
@@ -1,8 +1,7 @@
1
- unless File.read("README.md", 4096) =~ /^\s*\*\s*version:{1,2}\s*(.+)/i
1
+ unless ver = File.read("README.md").scan(/^\s*[\*\-]\s*version:{1,2}\s*(.+)/i).flatten[-1]
2
2
  raise "バージョン情報が README.md に見つかりません"
3
3
  end
4
4
 
5
- ver = $1
6
5
  verfile = "lib/extlz4/version.rb"
7
6
  LIB << verfile
8
7
 
@@ -29,12 +28,13 @@ GEMSTUB = Gem::Specification.new do |s|
29
28
  s.version = ver
30
29
  s.summary = "ruby bindings for LZ4"
31
30
  s.description = <<EOS
32
- ruby bindings for LZ4 <https://github.com/lz4/lz4>.
31
+ unofficial ruby bindings for LZ4 <https://github.com/lz4/lz4>.
33
32
  EOS
34
33
  s.homepage = "https://github.com/dearblue/ruby-extlz4"
35
34
  s.license = "BSD-2-Clause"
36
35
  s.author = "dearblue"
37
36
  s.email = "dearblue@users.noreply.github.com"
38
37
 
39
- s.add_development_dependency "rake"
38
+ s.add_development_dependency "rake", "~> 1.12", ">= 1.12.3"
39
+ s.add_development_dependency "test-unit", "~> 3.2", ">= 3.2.7"
40
40
  end
@@ -322,6 +322,52 @@ module LZ4
322
322
  alias block_stream_decompress block_stream_decode
323
323
  alias block_stream_uncompress block_stream_decode
324
324
  end
325
+
326
+ refine String do
327
+ #
328
+ # call-seq:
329
+ # to_lz4frame(level = 1, opts = {}) -> lz4 frame'd data
330
+ #
331
+ def to_lz4frame(*args)
332
+ LZ4.encode self, *args
333
+ end
334
+
335
+ #
336
+ # call-seq:
337
+ # unlz4frame -> decoded data
338
+ #
339
+ def unlz4frame(*args, &block)
340
+ LZ4.decode self, *args, &block
341
+ end
342
+
343
+ def to_lz4block(*args)
344
+ LZ4.block_encode(self, *args)
345
+ end
346
+
347
+ def unlz4block(*args)
348
+ LZ4.block_decode(self, *args)
349
+ end
350
+ end
351
+
352
+ refine Object do
353
+ #
354
+ # call-seq:
355
+ # to_lz4frame(level = 1, opts = {}) -> stream encoder
356
+ # to_lz4frame(level = 1, opts = {}) { |stream_encoder| ... } -> yield_status
357
+ #
358
+ def to_lz4frame(*args, &block)
359
+ LZ4.encode self, *args, &block
360
+ end
361
+
362
+ #
363
+ # call-seq:
364
+ # -> decoder
365
+ # { |decoder| ... } -> yield_status
366
+ #
367
+ def unlz4frame(*args, &block)
368
+ LZ4.decode self, *args, &block
369
+ end
370
+ end
325
371
  end
326
372
 
327
373
  require_relative "extlz4/compat"
@@ -1,3 +1,3 @@
1
1
  module LZ4
2
- VERSION = "0.2.5"
2
+ VERSION = "0.3"
3
3
  end
metadata CHANGED
@@ -1,32 +1,58 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: extlz4
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - dearblue
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-13 00:00:00.000000000 Z
11
+ date: 2019-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
17
20
  - - ">="
18
21
  - !ruby/object:Gem::Version
19
- version: '0'
22
+ version: 1.12.3
20
23
  type: :development
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.12'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.12.3
33
+ - !ruby/object:Gem::Dependency
34
+ name: test-unit
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '3.2'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 3.2.7
43
+ type: :development
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '3.2'
24
50
  - - ">="
25
51
  - !ruby/object:Gem::Version
26
- version: '0'
27
- description: 'ruby bindings for LZ4 <https://github.com/lz4/lz4>.
52
+ version: 3.2.7
53
+ description: 'unofficial ruby bindings for LZ4 <https://github.com/lz4/lz4>.
28
54
 
29
- '
55
+ '
30
56
  email: dearblue@users.noreply.github.com
31
57
  executables:
32
58
  - extlz4
@@ -62,7 +88,6 @@ files:
62
88
  - contrib/lz4/LICENSE
63
89
  - contrib/lz4/NEWS
64
90
  - contrib/lz4/README.md
65
- - contrib/lz4/circle.yml
66
91
  - contrib/lz4/lib/LICENSE
67
92
  - contrib/lz4/lib/README.md
68
93
  - contrib/lz4/lib/liblz4.pc.in
@@ -73,7 +98,6 @@ files:
73
98
  - contrib/lz4/lib/lz4frame_static.h
74
99
  - contrib/lz4/lib/lz4hc.c
75
100
  - contrib/lz4/lib/lz4hc.h
76
- - contrib/lz4/lib/lz4opt.h
77
101
  - contrib/lz4/lib/xxhash.c
78
102
  - contrib/lz4/lib/xxhash.h
79
103
  - examples/frameapi.rb
@@ -118,8 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
142
  - !ruby/object:Gem::Version
119
143
  version: '0'
120
144
  requirements: []
121
- rubyforge_project:
122
- rubygems_version: 2.7.4
145
+ rubygems_version: 3.0.3
123
146
  signing_key:
124
147
  specification_version: 4
125
148
  summary: ruby bindings for LZ4