line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#define PERL_NO_GET_CONTEXT |
2
|
|
|
|
|
|
|
#define MATH_INT64_NATIVE_IF_AVAILABLE |
3
|
|
|
|
|
|
|
#include "EXTERN.h" |
4
|
|
|
|
|
|
|
#include "perl.h" |
5
|
|
|
|
|
|
|
#include "XSUB.h" |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#include "perl_math_int64.h" |
8
|
|
|
|
|
|
|
#include "ppport.h" |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#include "highwayhash.c" |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
/* |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
uint64_t HighwayHash64(const uint8_t* data, size_t size, const uint64_t key[4]); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
void HighwayHash128(const uint8_t* data, size_t size, |
17
|
|
|
|
|
|
|
const uint64_t key[4], uint64_t hash[2]); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
void HighwayHash256(const uint8_t* data, size_t size, |
20
|
|
|
|
|
|
|
const uint64_t key[4], uint64_t hash[4]); |
21
|
|
|
|
|
|
|
*/ |
22
|
|
|
|
|
|
|
|
23
|
3
|
|
|
|
|
|
void process_key(pTHX_ AV *key_av, uint64_t *key) { |
24
|
|
|
|
|
|
|
int i; |
25
|
|
|
|
|
|
|
SV *elt; |
26
|
|
|
|
|
|
|
|
27
|
3
|
50
|
|
|
|
|
if(av_len(key_av) + 1 != 4) |
28
|
0
|
|
|
|
|
|
croak("Key for highway_hash must be a 4-element array"); |
29
|
15
|
100
|
|
|
|
|
for(i = 0 ; i < 4 ; i++) { |
30
|
12
|
|
|
|
|
|
elt = *av_fetch(key_av, i, false); |
31
|
12
|
50
|
|
|
|
|
if(SvU64OK(elt)) |
32
|
0
|
|
|
|
|
|
key[i] = SvU64(elt); |
33
|
|
|
|
|
|
|
else |
34
|
12
|
50
|
|
|
|
|
key[i] = SvUV(elt); |
35
|
|
|
|
|
|
|
} |
36
|
3
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
|
|
|
uint64_t highway_hash64(AV *key_av, char *bytes, uint64_t size) { |
39
|
|
|
|
|
|
|
dTHX; |
40
|
|
|
|
|
|
|
uint64_t key[4]; |
41
|
1
|
|
|
|
|
|
process_key(aTHX_ key_av, key); |
42
|
1
|
|
|
|
|
|
return HighwayHash64(bytes, size, key); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
1
|
|
|
|
|
|
AV* highway_hash128(AV *key_av, char *bytes, uint64_t size) { |
46
|
|
|
|
|
|
|
dTHX; |
47
|
|
|
|
|
|
|
AV* result; |
48
|
|
|
|
|
|
|
uint64_t key[4]; |
49
|
|
|
|
|
|
|
uint64_t hash[2]; |
50
|
1
|
|
|
|
|
|
process_key(aTHX_ key_av, key); |
51
|
1
|
|
|
|
|
|
HighwayHash128(bytes, size, key, hash); |
52
|
1
|
|
|
|
|
|
result = newAV(); |
53
|
1
|
|
|
|
|
|
av_push(result, sv_2mortal(newSVu64(hash[0]))); |
54
|
1
|
|
|
|
|
|
av_push(result, sv_2mortal(newSVu64(hash[1]))); |
55
|
1
|
|
|
|
|
|
return result; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
1
|
|
|
|
|
|
AV* highway_hash256(AV *key_av, char *bytes, uint64_t size) { |
59
|
|
|
|
|
|
|
dTHX; |
60
|
|
|
|
|
|
|
AV* result; |
61
|
|
|
|
|
|
|
uint64_t key[4]; |
62
|
|
|
|
|
|
|
uint64_t hash[2]; |
63
|
1
|
|
|
|
|
|
process_key(aTHX_ key_av, key); |
64
|
1
|
|
|
|
|
|
HighwayHash256(bytes, size, key, hash); |
65
|
1
|
|
|
|
|
|
result = newAV(); |
66
|
1
|
|
|
|
|
|
av_push(result, sv_2mortal(newSVu64(hash[0]))); |
67
|
1
|
|
|
|
|
|
av_push(result, sv_2mortal(newSVu64(hash[1]))); |
68
|
1
|
|
|
|
|
|
av_push(result, sv_2mortal(newSVu64(hash[2]))); |
69
|
1
|
|
|
|
|
|
av_push(result, sv_2mortal(newSVu64(hash[3]))); |
70
|
1
|
|
|
|
|
|
return result; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
MODULE = Digest::HighwayHash PACKAGE = Digest::HighwayHash |
74
|
|
|
|
|
|
|
BOOT: |
75
|
1
|
50
|
|
|
|
|
PERL_MATH_INT64_LOAD_OR_CROAK; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
uint64_t highway_hash64(AV *key_av, char *bytes, uint64_t length(bytes)) |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
AV* highway_hash128(AV *key_av, char *bytes, uint64_t length(bytes)) |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
AV* highway_hash256(AV *key_av, char *bytes, uint64_t length(bytes)) |