digest-crc 0.6.3 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +5 -4
  3. data/ChangeLog.md +10 -0
  4. data/Gemfile +2 -1
  5. data/LICENSE.txt +1 -1
  6. data/README.md +265 -116
  7. data/benchmarks.rb +1 -1
  8. data/ext/digest/crc12_3gpp/crc12_3gpp_ext.c +5 -0
  9. data/ext/digest/crc15/crc15_ext.c +5 -0
  10. data/ext/digest/crc16/crc16_ext.c +5 -0
  11. data/ext/digest/crc16_ccitt/crc16_ccitt_ext.c +5 -0
  12. data/ext/digest/crc16_dnp/crc16_dnp_ext.c +5 -0
  13. data/ext/digest/crc16_genibus/crc16_genibus_ext.c +5 -0
  14. data/ext/digest/crc16_kermit/crc16_kermit_ext.c +5 -0
  15. data/ext/digest/crc16_modbus/crc16_modbus_ext.c +4 -0
  16. data/ext/digest/crc16_usb/crc16_usb_ext.c +4 -0
  17. data/ext/digest/crc16_x_25/crc16_x_25_ext.c +4 -0
  18. data/ext/digest/crc16_xmodem/crc16_xmodem_ext.c +5 -0
  19. data/ext/digest/crc16_zmodem/crc16_zmodem_ext.c +5 -0
  20. data/ext/digest/crc24/crc24_ext.c +5 -0
  21. data/ext/digest/crc32/crc32_ext.c +5 -0
  22. data/ext/digest/crc32_bzip2/crc32_bzip2_ext.c +5 -0
  23. data/ext/digest/crc32_jam/crc32_jam_ext.c +4 -0
  24. data/ext/digest/crc32_mpeg/crc32_mpeg_ext.c +5 -0
  25. data/ext/digest/crc32_posix/crc32_posix_ext.c +5 -0
  26. data/ext/digest/crc32_xfer/crc32_xfer_ext.c +5 -0
  27. data/ext/digest/crc32c/crc32c_ext.c +4 -0
  28. data/ext/digest/crc5/crc5_ext.c +5 -0
  29. data/ext/digest/crc64/crc64_ext.c +5 -0
  30. data/ext/digest/crc64_jones/crc64_jones_ext.c +4 -0
  31. data/ext/digest/crc64_xz/crc64_xz_ext.c +4 -0
  32. data/ext/digest/crc8/crc8_ext.c +5 -0
  33. data/ext/digest/crc8_1wire/crc8_1wire_ext.c +4 -0
  34. data/gemspec.yml +4 -4
  35. data/lib/digest/crc5.rb +18 -18
  36. data/spec/crc5_spec.rb +2 -4
  37. data/spec/crc_examples.rb +10 -0
  38. data/spec/spec_helper.rb +2 -0
  39. metadata +6 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f5e688a7da7f932c40ddbfc271ac0fada5ec85a5b98bcfec9040d15279bef8a2
4
- data.tar.gz: 7f51652724f8b0e168d702e068a63e1b1ff7db080e2d6efd1b9930c57ac12c5b
3
+ metadata.gz: a91420951947a2ed738b2b786ab0c22105124fa9c92fa2cbaebf5664abd8b8e4
4
+ data.tar.gz: b46f6cc23d7d6e300d55524a31d4cb4c331bd3c0489819c56d6f05e60c6246bc
5
5
  SHA512:
6
- metadata.gz: 88e32eb6fe7fb27b4ff1e3bbbffbe1680a9b22f7a58a1021518601bc6944279fa82acf9303bd70e62cce7fd7f8b168e079153a9a00241130f9cec339305f5874
7
- data.tar.gz: '093770c8846be1baa29522e3a15d35b114eb5836cd5ebc7f9fa64776330694e8a9111a429ba8c3e7d9885ae2a4093e73c9bccdefdc5974b1d4270795ed901e1a'
6
+ metadata.gz: ce767424edcbdf407a449b6f3dc3f31bf3cb60f240bbaf47d4bc8754da13d913b05644bc77e73c892f419e289cdde52651496c67d72a754d7d562528a9c3a64a
7
+ data.tar.gz: 334b17ae6e0e36546cf99617d9a0f4e2bf826bb1db578f4a8c4f556f66edf9585f00fe21b5e69865105e873e50a458e820ede34ddf204883858def40dbdfff4b
@@ -12,11 +12,12 @@ jobs:
12
12
  - ubuntu-latest
13
13
  - macos-latest
14
14
  ruby:
15
- - 2.4
16
- - 2.5
17
- - 2.6
18
- - 2.7
15
+ - '2.7'
16
+ - '3.0'
17
+ - '3.1'
18
+ - '3.2.0-preview1'
19
19
  - jruby
20
+ - truffleruby
20
21
  name: OS ${{ matrix.os }} / Ruby ${{ matrix.ruby }}
21
22
  steps:
22
23
  - uses: actions/checkout@v2
data/ChangeLog.md CHANGED
@@ -1,3 +1,13 @@
1
+ ### 0.6.5 / 2023-07-03
2
+
3
+ * Corrected the implementation of {Digest::CRC5}.
4
+ * Make `digest-crc` Ractor-safe.
5
+
6
+ ### 0.6.4 / 2021-07-14
7
+
8
+ * Silence potential method redefinition warnings when loading the C extensions.
9
+ (@ojab)
10
+
1
11
  ### 0.6.3 / 2020-12-19
2
12
 
