crc-turbo 0.3 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a49a016f795553e23b9b023b621e9390685ebbe
4
- data.tar.gz: 0d42b72af55e038705b6a74cbda02a7333b9a782
3
+ metadata.gz: c6264e617f1b52dbff8f4905030bd1a7d4df20fb
4
+ data.tar.gz: d8181645b2fc56467c113f8ac04a3eccfaee9a9d
5
5
  SHA512:
6
- metadata.gz: a368f931fe8d8959a4491347f4fab9012ce30349f719eb80db795e4813c59cb8f02176b46df26a408b19a1d6c518eef7e78b2f0433bfb6254231a381a95e3d34
7
- data.tar.gz: e75bc2d1dbf6054a4a5d526aae24719da7a4b82db57ee4ddeb257395457e41082eaa9fb1f5055041c04fd35acae16f3f684583285a55413f6e4b01fd172234f4
6
+ metadata.gz: 55eb3f257d636dbef6292bcd3ff31e8b0f3e496cbb349ae6ee9e8e61d20a57a825919ebf43f43986ec775ab74de87fa627fd1af4e0f75e3688173b89d09668ca
7
+ data.tar.gz: c59df1da5c3c1c19f9efe325df24bdfe14f8d7d19f542534013dbbcbc05e0ace71f527f0045e0a294ccdce10a05896c92539b3bc0edc4b173d4ec9bf16079687
@@ -2,7 +2,13 @@ This document is written in Japanese.
2
2
 
3
3
  # crc-turbo for ruby の更新履歴
4
4
 
5
- ## crc-0.3
5
+
6
+ ## crc-0.4 (TRYOUT)
7
+
8
+ * crc-0.4 に追従
9
+
10
+
11
+ ## crc-0.3 (平成28年7月31日 日曜日)
6
12
 
7
13
  * crc-0.3 に追従して、CRC::BasicCRC と CRC::Generator を CRC に統合
8
14
 
data/README.md CHANGED
@@ -1,21 +1,25 @@
1
1
 
2
- # crc-turbo - CRC generator for ruby
2
+ # crc-turbo - C written accelerator for ruby CRC calcurator
3
3
 
4
- This is a C extention for "crc" gem library.
4
+ C written accelerator for "crc" gem library.
5
5
 
6
- Just install this, and to do "require 'crc'" only. Additional other work is not required.
6
+ Just install this, and to do ``require "crc"`` only.
7
+
8
+ Additional other work is not required.
7
9
 
8
10
 
9
11
  ## Summary
10
12
 
11
13
  * package name: crc-turbo
12
- * author: dearblue (mailto:dearblue@users.osdn.me)
13
- * report issue to: <https://osdn.jp/projects/rutsubo/ticket/>
14
+ * author: dearblue (mailto:dearblue@users.noreply.github.com)
15
+ * report issue to: <https://github.com/dearblue/ruby-crc/issues>
14
16
  * how to install: ``gem install crc-turbo``
