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 +4 -4
- data/HISTORY.ja.md +7 -1
- data/README.md +13 -9
- data/ext/crc/crc_imps.h +2 -2
- data/ext/crc/crcturbo.c +35 -50
- data/gemstub.rb +9 -8
- metadata +12 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6264e617f1b52dbff8f4905030bd1a7d4df20fb
|
4
|
+
data.tar.gz: d8181645b2fc56467c113f8ac04a3eccfaee9a9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55eb3f257d636dbef6292bcd3ff31e8b0f3e496cbb349ae6ee9e8e61d20a57a825919ebf43f43986ec775ab74de87fa627fd1af4e0f75e3688173b89d09668ca
|
7
|
+
data.tar.gz: c59df1da5c3c1c19f9efe325df24bdfe14f8d7d19f542534013dbbcbc05e0ace71f527f0045e0a294ccdce10a05896c92539b3bc0edc4b173d4ec9bf16079687
|
data/HISTORY.ja.md
CHANGED
data/README.md
CHANGED
@@ -1,21 +1,25 @@
|
|
1
1
|
|
2
|
-
# crc-turbo -
|
2
|
+
# crc-turbo - C written accelerator for ruby CRC calcurator
|
3
3
|
|
4
|
-
|
4
|
+
C written accelerator for "crc" gem library.
|
5
5
|
|
6
|
-
Just install this, and to do
|
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.
|
13
|
-
* report issue to: <https://
|
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.
|
16
|
-
*
|
17
|
-
* licensing:
|
18
|
-
|
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
|
|
data/ext/crc/crc_imps.h
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
/*
|
2
|
-
* author:: dearblue <dearblue@users.
|
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
|
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.
|
data/ext/crc/crcturbo.c
CHANGED
@@ -16,16 +16,16 @@ enum {
|
|
16
16
|
TABLE_NOTREADY = 0x1000,
|
17
17
|
};
|
18
18
|
|
19
|
-
//#define SNNIPET(BITSIZE,
|
20
|
-
#define SWITCH_BY_TYPE(TYPE, SNNIPET)
|
21
|
-
switch ((TYPE)) {
|
22
|
-
case TYPE_UINT8_T: { SNNIPET( 8,
|
23
|
-
case TYPE_UINT16_T: { SNNIPET( 16,
|
24
|
-
case TYPE_UINT32_T: { SNNIPET( 32,
|
25
|
-
case TYPE_UINT64_T: { SNNIPET( 64,
|
26
|
-
/* case TYPE_UINT128_T: { SNNIPET(128,
|
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,
|
417
|
-
p->bitmask
|
418
|
-
p->polynomial
|
419
|
-
p->initial
|
420
|
-
p->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("
|
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,
|
447
|
-
return CONVUINT(p->bitmask
|
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,
|
458
|
-
return CONVUINT(p->polynomial
|
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,
|
469
|
-
return CONVUINT(p->initial
|
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,
|
501
|
-
return CONVUINT(p->xorout
|
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,
|
540
|
-
crc_build_reflect_tables_u##BITSIZE(p->bitsize, table, p->polynomial
|
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,
|
545
|
-
crc_build_tables_u##BITSIZE(p->bitsize, table, p->polynomial
|
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,
|
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,
|
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.
|
4
|
-
s.summary = "
|
3
|
+
s.version = "0.4"
|
4
|
+
s.summary = "C written accelerator for \"crc\" gem library"
|
5
5
|
s.description = <<EOS
|
6
|
-
|
7
|
-
Just install this, and to do
|
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://
|
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.
|
13
|
+
s.email = "dearblue@users.noreply.github.com"
|
13
14
|
|
14
|
-
s.required_ruby_version = ">= 2.
|
15
|
+
s.required_ruby_version = ">= 2.2"
|
15
16
|
s.add_development_dependency "rake"
|
16
|
-
s.add_runtime_dependency "crc", "~> 0.
|
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.
|
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:
|
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:
|
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:
|
40
|
+
version: 0.4.A
|
41
41
|
description: |
|
42
|
-
|
43
|
-
Just install this, and to do
|
44
|
-
|
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://
|
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.
|
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.
|
89
|
+
rubygems_version: 2.6.10
|
89
90
|
signing_key:
|
90
91
|
specification_version: 4
|
91
|
-
summary:
|
92
|
+
summary: C written accelerator for "crc" gem library
|
92
93
|
test_files: []
|