digest-crc 0.6.4 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/integration.yml +1 -1
- data/.github/workflows/ruby.yml +6 -6
- data/ChangeLog.md +11 -0
- data/Gemfile +2 -1
- data/LICENSE.txt +1 -1
- data/README.md +5 -10
- data/benchmarks.rb +1 -0
- data/digest-crc.gemspec +8 -4
- data/ext/digest/crc12_3gpp/crc12_3gpp_ext.c +4 -0
- data/ext/digest/crc15/crc15_ext.c +4 -0
- data/ext/digest/crc16/crc16_ext.c +4 -0
- data/ext/digest/crc16_ccitt/crc16_ccitt_ext.c +4 -0
- data/ext/digest/crc16_dnp/crc16_dnp_ext.c +4 -0
- data/ext/digest/crc16_genibus/crc16_genibus_ext.c +4 -0
- data/ext/digest/crc16_kermit/crc16_kermit_ext.c +4 -0
- data/ext/digest/crc16_modbus/crc16_modbus_ext.c +4 -1
- data/ext/digest/crc16_usb/crc16_usb_ext.c +4 -1
- data/ext/digest/crc16_x_25/crc16_x_25_ext.c +4 -1
- data/ext/digest/crc16_xmodem/crc16_xmodem_ext.c +4 -0
- data/ext/digest/crc16_zmodem/crc16_zmodem_ext.c +4 -0
- data/ext/digest/crc24/crc24_ext.c +4 -0
- data/ext/digest/crc32/crc32_ext.c +4 -0
- data/ext/digest/crc32_bzip2/crc32_bzip2_ext.c +4 -0
- data/ext/digest/crc32_jam/crc32_jam_ext.c +4 -1
- data/ext/digest/crc32_mpeg/crc32_mpeg_ext.c +4 -0
- data/ext/digest/crc32_posix/crc32_posix_ext.c +4 -0
- data/ext/digest/crc32_xfer/crc32_xfer_ext.c +4 -0
- data/ext/digest/crc32c/crc32c_ext.c +4 -1
- data/ext/digest/crc5/crc5_ext.c +4 -0
- data/ext/digest/crc64/crc64_ext.c +4 -0
- data/ext/digest/crc64_jones/crc64_jones_ext.c +4 -1
- data/ext/digest/crc64_nvme/crc64_nvme.c +102 -0
- data/ext/digest/crc64_nvme/crc64_nvme.h +8 -0
- data/ext/digest/crc64_nvme/crc64_nvme_ext.c +31 -0
- data/ext/digest/crc64_nvme/extconf.rb +7 -0
- data/ext/digest/crc64_xz/crc64_xz_ext.c +4 -1
- data/ext/digest/crc8/crc8_ext.c +4 -0
- data/ext/digest/crc8_1wire/crc8_1wire_ext.c +4 -1
- data/gemspec.yml +1 -1
- data/lib/digest/crc.rb +85 -9
- data/lib/digest/crc1.rb +2 -0
- data/lib/digest/crc15.rb +2 -32
- data/lib/digest/crc16.rb +2 -32
- data/lib/digest/crc16_ccitt.rb +2 -14
- data/lib/digest/crc16_dnp.rb +2 -14
- data/lib/digest/crc16_genibus.rb +2 -14
- data/lib/digest/crc16_kermit.rb +2 -14
- data/lib/digest/crc16_x_25.rb +3 -1
- data/lib/digest/crc16_xmodem.rb +2 -14
- data/lib/digest/crc16_zmodem.rb +2 -14
- data/lib/digest/crc24.rb +2 -33
- data/lib/digest/crc32.rb +2 -34
- data/lib/digest/crc32_bzip2.rb +2 -14
- data/lib/digest/crc32_mpeg.rb +2 -14
- data/lib/digest/crc32_posix.rb +2 -14
- data/lib/digest/crc32_xfer.rb +2 -14
- data/lib/digest/crc5.rb +19 -44
- data/lib/digest/crc64.rb +2 -38
- data/lib/digest/crc64_nvme.rb +90 -0
- data/lib/digest/crc8.rb +2 -27
- metadata +8 -36
- data/spec/crc15_spec.rb +0 -10
- data/spec/crc16_ccitt_spec.rb +0 -10
- data/spec/crc16_genibus_spec.rb +0 -10
- data/spec/crc16_kermit_spec.rb +0 -10
- data/spec/crc16_modbus_spec.rb +0 -10
- data/spec/crc16_qt_spec.rb +0 -10
- data/spec/crc16_spec.rb +0 -10
- data/spec/crc16_usb_spec.rb +0 -10
- data/spec/crc16_x_25_spec.rb +0 -10
- data/spec/crc16_xmodem_spec.rb +0 -10
- data/spec/crc16_zmodem_spec.rb +0 -10
- data/spec/crc1_spec.rb +0 -10
- data/spec/crc24_spec.rb +0 -10
- data/spec/crc32_bzip2_spec.rb +0 -10
- data/spec/crc32_jam_spec.rb +0 -10
- data/spec/crc32_mpeg_spec.rb +0 -16
- data/spec/crc32_posix_spec.rb +0 -10
- data/spec/crc32_spec.rb +0 -10
- data/spec/crc32_xfer_spec.rb +0 -10
- data/spec/crc32c_spec.rb +0 -10
- data/spec/crc5_spec.rb +0 -12
- data/spec/crc64_jones_spec.rb +0 -10
- data/spec/crc64_spec.rb +0 -10
- data/spec/crc64_xz_spec.rb +0 -10
- data/spec/crc8_1wire_spec.rb +0 -16
- data/spec/crc8_spec.rb +0 -10
- data/spec/crc_examples.rb +0 -27
- data/spec/crc_spec.rb +0 -72
- data/spec/integration/docker/Dockerfile.base +0 -9
- data/spec/integration/docker/Dockerfile.with-gcc +0 -3
- data/spec/integration/docker/Dockerfile.with-gcc-and-make +0 -3
- data/spec/integration/install_spec.rb +0 -59
- data/spec/spec_helper.rb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc7bf9540848173d66f9cd834da9d5a77d2f185bfe839023195cd16c6041dd6d
|
4
|
+
data.tar.gz: 5fb1d168b82d68f2bec09eecfeb6666d47a6ad0c46689b9320a67c5791975dd3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 768dc6d55b6aaa199d56c1d554d6f7dc91a53c2f774e381dce0772bd6430e0e58b0e1a7d4cede0397e30e6eed4238214a636dedac061d7cfbf0b931b668f0590
|
7
|
+
data.tar.gz: 3273faef714eb259b681b56c825c7cba2e7950fe25a2d7a275ae2e19af92e15d09b7d1ab811572fc27d55bcf42f1d6b5c7955261e937b94c80d214af608dd216
|
data/.github/workflows/ruby.yml
CHANGED
@@ -12,15 +12,15 @@ jobs:
|
|
12
12
|
- ubuntu-latest
|
13
13
|
- macos-latest
|
14
14
|
ruby:
|
15
|
-
-
|
16
|
-
-
|
17
|
-
- 2
|
18
|
-
-
|
19
|
-
- 3.0
|
15
|
+
- '3.0'
|
16
|
+
- '3.1'
|
17
|
+
- '3.2'
|
18
|
+
- '3.3'
|
20
19
|
- jruby
|
20
|
+
- truffleruby
|
21
21
|
name: OS ${{ matrix.os }} / Ruby ${{ matrix.ruby }}
|
22
22
|
steps:
|
23
|
-
- uses: actions/checkout@
|
23
|
+
- uses: actions/checkout@v4
|
24
24
|
- name: Set up Ruby
|
25
25
|
uses: ruby/setup-ruby@v1
|
26
26
|
with:
|
data/ChangeLog.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
### 0.7.0 / 2025-01-28
|
2
|
+
|
3
|
+
* Added {Digest::CRC64NVMe}.
|
4
|
+
* Added {Digest::CRC.implementation}.
|
5
|
+
* Reduced duplicate code.
|
6
|
+
|
7
|
+
### 0.6.5 / 2023-07-03
|
8
|
+
|
9
|
+
* Corrected the implementation of {Digest::CRC5}.
|
10
|
+
* Make `digest-crc` Ractor-safe.
|
11
|
+
|
1
12
|
### 0.6.4 / 2021-07-14
|
2
13
|
|
3
14
|
* Silence potential method redefinition warnings when loading the C extensions.
|
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -40,6 +40,7 @@ module.
|
|
40
40
|
* [CRC32 XFER](https://rubydoc.info/gems/digest-crc/Digest/CRC32XFER)
|
41
41
|
* [CRC64](https://rubydoc.info/gems/digest-crc/Digest/CRC64)
|
42
42
|
* [CRC64 Jones](https://rubydoc.info/gems/digest-crc/Digest/CRC64Jones)
|
43
|
+
* [CRC64 NVMe](https://rubydoc.info/gems/digest-crc/Digest/CRC64Nvme)
|
43
44
|
* [CRC64 XZ](https://rubydoc.info/gems/digest-crc/Digest/CRC64XZ)
|
44
45
|
* Pure Ruby implementation.
|
45
46
|
* Provides CRC Tables for optimized calculations.
|
@@ -115,7 +116,9 @@ require 'digest/crc32'
|
|
115
116
|
module Digest
|
116
117
|
class CRC3000 < CRC32
|
117
118
|
|
118
|
-
WIDTH =
|
119
|
+
WIDTH = 32
|
120
|
+
|
121
|
+
REFLECT_INPUT = true
|
119
122
|
|
120
123
|
INIT_CRC = 0xffffffff
|
121
124
|
|
@@ -124,14 +127,6 @@ module Digest
|
|
124
127
|
TABLE = [
|
125
128
|
# ....
|
126
129
|
].freeze
|
127
|
-
|
128
|
-
def update(data)
|
129
|
-
data.each_byte do |b|
|
130
|
-
@crc = (((@crc >> 8) & 0x00ffffff) ^ @table[(@crc ^ b) & 0xff])
|
131
|
-
end
|
132
|
-
|
133
|
-
return self
|
134
|
-
end
|
135
130
|
end
|
136
131
|
end
|
137
132
|
```
|
@@ -401,6 +396,6 @@ including their CRC Tables.
|
|
401
396
|
|
402
397
|
## License
|
403
398
|
|
404
|
-
Copyright (c) 2010-
|
399
|
+
Copyright (c) 2010-2025 Hal Brodigan
|
405
400
|
|
406
401
|
See {file:LICENSE.txt} for license information.
|
data/benchmarks.rb
CHANGED
data/digest-crc.gemspec
CHANGED
@@ -22,10 +22,14 @@ Gem::Specification.new do |gem|
|
|
22
22
|
gem.homepage = gemspec['homepage']
|
23
23
|
gem.metadata = gemspec['metadata'] if gemspec['metadata']
|
24
24
|
|
25
|
-
glob =
|
25
|
+
glob = ->(patterns) { gem.files & Dir[*patterns] }
|
26
26
|
|
27
|
-
gem.files =
|
28
|
-
|
27
|
+
gem.files = if gemspec['files'] then glob[gemspec['files']]
|
28
|
+
else `git ls-files`.split($/)
|
29
|
+
end
|
30
|
+
|
31
|
+
# exclude test files from the packages gem
|
32
|
+
gem.files -= glob[gemspec['test_files'] || 'spec/{**/}*']
|
29
33
|
|
30
34
|
gem.executables = gemspec.fetch('executables') do
|
31
35
|
glob['bin/*'].map { |path| File.basename(path) }
|
@@ -45,7 +49,7 @@ Gem::Specification.new do |gem|
|
|
45
49
|
gem.required_rubygems_version = gemspec['required_rubygems_version']
|
46
50
|
gem.post_install_message = gemspec['post_install_message']
|
47
51
|
|
48
|
-
split =
|
52
|
+
split = ->(string) { string.split(/,\s*/) }
|
49
53
|
|
50
54
|
if gemspec['dependencies']
|
51
55
|
gemspec['dependencies'].each do |name,versions|
|
@@ -23,6 +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
|
+
|
26
30
|
rb_undef_method(cCRC12_3GPP, "update");
|
27
31
|
rb_define_method(cCRC12_3GPP, "update", Digest_CRC12_3GPP_update, 1);
|
28
32
|
}
|
@@ -24,6 +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
|
+
|
27
31
|
rb_undef_method(cCRC15, "update");
|
28
32
|
rb_define_method(cCRC15, "update", Digest_CRC15_update, 1);
|
29
33
|
}
|
@@ -24,6 +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
|
+
|
27
31
|
rb_undef_method(cCRC16, "update");
|
28
32
|
rb_define_method(cCRC16, "update", Digest_CRC16_update, 1);
|
29
33
|
}
|
@@ -24,6 +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
|
+
|
27
31
|
rb_undef_method(cCRC16CCITT, "update");
|
28
32
|
rb_define_method(cCRC16CCITT, "update", Digest_CRC16CCITT_update, 1);
|
29
33
|
}
|
@@ -24,6 +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
|
+
|
27
31
|
rb_undef_method(cCRC16DNP, "update");
|
28
32
|
rb_define_method(cCRC16DNP, "update", Digest_CRC16DNP_update, 1);
|
29
33
|
}
|
@@ -24,6 +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
|
+
|
27
31
|
rb_undef_method(cCRC16Genibus, "update");
|
28
32
|
rb_define_method(cCRC16Genibus, "update", Digest_CRC16Genibus_update, 1);
|
29
33
|
}
|
@@ -24,6 +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
|
+
|
27
31
|
rb_undef_method(cCRC16Kermit, "update");
|
28
32
|
rb_define_method(cCRC16Kermit, "update", Digest_CRC16Kermit_update, 1);
|
29
33
|
}
|
@@ -24,6 +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
|
-
|
27
|
+
#ifdef HAVE_RB_EXT_RACTOR_SAFE
|
28
|
+
rb_ext_ractor_safe(true);
|
29
|
+
#endif
|
30
|
+
|
28
31
|
rb_define_method(cCRC16Modbus, "update", Digest_CRC16Modbus_update, 1);
|
29
32
|
}
|
@@ -24,6 +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
|
-
|
27
|
+
#ifdef HAVE_RB_EXT_RACTOR_SAFE
|
28
|
+
rb_ext_ractor_safe(true);
|
29
|
+
#endif
|
30
|
+
|
28
31
|
rb_define_method(cCRC16USB, "update", Digest_CRC16USB_update, 1);
|
29
32
|
}
|
@@ -24,6 +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
|
-
|
27
|
+
#ifdef HAVE_RB_EXT_RACTOR_SAFE
|
28
|
+
rb_ext_ractor_safe(true);
|
29
|
+
#endif
|
30
|
+
|
28
31
|
rb_define_method(cCRC16X25, "update", Digest_CRC16X25_update, 1);
|
29
32
|
}
|
@@ -24,6 +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
|
+
|
27
31
|
rb_undef_method(cCRC16XModem, "update");
|
28
32
|
rb_define_method(cCRC16XModem, "update", Digest_CRC16XModem_update, 1);
|
29
33
|
}
|
@@ -24,6 +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
|
+
|
27
31
|
rb_undef_method(cCRC16ZModem, "update");
|
28
32
|
rb_define_method(cCRC16ZModem, "update", Digest_CRC16ZModem_update, 1);
|
29
33
|
}
|
@@ -23,6 +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
|
+
|
26
30
|
rb_undef_method(cCRC24, "update");
|
27
31
|
rb_define_method(cCRC24, "update", Digest_CRC24_update, 1);
|
28
32
|
}
|
@@ -23,6 +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
|
+
|
26
30
|
rb_undef_method(cCRC32, "update");
|
27
31
|
rb_define_method(cCRC32, "update", Digest_CRC32_update, 1);
|
28
32
|
}
|
@@ -23,6 +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
|
+
|
26
30
|
rb_undef_method(cCRC32Bzip2, "update");
|
27
31
|
rb_define_method(cCRC32Bzip2, "update", Digest_CRC32Bzip2_update, 1);
|
28
32
|
}
|
@@ -23,6 +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
|
-
|
26
|
+
#ifdef HAVE_RB_EXT_RACTOR_SAFE
|
27
|
+
rb_ext_ractor_safe(true);
|
28
|
+
#endif
|
29
|
+
|
27
30
|
rb_define_method(cCRC32Jam, "update", Digest_CRC32Jam_update, 1);
|
28
31
|
}
|
@@ -23,6 +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
|
+
|
26
30
|
rb_undef_method(cCRC32MPEG, "update");
|
27
31
|
rb_define_method(cCRC32MPEG, "update", Digest_CRC32MPEG_update, 1);
|
28
32
|
}
|
@@ -23,6 +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
|
+
|
26
30
|
rb_undef_method(cCRC32POSIX, "update");
|
27
31
|
rb_define_method(cCRC32POSIX, "update", Digest_CRC32POSIX_update, 1);
|
28
32
|
}
|
@@ -23,6 +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
|
+
|
26
30
|
rb_undef_method(cCRC32XFER, "update");
|
27
31
|
rb_define_method(cCRC32XFER, "update", Digest_CRC32XFER_update, 1);
|
28
32
|
}
|
@@ -23,6 +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
|
-
|
26
|
+
#ifdef HAVE_RB_EXT_RACTOR_SAFE
|
27
|
+
rb_ext_ractor_safe(true);
|
28
|
+
#endif
|
29
|
+
|
27
30
|
rb_define_method(cCRC32c, "update", Digest_CRC32c_update, 1);
|
28
31
|
}
|
data/ext/digest/crc5/crc5_ext.c
CHANGED
@@ -23,6 +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
|
+
|
26
30
|
rb_undef_method(cCRC5, "update");
|
27
31
|
rb_define_method(cCRC5, "update", Digest_CRC5_update, 1);
|
28
32
|
}
|
@@ -23,6 +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
|
+
|
26
30
|
rb_undef_method(cCRC64, "update");
|
27
31
|
rb_define_method(cCRC64, "update", Digest_CRC64_update, 1);
|
28
32
|
}
|
@@ -23,6 +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
|
-
|
26
|
+
#ifdef HAVE_RB_EXT_RACTOR_SAFE
|
27
|
+
rb_ext_ractor_safe(true);
|
28
|
+
#endif
|
29
|
+
|
27
30
|
rb_define_method(cCRC64Jones, "update", Digest_CRC64Jones_update, 1);
|
28
31
|
}
|
@@ -0,0 +1,102 @@
|
|
1
|
+
/**
|
2
|
+
* \file
|
3
|
+
* Functions and types for CRC checks.
|
4
|
+
*
|
5
|
+
* Generated on Mon Jan 6 09:50:24 2025
|
6
|
+
* by pycrc v0.10.0, https://pycrc.org
|
7
|
+
* using the configuration:
|
8
|
+
* - Width. = 64
|
9
|
+
* - Poly. = 0xad93d23594c93659
|
10
|
+
* - XorIn. = 0xffffffffffffffff
|
11
|
+
* - ReflectIn = True
|
12
|
+
* - XorOut. = 0xffffffffffffffff
|
13
|
+
* - ReflectOut = True
|
14
|
+
* - Algorithm = table-driven
|
15
|
+
*/
|
16
|
+
|
17
|
+
#include "crc64_nvme.h"
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Static table used for the table_driven implementation.
|
21
|
+
*/
|
22
|
+
static const crc64_t crc64_table[256] = {
|
23
|
+
0x0000000000000000, 0x7f6ef0c830358979, 0xfedde190606b12f2, 0x81b31158505e9b8b,
|
24
|
+
0xc962e5739841b68f, 0xb60c15bba8743ff6, 0x37bf04e3f82aa47d, 0x48d1f42bc81f2d04,
|
25
|
+
0xa61cecb46814fe75, 0xd9721c7c5821770c, 0x58c10d24087fec87, 0x27affdec384a65fe,
|
26
|
+
0x6f7e09c7f05548fa, 0x1010f90fc060c183, 0x91a3e857903e5a08, 0xeecd189fa00bd371,
|
27
|
+
0x78e0ff3b88be6f81, 0x078e0ff3b88be6f8, 0x863d1eabe8d57d73, 0xf953ee63d8e0f40a,
|
28
|
+
0xb1821a4810ffd90e, 0xceecea8020ca5077, 0x4f5ffbd87094cbfc, 0x30310b1040a14285,
|
29
|
+
0xdefc138fe0aa91f4, 0xa192e347d09f188d, 0x2021f21f80c18306, 0x5f4f02d7b0f40a7f,
|
30
|
+
0x179ef6fc78eb277b, 0x68f0063448deae02, 0xe943176c18803589, 0x962de7a428b5bcf0,
|
31
|
+
0xf1c1fe77117cdf02, 0x8eaf0ebf2149567b, 0x0f1c1fe77117cdf0, 0x7072ef2f41224489,
|
32
|
+
0x38a31b04893d698d, 0x47cdebccb908e0f4, 0xc67efa94e9567b7f, 0xb9100a5cd963f206,
|
33
|
+
0x57dd12c379682177, 0x28b3e20b495da80e, 0xa900f35319033385, 0xd66e039b2936bafc,
|
34
|
+
0x9ebff7b0e12997f8, 0xe1d10778d11c1e81, 0x606216208142850a, 0x1f0ce6e8b1770c73,
|
35
|
+
0x8921014c99c2b083, 0xf64ff184a9f739fa, 0x77fce0dcf9a9a271, 0x08921014c99c2b08,
|
36
|
+
0x4043e43f0183060c, 0x3f2d14f731b68f75, 0xbe9e05af61e814fe, 0xc1f0f56751dd9d87,
|
37
|
+
0x2f3dedf8f1d64ef6, 0x50531d30c1e3c78f, 0xd1e00c6891bd5c04, 0xae8efca0a188d57d,
|
38
|
+
0xe65f088b6997f879, 0x9931f84359a27100, 0x1882e91b09fcea8b, 0x67ec19d339c963f2,
|
39
|
+
0xd75adabd7a6e2d6f, 0xa8342a754a5ba416, 0x29873b2d1a053f9d, 0x56e9cbe52a30b6e4,
|
40
|
+
0x1e383fcee22f9be0, 0x6156cf06d21a1299, 0xe0e5de5e82448912, 0x9f8b2e96b271006b,
|
41
|
+
0x71463609127ad31a, 0x0e28c6c1224f5a63, 0x8f9bd7997211c1e8, 0xf0f5275142244891,
|
42
|
+
0xb824d37a8a3b6595, 0xc74a23b2ba0eecec, 0x46f932eaea507767, 0x3997c222da65fe1e,
|
43
|
+
0xafba2586f2d042ee, 0xd0d4d54ec2e5cb97, 0x5167c41692bb501c, 0x2e0934dea28ed965,
|
44
|
+
0x66d8c0f56a91f461, 0x19b6303d5aa47d18, 0x980521650afae693, 0xe76bd1ad3acf6fea,
|
45
|
+
0x09a6c9329ac4bc9b, 0x76c839faaaf135e2, 0xf77b28a2faafae69, 0x8815d86aca9a2710,
|
46
|
+
0xc0c42c4102850a14, 0xbfaadc8932b0836d, 0x3e19cdd162ee18e6, 0x41773d1952db919f,
|
47
|
+
0x269b24ca6b12f26d, 0x59f5d4025b277b14, 0xd846c55a0b79e09f, 0xa72835923b4c69e6,
|
48
|
+
0xeff9c1b9f35344e2, 0x90973171c366cd9b, 0x1124202993385610, 0x6e4ad0e1a30ddf69,
|
49
|
+
0x8087c87e03060c18, 0xffe938b633338561, 0x7e5a29ee636d1eea, 0x0134d92653589793,
|
50
|
+
0x49e52d0d9b47ba97, 0x368bddc5ab7233ee, 0xb738cc9dfb2ca865, 0xc8563c55cb19211c,
|
51
|
+
0x5e7bdbf1e3ac9dec, 0x21152b39d3991495, 0xa0a63a6183c78f1e, 0xdfc8caa9b3f20667,
|
52
|
+
0x97193e827bed2b63, 0xe877ce4a4bd8a21a, 0x69c4df121b863991, 0x16aa2fda2bb3b0e8,
|
53
|
+
0xf86737458bb86399, 0x8709c78dbb8deae0, 0x06bad6d5ebd3716b, 0x79d4261ddbe6f812,
|
54
|
+
0x3105d23613f9d516, 0x4e6b22fe23cc5c6f, 0xcfd833a67392c7e4, 0xb0b6c36e43a74e9d,
|
55
|
+
0x9a6c9329ac4bc9b5, 0xe50263e19c7e40cc, 0x64b172b9cc20db47, 0x1bdf8271fc15523e,
|
56
|
+
0x530e765a340a7f3a, 0x2c608692043ff643, 0xadd397ca54616dc8, 0xd2bd67026454e4b1,
|
57
|
+
0x3c707f9dc45f37c0, 0x431e8f55f46abeb9, 0xc2ad9e0da4342532, 0xbdc36ec59401ac4b,
|
58
|
+
0xf5129aee5c1e814f, 0x8a7c6a266c2b0836, 0x0bcf7b7e3c7593bd, 0x74a18bb60c401ac4,
|
59
|
+
0xe28c6c1224f5a634, 0x9de29cda14c02f4d, 0x1c518d82449eb4c6, 0x633f7d4a74ab3dbf,
|
60
|
+
0x2bee8961bcb410bb, 0x548079a98c8199c2, 0xd53368f1dcdf0249, 0xaa5d9839ecea8b30,
|
61
|
+
0x449080a64ce15841, 0x3bfe706e7cd4d138, 0xba4d61362c8a4ab3, 0xc52391fe1cbfc3ca,
|
62
|
+
0x8df265d5d4a0eece, 0xf29c951de49567b7, 0x732f8445b4cbfc3c, 0x0c41748d84fe7545,
|
63
|
+
0x6bad6d5ebd3716b7, 0x14c39d968d029fce, 0x95708ccedd5c0445, 0xea1e7c06ed698d3c,
|
64
|
+
0xa2cf882d2576a038, 0xdda178e515432941, 0x5c1269bd451db2ca, 0x237c997575283bb3,
|
65
|
+
0xcdb181ead523e8c2, 0xb2df7122e51661bb, 0x336c607ab548fa30, 0x4c0290b2857d7349,
|
66
|
+
0x04d364994d625e4d, 0x7bbd94517d57d734, 0xfa0e85092d094cbf, 0x856075c11d3cc5c6,
|
67
|
+
0x134d926535897936, 0x6c2362ad05bcf04f, 0xed9073f555e26bc4, 0x92fe833d65d7e2bd,
|
68
|
+
0xda2f7716adc8cfb9, 0xa54187de9dfd46c0, 0x24f29686cda3dd4b, 0x5b9c664efd965432,
|
69
|
+
0xb5517ed15d9d8743, 0xca3f8e196da80e3a, 0x4b8c9f413df695b1, 0x34e26f890dc31cc8,
|
70
|
+
0x7c339ba2c5dc31cc, 0x035d6b6af5e9b8b5, 0x82ee7a32a5b7233e, 0xfd808afa9582aa47,
|
71
|
+
0x4d364994d625e4da, 0x3258b95ce6106da3, 0xb3eba804b64ef628, 0xcc8558cc867b7f51,
|
72
|
+
0x8454ace74e645255, 0xfb3a5c2f7e51db2c, 0x7a894d772e0f40a7, 0x05e7bdbf1e3ac9de,
|
73
|
+
0xeb2aa520be311aaf, 0x944455e88e0493d6, 0x15f744b0de5a085d, 0x6a99b478ee6f8124,
|
74
|
+
0x224840532670ac20, 0x5d26b09b16452559, 0xdc95a1c3461bbed2, 0xa3fb510b762e37ab,
|
75
|
+
0x35d6b6af5e9b8b5b, 0x4ab846676eae0222, 0xcb0b573f3ef099a9, 0xb465a7f70ec510d0,
|
76
|
+
0xfcb453dcc6da3dd4, 0x83daa314f6efb4ad, 0x0269b24ca6b12f26, 0x7d0742849684a65f,
|
77
|
+
0x93ca5a1b368f752e, 0xeca4aad306bafc57, 0x6d17bb8b56e467dc, 0x12794b4366d1eea5,
|
78
|
+
0x5aa8bf68aecec3a1, 0x25c64fa09efb4ad8, 0xa4755ef8cea5d153, 0xdb1bae30fe90582a,
|
79
|
+
0xbcf7b7e3c7593bd8, 0xc399472bf76cb2a1, 0x422a5673a732292a, 0x3d44a6bb9707a053,
|
80
|
+
0x759552905f188d57, 0x0afba2586f2d042e, 0x8b48b3003f739fa5, 0xf42643c80f4616dc,
|
81
|
+
0x1aeb5b57af4dc5ad, 0x6585ab9f9f784cd4, 0xe436bac7cf26d75f, 0x9b584a0fff135e26,
|
82
|
+
0xd389be24370c7322, 0xace74eec0739fa5b, 0x2d545fb4576761d0, 0x523aaf7c6752e8a9,
|
83
|
+
0xc41748d84fe75459, 0xbb79b8107fd2dd20, 0x3acaa9482f8c46ab, 0x45a459801fb9cfd2,
|
84
|
+
0x0d75adabd7a6e2d6, 0x721b5d63e7936baf, 0xf3a84c3bb7cdf024, 0x8cc6bcf387f8795d,
|
85
|
+
0x620ba46c27f3aa2c, 0x1d6554a417c62355, 0x9cd645fc4798b8de, 0xe3b8b53477ad31a7,
|
86
|
+
0xab69411fbfb21ca3, 0xd407b1d78f8795da, 0x55b4a08fdfd90e51, 0x2ada5047efec8728
|
87
|
+
};
|
88
|
+
|
89
|
+
crc64_t crc64_nvme_update(crc64_t crc, const void *data, size_t data_len)
|
90
|
+
{
|
91
|
+
const unsigned char *d = (const unsigned char *)data;
|
92
|
+
unsigned int tbl_idx;
|
93
|
+
|
94
|
+
while (data_len--)
|
95
|
+
{
|
96
|
+
tbl_idx = (crc ^ *d) & 0xff;
|
97
|
+
crc = (crc64_table[tbl_idx] ^ (crc >> 8)) & 0xffffffffffffffff;
|
98
|
+
d++;
|
99
|
+
}
|
100
|
+
|
101
|
+
return crc & 0xffffffffffffffff;
|
102
|
+
}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#include "ruby.h"
|
2
|
+
#include "extconf.h"
|
3
|
+
|
4
|
+
#include "crc64_nvme.h"
|
5
|
+
|
6
|
+
VALUE Digest_CRC64NVMe_update(VALUE self, VALUE data)
|
7
|
+
{
|
8
|
+
VALUE crc_ivar_name = rb_intern("@crc");
|
9
|
+
VALUE crc_ivar = rb_ivar_get(self, crc_ivar_name);
|
10
|
+
crc64_t crc = NUM2ULONG(crc_ivar);
|
11
|
+
|
12
|
+
const char *data_ptr = StringValuePtr(data);
|
13
|
+
size_t length = RSTRING_LEN(data);
|
14
|
+
|
15
|
+
crc = crc64_nvme_update(crc,data_ptr,length);
|
16
|
+
|
17
|
+
rb_ivar_set(self, crc_ivar_name, ULONG2NUM(crc));
|
18
|
+
return self;
|
19
|
+
}
|
20
|
+
|
21
|
+
void Init_crc64_nvme_ext()
|
22
|
+
{
|
23
|
+
VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
|
24
|
+
VALUE cCRC64NVMe = rb_const_get(mDigest, rb_intern("CRC64NVMe"));
|
25
|
+
|
26
|
+
#ifdef HAVE_RB_EXT_RACTOR_SAFE
|
27
|
+
rb_ext_ractor_safe(true);
|
28
|
+
#endif
|
29
|
+
|
30
|
+
rb_define_method(cCRC64NVMe, "update", Digest_CRC64NVMe_update, 1);
|
31
|
+
}
|
@@ -23,6 +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
|
-
|
26
|
+
#ifdef HAVE_RB_EXT_RACTOR_SAFE
|
27
|
+
rb_ext_ractor_safe(true);
|
28
|
+
#endif
|
29
|
+
|
27
30
|
rb_define_method(cCRC64XZ, "update", Digest_CRC64XZ_update, 1);
|
28
31
|
}
|
data/ext/digest/crc8/crc8_ext.c
CHANGED
@@ -23,6 +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
|
+
|
26
30
|
rb_undef_method(cCRC8, "update");
|
27
31
|
rb_define_method(cCRC8, "update", Digest_CRC8_update, 1);
|
28
32
|
}
|
@@ -23,6 +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
|
-
|
26
|
+
#ifdef HAVE_RB_EXT_RACTOR_SAFE
|
27
|
+
rb_ext_ractor_safe(true);
|
28
|
+
#endif
|
29
|
+
|
27
30
|
rb_define_method(cCRC81Wire, "update", Digest_CRC81Wire_update, 1);
|
28
31
|
}
|
data/gemspec.yml
CHANGED