/*

// Only a few opcodes, and length is 8-byte aligned, so use low bits for opcode.
struct tcmu_cmd_entry_hdr {
  __u32 len_op;
  __u16 cmd_id;
  __u8 kflags;
#define TCMU_UFLAG_UNKNOWN_OP 0x1
  __u8 uflags;

} __packed;
*/
548471
func (d *Device) entHdrOp(off int) tcmuOpcode {
	i := int(*(*uint32)(unsafe.Pointer(&d.mmap[off+offLenOp])))
	i = i & 0x7
	return tcmuOpcode(i)
}
151636
func init() {
	if intIs64 {
		arrayTypeMap[reflect.TypeOf(int(0))] = C.PN_LONG
		arrayTypeMap[reflect.TypeOf(uint(0))] = C.PN_ULONG
	} else {
		arrayTypeMap[reflect.TypeOf(int(0))] = C.PN_INT
		arrayTypeMap[reflect.TypeOf(uint(0))] = C.PN_UINT
	}
}
48994
func toSignedFixedBytes(size uint) func(*big.Int) ([]byte, error) {
	return func(n *big.Int) ([]byte, error) {
		switch n.Sign() {
		case 0:
			return []byte{0}, nil
		case 1:
			b := n.Bytes()
			if b[0]&0x80 > 0 {
				b = append([]byte{0}, b...)
			}
			return padBytes(b, size), nil
		case -1:
			length := size * 8
			b := new(big.Int).Add(n, new(big.Int).Lsh(one, length)).Bytes()
			// Unlike a variable length byte length we need the extra bits to meet byte length
			return b, nil
		}
		return nil, fmt.Errorf("toSignedBytes: error big.Int.Sign() returned unexpected value")
	}
}
755311
func (p *parserMixin) Uint8() (target *uint8) {
	target = new(uint8)
	p.Uint8Var(target)
	return
}
60462
func ParseByteUnit(str string) (uint64, error) {
	str = strings.TrimSpace(str)
	str = strings.ToLower(str)

	if u, ok := bytesTable[str]; ok {
		return u, nil
	}
	return 0, errors.Errorf("unknown unit: %q", str)
}
855835
func (e *Encoder) StructAsArray(flag bool) *Encoder {
	e.structAsArray = flag
	return e
}
737492
func (enc *Encoder) AddUint64KeyOmitEmpty(key string, v uint64) {
	enc.Uint64KeyOmitEmpty(key, v)
}
1289919
func decode(dst, src []byte) int {
	var d, s, offset, length int
	for s < len(src) {
		switch src[s] & 0x03 {
		case tagLiteral:
			x := uint32(src[s] >> 2)
			switch {
			case x < 60:
				s++
			case x == 60:
				s += 2
				if uint(s) > uint(len(src)) { // The uint conversions catch overflow from the previous line.
					return decodeErrCodeCorrupt
				}
				x = uint32(src[s-1])
			case x == 61:
				s += 3
				if uint(s) > uint(len(src)) { // The uint conversions catch overflow from the previous line.
					return decodeErrCodeCorrupt
				}
				x = uint32(src[s-2]) | uint32(src[s-1])<<8
			case x == 62:
				s += 4
				if uint(s) > uint(len(src)) { // The uint conversions catch overflow from the previous line.
					return decodeErrCodeCorrupt
				}
				x = uint32(src[s-3]) | uint32(src[s-2])<<8 | uint32(src[s-1])<<16
			case x == 63:
				s += 5
				if uint(s) > uint(len(src)) { // The uint conversions catch overflow from the previous line.
					return decodeErrCodeCorrupt
				}
				x = uint32(src[s-4]) | uint32(src[s-3])<<8 | uint32(src[s-2])<<16 | uint32(src[s-1])<<24
			}
			length = int(x) + 1
			if length <= 0 {
				return decodeErrCodeUnsupportedLiteralLength
			}
			if length > len(dst)-d || length > len(src)-s {
				return decodeErrCodeCorrupt
			}
			copy(dst[d:], src[s:s+length])
			d += length
			s += length
			continue

		case tagCopy1:
			s += 2
			if uint(s) > uint(len(src)) { // The uint conversions catch overflow from the previous line.
				return decodeErrCodeCorrupt
			}
			length = 4 + int(src[s-2])>>2&0x7
			offset = int(uint32(src[s-2])&0xe0<<3 | uint32(src[s-1]))

		case tagCopy2:
			s += 3
			if uint(s) > uint(len(src)) { // The uint conversions catch overflow from the previous line.
				return decodeErrCodeCorrupt
			}
			length = 1 + int(src[s-3])>>2
			offset = int(uint32(src[s-2]) | uint32(src[s-1])<<8)

		case tagCopy4:
			s += 5
			if uint(s) > uint(len(src)) { // The uint conversions catch overflow from the previous line.
				return decodeErrCodeCorrupt
			}
			length = 1 + int(src[s-5])>>2
			offset = int(uint32(src[s-4]) | uint32(src[s-3])<<8 | uint32(src[s-2])<<16 | uint32(src[s-1])<<24)
		}

		if offset <= 0 || d < offset || length > len(dst)-d {
			return decodeErrCodeCorrupt
		}
		// Copy from an earlier sub-slice of dst to a later sub-slice. Unlike
		// the built-in copy function, this byte-by-byte copy always runs
		// forwards, even if the slices overlap. Conceptually, this is:
		//
		// d += forwardCopy(dst[d:d+length], dst[d-offset:])
		for end := d + length; d != end; d++ {
			dst[d] = dst[d-offset]
		}
	}
	if d != len(dst) {
		return decodeErrCodeCorrupt
	}
	return 0
}
329956
func (s *Statement) Struct(fields ...Code) *Statement {
	g := &Group{
		close:     "}",
		items:     fields,
		multi:     true,
		name:      "struct",
		open:      "struct{",
		separator: "",
	}
	*s = append(*s, g)
	return s
}
1346627
func RegisterCodec(codecs ...Codec) {
	for _, codec := range codecs {
		fmt.Printf("Found codec: %v\n", codec.Name())
		allCodecs[codec.Name()] = codec
	}
}
1250838
func decSymbolValue(symb uint8, t []baseOffset) (decSymbol, error) {
	if int(symb) >= len(t) {
		return decSymbol{}, fmt.Errorf("rle symbol %d >= max %d", symb, len(t))
	}
	lu := t[symb]
	return decSymbol{
		addBits:  lu.addBits,
		baseline: lu.baseLine,
	}, nil
}
872534
func Struct(name string, opts ...FieldOpt) FieldOpt {
	return func(em *eventMetadata, ed *eventData) {
		em.writeStruct(name, uint8(len(opts)), 0)
		for _, opt := range opts {
			opt(em, ed)
		}
	}
}
290604
func fromSignedBytes(n *big.Int, data []byte) {
	n.SetBytes(data)
	if len(data) > 0 && data[0]&0x80 > 0 {
		n.Sub(n, new(big.Int).Lsh(one, uint(len(data))*8))
	}
}
420425
func init() {
	RegisterCharset(&Charset{
		Name:    "EUC-JP",
		Aliases: []string{"extended_unix_code_packed_format_for_japanese", "cseucpkdfmtjapanese"},
		NewDecoder: func() Decoder {
			return decodeEucJP
		},
		NewEncoder: func() Encoder {
			jis0208Table.Reverse()
			jis0212Table.Reverse()
			return encodeEucJP
		},
	})
}
647257
func syscallMode(p PermissionBits) (o uint32) {
	o |= uint32(p)

	if p.Setuid() {
		o |= syscall.S_ISUID
	}
	if p.Setgid() {
		o |= syscall.S_ISGID
	}
	if p.Sticky() {
		o |= syscall.S_ISVTX
	}
	return
}
990626
func structMaxAttrID(v reflect.Value) (uint16, error) {
	if v.Kind() != reflect.Struct {
		return 0, fmt.Errorf("%v is not a struct", v.Type())
	}
	st := v.Type()

	var maxAttrID uint16
	for i := 0; i < st.NumField(); i++ {
		ft, fv := st.Field(i), v.Field(i)
		fp, err := parseFieldParams(ft.Tag.Get("netlink"))
		if err != nil {
			return 0, err
		}
		if fp != nil && fp.attr > maxAttrID {
			maxAttrID = fp.attr
		}
		if fp == nil && fv.Kind() == reflect.Struct {
			attrID, err := structMaxAttrID(fv)
			if err != nil {
				return 0, err
			}
			if attrID > maxAttrID {
				maxAttrID = attrID
			}
		}
	}
	return maxAttrID, nil
}
1154619
func Uint64(b []byte) uint64 {
	if l := len(b); l != 8 {
		panic(fmt.Sprintf("Uint64: unexpected byte slice length: %d", l))
	}

	return *(*uint64)(unsafe.Pointer(&b[0]))
}