3
13
  * Broaden rake dependency to >= 12.0.0, < 14.0.0` for ruby 2.7, which includes
data/Gemfile CHANGED
@@ -6,7 +6,8 @@ group :development do
6
6
  gem 'rake'
7
7
  gem 'rubygems-tasks', '~> 0.2'
8
8
 
9
- gem 'rspec', '~> 3.0'
9
+ gem 'rspec', '~> 3.0'
10
+ gem 'simplecov', '~> 0.20'
10
11
 
11
12
  gem 'yard', '~> 0.9'
12
13
  gem 'kramdown'
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2020 Hal Brodigan
1
+ Copyright (c) 2010-2021 Hal Brodigan
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,11 +1,10 @@
1
1
  # Digest CRC
2
2
 
3
- [![Build Status](https://travis-ci.org/postmodern/digest-crc.svg?branch=master)](https://travis-ci.org/postmodern/digest-crc)
3
+ [![CI](https://github.com/postmodern/digest-crc/actions/workflows/ruby.yml/badge.svg)](https://github.com/postmodern/digest-crc/actions/workflows/ruby.yml)
4
4
 
5
5
  * [Source](https://github.com/postmodern/digest-crc)
6
6
  * [Issues](https://github.com/postmodern/digest-crc/issues)
7
7
  * [Documentation](http://rubydoc.info/gems/digest-crc/frames)
8
- * [Email](mailto:postmodern.mod3 at gmail.com)
9
8
 
10
9
  ## Description
11
10
 
@@ -15,33 +14,33 @@ module.
15
14
  ## Features
16
15
 
17
16
  * Provides support for the following CRC algorithms:
18
- * {Digest::CRC1 CRC1}
19
- * {Digest::CRC5 CRC5}
20
- * {Digest::CRC8 CRC8}
21
- * {Digest::CRC8_1Wire CRC8 1-Wire}
22
- * {Digest::CRC15 CRC15}
23
- * {Digest::CRC16 CRC16}
24
- * {Digest::CRC16CCITT CRC16 CCITT}
25
- * {Digest::CRC16DNP CRC16 DNP}
26
- * {Digest::CRC16Genibus CRC16 Genibus}
27
- * {Digest::CRC16Kermit CRC16 Kermit}
28
- * {Digest::CRC16Modbus CRC16 Modbus}
29
- * {Digest::CRC16USB CRC16 USB}
30
- * {Digest::CRC16X25 CRC16 X25}
31
- * {Digest::CRC16XModem CRC16 XModem}
32
- * {Digest::CRC16ZModem CRC16 ZModem}
33
- * {Digest::CRC16QT CRC16 QT}
34
- * {Digest::CRC24 CRC24}
35
- * {Digest::CRC32 CRC32}
36
- * {Digest::CRC32BZip2 CRC32 BZip2}
37
- * {Digest::CRC32c CRC32c}
38
- * {Digest::CRC32Jam CRC32 Jam}
39
- * {Digest::CRC32MPEG CRC32 MPEG}
40
- * {Digest::CRC32POSIX CRC32 POSIX}
41
- * {Digest::CRC32XFER CRC32 XFER}
42
- * {Digest::CRC64 CRC64}
43
- * {Digest::CRC64Jones CRC64 Jones}
44
- * {Digest::CRC64XZ CRC64 XZ}
17
+ * [CRC1](https://rubydoc.info/gems/digest-crc/Digest/CRC1)
18
+ * [CRC5](https://rubydoc.info/gems/digest-crc/Digest/CRC5)
19
+ * [CRC8](https://rubydoc.info/gems/digest-crc/Digest/CRC8)
20
+ * [CRC8 1-Wire](https://rubydoc.info/gems/digest-crc/Digest/CRC8_1Wire)
21
+ * [CRC15](https://rubydoc.info/gems/digest-crc/Digest/CRC15)
22
+ * [CRC16](https://rubydoc.info/gems/digest-crc/Digest/CRC16)
23
+ * [CRC16 CCITT](https://rubydoc.info/gems/digest-crc/Digest/CRC16CCITT)
24
+ * [CRC16 DNP](https://rubydoc.info/gems/digest-crc/Digest/CRC16DNP)
25
+ * [CRC16 Genibus](https://rubydoc.info/gems/digest-crc/Digest/CRC16Genibus)
26
+ * [CRC16 Kermit](https://rubydoc.info/gems/digest-crc/Digest/CRC16Kermit)
27
+ * [CRC16 Modbus](https://rubydoc.info/gems/digest-crc/Digest/CRC16Modbus)
28
+ * [CRC16 USB](https://rubydoc.info/gems/digest-crc/Digest/CRC16USB)
29
+ * [CRC16 X25](https://rubydoc.info/gems/digest-crc/Digest/CRC16X25)
30
+ * [CRC16 XModem](https://rubydoc.info/gems/digest-crc/Digest/CRC16XModem)
31
+ * [CRC16 ZModem](https://rubydoc.info/gems/digest-crc/Digest/CRC16ZModem)
32
+ * [CRC16 QT](https://rubydoc.info/gems/digest-crc/Digest/CRC16QT)
33
+ * [CRC24](https://rubydoc.info/gems/digest-crc/Digest/CRC24)
34
+ * [CRC32](https://rubydoc.info/gems/digest-crc/Digest/CRC32)
35
+ * [CRC32 BZip2](https://rubydoc.info/gems/digest-crc/Digest/CRC32BZip2)
36
+ * [CRC32c](https://rubydoc.info/gems/digest-crc/Digest/CRC32c)
37
+ * [CRC32 Jam](https://rubydoc.info/gems/digest-crc/Digest/CRC32Jam)
38
+ * [CRC32 MPEG](https://rubydoc.info/gems/digest-crc/Digest/CRC32MPEG)
39
+ * [CRC32 POSIX](https://rubydoc.info/gems/digest-crc/Digest/CRC32POSIX)
40
+ * [CRC32 XFER](https://rubydoc.info/gems/digest-crc/Digest/CRC32XFER)
41
+ * [CRC64](https://rubydoc.info/gems/digest-crc/Digest/CRC64)
42
+ * [CRC64 Jones](https://rubydoc.info/gems/digest-crc/Digest/CRC64Jones)
43
+ * [CRC64 XZ](https://rubydoc.info/gems/digest-crc/Digest/CRC64XZ)
45
44
  * Pure Ruby implementation.
46
45
  * Provides CRC Tables for optimized calculations.
47
46
  * Supports _optional_ C extensions which increases performance by ~40x.
@@ -139,42 +138,42 @@ end
139
138
 
140
139
  ## Benchmarks
141
140
 
142
- ### Pure Ruby (ruby 2.7.1)
141
+ ### Ruby 2.7.4 (pure Ruby)
143
142
 
144
143
  $ bundle exec rake clean
145
144
  $ bundle exec ./benchmarks.rb
146
145
  Loading Digest::CRC classes ...
147
146
  Generating 1000 8Kb lengthed strings ...
148
147
  Benchmarking Digest::CRC classes ...
149
- user system total real
150
- Digest::CRC1#update 0.349756 0.000002 0.349758 ( 0.351427)
151
- Digest::CRC5#update 1.175206 0.000049 1.175255 ( 1.180975)
152
- Digest::CRC8#update 1.023536 0.000015 1.023551 ( 1.029017)
153
- Digest::CRC8_1Wire#update 1.012156 0.000000 1.012156 ( 1.017342)
154
- Digest::CRC15#update 1.187286 0.000005 1.187291 ( 1.193634)
155
- Digest::CRC16#update 0.998527 0.000013 0.998540 ( 1.003940)
156
- Digest::CRC16CCITT#update 1.179864 0.000005 1.179869 ( 1.186134)
157
- Digest::CRC16DNP#update 1.018969 0.000003 1.018972 ( 1.025248)
158
- Digest::CRC16Genibus#update 1.196754 0.000065 1.196819 ( 1.203605)
159
- Digest::CRC16Modbus#update 1.007367 0.000000 1.007367 ( 1.012325)
160
- Digest::CRC16X25#update 1.044127 0.000000 1.044127 ( 1.052010)
161
- Digest::CRC16USB#update 1.012804 0.000000 1.012804 ( 1.018324)
162
- Digest::CRC16X25#update 1.009694 0.000000 1.009694 ( 1.015890)
163
- Digest::CRC16XModem#update 1.210814 0.000000 1.210814 ( 1.217951)
164
- Digest::CRC16ZModem#update 1.175239 0.000000 1.175239 ( 1.181395)
165
- Digest::CRC24#update 1.207431 0.000000 1.207431 ( 1.213373)
166
- Digest::CRC32#update 1.012334 0.000000 1.012334 ( 1.017671)
167
- Digest::CRC32BZip2#update 1.190351 0.000000 1.190351 ( 1.196567)
168
- Digest::CRC32c#update 1.021147 0.000000 1.021147 ( 1.027035)
169
- Digest::CRC32Jam#update 1.002365 0.000000 1.002365 ( 1.007202)
170
- Digest::CRC32MPEG#update 1.161925 0.000000 1.161925 ( 1.168058)
171
- Digest::CRC32POSIX#update 1.191860 0.000967 1.192827 ( 1.198722)
172
- Digest::CRC32XFER#update 1.217692 0.000000 1.217692 ( 1.224075)
173
- Digest::CRC64#update 3.084106 0.000000 3.084106 ( 3.106840)
174
- Digest::CRC64Jones#update 3.016687 0.000000 3.016687 ( 3.038963)
175
- Digest::CRC64XZ#update 3.019690 0.000000 3.019690 ( 3.040971)
176
-
177
- ### C extensions (ruby 2.7.1)
148
+ user system total real
149
+ Digest::CRC1#update 0.423741 0.000000 0.423741 ( 0.425887)
150
+ Digest::CRC5#update 1.486578 0.000011 1.486589 ( 1.493215)
151
+ Digest::CRC8#update 1.261386 0.000000 1.261386 ( 1.266399)
152
+ Digest::CRC8_1Wire#update 1.250344 0.000000 1.250344 ( 1.255009)
153
+ Digest::CRC15#update 1.482515 0.000000 1.482515 ( 1.488131)
154
+ Digest::CRC16#update 1.216744 0.000811 1.217555 ( 1.222228)
155
+ Digest::CRC16CCITT#update 1.480490 0.000000 1.480490 ( 1.486745)
156
+ Digest::CRC16DNP#update 1.200067 0.000000 1.200067 ( 1.204835)
157
+ Digest::CRC16Genibus#update 1.492910 0.000000 1.492910 ( 1.498923)
158
+ Digest::CRC16Modbus#update 1.217449 0.000003 1.217452 ( 1.222348)
159
+ Digest::CRC16QT#update 1.223311 0.000000 1.223311 ( 1.229211)
160
+ Digest::CRC16USB#update 1.233744 0.000000 1.233744 ( 1.238615)
161
+ Digest::CRC16X25#update 1.223077 0.000000 1.223077 ( 1.227607)
162
+ Digest::CRC16XModem#update 1.487674 0.000000 1.487674 ( 1.493316)
163
+ Digest::CRC16ZModem#update 1.484288 0.000000 1.484288 ( 1.490096)
164
+ Digest::CRC24#update 1.490272 0.000000 1.490272 ( 1.496027)
165
+ Digest::CRC32#update 1.225311 0.000000 1.225311 ( 1.230572)
166
+ Digest::CRC32BZip2#update 1.503096 0.000000 1.503096 ( 1.509202)
167
+ Digest::CRC32c#update 1.220390 0.000000 1.220390 ( 1.225487)
168
+ Digest::CRC32Jam#update 1.216066 0.000000 1.216066 ( 1.220591)
169
+ Digest::CRC32MPEG#update 1.486808 0.000000 1.486808 ( 1.492611)
170
+ Digest::CRC32POSIX#update 1.494508 0.000957 1.495465 ( 1.503262)
171
+ Digest::CRC32XFER#update 1.504802 0.005830 1.510632 ( 1.522066)
172
+ Digest::CRC64#update 3.260784 0.015674 3.276458 ( 3.310506)
173
+ Digest::CRC64Jones#update 3.195204 0.000000 3.195204 ( 3.213054)
174
+ Digest::CRC64XZ#update 3.173597 0.000000 3.173597 ( 3.190438)
175
+
176
+ ### Ruby 2.7.4 (C extensions)
178
177
 
179
178
  $ bundle exec rake build:c_exts
180
179
  ...
@@ -182,67 +181,217 @@ end
182
181
  Loading Digest::CRC classes ...
183
182
  Generating 1000 8Kb lengthed strings ...
184
183
  Benchmarking Digest::CRC classes ...
185
- user system total real
186
- Digest::CRC1#update 0.356025 0.000016 0.356041 ( 0.365345)
187
- Digest::CRC5#update 0.023957 0.000001 0.023958 ( 0.024835)
188
- Digest::CRC8#update 0.021254 0.000007 0.021261 ( 0.024647)
189
- Digest::CRC8_1Wire#update 0.039129 0.000000 0.039129 ( 0.042417)
190
- Digest::CRC15#update 0.030285 0.000000 0.030285 ( 0.030560)
191
- Digest::CRC16#update 0.023003 0.000000 0.023003 ( 0.023267)
192
- Digest::CRC16CCITT#update 0.028207 0.000000 0.028207 ( 0.028467)
193
- Digest::CRC16DNP#update 0.022861 0.000000 0.022861 ( 0.023111)
194
- Digest::CRC16Genibus#update 0.028041 0.000000 0.028041 ( 0.028359)
195
- Digest::CRC16Modbus#update 0.022931 0.000009 0.022940 ( 0.023560)
196
- Digest::CRC16X25#update 0.022808 0.000000 0.022808 ( 0.023054)
197
- Digest::CRC16USB#update 0.022258 0.000882 0.023140 ( 0.023418)
198
- Digest::CRC16X25#update 0.022816 0.000000 0.022816 ( 0.023084)
199
- Digest::CRC16XModem#update 0.027984 0.000000 0.027984 ( 0.028269)
200
- Digest::CRC16ZModem#update 0.027968 0.000000 0.027968 ( 0.028214)
201
- Digest::CRC24#update 0.028426 0.000000 0.028426 ( 0.028687)
202
- Digest::CRC32#update 0.022805 0.000000 0.022805 ( 0.023043)
203
- Digest::CRC32BZip2#update 0.025519 0.000000 0.025519 ( 0.025797)
204
- Digest::CRC32c#update 0.022807 0.000000 0.022807 ( 0.023069)
205
- Digest::CRC32Jam#update 0.023006 0.000000 0.023006 ( 0.023231)
206
- Digest::CRC32MPEG#update 0.025536 0.000000 0.025536 ( 0.025861)
207
- Digest::CRC32POSIX#update 0.025557 0.000000 0.025557 ( 0.025841)
208
- Digest::CRC32XFER#update 0.025310 0.000000 0.025310 ( 0.025599)
209
- Digest::CRC64#update 0.023182 0.000000 0.023182 ( 0.023421)
210
- Digest::CRC64Jones#update 0.022916 0.000000 0.022916 ( 0.023139)
211
- Digest::CRC64XZ#update 0.022879 0.000000 0.022879 ( 0.023131)
212
-
213
- ### Pure Ruby (jruby 9.2.12.0)
184
+ user system total real
185
+ Digest::CRC1#update 0.443619 0.000007 0.443626 ( 0.446545)
186
+ Digest::CRC5#update 0.025134 0.000806 0.025940 ( 0.026129)
187
+ Digest::CRC8#update 0.022564 0.000000 0.022564 ( 0.022775)
188
+ Digest::CRC8_1Wire#update 0.021427 0.000008 0.021435 ( 0.021551)
189
+ Digest::CRC15#update 0.030377 0.000833 0.031210 ( 0.031406)
190
+ Digest::CRC16#update 0.024004 0.000002 0.024006 ( 0.024418)
191
+ Digest::CRC16CCITT#update 0.026930 0.000001 0.026931 ( 0.027238)
192
+ Digest::CRC16DNP#update 0.024279 0.000000 0.024279 ( 0.024446)
193
+ Digest::CRC16Genibus#update 0.026477 0.000004 0.026481 ( 0.026656)
194
+ Digest::CRC16Modbus#update 0.023568 0.000000 0.023568 ( 0.023704)
195
+ Digest::CRC16QT#update 0.024161 0.000000 0.024161 ( 0.024316)
196
+ Digest::CRC16USB#update 0.023891 0.000000 0.023891 ( 0.024038)
197
+ Digest::CRC16X25#update 0.023849 0.000000 0.023849 ( 0.023991)
198
+ Digest::CRC16XModem#update 0.026254 0.000000 0.026254 ( 0.026523)
199
+ Digest::CRC16ZModem#update 0.026391 0.000000 0.026391 ( 0.026529)
200
+ Digest::CRC24#update 0.028805 0.000854 0.029659 ( 0.029830)
201
+ Digest::CRC32#update 0.024030 0.000000 0.024030 ( 0.024200)
202
+ Digest::CRC32BZip2#update 0.026942 0.000000 0.026942 ( 0.027244)
203
+ Digest::CRC32c#update 0.023989 0.000000 0.023989 ( 0.024159)
204
+ Digest::CRC32Jam#update 0.023940 0.000000 0.023940 ( 0.024066)
205
+ Digest::CRC32MPEG#update 0.027063 0.000000 0.027063 ( 0.027213)
206
+ Digest::CRC32POSIX#update 0.027137 0.000000 0.027137 ( 0.028160)
207
+ Digest::CRC32XFER#update 0.026956 0.000002 0.026958 ( 0.027103)
208
+ Digest::CRC64#update 0.024222 0.000005 0.024227 ( 0.024796)
209
+ Digest::CRC64Jones#update 0.025331 0.000000 0.025331 ( 0.025789)
210
+ Digest::CRC64XZ#update 0.024131 0.000001 0.024132 ( 0.024348)
211
+
212
+ ### Ruby 3.0.2 (pure Ruby)
214
213
 
214
+ $ bundle exec rake clean
215
+ $ bundle exec ./benchmarks.rb
216
+ Loading Digest::CRC classes ...
217
+ Generating 1000 8Kb lengthed strings ...
218
+ Benchmarking Digest::CRC classes ...
219
+ user system total real
220
+ Digest::CRC1#update 0.331405 0.000002 0.331407 ( 0.333588)
221
+ Digest::CRC5#update 1.206847 0.000020 1.206867 ( 1.224072)
222
+ Digest::CRC8#update 1.018571 0.000000 1.018571 ( 1.023002)
223
+ Digest::CRC8_1Wire#update 1.018802 0.000000 1.018802 ( 1.023292)
224
+ Digest::CRC15#update 1.207586 0.000000 1.207586 ( 1.212691)
225
+ Digest::CRC16#update 1.032505 0.000965 1.033470 ( 1.040862)
226
+ Digest::CRC16CCITT#update 1.198079 0.000000 1.198079 ( 1.203134)
227
+ Digest::CRC16DNP#update 0.994582 0.000000 0.994582 ( 1.006520)
228
+ Digest::CRC16Genibus#update 1.190596 0.000000 1.190596 ( 1.196087)
229
+ Digest::CRC16Modbus#update 1.007826 0.000000 1.007826 ( 1.012934)
230
+ Digest::CRC16QT#update 0.996298 0.000001 0.996299 ( 1.000255)
231
+ Digest::CRC16USB#update 0.995806 0.000000 0.995806 ( 0.999822)
232
+ Digest::CRC16X25#update 1.019589 0.000000 1.019589 ( 1.031010)
233
+ Digest::CRC16XModem#update 1.146947 0.000000 1.146947 ( 1.150817)
234
+ Digest::CRC16ZModem#update 1.145145 0.000000 1.145145 ( 1.149483)
235
+ Digest::CRC24#update 1.149009 0.000000 1.149009 ( 1.152854)
236
+ Digest::CRC32#update 0.970976 0.000000 0.970976 ( 0.974227)
237
+ Digest::CRC32BZip2#update 1.148596 0.000000 1.148596 ( 1.152381)
238
+ Digest::CRC32c#update 0.972566 0.000000 0.972566 ( 0.975790)
239
+ Digest::CRC32Jam#update 0.975854 0.000000 0.975854 ( 0.979217)
240
+ Digest::CRC32MPEG#update 1.148578 0.000000 1.148578 ( 1.153088)
241
+ Digest::CRC32POSIX#update 1.146218 0.000986 1.147204 ( 1.152460)
242
+ Digest::CRC32XFER#update 1.149823 0.000000 1.149823 ( 1.153692)
243
+ Digest::CRC64#update 2.869948 0.000016 2.869964 ( 2.884261)
244
+ Digest::CRC64Jones#update 2.867662 0.000000 2.867662 ( 2.886559)
245
+ Digest::CRC64XZ#update 2.858847 0.000000 2.858847 ( 2.874058)
246
+
247
+ ### Ruby 3.0.2 (C extensions)
248
+
249
+ $ bundle exec rake build:c_exts
250
+ ...
251
+ $ bundle exec ./benchmarks.rb
252
+ Loading Digest::CRC classes ...
253
+ Generating 1000 8Kb lengthed strings ...
254
+ Benchmarking Digest::CRC classes ...
255
+ user system total real
256
+ Digest::CRC1#update 0.349055 0.000000 0.349055 ( 0.350454)
257
+ Digest::CRC5#update 0.023144 0.000000 0.023144 ( 0.023248)
258
+ Digest::CRC8#update 0.021378 0.000000 0.021378 ( 0.021522)
259
+ Digest::CRC8_1Wire#update 0.021019 0.000000 0.021019 ( 0.021145)
260
+ Digest::CRC15#update 0.030063 0.000003 0.030066 ( 0.030245)
261
+ Digest::CRC16#update 0.024395 0.000000 0.024395 ( 0.024572)
262
+ Digest::CRC16CCITT#update 0.026979 0.000000 0.026979 ( 0.027138)
263
+ Digest::CRC16DNP#update 0.024665 0.000000 0.024665 ( 0.024844)
264
+ Digest::CRC16Genibus#update 0.027054 0.000000 0.027054 ( 0.027217)
265
+ Digest::CRC16Modbus#update 0.023963 0.000000 0.023963 ( 0.024257)
266
+ Digest::CRC16QT#update 0.024218 0.000000 0.024218 ( 0.024360)
267
+ Digest::CRC16USB#update 0.024393 0.000000 0.024393 ( 0.024561)
268
+ Digest::CRC16X25#update 0.025127 0.000000 0.025127 ( 0.025292)
269
+ Digest::CRC16XModem#update 0.028123 0.000000 0.028123 ( 0.028377)
270
+ Digest::CRC16ZModem#update 0.028205 0.000000 0.028205 ( 0.028571)
271
+ Digest::CRC24#update 0.031386 0.000000 0.031386 ( 0.031740)
272
+ Digest::CRC32#update 0.023832 0.000000 0.023832 ( 0.023948)
273
+ Digest::CRC32BZip2#update 0.027159 0.000000 0.027159 ( 0.027315)
274
+ Digest::CRC32c#update 0.024172 0.000000 0.024172 ( 0.024310)
275
+ Digest::CRC32Jam#update 0.024376 0.000000 0.024376 ( 0.024494)
276
+ Digest::CRC32MPEG#update 0.026035 0.000784 0.026819 ( 0.026940)
277
+ Digest::CRC32POSIX#update 0.026784 0.000000 0.026784 ( 0.026907)
278
+ Digest::CRC32XFER#update 0.026770 0.000000 0.026770 ( 0.026893)
279
+ Digest::CRC64#update 0.024400 0.000009 0.024409 ( 0.024531)
280
+ Digest::CRC64Jones#update 0.023477 0.000781 0.024258 ( 0.024390)
281
+ Digest::CRC64XZ#update 0.024611 0.000000 0.024611 ( 0.024779)
282
+
283
+ ### JRuby 9.2.18.0 (pure Ruby)
284
+
285
+ $ bundle exec ./benchmarks.rb
286
+ Loading Digest::CRC classes ...
287
+ Generating 1000 8Kb lengthed strings ...
288
+ Benchmarking Digest::CRC classes ...
289
+ user system total real
290
+ Digest::CRC1#update 1.080000 0.050000 1.130000 ( 0.676022)
291
+ Digest::CRC5#update 2.030000 0.040000 2.070000 ( 1.089240)
292
+ Digest::CRC8#update 1.590000 0.000000 1.590000 ( 0.999138)
293
+ Digest::CRC8_1Wire#update 0.920000 0.010000 0.930000 ( 0.873813)
294
+ Digest::CRC15#update 1.470000 0.030000 1.500000 ( 1.118886)
295
+ Digest::CRC16#update 1.780000 0.010000 1.790000 ( 1.067874)
296
+ Digest::CRC16CCITT#update 1.500000 0.070000 1.570000 ( 1.185564)
297
+ Digest::CRC16DNP#update 1.250000 0.000000 1.250000 ( 0.972322)
298
+ Digest::CRC16Genibus#update 1.700000 0.010000 1.710000 ( 1.092047)
299
+ Digest::CRC16Modbus#update 1.000000 0.010000 1.010000 ( 0.915328)
300
+ Digest::CRC16QT#update 1.250000 0.000000 1.250000 ( 0.968528)
301
+ Digest::CRC16USB#update 1.150000 0.010000 1.160000 ( 0.990387)
302
+ Digest::CRC16X25#update 0.940000 0.000000 0.940000 ( 0.926926)
303
+ Digest::CRC16XModem#update 1.390000 0.010000 1.400000 ( 1.100584)
304
+ Digest::CRC16ZModem#update 1.760000 0.020000 1.780000 ( 1.094003)
305
+ Digest::CRC24#update 1.690000 0.010000 1.700000 ( 1.106875)
306
+ Digest::CRC32#update 1.410000 0.020000 1.430000 ( 1.082506)
307
+ Digest::CRC32BZip2#update 1.510000 0.010000 1.520000 ( 1.104225)
308
+ Digest::CRC32c#update 1.270000 0.010000 1.280000 ( 1.023881)
309
+ Digest::CRC32Jam#update 1.190000 0.010000 1.200000 ( 0.998146)
310
+ Digest::CRC32MPEG#update 1.580000 0.010000 1.590000 ( 1.099086)
311
+ Digest::CRC32POSIX#update 1.550000 0.010000 1.560000 ( 1.142051)
312
+ Digest::CRC32XFER#update 1.360000 0.000000 1.360000 ( 1.071381)
313
+ Digest::CRC64#update 3.730000 0.020000 3.750000 ( 2.780390)
314
+ Digest::CRC64Jones#update 2.710000 0.020000 2.730000 ( 2.608007)
315
+ Digest::CRC64XZ#update 2.910000 0.020000 2.930000 ( 2.629401)
316
+
317
+ ### TruffleRuby 21.2.0 (pure Ruby)
318
+
319
+ $ bundle exec rake clean
320
+ $ bundle exec ./benchmarks.rb
321
+ Loading Digest::CRC classes ...
322
+ Generating 1000 8Kb lengthed strings ...
323
+ Benchmarking Digest::CRC classes ...
324
+ user system total real
325
+ Digest::CRC1#update 0.455340 0.000000 0.455340 ( 0.457710)
326
+ Digest::CRC5#update 1.406700 0.000000 1.406700 ( 1.412535)
327
+ Digest::CRC8#update 1.248323 0.000000 1.248323 ( 1.255452)
328
+ Digest::CRC8_1Wire#update 1.269434 0.000000 1.269434 ( 1.275315)
329
+ Digest::CRC15#update 1.428752 0.000000 1.428752 ( 1.434836)
330
+ Digest::CRC16#update 1.220394 0.000967 1.221361 ( 1.229684)
331
+ Digest::CRC16CCITT#update 1.434932 0.001000 1.435932 ( 1.452391)
332
+ Digest::CRC16DNP#update 1.191351 0.000000 1.191351 ( 1.202262)
333
+ Digest::CRC16Genibus#update 1.434067 0.000000 1.434067 ( 1.440300)
334
+ Digest::CRC16Modbus#update 1.200827 0.000000 1.200827 ( 1.205658)
335
+ Digest::CRC16QT#update 1.195077 0.000000 1.195077 ( 1.200328)
336
+ Digest::CRC16USB#update 1.196266 0.000000 1.196266 ( 1.201262)
337
+ Digest::CRC16X25#update 1.206690 0.000000 1.206690 ( 1.211781)
338
+ Digest::CRC16XModem#update 1.430468 0.000000 1.430468 ( 1.436801)
339
+ Digest::CRC16ZModem#update 1.442524 0.000000 1.442524 ( 1.448624)
340
+ Digest::CRC24#update 1.447611 0.000018 1.447629 ( 1.454534)
341
+ Digest::CRC32#update 1.214314 0.000000 1.214314 ( 1.219838)
342
+ Digest::CRC32BZip2#update 1.427408 0.000000 1.427408 ( 1.433626)
343
+ Digest::CRC32c#update 1.204985 0.000000 1.204985 ( 1.210273)
344
+ Digest::CRC32Jam#update 1.235039 0.000000 1.235039 ( 1.240686)
345
+ Digest::CRC32MPEG#update 1.429731 0.000000 1.429731 ( 1.435404)
346
+ Digest::CRC32POSIX#update 1.458886 0.000000 1.458886 ( 1.465914)
347
+ Digest::CRC32XFER#update 1.422109 0.000000 1.422109 ( 1.427635)
348
+ Digest::CRC64#update 3.283506 0.000000 3.283506 ( 3.303129)
349
+ Digest::CRC64Jones#update 3.297402 0.000000 3.297402 ( 3.317357)
350
+ Digest::CRC64XZ#update 3.278551 0.001875 3.280426 ( 3.315165)
351
+
352
+
353
+ ### TruffleRuby 21.2.0 (C extensions)
354
+
355
+ $ bundle exec rake build:c_exts
356
+ ...
215
357
  $ bundle exec ./benchmarks.rb
216
358
  Loading Digest::CRC classes ...
217
359
  Generating 1000 8Kb lengthed strings ...
218
360
  Benchmarking Digest::CRC classes ...
219
- user system total real
220
- Digest::CRC1#update 1.030000 0.090000 1.120000 ( 0.511189)
221
- Digest::CRC5#update 1.620000 0.060000 1.680000 ( 1.096031)
222
- Digest::CRC8#update 1.560000 0.070000 1.630000 ( 1.083921)
223
- Digest::CRC8_1Wire#update 0.930000 0.040000 0.970000 ( 0.927024)
224
- Digest::CRC15#update 1.590000 0.070000 1.660000 ( 1.132566)
225
- Digest::CRC16#update 1.650000 0.060000 1.710000 ( 1.074508)
226
- Digest::CRC16CCITT#update 1.610000 0.060000 1.670000 ( 1.190860)
227
- Digest::CRC16DNP#update 1.270000 0.010000 1.280000 ( 0.938132)
228
- Digest::CRC16Genibus#update 1.620000 0.030000 1.650000 ( 1.148556)
229
- Digest::CRC16Modbus#update 1.070000 0.020000 1.090000 ( 0.881455)
230
- Digest::CRC16X25#update 1.110000 0.010000 1.120000 ( 0.945366)
231
- Digest::CRC16USB#update 1.140000 0.000000 1.140000 ( 0.984367)
232
- Digest::CRC16X25#update 0.920000 0.010000 0.930000 ( 0.872541)
233
- Digest::CRC16XModem#update 1.530000 0.010000 1.540000 ( 1.092838)
234
- Digest::CRC16ZModem#update 1.720000 0.010000 1.730000 ( 1.164787)
235
- Digest::CRC24#update 1.810000 0.020000 1.830000 ( 1.084953)
236
- Digest::CRC32#update 1.590000 0.010000 1.600000 ( 1.105553)
237
- Digest::CRC32BZip2#update 1.520000 0.010000 1.530000 ( 1.070839)
238
- Digest::CRC32c#update 0.960000 0.010000 0.970000 ( 0.881989)
239
- Digest::CRC32Jam#update 1.030000 0.010000 1.040000 ( 0.907208)
240
- Digest::CRC32MPEG#update 1.420000 0.010000 1.430000 ( 0.994035)
241
- Digest::CRC32POSIX#update 1.530000 0.020000 1.550000 ( 1.106366)
242
- Digest::CRC32XFER#update 1.650000 0.010000 1.660000 ( 1.097647)
243
- Digest::CRC64#update 3.440000 0.030000 3.470000 ( 2.771806)
244
- Digest::CRC64Jones#update 2.630000 0.010000 2.640000 ( 2.628016)
245
- Digest::CRC64XZ#update 3.200000 0.020000 3.220000 ( 2.913442)
361
+ user system total real
362
+ Digest::CRC1#update 0.480586 0.000014 0.480600 ( 0.482817)
363
+ Digest::CRC5#update 0.023795 0.000000 0.023795 ( 0.023941)
364
+ Digest::CRC8#update 0.020619 0.000000 0.020619 ( 0.020747)
365
+ Digest::CRC8_1Wire#update 0.020571 0.000000 0.020571 ( 0.020700)
366
+ Digest::CRC15#update 0.031224 0.000000 0.031224 ( 0.031412)
367
+ Digest::CRC16#update 0.024013 0.000000 0.024013 ( 0.024174)
368
+ Digest::CRC16CCITT#update 0.026790 0.000000 0.026790 ( 0.027079)
369
+ Digest::CRC16DNP#update 0.024253 0.000000 0.024253 ( 0.024427)
370
+ Digest::CRC16Genibus#update 0.027237 0.000000 0.027237 ( 0.027390)
371
+ Digest::CRC16Modbus#update 0.024376 0.000000 0.024376 ( 0.024548)
372
+ Digest::CRC16QT#update 0.024361 0.000000 0.024361 ( 0.024518)
373
+ Digest::CRC16USB#update 0.024142 0.000000 0.024142 ( 0.024311)
374
+ Digest::CRC16X25#update 0.024098 0.000000 0.024098 ( 0.024222)
375
+ Digest::CRC16XModem#update 0.026306 0.000000 0.026306 ( 0.026502)
376
+ Digest::CRC16ZModem#update 0.026536 0.000000 0.026536 ( 0.026688)
377
+ Digest::CRC24#update 0.029732 0.000000 0.029732 ( 0.029902)
378
+ Digest::CRC32#update 0.024219 0.000000 0.024219 ( 0.024391)
379
+ Digest::CRC32BZip2#update 0.026817 0.000000 0.026817 ( 0.027044)
380
+ Digest::CRC32c#update 0.023681 0.000000 0.023681 ( 0.023798)
381
+ Digest::CRC32Jam#update 0.024243 0.000000 0.024243 ( 0.024419)
382
+ Digest::CRC32MPEG#update 0.026865 0.000000 0.026865 ( 0.027020)
383
+ Digest::CRC32POSIX#update 0.026583 0.000000 0.026583 ( 0.026748)
384
+ Digest::CRC32XFER#update 0.027423 0.000000 0.027423 ( 0.027615)
385
+ Digest::CRC64#update 0.024150 0.000000 0.024150 ( 0.024310)
386
+ Digest::CRC64Jones#update 0.024218 0.000000 0.024218 ( 0.024363)
387
+ Digest::CRC64XZ#update 0.024124 0.000000 0.024124 ( 0.024255)
388
+
389
+ ## Crystal
390
+
391
+ [crystal-crc] is a [Crystal][crystal-lang] port of this library.
392
+
393
+ [crystal-crc]: https://github.com/postmodern/crystal-crc
394
+ [crystal-lang]: https://www.crystal-lang.org/
246
395
 
247
396
  ## Thanks
248
397
 
@@ -252,6 +401,6 @@ including their CRC Tables.
252
401
 
253
402
  ## License
254
403
 
255
- Copyright (c) 2010-2020 Hal Brodigan
404
+ Copyright (c) 2010-2021 Hal Brodigan
256
405
 
257
406
  See {file:LICENSE.txt} for license information.
data/benchmarks.rb CHANGED
@@ -44,7 +44,7 @@ SAMPLES = Array.new(N) do
44
44
  end
45
45
 
46
46
  puts "Benchmarking Digest::CRC classes ..."
47
- Benchmark.bm do |b|
47
+ Benchmark.bm(27) do |b|
48
48
  CRCs.each_value do |crc|
49
49
  crc_class = Digest.const_get(crc)
50
50
  crc = crc_class.new
@@ -23,5 +23,10 @@ void Init_crc12_3gpp_ext()
23
23
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
24
24
  VALUE cCRC12_3GPP = rb_const_get(mDigest, rb_intern("CRC12_3GPP"));
25
25
 
26
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
27
+ rb_ext_ractor_safe(true);
28
+ #endif
29
+
30
+ rb_undef_method(cCRC12_3GPP, "update");
26
31
  rb_define_method(cCRC12_3GPP, "update", Digest_CRC12_3GPP_update, 1);
27
32
  }
@@ -24,5 +24,10 @@ void Init_crc15_ext()
24
24
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
25
25
  VALUE cCRC15 = rb_const_get(mDigest, rb_intern("CRC15"));
26
26
 
27
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
28
+ rb_ext_ractor_safe(true);
29
+ #endif
30
+
31
+ rb_undef_method(cCRC15, "update");
27
32
  rb_define_method(cCRC15, "update", Digest_CRC15_update, 1);
28
33
  }
@@ -24,5 +24,10 @@ void Init_crc16_ext()
24
24
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
25
25
  VALUE cCRC16 = rb_const_get(mDigest, rb_intern("CRC16"));
26
26
 
27
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
28
+ rb_ext_ractor_safe(true);
29
+ #endif
30
+
31
+ rb_undef_method(cCRC16, "update");
27
32
  rb_define_method(cCRC16, "update", Digest_CRC16_update, 1);
28
33
  }
@@ -24,5 +24,10 @@ void Init_crc16_ccitt_ext()
24
24
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
25
25
  VALUE cCRC16CCITT = rb_const_get(mDigest, rb_intern("CRC16CCITT"));
26
26
 
27
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
28
+ rb_ext_ractor_safe(true);
29
+ #endif
30
+
31
+ rb_undef_method(cCRC16CCITT, "update");
27
32
  rb_define_method(cCRC16CCITT, "update", Digest_CRC16CCITT_update, 1);
28
33
  }
@@ -24,5 +24,10 @@ void Init_crc16_dnp_ext()
24
24
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
25
25
  VALUE cCRC16DNP = rb_const_get(mDigest, rb_intern("CRC16DNP"));
26
26
 
27
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
28
+ rb_ext_ractor_safe(true);
29
+ #endif
30
+
31
+ rb_undef_method(cCRC16DNP, "update");
27
32
  rb_define_method(cCRC16DNP, "update", Digest_CRC16DNP_update, 1);
28
33
  }
@@ -24,5 +24,10 @@ void Init_crc16_genibus_ext()
24
24
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
25
25
  VALUE cCRC16Genibus = rb_const_get(mDigest, rb_intern("CRC16Genibus"));
26
26
 
27
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
28
+ rb_ext_ractor_safe(true);
29
+ #endif
30
+
31
+ rb_undef_method(cCRC16Genibus, "update");
27
32
  rb_define_method(cCRC16Genibus, "update", Digest_CRC16Genibus_update, 1);
28
33
  }
@@ -24,5 +24,10 @@ void Init_crc16_kermit_ext()
24
24
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
25
25
  VALUE cCRC16Kermit = rb_const_get(mDigest, rb_intern("CRC16Kermit"));
26
26
 
27
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
28
+ rb_ext_ractor_safe(true);
29
+ #endif
30
+
31
+ rb_undef_method(cCRC16Kermit, "update");
27
32
  rb_define_method(cCRC16Kermit, "update", Digest_CRC16Kermit_update, 1);
28
33
  }
@@ -24,5 +24,9 @@ void Init_crc16_modbus_ext()
24
24
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
25
25
  VALUE cCRC16Modbus = rb_const_get(mDigest, rb_intern("CRC16Modbus"));
26
26
 
27
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
28
+ rb_ext_ractor_safe(true);
29
+ #endif
30
+
27
31
  rb_define_method(cCRC16Modbus, "update", Digest_CRC16Modbus_update, 1);
28
32
  }
@@ -24,5 +24,9 @@ void Init_crc16_usb_ext()
24
24
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
25
25
  VALUE cCRC16USB = rb_const_get(mDigest, rb_intern("CRC16USB"));
26
26
 
27
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
28
+ rb_ext_ractor_safe(true);
29
+ #endif
30
+
27
31
  rb_define_method(cCRC16USB, "update", Digest_CRC16USB_update, 1);
28
32
  }
@@ -24,5 +24,9 @@ void Init_crc16_x_25_ext()
24
24
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
25
25
  VALUE cCRC16X25 = rb_const_get(mDigest, rb_intern("CRC16X25"));
26
26
 
27
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
28
+ rb_ext_ractor_safe(true);
29
+ #endif
30
+
27
31
  rb_define_method(cCRC16X25, "update", Digest_CRC16X25_update, 1);
28
32
  }
@@ -24,5 +24,10 @@ void Init_crc16_xmodem_ext()
24
24
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
25
25
  VALUE cCRC16XModem = rb_const_get(mDigest, rb_intern("CRC16XModem"));
26
26
 
27
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
28
+ rb_ext_ractor_safe(true);
29
+ #endif
30
+
31
+ rb_undef_method(cCRC16XModem, "update");
27
32
  rb_define_method(cCRC16XModem, "update", Digest_CRC16XModem_update, 1);
28
33
  }
@@ -24,5 +24,10 @@ void Init_crc16_zmodem_ext()
24
24
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
25
25
  VALUE cCRC16ZModem = rb_const_get(mDigest, rb_intern("CRC16ZModem"));
26
26
 
27
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
28
+ rb_ext_ractor_safe(true);
29
+ #endif
30
+
31
+ rb_undef_method(cCRC16ZModem, "update");
27
32
  rb_define_method(cCRC16ZModem, "update", Digest_CRC16ZModem_update, 1);
28
33
  }
@@ -23,5 +23,10 @@ void Init_crc24_ext()
23
23
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
24
24
  VALUE cCRC24 = rb_const_get(mDigest, rb_intern("CRC24"));
25
25
 
26
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
27
+ rb_ext_ractor_safe(true);
28
+ #endif
29
+
30
+ rb_undef_method(cCRC24, "update");
26
31
  rb_define_method(cCRC24, "update", Digest_CRC24_update, 1);
27
32
  }
@@ -23,5 +23,10 @@ void Init_crc32_ext()
23
23
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
24
24
  VALUE cCRC32 = rb_const_get(mDigest, rb_intern("CRC32"));
25
25
 
26
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
27
+ rb_ext_ractor_safe(true);
28
+ #endif
29
+
30
+ rb_undef_method(cCRC32, "update");
26
31
  rb_define_method(cCRC32, "update", Digest_CRC32_update, 1);
27
32
  }
@@ -23,5 +23,10 @@ void Init_crc32_bzip2_ext()
23
23
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
24
24
  VALUE cCRC32Bzip2 = rb_const_get(mDigest, rb_intern("CRC32BZip2"));
25
25
 
26
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
27
+ rb_ext_ractor_safe(true);
28
+ #endif
29
+
30
+ rb_undef_method(cCRC32Bzip2, "update");
26
31
  rb_define_method(cCRC32Bzip2, "update", Digest_CRC32Bzip2_update, 1);
27
32
  }
@@ -23,5 +23,9 @@ void Init_crc32_jam_ext()
23
23
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
24
24
  VALUE cCRC32Jam = rb_const_get(mDigest, rb_intern("CRC32Jam"));
25
25
 
26
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
27
+ rb_ext_ractor_safe(true);
28
+ #endif
29
+
26
30
  rb_define_method(cCRC32Jam, "update", Digest_CRC32Jam_update, 1);
27
31
  }
@@ -23,5 +23,10 @@ void Init_crc32_mpeg_ext()
23
23
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
24
24
  VALUE cCRC32MPEG = rb_const_get(mDigest, rb_intern("CRC32MPEG"));
25
25
 
26
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
27
+ rb_ext_ractor_safe(true);
28
+ #endif
29
+
30
+ rb_undef_method(cCRC32MPEG, "update");
26
31
  rb_define_method(cCRC32MPEG, "update", Digest_CRC32MPEG_update, 1);
27
32
  }
@@ -23,5 +23,10 @@ void Init_crc32_posix_ext()
23
23
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
24
24
  VALUE cCRC32POSIX = rb_const_get(mDigest, rb_intern("CRC32POSIX"));
25
25
 
26
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
27
+ rb_ext_ractor_safe(true);
28
+ #endif
29
+
30
+ rb_undef_method(cCRC32POSIX, "update");
26
31
  rb_define_method(cCRC32POSIX, "update", Digest_CRC32POSIX_update, 1);
27
32
  }
@@ -23,5 +23,10 @@ void Init_crc32_xfer_ext()
23
23
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
24
24
  VALUE cCRC32XFER = rb_const_get(mDigest, rb_intern("CRC32XFER"));
25
25
 
26
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
27
+ rb_ext_ractor_safe(true);
28
+ #endif
29
+
30
+ rb_undef_method(cCRC32XFER, "update");
26
31
  rb_define_method(cCRC32XFER, "update", Digest_CRC32XFER_update, 1);
27
32
  }
@@ -23,5 +23,9 @@ void Init_crc32c_ext()
23
23
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
24
24
  VALUE cCRC32c = rb_const_get(mDigest, rb_intern("CRC32c"));
25
25
 
26
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
27
+ rb_ext_ractor_safe(true);
28
+ #endif
29
+
26
30
  rb_define_method(cCRC32c, "update", Digest_CRC32c_update, 1);
27
31
  }
@@ -23,5 +23,10 @@ void Init_crc5_ext()
23
23
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
24
24
  VALUE cCRC5 = rb_const_get(mDigest, rb_intern("CRC5"));
25
25
 
26
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
27
+ rb_ext_ractor_safe(true);
28
+ #endif
29
+
30
+ rb_undef_method(cCRC5, "update");
26
31
  rb_define_method(cCRC5, "update", Digest_CRC5_update, 1);
27
32
  }
@@ -23,5 +23,10 @@ void Init_crc64_ext()
23
23
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
24
24
  VALUE cCRC64 = rb_const_get(mDigest, rb_intern("CRC64"));
25
25
 
26
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
27
+ rb_ext_ractor_safe(true);
28
+ #endif
29
+
30
+ rb_undef_method(cCRC64, "update");
26
31
  rb_define_method(cCRC64, "update", Digest_CRC64_update, 1);
27
32
  }
@@ -23,5 +23,9 @@ void Init_crc64_jones_ext()
23
23
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
24
24
  VALUE cCRC64Jones = rb_const_get(mDigest, rb_intern("CRC64Jones"));
25
25
 
26
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
27
+ rb_ext_ractor_safe(true);
28
+ #endif
29
+
26
30
  rb_define_method(cCRC64Jones, "update", Digest_CRC64Jones_update, 1);
27
31
  }
@@ -23,5 +23,9 @@ void Init_crc64_xz_ext()
23
23
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
24
24
  VALUE cCRC64XZ = rb_const_get(mDigest, rb_intern("CRC64XZ"));
25
25
 
26
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
27
+ rb_ext_ractor_safe(true);
28
+ #endif
29
+
26
30
  rb_define_method(cCRC64XZ, "update", Digest_CRC64XZ_update, 1);
27
31
  }
@@ -23,5 +23,10 @@ void Init_crc8_ext()
23
23
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
24
24
  VALUE cCRC8 = rb_const_get(mDigest, rb_intern("CRC8"));
25
25
 
26
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
27
+ rb_ext_ractor_safe(true);
28
+ #endif
29
+
30
+ rb_undef_method(cCRC8, "update");
26
31
  rb_define_method(cCRC8, "update", Digest_CRC8_update, 1);
27
32
  }
@@ -23,5 +23,9 @@ void Init_crc8_1wire_ext()
23
23
  VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
24
24
  VALUE cCRC81Wire = rb_const_get(mDigest, rb_intern("CRC8_1Wire"));
25
25
 
26
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
27
+ rb_ext_ractor_safe(true);
28
+ #endif
29
+
26
30
  rb_define_method(cCRC81Wire, "update", Digest_CRC81Wire_update, 1);
27
31
  }
data/gemspec.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  name: digest-crc
2
- version: 0.6.3
2
+ version: 0.6.5
3
3
  summary: A Cyclic Redundancy Check (CRC) library for Ruby.
4
4
  description:
5
5
  Adds support for calculating Cyclic Redundancy Check (CRC) to the Digest
@@ -12,9 +12,9 @@ homepage: https://github.com/postmodern/digest-crc#readme
12
12
 
13
13
  metadata:
14
14
  documentation_uri: https://rubydoc.info/gems/digest-crc
15
- source_code_uri: https://github.com/postmodern/digest-crc
16
- bug_tracker_uri: https://github.com/postmodern/digest-crc/issues
17
- changelog_uri: https://github.com/postmodern/digest-crc/blob/master/ChangeLog.md
15
+ source_code_uri: https://github.com/postmodern/digest-crc
16
+ bug_tracker_uri: https://github.com/postmodern/digest-crc/issues
17
+ changelog_uri: https://github.com/postmodern/digest-crc/blob/master/ChangeLog.md
18
18
 
19
19
  extensions:
20
20
  - ext/digest/Rakefile
data/lib/digest/crc5.rb CHANGED
@@ -12,26 +12,26 @@ module Digest
12
12
 
13
13
  XOR_MASK = 0x1f
14
14
 
15
- CRC_MASK = (0x1f << 3)
15
+ CRC_MASK = 0x1f
16
16
 
17
17
  # Generated by `./pycrc.py --algorithm=table-driven --model=crc-5 --generate=c`
18
18
  TABLE = [
19
- 0x00, 0x70, 0xe0, 0x90, 0x88, 0xf8, 0x68, 0x18, 0x58, 0x28, 0xb8, 0xc8, 0xd0, 0xa0, 0x30, 0x40,
20
- 0xb0, 0xc0, 0x50, 0x20, 0x38, 0x48, 0xd8, 0xa8, 0xe8, 0x98, 0x08, 0x78, 0x60, 0x10, 0x80, 0xf0,
21
- 0x28, 0x58, 0xc8, 0xb8, 0xa0, 0xd0, 0x40, 0x30, 0x70, 0x00, 0x90, 0xe0, 0xf8, 0x88, 0x18, 0x68,
22
- 0x98, 0xe8, 0x78, 0x08, 0x10, 0x60, 0xf0, 0x80, 0xc0, 0xb0, 0x20, 0x50, 0x48, 0x38, 0xa8, 0xd8,
23
- 0x50, 0x20, 0xb0, 0xc0, 0xd8, 0xa8, 0x38, 0x48, 0x08, 0x78, 0xe8, 0x98, 0x80, 0xf0, 0x60, 0x10,
24
- 0xe0, 0x90, 0x00, 0x70, 0x68, 0x18, 0x88, 0xf8, 0xb8, 0xc8, 0x58, 0x28, 0x30, 0x40, 0xd0, 0xa0,
25
- 0x78, 0x08, 0x98, 0xe8, 0xf0, 0x80, 0x10, 0x60, 0x20, 0x50, 0xc0, 0xb0, 0xa8, 0xd8, 0x48, 0x38,
26
- 0xc8, 0xb8, 0x28, 0x58, 0x40, 0x30, 0xa0, 0xd0, 0x90, 0xe0, 0x70, 0x00, 0x18, 0x68, 0xf8, 0x88,
27
- 0xa0, 0xd0, 0x40, 0x30, 0x28, 0x58, 0xc8, 0xb8, 0xf8, 0x88, 0x18, 0x68, 0x70, 0x00, 0x90, 0xe0,
28
- 0x10, 0x60, 0xf0, 0x80, 0x98, 0xe8, 0x78, 0x08, 0x48, 0x38, 0xa8, 0xd8, 0xc0, 0xb0, 0x20, 0x50,
29
- 0x88, 0xf8, 0x68, 0x18, 0x00, 0x70, 0xe0, 0x90, 0xd0, 0xa0, 0x30, 0x40, 0x58, 0x28, 0xb8, 0xc8,
30
- 0x38, 0x48, 0xd8, 0xa8, 0xb0, 0xc0, 0x50, 0x20, 0x60, 0x10, 0x80, 0xf0, 0xe8, 0x98, 0x08, 0x78,
31
- 0xf0, 0x80, 0x10, 0x60, 0x78, 0x08, 0x98, 0xe8, 0xa8, 0xd8, 0x48, 0x38, 0x20, 0x50, 0xc0, 0xb0,
32
- 0x40, 0x30, 0xa0, 0xd0, 0xc8, 0xb8, 0x28, 0x58, 0x18, 0x68, 0xf8, 0x88, 0x90, 0xe0, 0x70, 0x00,
33
- 0xd8, 0xa8, 0x38, 0x48, 0x50, 0x20, 0xb0, 0xc0, 0x80, 0xf0, 0x60, 0x10, 0x08, 0x78, 0xe8, 0x98,
34
- 0x68, 0x18, 0x88, 0xf8, 0xe0, 0x90, 0x00, 0x70, 0x30, 0x40, 0xd0, 0xa0, 0xb8, 0xc8, 0x58, 0x28
19
+ 0x00, 0x0e, 0x1c, 0x12, 0x11, 0x1f, 0x0d, 0x03, 0x0b, 0x05, 0x17, 0x19, 0x1a, 0x14, 0x06, 0x08,
20
+ 0x16, 0x18, 0x0a, 0x04, 0x07, 0x09, 0x1b, 0x15, 0x1d, 0x13, 0x01, 0x0f, 0x0c, 0x02, 0x10, 0x1e,
21
+ 0x05, 0x0b, 0x19, 0x17, 0x14, 0x1a, 0x08, 0x06, 0x0e, 0x00, 0x12, 0x1c, 0x1f, 0x11, 0x03, 0x0d,
22
+ 0x13, 0x1d, 0x0f, 0x01, 0x02, 0x0c, 0x1e, 0x10, 0x18, 0x16, 0x04, 0x0a, 0x09, 0x07, 0x15, 0x1b,
23
+ 0x0a, 0x04, 0x16, 0x18, 0x1b, 0x15, 0x07, 0x09, 0x01, 0x0f, 0x1d, 0x13, 0x10, 0x1e, 0x0c, 0x02,
24
+ 0x1c, 0x12, 0x00, 0x0e, 0x0d, 0x03, 0x11, 0x1f, 0x17, 0x19, 0x0b, 0x05, 0x06, 0x08, 0x1a, 0x14,
25
+ 0x0f, 0x01, 0x13, 0x1d, 0x1e, 0x10, 0x02, 0x0c, 0x04, 0x0a, 0x18, 0x16, 0x15, 0x1b, 0x09, 0x07,
26
+ 0x19, 0x17, 0x05, 0x0b, 0x08, 0x06, 0x14, 0x1a, 0x12, 0x1c, 0x0e, 0x00, 0x03, 0x0d, 0x1f, 0x11,
27
+ 0x14, 0x1a, 0x08, 0x06, 0x05, 0x0b, 0x19, 0x17, 0x1f, 0x11, 0x03, 0x0d, 0x0e, 0x00, 0x12, 0x1c,
28
+ 0x02, 0x0c, 0x1e, 0x10, 0x13, 0x1d, 0x0f, 0x01, 0x09, 0x07, 0x15, 0x1b, 0x18, 0x16, 0x04, 0x0a,
29
+ 0x11, 0x1f, 0x0d, 0x03, 0x00, 0x0e, 0x1c, 0x12, 0x1a, 0x14, 0x06, 0x08, 0x0b, 0x05, 0x17, 0x19,
30
+ 0x07, 0x09, 0x1b, 0x15, 0x16, 0x18, 0x0a, 0x04, 0x0c, 0x02, 0x10, 0x1e, 0x1d, 0x13, 0x01, 0x0f,
31
+ 0x1e, 0x10, 0x02, 0x0c, 0x0f, 0x01, 0x13, 0x1d, 0x15, 0x1b, 0x09, 0x07, 0x04, 0x0a, 0x18, 0x16,
32
+ 0x08, 0x06, 0x14, 0x1a, 0x19, 0x17, 0x05, 0x0b, 0x03, 0x0d, 0x1f, 0x11, 0x12, 0x1c, 0x0e, 0x00,
33
+ 0x1b, 0x15, 0x07, 0x09, 0x0a, 0x04, 0x16, 0x18, 0x10, 0x1e, 0x0c, 0x02, 0x01, 0x0f, 0x1d, 0x13,
34
+ 0x0d, 0x03, 0x11, 0x1f, 0x1c, 0x12, 0x00, 0x0e, 0x06, 0x08, 0x1a, 0x14, 0x17, 0x19, 0x0b, 0x05
35
35
  ].freeze
36
36
 
37
37
  #
@@ -64,7 +64,7 @@ module Digest
64
64
  #
65
65
  def update(data)
66
66
  data.each_byte do |b|
67
- @crc = ((@table[((@crc >> 3) ^ b) & 0xff] ^ (@crc >> 8)) & @crc_mask)
67
+ @crc = ((@table[(@crc ^ b) & 0xff] ^ (@crc >> 8)) & @crc_mask)
68
68
  end
69
69
 
70
70
  return self
data/spec/crc5_spec.rb CHANGED
@@ -4,9 +4,7 @@ require 'digest/crc5'
4
4
 
5
5
  describe Digest::CRC5 do
6
6
  let(:string) { '1234567890' }
7
- let(:expected) { '1' }
7
+ let(:expected) { '01' }
8
8
 
9
- pending "Implementation of CRC5 does not match pycrc.py" do
10
- it_should_behave_like "CRC"
11
- end
9
+ it_should_behave_like "CRC"
12
10
  end
data/spec/crc_examples.rb CHANGED
@@ -24,4 +24,14 @@ shared_examples_for "CRC" do
24
24
 
25
25
  expect(crc.checksum).to be == expected.to_i(16)
26
26
  end
27
+
28
+ if defined?(Ractor)
29
+ it "should calculate CRC inside ractor" do
30
+ digest = Ractor.new(described_class, string) do |klass, string|
31
+ klass.hexdigest(string)
32
+ end.take
33
+
34
+ expect(digest).to eq expected
35
+ end
36
+ end
27
37
  end
data/spec/spec_helper.rb CHANGED
@@ -1 +1,3 @@
1
1
  require 'rspec'
2
+ require 'simplecov'
3
+ SimpleCov.start
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: digest-crc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Postmodern
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-20 00:00:00.000000000 Z
11
+ date: 2023-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -243,7 +243,7 @@ metadata:
243
243
  source_code_uri: https://github.com/postmodern/digest-crc
244
244
  bug_tracker_uri: https://github.com/postmodern/digest-crc/issues
245
245
  changelog_uri: https://github.com/postmodern/digest-crc/blob/master/ChangeLog.md
246
- post_install_message:
246
+ post_install_message:
247
247
  rdoc_options: []
248
248
  require_paths:
249
249
  - ext
@@ -259,8 +259,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
259
259
  - !ruby/object:Gem::Version
260
260
  version: '0'
261
261
  requirements: []
262
- rubygems_version: 3.1.4
263
- signing_key:
262
+ rubygems_version: 3.4.10
263
+ signing_key:
264
264
  specification_version: 4
265
265
  summary: A Cyclic Redundancy Check (CRC) library for Ruby.
266
266
  test_files: []