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
|
3
|
|
|
|
|
|
void process_key(pTHX_ AV *key_av, uint64_t *key) { |
13
|
|
|
|
|
|
|
int i; |
14
|
|
|
|
|
|
|
SV *elt; |
15
|
|
|
|
|
|
|
|
16
|
3
|
50
|
|
|
|
|
if(av_len(key_av) + 1 != 4) |
17
|
0
|
|
|
|
|
|
croak("Key for highway_hash must be a 4-element array"); |
18
|
15
|
100
|
|
|
|
|
for(i = 0 ; i < 4 ; i++) { |
19
|
12
|
|
|
|
|
|
elt = *av_fetch(key_av, i, false); |
20
|
12
|
50
|
|
|
|
|
if(SvU64OK(elt)) |
21
|
0
|
|
|
|
|
|
key[i] = SvU64(elt); |
22
|
|
|
|
|
|
|
else |
23
|
12
|
50
|
|
|
|
|
key[i] = SvUV(elt); |
24
|
|
|
|
|
|
|
} |
25
|
3
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
|
|
|
uint64_t highway_hash64(AV *key_av, char *bytes, uint64_t size) { |
28
|
|
|
|
|
|
|
dTHX; |
29
|
|
|
|
|
|
|
uint64_t key[4]; |
30
|
1
|
|
|
|
|
|
process_key(aTHX_ key_av, key); |
31
|
1
|
|
|
|
|
|
return HighwayHash64(bytes, size, key); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
|
|
|
AV* highway_hash128(AV *key_av, char *bytes, uint64_t size) { |
35
|
|
|
|
|
|
|
dTHX; |
36
|
|
|
|
|
|
|
AV* result; |
37
|
|
|
|
|
|
|
uint64_t key[4]; |
38
|
|
|
|
|
|
|
uint64_t hash[2]; |
39
|
1
|
|
|
|
|
|
process_key(aTHX_ key_av, key); |
40
|
1
|
|
|
|
|
|
HighwayHash128(bytes, size, key, hash); |
41
|
1
|
|
|
|
|
|
result = newAV(); |
42
|
1
|
|
|
|
|
|
av_push(result, sv_2mortal(newSVu64(hash[0]))); |
43
|
1
|
|
|
|
|
|
av_push(result, sv_2mortal(newSVu64(hash[1]))); |
44
|
1
|
|
|
|
|
|
return result; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
1
|
|
|
|
|
|
AV* highway_hash256(AV *key_av, char *bytes, uint64_t size) { |
48
|
|
|
|
|
|
|
dTHX; |
49
|
|
|
|
|
|
|
AV* result; |
50
|
|
|
|
|
|
|
uint64_t key[4]; |
51
|
|
|
|
|
|
|
uint64_t hash[4]; |
52
|
1
|
|
|
|
|
|
process_key(aTHX_ key_av, key); |
53
|
1
|
|
|
|
|
|
HighwayHash256(bytes, size, key, hash); |
54
|
1
|
|
|
|
|
|
result = newAV(); |
55
|
1
|
|
|
|
|
|
av_push(result, sv_2mortal(newSVu64(hash[0]))); |
56
|
1
|
|
|
|
|
|
av_push(result, sv_2mortal(newSVu64(hash[1]))); |
57
|
1
|
|
|
|
|
|
av_push(result, sv_2mortal(newSVu64(hash[2]))); |
58
|
1
|
|
|
|
|
|
av_push(result, sv_2mortal(newSVu64(hash[3]))); |
59
|
1
|
|
|
|
|
|
return result; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
MODULE = Digest::HighwayHash PACKAGE = Digest::HighwayHash |
63
|
|
|
|
|
|
|
BOOT: |
64
|
1
|
50
|
|
|
|
|
PERL_MATH_INT64_LOAD_OR_CROAK; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
uint64_t highway_hash64(AV *key_av, char *bytes, uint64_t length(bytes)) |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
AV* highway_hash128(AV *key_av, char *bytes, uint64_t length(bytes)) |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
AV* highway_hash256(AV *key_av, char *bytes, uint64_t length(bytes)) |