| 1 |
root |
1.1 |
NAME |
| 2 |
root |
1.4 |
String::CRC32C - Castagnoli CRC |
| 3 |
root |
1.1 |
|
| 4 |
|
|
SYNOPSIS |
| 5 |
root |
1.2 |
use String::CRC32C; # does not export anything by default |
| 6 |
|
|
use String::CRC32C 'crc32c'; |
| 7 |
|
|
|
| 8 |
|
|
$crc = crc32 "some string"; |
| 9 |
|
|
$crc = crc32 "some string", $initvalue; |
| 10 |
root |
1.1 |
|
| 11 |
|
|
DESCRIPTION |
| 12 |
root |
1.2 |
This module calculates the Castagnoli CRC32 variant (polynomial |
| 13 |
|
|
0x11EDC6F41). |
| 14 |
|
|
|
| 15 |
root |
1.3 |
It is used by iSCSI, SCTP, BTRFS, ext4, leveldb, x86 CPUs and others. |
| 16 |
root |
1.2 |
|
| 17 |
root |
1.3 |
This module uses an optimized implementation for SSE 4.2 targets (GCC |
| 18 |
|
|
and compatible supported, SSE 4.2 must be enabled in your Perl) and the |
| 19 |
root |
1.2 |
SlicingBy8 algorithm for anything else. |
| 20 |
|
|
|
| 21 |
|
|
$crc32c = crc32c $string[, $initvalue] |
| 22 |
|
|
Calculates the CRC32C value of the given $string and returns it as a |
| 23 |
|
|
32 bit unsigned integer. |
| 24 |
|
|
|
| 25 |
|
|
To get the common hex form, use one of: |
| 26 |
|
|
|
| 27 |
|
|
sprintf "%08x", crc32c $string |
| 28 |
|
|
unpack "H*", pack "L>", crc32c $string |
| 29 |
|
|
|
| 30 |
|
|
A seed/initial crc value can be given as second argument. Note that |
| 31 |
|
|
both the initial value and the result value are inverted |
| 32 |
|
|
(pre-inversion and post-inversion), e.g. a common init value of -1 |
| 33 |
|
|
from other descriptions needs to be given as 0 (or "~-1"). |
| 34 |
|
|
|
| 35 |
|
|
This allows easy chaining, e.g. |
| 36 |
|
|
|
| 37 |
root |
1.4 |
(crc32c "abcdefghi") eq (crc32 "ghi", crc32 "def", crc32 "abc") |
| 38 |
root |
1.1 |
|
| 39 |
root |
1.4 |
$String::CRC32C::IMPL |
| 40 |
|
|
Contains a string indicating the implementation that will be used. |
| 41 |
root |
1.3 |
Currently either "SlicingBy8" for the portable implementation or |
| 42 |
|
|
"IntelCSSE42" for the SSE 4.2 optimized intel version. |
| 43 |
|
|
|
| 44 |
root |
1.4 |
PERLMULTICORE SUPPORT |
| 45 |
|
|
This module supports the perl multicore spoecification |
| 46 |
|
|
(<http://perlmulticore.schmorp.de/>): the "crc32c" function will |
| 47 |
|
|
relinquish the current thread for crc32c lengths larger than 64k (the |
| 48 |
|
|
break-even point on my machine is around 128k), so multiprocessing makes |
| 49 |
|
|
only sense for very long blocks. |
| 50 |
|
|
|
| 51 |
root |
1.1 |
AUTHOR |
| 52 |
|
|
Marc Lehmann <schmorp@schmorp.de> |
| 53 |
|
|
http://home.schmorp.de/ |
| 54 |
|
|
|
| 55 |
root |
1.2 |
CRC32C code by various sources, ported from |
| 56 |
|
|
https://github.com/htot/crc32c, see sources for details. |
| 57 |
|
|
|