15
- * version: 0.3
16
- * release quality: thechnical preview
17
- * licensing: BSD-2-Clause<br>any parts are under Creative Commons License Zero (CC0 / Public Domain).
18
- * dependency gems: crc-0.3 (<https://rubygems/gems/crc>)
17
+ * version: 0.4
18
+ * production quality: TECHNICAL PREVIEW
19
+ * licensing:
20
+ * ***BSD-2-Clause : MAIN LICENSE***
21
+ * Creative Commons License Zero (CC0 / Public Domain) : ``ext/crc/crc_imps.h``
22
+ * dependency gems: crc-0.4 (<https://rubygems/gems/crc>)
19
23
  * dependency external C libraries: none
20
24
  * bundled external C libraries: none
21
25
 
@@ -1,8 +1,8 @@
1
1
  /*
2
- * author:: dearblue <dearblue@users.osdn.me>
2
+ * author:: dearblue <dearblue@users.noreply.github.com>
3
3
  * license:: Creative Commons License Zero (CC0 / Public Domain)
4
4
  *
5
- * This is a general CRC generator.
5
+ * This is a general CRC calcurator.
6
6
  *
7
7
  * It's used slice-by-16 algorithm with byte-order free.
8
8
  * This is based on the Intel's slice-by-eight algorithm.
@@ -16,16 +16,16 @@ enum {
16
16
  TABLE_NOTREADY = 0x1000,
17
17
  };
18
18
 
19
- //#define SNNIPET(BITSIZE, AS, TYPE, TOUINT, CONVUINT)
20
- #define SWITCH_BY_TYPE(TYPE, SNNIPET) \
21
- switch ((TYPE)) { \
22
- case TYPE_UINT8_T: { SNNIPET( 8, as8, uint8_t, to_uint8, conv_uint8); break; } \
23
- case TYPE_UINT16_T: { SNNIPET( 16, as16, uint16_t, to_uint16, conv_uint16); break; } \
24
- case TYPE_UINT32_T: { SNNIPET( 32, as32, uint32_t, to_uint32, conv_uint32); break; } \
25
- case TYPE_UINT64_T: { SNNIPET( 64, as64, uint64_t, to_uint64, conv_uint64); break; } \
26
- /* case TYPE_UINT128_T: { SNNIPET(128, as128, uint128_t, to_uint128, conv_uint128); break; } */ \
27
- default: { rb_bug(" [INVALID TYPE FLAGS: 0x%02X] ", (TYPE)); } \
28
- } \
19
+ //#define SNNIPET(BITSIZE, TYPE, TOUINT, CONVUINT)
20
+ #define SWITCH_BY_TYPE(TYPE, SNNIPET) \
21
+ switch ((TYPE)) { \
22
+ case TYPE_UINT8_T: { SNNIPET( 8, uint8_t, to_uint8, conv_uint8); break; } \
23
+ case TYPE_UINT16_T: { SNNIPET( 16, uint16_t, to_uint16, conv_uint16); break; } \
24
+ case TYPE_UINT32_T: { SNNIPET( 32, uint32_t, to_uint32, conv_uint32); break; } \
25
+ case TYPE_UINT64_T: { SNNIPET( 64, uint64_t, to_uint64, conv_uint64); break; } \
26
+ /* case TYPE_UINT128_T: { SNNIPET(128, uint128_t, to_uint128, conv_uint128); break; } */ \
27
+ default: { rb_bug(" [INVALID TYPE FLAGS: 0x%02X] ", (TYPE)); } \
28
+ } \
29
29
 
30
30
  static inline uint8_t
31
31
  to_uint8(VALUE num)
@@ -309,27 +309,13 @@ bitsize_to_type(int bitsize)
309
309
  *
310
310
  */
311
311
 
312
- typedef struct anyuint_t
313
- {
314
- union {
315
- uint8_t as8;
316
- uint16_t as16;
317
- uint32_t as32;
318
- uint64_t as64;
319
- #ifdef HAVE_TYPE_UINT128_T
320
- uint128_t as128;
321
- #endif
322
- };
323
- } anyuint_t;
324
-
325
312
  struct crc_module
326
313
  {
327
314
  uint32_t bitsize:10;
328
315
  uint32_t type:10;
329
316
  uint32_t reflect_input:1;
330
317
  uint32_t reflect_output:1;
331
-
332
- anyuint_t bitmask, polynomial, initial, xorout;
318
+ uint64_t bitmask, polynomial, initial, xorout;
333
319
  const void *table; /* entity is String buffer as instance variable */
334
320
  };
335
321
 
@@ -413,11 +399,11 @@ ext_s_new(int argc, VALUE argv[], VALUE crc)
413
399
  * 例えば uint8_t に対して << 8 をすると何もしないため、
414
400
  * これへの対処を目的とする。
415
401
  */
416
- #define SNNIPET_INIT_MOD(BITSIZE, AS, TYPE, TOUINT, CONVUINT) \
417
- p->bitmask.AS = ~(~(TYPE)0 << 1 << (bitsize - 1)); \
418
- p->polynomial.AS = p->bitmask.AS & TOUINT(poly); \
419
- p->initial.AS = p->bitmask.AS & TOUINT(init); \
420
- p->xorout.AS = p->bitmask.AS & TOUINT(xorout); \
402
+ #define SNNIPET_INIT_MOD(BITSIZE, TYPE, TOUINT, CONVUINT) \
403
+ p->bitmask = ~(~(uint64_t)0 << 1 << (bitsize - 1)); \
404
+ p->polynomial = p->bitmask & TOUINT(poly); \
405
+ p->initial = p->bitmask & TOUINT(init); \
406
+ p->xorout = p->bitmask & TOUINT(xorout); \
421
407
 
422
408
  SWITCH_BY_TYPE(p->type, SNNIPET_INIT_MOD);
423
409
 
@@ -425,8 +411,7 @@ ext_s_new(int argc, VALUE argv[], VALUE crc)
425
411
  rb_ivar_set(newcrc, ext_iv_module, crcmod);
426
412
  rb_ivar_set(newcrc, ext_iv_name, name);
427
413
 
428
- rb_extend_object(newcrc, rb_const_get(cCRC, rb_intern("ModuleClass")));
429
- rb_define_alias(rb_singleton_class(newcrc), "[]", "new");
414
+ rb_extend_object(newcrc, rb_const_get(cCRC, rb_intern("Calcurator")));
430
415
 
431
416
  return newcrc;
432
417
  }
