zstdlib 0.1.0-x86-mingw32

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.
Files changed (104) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGES.md +9 -0
  3. data/Gemfile +3 -0
  4. data/README.md +96 -0
  5. data/Rakefile +29 -0
  6. data/ext/zstdlib/extconf.rb +53 -0
  7. data/ext/zstdlib/ruby/zlib-2.2/zlib.c +4659 -0
  8. data/ext/zstdlib/ruby/zlib-2.3/zlib.c +4686 -0
  9. data/ext/zstdlib/ruby/zlib-2.4/zlib.c +4843 -0
  10. data/ext/zstdlib/ruby/zlib-2.5/zlib.c +4848 -0
  11. data/ext/zstdlib/ruby/zlib-2.6/zlib.c +4890 -0
  12. data/ext/zstdlib/zlib-1.2.11/adler32.c +186 -0
  13. data/ext/zstdlib/zlib-1.2.11/compress.c +86 -0
  14. data/ext/zstdlib/zlib-1.2.11/crc32.c +442 -0
  15. data/ext/zstdlib/zlib-1.2.11/crc32.h +441 -0
  16. data/ext/zstdlib/zlib-1.2.11/deflate.c +2163 -0
  17. data/ext/zstdlib/zlib-1.2.11/deflate.h +349 -0
  18. data/ext/zstdlib/zlib-1.2.11/gzclose.c +25 -0
  19. data/ext/zstdlib/zlib-1.2.11/gzguts.h +218 -0
  20. data/ext/zstdlib/zlib-1.2.11/gzlib.c +637 -0
  21. data/ext/zstdlib/zlib-1.2.11/gzread.c +654 -0
  22. data/ext/zstdlib/zlib-1.2.11/gzwrite.c +665 -0
  23. data/ext/zstdlib/zlib-1.2.11/infback.c +640 -0
  24. data/ext/zstdlib/zlib-1.2.11/inffast.c +323 -0
  25. data/ext/zstdlib/zlib-1.2.11/inffast.h +11 -0
  26. data/ext/zstdlib/zlib-1.2.11/inffixed.h +94 -0
  27. data/ext/zstdlib/zlib-1.2.11/inflate.c +1561 -0
  28. data/ext/zstdlib/zlib-1.2.11/inflate.h +125 -0
  29. data/ext/zstdlib/zlib-1.2.11/inftrees.c +304 -0
  30. data/ext/zstdlib/zlib-1.2.11/inftrees.h +62 -0
  31. data/ext/zstdlib/zlib-1.2.11/trees.c +1203 -0
  32. data/ext/zstdlib/zlib-1.2.11/trees.h +128 -0
  33. data/ext/zstdlib/zlib-1.2.11/uncompr.c +93 -0
  34. data/ext/zstdlib/zlib-1.2.11/zconf.h +534 -0
  35. data/ext/zstdlib/zlib-1.2.11/zlib.h +1912 -0
  36. data/ext/zstdlib/zlib-1.2.11/zutil.c +325 -0
  37. data/ext/zstdlib/zlib-1.2.11/zutil.h +271 -0
  38. data/ext/zstdlib/zlib.mk +14 -0
  39. data/ext/zstdlib/zlibwrapper/zlibwrapper.c +14 -0
  40. data/ext/zstdlib/zlibwrapper.mk +14 -0
  41. data/ext/zstdlib/zstd-1.3.8/lib/common/bitstream.h +455 -0
  42. data/ext/zstdlib/zstd-1.3.8/lib/common/compiler.h +140 -0
  43. data/ext/zstdlib/zstd-1.3.8/lib/common/cpu.h +215 -0
  44. data/ext/zstdlib/zstd-1.3.8/lib/common/debug.c +44 -0
  45. data/ext/zstdlib/zstd-1.3.8/lib/common/debug.h +134 -0
  46. data/ext/zstdlib/zstd-1.3.8/lib/common/entropy_common.c +236 -0
  47. data/ext/zstdlib/zstd-1.3.8/lib/common/error_private.c +54 -0
  48. data/ext/zstdlib/zstd-1.3.8/lib/common/error_private.h +76 -0
  49. data/ext/zstdlib/zstd-1.3.8/lib/common/fse.h +708 -0
  50. data/ext/zstdlib/zstd-1.3.8/lib/common/fse_decompress.c +309 -0
  51. data/ext/zstdlib/zstd-1.3.8/lib/common/huf.h +358 -0
  52. data/ext/zstdlib/zstd-1.3.8/lib/common/mem.h +380 -0
  53. data/ext/zstdlib/zstd-1.3.8/lib/common/pool.c +340 -0
  54. data/ext/zstdlib/zstd-1.3.8/lib/common/pool.h +84 -0
  55. data/ext/zstdlib/zstd-1.3.8/lib/common/threading.c +75 -0
  56. data/ext/zstdlib/zstd-1.3.8/lib/common/threading.h +123 -0
  57. data/ext/zstdlib/zstd-1.3.8/lib/common/xxhash.c +876 -0
  58. data/ext/zstdlib/zstd-1.3.8/lib/common/xxhash.h +305 -0
  59. data/ext/zstdlib/zstd-1.3.8/lib/common/zstd_common.c +83 -0
  60. data/ext/zstdlib/zstd-1.3.8/lib/common/zstd_errors.h +93 -0
  61. data/ext/zstdlib/zstd-1.3.8/lib/common/zstd_internal.h +266 -0
  62. data/ext/zstdlib/zstd-1.3.8/lib/compress/fse_compress.c +721 -0
  63. data/ext/zstdlib/zstd-1.3.8/lib/compress/hist.c +203 -0
  64. data/ext/zstdlib/zstd-1.3.8/lib/compress/hist.h +95 -0
  65. data/ext/zstdlib/zstd-1.3.8/lib/compress/huf_compress.c +798 -0
  66. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_compress.c +4290 -0
  67. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_compress_internal.h +860 -0
  68. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_double_fast.c +499 -0
  69. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_double_fast.h +38 -0
  70. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_fast.c +391 -0
  71. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_fast.h +37 -0
  72. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_lazy.c +1106 -0
  73. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_lazy.h +67 -0
  74. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_ldm.c +597 -0
  75. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_ldm.h +105 -0
  76. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_opt.c +1217 -0
  77. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_opt.h +56 -0
  78. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstdmt_compress.c +2107 -0
  79. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstdmt_compress.h +174 -0
  80. data/ext/zstdlib/zstd-1.3.8/lib/decompress/huf_decompress.c +1232 -0
  81. data/ext/zstdlib/zstd-1.3.8/lib/decompress/zstd_ddict.c +240 -0
  82. data/ext/zstdlib/zstd-1.3.8/lib/decompress/zstd_ddict.h +44 -0
  83. data/ext/zstdlib/zstd-1.3.8/lib/decompress/zstd_decompress.c +1672 -0
  84. data/ext/zstdlib/zstd-1.3.8/lib/decompress/zstd_decompress_block.c +1307 -0
  85. data/ext/zstdlib/zstd-1.3.8/lib/decompress/zstd_decompress_block.h +59 -0
  86. data/ext/zstdlib/zstd-1.3.8/lib/decompress/zstd_decompress_internal.h +168 -0
  87. data/ext/zstdlib/zstd-1.3.8/lib/zstd.h +1766 -0
  88. data/ext/zstdlib/zstd-1.3.8/zlibWrapper/gzclose.c +28 -0
  89. data/ext/zstdlib/zstd-1.3.8/zlibWrapper/gzcompatibility.h +68 -0
  90. data/ext/zstdlib/zstd-1.3.8/zlibWrapper/gzguts.h +227 -0
  91. data/ext/zstdlib/zstd-1.3.8/zlibWrapper/gzlib.c +640 -0
  92. data/ext/zstdlib/zstd-1.3.8/zlibWrapper/gzread.c +670 -0
  93. data/ext/zstdlib/zstd-1.3.8/zlibWrapper/gzwrite.c +671 -0
  94. data/ext/zstdlib/zstd-1.3.8/zlibWrapper/zstd_zlibwrapper.c +1105 -0
  95. data/ext/zstdlib/zstd-1.3.8/zlibWrapper/zstd_zlibwrapper.h +88 -0
  96. data/ext/zstdlib/zstd.mk +14 -0
  97. data/lib/2.2/zstdlib.so +0 -0
  98. data/lib/2.3/zstdlib.so +0 -0
  99. data/lib/2.4/zstdlib.so +0 -0
  100. data/lib/2.5/zstdlib.so +0 -0
  101. data/lib/2.6/zstdlib.so +0 -0
  102. data/lib/zstdlib.rb +6 -0
  103. data/test/zstdlib_test.rb +21 -0
  104. metadata +205 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4ca9afd7456f2dbce0f0f12d12f67901d0ed2b363652f0f6ae3fc7d6c4488731
