1
2
3
4
5 package ir
6
7 type bitset8 uint8
8
9 func (f *bitset8) set(mask uint8, b bool) {
10 if b {
11 *(*uint8)(f) |= mask
12 } else {
13 *(*uint8)(f) &^= mask
14 }
15 }
16
17 func (f bitset8) get2(shift uint8) uint8 {
18 return uint8(f>>shift) & 3
19 }
20
21
22 func (f *bitset8) set2(shift uint8, b uint8) {
23
24 *(*uint8)(f) &^= 3 << shift
25
26 *(*uint8)(f) |= uint8(b&3) << shift
27 }
28
29 type bitset16 uint16
30
31 func (f *bitset16) set(mask uint16, b bool) {
32 if b {
33 *(*uint16)(f) |= mask
34 } else {
35 *(*uint16)(f) &^= mask
36 }
37 }
38
View as plain text