-
Notifications
You must be signed in to change notification settings - Fork 6
/
safe.go
39 lines (34 loc) · 900 Bytes
/
safe.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright (c) 2020 Robert Clausecker <[email protected]>
package pospop
// count8 reference implementation for tests. Do not alter.
func count8safe(counts *[8]int, buf []uint8) {
for i := range buf {
for j := 0; j < 8; j++ {
counts[j] += int(buf[i] >> j & 1)
}
}
}
// count16 reference implementation for tests. Do not alter.
func count16safe(counts *[16]int, buf []uint16) {
for i := range buf {
for j := 0; j < 16; j++ {
counts[j] += int(buf[i] >> j & 1)
}
}
}
// count32 reference implementation for tests. Do not alter.
func count32safe(counts *[32]int, buf []uint32) {
for i := range buf {
for j := 0; j < 32; j++ {
counts[j] += int(buf[i] >> j & 1)
}
}
}
// count64 reference implementation for tests. Do not alter.
func count64safe(counts *[64]int, buf []uint64) {
for i := range buf {
for j := 0; j < 64; j++ {
counts[j] += int(buf[i] >> j & 1)
}
}
}