@@ -443,8 +428,8 @@ ext_bitmask(VALUE t)
443
428
  {
444
429
  struct crc_module *p = get_module(t);
445
430
 
446
- #define SNNIPET_BITMASK(BITSIZE, AS, TYPE, TOUINT, CONVUINT) \
447
- return CONVUINT(p->bitmask.AS); \
431
+ #define SNNIPET_BITMASK(BITSIZE, TYPE, TOUINT, CONVUINT) \
432
+ return CONVUINT(p->bitmask); \
448
433
 
449
434
  SWITCH_BY_TYPE(p->type, SNNIPET_BITMASK);
450
435
  }
@@ -454,8 +439,8 @@ ext_polynomial(VALUE t)
454
439
  {
455
440
  struct crc_module *p = get_module(t);
456
441
 
457
- #define SNNIPET_POLYNOMIAL(BITSIZE, AS, TYPE, TOUINT, CONVUINT) \
458
- return CONVUINT(p->polynomial.AS); \
442
+ #define SNNIPET_POLYNOMIAL(BITSIZE, TYPE, TOUINT, CONVUINT) \
443
+ return CONVUINT(p->polynomial); \
459
444
 
460
445
  SWITCH_BY_TYPE(p->type, SNNIPET_POLYNOMIAL);
461
446
  }
@@ -465,8 +450,8 @@ ext_initial_crc(VALUE t)
465
450
  {
466
451
  struct crc_module *p = get_module(t);
467
452
 
468
- #define SNNIPET_INITIAL_CRC(BITSIZE, AS, TYPE, TOUINT, CONVUINT) \
469
- return CONVUINT(p->initial.AS); \
453
+ #define SNNIPET_INITIAL_CRC(BITSIZE, TYPE, TOUINT, CONVUINT) \
454
+ return CONVUINT(p->initial); \
470
455
 
471
456
  SWITCH_BY_TYPE(p->type, SNNIPET_INITIAL_CRC);
472
457
  }
@@ -497,8 +482,8 @@ ext_xor_output(VALUE t)
497
482
  {
498
483
  struct crc_module *p = get_module(t);
499
484
 
500
- #define SNNIPET_XOR_OUTPUT(BITSIZE, AS, TYPE, TOUINT, CONVUINT) \
501
- return CONVUINT(p->xorout.AS); \
485
+ #define SNNIPET_XOR_OUTPUT(BITSIZE, TYPE, TOUINT, CONVUINT) \
486
+ return CONVUINT(p->xorout); \
502
487
 
503
488
  SWITCH_BY_TYPE(p->type, SNNIPET_XOR_OUTPUT);
504
489
  }
@@ -536,13 +521,13 @@ ext_update(VALUE t, VALUE seq, VALUE state)
536
521
  rb_str_set_len(tablebuf, tablebytes);
537
522
  void *table = RSTRING_PTR(tablebuf);
538
523
  if (p->reflect_input) {
539
- #define SNNIPET_BUILD_REFTABLE(BITSIZE, AS, TYPE, TOUINT, CONVUINT) \
540
- crc_build_reflect_tables_u##BITSIZE(p->bitsize, table, p->polynomial.AS, 16); \
524
+ #define SNNIPET_BUILD_REFTABLE(BITSIZE, TYPE, TOUINT, CONVUINT) \
525
+ crc_build_reflect_tables_u##BITSIZE(p->bitsize, table, p->polynomial, 16); \
541
526
 
542
527
  SWITCH_BY_TYPE(p->type, SNNIPET_BUILD_REFTABLE);
543
528
  } else {
544
- #define SNNIPET_BUILD_TABLE(BITSIZE, AS, TYPE, TOUINT, CONVUINT) \
545
- crc_build_tables_u##BITSIZE(p->bitsize, table, p->polynomial.AS, 16); \
529
+ #define SNNIPET_BUILD_TABLE(BITSIZE, TYPE, TOUINT, CONVUINT) \
530
+ crc_build_tables_u##BITSIZE(p->bitsize, table, p->polynomial, 16); \
546
531
 
547
532
  SWITCH_BY_TYPE(p->type, SNNIPET_BUILD_TABLE);
548
533
  }
@@ -552,15 +537,15 @@ ext_update(VALUE t, VALUE seq, VALUE state)
552
537
  }
553
538
 