4
+ data.tar.gz: 1605a7d9aba92e69fbe55e0cef92d6eeedf1e0337d52fa9538cd5beb99cad960
5
+ SHA512:
6
+ metadata.gz: 69fe0e161f25676c7c1a3c70dcb3e6b717301f294b86e6f5981d6d0d6a1f985750de66e1bbf27d74114f1d16a5ab2153a5ad051a90ea77762053ffabc09c7067
7
+ data.tar.gz: ed0cd3ae52582ea6e07542d0d60dffc3bf1394c46da8afcbbdbfafecdf6c184c0e5372bce563262fccdf13fe8e9b528040a57dc205caf3519afa8cfac7783e4d
data/CHANGES.md ADDED
@@ -0,0 +1,9 @@
1
+ # 0.1.0
2
+
3
+ Initial release.
4
+
5
+ Zstd version: `1.3.8`
6
+
7
+ Zlib version: `1.2.11`
8
+
9
+ Supported MRI Ruby versions: `2.2-2.6`
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # [Zstdlib](https://bitbucket.org/fougas/zstdlib) - a Zstd (de)compression library binding for Ruby
2
+
3
+ _zstdlib_ is native Ruby extension for [Zstandard](https://facebook.github.io/zstd/) data compression library.
4
+
5
+ _zstdlib_ is currently available for the [MRI Ruby](https://www.ruby-lang.org/) platform.
6
+
7
+ ## Why bother?
8
+
9
+ Unlike the other Zstd bindings available for Ruby, *Zstdlib* utilizes Zstd's native *Zlib* compatibility layer.
10
+
11
+ This specifically means that `Zstdlib` module is and will be (mostly) API-compatible with standard Ruby `Zlib` module and thus _zstdlib_ can be used as a drop-in replacement for _zlib_: just replace `Zlib` with `Zstdlib` throughout the source code and you're in!
12
+
13
+ Streams produced by `Zstdlib::Deflate` can be decompressed with standard _zstd_ utility and hence can be written to _.zst_ or _.zstd_ files.
14
+
15
+ ## Use cases
16
+
17
+ ### Simple string compression
18
+ ````ruby
19
+ require 'zstdlib'
20
+ data = Zstdlib.deflate('Hello, Zstd!')
21
+ ````
22
+
23
+ ### Incremental data compression
24
+ ````ruby
25
+ require 'zstdlib'
26
+ zstd = Zstdlib::Deflate.new
27
+ data = String.new
28
+ data << zstd.deflate('Hello')
29
+ data << zstd.deflate('Zstd')
30
+ data << zstd.finish
31
+ ````
32
+
33
+ ### Simple string decompression
34
+ ````ruby
35
+ require 'zstdlib'
36
+ data = Zstdlib.inflate(compressed_data)
37
+ ````
38
+
39
+ ## Technical notes
40
+
41
+ _zstdlib_ covers the following parts of _zlib_:
42
+
43
+ - `ZStream`, `Inflate` and `Deflate` classes
44
+ - Various `Zlib::` constants (`DEFAULT_COMPRESSION` etc.)
45
+ - `Zlib::` exception classes (`Error` and its descendants)
46
+
47
+ Note that _zstdlib_ currently omits Gzip file support with its `GzipFile`, `GzipReader` and `GzipWriter` classes
48
+ and associated constants although this may be changed in future.
49
+
50
+ ### General guidelines
51
+
52
+ In order to enable Zstd (de)compression capability in existing code, simply replace _zlib_ with _zstdlib_ in require statements and
53
+ `Zlib` with `Zstdlib` module references throughout the code.
54
+
55
+ The rest of the _zlib_-aware code should work unchanged.
56
+
57
+ For further information refer to documentation on _zlib_ .
58
+
59
+
60
+ ### Notes on compression levels
61
+
62
+ If unsure do not pass anything to constructor in order to use `DEFAULT_COMPRESSION` level which works for both _zlib_ ans _zstdlib_.
63
+
64
+ Contrary to _zlib_ the `NO_COMPRESSION` constant in _zstdlib_ is an equivalent to `BEST_SPEED` as Zstd always compresses data.
65
+
66
+ The `BEST_COMPRESSION` constant is adjusted to reflect Zstd-specific compression level range.
67
+ Anyways this level is recommended against due to abysmal performance not to be expected from the *fast* state-of-the-art compression algorithm.
68
+ The Zstd documentation (currently) recommends using *19* as the level for optimal *best* compression.
69
+
70
+ The `BEST_SPEED` constant remains unchanged.
71
+
72
+ ## Availability
73
+
74
+ _zstdlib_ home page on [bitbucket.org](https://bitbucket.org/fougas/zstdlib).
75
+
76
+ Source code and Windows-specific multi-versioned binary gems can be obtained from [rubygems.org](https://rubygems.org/gems/zstdlib).
77
+
78
+ ## Release history
79
+
80
+ For user-visible changes refer to [change log](CHANGES.md).
81
+
82
+ ## Caveats
83
+
84
+ Ruby documentation extraction tools (such as RDoc) produce incorrect documentation for _zstdlib_
85
+ which is technically valid but contains all identifies referring to _zlib_.
86
+ This may change in future.
87
+
88
+ Gzip support, although available in Zstd's Zlib compatibility layer, is currently disabled.
89
+
90
+ Zstd's external compression dictionaries capability is not (yet) implemented.
91
+
92
+ # The end
93
+
94
+ Cheers,
95
+
96
+ Oleg A. Khlybov <fougas@mail.ru>
data/Rakefile ADDED
@@ -0,0 +1,29 @@
1
+ require 'rake/testtask'
2
+ require 'bundler/gem_tasks'
3
+ require 'rake/extensiontask'
4
+
5
+
6
+ spec = Gem::Specification.load('zstdlib.gemspec')
7
+
8
+
9
+ Rake::ExtensionTask.new('zstdlib', spec) do |t|
10
+ t.cross_compile = true
11
+ t.cross_platform = %w(x86-mingw32 x64-mingw32)
12
+ end
13
+
14
+
15
+ Gem::PackageTask.new(spec)
16
+
17
+
18
+ Rake::TestTask.new(:test) do |t|
19
+ t.libs << 'test'
20
+ t.libs << 'lib'
21
+ t.test_files = FileList['test/*_test.rb']
22
+ end
23
+
24
+
25
+ task :fat do
26
+ require 'rake_compiler_dock'
27
+ sh 'bundle package'
28
+ RakeCompilerDock.sh 'bundle --local && rake cross native gem'
29
+ end
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'mkmf'
4
+ require 'fileutils'
5
+
6
+ include FileUtils
7
+
8
+ ZSTD_VERSION = '1.3.8'
9
+ ZLIB_VERSION = '1.2.11'
10
+ RB_VERSION = Gem.ruby_api_version.slice(/^\d+\.\d+/)
11
+
12
+ root = File.dirname(__FILE__)
13
+
14
+ zmod = File.expand_path "ruby/zlib-#{RB_VERSION}", root
15
+ zlib = File.expand_path "zlib-#{ZLIB_VERSION}", root
16
+ zstd = File.expand_path "zstd-#{ZSTD_VERSION}/lib", root
17
+ zlibwrapper = File.expand_path "zstd-#{ZSTD_VERSION}/zlibWrapper", root
18
+
19
+ File.open('zstdlib.c', 'w') do |file|
20
+ file << File.read("#{zmod}/zlib.c").
21
+ gsub(/Init_zlib/, 'Init_zstdlib').
22
+ gsub(/rb_define_module.*/, 'rb_define_module("Zstdlib");').
23
+ gsub(%~<zlib.h>~, %~<zstd_zlibwrapper.h>~).
24
+ gsub(%~Z_BEST_COMPRESSION~, %~ZSTD_maxCLevel()~)
25
+ end
26
+
27
+ $srcs = ['zstdlib.c']
28
+
29
+ $CFLAGS += ' -fomit-frame-pointer -ffast-math -O3'
30
+ $CPPFLAGS += " -I#{zlib} -I#{zlibwrapper} -I#{zstd}/lib -DZWRAP_USE_ZSTD=1 -DGZIP_SUPPORT=0"
31
+ $LDFLAGS += ' -s'
32
+ $LOCAL_LIBS += ' libzlibwrapper.a libz.a libzstd.a'
33
+
34
+ create_makefile('zstdlib')
35
+
36
+ File.open('Makefile', 'a') do |file|
37
+ file << %~
38
+
39
+ export CC AR CFLAGS CPPFLAGS
40
+
41
+ $(DLLIB) : libz.a libzstd.a libzlibwrapper.a
42
+
43
+ libzstd.a :
44
+ \texport SRCDIR=#{zstd} && mkdir -p zstd && $(MAKE) -C zstd -f #{File.expand_path root}/zstd.mk
45
+
46
+ libz.a :
47
+ \texport SRCDIR=#{zlib} && mkdir -p zlib && $(MAKE) -C zlib -f #{File.expand_path root}/zlib.mk
48
+
49
+ libzlibwrapper.a :
50
+ \texport SRCDIR=#{zlibwrapper} && mkdir -p zlibwrapper && $(MAKE) -C zlibwrapper -f #{File.expand_path root}/zlibwrapper.mk
51
+
52
+ ~
53
+ end