precompiled-digest-crc 0.7.0

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 (155) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/cibuildgem.yaml +89 -0
  3. data/.github/workflows/integration.yml +26 -0
  4. data/.github/workflows/ruby.yml +33 -0
  5. data/.gitignore +11 -0
  6. data/.rspec +1 -0
  7. data/.yardopts +1 -0
  8. data/ChangeLog.md +212 -0
  9. data/Gemfile +16 -0
  10. data/LICENSE.txt +20 -0
  11. data/README.md +401 -0
  12. data/Rakefile +57 -0
  13. data/benchmarks.rb +59 -0
  14. data/digest-crc.gemspec +65 -0
  15. data/ext/digest/Rakefile +46 -0
  16. data/ext/digest/compat/ruby.h +11 -0
  17. data/ext/digest/crc12_3gpp/crc12_3gpp.c +68 -0
  18. data/ext/digest/crc12_3gpp/crc12_3gpp.h +11 -0
  19. data/ext/digest/crc12_3gpp/crc12_3gpp_ext.c +32 -0
  20. data/ext/digest/crc12_3gpp/extconf.rb +7 -0
  21. data/ext/digest/crc15/crc15.c +54 -0
  22. data/ext/digest/crc15/crc15.h +11 -0
  23. data/ext/digest/crc15/crc15_ext.c +33 -0
  24. data/ext/digest/crc15/extconf.rb +7 -0
  25. data/ext/digest/crc16/crc16.c +70 -0
  26. data/ext/digest/crc16/crc16.h +11 -0
  27. data/ext/digest/crc16/crc16_ext.c +33 -0
  28. data/ext/digest/crc16/extconf.rb +7 -0
  29. data/ext/digest/crc16_ccitt/crc16_ccitt.c +70 -0
  30. data/ext/digest/crc16_ccitt/crc16_ccitt.h +8 -0
  31. data/ext/digest/crc16_ccitt/crc16_ccitt_ext.c +33 -0
  32. data/ext/digest/crc16_ccitt/extconf.rb +7 -0
  33. data/ext/digest/crc16_dnp/crc16_dnp.c +54 -0
  34. data/ext/digest/crc16_dnp/crc16_dnp.h +8 -0
  35. data/ext/digest/crc16_dnp/crc16_dnp_ext.c +33 -0
  36. data/ext/digest/crc16_dnp/extconf.rb +7 -0
  37. data/ext/digest/crc16_genibus/crc16_genibus.c +70 -0
  38. data/ext/digest/crc16_genibus/crc16_genibus.h +8 -0
  39. data/ext/digest/crc16_genibus/crc16_genibus_ext.c +33 -0
  40. data/ext/digest/crc16_genibus/extconf.rb +7 -0
  41. data/ext/digest/crc16_kermit/crc16_kermit.c +70 -0
  42. data/ext/digest/crc16_kermit/crc16_kermit.h +8 -0
  43. data/ext/digest/crc16_kermit/crc16_kermit_ext.c +33 -0
  44. data/ext/digest/crc16_kermit/extconf.rb +7 -0
  45. data/ext/digest/crc16_modbus/crc16_modbus.c +70 -0
  46. data/ext/digest/crc16_modbus/crc16_modbus.h +8 -0
  47. data/ext/digest/crc16_modbus/crc16_modbus_ext.c +32 -0
  48. data/ext/digest/crc16_modbus/extconf.rb +7 -0
  49. data/ext/digest/crc16_usb/crc16_usb.c +70 -0
  50. data/ext/digest/crc16_usb/crc16_usb.h +8 -0
  51. data/ext/digest/crc16_usb/crc16_usb_ext.c +32 -0
  52. data/ext/digest/crc16_usb/extconf.rb +7 -0
  53. data/ext/digest/crc16_x_25/crc16_x_25.c +70 -0
  54. data/ext/digest/crc16_x_25/crc16_x_25.h +8 -0
  55. data/ext/digest/crc16_x_25/crc16_x_25_ext.c +32 -0
  56. data/ext/digest/crc16_x_25/extconf.rb +7 -0
  57. data/ext/digest/crc16_xmodem/crc16_xmodem.c +70 -0
  58. data/ext/digest/crc16_xmodem/crc16_xmodem.h +8 -0
  59. data/ext/digest/crc16_xmodem/crc16_xmodem_ext.c +33 -0
  60. data/ext/digest/crc16_xmodem/extconf.rb +7 -0
  61. data/ext/digest/crc16_zmodem/crc16_zmodem.c +70 -0
  62. data/ext/digest/crc16_zmodem/crc16_zmodem.h +8 -0
  63. data/ext/digest/crc16_zmodem/crc16_zmodem_ext.c +33 -0
  64. data/ext/digest/crc16_zmodem/extconf.rb +7 -0
  65. data/ext/digest/crc24/crc24.c +70 -0
  66. data/ext/digest/crc24/crc24.h +11 -0
  67. data/ext/digest/crc24/crc24_ext.c +32 -0
  68. data/ext/digest/crc24/extconf.rb +7 -0
  69. data/ext/digest/crc32/crc32.c +69 -0
  70. data/ext/digest/crc32/crc32.h +11 -0
  71. data/ext/digest/crc32/crc32_ext.c +32 -0
  72. data/ext/digest/crc32/extconf.rb +7 -0
  73. data/ext/digest/crc32_bzip2/crc32_bzip2.c +70 -0
  74. data/ext/digest/crc32_bzip2/crc32_bzip2.h +8 -0
  75. data/ext/digest/crc32_bzip2/crc32_bzip2_ext.c +32 -0
  76. data/ext/digest/crc32_bzip2/extconf.rb +7 -0
  77. data/ext/digest/crc32_jam/crc32_jam.c +70 -0
  78. data/ext/digest/crc32_jam/crc32_jam.h +8 -0
  79. data/ext/digest/crc32_jam/crc32_jam_ext.c +31 -0
  80. data/ext/digest/crc32_jam/extconf.rb +7 -0
  81. data/ext/digest/crc32_mpeg/crc32_mpeg.c +70 -0
  82. data/ext/digest/crc32_mpeg/crc32_mpeg.h +8 -0
  83. data/ext/digest/crc32_mpeg/crc32_mpeg_ext.c +32 -0
  84. data/ext/digest/crc32_mpeg/extconf.rb +7 -0
  85. data/ext/digest/crc32_posix/crc32_posix.c +70 -0
  86. data/ext/digest/crc32_posix/crc32_posix.h +8 -0
  87. data/ext/digest/crc32_posix/crc32_posix_ext.c +32 -0
  88. data/ext/digest/crc32_posix/extconf.rb +7 -0
  89. data/ext/digest/crc32_xfer/crc32_xfer.c +70 -0
  90. data/ext/digest/crc32_xfer/crc32_xfer.h +8 -0
  91. data/ext/digest/crc32_xfer/crc32_xfer_ext.c +32 -0
  92. data/ext/digest/crc32_xfer/extconf.rb +7 -0
  93. data/ext/digest/crc32c/crc32c.c +70 -0
  94. data/ext/digest/crc32c/crc32c.h +8 -0
  95. data/ext/digest/crc32c/crc32c_ext.c +31 -0
  96. data/ext/digest/crc32c/extconf.rb +7 -0
  97. data/ext/digest/crc5/crc5.c +54 -0
  98. data/ext/digest/crc5/crc5.h +11 -0
  99. data/ext/digest/crc5/crc5_ext.c +32 -0
  100. data/ext/digest/crc5/extconf.rb +7 -0
  101. data/ext/digest/crc64/crc64.c +102 -0
  102. data/ext/digest/crc64/crc64.h +11 -0
  103. data/ext/digest/crc64/crc64_ext.c +32 -0
  104. data/ext/digest/crc64/extconf.rb +7 -0
  105. data/ext/digest/crc64_jones/crc64_jones.c +102 -0
  106. data/ext/digest/crc64_jones/crc64_jones.h +8 -0
  107. data/ext/digest/crc64_jones/crc64_jones_ext.c +31 -0
  108. data/ext/digest/crc64_jones/extconf.rb +7 -0
  109. data/ext/digest/crc64_nvme/crc64_nvme.c +102 -0
  110. data/ext/digest/crc64_nvme/crc64_nvme.h +8 -0
  111. data/ext/digest/crc64_nvme/crc64_nvme_ext.c +31 -0
  112. data/ext/digest/crc64_nvme/extconf.rb +7 -0
  113. data/ext/digest/crc64_xz/crc64_xz.c +102 -0
  114. data/ext/digest/crc64_xz/crc64_xz.h +8 -0
  115. data/ext/digest/crc64_xz/crc64_xz_ext.c +31 -0
  116. data/ext/digest/crc64_xz/extconf.rb +7 -0
  117. data/ext/digest/crc8/crc8.c +54 -0
  118. data/ext/digest/crc8/crc8.h +11 -0
  119. data/ext/digest/crc8/crc8_ext.c +32 -0
  120. data/ext/digest/crc8/extconf.rb +7 -0
  121. data/ext/digest/crc8_1wire/crc8_1wire.c +54 -0
  122. data/ext/digest/crc8_1wire/crc8_1wire.h +8 -0
  123. data/ext/digest/crc8_1wire/crc8_1wire_ext.c +31 -0
  124. data/ext/digest/crc8_1wire/extconf.rb +7 -0
  125. data/gemspec.yml +25 -0
  126. data/lib/digest/crc.rb +211 -0
  127. data/lib/digest/crc1.rb +37 -0
  128. data/lib/digest/crc15.rb +45 -0
  129. data/lib/digest/crc16.rb +61 -0
  130. data/lib/digest/crc16_ccitt.rb +59 -0
  131. data/lib/digest/crc16_dnp.rb +62 -0
  132. data/lib/digest/crc16_genibus.rb +65 -0
  133. data/lib/digest/crc16_kermit.rb +59 -0
  134. data/lib/digest/crc16_modbus.rb +57 -0
  135. data/lib/digest/crc16_qt.rb +11 -0
  136. data/lib/digest/crc16_usb.rb +23 -0
  137. data/lib/digest/crc16_x_25.rb +63 -0
  138. data/lib/digest/crc16_xmodem.rb +57 -0
  139. data/lib/digest/crc16_zmodem.rb +57 -0
  140. data/lib/digest/crc24.rb +61 -0
  141. data/lib/digest/crc32.rb +95 -0
  142. data/lib/digest/crc32_bzip2.rb +57 -0
  143. data/lib/digest/crc32_jam.rb +16 -0
  144. data/lib/digest/crc32_mpeg.rb +94 -0
  145. data/lib/digest/crc32_posix.rb +58 -0
  146. data/lib/digest/crc32_xfer.rb +61 -0
  147. data/lib/digest/crc32c.rb +87 -0
  148. data/lib/digest/crc5.rb +58 -0
  149. data/lib/digest/crc64.rb +95 -0
  150. data/lib/digest/crc64_jones.rb +93 -0
  151. data/lib/digest/crc64_nvme.rb +95 -0
  152. data/lib/digest/crc64_xz.rb +95 -0
  153. data/lib/digest/crc8.rb +45 -0
  154. data/lib/digest/crc8_1wire.rb +42 -0
  155. metadata +265 -0
