| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#include "EXTERN.h" |
|
2
|
|
|
|
|
|
|
#include "perl.h" |
|
3
|
|
|
|
|
|
|
#include "XSUB.h" |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#include "perlmulticore.h" |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
// portable impl |
|
8
|
|
|
|
|
|
|
#include "crc32csb8.c" |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
static uint32_t (*crc32c) (uint32_t crc, const void *data, size_t length) = crc32cSlicingBy8; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
// optimized sse4.2 impl |
|
13
|
|
|
|
|
|
|
#if __GNUC__ >= 8 && (__i386__ || __x86_64__) && __SSE4_2__ /* for __builtin__crc32 */ |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
#include |
|
16
|
|
|
|
|
|
|
#include "crc32intelc.c" |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
static const char * |
|
19
|
|
|
|
|
|
|
detect (void) |
|
20
|
|
|
|
|
|
|
{ |
|
21
|
|
|
|
|
|
|
unsigned int eax, ebx, ecx = 0, edx; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
__get_cpuid (1, &eax, &ebx, &ecx, &edx); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
if (ecx & bit_SSE4_2) |
|
26
|
|
|
|
|
|
|
{ |
|
27
|
|
|
|
|
|
|
crc32c = crc32cIntelC; |
|
28
|
|
|
|
|
|
|
return "IntelCSSE42"; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
return "SlicingBy8"; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
#else |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
static const char * |
|
37
|
2
|
|
|
|
|
|
detect (void) |
|
38
|
|
|
|
|
|
|
{ |
|
39
|
2
|
|
|
|
|
|
return "SlicingBy8"; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
#endif |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
MODULE = String::CRC32C PACKAGE = String::CRC32C |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
BOOT: |
|
47
|
2
|
50
|
|
|
|
|
perlmulticore_support (); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
48
|
2
|
|
|
|
|
|
sv_setpv (get_sv ("String::CRC32C::IMPL", GV_ADD), detect ()); |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
PROTOTYPES: ENABLE |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
U32 crc32c (SV *data, U32 initvalue = 0) |
|
53
|
|
|
|
|
|
|
CODE: |
|
54
|
|
|
|
|
|
|
{ |
|
55
|
|
|
|
|
|
|
STRLEN len; |
|
56
|
8
|
|
|
|
|
|
const char *ptr = SvPVbyte (data, len); |
|
57
|
8
|
50
|
|
|
|
|
if (len > 65536) perlinterp_release (); |
|
58
|
8
|
|
|
|
|
|
RETVAL = ~crc32c (~initvalue, ptr, len); |
|
59
|
8
|
50
|
|
|
|
|
if (len > 65536) perlinterp_acquire (); |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
OUTPUT: RETVAL |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|