...
1
2
3
4 package zstd
5
6 import (
7 "fmt"
8 )
9
10 type buildDtableAsmContext struct {
11
12 stateTable *uint16
13 norm *int16
14 dt *uint64
15
16
17
18 errParam1 uint64
19 errParam2 uint64
20 }
21
22
23
24
25
26 func buildDtable_asm(s *fseDecoder, ctx *buildDtableAsmContext) int
27
28
29 const (
30 errorCorruptedNormalizedCounter = 1
31 errorNewStateTooBig = 2
32 errorNewStateNoBits = 3
33 )
34
35
36 func (s *fseDecoder) buildDtable() error {
37 ctx := buildDtableAsmContext{
38 stateTable: &s.stateTable[0],
39 norm: &s.norm[0],
40 dt: (*uint64)(&s.dt[0]),
41 }
42 code := buildDtable_asm(s, &ctx)
43
44 if code != 0 {
45 switch code {
46 case errorCorruptedNormalizedCounter:
47 position := ctx.errParam1
48 return fmt.Errorf("corrupted input (position=%d, expected 0)", position)
49
50 case errorNewStateTooBig:
51 newState := decSymbol(ctx.errParam1)
52 size := ctx.errParam2
53 return fmt.Errorf("newState (%d) outside table size (%d)", newState, size)
54
55 case errorNewStateNoBits:
56 newState := decSymbol(ctx.errParam1)
57 oldState := decSymbol(ctx.errParam2)
58 return fmt.Errorf("newState (%d) == oldState (%d) and no bits", newState, oldState)
59
60 default:
61 return fmt.Errorf("buildDtable_asm returned unhandled nonzero code = %d", code)
62 }
63 }
64 return nil
65 }
66
View as plain text