@@ -0,0 +1,70 @@
1
+ /**
2
+ * \file
3
+ * Functions and types for CRC checks.
4
+ *
5
+ * Generated on Sat Feb 29 02:06:11 2020
6
+ * by pycrc v0.9.2, https://pycrc.org
7
+ * using the configuration:
8
+ * - Width = 16
9
+ * - Poly = 0x1021
10
+ * - XorIn = 0x0000
11
+ * - ReflectIn = False
12
+ * - XorOut = 0x0000
13
+ * - ReflectOut = False
14
+ * - Algorithm = table-driven
15
+ */
16
+
17
+ #include "crc16_zmodem.h"
18
+
19
+ /**
20
+ * Static table used for the table_driven implementation.
21
+ */
22
+ static const crc16_t crc16_zmodem_table[256] = {
23
+ 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
24
+ 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
25
+ 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
26
+ 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
27
+ 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
28
+ 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
29
+ 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
30
+ 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
31
+ 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
32
+ 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
33
+ 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
34
+ 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
35
+ 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
36
+ 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
37
+ 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
38
+ 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
39
+ 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
40
+ 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
41
+ 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
42
+ 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
43
+ 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
44
+ 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
45
+ 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
46
+ 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
47
+ 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
48
+ 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
49
+ 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
50
+ 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
51
+ 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
52
+ 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
53
+ 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
54
+ 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
55
+ };
56
+
57
+ crc16_t crc16_zmodem_update(crc16_t crc, const void *data, size_t data_len)
58
+ {
59
+ const unsigned char *d = (const unsigned char *)data;
60
+ unsigned int tbl_idx;
61
+
62
+ while (data_len--)
63
+ {
64
+ tbl_idx = ((crc >> 8) ^ *d) & 0xff;
65
+ crc = (crc16_zmodem_table[tbl_idx] ^ (crc << 8)) & 0xffff;
66
+ d++;
67
+ }
68
+
69
+ return crc & 0xffff;
70
+ }
@@ -0,0 +1,8 @@
1
+ #ifndef _CRC16_ZMODEM_H_
2
+ #define _CRC16_ZMODEM_H_
3
+
4
+ #include "../crc16/crc16.h"
5
+
6
+ crc16_t crc16_zmodem_update(crc16_t crc, const void *data, size_t data_len);
7
+
8
+ #endif
@@ -0,0 +1,33 @@
1
+ #include <ruby.h>
2
+ #include "../compat/ruby.h"
3
+
4
+ #include "extconf.h"
5
+ #include "crc16_zmodem.h"
6
+
7
+ VALUE Digest_CRC16ZModem_update(VALUE self, VALUE data)
8
+ {
9
+ VALUE crc_ivar_name = rb_intern("@crc");
10
+ VALUE crc_ivar = rb_ivar_get(self, crc_ivar_name);
11
+ crc16_t crc = NUM2USHORT(crc_ivar);
12
+
13
+ const char *data_ptr = StringValuePtr(data);
14
+ size_t length = RSTRING_LEN(data);
15
+
16
+ crc = crc16_zmodem_update(crc,data_ptr,length);
17
+
18
+ rb_ivar_set(self, crc_ivar_name, USHORT2NUM(crc));
19
+ return self;
20
+ }
21
+
22
+ void Init_crc16_zmodem_ext()
23
+ {
24
+ VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
25
+ VALUE cCRC16ZModem = rb_const_get(mDigest, rb_intern("CRC16ZModem"));
26
+
27
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
28
+ rb_ext_ractor_safe(true);
29
+ #endif
30
+
31
+ rb_undef_method(cCRC16ZModem, "update");
32
+ rb_define_method(cCRC16ZModem, "update", Digest_CRC16ZModem_update, 1);
33
+ }
@@ -0,0 +1,7 @@
1
+ require 'mkmf'
2
+
3
+ have_header("stdint.h")
4
+ have_header('stddef.h')
5
+
6
+ create_header
7
+ create_makefile "digest/crc16_zmodem/crc16_zmodem_ext"
@@ -0,0 +1,70 @@
1
+ /**
2
+ * \file
3
+ * Functions and types for CRC checks.
4
+ *
5
+ * Generated on Sat Feb 29 02:02:04 2020
6
+ * by pycrc v0.9.2, https://pycrc.org
7
+ * using the configuration:
8
+ * - Width = 24
9
+ * - Poly = 0x864cfb
10
+ * - XorIn = 0xb704ce
11
+ * - ReflectIn = False
12
+ * - XorOut = 0x000000
13
+ * - ReflectOut = False
14
+ * - Algorithm = table-driven
15
+ */
16
+
17
+ #include "crc24.h"
18
+
19
+ /**
20
+ * Static table used for the table_driven implementation.
21
+ */
22
+ static const crc24_t crc24_table[256] = {
23
+ 0x000000, 0x864cfb, 0x8ad50d, 0x0c99f6, 0x93e6e1, 0x15aa1a, 0x1933ec, 0x9f7f17,
24
+ 0xa18139, 0x27cdc2, 0x2b5434, 0xad18cf, 0x3267d8, 0xb42b23, 0xb8b2d5, 0x3efe2e,
25
+ 0xc54e89, 0x430272, 0x4f9b84, 0xc9d77f, 0x56a868, 0xd0e493, 0xdc7d65, 0x5a319e,
26
+ 0x64cfb0, 0xe2834b, 0xee1abd, 0x685646, 0xf72951, 0x7165aa, 0x7dfc5c, 0xfbb0a7,
27
+ 0x0cd1e9, 0x8a9d12, 0x8604e4, 0x00481f, 0x9f3708, 0x197bf3, 0x15e205, 0x93aefe,
28
+ 0xad50d0, 0x2b1c2b, 0x2785dd, 0xa1c926, 0x3eb631, 0xb8faca, 0xb4633c, 0x322fc7,
29
+ 0xc99f60, 0x4fd39b, 0x434a6d, 0xc50696, 0x5a7981, 0xdc357a, 0xd0ac8c, 0x56e077,
30
+ 0x681e59, 0xee52a2, 0xe2cb54, 0x6487af, 0xfbf8b8, 0x7db443, 0x712db5, 0xf7614e,
31
+ 0x19a3d2, 0x9fef29, 0x9376df, 0x153a24, 0x8a4533, 0x0c09c8, 0x00903e, 0x86dcc5,
32
+ 0xb822eb, 0x3e6e10, 0x32f7e6, 0xb4bb1d, 0x2bc40a, 0xad88f1, 0xa11107, 0x275dfc,
33
+ 0xdced5b, 0x5aa1a0, 0x563856, 0xd074ad, 0x4f0bba, 0xc94741, 0xc5deb7, 0x43924c,
34
+ 0x7d6c62, 0xfb2099, 0xf7b96f, 0x71f594, 0xee8a83, 0x68c678, 0x645f8e, 0xe21375,
35
+ 0x15723b, 0x933ec0, 0x9fa736, 0x19ebcd, 0x8694da, 0x00d821, 0x0c41d7, 0x8a0d2c,
36
+ 0xb4f302, 0x32bff9, 0x3e260f, 0xb86af4, 0x2715e3, 0xa15918, 0xadc0ee, 0x2b8c15,
37
+ 0xd03cb2, 0x567049, 0x5ae9bf, 0xdca544, 0x43da53, 0xc596a8, 0xc90f5e, 0x4f43a5,
38
+ 0x71bd8b, 0xf7f170, 0xfb6886, 0x7d247d, 0xe25b6a, 0x641791, 0x688e67, 0xeec29c,
39
+ 0x3347a4, 0xb50b5f, 0xb992a9, 0x3fde52, 0xa0a145, 0x26edbe, 0x2a7448, 0xac38b3,
40
+ 0x92c69d, 0x148a66, 0x181390, 0x9e5f6b, 0x01207c, 0x876c87, 0x8bf571, 0x0db98a,
41
+ 0xf6092d, 0x7045d6, 0x7cdc20, 0xfa90db, 0x65efcc, 0xe3a337, 0xef3ac1, 0x69763a,
42
+ 0x578814, 0xd1c4ef, 0xdd5d19, 0x5b11e2, 0xc46ef5, 0x42220e, 0x4ebbf8, 0xc8f703,
43
+ 0x3f964d, 0xb9dab6, 0xb54340, 0x330fbb, 0xac70ac, 0x2a3c57, 0x26a5a1, 0xa0e95a,
44
+ 0x9e1774, 0x185b8f, 0x14c279, 0x928e82, 0x0df195, 0x8bbd6e, 0x872498, 0x016863,
45
+ 0xfad8c4, 0x7c943f, 0x700dc9, 0xf64132, 0x693e25, 0xef72de, 0xe3eb28, 0x65a7d3,
46
+ 0x5b59fd, 0xdd1506, 0xd18cf0, 0x57c00b, 0xc8bf1c, 0x4ef3e7, 0x426a11, 0xc426ea,
47
+ 0x2ae476, 0xaca88d, 0xa0317b, 0x267d80, 0xb90297, 0x3f4e6c, 0x33d79a, 0xb59b61,
48
+ 0x8b654f, 0x0d29b4, 0x01b042, 0x87fcb9, 0x1883ae, 0x9ecf55, 0x9256a3, 0x141a58,
49
+ 0xefaaff, 0x69e604, 0x657ff2, 0xe33309, 0x7c4c1e, 0xfa00e5, 0xf69913, 0x70d5e8,
50
+ 0x4e2bc6, 0xc8673d, 0xc4fecb, 0x42b230, 0xddcd27, 0x5b81dc, 0x57182a, 0xd154d1,
51
+ 0x26359f, 0xa07964, 0xace092, 0x2aac69, 0xb5d37e, 0x339f85, 0x3f0673, 0xb94a88,
52
+ 0x87b4a6, 0x01f85d, 0x0d61ab, 0x8b2d50, 0x145247, 0x921ebc, 0x9e874a, 0x18cbb1,
53
+ 0xe37b16, 0x6537ed, 0x69ae1b, 0xefe2e0, 0x709df7, 0xf6d10c, 0xfa48fa, 0x7c0401,
54
+ 0x42fa2f, 0xc4b6d4, 0xc82f22, 0x4e63d9, 0xd11cce, 0x575035, 0x5bc9c3, 0xdd8538
55
+ };
56
+
57
+ crc24_t crc24_update(crc24_t crc, const void *data, size_t data_len)
58
+ {
59
+ const unsigned char *d = (const unsigned char *)data;
60
+ unsigned int tbl_idx;
61
+
62
+ while (data_len--)
63
+ {
64
+ tbl_idx = ((crc >> 16) ^ *d) & 0xff;
65
+ crc = (crc24_table[tbl_idx] ^ (crc << 8)) & 0xffffff;
66
+ d++;
67
+ }
68
+
69
+ return crc & 0xffffff;
70
+ }
@@ -0,0 +1,11 @@
1
+ #ifndef _CRC24_H_
2
+ #define _CRC24_H_
3
+
4
+ #include <stdint.h>
5
+ #include <stddef.h>
6
+
7
+ typedef uint32_t crc24_t;
8
+
9
+ crc24_t crc24_update(crc24_t crc, const void *data, size_t data_len);
10
+
11
+ #endif
@@ -0,0 +1,32 @@
1
+ #include "ruby.h"
2
+ #include "extconf.h"
3
+
4
+ #include "crc24.h"
5
+
6
+ VALUE Digest_CRC24_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
+ crc24_t crc = NUM2UINT(crc_ivar);
11
+
12
+ const char *data_ptr = StringValuePtr(data);
13
+ size_t length = RSTRING_LEN(data);
14
+
15
+ crc = crc24_update(crc,data_ptr,length);
16
+
17
+ rb_ivar_set(self, crc_ivar_name, UINT2NUM(crc));
18
+ return self;
19
+ }
20
+
21
+ void Init_crc24_ext()
22
+ {
23
+ VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
24
+ VALUE cCRC24 = rb_const_get(mDigest, rb_intern("CRC24"));
25
+
26
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
27
+ rb_ext_ractor_safe(true);
28
+ #endif
29
+
30
+ rb_undef_method(cCRC24, "update");
31
+ rb_define_method(cCRC24, "update", Digest_CRC24_update, 1);
32
+ }
@@ -0,0 +1,7 @@
1
+ require 'mkmf'
2
+
3
+ have_header("stdint.h")
4
+ have_header('stddef.h')
5
+
6
+ create_header
7
+ create_makefile "digest/crc24/crc24_ext"
@@ -0,0 +1,69 @@
1
+ /**
2
+ * \file
3
+ * Functions and types for CRC checks.
4
+ *
5
+ * Generated on Sat Feb 29 06:06:44 2020
6
+ * by pycrc v0.9.2, https://pycrc.org
7
+ * using the configuration:
8
+ * - Width = 32
9
+ * - Poly = 0x04c11db7
10
+ * - XorIn = 0xffffffff
11
+ * - ReflectIn = True
12
+ * - XorOut = 0xffffffff
13
+ * - ReflectOut = True
14
+ * - Algorithm = table-driven
15
+ */
16
+ #include "crc32.h"
17
+
18
+ /**
19
+ * Static table used for the table_driven implementation.
20
+ */
21
+ static const crc32_t crc32_table[256] = {
22
+ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
23
+ 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
24
+ 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
25
+ 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
26
+ 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
27
+ 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
28
+ 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
29
+ 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
30
+ 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
31
+ 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
32
+ 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
33
+ 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
34
+ 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
35
+ 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
36
+ 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
37
+ 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
38
+ 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
39
+ 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
40
+ 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
41
+ 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
42
+ 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
43
+ 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
44
+ 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
45
+ 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
46
+ 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
47
+ 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
48
+ 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
49
+ 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
50
+ 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
51
+ 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
52
+ 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
53
+ 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
54
+ };
55
+
56
+ crc32_t crc32_update(crc32_t crc, const void *data, size_t data_len)
57
+ {
58
+ const unsigned char *d = (const unsigned char *)data;
59
+ unsigned int tbl_idx;
60
+
61
+ while (data_len--)
62
+ {
63
+ tbl_idx = (crc ^ *d) & 0xff;
64
+ crc = (crc32_table[tbl_idx] ^ (crc >> 8)) & 0xffffffff;
65
+ d++;
66
+ }
67
+
68
+ return crc & 0xffffffff;
69
+ }
@@ -0,0 +1,11 @@
1
+ #ifndef _CRC32_H_
2
+ #define _CRC32_H_
3
+
4
+ #include <stdint.h>
5
+ #include <stddef.h>
6
+
7
+ typedef uint32_t crc32_t;
8
+
9
+ crc32_t crc32_update(crc32_t crc, const void *data, size_t data_len);
10
+
11
+ #endif
@@ -0,0 +1,32 @@
1
+ #include "ruby.h"
2
+ #include "extconf.h"
3
+
4
+ #include "crc32.h"
5
+
6
+ VALUE Digest_CRC32_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
+ crc32_t crc = NUM2UINT(crc_ivar);
11
+
12
+ const char *data_ptr = StringValuePtr(data);
13
+ size_t length = RSTRING_LEN(data);
14
+
15
+ crc = crc32_update(crc,data_ptr,length);
16
+
17
+ rb_ivar_set(self, crc_ivar_name, UINT2NUM(crc));
18
+ return self;
19
+ }
20
+
21
+ void Init_crc32_ext()
22
+ {
23
+ VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
24
+ VALUE cCRC32 = rb_const_get(mDigest, rb_intern("CRC32"));
25
+
26
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
27
+ rb_ext_ractor_safe(true);
28
+ #endif
29
+
30
+ rb_undef_method(cCRC32, "update");
31
+ rb_define_method(cCRC32, "update", Digest_CRC32_update, 1);
32
+ }
@@ -0,0 +1,7 @@
1
+ require 'mkmf'
2
+
3
+ have_header("stdint.h")
4
+ have_header('stddef.h')
5
+
6
+ create_header
7
+ create_makefile "digest/crc32/crc32_ext"
@@ -0,0 +1,70 @@
1
+ /**
2
+ * \file
3
+ * Functions and types for CRC checks.
4
+ *
5
+ * Generated on Sat Feb 29 02:08:13 2020
6
+ * by pycrc v0.9.2, https://pycrc.org
7
+ * using the configuration:
8
+ * - Width = 32
9
+ * - Poly = 0x04c11db7
10
+ * - XorIn = 0xffffffff
11
+ * - ReflectIn = False
12
+ * - XorOut = 0xffffffff
13
+ * - ReflectOut = False
14
+ * - Algorithm = table-driven
15
+ */
16
+
17
+ #include "crc32_bzip2.h"
18
+
19
+ /**
20
+ * Static table used for the table_driven implementation.
21
+ */
22
+ static const crc32_t crc32_bzip2_table[256] = {
23
+ 0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005,
24
+ 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd,
25
+ 0x4c11db70, 0x48d0c6c7, 0x4593e01e, 0x4152fda9, 0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75,
26
+ 0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011, 0x791d4014, 0x7ddc5da3, 0x709f7b7a, 0x745e66cd,
27
+ 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039, 0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5,
28
+ 0xbe2b5b58, 0xbaea46ef, 0xb7a96036, 0xb3687d81, 0xad2f2d84, 0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d,
29
+ 0xd4326d90, 0xd0f37027, 0xddb056fe, 0xd9714b49, 0xc7361b4c, 0xc3f706fb, 0xceb42022, 0xca753d95,
30
+ 0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1, 0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d,
31
+ 0x34867077, 0x30476dc0, 0x3d044b19, 0x39c556ae, 0x278206ab, 0x23431b1c, 0x2e003dc5, 0x2ac12072,
32
+ 0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16, 0x018aeb13, 0x054bf6a4, 0x0808d07d, 0x0cc9cdca,
33
+ 0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde, 0x6b93dddb, 0x6f52c06c, 0x6211e6b5, 0x66d0fb02,
34
+ 0x5e9f46bf, 0x5a5e5b08, 0x571d7dd1, 0x53dc6066, 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba,
35
+ 0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, 0xbfa1b04b, 0xbb60adfc, 0xb6238b25, 0xb2e29692,
36
+ 0x8aad2b2f, 0x8e6c3698, 0x832f1041, 0x87ee0df6, 0x99a95df3, 0x9d684044, 0x902b669d, 0x94ea7b2a,
37
+ 0xe0b41de7, 0xe4750050, 0xe9362689, 0xedf73b3e, 0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2,
38
+ 0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686, 0xd5b88683, 0xd1799b34, 0xdc3abded, 0xd8fba05a,
39
+ 0x690ce0ee, 0x6dcdfd59, 0x608edb80, 0x644fc637, 0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb,
40
+ 0x4f040d56, 0x4bc510e1, 0x46863638, 0x42472b8f, 0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53,
41
+ 0x251d3b9e, 0x21dc2629, 0x2c9f00f0, 0x285e1d47, 0x36194d42, 0x32d850f5, 0x3f9b762c, 0x3b5a6b9b,
42
+ 0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff, 0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623,
43
+ 0xf12f560e, 0xf5ee4bb9, 0xf8ad6d60, 0xfc6c70d7, 0xe22b20d2, 0xe6ea3d65, 0xeba91bbc, 0xef68060b,
44
+ 0xd727bbb6, 0xd3e6a601, 0xdea580d8, 0xda649d6f, 0xc423cd6a, 0xc0e2d0dd, 0xcda1f604, 0xc960ebb3,
45
+ 0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7, 0xae3afba2, 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b,
46
+ 0x9b3660c6, 0x9ff77d71, 0x92b45ba8, 0x9675461f, 0x8832161a, 0x8cf30bad, 0x81b02d74, 0x857130c3,
47
+ 0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640, 0x4e8ee645, 0x4a4ffbf2, 0x470cdd2b, 0x43cdc09c,
48
+ 0x7b827d21, 0x7f436096, 0x7200464f, 0x76c15bf8, 0x68860bfd, 0x6c47164a, 0x61043093, 0x65c52d24,
49
+ 0x119b4be9, 0x155a565e, 0x18197087, 0x1cd86d30, 0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec,
50
+ 0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, 0x2497d08d, 0x2056cd3a, 0x2d15ebe3, 0x29d4f654,
51
+ 0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0, 0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, 0xdbee767c,
52
+ 0xe3a1cbc1, 0xe760d676, 0xea23f0af, 0xeee2ed18, 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4,
53
+ 0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5, 0x9e7d9662, 0x933eb0bb, 0x97ffad0c,
54
+ 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668, 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4
55
+ };
56
+
57
+ crc32_t crc32_bzip2_update(crc32_t crc, const void *data, size_t data_len)
58
+ {
59
+ const unsigned char *d = (const unsigned char *)data;
60
+ unsigned int tbl_idx;
61
+
62
+ while (data_len--)
63
+ {
64
+ tbl_idx = ((crc >> 24) ^ *d) & 0xff;
65
+ crc = (crc32_bzip2_table[tbl_idx] ^ (crc << 8)) & 0xffffffff;
66
+ d++;
67
+ }
68
+
69
+ return crc & 0xffffffff;
70
+ }
@@ -0,0 +1,8 @@
1
+ #ifndef _CRC32_BZIP2_H_
2
+ #define _CRC32_BZIP2_H_
3
+
4
+ #include "../crc32/crc32.h"
5
+
6
+ crc32_t crc32_bzip2_update(crc32_t crc, const void *data, size_t data_len);
7
+
8
+ #endif
@@ -0,0 +1,32 @@
1
+ #include "ruby.h"
2
+ #include "extconf.h"
3
+
4
+ #include "crc32_bzip2.h"
5
+
6
+ VALUE Digest_CRC32Bzip2_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
+ crc32_t crc = NUM2UINT(crc_ivar);
11
+
12
+ const char *data_ptr = StringValuePtr(data);
13
+ size_t length = RSTRING_LEN(data);
14
+
15
+ crc = crc32_bzip2_update(crc,data_ptr,length);
16
+
17
+ rb_ivar_set(self, crc_ivar_name, UINT2NUM(crc));
18
+ return self;
19
+ }
20
+
21
+ void Init_crc32_bzip2_ext()
22
+ {
23
+ VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
24
+ VALUE cCRC32Bzip2 = rb_const_get(mDigest, rb_intern("CRC32BZip2"));
25
+
26
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
27
+ rb_ext_ractor_safe(true);
28
+ #endif
29
+
30
+ rb_undef_method(cCRC32Bzip2, "update");
31
+ rb_define_method(cCRC32Bzip2, "update", Digest_CRC32Bzip2_update, 1);
32
+ }
@@ -0,0 +1,7 @@
1
+ require 'mkmf'
2
+
3
+ have_header("stdint.h")
4
+ have_header('stddef.h')
5
+
6
+ create_header
7
+ create_makefile "digest/crc32_bzip2/crc32_bzip2_ext"
@@ -0,0 +1,70 @@
1
+ /*
2
+ * \file
3
+ * Functions and types for CRC checks.
4
+ *
5
+ * Generated on Sat Feb 29 02:33:07 2020
6
+ * by pycrc v0.9.2, https://pycrc.org
7
+ * using the configuration:
8
+ * - Width = 32
9
+ * - Poly = 0x04c11db7
10
+ * - XorIn = 0xffffffff
11
+ * - ReflectIn = True
12
+ * - XorOut = 0x00000000
13
+ * - ReflectOut = True
14
+ * - Algorithm = table-driven
15
+ */
16
+
17
+ #include "crc32_jam.h"
18
+
19
+ /**
20
+ * Static table used for the table_driven implementation.
21
+ */
22
+ static const crc32_t crc32_table[256] = {
23
+ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
24
+ 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
25
+ 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
26
+ 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
27
+ 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
28
+ 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
29
+ 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
30
+ 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
31
+ 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
32
+ 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
33
+ 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
34
+ 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
35
+ 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
36
+ 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
37
+ 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
38
+ 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
39
+ 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
40
+ 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
41
+ 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
42
+ 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
43
+ 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
44
+ 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
45
+ 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
46
+ 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
47
+ 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
48
+ 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
49
+ 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
50
+ 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
51
+ 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
52
+ 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
53
+ 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
54
+ 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
55
+ };
56
+
57
+ crc32_t crc32_jam_update(crc32_t crc, const void *data, size_t data_len)
58
+ {
59
+ const unsigned char *d = (const unsigned char *)data;
60
+ unsigned int tbl_idx;
61
+
62
+ while (data_len--)
63
+ {
64
+ tbl_idx = (crc ^ *d) & 0xff;
65
+ crc = (crc32_table[tbl_idx] ^ (crc >> 8)) & 0xffffffff;
66
+ d++;
67
+ }
68
+
69
+ return crc & 0xffffffff;
70
+ }
@@ -0,0 +1,8 @@
1
+ #ifndef _CRC32_JAM_H_
2
+ #define _CRC32_JAM_H_
3
+
4
+ #include "../crc32/crc32.h"
5
+
6
+ crc32_t crc32_jam_update(crc32_t crc, const void *data, size_t data_len);
7
+
8
+ #endif
@@ -0,0 +1,31 @@
1
+ #include "ruby.h"
2
+ #include "extconf.h"
3
+
4
+ #include "crc32_jam.h"
5
+
6
+ VALUE Digest_CRC32Jam_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
+ crc32_t crc = NUM2UINT(crc_ivar);
11
+
12
+ const char *data_ptr = StringValuePtr(data);
13
+ size_t length = RSTRING_LEN(data);
14
+
15
+ crc = crc32_jam_update(crc,data_ptr,length);
16
+
17
+ rb_ivar_set(self, crc_ivar_name, UINT2NUM(crc));
18
+ return self;
19
+ }
20
+
21
+ void Init_crc32_jam_ext()
22
+ {
23
+ VALUE mDigest = rb_const_get(rb_cObject, rb_intern("Digest"));
24
+ VALUE cCRC32Jam = rb_const_get(mDigest, rb_intern("CRC32Jam"));
25
+
26
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
27
+ rb_ext_ractor_safe(true);
28
+ #endif
29
+
30
+ rb_define_method(cCRC32Jam, "update", Digest_CRC32Jam_update, 1);
31
+ }
@@ -0,0 +1,7 @@
1
+ require 'mkmf'
2
+
3
+ have_header("stdint.h")
4
+ have_header('stddef.h')
5
+
6
+ create_header
7
+ create_makefile "digest/crc32_jam/crc32_jam_ext"