554
539
  if (p->reflect_input) {
555
- #define SNNIPET_REFUPDATE(BITSIZE, AS, TYPE, TOUINT, CONVUINT) \
556
- return CONVUINT(crc_reflect_update_u##BITSIZE( \
557
- p->bitsize, p->table, q, qq, TOUINT(state))); \
540
+ #define SNNIPET_REFUPDATE(BITSIZE, TYPE, TOUINT, CONVUINT) \
541
+ return CONVUINT(crc_reflect_update_u##BITSIZE( \
542
+ p->bitsize, p->table, q, qq, TOUINT(state))); \
558
543
 
559
544
  SWITCH_BY_TYPE(p->type, SNNIPET_REFUPDATE);
560
545
  } else {
561
- #define SNNIPET_UPDATE(BITSIZE, AS, TYPE, TOUINT, CONVUINT) \
562
- return CONVUINT(crc_update_u##BITSIZE( \
563
- p->bitsize, p->table, q, qq, TOUINT(state))); \
546
+ #define SNNIPET_UPDATE(BITSIZE, TYPE, TOUINT, CONVUINT) \
547
+ return CONVUINT(crc_update_u##BITSIZE( \
548
+ p->bitsize, p->table, q, qq, TOUINT(state))); \
564
549
 
565
550
  SWITCH_BY_TYPE(p->type, SNNIPET_UPDATE);
566
551
  }
data/gemstub.rb CHANGED
@@ -1,19 +1,20 @@
1
1
  GEMSTUB = Gem::Specification.new do |s|
2
2
  s.name = "crc-turbo"
3
- s.version = "0.3"
4
- s.summary = "general CRC generator"
3
+ s.version = "0.4"
4
+ s.summary = "C written accelerator for \"crc\" gem library"
5
5
  s.description = <<EOS
6
- This is a C extention for "crc" gem library.
7
- Just install this, and to do "require 'crc'" only. Additional other work is not required.
6
+ C written accelerator for "crc" gem library.
7
+ Just install this, and to do ``require "crc"`` only.
8
+ Additional other work is not required.
8
9
  EOS
9
- s.homepage = "https://osdn.jp/projects/rutsubo/"
10
+ s.homepage = "https://github.com/dearblue/ruby-crc-turbo"
10
11
  s.licenses = ["BSD-2-Clause", "CC0-1.0"]
11
12
  s.author = "dearblue"
12
- s.email = "dearblue@users.osdn.me"
13
+ s.email = "dearblue@users.noreply.github.com"
13
14
 
14
- s.required_ruby_version = ">= 2.0"
15
+ s.required_ruby_version = ">= 2.2"
15
16
  s.add_development_dependency "rake"
16
- s.add_runtime_dependency "crc", "~> 0.3"
17
+ s.add_runtime_dependency "crc", "~> 0.4.A"
17
18
  end
18
19
 
19
20
  EXTMAP["crc"] = "crc/_turbo"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crc-turbo
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: '0.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - dearblue
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-31 00:00:00.000000000 Z
11
+ date: 2017-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -30,18 +30,19 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.3'
33
+ version: 0.4.A
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.3'
40
+ version: 0.4.A
41
41
  description: |
42
- This is a C extention for "crc" gem library.
43
- Just install this, and to do "require 'crc'" only. Additional other work is not required.
44
- email: dearblue@users.osdn.me
42
+ C written accelerator for "crc" gem library.
43
+ Just install this, and to do ``require "crc"`` only.
44
+ Additional other work is not required.
45
+ email: dearblue@users.noreply.github.com
45
46
  executables: []
46
47
  extensions:
47
48
  - ext/crc/extconf.rb
@@ -60,7 +61,7 @@ files:
60
61
  - ext/crc/crcturbo.c
61
62
  - ext/crc/extconf.rb
62
63
  - gemstub.rb
63
- homepage: https://osdn.jp/projects/rutsubo/
64
+ homepage: https://github.com/dearblue/ruby-crc-turbo
64
65
  licenses:
65
66
  - BSD-2-Clause
66
67
  - CC0-1.0
@@ -77,7 +78,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
77
78
  requirements:
78
79
  - - ">="
79
80
  - !ruby/object:Gem::Version
80
- version: '2.0'
81
+ version: '2.2'
81
82
  required_rubygems_version: !ruby/object:Gem::Requirement
82
83
  requirements:
83
84
  - - ">="
@@ -85,8 +86,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
86
  version: '0'
86
87
  requirements: []
87
88
  rubyforge_project:
88
- rubygems_version: 2.6.4
89
+ rubygems_version: 2.6.10
89
90
  signing_key:
90
91
  specification_version: 4
91
- summary: general CRC generator
92
+ summary: C written accelerator for "crc" gem library
92
93
  test_files: []