text
stringlengths 2
1.1M
| id
stringlengths 11
117
| metadata
dict | __index_level_0__
int64 0
885
|
---|---|---|---|
// Code generated from _gen/dec64.rules using 'go generate'; DO NOT EDIT.
package ssa
import "cmd/compile/internal/types"
func rewriteValuedec64(v *Value) bool {
switch v.Op {
case OpAdd64:
return rewriteValuedec64_OpAdd64(v)
case OpAnd64:
return rewriteValuedec64_OpAnd64(v)
case OpArg:
return rewriteValuedec64_OpArg(v)
case OpBitLen64:
return rewriteValuedec64_OpBitLen64(v)
case OpBswap64:
return rewriteValuedec64_OpBswap64(v)
case OpCom64:
return rewriteValuedec64_OpCom64(v)
case OpConst64:
return rewriteValuedec64_OpConst64(v)
case OpCtz64:
return rewriteValuedec64_OpCtz64(v)
case OpCtz64NonZero:
v.Op = OpCtz64
return true
case OpEq64:
return rewriteValuedec64_OpEq64(v)
case OpInt64Hi:
return rewriteValuedec64_OpInt64Hi(v)
case OpInt64Lo:
return rewriteValuedec64_OpInt64Lo(v)
case OpLeq64:
return rewriteValuedec64_OpLeq64(v)
case OpLeq64U:
return rewriteValuedec64_OpLeq64U(v)
case OpLess64:
return rewriteValuedec64_OpLess64(v)
case OpLess64U:
return rewriteValuedec64_OpLess64U(v)
case OpLoad:
return rewriteValuedec64_OpLoad(v)
case OpLsh16x64:
return rewriteValuedec64_OpLsh16x64(v)
case OpLsh32x64:
return rewriteValuedec64_OpLsh32x64(v)
case OpLsh64x16:
return rewriteValuedec64_OpLsh64x16(v)
case OpLsh64x32:
return rewriteValuedec64_OpLsh64x32(v)
case OpLsh64x64:
return rewriteValuedec64_OpLsh64x64(v)
case OpLsh64x8:
return rewriteValuedec64_OpLsh64x8(v)
case OpLsh8x64:
return rewriteValuedec64_OpLsh8x64(v)
case OpMul64:
return rewriteValuedec64_OpMul64(v)
case OpNeg64:
return rewriteValuedec64_OpNeg64(v)
case OpNeq64:
return rewriteValuedec64_OpNeq64(v)
case OpOr32:
return rewriteValuedec64_OpOr32(v)
case OpOr64:
return rewriteValuedec64_OpOr64(v)
case OpRotateLeft16:
return rewriteValuedec64_OpRotateLeft16(v)
case OpRotateLeft32:
return rewriteValuedec64_OpRotateLeft32(v)
case OpRotateLeft64:
return rewriteValuedec64_OpRotateLeft64(v)
case OpRotateLeft8:
return rewriteValuedec64_OpRotateLeft8(v)
case OpRsh16Ux64:
return rewriteValuedec64_OpRsh16Ux64(v)
case OpRsh16x64:
return rewriteValuedec64_OpRsh16x64(v)
case OpRsh32Ux64:
return rewriteValuedec64_OpRsh32Ux64(v)
case OpRsh32x64:
return rewriteValuedec64_OpRsh32x64(v)
case OpRsh64Ux16:
return rewriteValuedec64_OpRsh64Ux16(v)
case OpRsh64Ux32:
return rewriteValuedec64_OpRsh64Ux32(v)
case OpRsh64Ux64:
return rewriteValuedec64_OpRsh64Ux64(v)
case OpRsh64Ux8:
return rewriteValuedec64_OpRsh64Ux8(v)
case OpRsh64x16:
return rewriteValuedec64_OpRsh64x16(v)
case OpRsh64x32:
return rewriteValuedec64_OpRsh64x32(v)
case OpRsh64x64:
return rewriteValuedec64_OpRsh64x64(v)
case OpRsh64x8:
return rewriteValuedec64_OpRsh64x8(v)
case OpRsh8Ux64:
return rewriteValuedec64_OpRsh8Ux64(v)
case OpRsh8x64:
return rewriteValuedec64_OpRsh8x64(v)
case OpSignExt16to64:
return rewriteValuedec64_OpSignExt16to64(v)
case OpSignExt32to64:
return rewriteValuedec64_OpSignExt32to64(v)
case OpSignExt8to64:
return rewriteValuedec64_OpSignExt8to64(v)
case OpStore:
return rewriteValuedec64_OpStore(v)
case OpSub64:
return rewriteValuedec64_OpSub64(v)
case OpTrunc64to16:
return rewriteValuedec64_OpTrunc64to16(v)
case OpTrunc64to32:
return rewriteValuedec64_OpTrunc64to32(v)
case OpTrunc64to8:
return rewriteValuedec64_OpTrunc64to8(v)
case OpXor64:
return rewriteValuedec64_OpXor64(v)
case OpZeroExt16to64:
return rewriteValuedec64_OpZeroExt16to64(v)
case OpZeroExt32to64:
return rewriteValuedec64_OpZeroExt32to64(v)
case OpZeroExt8to64:
return rewriteValuedec64_OpZeroExt8to64(v)
}
return false
}
func rewriteValuedec64_OpAdd64(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Add64 x y)
// result: (Int64Make (Add32withcarry <typ.Int32> (Int64Hi x) (Int64Hi y) (Select1 <types.TypeFlags> (Add32carry (Int64Lo x) (Int64Lo y)))) (Select0 <typ.UInt32> (Add32carry (Int64Lo x) (Int64Lo y))))
for {
x := v_0
y := v_1
v.reset(OpInt64Make)
v0 := b.NewValue0(v.Pos, OpAdd32withcarry, typ.Int32)
v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v1.AddArg(x)
v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v2.AddArg(y)
v3 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags)
v4 := b.NewValue0(v.Pos, OpAdd32carry, types.NewTuple(typ.UInt32, types.TypeFlags))
v5 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v5.AddArg(x)
v6 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v6.AddArg(y)
v4.AddArg2(v5, v6)
v3.AddArg(v4)
v0.AddArg3(v1, v2, v3)
v7 := b.NewValue0(v.Pos, OpSelect0, typ.UInt32)
v7.AddArg(v4)
v.AddArg2(v0, v7)
return true
}
}
func rewriteValuedec64_OpAnd64(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (And64 x y)
// result: (Int64Make (And32 <typ.UInt32> (Int64Hi x) (Int64Hi y)) (And32 <typ.UInt32> (Int64Lo x) (Int64Lo y)))
for {
x := v_0
y := v_1
v.reset(OpInt64Make)
v0 := b.NewValue0(v.Pos, OpAnd32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v1.AddArg(x)
v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v2.AddArg(y)
v0.AddArg2(v1, v2)
v3 := b.NewValue0(v.Pos, OpAnd32, typ.UInt32)
v4 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v4.AddArg(x)
v5 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v5.AddArg(y)
v3.AddArg2(v4, v5)
v.AddArg2(v0, v3)
return true
}
}
func rewriteValuedec64_OpArg(v *Value) bool {
b := v.Block
config := b.Func.Config
typ := &b.Func.Config.Types
// match: (Arg {n} [off])
// cond: is64BitInt(v.Type) && !config.BigEndian && v.Type.IsSigned() && !(b.Func.pass.name == "decompose builtin")
// result: (Int64Make (Arg <typ.Int32> {n} [off+4]) (Arg <typ.UInt32> {n} [off]))
for {
off := auxIntToInt32(v.AuxInt)
n := auxToSym(v.Aux)
if !(is64BitInt(v.Type) && !config.BigEndian && v.Type.IsSigned() && !(b.Func.pass.name == "decompose builtin")) {
break
}
v.reset(OpInt64Make)
v0 := b.NewValue0(v.Pos, OpArg, typ.Int32)
v0.AuxInt = int32ToAuxInt(off + 4)
v0.Aux = symToAux(n)
v1 := b.NewValue0(v.Pos, OpArg, typ.UInt32)
v1.AuxInt = int32ToAuxInt(off)
v1.Aux = symToAux(n)
v.AddArg2(v0, v1)
return true
}
// match: (Arg {n} [off])
// cond: is64BitInt(v.Type) && !config.BigEndian && !v.Type.IsSigned() && !(b.Func.pass.name == "decompose builtin")
// result: (Int64Make (Arg <typ.UInt32> {n} [off+4]) (Arg <typ.UInt32> {n} [off]))
for {
off := auxIntToInt32(v.AuxInt)
n := auxToSym(v.Aux)
if !(is64BitInt(v.Type) && !config.BigEndian && !v.Type.IsSigned() && !(b.Func.pass.name == "decompose builtin")) {
break
}
v.reset(OpInt64Make)
v0 := b.NewValue0(v.Pos, OpArg, typ.UInt32)
v0.AuxInt = int32ToAuxInt(off + 4)
v0.Aux = symToAux(n)
v1 := b.NewValue0(v.Pos, OpArg, typ.UInt32)
v1.AuxInt = int32ToAuxInt(off)
v1.Aux = symToAux(n)
v.AddArg2(v0, v1)
return true
}
// match: (Arg {n} [off])
// cond: is64BitInt(v.Type) && config.BigEndian && v.Type.IsSigned() && !(b.Func.pass.name == "decompose builtin")
// result: (Int64Make (Arg <typ.Int32> {n} [off]) (Arg <typ.UInt32> {n} [off+4]))
for {
off := auxIntToInt32(v.AuxInt)
n := auxToSym(v.Aux)
if !(is64BitInt(v.Type) && config.BigEndian && v.Type.IsSigned() && !(b.Func.pass.name == "decompose builtin")) {
break
}
v.reset(OpInt64Make)
v0 := b.NewValue0(v.Pos, OpArg, typ.Int32)
v0.AuxInt = int32ToAuxInt(off)
v0.Aux = symToAux(n)
v1 := b.NewValue0(v.Pos, OpArg, typ.UInt32)
v1.AuxInt = int32ToAuxInt(off + 4)
v1.Aux = symToAux(n)
v.AddArg2(v0, v1)
return true
}
// match: (Arg {n} [off])
// cond: is64BitInt(v.Type) && config.BigEndian && !v.Type.IsSigned() && !(b.Func.pass.name == "decompose builtin")
// result: (Int64Make (Arg <typ.UInt32> {n} [off]) (Arg <typ.UInt32> {n} [off+4]))
for {
off := auxIntToInt32(v.AuxInt)
n := auxToSym(v.Aux)
if !(is64BitInt(v.Type) && config.BigEndian && !v.Type.IsSigned() && !(b.Func.pass.name == "decompose builtin")) {
break
}
v.reset(OpInt64Make)
v0 := b.NewValue0(v.Pos, OpArg, typ.UInt32)
v0.AuxInt = int32ToAuxInt(off)
v0.Aux = symToAux(n)
v1 := b.NewValue0(v.Pos, OpArg, typ.UInt32)
v1.AuxInt = int32ToAuxInt(off + 4)
v1.Aux = symToAux(n)
v.AddArg2(v0, v1)
return true
}
return false
}
func rewriteValuedec64_OpBitLen64(v *Value) bool {
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (BitLen64 x)
// result: (Add32 <typ.Int> (BitLen32 <typ.Int> (Int64Hi x)) (BitLen32 <typ.Int> (Or32 <typ.UInt32> (Int64Lo x) (Zeromask (Int64Hi x)))))
for {
x := v_0
v.reset(OpAdd32)
v.Type = typ.Int
v0 := b.NewValue0(v.Pos, OpBitLen32, typ.Int)
v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v1.AddArg(x)
v0.AddArg(v1)
v2 := b.NewValue0(v.Pos, OpBitLen32, typ.Int)
v3 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v4 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v4.AddArg(x)
v5 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32)
v5.AddArg(v1)
v3.AddArg2(v4, v5)
v2.AddArg(v3)
v.AddArg2(v0, v2)
return true
}
}
func rewriteValuedec64_OpBswap64(v *Value) bool {
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Bswap64 x)
// result: (Int64Make (Bswap32 <typ.UInt32> (Int64Lo x)) (Bswap32 <typ.UInt32> (Int64Hi x)))
for {
x := v_0
v.reset(OpInt64Make)
v0 := b.NewValue0(v.Pos, OpBswap32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v1.AddArg(x)
v0.AddArg(v1)
v2 := b.NewValue0(v.Pos, OpBswap32, typ.UInt32)
v3 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v3.AddArg(x)
v2.AddArg(v3)
v.AddArg2(v0, v2)
return true
}
}
func rewriteValuedec64_OpCom64(v *Value) bool {
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Com64 x)
// result: (Int64Make (Com32 <typ.UInt32> (Int64Hi x)) (Com32 <typ.UInt32> (Int64Lo x)))
for {
x := v_0
v.reset(OpInt64Make)
v0 := b.NewValue0(v.Pos, OpCom32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v1.AddArg(x)
v0.AddArg(v1)
v2 := b.NewValue0(v.Pos, OpCom32, typ.UInt32)
v3 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v3.AddArg(x)
v2.AddArg(v3)
v.AddArg2(v0, v2)
return true
}
}
func rewriteValuedec64_OpConst64(v *Value) bool {
b := v.Block
typ := &b.Func.Config.Types
// match: (Const64 <t> [c])
// cond: t.IsSigned()
// result: (Int64Make (Const32 <typ.Int32> [int32(c>>32)]) (Const32 <typ.UInt32> [int32(c)]))
for {
t := v.Type
c := auxIntToInt64(v.AuxInt)
if !(t.IsSigned()) {
break
}
v.reset(OpInt64Make)
v0 := b.NewValue0(v.Pos, OpConst32, typ.Int32)
v0.AuxInt = int32ToAuxInt(int32(c >> 32))
v1 := b.NewValue0(v.Pos, OpConst32, typ.UInt32)
v1.AuxInt = int32ToAuxInt(int32(c))
v.AddArg2(v0, v1)
return true
}
// match: (Const64 <t> [c])
// cond: !t.IsSigned()
// result: (Int64Make (Const32 <typ.UInt32> [int32(c>>32)]) (Const32 <typ.UInt32> [int32(c)]))
for {
t := v.Type
c := auxIntToInt64(v.AuxInt)
if !(!t.IsSigned()) {
break
}
v.reset(OpInt64Make)
v0 := b.NewValue0(v.Pos, OpConst32, typ.UInt32)
v0.AuxInt = int32ToAuxInt(int32(c >> 32))
v1 := b.NewValue0(v.Pos, OpConst32, typ.UInt32)
v1.AuxInt = int32ToAuxInt(int32(c))
v.AddArg2(v0, v1)
return true
}
return false
}
func rewriteValuedec64_OpCtz64(v *Value) bool {
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Ctz64 x)
// result: (Add32 <typ.UInt32> (Ctz32 <typ.UInt32> (Int64Lo x)) (And32 <typ.UInt32> (Com32 <typ.UInt32> (Zeromask (Int64Lo x))) (Ctz32 <typ.UInt32> (Int64Hi x))))
for {
x := v_0
v.reset(OpAdd32)
v.Type = typ.UInt32
v0 := b.NewValue0(v.Pos, OpCtz32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v1.AddArg(x)
v0.AddArg(v1)
v2 := b.NewValue0(v.Pos, OpAnd32, typ.UInt32)
v3 := b.NewValue0(v.Pos, OpCom32, typ.UInt32)
v4 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32)
v4.AddArg(v1)
v3.AddArg(v4)
v5 := b.NewValue0(v.Pos, OpCtz32, typ.UInt32)
v6 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v6.AddArg(x)
v5.AddArg(v6)
v2.AddArg2(v3, v5)
v.AddArg2(v0, v2)
return true
}
}
func rewriteValuedec64_OpEq64(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Eq64 x y)
// result: (AndB (Eq32 (Int64Hi x) (Int64Hi y)) (Eq32 (Int64Lo x) (Int64Lo y)))
for {
x := v_0
y := v_1
v.reset(OpAndB)
v0 := b.NewValue0(v.Pos, OpEq32, typ.Bool)
v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v1.AddArg(x)
v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v2.AddArg(y)
v0.AddArg2(v1, v2)
v3 := b.NewValue0(v.Pos, OpEq32, typ.Bool)
v4 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v4.AddArg(x)
v5 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v5.AddArg(y)
v3.AddArg2(v4, v5)
v.AddArg2(v0, v3)
return true
}
}
func rewriteValuedec64_OpInt64Hi(v *Value) bool {
v_0 := v.Args[0]
// match: (Int64Hi (Int64Make hi _))
// result: hi
for {
if v_0.Op != OpInt64Make {
break
}
hi := v_0.Args[0]
v.copyOf(hi)
return true
}
return false
}
func rewriteValuedec64_OpInt64Lo(v *Value) bool {
v_0 := v.Args[0]
// match: (Int64Lo (Int64Make _ lo))
// result: lo
for {
if v_0.Op != OpInt64Make {
break
}
lo := v_0.Args[1]
v.copyOf(lo)
return true
}
return false
}
func rewriteValuedec64_OpLeq64(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Leq64 x y)
// result: (OrB (Less32 (Int64Hi x) (Int64Hi y)) (AndB (Eq32 (Int64Hi x) (Int64Hi y)) (Leq32U (Int64Lo x) (Int64Lo y))))
for {
x := v_0
y := v_1
v.reset(OpOrB)
v0 := b.NewValue0(v.Pos, OpLess32, typ.Bool)
v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v1.AddArg(x)
v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v2.AddArg(y)
v0.AddArg2(v1, v2)
v3 := b.NewValue0(v.Pos, OpAndB, typ.Bool)
v4 := b.NewValue0(v.Pos, OpEq32, typ.Bool)
v4.AddArg2(v1, v2)
v5 := b.NewValue0(v.Pos, OpLeq32U, typ.Bool)
v6 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v6.AddArg(x)
v7 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v7.AddArg(y)
v5.AddArg2(v6, v7)
v3.AddArg2(v4, v5)
v.AddArg2(v0, v3)
return true
}
}
func rewriteValuedec64_OpLeq64U(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Leq64U x y)
// result: (OrB (Less32U (Int64Hi x) (Int64Hi y)) (AndB (Eq32 (Int64Hi x) (Int64Hi y)) (Leq32U (Int64Lo x) (Int64Lo y))))
for {
x := v_0
y := v_1
v.reset(OpOrB)
v0 := b.NewValue0(v.Pos, OpLess32U, typ.Bool)
v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v1.AddArg(x)
v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v2.AddArg(y)
v0.AddArg2(v1, v2)
v3 := b.NewValue0(v.Pos, OpAndB, typ.Bool)
v4 := b.NewValue0(v.Pos, OpEq32, typ.Bool)
v4.AddArg2(v1, v2)
v5 := b.NewValue0(v.Pos, OpLeq32U, typ.Bool)
v6 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v6.AddArg(x)
v7 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v7.AddArg(y)
v5.AddArg2(v6, v7)
v3.AddArg2(v4, v5)
v.AddArg2(v0, v3)
return true
}
}
func rewriteValuedec64_OpLess64(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Less64 x y)
// result: (OrB (Less32 (Int64Hi x) (Int64Hi y)) (AndB (Eq32 (Int64Hi x) (Int64Hi y)) (Less32U (Int64Lo x) (Int64Lo y))))
for {
x := v_0
y := v_1
v.reset(OpOrB)
v0 := b.NewValue0(v.Pos, OpLess32, typ.Bool)
v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v1.AddArg(x)
v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v2.AddArg(y)
v0.AddArg2(v1, v2)
v3 := b.NewValue0(v.Pos, OpAndB, typ.Bool)
v4 := b.NewValue0(v.Pos, OpEq32, typ.Bool)
v4.AddArg2(v1, v2)
v5 := b.NewValue0(v.Pos, OpLess32U, typ.Bool)
v6 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v6.AddArg(x)
v7 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v7.AddArg(y)
v5.AddArg2(v6, v7)
v3.AddArg2(v4, v5)
v.AddArg2(v0, v3)
return true
}
}
func rewriteValuedec64_OpLess64U(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Less64U x y)
// result: (OrB (Less32U (Int64Hi x) (Int64Hi y)) (AndB (Eq32 (Int64Hi x) (Int64Hi y)) (Less32U (Int64Lo x) (Int64Lo y))))
for {
x := v_0
y := v_1
v.reset(OpOrB)
v0 := b.NewValue0(v.Pos, OpLess32U, typ.Bool)
v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v1.AddArg(x)
v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v2.AddArg(y)
v0.AddArg2(v1, v2)
v3 := b.NewValue0(v.Pos, OpAndB, typ.Bool)
v4 := b.NewValue0(v.Pos, OpEq32, typ.Bool)
v4.AddArg2(v1, v2)
v5 := b.NewValue0(v.Pos, OpLess32U, typ.Bool)
v6 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v6.AddArg(x)
v7 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v7.AddArg(y)
v5.AddArg2(v6, v7)
v3.AddArg2(v4, v5)
v.AddArg2(v0, v3)
return true
}
}
func rewriteValuedec64_OpLoad(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
config := b.Func.Config
typ := &b.Func.Config.Types
// match: (Load <t> ptr mem)
// cond: is64BitInt(t) && !config.BigEndian && t.IsSigned()
// result: (Int64Make (Load <typ.Int32> (OffPtr <typ.Int32Ptr> [4] ptr) mem) (Load <typ.UInt32> ptr mem))
for {
t := v.Type
ptr := v_0
mem := v_1
if !(is64BitInt(t) && !config.BigEndian && t.IsSigned()) {
break
}
v.reset(OpInt64Make)
v0 := b.NewValue0(v.Pos, OpLoad, typ.Int32)
v1 := b.NewValue0(v.Pos, OpOffPtr, typ.Int32Ptr)
v1.AuxInt = int64ToAuxInt(4)
v1.AddArg(ptr)
v0.AddArg2(v1, mem)
v2 := b.NewValue0(v.Pos, OpLoad, typ.UInt32)
v2.AddArg2(ptr, mem)
v.AddArg2(v0, v2)
return true
}
// match: (Load <t> ptr mem)
// cond: is64BitInt(t) && !config.BigEndian && !t.IsSigned()
// result: (Int64Make (Load <typ.UInt32> (OffPtr <typ.UInt32Ptr> [4] ptr) mem) (Load <typ.UInt32> ptr mem))
for {
t := v.Type
ptr := v_0
mem := v_1
if !(is64BitInt(t) && !config.BigEndian && !t.IsSigned()) {
break
}
v.reset(OpInt64Make)
v0 := b.NewValue0(v.Pos, OpLoad, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpOffPtr, typ.UInt32Ptr)
v1.AuxInt = int64ToAuxInt(4)
v1.AddArg(ptr)
v0.AddArg2(v1, mem)
v2 := b.NewValue0(v.Pos, OpLoad, typ.UInt32)
v2.AddArg2(ptr, mem)
v.AddArg2(v0, v2)
return true
}
// match: (Load <t> ptr mem)
// cond: is64BitInt(t) && config.BigEndian && t.IsSigned()
// result: (Int64Make (Load <typ.Int32> ptr mem) (Load <typ.UInt32> (OffPtr <typ.UInt32Ptr> [4] ptr) mem))
for {
t := v.Type
ptr := v_0
mem := v_1
if !(is64BitInt(t) && config.BigEndian && t.IsSigned()) {
break
}
v.reset(OpInt64Make)
v0 := b.NewValue0(v.Pos, OpLoad, typ.Int32)
v0.AddArg2(ptr, mem)
v1 := b.NewValue0(v.Pos, OpLoad, typ.UInt32)
v2 := b.NewValue0(v.Pos, OpOffPtr, typ.UInt32Ptr)
v2.AuxInt = int64ToAuxInt(4)
v2.AddArg(ptr)
v1.AddArg2(v2, mem)
v.AddArg2(v0, v1)
return true
}
// match: (Load <t> ptr mem)
// cond: is64BitInt(t) && config.BigEndian && !t.IsSigned()
// result: (Int64Make (Load <typ.UInt32> ptr mem) (Load <typ.UInt32> (OffPtr <typ.UInt32Ptr> [4] ptr) mem))
for {
t := v.Type
ptr := v_0
mem := v_1
if !(is64BitInt(t) && config.BigEndian && !t.IsSigned()) {
break
}
v.reset(OpInt64Make)
v0 := b.NewValue0(v.Pos, OpLoad, typ.UInt32)
v0.AddArg2(ptr, mem)
v1 := b.NewValue0(v.Pos, OpLoad, typ.UInt32)
v2 := b.NewValue0(v.Pos, OpOffPtr, typ.UInt32Ptr)
v2.AuxInt = int64ToAuxInt(4)
v2.AddArg(ptr)
v1.AddArg2(v2, mem)
v.AddArg2(v0, v1)
return true
}
return false
}
func rewriteValuedec64_OpLsh16x64(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Lsh16x64 _ (Int64Make (Const32 [c]) _))
// cond: c != 0
// result: (Const32 [0])
for {
if v_1.Op != OpInt64Make {
break
}
v_1_0 := v_1.Args[0]
if v_1_0.Op != OpConst32 {
break
}
c := auxIntToInt32(v_1_0.AuxInt)
if !(c != 0) {
break
}
v.reset(OpConst32)
v.AuxInt = int32ToAuxInt(0)
return true
}
// match: (Lsh16x64 [c] x (Int64Make (Const32 [0]) lo))
// result: (Lsh16x32 [c] x lo)
for {
c := auxIntToBool(v.AuxInt)
x := v_0
if v_1.Op != OpInt64Make {
break
}
lo := v_1.Args[1]
v_1_0 := v_1.Args[0]
if v_1_0.Op != OpConst32 || auxIntToInt32(v_1_0.AuxInt) != 0 {
break
}
v.reset(OpLsh16x32)
v.AuxInt = boolToAuxInt(c)
v.AddArg2(x, lo)
return true
}
// match: (Lsh16x64 x (Int64Make hi lo))
// cond: hi.Op != OpConst32
// result: (Lsh16x32 x (Or32 <typ.UInt32> (Zeromask hi) lo))
for {
x := v_0
if v_1.Op != OpInt64Make {
break
}
lo := v_1.Args[1]
hi := v_1.Args[0]
if !(hi.Op != OpConst32) {
break
}
v.reset(OpLsh16x32)
v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32)
v1.AddArg(hi)
v0.AddArg2(v1, lo)
v.AddArg2(x, v0)
return true
}
// match: (Lsh16x64 x y)
// result: (Lsh16x32 x (Or32 <typ.UInt32> (Zeromask (Int64Hi y)) (Int64Lo y)))
for {
x := v_0
y := v_1
v.reset(OpLsh16x32)
v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32)
v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v2.AddArg(y)
v1.AddArg(v2)
v3 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v3.AddArg(y)
v0.AddArg2(v1, v3)
v.AddArg2(x, v0)
return true
}
}
func rewriteValuedec64_OpLsh32x64(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Lsh32x64 _ (Int64Make (Const32 [c]) _))
// cond: c != 0
// result: (Const32 [0])
for {
if v_1.Op != OpInt64Make {
break
}
v_1_0 := v_1.Args[0]
if v_1_0.Op != OpConst32 {
break
}
c := auxIntToInt32(v_1_0.AuxInt)
if !(c != 0) {
break
}
v.reset(OpConst32)
v.AuxInt = int32ToAuxInt(0)
return true
}
// match: (Lsh32x64 [c] x (Int64Make (Const32 [0]) lo))
// result: (Lsh32x32 [c] x lo)
for {
c := auxIntToBool(v.AuxInt)
x := v_0
if v_1.Op != OpInt64Make {
break
}
lo := v_1.Args[1]
v_1_0 := v_1.Args[0]
if v_1_0.Op != OpConst32 || auxIntToInt32(v_1_0.AuxInt) != 0 {
break
}
v.reset(OpLsh32x32)
v.AuxInt = boolToAuxInt(c)
v.AddArg2(x, lo)
return true
}
// match: (Lsh32x64 x (Int64Make hi lo))
// cond: hi.Op != OpConst32
// result: (Lsh32x32 x (Or32 <typ.UInt32> (Zeromask hi) lo))
for {
x := v_0
if v_1.Op != OpInt64Make {
break
}
lo := v_1.Args[1]
hi := v_1.Args[0]
if !(hi.Op != OpConst32) {
break
}
v.reset(OpLsh32x32)
v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32)
v1.AddArg(hi)
v0.AddArg2(v1, lo)
v.AddArg2(x, v0)
return true
}
// match: (Lsh32x64 x y)
// result: (Lsh32x32 x (Or32 <typ.UInt32> (Zeromask (Int64Hi y)) (Int64Lo y)))
for {
x := v_0
y := v_1
v.reset(OpLsh32x32)
v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32)
v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v2.AddArg(y)
v1.AddArg(v2)
v3 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v3.AddArg(y)
v0.AddArg2(v1, v3)
v.AddArg2(x, v0)
return true
}
}
func rewriteValuedec64_OpLsh64x16(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Lsh64x16 x s)
// result: (Int64Make (Or32 <typ.UInt32> (Or32 <typ.UInt32> (Lsh32x16 <typ.UInt32> (Int64Hi x) s) (Rsh32Ux16 <typ.UInt32> (Int64Lo x) (Sub16 <typ.UInt16> (Const16 <typ.UInt16> [32]) s))) (Lsh32x16 <typ.UInt32> (Int64Lo x) (Sub16 <typ.UInt16> s (Const16 <typ.UInt16> [32])))) (Lsh32x16 <typ.UInt32> (Int64Lo x) s))
for {
x := v_0
s := v_1
v.reset(OpInt64Make)
v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v2 := b.NewValue0(v.Pos, OpLsh32x16, typ.UInt32)
v3 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v3.AddArg(x)
v2.AddArg2(v3, s)
v4 := b.NewValue0(v.Pos, OpRsh32Ux16, typ.UInt32)
v5 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v5.AddArg(x)
v6 := b.NewValue0(v.Pos, OpSub16, typ.UInt16)
v7 := b.NewValue0(v.Pos, OpConst16, typ.UInt16)
v7.AuxInt = int16ToAuxInt(32)
v6.AddArg2(v7, s)
v4.AddArg2(v5, v6)
v1.AddArg2(v2, v4)
v8 := b.NewValue0(v.Pos, OpLsh32x16, typ.UInt32)
v9 := b.NewValue0(v.Pos, OpSub16, typ.UInt16)
v9.AddArg2(s, v7)
v8.AddArg2(v5, v9)
v0.AddArg2(v1, v8)
v10 := b.NewValue0(v.Pos, OpLsh32x16, typ.UInt32)
v10.AddArg2(v5, s)
v.AddArg2(v0, v10)
return true
}
}
func rewriteValuedec64_OpLsh64x32(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Lsh64x32 x s)
// result: (Int64Make (Or32 <typ.UInt32> (Or32 <typ.UInt32> (Lsh32x32 <typ.UInt32> (Int64Hi x) s) (Rsh32Ux32 <typ.UInt32> (Int64Lo x) (Sub32 <typ.UInt32> (Const32 <typ.UInt32> [32]) s))) (Lsh32x32 <typ.UInt32> (Int64Lo x) (Sub32 <typ.UInt32> s (Const32 <typ.UInt32> [32])))) (Lsh32x32 <typ.UInt32> (Int64Lo x) s))
for {
x := v_0
s := v_1
v.reset(OpInt64Make)
v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v2 := b.NewValue0(v.Pos, OpLsh32x32, typ.UInt32)
v3 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v3.AddArg(x)
v2.AddArg2(v3, s)
v4 := b.NewValue0(v.Pos, OpRsh32Ux32, typ.UInt32)
v5 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v5.AddArg(x)
v6 := b.NewValue0(v.Pos, OpSub32, typ.UInt32)
v7 := b.NewValue0(v.Pos, OpConst32, typ.UInt32)
v7.AuxInt = int32ToAuxInt(32)
v6.AddArg2(v7, s)
v4.AddArg2(v5, v6)
v1.AddArg2(v2, v4)
v8 := b.NewValue0(v.Pos, OpLsh32x32, typ.UInt32)
v9 := b.NewValue0(v.Pos, OpSub32, typ.UInt32)
v9.AddArg2(s, v7)
v8.AddArg2(v5, v9)
v0.AddArg2(v1, v8)
v10 := b.NewValue0(v.Pos, OpLsh32x32, typ.UInt32)
v10.AddArg2(v5, s)
v.AddArg2(v0, v10)
return true
}
}
func rewriteValuedec64_OpLsh64x64(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Lsh64x64 _ (Int64Make (Const32 [c]) _))
// cond: c != 0
// result: (Const64 [0])
for {
if v_1.Op != OpInt64Make {
break
}
v_1_0 := v_1.Args[0]
if v_1_0.Op != OpConst32 {
break
}
c := auxIntToInt32(v_1_0.AuxInt)
if !(c != 0) {
break
}
v.reset(OpConst64)
v.AuxInt = int64ToAuxInt(0)
return true
}
// match: (Lsh64x64 [c] x (Int64Make (Const32 [0]) lo))
// result: (Lsh64x32 [c] x lo)
for {
c := auxIntToBool(v.AuxInt)
x := v_0
if v_1.Op != OpInt64Make {
break
}
lo := v_1.Args[1]
v_1_0 := v_1.Args[0]
if v_1_0.Op != OpConst32 || auxIntToInt32(v_1_0.AuxInt) != 0 {
break
}
v.reset(OpLsh64x32)
v.AuxInt = boolToAuxInt(c)
v.AddArg2(x, lo)
return true
}
// match: (Lsh64x64 x (Int64Make hi lo))
// cond: hi.Op != OpConst32
// result: (Lsh64x32 x (Or32 <typ.UInt32> (Zeromask hi) lo))
for {
x := v_0
if v_1.Op != OpInt64Make {
break
}
lo := v_1.Args[1]
hi := v_1.Args[0]
if !(hi.Op != OpConst32) {
break
}
v.reset(OpLsh64x32)
v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32)
v1.AddArg(hi)
v0.AddArg2(v1, lo)
v.AddArg2(x, v0)
return true
}
// match: (Lsh64x64 x y)
// result: (Lsh64x32 x (Or32 <typ.UInt32> (Zeromask (Int64Hi y)) (Int64Lo y)))
for {
x := v_0
y := v_1
v.reset(OpLsh64x32)
v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32)
v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v2.AddArg(y)
v1.AddArg(v2)
v3 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v3.AddArg(y)
v0.AddArg2(v1, v3)
v.AddArg2(x, v0)
return true
}
}
func rewriteValuedec64_OpLsh64x8(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Lsh64x8 x s)
// result: (Int64Make (Or32 <typ.UInt32> (Or32 <typ.UInt32> (Lsh32x8 <typ.UInt32> (Int64Hi x) s) (Rsh32Ux8 <typ.UInt32> (Int64Lo x) (Sub8 <typ.UInt8> (Const8 <typ.UInt8> [32]) s))) (Lsh32x8 <typ.UInt32> (Int64Lo x) (Sub8 <typ.UInt8> s (Const8 <typ.UInt8> [32])))) (Lsh32x8 <typ.UInt32> (Int64Lo x) s))
for {
x := v_0
s := v_1
v.reset(OpInt64Make)
v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v2 := b.NewValue0(v.Pos, OpLsh32x8, typ.UInt32)
v3 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v3.AddArg(x)
v2.AddArg2(v3, s)
v4 := b.NewValue0(v.Pos, OpRsh32Ux8, typ.UInt32)
v5 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v5.AddArg(x)
v6 := b.NewValue0(v.Pos, OpSub8, typ.UInt8)
v7 := b.NewValue0(v.Pos, OpConst8, typ.UInt8)
v7.AuxInt = int8ToAuxInt(32)
v6.AddArg2(v7, s)
v4.AddArg2(v5, v6)
v1.AddArg2(v2, v4)
v8 := b.NewValue0(v.Pos, OpLsh32x8, typ.UInt32)
v9 := b.NewValue0(v.Pos, OpSub8, typ.UInt8)
v9.AddArg2(s, v7)
v8.AddArg2(v5, v9)
v0.AddArg2(v1, v8)
v10 := b.NewValue0(v.Pos, OpLsh32x8, typ.UInt32)
v10.AddArg2(v5, s)
v.AddArg2(v0, v10)
return true
}
}
func rewriteValuedec64_OpLsh8x64(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Lsh8x64 _ (Int64Make (Const32 [c]) _))
// cond: c != 0
// result: (Const32 [0])
for {
if v_1.Op != OpInt64Make {
break
}
v_1_0 := v_1.Args[0]
if v_1_0.Op != OpConst32 {
break
}
c := auxIntToInt32(v_1_0.AuxInt)
if !(c != 0) {
break
}
v.reset(OpConst32)
v.AuxInt = int32ToAuxInt(0)
return true
}
// match: (Lsh8x64 [c] x (Int64Make (Const32 [0]) lo))
// result: (Lsh8x32 [c] x lo)
for {
c := auxIntToBool(v.AuxInt)
x := v_0
if v_1.Op != OpInt64Make {
break
}
lo := v_1.Args[1]
v_1_0 := v_1.Args[0]
if v_1_0.Op != OpConst32 || auxIntToInt32(v_1_0.AuxInt) != 0 {
break
}
v.reset(OpLsh8x32)
v.AuxInt = boolToAuxInt(c)
v.AddArg2(x, lo)
return true
}
// match: (Lsh8x64 x (Int64Make hi lo))
// cond: hi.Op != OpConst32
// result: (Lsh8x32 x (Or32 <typ.UInt32> (Zeromask hi) lo))
for {
x := v_0
if v_1.Op != OpInt64Make {
break
}
lo := v_1.Args[1]
hi := v_1.Args[0]
if !(hi.Op != OpConst32) {
break
}
v.reset(OpLsh8x32)
v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32)
v1.AddArg(hi)
v0.AddArg2(v1, lo)
v.AddArg2(x, v0)
return true
}
// match: (Lsh8x64 x y)
// result: (Lsh8x32 x (Or32 <typ.UInt32> (Zeromask (Int64Hi y)) (Int64Lo y)))
for {
x := v_0
y := v_1
v.reset(OpLsh8x32)
v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32)
v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v2.AddArg(y)
v1.AddArg(v2)
v3 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v3.AddArg(y)
v0.AddArg2(v1, v3)
v.AddArg2(x, v0)
return true
}
}
func rewriteValuedec64_OpMul64(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Mul64 x y)
// result: (Int64Make (Add32 <typ.UInt32> (Mul32 <typ.UInt32> (Int64Lo x) (Int64Hi y)) (Add32 <typ.UInt32> (Mul32 <typ.UInt32> (Int64Hi x) (Int64Lo y)) (Select0 <typ.UInt32> (Mul32uhilo (Int64Lo x) (Int64Lo y))))) (Select1 <typ.UInt32> (Mul32uhilo (Int64Lo x) (Int64Lo y))))
for {
x := v_0
y := v_1
v.reset(OpInt64Make)
v0 := b.NewValue0(v.Pos, OpAdd32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpMul32, typ.UInt32)
v2 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v2.AddArg(x)
v3 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v3.AddArg(y)
v1.AddArg2(v2, v3)
v4 := b.NewValue0(v.Pos, OpAdd32, typ.UInt32)
v5 := b.NewValue0(v.Pos, OpMul32, typ.UInt32)
v6 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v6.AddArg(x)
v7 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v7.AddArg(y)
v5.AddArg2(v6, v7)
v8 := b.NewValue0(v.Pos, OpSelect0, typ.UInt32)
v9 := b.NewValue0(v.Pos, OpMul32uhilo, types.NewTuple(typ.UInt32, typ.UInt32))
v9.AddArg2(v2, v7)
v8.AddArg(v9)
v4.AddArg2(v5, v8)
v0.AddArg2(v1, v4)
v10 := b.NewValue0(v.Pos, OpSelect1, typ.UInt32)
v10.AddArg(v9)
v.AddArg2(v0, v10)
return true
}
}
func rewriteValuedec64_OpNeg64(v *Value) bool {
v_0 := v.Args[0]
b := v.Block
// match: (Neg64 <t> x)
// result: (Sub64 (Const64 <t> [0]) x)
for {
t := v.Type
x := v_0
v.reset(OpSub64)
v0 := b.NewValue0(v.Pos, OpConst64, t)
v0.AuxInt = int64ToAuxInt(0)
v.AddArg2(v0, x)
return true
}
}
func rewriteValuedec64_OpNeq64(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Neq64 x y)
// result: (OrB (Neq32 (Int64Hi x) (Int64Hi y)) (Neq32 (Int64Lo x) (Int64Lo y)))
for {
x := v_0
y := v_1
v.reset(OpOrB)
v0 := b.NewValue0(v.Pos, OpNeq32, typ.Bool)
v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v1.AddArg(x)
v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v2.AddArg(y)
v0.AddArg2(v1, v2)
v3 := b.NewValue0(v.Pos, OpNeq32, typ.Bool)
v4 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v4.AddArg(x)
v5 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v5.AddArg(y)
v3.AddArg2(v4, v5)
v.AddArg2(v0, v3)
return true
}
}
func rewriteValuedec64_OpOr32(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Or32 <typ.UInt32> (Zeromask (Const32 [c])) y)
// cond: c == 0
// result: y
for {
if v.Type != typ.UInt32 {
break
}
for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
if v_0.Op != OpZeromask {
continue
}
v_0_0 := v_0.Args[0]
if v_0_0.Op != OpConst32 {
continue
}
c := auxIntToInt32(v_0_0.AuxInt)
y := v_1
if !(c == 0) {
continue
}
v.copyOf(y)
return true
}
break
}
// match: (Or32 <typ.UInt32> (Zeromask (Const32 [c])) y)
// cond: c != 0
// result: (Const32 <typ.UInt32> [-1])
for {
if v.Type != typ.UInt32 {
break
}
for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
if v_0.Op != OpZeromask {
continue
}
v_0_0 := v_0.Args[0]
if v_0_0.Op != OpConst32 {
continue
}
c := auxIntToInt32(v_0_0.AuxInt)
if !(c != 0) {
continue
}
v.reset(OpConst32)
v.Type = typ.UInt32
v.AuxInt = int32ToAuxInt(-1)
return true
}
break
}
return false
}
func rewriteValuedec64_OpOr64(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Or64 x y)
// result: (Int64Make (Or32 <typ.UInt32> (Int64Hi x) (Int64Hi y)) (Or32 <typ.UInt32> (Int64Lo x) (Int64Lo y)))
for {
x := v_0
y := v_1
v.reset(OpInt64Make)
v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v1.AddArg(x)
v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v2.AddArg(y)
v0.AddArg2(v1, v2)
v3 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v4 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v4.AddArg(x)
v5 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v5.AddArg(y)
v3.AddArg2(v4, v5)
v.AddArg2(v0, v3)
return true
}
}
func rewriteValuedec64_OpRotateLeft16(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
// match: (RotateLeft16 x (Int64Make hi lo))
// result: (RotateLeft16 x lo)
for {
x := v_0
if v_1.Op != OpInt64Make {
break
}
lo := v_1.Args[1]
v.reset(OpRotateLeft16)
v.AddArg2(x, lo)
return true
}
return false
}
func rewriteValuedec64_OpRotateLeft32(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
// match: (RotateLeft32 x (Int64Make hi lo))
// result: (RotateLeft32 x lo)
for {
x := v_0
if v_1.Op != OpInt64Make {
break
}
lo := v_1.Args[1]
v.reset(OpRotateLeft32)
v.AddArg2(x, lo)
return true
}
return false
}
func rewriteValuedec64_OpRotateLeft64(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
// match: (RotateLeft64 x (Int64Make hi lo))
// result: (RotateLeft64 x lo)
for {
x := v_0
if v_1.Op != OpInt64Make {
break
}
lo := v_1.Args[1]
v.reset(OpRotateLeft64)
v.AddArg2(x, lo)
return true
}
return false
}
func rewriteValuedec64_OpRotateLeft8(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
// match: (RotateLeft8 x (Int64Make hi lo))
// result: (RotateLeft8 x lo)
for {
x := v_0
if v_1.Op != OpInt64Make {
break
}
lo := v_1.Args[1]
v.reset(OpRotateLeft8)
v.AddArg2(x, lo)
return true
}
return false
}
func rewriteValuedec64_OpRsh16Ux64(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Rsh16Ux64 _ (Int64Make (Const32 [c]) _))
// cond: c != 0
// result: (Const32 [0])
for {
if v_1.Op != OpInt64Make {
break
}
v_1_0 := v_1.Args[0]
if v_1_0.Op != OpConst32 {
break
}
c := auxIntToInt32(v_1_0.AuxInt)
if !(c != 0) {
break
}
v.reset(OpConst32)
v.AuxInt = int32ToAuxInt(0)
return true
}
// match: (Rsh16Ux64 [c] x (Int64Make (Const32 [0]) lo))
// result: (Rsh16Ux32 [c] x lo)
for {
c := auxIntToBool(v.AuxInt)
x := v_0
if v_1.Op != OpInt64Make {
break
}
lo := v_1.Args[1]
v_1_0 := v_1.Args[0]
if v_1_0.Op != OpConst32 || auxIntToInt32(v_1_0.AuxInt) != 0 {
break
}
v.reset(OpRsh16Ux32)
v.AuxInt = boolToAuxInt(c)
v.AddArg2(x, lo)
return true
}
// match: (Rsh16Ux64 x (Int64Make hi lo))
// cond: hi.Op != OpConst32
// result: (Rsh16Ux32 x (Or32 <typ.UInt32> (Zeromask hi) lo))
for {
x := v_0
if v_1.Op != OpInt64Make {
break
}
lo := v_1.Args[1]
hi := v_1.Args[0]
if !(hi.Op != OpConst32) {
break
}
v.reset(OpRsh16Ux32)
v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32)
v1.AddArg(hi)
v0.AddArg2(v1, lo)
v.AddArg2(x, v0)
return true
}
// match: (Rsh16Ux64 x y)
// result: (Rsh16Ux32 x (Or32 <typ.UInt32> (Zeromask (Int64Hi y)) (Int64Lo y)))
for {
x := v_0
y := v_1
v.reset(OpRsh16Ux32)
v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32)
v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v2.AddArg(y)
v1.AddArg(v2)
v3 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v3.AddArg(y)
v0.AddArg2(v1, v3)
v.AddArg2(x, v0)
return true
}
}
func rewriteValuedec64_OpRsh16x64(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Rsh16x64 x (Int64Make (Const32 [c]) _))
// cond: c != 0
// result: (Signmask (SignExt16to32 x))
for {
x := v_0
if v_1.Op != OpInt64Make {
break
}
v_1_0 := v_1.Args[0]
if v_1_0.Op != OpConst32 {
break
}
c := auxIntToInt32(v_1_0.AuxInt)
if !(c != 0) {
break
}
v.reset(OpSignmask)
v0 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32)
v0.AddArg(x)
v.AddArg(v0)
return true
}
// match: (Rsh16x64 [c] x (Int64Make (Const32 [0]) lo))
// result: (Rsh16x32 [c] x lo)
for {
c := auxIntToBool(v.AuxInt)
x := v_0
if v_1.Op != OpInt64Make {
break
}
lo := v_1.Args[1]
v_1_0 := v_1.Args[0]
if v_1_0.Op != OpConst32 || auxIntToInt32(v_1_0.AuxInt) != 0 {
break
}
v.reset(OpRsh16x32)
v.AuxInt = boolToAuxInt(c)
v.AddArg2(x, lo)
return true
}
// match: (Rsh16x64 x (Int64Make hi lo))
// cond: hi.Op != OpConst32
// result: (Rsh16x32 x (Or32 <typ.UInt32> (Zeromask hi) lo))
for {
x := v_0
if v_1.Op != OpInt64Make {
break
}
lo := v_1.Args[1]
hi := v_1.Args[0]
if !(hi.Op != OpConst32) {
break
}
v.reset(OpRsh16x32)
v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32)
v1.AddArg(hi)
v0.AddArg2(v1, lo)
v.AddArg2(x, v0)
return true
}
// match: (Rsh16x64 x y)
// result: (Rsh16x32 x (Or32 <typ.UInt32> (Zeromask (Int64Hi y)) (Int64Lo y)))
for {
x := v_0
y := v_1
v.reset(OpRsh16x32)
v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32)
v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v2.AddArg(y)
v1.AddArg(v2)
v3 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v3.AddArg(y)
v0.AddArg2(v1, v3)
v.AddArg2(x, v0)
return true
}
}
func rewriteValuedec64_OpRsh32Ux64(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Rsh32Ux64 _ (Int64Make (Const32 [c]) _))
// cond: c != 0
// result: (Const32 [0])
for {
if v_1.Op != OpInt64Make {
break
}
v_1_0 := v_1.Args[0]
if v_1_0.Op != OpConst32 {
break
}
c := auxIntToInt32(v_1_0.AuxInt)
if !(c != 0) {
break
}
v.reset(OpConst32)
v.AuxInt = int32ToAuxInt(0)
return true
}
// match: (Rsh32Ux64 [c] x (Int64Make (Const32 [0]) lo))
// result: (Rsh32Ux32 [c] x lo)
for {
c := auxIntToBool(v.AuxInt)
x := v_0
if v_1.Op != OpInt64Make {
break
}
lo := v_1.Args[1]
v_1_0 := v_1.Args[0]
if v_1_0.Op != OpConst32 || auxIntToInt32(v_1_0.AuxInt) != 0 {
break
}
v.reset(OpRsh32Ux32)
v.AuxInt = boolToAuxInt(c)
v.AddArg2(x, lo)
return true
}
// match: (Rsh32Ux64 x (Int64Make hi lo))
// cond: hi.Op != OpConst32
// result: (Rsh32Ux32 x (Or32 <typ.UInt32> (Zeromask hi) lo))
for {
x := v_0
if v_1.Op != OpInt64Make {
break
}
lo := v_1.Args[1]
hi := v_1.Args[0]
if !(hi.Op != OpConst32) {
break
}
v.reset(OpRsh32Ux32)
v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32)
v1.AddArg(hi)
v0.AddArg2(v1, lo)
v.AddArg2(x, v0)
return true
}
// match: (Rsh32Ux64 x y)
// result: (Rsh32Ux32 x (Or32 <typ.UInt32> (Zeromask (Int64Hi y)) (Int64Lo y)))
for {
x := v_0
y := v_1
v.reset(OpRsh32Ux32)
v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32)
v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v2.AddArg(y)
v1.AddArg(v2)
v3 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v3.AddArg(y)
v0.AddArg2(v1, v3)
v.AddArg2(x, v0)
return true
}
}
func rewriteValuedec64_OpRsh32x64(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Rsh32x64 x (Int64Make (Const32 [c]) _))
// cond: c != 0
// result: (Signmask x)
for {
x := v_0
if v_1.Op != OpInt64Make {
break
}
v_1_0 := v_1.Args[0]
if v_1_0.Op != OpConst32 {
break
}
c := auxIntToInt32(v_1_0.AuxInt)
if !(c != 0) {
break
}
v.reset(OpSignmask)
v.AddArg(x)
return true
}
// match: (Rsh32x64 [c] x (Int64Make (Const32 [0]) lo))
// result: (Rsh32x32 [c] x lo)
for {
c := auxIntToBool(v.AuxInt)
x := v_0
if v_1.Op != OpInt64Make {
break
}
lo := v_1.Args[1]
v_1_0 := v_1.Args[0]
if v_1_0.Op != OpConst32 || auxIntToInt32(v_1_0.AuxInt) != 0 {
break
}
v.reset(OpRsh32x32)
v.AuxInt = boolToAuxInt(c)
v.AddArg2(x, lo)
return true
}
// match: (Rsh32x64 x (Int64Make hi lo))
// cond: hi.Op != OpConst32
// result: (Rsh32x32 x (Or32 <typ.UInt32> (Zeromask hi) lo))
for {
x := v_0
if v_1.Op != OpInt64Make {
break
}
lo := v_1.Args[1]
hi := v_1.Args[0]
if !(hi.Op != OpConst32) {
break
}
v.reset(OpRsh32x32)
v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32)
v1.AddArg(hi)
v0.AddArg2(v1, lo)
v.AddArg2(x, v0)
return true
}
// match: (Rsh32x64 x y)
// result: (Rsh32x32 x (Or32 <typ.UInt32> (Zeromask (Int64Hi y)) (Int64Lo y)))
for {
x := v_0
y := v_1
v.reset(OpRsh32x32)
v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32)
v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v2.AddArg(y)
v1.AddArg(v2)
v3 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v3.AddArg(y)
v0.AddArg2(v1, v3)
v.AddArg2(x, v0)
return true
}
}
func rewriteValuedec64_OpRsh64Ux16(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Rsh64Ux16 x s)
// result: (Int64Make (Rsh32Ux16 <typ.UInt32> (Int64Hi x) s) (Or32 <typ.UInt32> (Or32 <typ.UInt32> (Rsh32Ux16 <typ.UInt32> (Int64Lo x) s) (Lsh32x16 <typ.UInt32> (Int64Hi x) (Sub16 <typ.UInt16> (Const16 <typ.UInt16> [32]) s))) (Rsh32Ux16 <typ.UInt32> (Int64Hi x) (Sub16 <typ.UInt16> s (Const16 <typ.UInt16> [32])))))
for {
x := v_0
s := v_1
v.reset(OpInt64Make)
v0 := b.NewValue0(v.Pos, OpRsh32Ux16, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v1.AddArg(x)
v0.AddArg2(v1, s)
v2 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v3 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v4 := b.NewValue0(v.Pos, OpRsh32Ux16, typ.UInt32)
v5 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v5.AddArg(x)
v4.AddArg2(v5, s)
v6 := b.NewValue0(v.Pos, OpLsh32x16, typ.UInt32)
v7 := b.NewValue0(v.Pos, OpSub16, typ.UInt16)
v8 := b.NewValue0(v.Pos, OpConst16, typ.UInt16)
v8.AuxInt = int16ToAuxInt(32)
v7.AddArg2(v8, s)
v6.AddArg2(v1, v7)
v3.AddArg2(v4, v6)
v9 := b.NewValue0(v.Pos, OpRsh32Ux16, typ.UInt32)
v10 := b.NewValue0(v.Pos, OpSub16, typ.UInt16)
v10.AddArg2(s, v8)
v9.AddArg2(v1, v10)
v2.AddArg2(v3, v9)
v.AddArg2(v0, v2)
return true
}
}
func rewriteValuedec64_OpRsh64Ux32(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Rsh64Ux32 x s)
// result: (Int64Make (Rsh32Ux32 <typ.UInt32> (Int64Hi x) s) (Or32 <typ.UInt32> (Or32 <typ.UInt32> (Rsh32Ux32 <typ.UInt32> (Int64Lo x) s) (Lsh32x32 <typ.UInt32> (Int64Hi x) (Sub32 <typ.UInt32> (Const32 <typ.UInt32> [32]) s))) (Rsh32Ux32 <typ.UInt32> (Int64Hi x) (Sub32 <typ.UInt32> s (Const32 <typ.UInt32> [32])))))
for {
x := v_0
s := v_1
v.reset(OpInt64Make)
v0 := b.NewValue0(v.Pos, OpRsh32Ux32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v1.AddArg(x)
v0.AddArg2(v1, s)
v2 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v3 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v4 := b.NewValue0(v.Pos, OpRsh32Ux32, typ.UInt32)
v5 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v5.AddArg(x)
v4.AddArg2(v5, s)
v6 := b.NewValue0(v.Pos, OpLsh32x32, typ.UInt32)
v7 := b.NewValue0(v.Pos, OpSub32, typ.UInt32)
v8 := b.NewValue0(v.Pos, OpConst32, typ.UInt32)
v8.AuxInt = int32ToAuxInt(32)
v7.AddArg2(v8, s)
v6.AddArg2(v1, v7)
v3.AddArg2(v4, v6)
v9 := b.NewValue0(v.Pos, OpRsh32Ux32, typ.UInt32)
v10 := b.NewValue0(v.Pos, OpSub32, typ.UInt32)
v10.AddArg2(s, v8)
v9.AddArg2(v1, v10)
v2.AddArg2(v3, v9)
v.AddArg2(v0, v2)
return true
}
}
func rewriteValuedec64_OpRsh64Ux64(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Rsh64Ux64 _ (Int64Make (Const32 [c]) _))
// cond: c != 0
// result: (Const64 [0])
for {
if v_1.Op != OpInt64Make {
break
}
v_1_0 := v_1.Args[0]
if v_1_0.Op != OpConst32 {
break
}
c := auxIntToInt32(v_1_0.AuxInt)
if !(c != 0) {
break
}
v.reset(OpConst64)
v.AuxInt = int64ToAuxInt(0)
return true
}
// match: (Rsh64Ux64 [c] x (Int64Make (Const32 [0]) lo))
// result: (Rsh64Ux32 [c] x lo)
for {
c := auxIntToBool(v.AuxInt)
x := v_0
if v_1.Op != OpInt64Make {
break
}
lo := v_1.Args[1]
v_1_0 := v_1.Args[0]
if v_1_0.Op != OpConst32 || auxIntToInt32(v_1_0.AuxInt) != 0 {
break
}
v.reset(OpRsh64Ux32)
v.AuxInt = boolToAuxInt(c)
v.AddArg2(x, lo)
return true
}
// match: (Rsh64Ux64 x (Int64Make hi lo))
// cond: hi.Op != OpConst32
// result: (Rsh64Ux32 x (Or32 <typ.UInt32> (Zeromask hi) lo))
for {
x := v_0
if v_1.Op != OpInt64Make {
break
}
lo := v_1.Args[1]
hi := v_1.Args[0]
if !(hi.Op != OpConst32) {
break
}
v.reset(OpRsh64Ux32)
v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32)
v1.AddArg(hi)
v0.AddArg2(v1, lo)
v.AddArg2(x, v0)
return true
}
// match: (Rsh64Ux64 x y)
// result: (Rsh64Ux32 x (Or32 <typ.UInt32> (Zeromask (Int64Hi y)) (Int64Lo y)))
for {
x := v_0
y := v_1
v.reset(OpRsh64Ux32)
v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32)
v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v2.AddArg(y)
v1.AddArg(v2)
v3 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v3.AddArg(y)
v0.AddArg2(v1, v3)
v.AddArg2(x, v0)
return true
}
}
func rewriteValuedec64_OpRsh64Ux8(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Rsh64Ux8 x s)
// result: (Int64Make (Rsh32Ux8 <typ.UInt32> (Int64Hi x) s) (Or32 <typ.UInt32> (Or32 <typ.UInt32> (Rsh32Ux8 <typ.UInt32> (Int64Lo x) s) (Lsh32x8 <typ.UInt32> (Int64Hi x) (Sub8 <typ.UInt8> (Const8 <typ.UInt8> [32]) s))) (Rsh32Ux8 <typ.UInt32> (Int64Hi x) (Sub8 <typ.UInt8> s (Const8 <typ.UInt8> [32])))))
for {
x := v_0
s := v_1
v.reset(OpInt64Make)
v0 := b.NewValue0(v.Pos, OpRsh32Ux8, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v1.AddArg(x)
v0.AddArg2(v1, s)
v2 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v3 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v4 := b.NewValue0(v.Pos, OpRsh32Ux8, typ.UInt32)
v5 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v5.AddArg(x)
v4.AddArg2(v5, s)
v6 := b.NewValue0(v.Pos, OpLsh32x8, typ.UInt32)
v7 := b.NewValue0(v.Pos, OpSub8, typ.UInt8)
v8 := b.NewValue0(v.Pos, OpConst8, typ.UInt8)
v8.AuxInt = int8ToAuxInt(32)
v7.AddArg2(v8, s)
v6.AddArg2(v1, v7)
v3.AddArg2(v4, v6)
v9 := b.NewValue0(v.Pos, OpRsh32Ux8, typ.UInt32)
v10 := b.NewValue0(v.Pos, OpSub8, typ.UInt8)
v10.AddArg2(s, v8)
v9.AddArg2(v1, v10)
v2.AddArg2(v3, v9)
v.AddArg2(v0, v2)
return true
}
}
func rewriteValuedec64_OpRsh64x16(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Rsh64x16 x s)
// result: (Int64Make (Rsh32x16 <typ.UInt32> (Int64Hi x) s) (Or32 <typ.UInt32> (Or32 <typ.UInt32> (Rsh32Ux16 <typ.UInt32> (Int64Lo x) s) (Lsh32x16 <typ.UInt32> (Int64Hi x) (Sub16 <typ.UInt16> (Const16 <typ.UInt16> [32]) s))) (And32 <typ.UInt32> (Rsh32x16 <typ.UInt32> (Int64Hi x) (Sub16 <typ.UInt16> s (Const16 <typ.UInt16> [32]))) (Zeromask (ZeroExt16to32 (Rsh16Ux32 <typ.UInt16> s (Const32 <typ.UInt32> [5])))))))
for {
x := v_0
s := v_1
v.reset(OpInt64Make)
v0 := b.NewValue0(v.Pos, OpRsh32x16, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v1.AddArg(x)
v0.AddArg2(v1, s)
v2 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v3 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v4 := b.NewValue0(v.Pos, OpRsh32Ux16, typ.UInt32)
v5 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v5.AddArg(x)
v4.AddArg2(v5, s)
v6 := b.NewValue0(v.Pos, OpLsh32x16, typ.UInt32)
v7 := b.NewValue0(v.Pos, OpSub16, typ.UInt16)
v8 := b.NewValue0(v.Pos, OpConst16, typ.UInt16)
v8.AuxInt = int16ToAuxInt(32)
v7.AddArg2(v8, s)
v6.AddArg2(v1, v7)
v3.AddArg2(v4, v6)
v9 := b.NewValue0(v.Pos, OpAnd32, typ.UInt32)
v10 := b.NewValue0(v.Pos, OpRsh32x16, typ.UInt32)
v11 := b.NewValue0(v.Pos, OpSub16, typ.UInt16)
v11.AddArg2(s, v8)
v10.AddArg2(v1, v11)
v12 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32)
v13 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32)
v14 := b.NewValue0(v.Pos, OpRsh16Ux32, typ.UInt16)
v15 := b.NewValue0(v.Pos, OpConst32, typ.UInt32)
v15.AuxInt = int32ToAuxInt(5)
v14.AddArg2(s, v15)
v13.AddArg(v14)
v12.AddArg(v13)
v9.AddArg2(v10, v12)
v2.AddArg2(v3, v9)
v.AddArg2(v0, v2)
return true
}
}
func rewriteValuedec64_OpRsh64x32(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Rsh64x32 x s)
// result: (Int64Make (Rsh32x32 <typ.UInt32> (Int64Hi x) s) (Or32 <typ.UInt32> (Or32 <typ.UInt32> (Rsh32Ux32 <typ.UInt32> (Int64Lo x) s) (Lsh32x32 <typ.UInt32> (Int64Hi x) (Sub32 <typ.UInt32> (Const32 <typ.UInt32> [32]) s))) (And32 <typ.UInt32> (Rsh32x32 <typ.UInt32> (Int64Hi x) (Sub32 <typ.UInt32> s (Const32 <typ.UInt32> [32]))) (Zeromask (Rsh32Ux32 <typ.UInt32> s (Const32 <typ.UInt32> [5]))))))
for {
x := v_0
s := v_1
v.reset(OpInt64Make)
v0 := b.NewValue0(v.Pos, OpRsh32x32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v1.AddArg(x)
v0.AddArg2(v1, s)
v2 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v3 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v4 := b.NewValue0(v.Pos, OpRsh32Ux32, typ.UInt32)
v5 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v5.AddArg(x)
v4.AddArg2(v5, s)
v6 := b.NewValue0(v.Pos, OpLsh32x32, typ.UInt32)
v7 := b.NewValue0(v.Pos, OpSub32, typ.UInt32)
v8 := b.NewValue0(v.Pos, OpConst32, typ.UInt32)
v8.AuxInt = int32ToAuxInt(32)
v7.AddArg2(v8, s)
v6.AddArg2(v1, v7)
v3.AddArg2(v4, v6)
v9 := b.NewValue0(v.Pos, OpAnd32, typ.UInt32)
v10 := b.NewValue0(v.Pos, OpRsh32x32, typ.UInt32)
v11 := b.NewValue0(v.Pos, OpSub32, typ.UInt32)
v11.AddArg2(s, v8)
v10.AddArg2(v1, v11)
v12 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32)
v13 := b.NewValue0(v.Pos, OpRsh32Ux32, typ.UInt32)
v14 := b.NewValue0(v.Pos, OpConst32, typ.UInt32)
v14.AuxInt = int32ToAuxInt(5)
v13.AddArg2(s, v14)
v12.AddArg(v13)
v9.AddArg2(v10, v12)
v2.AddArg2(v3, v9)
v.AddArg2(v0, v2)
return true
}
}
func rewriteValuedec64_OpRsh64x64(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Rsh64x64 x (Int64Make (Const32 [c]) _))
// cond: c != 0
// result: (Int64Make (Signmask (Int64Hi x)) (Signmask (Int64Hi x)))
for {
x := v_0
if v_1.Op != OpInt64Make {
break
}
v_1_0 := v_1.Args[0]
if v_1_0.Op != OpConst32 {
break
}
c := auxIntToInt32(v_1_0.AuxInt)
if !(c != 0) {
break
}
v.reset(OpInt64Make)
v0 := b.NewValue0(v.Pos, OpSignmask, typ.Int32)
v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v1.AddArg(x)
v0.AddArg(v1)
v.AddArg2(v0, v0)
return true
}
// match: (Rsh64x64 [c] x (Int64Make (Const32 [0]) lo))
// result: (Rsh64x32 [c] x lo)
for {
c := auxIntToBool(v.AuxInt)
x := v_0
if v_1.Op != OpInt64Make {
break
}
lo := v_1.Args[1]
v_1_0 := v_1.Args[0]
if v_1_0.Op != OpConst32 || auxIntToInt32(v_1_0.AuxInt) != 0 {
break
}
v.reset(OpRsh64x32)
v.AuxInt = boolToAuxInt(c)
v.AddArg2(x, lo)
return true
}
// match: (Rsh64x64 x (Int64Make hi lo))
// cond: hi.Op != OpConst32
// result: (Rsh64x32 x (Or32 <typ.UInt32> (Zeromask hi) lo))
for {
x := v_0
if v_1.Op != OpInt64Make {
break
}
lo := v_1.Args[1]
hi := v_1.Args[0]
if !(hi.Op != OpConst32) {
break
}
v.reset(OpRsh64x32)
v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32)
v1.AddArg(hi)
v0.AddArg2(v1, lo)
v.AddArg2(x, v0)
return true
}
// match: (Rsh64x64 x y)
// result: (Rsh64x32 x (Or32 <typ.UInt32> (Zeromask (Int64Hi y)) (Int64Lo y)))
for {
x := v_0
y := v_1
v.reset(OpRsh64x32)
v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32)
v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v2.AddArg(y)
v1.AddArg(v2)
v3 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v3.AddArg(y)
v0.AddArg2(v1, v3)
v.AddArg2(x, v0)
return true
}
}
func rewriteValuedec64_OpRsh64x8(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Rsh64x8 x s)
// result: (Int64Make (Rsh32x8 <typ.UInt32> (Int64Hi x) s) (Or32 <typ.UInt32> (Or32 <typ.UInt32> (Rsh32Ux8 <typ.UInt32> (Int64Lo x) s) (Lsh32x8 <typ.UInt32> (Int64Hi x) (Sub8 <typ.UInt8> (Const8 <typ.UInt8> [32]) s))) (And32 <typ.UInt32> (Rsh32x8 <typ.UInt32> (Int64Hi x) (Sub8 <typ.UInt8> s (Const8 <typ.UInt8> [32]))) (Zeromask (ZeroExt8to32 (Rsh8Ux32 <typ.UInt8> s (Const32 <typ.UInt32> [5])))))))
for {
x := v_0
s := v_1
v.reset(OpInt64Make)
v0 := b.NewValue0(v.Pos, OpRsh32x8, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v1.AddArg(x)
v0.AddArg2(v1, s)
v2 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v3 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v4 := b.NewValue0(v.Pos, OpRsh32Ux8, typ.UInt32)
v5 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v5.AddArg(x)
v4.AddArg2(v5, s)
v6 := b.NewValue0(v.Pos, OpLsh32x8, typ.UInt32)
v7 := b.NewValue0(v.Pos, OpSub8, typ.UInt8)
v8 := b.NewValue0(v.Pos, OpConst8, typ.UInt8)
v8.AuxInt = int8ToAuxInt(32)
v7.AddArg2(v8, s)
v6.AddArg2(v1, v7)
v3.AddArg2(v4, v6)
v9 := b.NewValue0(v.Pos, OpAnd32, typ.UInt32)
v10 := b.NewValue0(v.Pos, OpRsh32x8, typ.UInt32)
v11 := b.NewValue0(v.Pos, OpSub8, typ.UInt8)
v11.AddArg2(s, v8)
v10.AddArg2(v1, v11)
v12 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32)
v13 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32)
v14 := b.NewValue0(v.Pos, OpRsh8Ux32, typ.UInt8)
v15 := b.NewValue0(v.Pos, OpConst32, typ.UInt32)
v15.AuxInt = int32ToAuxInt(5)
v14.AddArg2(s, v15)
v13.AddArg(v14)
v12.AddArg(v13)
v9.AddArg2(v10, v12)
v2.AddArg2(v3, v9)
v.AddArg2(v0, v2)
return true
}
}
func rewriteValuedec64_OpRsh8Ux64(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Rsh8Ux64 _ (Int64Make (Const32 [c]) _))
// cond: c != 0
// result: (Const32 [0])
for {
if v_1.Op != OpInt64Make {
break
}
v_1_0 := v_1.Args[0]
if v_1_0.Op != OpConst32 {
break
}
c := auxIntToInt32(v_1_0.AuxInt)
if !(c != 0) {
break
}
v.reset(OpConst32)
v.AuxInt = int32ToAuxInt(0)
return true
}
// match: (Rsh8Ux64 [c] x (Int64Make (Const32 [0]) lo))
// result: (Rsh8Ux32 [c] x lo)
for {
c := auxIntToBool(v.AuxInt)
x := v_0
if v_1.Op != OpInt64Make {
break
}
lo := v_1.Args[1]
v_1_0 := v_1.Args[0]
if v_1_0.Op != OpConst32 || auxIntToInt32(v_1_0.AuxInt) != 0 {
break
}
v.reset(OpRsh8Ux32)
v.AuxInt = boolToAuxInt(c)
v.AddArg2(x, lo)
return true
}
// match: (Rsh8Ux64 x (Int64Make hi lo))
// cond: hi.Op != OpConst32
// result: (Rsh8Ux32 x (Or32 <typ.UInt32> (Zeromask hi) lo))
for {
x := v_0
if v_1.Op != OpInt64Make {
break
}
lo := v_1.Args[1]
hi := v_1.Args[0]
if !(hi.Op != OpConst32) {
break
}
v.reset(OpRsh8Ux32)
v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32)
v1.AddArg(hi)
v0.AddArg2(v1, lo)
v.AddArg2(x, v0)
return true
}
// match: (Rsh8Ux64 x y)
// result: (Rsh8Ux32 x (Or32 <typ.UInt32> (Zeromask (Int64Hi y)) (Int64Lo y)))
for {
x := v_0
y := v_1
v.reset(OpRsh8Ux32)
v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32)
v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v2.AddArg(y)
v1.AddArg(v2)
v3 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v3.AddArg(y)
v0.AddArg2(v1, v3)
v.AddArg2(x, v0)
return true
}
}
func rewriteValuedec64_OpRsh8x64(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Rsh8x64 x (Int64Make (Const32 [c]) _))
// cond: c != 0
// result: (Signmask (SignExt8to32 x))
for {
x := v_0
if v_1.Op != OpInt64Make {
break
}
v_1_0 := v_1.Args[0]
if v_1_0.Op != OpConst32 {
break
}
c := auxIntToInt32(v_1_0.AuxInt)
if !(c != 0) {
break
}
v.reset(OpSignmask)
v0 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32)
v0.AddArg(x)
v.AddArg(v0)
return true
}
// match: (Rsh8x64 [c] x (Int64Make (Const32 [0]) lo))
// result: (Rsh8x32 [c] x lo)
for {
c := auxIntToBool(v.AuxInt)
x := v_0
if v_1.Op != OpInt64Make {
break
}
lo := v_1.Args[1]
v_1_0 := v_1.Args[0]
if v_1_0.Op != OpConst32 || auxIntToInt32(v_1_0.AuxInt) != 0 {
break
}
v.reset(OpRsh8x32)
v.AuxInt = boolToAuxInt(c)
v.AddArg2(x, lo)
return true
}
// match: (Rsh8x64 x (Int64Make hi lo))
// cond: hi.Op != OpConst32
// result: (Rsh8x32 x (Or32 <typ.UInt32> (Zeromask hi) lo))
for {
x := v_0
if v_1.Op != OpInt64Make {
break
}
lo := v_1.Args[1]
hi := v_1.Args[0]
if !(hi.Op != OpConst32) {
break
}
v.reset(OpRsh8x32)
v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32)
v1.AddArg(hi)
v0.AddArg2(v1, lo)
v.AddArg2(x, v0)
return true
}
// match: (Rsh8x64 x y)
// result: (Rsh8x32 x (Or32 <typ.UInt32> (Zeromask (Int64Hi y)) (Int64Lo y)))
for {
x := v_0
y := v_1
v.reset(OpRsh8x32)
v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32)
v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v2.AddArg(y)
v1.AddArg(v2)
v3 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v3.AddArg(y)
v0.AddArg2(v1, v3)
v.AddArg2(x, v0)
return true
}
}
func rewriteValuedec64_OpSignExt16to64(v *Value) bool {
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (SignExt16to64 x)
// result: (SignExt32to64 (SignExt16to32 x))
for {
x := v_0
v.reset(OpSignExt32to64)
v0 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32)
v0.AddArg(x)
v.AddArg(v0)
return true
}
}
func rewriteValuedec64_OpSignExt32to64(v *Value) bool {
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (SignExt32to64 x)
// result: (Int64Make (Signmask x) x)
for {
x := v_0
v.reset(OpInt64Make)
v0 := b.NewValue0(v.Pos, OpSignmask, typ.Int32)
v0.AddArg(x)
v.AddArg2(v0, x)
return true
}
}
func rewriteValuedec64_OpSignExt8to64(v *Value) bool {
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (SignExt8to64 x)
// result: (SignExt32to64 (SignExt8to32 x))
for {
x := v_0
v.reset(OpSignExt32to64)
v0 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32)
v0.AddArg(x)
v.AddArg(v0)
return true
}
}
func rewriteValuedec64_OpStore(v *Value) bool {
v_2 := v.Args[2]
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
config := b.Func.Config
// match: (Store {t} dst (Int64Make hi lo) mem)
// cond: t.Size() == 8 && !config.BigEndian
// result: (Store {hi.Type} (OffPtr <hi.Type.PtrTo()> [4] dst) hi (Store {lo.Type} dst lo mem))
for {
t := auxToType(v.Aux)
dst := v_0
if v_1.Op != OpInt64Make {
break
}
lo := v_1.Args[1]
hi := v_1.Args[0]
mem := v_2
if !(t.Size() == 8 && !config.BigEndian) {
break
}
v.reset(OpStore)
v.Aux = typeToAux(hi.Type)
v0 := b.NewValue0(v.Pos, OpOffPtr, hi.Type.PtrTo())
v0.AuxInt = int64ToAuxInt(4)
v0.AddArg(dst)
v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem)
v1.Aux = typeToAux(lo.Type)
v1.AddArg3(dst, lo, mem)
v.AddArg3(v0, hi, v1)
return true
}
// match: (Store {t} dst (Int64Make hi lo) mem)
// cond: t.Size() == 8 && config.BigEndian
// result: (Store {lo.Type} (OffPtr <lo.Type.PtrTo()> [4] dst) lo (Store {hi.Type} dst hi mem))
for {
t := auxToType(v.Aux)
dst := v_0
if v_1.Op != OpInt64Make {
break
}
lo := v_1.Args[1]
hi := v_1.Args[0]
mem := v_2
if !(t.Size() == 8 && config.BigEndian) {
break
}
v.reset(OpStore)
v.Aux = typeToAux(lo.Type)
v0 := b.NewValue0(v.Pos, OpOffPtr, lo.Type.PtrTo())
v0.AuxInt = int64ToAuxInt(4)
v0.AddArg(dst)
v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem)
v1.Aux = typeToAux(hi.Type)
v1.AddArg3(dst, hi, mem)
v.AddArg3(v0, lo, v1)
return true
}
return false
}
func rewriteValuedec64_OpSub64(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Sub64 x y)
// result: (Int64Make (Sub32withcarry <typ.Int32> (Int64Hi x) (Int64Hi y) (Select1 <types.TypeFlags> (Sub32carry (Int64Lo x) (Int64Lo y)))) (Select0 <typ.UInt32> (Sub32carry (Int64Lo x) (Int64Lo y))))
for {
x := v_0
y := v_1
v.reset(OpInt64Make)
v0 := b.NewValue0(v.Pos, OpSub32withcarry, typ.Int32)
v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v1.AddArg(x)
v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v2.AddArg(y)
v3 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags)
v4 := b.NewValue0(v.Pos, OpSub32carry, types.NewTuple(typ.UInt32, types.TypeFlags))
v5 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v5.AddArg(x)
v6 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v6.AddArg(y)
v4.AddArg2(v5, v6)
v3.AddArg(v4)
v0.AddArg3(v1, v2, v3)
v7 := b.NewValue0(v.Pos, OpSelect0, typ.UInt32)
v7.AddArg(v4)
v.AddArg2(v0, v7)
return true
}
}
func rewriteValuedec64_OpTrunc64to16(v *Value) bool {
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Trunc64to16 (Int64Make _ lo))
// result: (Trunc32to16 lo)
for {
if v_0.Op != OpInt64Make {
break
}
lo := v_0.Args[1]
v.reset(OpTrunc32to16)
v.AddArg(lo)
return true
}
// match: (Trunc64to16 x)
// result: (Trunc32to16 (Int64Lo x))
for {
x := v_0
v.reset(OpTrunc32to16)
v0 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v0.AddArg(x)
v.AddArg(v0)
return true
}
}
func rewriteValuedec64_OpTrunc64to32(v *Value) bool {
v_0 := v.Args[0]
// match: (Trunc64to32 (Int64Make _ lo))
// result: lo
for {
if v_0.Op != OpInt64Make {
break
}
lo := v_0.Args[1]
v.copyOf(lo)
return true
}
// match: (Trunc64to32 x)
// result: (Int64Lo x)
for {
x := v_0
v.reset(OpInt64Lo)
v.AddArg(x)
return true
}
}
func rewriteValuedec64_OpTrunc64to8(v *Value) bool {
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Trunc64to8 (Int64Make _ lo))
// result: (Trunc32to8 lo)
for {
if v_0.Op != OpInt64Make {
break
}
lo := v_0.Args[1]
v.reset(OpTrunc32to8)
v.AddArg(lo)
return true
}
// match: (Trunc64to8 x)
// result: (Trunc32to8 (Int64Lo x))
for {
x := v_0
v.reset(OpTrunc32to8)
v0 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v0.AddArg(x)
v.AddArg(v0)
return true
}
}
func rewriteValuedec64_OpXor64(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Xor64 x y)
// result: (Int64Make (Xor32 <typ.UInt32> (Int64Hi x) (Int64Hi y)) (Xor32 <typ.UInt32> (Int64Lo x) (Int64Lo y)))
for {
x := v_0
y := v_1
v.reset(OpInt64Make)
v0 := b.NewValue0(v.Pos, OpXor32, typ.UInt32)
v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v1.AddArg(x)
v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32)
v2.AddArg(y)
v0.AddArg2(v1, v2)
v3 := b.NewValue0(v.Pos, OpXor32, typ.UInt32)
v4 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v4.AddArg(x)
v5 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32)
v5.AddArg(y)
v3.AddArg2(v4, v5)
v.AddArg2(v0, v3)
return true
}
}
func rewriteValuedec64_OpZeroExt16to64(v *Value) bool {
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (ZeroExt16to64 x)
// result: (ZeroExt32to64 (ZeroExt16to32 x))
for {
x := v_0
v.reset(OpZeroExt32to64)
v0 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32)
v0.AddArg(x)
v.AddArg(v0)
return true
}
}
func rewriteValuedec64_OpZeroExt32to64(v *Value) bool {
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (ZeroExt32to64 x)
// result: (Int64Make (Const32 <typ.UInt32> [0]) x)
for {
x := v_0
v.reset(OpInt64Make)
v0 := b.NewValue0(v.Pos, OpConst32, typ.UInt32)
v0.AuxInt = int32ToAuxInt(0)
v.AddArg2(v0, x)
return true
}
}
func rewriteValuedec64_OpZeroExt8to64(v *Value) bool {
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (ZeroExt8to64 x)
// result: (ZeroExt32to64 (ZeroExt8to32 x))
for {
x := v_0
v.reset(OpZeroExt32to64)
v0 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32)
v0.AddArg(x)
v.AddArg(v0)
return true
}
}
func rewriteBlockdec64(b *Block) bool {
return false
}
|
go/src/cmd/compile/internal/ssa/rewritedec64.go/0
|
{
"file_path": "go/src/cmd/compile/internal/ssa/rewritedec64.go",
"repo_id": "go",
"token_count": 36748
}
| 104 |
// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package ssa_test
import (
cmddwarf "cmd/internal/dwarf"
"cmd/internal/quoted"
"debug/dwarf"
"debug/elf"
"debug/macho"
"debug/pe"
"fmt"
"internal/platform"
"internal/testenv"
"internal/xcoff"
"io"
"os"
"runtime"
"sort"
"testing"
)
func open(path string) (*dwarf.Data, error) {
if fh, err := elf.Open(path); err == nil {
return fh.DWARF()
}
if fh, err := pe.Open(path); err == nil {
return fh.DWARF()
}
if fh, err := macho.Open(path); err == nil {
return fh.DWARF()
}
if fh, err := xcoff.Open(path); err == nil {
return fh.DWARF()
}
return nil, fmt.Errorf("unrecognized executable format")
}
func must(err error) {
if err != nil {
panic(err)
}
}
type Line struct {
File string
Line int
}
func TestStmtLines(t *testing.T) {
if !platform.ExecutableHasDWARF(runtime.GOOS, runtime.GOARCH) {
t.Skipf("skipping on %s/%s: no DWARF symbol table in executables", runtime.GOOS, runtime.GOARCH)
}
if runtime.GOOS == "aix" {
extld := os.Getenv("CC")
if extld == "" {
extld = "gcc"
}
extldArgs, err := quoted.Split(extld)
if err != nil {
t.Fatal(err)
}
enabled, err := cmddwarf.IsDWARFEnabledOnAIXLd(extldArgs)
if err != nil {
t.Fatal(err)
}
if !enabled {
t.Skip("skipping on aix: no DWARF with ld version < 7.2.2 ")
}
}
// Build cmd/go forcing DWARF enabled, as a large test case.
dir := t.TempDir()
out, err := testenv.Command(t, testenv.GoToolPath(t), "build", "-ldflags=-w=0", "-o", dir+"/test.exe", "cmd/go").CombinedOutput()
if err != nil {
t.Fatalf("go build: %v\n%s", err, out)
}
lines := map[Line]bool{}
dw, err := open(dir + "/test.exe")
must(err)
rdr := dw.Reader()
rdr.Seek(0)
for {
e, err := rdr.Next()
must(err)
if e == nil {
break
}
if e.Tag != dwarf.TagCompileUnit {
continue
}
pkgname, _ := e.Val(dwarf.AttrName).(string)
if pkgname == "runtime" {
continue
}
if pkgname == "crypto/internal/nistec/fiat" {
continue // golang.org/issue/49372
}
if e.Val(dwarf.AttrStmtList) == nil {
continue
}
lrdr, err := dw.LineReader(e)
must(err)
var le dwarf.LineEntry
for {
err := lrdr.Next(&le)
if err == io.EOF {
break
}
must(err)
fl := Line{le.File.Name, le.Line}
lines[fl] = lines[fl] || le.IsStmt
}
}
nonStmtLines := []Line{}
for line, isstmt := range lines {
if !isstmt {
nonStmtLines = append(nonStmtLines, line)
}
}
var m int
if runtime.GOARCH == "amd64" {
m = 1 // > 99% obtained on amd64, no backsliding
} else if runtime.GOARCH == "riscv64" {
m = 3 // XXX temporary update threshold to 97% for regabi
} else {
m = 2 // expect 98% elsewhere.
}
if len(nonStmtLines)*100 > m*len(lines) {
t.Errorf("Saw too many (%s, > %d%%) lines without statement marks, total=%d, nostmt=%d ('-run TestStmtLines -v' lists failing lines)\n", runtime.GOARCH, m, len(lines), len(nonStmtLines))
}
t.Logf("Saw %d out of %d lines without statement marks", len(nonStmtLines), len(lines))
if testing.Verbose() {
sort.Slice(nonStmtLines, func(i, j int) bool {
if nonStmtLines[i].File != nonStmtLines[j].File {
return nonStmtLines[i].File < nonStmtLines[j].File
}
return nonStmtLines[i].Line < nonStmtLines[j].Line
})
for _, l := range nonStmtLines {
t.Logf("%s:%d has no DWARF is_stmt mark\n", l.File, l.Line)
}
}
t.Logf("total=%d, nostmt=%d\n", len(lines), len(nonStmtLines))
}
|
go/src/cmd/compile/internal/ssa/stmtlines_test.go/0
|
{
"file_path": "go/src/cmd/compile/internal/ssa/stmtlines_test.go",
"repo_id": "go",
"token_count": 1592
}
| 105 |
src/cmd/compile/internal/ssa/testdata/infloop.go
6: func test() {
8: go func() {}()
10: for {
|
go/src/cmd/compile/internal/ssa/testdata/infloop.gdb-opt.nexts/0
|
{
"file_path": "go/src/cmd/compile/internal/ssa/testdata/infloop.gdb-opt.nexts",
"repo_id": "go",
"token_count": 47
}
| 106 |
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package ssa
import (
"cmd/internal/src"
"fmt"
)
type lineRange struct {
first, last uint32
}
// An xposmap is a map from fileindex and line of src.XPos to int32,
// implemented sparsely to save space (column and statement status are ignored).
// The sparse skeleton is constructed once, and then reused by ssa phases
// that (re)move values with statements attached.
type xposmap struct {
// A map from file index to maps from line range to integers (block numbers)
maps map[int32]*biasedSparseMap
// The next two fields provide a single-item cache for common case of repeated lines from same file.
lastIndex int32 // -1 means no entry in cache
lastMap *biasedSparseMap // map found at maps[lastIndex]
}
// newXposmap constructs an xposmap valid for inputs which have a file index in the keys of x,
// and line numbers in the range x[file index].
// The resulting xposmap will panic if a caller attempts to set or add an XPos not in that range.
func newXposmap(x map[int]lineRange) *xposmap {
maps := make(map[int32]*biasedSparseMap)
for i, p := range x {
maps[int32(i)] = newBiasedSparseMap(int(p.first), int(p.last))
}
return &xposmap{maps: maps, lastIndex: -1} // zero for the rest is okay
}
// clear removes data from the map but leaves the sparse skeleton.
func (m *xposmap) clear() {
for _, l := range m.maps {
if l != nil {
l.clear()
}
}
m.lastIndex = -1
m.lastMap = nil
}
// mapFor returns the line range map for a given file index.
func (m *xposmap) mapFor(index int32) *biasedSparseMap {
if index == m.lastIndex {
return m.lastMap
}
mf := m.maps[index]
m.lastIndex = index
m.lastMap = mf
return mf
}
// set inserts p->v into the map.
// If p does not fall within the set of fileindex->lineRange used to construct m, this will panic.
func (m *xposmap) set(p src.XPos, v int32) {
s := m.mapFor(p.FileIndex())
if s == nil {
panic(fmt.Sprintf("xposmap.set(%d), file index not found in map\n", p.FileIndex()))
}
s.set(p.Line(), v)
}
// get returns the int32 associated with the file index and line of p.
func (m *xposmap) get(p src.XPos) int32 {
s := m.mapFor(p.FileIndex())
if s == nil {
return -1
}
return s.get(p.Line())
}
// add adds p to m, treating m as a set instead of as a map.
// If p does not fall within the set of fileindex->lineRange used to construct m, this will panic.
// Use clear() in between set/map interpretations of m.
func (m *xposmap) add(p src.XPos) {
m.set(p, 0)
}
// contains returns whether the file index and line of p are in m,
// treating m as a set instead of as a map.
func (m *xposmap) contains(p src.XPos) bool {
s := m.mapFor(p.FileIndex())
if s == nil {
return false
}
return s.contains(p.Line())
}
// remove removes the file index and line for p from m,
// whether m is currently treated as a map or set.
func (m *xposmap) remove(p src.XPos) {
s := m.mapFor(p.FileIndex())
if s == nil {
return
}
s.remove(p.Line())
}
// foreachEntry applies f to each (fileindex, line, value) triple in m.
func (m *xposmap) foreachEntry(f func(j int32, l uint, v int32)) {
for j, mm := range m.maps {
s := mm.size()
for i := 0; i < s; i++ {
l, v := mm.getEntry(i)
f(j, l, v)
}
}
}
|
go/src/cmd/compile/internal/ssa/xposmap.go/0
|
{
"file_path": "go/src/cmd/compile/internal/ssa/xposmap.go",
"repo_id": "go",
"token_count": 1207
}
| 107 |
// Copyright 2024 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This file holds test cases for individual issues
// for which there is (currently) no better location.
package syntax
import (
"strings"
"testing"
)
func TestIssue67866(t *testing.T) {
var tests = []string{
"package p; var _ = T{@0: 0}",
"package p; var _ = T{@1 + 2: 0}",
"package p; var _ = T{@x[i]: 0}",
"package p; var _ = T{@f(1, 2, 3): 0}",
"package p; var _ = T{@a + f(b) + <-ch: 0}",
}
for _, src := range tests {
// identify column position of @ and remove it from src
i := strings.Index(src, "@")
if i < 0 {
t.Errorf("%s: invalid test case (missing @)", src)
continue
}
src = src[:i] + src[i+1:]
want := colbase + uint(i)
f, err := Parse(nil, strings.NewReader(src), nil, nil, 0)
if err != nil {
t.Errorf("%s: %v", src, err)
continue
}
// locate KeyValueExpr
Inspect(f, func(n Node) bool {
_, ok := n.(*KeyValueExpr)
if ok {
if got := StartPos(n).Col(); got != want {
t.Errorf("%s: got col = %d, want %d", src, got, want)
}
}
return !ok
})
}
}
|
go/src/cmd/compile/internal/syntax/issues_test.go/0
|
{
"file_path": "go/src/cmd/compile/internal/syntax/issues_test.go",
"repo_id": "go",
"token_count": 506
}
| 108 |
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package p
import (
"fmt"
)
func f() {
int status // ERROR syntax error: unexpected name status at end of statement
fmt.Println(status)
}
|
go/src/cmd/compile/internal/syntax/testdata/issue65790.go/0
|
{
"file_path": "go/src/cmd/compile/internal/syntax/testdata/issue65790.go",
"repo_id": "go",
"token_count": 91
}
| 109 |
// Copyright 2020 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package test
import (
"bufio"
"cmd/compile/internal/abi"
"cmd/compile/internal/base"
"cmd/compile/internal/ssagen"
"cmd/compile/internal/typecheck"
"cmd/compile/internal/types"
"cmd/internal/obj"
"cmd/internal/obj/x86"
"cmd/internal/src"
"fmt"
"os"
"testing"
)
// AMD64 registers available:
// - integer: RAX, RBX, RCX, RDI, RSI, R8, R9, r10, R11
// - floating point: X0 - X14
var configAMD64 = abi.NewABIConfig(9, 15, 0, 1)
func TestMain(m *testing.M) {
ssagen.Arch.LinkArch = &x86.Linkamd64
ssagen.Arch.REGSP = x86.REGSP
ssagen.Arch.MAXWIDTH = 1 << 50
types.MaxWidth = ssagen.Arch.MAXWIDTH
base.Ctxt = obj.Linknew(ssagen.Arch.LinkArch)
base.Ctxt.DiagFunc = base.Errorf
base.Ctxt.DiagFlush = base.FlushErrors
base.Ctxt.Bso = bufio.NewWriter(os.Stdout)
types.LocalPkg = types.NewPkg("p", "local")
types.LocalPkg.Prefix = "p"
types.PtrSize = ssagen.Arch.LinkArch.PtrSize
types.RegSize = ssagen.Arch.LinkArch.RegSize
typecheck.InitUniverse()
os.Exit(m.Run())
}
func TestABIUtilsBasic1(t *testing.T) {
// func(x int32) int32
i32 := types.Types[types.TINT32]
ft := mkFuncType(nil, []*types.Type{i32}, []*types.Type{i32})
// expected results
exp := makeExpectedDump(`
IN 0: R{ I0 } spilloffset: 0 typ: int32
OUT 0: R{ I0 } spilloffset: -1 typ: int32
offsetToSpillArea: 0 spillAreaSize: 8
`)
abitest(t, ft, exp)
}
func TestABIUtilsBasic2(t *testing.T) {
// func(p1 int8, p2 int16, p3 int32, p4 int64,
// p5 float32, p6 float32, p7 float64, p8 float64,
// p9 int8, p10 int16, p11 int32, p12 int64,
// p13 float32, p14 float32, p15 float64, p16 float64,
// p17 complex128, p18 complex128, p19 complex12, p20 complex128,
// p21 complex64, p22 int8, p23 in16, p24 int32, p25 int64,
// p26 int8, p27 in16, p28 int32, p29 int64)
// (r1 int32, r2 float64, r3 float64) {
i8 := types.Types[types.TINT8]
i16 := types.Types[types.TINT16]
i32 := types.Types[types.TINT32]
i64 := types.Types[types.TINT64]
f32 := types.Types[types.TFLOAT32]
f64 := types.Types[types.TFLOAT64]
c64 := types.Types[types.TCOMPLEX64]
c128 := types.Types[types.TCOMPLEX128]
ft := mkFuncType(nil,
[]*types.Type{
i8, i16, i32, i64,
f32, f32, f64, f64,
i8, i16, i32, i64,
f32, f32, f64, f64,
c128, c128, c128, c128, c64,
i8, i16, i32, i64,
i8, i16, i32, i64},
[]*types.Type{i32, f64, f64})
exp := makeExpectedDump(`
IN 0: R{ I0 } spilloffset: 0 typ: int8
IN 1: R{ I1 } spilloffset: 2 typ: int16
IN 2: R{ I2 } spilloffset: 4 typ: int32
IN 3: R{ I3 } spilloffset: 8 typ: int64
IN 4: R{ F0 } spilloffset: 16 typ: float32
IN 5: R{ F1 } spilloffset: 20 typ: float32
IN 6: R{ F2 } spilloffset: 24 typ: float64
IN 7: R{ F3 } spilloffset: 32 typ: float64
IN 8: R{ I4 } spilloffset: 40 typ: int8
IN 9: R{ I5 } spilloffset: 42 typ: int16
IN 10: R{ I6 } spilloffset: 44 typ: int32
IN 11: R{ I7 } spilloffset: 48 typ: int64
IN 12: R{ F4 } spilloffset: 56 typ: float32
IN 13: R{ F5 } spilloffset: 60 typ: float32
IN 14: R{ F6 } spilloffset: 64 typ: float64
IN 15: R{ F7 } spilloffset: 72 typ: float64
IN 16: R{ F8 F9 } spilloffset: 80 typ: complex128
IN 17: R{ F10 F11 } spilloffset: 96 typ: complex128
IN 18: R{ F12 F13 } spilloffset: 112 typ: complex128
IN 19: R{ } offset: 0 typ: complex128
IN 20: R{ } offset: 16 typ: complex64
IN 21: R{ I8 } spilloffset: 128 typ: int8
IN 22: R{ } offset: 24 typ: int16
IN 23: R{ } offset: 28 typ: int32
IN 24: R{ } offset: 32 typ: int64
IN 25: R{ } offset: 40 typ: int8
IN 26: R{ } offset: 42 typ: int16
IN 27: R{ } offset: 44 typ: int32
IN 28: R{ } offset: 48 typ: int64
OUT 0: R{ I0 } spilloffset: -1 typ: int32
OUT 1: R{ F0 } spilloffset: -1 typ: float64
OUT 2: R{ F1 } spilloffset: -1 typ: float64
offsetToSpillArea: 56 spillAreaSize: 136
`)
abitest(t, ft, exp)
}
func TestABIUtilsArrays(t *testing.T) {
// func(p1 [1]int32, p2 [0]int32, p3 [1][1]int32, p4 [2]int32)
// (r1 [2]int32, r2 [1]int32, r3 [0]int32, r4 [1][1]int32) {
i32 := types.Types[types.TINT32]
ae := types.NewArray(i32, 0)
a1 := types.NewArray(i32, 1)
a2 := types.NewArray(i32, 2)
aa1 := types.NewArray(a1, 1)
ft := mkFuncType(nil, []*types.Type{a1, ae, aa1, a2},
[]*types.Type{a2, a1, ae, aa1})
exp := makeExpectedDump(`
IN 0: R{ I0 } spilloffset: 0 typ: [1]int32
IN 1: R{ } offset: 0 typ: [0]int32
IN 2: R{ I1 } spilloffset: 4 typ: [1][1]int32
IN 3: R{ } offset: 0 typ: [2]int32
OUT 0: R{ } offset: 8 typ: [2]int32
OUT 1: R{ I0 } spilloffset: -1 typ: [1]int32
OUT 2: R{ } offset: 16 typ: [0]int32
OUT 3: R{ I1 } spilloffset: -1 typ: [1][1]int32
offsetToSpillArea: 16 spillAreaSize: 8
`)
abitest(t, ft, exp)
}
func TestABIUtilsStruct1(t *testing.T) {
// type s struct { f1 int8; f2 int8; f3 struct {}; f4 int8; f5 int16) }
// func(p1 int6, p2 s, p3 int64)
// (r1 s, r2 int8, r3 int32) {
i8 := types.Types[types.TINT8]
i16 := types.Types[types.TINT16]
i32 := types.Types[types.TINT32]
i64 := types.Types[types.TINT64]
s := mkstruct(i8, i8, mkstruct(), i8, i16)
ft := mkFuncType(nil, []*types.Type{i8, s, i64},
[]*types.Type{s, i8, i32})
exp := makeExpectedDump(`
IN 0: R{ I0 } spilloffset: 0 typ: int8
IN 1: R{ I1 I2 I3 I4 } spilloffset: 2 typ: struct { int8; int8; struct {}; int8; int16 }
IN 2: R{ I5 } spilloffset: 8 typ: int64
OUT 0: R{ I0 I1 I2 I3 } spilloffset: -1 typ: struct { int8; int8; struct {}; int8; int16 }
OUT 1: R{ I4 } spilloffset: -1 typ: int8
OUT 2: R{ I5 } spilloffset: -1 typ: int32
offsetToSpillArea: 0 spillAreaSize: 16
`)
abitest(t, ft, exp)
}
func TestABIUtilsStruct2(t *testing.T) {
// type s struct { f1 int64; f2 struct { } }
// type fs struct { f1 float64; f2 s; f3 struct { } }
// func(p1 s, p2 s, p3 fs)
// (r1 fs, r2 fs)
f64 := types.Types[types.TFLOAT64]
i64 := types.Types[types.TINT64]
s := mkstruct(i64, mkstruct())
fs := mkstruct(f64, s, mkstruct())
ft := mkFuncType(nil, []*types.Type{s, s, fs},
[]*types.Type{fs, fs})
exp := makeExpectedDump(`
IN 0: R{ I0 } spilloffset: 0 typ: struct { int64; struct {} }
IN 1: R{ I1 } spilloffset: 16 typ: struct { int64; struct {} }
IN 2: R{ F0 I2 } spilloffset: 32 typ: struct { float64; struct { int64; struct {} }; struct {} }
OUT 0: R{ F0 I0 } spilloffset: -1 typ: struct { float64; struct { int64; struct {} }; struct {} }
OUT 1: R{ F1 I1 } spilloffset: -1 typ: struct { float64; struct { int64; struct {} }; struct {} }
offsetToSpillArea: 0 spillAreaSize: 64
`)
abitest(t, ft, exp)
}
// TestABIUtilsEmptyFieldAtEndOfStruct is testing to make sure
// the abi code is doing the right thing for struct types that have
// a trailing zero-sized field (where the we need to add padding).
func TestABIUtilsEmptyFieldAtEndOfStruct(t *testing.T) {
// type s struct { f1 [2]int64; f2 struct { } }
// type s2 struct { f1 [3]int16; f2 struct { } }
// type fs struct { f1 float64; f s; f3 struct { } }
// func(p1 s, p2 s, p3 fs) (r1 fs, r2 fs)
f64 := types.Types[types.TFLOAT64]
i64 := types.Types[types.TINT64]
i16 := types.Types[types.TINT16]
tb := types.Types[types.TBOOL]
ab2 := types.NewArray(tb, 2)
a2 := types.NewArray(i64, 2)
a3 := types.NewArray(i16, 3)
empty := mkstruct()
s := mkstruct(a2, empty)
s2 := mkstruct(a3, empty)
fs := mkstruct(f64, s, empty)
ft := mkFuncType(nil, []*types.Type{s, ab2, s2, fs, fs},
[]*types.Type{fs, ab2, fs})
exp := makeExpectedDump(`
IN 0: R{ } offset: 0 typ: struct { [2]int64; struct {} }
IN 1: R{ } offset: 24 typ: [2]bool
IN 2: R{ } offset: 26 typ: struct { [3]int16; struct {} }
IN 3: R{ } offset: 40 typ: struct { float64; struct { [2]int64; struct {} }; struct {} }
IN 4: R{ } offset: 80 typ: struct { float64; struct { [2]int64; struct {} }; struct {} }
OUT 0: R{ } offset: 120 typ: struct { float64; struct { [2]int64; struct {} }; struct {} }
OUT 1: R{ } offset: 160 typ: [2]bool
OUT 2: R{ } offset: 168 typ: struct { float64; struct { [2]int64; struct {} }; struct {} }
offsetToSpillArea: 208 spillAreaSize: 0
`)
abitest(t, ft, exp)
// Test that NumParamRegs doesn't assign registers to trailing padding.
typ := mkstruct(i64, i64, mkstruct())
have := configAMD64.NumParamRegs(typ)
if have != 2 {
t.Errorf("NumParams(%v): have %v, want %v", typ, have, 2)
}
}
func TestABIUtilsSliceString(t *testing.T) {
// func(p1 []int32, p2 int8, p3 []int32, p4 int8, p5 string,
// p6 int64, p6 []intr32) (r1 string, r2 int64, r3 string, r4 []int32)
i32 := types.Types[types.TINT32]
sli32 := types.NewSlice(i32)
str := types.Types[types.TSTRING]
i8 := types.Types[types.TINT8]
i64 := types.Types[types.TINT64]
ft := mkFuncType(nil, []*types.Type{sli32, i8, sli32, i8, str, i8, i64, sli32},
[]*types.Type{str, i64, str, sli32})
exp := makeExpectedDump(`
IN 0: R{ I0 I1 I2 } spilloffset: 0 typ: []int32
IN 1: R{ I3 } spilloffset: 24 typ: int8
IN 2: R{ I4 I5 I6 } spilloffset: 32 typ: []int32
IN 3: R{ I7 } spilloffset: 56 typ: int8
IN 4: R{ } offset: 0 typ: string
IN 5: R{ I8 } spilloffset: 57 typ: int8
IN 6: R{ } offset: 16 typ: int64
IN 7: R{ } offset: 24 typ: []int32
OUT 0: R{ I0 I1 } spilloffset: -1 typ: string
OUT 1: R{ I2 } spilloffset: -1 typ: int64
OUT 2: R{ I3 I4 } spilloffset: -1 typ: string
OUT 3: R{ I5 I6 I7 } spilloffset: -1 typ: []int32
offsetToSpillArea: 48 spillAreaSize: 64
`)
abitest(t, ft, exp)
}
func TestABIUtilsMethod(t *testing.T) {
// type s1 struct { f1 int16; f2 int16; f3 int16 }
// func(p1 *s1, p2 [7]*s1, p3 float64, p4 int16, p5 int16, p6 int16)
// (r1 [7]*s1, r2 float64, r3 int64)
i16 := types.Types[types.TINT16]
i64 := types.Types[types.TINT64]
f64 := types.Types[types.TFLOAT64]
s1 := mkstruct(i16, i16, i16)
ps1 := types.NewPtr(s1)
a7 := types.NewArray(ps1, 7)
ft := mkFuncType(s1, []*types.Type{ps1, a7, f64, i16, i16, i16},
[]*types.Type{a7, f64, i64})
exp := makeExpectedDump(`
IN 0: R{ I0 I1 I2 } spilloffset: 0 typ: struct { int16; int16; int16 }
IN 1: R{ I3 } spilloffset: 8 typ: *struct { int16; int16; int16 }
IN 2: R{ } offset: 0 typ: [7]*struct { int16; int16; int16 }
IN 3: R{ F0 } spilloffset: 16 typ: float64
IN 4: R{ I4 } spilloffset: 24 typ: int16
IN 5: R{ I5 } spilloffset: 26 typ: int16
IN 6: R{ I6 } spilloffset: 28 typ: int16
OUT 0: R{ } offset: 56 typ: [7]*struct { int16; int16; int16 }
OUT 1: R{ F0 } spilloffset: -1 typ: float64
OUT 2: R{ I0 } spilloffset: -1 typ: int64
offsetToSpillArea: 112 spillAreaSize: 32
`)
abitest(t, ft, exp)
}
func TestABIUtilsInterfaces(t *testing.T) {
// type s1 { f1 int16; f2 int16; f3 bool)
// type nei interface { ...() string }
// func(p1 s1, p2 interface{}, p3 interface{}, p4 nei,
// p5 *interface{}, p6 nei, p7 int64)
// (r1 interface{}, r2 nei, r3 bool)
ei := types.Types[types.TINTER] // interface{}
pei := types.NewPtr(ei) // *interface{}
fldt := mkFuncType(types.FakeRecvType(), []*types.Type{},
[]*types.Type{types.Types[types.TSTRING]})
field := types.NewField(src.NoXPos, typecheck.Lookup("F"), fldt)
nei := types.NewInterface([]*types.Field{field})
i16 := types.Types[types.TINT16]
tb := types.Types[types.TBOOL]
s1 := mkstruct(i16, i16, tb)
ft := mkFuncType(nil, []*types.Type{s1, ei, ei, nei, pei, nei, i16},
[]*types.Type{ei, nei, pei})
exp := makeExpectedDump(`
IN 0: R{ I0 I1 I2 } spilloffset: 0 typ: struct { int16; int16; bool }
IN 1: R{ I3 I4 } spilloffset: 8 typ: interface {}
IN 2: R{ I5 I6 } spilloffset: 24 typ: interface {}
IN 3: R{ I7 I8 } spilloffset: 40 typ: interface { F() string }
IN 4: R{ } offset: 0 typ: *interface {}
IN 5: R{ } offset: 8 typ: interface { F() string }
IN 6: R{ } offset: 24 typ: int16
OUT 0: R{ I0 I1 } spilloffset: -1 typ: interface {}
OUT 1: R{ I2 I3 } spilloffset: -1 typ: interface { F() string }
OUT 2: R{ I4 } spilloffset: -1 typ: *interface {}
offsetToSpillArea: 32 spillAreaSize: 56
`)
abitest(t, ft, exp)
}
func TestABINumParamRegs(t *testing.T) {
i8 := types.Types[types.TINT8]
i16 := types.Types[types.TINT16]
i32 := types.Types[types.TINT32]
i64 := types.Types[types.TINT64]
f32 := types.Types[types.TFLOAT32]
f64 := types.Types[types.TFLOAT64]
c64 := types.Types[types.TCOMPLEX64]
c128 := types.Types[types.TCOMPLEX128]
s := mkstruct(i8, i8, mkstruct(), i8, i16)
a := mkstruct(s, s, s)
nrtest(t, i8, 1)
nrtest(t, i16, 1)
nrtest(t, i32, 1)
nrtest(t, i64, 1)
nrtest(t, f32, 1)
nrtest(t, f64, 1)
nrtest(t, c64, 2)
nrtest(t, c128, 2)
nrtest(t, s, 4)
nrtest(t, a, 12)
}
func TestABIUtilsComputePadding(t *testing.T) {
// type s1 { f1 int8; f2 int16; f3 struct{}; f4 int32; f5 int64 }
i8 := types.Types[types.TINT8]
i16 := types.Types[types.TINT16]
i32 := types.Types[types.TINT32]
i64 := types.Types[types.TINT64]
emptys := mkstruct()
s1 := mkstruct(i8, i16, emptys, i32, i64)
// func (p1 int32, p2 s1, p3 emptys, p4 [1]int32)
a1 := types.NewArray(i32, 1)
ft := mkFuncType(nil, []*types.Type{i32, s1, emptys, a1}, nil)
// Run abitest() just to document what we're expected to see.
exp := makeExpectedDump(`
IN 0: R{ I0 } spilloffset: 0 typ: int32
IN 1: R{ I1 I2 I3 I4 } spilloffset: 8 typ: struct { int8; int16; struct {}; int32; int64 }
IN 2: R{ } offset: 0 typ: struct {}
IN 3: R{ I5 } spilloffset: 24 typ: [1]int32
offsetToSpillArea: 0 spillAreaSize: 32
`)
abitest(t, ft, exp)
// Analyze with full set of registers, then call ComputePadding
// on the second param, verifying the results.
regRes := configAMD64.ABIAnalyze(ft, false)
padding := make([]uint64, 32)
parm := regRes.InParams()[1]
padding = parm.ComputePadding(padding)
want := "[1 1 1 0]"
got := fmt.Sprintf("%+v", padding)
if got != want {
t.Errorf("padding mismatch: wanted %q got %q\n", got, want)
}
}
|
go/src/cmd/compile/internal/test/abiutils_test.go/0
|
{
"file_path": "go/src/cmd/compile/internal/test/abiutils_test.go",
"repo_id": "go",
"token_count": 6754
}
| 110 |
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build !race
package test
import (
"internal/testenv"
"testing"
)
func TestAppendOfMake(t *testing.T) {
testenv.SkipIfOptimizationOff(t)
for n := 32; n < 33; n++ { // avoid stack allocation of make()
b := make([]byte, n)
f := func() {
b = append(b[:0], make([]byte, n)...)
}
if n := testing.AllocsPerRun(10, f); n > 0 {
t.Errorf("got %f allocs, want 0", n)
}
type S []byte
s := make(S, n)
g := func() {
s = append(s[:0], make(S, n)...)
}
if n := testing.AllocsPerRun(10, g); n > 0 {
t.Errorf("got %f allocs, want 0", n)
}
h := func() {
s = append(s[:0], make([]byte, n)...)
}
if n := testing.AllocsPerRun(10, h); n > 0 {
t.Errorf("got %f allocs, want 0", n)
}
i := func() {
b = append(b[:0], make(S, n)...)
}
if n := testing.AllocsPerRun(10, i); n > 0 {
t.Errorf("got %f allocs, want 0", n)
}
}
}
|
go/src/cmd/compile/internal/test/issue53888_test.go/0
|
{
"file_path": "go/src/cmd/compile/internal/test/issue53888_test.go",
"repo_id": "go",
"token_count": 471
}
| 111 |
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"fmt"
"testing"
)
var output string
func mypanic(t *testing.T, s string) {
t.Fatalf(s + "\n" + output)
}
func assertEqual(t *testing.T, x, y int) {
if x != y {
mypanic(t, fmt.Sprintf("assertEqual failed got %d, want %d", x, y))
}
}
func TestAddressed(t *testing.T) {
x := f1_ssa(2, 3)
output += fmt.Sprintln("*x is", *x)
output += fmt.Sprintln("Gratuitously use some stack")
output += fmt.Sprintln("*x is", *x)
assertEqual(t, *x, 9)
w := f3a_ssa(6)
output += fmt.Sprintln("*w is", *w)
output += fmt.Sprintln("Gratuitously use some stack")
output += fmt.Sprintln("*w is", *w)
assertEqual(t, *w, 6)
y := f3b_ssa(12)
output += fmt.Sprintln("*y.(*int) is", *y.(*int))
output += fmt.Sprintln("Gratuitously use some stack")
output += fmt.Sprintln("*y.(*int) is", *y.(*int))
assertEqual(t, *y.(*int), 12)
z := f3c_ssa(8)
output += fmt.Sprintln("*z.(*int) is", *z.(*int))
output += fmt.Sprintln("Gratuitously use some stack")
output += fmt.Sprintln("*z.(*int) is", *z.(*int))
assertEqual(t, *z.(*int), 8)
args(t)
test_autos(t)
}
//go:noinline
func f1_ssa(x, y int) *int {
x = x*y + y
return &x
}
//go:noinline
func f3a_ssa(x int) *int {
return &x
}
//go:noinline
func f3b_ssa(x int) interface{} { // ./foo.go:15: internal error: f3b_ssa ~r1 (type interface {}) recorded as live on entry
return &x
}
//go:noinline
func f3c_ssa(y int) interface{} {
x := y
return &x
}
type V struct {
p *V
w, x int64
}
func args(t *testing.T) {
v := V{p: nil, w: 1, x: 1}
a := V{p: &v, w: 2, x: 2}
b := V{p: &v, w: 0, x: 0}
i := v.args_ssa(a, b)
output += fmt.Sprintln("i=", i)
assertEqual(t, int(i), 2)
}
//go:noinline
func (v V) args_ssa(a, b V) int64 {
if v.w == 0 {
return v.x
}
if v.w == 1 {
return a.x
}
if v.w == 2 {
return b.x
}
b.p.p = &a // v.p in caller = &a
return -1
}
func test_autos(t *testing.T) {
test(t, 11)
test(t, 12)
test(t, 13)
test(t, 21)
test(t, 22)
test(t, 23)
test(t, 31)
test(t, 32)
}
func test(t *testing.T, which int64) {
output += fmt.Sprintln("test", which)
v1 := V{w: 30, x: 3, p: nil}
v2, v3 := v1.autos_ssa(which, 10, 1, 20, 2)
if which != v2.val() {
output += fmt.Sprintln("Expected which=", which, "got v2.val()=", v2.val())
mypanic(t, "Failure of expected V value")
}
if v2.p.val() != v3.val() {
output += fmt.Sprintln("Expected v2.p.val()=", v2.p.val(), "got v3.val()=", v3.val())
mypanic(t, "Failure of expected V.p value")
}
if which != v3.p.p.p.p.p.p.p.val() {
output += fmt.Sprintln("Expected which=", which, "got v3.p.p.p.p.p.p.p.val()=", v3.p.p.p.p.p.p.p.val())
mypanic(t, "Failure of expected V.p value")
}
}
func (v V) val() int64 {
return v.w + v.x
}
// autos_ssa uses contents of v and parameters w1, w2, x1, x2
// to initialize a bunch of locals, all of which have their
// address taken to force heap allocation, and then based on
// the value of which a pair of those locals are copied in
// various ways to the two results y, and z, which are also
// addressed. Which is expected to be one of 11-13, 21-23, 31, 32,
// and y.val() should be equal to which and y.p.val() should
// be equal to z.val(). Also, x(.p)**8 == x; that is, the
// autos are all linked into a ring.
//
//go:noinline
func (v V) autos_ssa(which, w1, x1, w2, x2 int64) (y, z V) {
fill_ssa(v.w, v.x, &v, v.p) // gratuitous no-op to force addressing
var a, b, c, d, e, f, g, h V
fill_ssa(w1, x1, &a, &b)
fill_ssa(w1, x2, &b, &c)
fill_ssa(w1, v.x, &c, &d)
fill_ssa(w2, x1, &d, &e)
fill_ssa(w2, x2, &e, &f)
fill_ssa(w2, v.x, &f, &g)
fill_ssa(v.w, x1, &g, &h)
fill_ssa(v.w, x2, &h, &a)
switch which {
case 11:
y = a
z.getsI(&b)
case 12:
y.gets(&b)
z = c
case 13:
y.gets(&c)
z = d
case 21:
y.getsI(&d)
z.gets(&e)
case 22:
y = e
z = f
case 23:
y.gets(&f)
z.getsI(&g)
case 31:
y = g
z.gets(&h)
case 32:
y.getsI(&h)
z = a
default:
panic("")
}
return
}
// gets is an address-mentioning way of implementing
// structure assignment.
//
//go:noinline
func (to *V) gets(from *V) {
*to = *from
}
// gets is an address-and-interface-mentioning way of
// implementing structure assignment.
//
//go:noinline
func (to *V) getsI(from interface{}) {
*to = *from.(*V)
}
// fill_ssa initializes r with V{w:w, x:x, p:p}
//
//go:noinline
func fill_ssa(w, x int64, r, p *V) {
*r = V{w: w, x: x, p: p}
}
|
go/src/cmd/compile/internal/test/testdata/addressed_test.go/0
|
{
"file_path": "go/src/cmd/compile/internal/test/testdata/addressed_test.go",
"repo_id": "go",
"token_count": 2140
}
| 112 |
package main
import (
"runtime"
"testing"
)
func checkDivByZero(f func()) (divByZero bool) {
defer func() {
if r := recover(); r != nil {
if e, ok := r.(runtime.Error); ok && e.Error() == "runtime error: integer divide by zero" {
divByZero = true
}
}
}()
f()
return false
}
//go:noinline
func div_a(i uint, s []int) int {
return s[i%uint(len(s))]
}
//go:noinline
func div_b(i uint, j uint) uint {
return i / j
}
//go:noinline
func div_c(i int) int {
return 7 / (i - i)
}
func TestDivByZero(t *testing.T) {
if got := checkDivByZero(func() { div_b(7, 0) }); !got {
t.Errorf("expected div by zero for b(7, 0), got no error\n")
}
if got := checkDivByZero(func() { div_b(7, 7) }); got {
t.Errorf("expected no error for b(7, 7), got div by zero\n")
}
if got := checkDivByZero(func() { div_a(4, nil) }); !got {
t.Errorf("expected div by zero for a(4, nil), got no error\n")
}
if got := checkDivByZero(func() { div_c(5) }); !got {
t.Errorf("expected div by zero for c(5), got no error\n")
}
}
|
go/src/cmd/compile/internal/test/testdata/divbyzero_test.go/0
|
{
"file_path": "go/src/cmd/compile/internal/test/testdata/divbyzero_test.go",
"repo_id": "go",
"token_count": 442
}
| 113 |
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Tests short circuiting.
package main
import "testing"
func and_ssa(arg1, arg2 bool) bool {
return arg1 && rightCall(arg2)
}
func or_ssa(arg1, arg2 bool) bool {
return arg1 || rightCall(arg2)
}
var rightCalled bool
//go:noinline
func rightCall(v bool) bool {
rightCalled = true
return v
panic("unreached")
}
func testAnd(t *testing.T, arg1, arg2, wantRes bool) {
testShortCircuit(t, "AND", arg1, arg2, and_ssa, arg1, wantRes)
}
func testOr(t *testing.T, arg1, arg2, wantRes bool) {
testShortCircuit(t, "OR", arg1, arg2, or_ssa, !arg1, wantRes)
}
func testShortCircuit(t *testing.T, opName string, arg1, arg2 bool, fn func(bool, bool) bool, wantRightCall, wantRes bool) {
rightCalled = false
got := fn(arg1, arg2)
if rightCalled != wantRightCall {
t.Errorf("failed for %t %s %t; rightCalled=%t want=%t", arg1, opName, arg2, rightCalled, wantRightCall)
}
if wantRes != got {
t.Errorf("failed for %t %s %t; res=%t want=%t", arg1, opName, arg2, got, wantRes)
}
}
// TestShortCircuit tests OANDAND and OOROR expressions and short circuiting.
func TestShortCircuit(t *testing.T) {
testAnd(t, false, false, false)
testAnd(t, false, true, false)
testAnd(t, true, false, false)
testAnd(t, true, true, true)
testOr(t, false, false, false)
testOr(t, false, true, true)
testOr(t, true, false, true)
testOr(t, true, true, true)
}
|
go/src/cmd/compile/internal/test/testdata/short_test.go/0
|
{
"file_path": "go/src/cmd/compile/internal/test/testdata/short_test.go",
"repo_id": "go",
"token_count": 590
}
| 114 |
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package typecheck
import (
"cmd/compile/internal/base"
"cmd/compile/internal/ir"
"cmd/compile/internal/types"
"cmd/internal/src"
)
// importfunc declares symbol s as an imported function with type t.
func importfunc(s *types.Sym, t *types.Type) {
fn := ir.NewFunc(src.NoXPos, src.NoXPos, s, t)
importsym(fn.Nname)
}
// importvar declares symbol s as an imported variable with type t.
func importvar(s *types.Sym, t *types.Type) {
n := ir.NewNameAt(src.NoXPos, s, t)
n.Class = ir.PEXTERN
importsym(n)
}
func importsym(name *ir.Name) {
sym := name.Sym()
if sym.Def != nil {
base.Fatalf("importsym of symbol that already exists: %v", sym.Def)
}
sym.Def = name
}
|
go/src/cmd/compile/internal/typecheck/export.go/0
|
{
"file_path": "go/src/cmd/compile/internal/typecheck/export.go",
"repo_id": "go",
"token_count": 307
}
| 115 |
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package types
import (
"fmt"
"internal/goversion"
"internal/lazyregexp"
"log"
"strconv"
"cmd/compile/internal/base"
)
// A lang is a language version broken into major and minor numbers.
type lang struct {
major, minor int
}
// langWant is the desired language version set by the -lang flag.
// If the -lang flag is not set, this is the zero value, meaning that
// any language version is supported.
var langWant lang
// AllowsGoVersion reports whether local package is allowed
// to use Go version major.minor.
func AllowsGoVersion(major, minor int) bool {
if langWant.major == 0 && langWant.minor == 0 {
return true
}
return langWant.major > major || (langWant.major == major && langWant.minor >= minor)
}
// ParseLangFlag verifies that the -lang flag holds a valid value, and
// exits if not. It initializes data used by AllowsGoVersion.
func ParseLangFlag() {
if base.Flag.Lang == "" {
return
}
var err error
langWant, err = parseLang(base.Flag.Lang)
if err != nil {
log.Fatalf("invalid value %q for -lang: %v", base.Flag.Lang, err)
}
if def := currentLang(); base.Flag.Lang != def {
defVers, err := parseLang(def)
if err != nil {
log.Fatalf("internal error parsing default lang %q: %v", def, err)
}
if langWant.major > defVers.major || (langWant.major == defVers.major && langWant.minor > defVers.minor) {
log.Fatalf("invalid value %q for -lang: max known version is %q", base.Flag.Lang, def)
}
}
}
// parseLang parses a -lang option into a langVer.
func parseLang(s string) (lang, error) {
if s == "go1" { // cmd/go's new spelling of "go1.0" (#65528)
s = "go1.0"
}
matches := goVersionRE.FindStringSubmatch(s)
if matches == nil {
return lang{}, fmt.Errorf(`should be something like "go1.12"`)
}
major, err := strconv.Atoi(matches[1])
if err != nil {
return lang{}, err
}
minor, err := strconv.Atoi(matches[2])
if err != nil {
return lang{}, err
}
return lang{major: major, minor: minor}, nil
}
// currentLang returns the current language version.
func currentLang() string {
return fmt.Sprintf("go1.%d", goversion.Version)
}
// goVersionRE is a regular expression that matches the valid
// arguments to the -lang flag.
var goVersionRE = lazyregexp.New(`^go([1-9]\d*)\.(0|[1-9]\d*)$`)
|
go/src/cmd/compile/internal/types/goversion.go/0
|
{
"file_path": "go/src/cmd/compile/internal/types/goversion.go",
"repo_id": "go",
"token_count": 859
}
| 116 |
// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package types2_test
import (
"cmd/compile/internal/syntax"
"errors"
"fmt"
"internal/goversion"
"internal/testenv"
"reflect"
"regexp"
"sort"
"strings"
"sync"
"testing"
. "cmd/compile/internal/types2"
)
// nopos indicates an unknown position
var nopos syntax.Pos
func mustParse(src string) *syntax.File {
f, err := syntax.Parse(syntax.NewFileBase(pkgName(src)), strings.NewReader(src), nil, nil, 0)
if err != nil {
panic(err) // so we don't need to pass *testing.T
}
return f
}
func typecheck(src string, conf *Config, info *Info) (*Package, error) {
f := mustParse(src)
if conf == nil {
conf = &Config{
Error: func(err error) {}, // collect all errors
Importer: defaultImporter(),
}
}
return conf.Check(f.PkgName.Value, []*syntax.File{f}, info)
}
func mustTypecheck(src string, conf *Config, info *Info) *Package {
pkg, err := typecheck(src, conf, info)
if err != nil {
panic(err) // so we don't need to pass *testing.T
}
return pkg
}
// pkgName extracts the package name from src, which must contain a package header.
func pkgName(src string) string {
const kw = "package "
if i := strings.Index(src, kw); i >= 0 {
after := src[i+len(kw):]
n := len(after)
if i := strings.IndexAny(after, "\n\t ;/"); i >= 0 {
n = i
}
return after[:n]
}
panic("missing package header: " + src)
}
func TestValuesInfo(t *testing.T) {
var tests = []struct {
src string
expr string // constant expression
typ string // constant type
val string // constant value
}{
{`package a0; const _ = false`, `false`, `untyped bool`, `false`},
{`package a1; const _ = 0`, `0`, `untyped int`, `0`},
{`package a2; const _ = 'A'`, `'A'`, `untyped rune`, `65`},
{`package a3; const _ = 0.`, `0.`, `untyped float`, `0`},
{`package a4; const _ = 0i`, `0i`, `untyped complex`, `(0 + 0i)`},
{`package a5; const _ = "foo"`, `"foo"`, `untyped string`, `"foo"`},
{`package b0; var _ = false`, `false`, `bool`, `false`},
{`package b1; var _ = 0`, `0`, `int`, `0`},
{`package b2; var _ = 'A'`, `'A'`, `rune`, `65`},
{`package b3; var _ = 0.`, `0.`, `float64`, `0`},
{`package b4; var _ = 0i`, `0i`, `complex128`, `(0 + 0i)`},
{`package b5; var _ = "foo"`, `"foo"`, `string`, `"foo"`},
{`package c0a; var _ = bool(false)`, `false`, `bool`, `false`},
{`package c0b; var _ = bool(false)`, `bool(false)`, `bool`, `false`},
{`package c0c; type T bool; var _ = T(false)`, `T(false)`, `c0c.T`, `false`},
{`package c1a; var _ = int(0)`, `0`, `int`, `0`},
{`package c1b; var _ = int(0)`, `int(0)`, `int`, `0`},
{`package c1c; type T int; var _ = T(0)`, `T(0)`, `c1c.T`, `0`},
{`package c2a; var _ = rune('A')`, `'A'`, `rune`, `65`},
{`package c2b; var _ = rune('A')`, `rune('A')`, `rune`, `65`},
{`package c2c; type T rune; var _ = T('A')`, `T('A')`, `c2c.T`, `65`},
{`package c3a; var _ = float32(0.)`, `0.`, `float32`, `0`},
{`package c3b; var _ = float32(0.)`, `float32(0.)`, `float32`, `0`},
{`package c3c; type T float32; var _ = T(0.)`, `T(0.)`, `c3c.T`, `0`},
{`package c4a; var _ = complex64(0i)`, `0i`, `complex64`, `(0 + 0i)`},
{`package c4b; var _ = complex64(0i)`, `complex64(0i)`, `complex64`, `(0 + 0i)`},
{`package c4c; type T complex64; var _ = T(0i)`, `T(0i)`, `c4c.T`, `(0 + 0i)`},
{`package c5a; var _ = string("foo")`, `"foo"`, `string`, `"foo"`},
{`package c5b; var _ = string("foo")`, `string("foo")`, `string`, `"foo"`},
{`package c5c; type T string; var _ = T("foo")`, `T("foo")`, `c5c.T`, `"foo"`},
{`package c5d; var _ = string(65)`, `65`, `untyped int`, `65`},
{`package c5e; var _ = string('A')`, `'A'`, `untyped rune`, `65`},
{`package c5f; type T string; var _ = T('A')`, `'A'`, `untyped rune`, `65`},
{`package d0; var _ = []byte("foo")`, `"foo"`, `string`, `"foo"`},
{`package d1; var _ = []byte(string("foo"))`, `"foo"`, `string`, `"foo"`},
{`package d2; var _ = []byte(string("foo"))`, `string("foo")`, `string`, `"foo"`},
{`package d3; type T []byte; var _ = T("foo")`, `"foo"`, `string`, `"foo"`},
{`package e0; const _ = float32( 1e-200)`, `float32(1e-200)`, `float32`, `0`},
{`package e1; const _ = float32(-1e-200)`, `float32(-1e-200)`, `float32`, `0`},
{`package e2; const _ = float64( 1e-2000)`, `float64(1e-2000)`, `float64`, `0`},
{`package e3; const _ = float64(-1e-2000)`, `float64(-1e-2000)`, `float64`, `0`},
{`package e4; const _ = complex64( 1e-200)`, `complex64(1e-200)`, `complex64`, `(0 + 0i)`},
{`package e5; const _ = complex64(-1e-200)`, `complex64(-1e-200)`, `complex64`, `(0 + 0i)`},
{`package e6; const _ = complex128( 1e-2000)`, `complex128(1e-2000)`, `complex128`, `(0 + 0i)`},
{`package e7; const _ = complex128(-1e-2000)`, `complex128(-1e-2000)`, `complex128`, `(0 + 0i)`},
{`package f0 ; var _ float32 = 1e-200`, `1e-200`, `float32`, `0`},
{`package f1 ; var _ float32 = -1e-200`, `-1e-200`, `float32`, `0`},
{`package f2a; var _ float64 = 1e-2000`, `1e-2000`, `float64`, `0`},
{`package f3a; var _ float64 = -1e-2000`, `-1e-2000`, `float64`, `0`},
{`package f2b; var _ = 1e-2000`, `1e-2000`, `float64`, `0`},
{`package f3b; var _ = -1e-2000`, `-1e-2000`, `float64`, `0`},
{`package f4 ; var _ complex64 = 1e-200 `, `1e-200`, `complex64`, `(0 + 0i)`},
{`package f5 ; var _ complex64 = -1e-200 `, `-1e-200`, `complex64`, `(0 + 0i)`},
{`package f6a; var _ complex128 = 1e-2000i`, `1e-2000i`, `complex128`, `(0 + 0i)`},
{`package f7a; var _ complex128 = -1e-2000i`, `-1e-2000i`, `complex128`, `(0 + 0i)`},
{`package f6b; var _ = 1e-2000i`, `1e-2000i`, `complex128`, `(0 + 0i)`},
{`package f7b; var _ = -1e-2000i`, `-1e-2000i`, `complex128`, `(0 + 0i)`},
{`package g0; const (a = len([iota]int{}); b; c); const _ = c`, `c`, `int`, `2`}, // go.dev/issue/22341
{`package g1; var(j int32; s int; n = 1.0<<s == j)`, `1.0`, `int32`, `1`}, // go.dev/issue/48422
}
for _, test := range tests {
info := Info{
Types: make(map[syntax.Expr]TypeAndValue),
}
name := mustTypecheck(test.src, nil, &info).Name()
// look for expression
var expr syntax.Expr
for e := range info.Types {
if ExprString(e) == test.expr {
expr = e
break
}
}
if expr == nil {
t.Errorf("package %s: no expression found for %s", name, test.expr)
continue
}
tv := info.Types[expr]
// check that type is correct
if got := tv.Type.String(); got != test.typ {
t.Errorf("package %s: got type %s; want %s", name, got, test.typ)
continue
}
// if we have a constant, check that value is correct
if tv.Value != nil {
if got := tv.Value.ExactString(); got != test.val {
t.Errorf("package %s: got value %s; want %s", name, got, test.val)
}
} else {
if test.val != "" {
t.Errorf("package %s: no constant found; want %s", name, test.val)
}
}
}
}
func TestTypesInfo(t *testing.T) {
// Test sources that are not expected to typecheck must start with the broken prefix.
const brokenPkg = "package broken_"
var tests = []struct {
src string
expr string // expression
typ string // value type
}{
// single-valued expressions of untyped constants
{`package b0; var x interface{} = false`, `false`, `bool`},
{`package b1; var x interface{} = 0`, `0`, `int`},
{`package b2; var x interface{} = 0.`, `0.`, `float64`},
{`package b3; var x interface{} = 0i`, `0i`, `complex128`},
{`package b4; var x interface{} = "foo"`, `"foo"`, `string`},
// uses of nil
{`package n0; var _ *int = nil`, `nil`, `*int`},
{`package n1; var _ func() = nil`, `nil`, `func()`},
{`package n2; var _ []byte = nil`, `nil`, `[]byte`},
{`package n3; var _ map[int]int = nil`, `nil`, `map[int]int`},
{`package n4; var _ chan int = nil`, `nil`, `chan int`},
{`package n5a; var _ interface{} = (*int)(nil)`, `nil`, `*int`},
{`package n5b; var _ interface{m()} = nil`, `nil`, `interface{m()}`},
{`package n6; import "unsafe"; var _ unsafe.Pointer = nil`, `nil`, `unsafe.Pointer`},
{`package n10; var (x *int; _ = x == nil)`, `nil`, `*int`},
{`package n11; var (x func(); _ = x == nil)`, `nil`, `func()`},
{`package n12; var (x []byte; _ = x == nil)`, `nil`, `[]byte`},
{`package n13; var (x map[int]int; _ = x == nil)`, `nil`, `map[int]int`},
{`package n14; var (x chan int; _ = x == nil)`, `nil`, `chan int`},
{`package n15a; var (x interface{}; _ = x == (*int)(nil))`, `nil`, `*int`},
{`package n15b; var (x interface{m()}; _ = x == nil)`, `nil`, `interface{m()}`},
{`package n15; import "unsafe"; var (x unsafe.Pointer; _ = x == nil)`, `nil`, `unsafe.Pointer`},
{`package n20; var _ = (*int)(nil)`, `nil`, `*int`},
{`package n21; var _ = (func())(nil)`, `nil`, `func()`},
{`package n22; var _ = ([]byte)(nil)`, `nil`, `[]byte`},
{`package n23; var _ = (map[int]int)(nil)`, `nil`, `map[int]int`},
{`package n24; var _ = (chan int)(nil)`, `nil`, `chan int`},
{`package n25a; var _ = (interface{})((*int)(nil))`, `nil`, `*int`},
{`package n25b; var _ = (interface{m()})(nil)`, `nil`, `interface{m()}`},
{`package n26; import "unsafe"; var _ = unsafe.Pointer(nil)`, `nil`, `unsafe.Pointer`},
{`package n30; func f(*int) { f(nil) }`, `nil`, `*int`},
{`package n31; func f(func()) { f(nil) }`, `nil`, `func()`},
{`package n32; func f([]byte) { f(nil) }`, `nil`, `[]byte`},
{`package n33; func f(map[int]int) { f(nil) }`, `nil`, `map[int]int`},
{`package n34; func f(chan int) { f(nil) }`, `nil`, `chan int`},
{`package n35a; func f(interface{}) { f((*int)(nil)) }`, `nil`, `*int`},
{`package n35b; func f(interface{m()}) { f(nil) }`, `nil`, `interface{m()}`},
{`package n35; import "unsafe"; func f(unsafe.Pointer) { f(nil) }`, `nil`, `unsafe.Pointer`},
// comma-ok expressions
{`package p0; var x interface{}; var _, _ = x.(int)`,
`x.(int)`,
`(int, bool)`,
},
{`package p1; var x interface{}; func _() { _, _ = x.(int) }`,
`x.(int)`,
`(int, bool)`,
},
{`package p2a; type mybool bool; var m map[string]complex128; var b mybool; func _() { _, b = m["foo"] }`,
`m["foo"]`,
`(complex128, p2a.mybool)`,
},
{`package p2b; var m map[string]complex128; var b bool; func _() { _, b = m["foo"] }`,
`m["foo"]`,
`(complex128, bool)`,
},
{`package p3; var c chan string; var _, _ = <-c`,
`<-c`,
`(string, bool)`,
},
// go.dev/issue/6796
{`package issue6796_a; var x interface{}; var _, _ = (x.(int))`,
`x.(int)`,
`(int, bool)`,
},
{`package issue6796_b; var c chan string; var _, _ = (<-c)`,
`(<-c)`,
`(string, bool)`,
},
{`package issue6796_c; var c chan string; var _, _ = (<-c)`,
`<-c`,
`(string, bool)`,
},
{`package issue6796_d; var c chan string; var _, _ = ((<-c))`,
`(<-c)`,
`(string, bool)`,
},
{`package issue6796_e; func f(c chan string) { _, _ = ((<-c)) }`,
`(<-c)`,
`(string, bool)`,
},
// go.dev/issue/7060
{`package issue7060_a; var ( m map[int]string; x, ok = m[0] )`,
`m[0]`,
`(string, bool)`,
},
{`package issue7060_b; var ( m map[int]string; x, ok interface{} = m[0] )`,
`m[0]`,
`(string, bool)`,
},
{`package issue7060_c; func f(x interface{}, ok bool, m map[int]string) { x, ok = m[0] }`,
`m[0]`,
`(string, bool)`,
},
{`package issue7060_d; var ( ch chan string; x, ok = <-ch )`,
`<-ch`,
`(string, bool)`,
},
{`package issue7060_e; var ( ch chan string; x, ok interface{} = <-ch )`,
`<-ch`,
`(string, bool)`,
},
{`package issue7060_f; func f(x interface{}, ok bool, ch chan string) { x, ok = <-ch }`,
`<-ch`,
`(string, bool)`,
},
// go.dev/issue/28277
{`package issue28277_a; func f(...int)`,
`...int`,
`[]int`,
},
{`package issue28277_b; func f(a, b int, c ...[]struct{})`,
`...[]struct{}`,
`[][]struct{}`,
},
// go.dev/issue/47243
{`package issue47243_a; var x int32; var _ = x << 3`, `3`, `untyped int`},
{`package issue47243_b; var x int32; var _ = x << 3.`, `3.`, `untyped float`},
{`package issue47243_c; var x int32; var _ = 1 << x`, `1 << x`, `int`},
{`package issue47243_d; var x int32; var _ = 1 << x`, `1`, `int`},
{`package issue47243_e; var x int32; var _ = 1 << 2`, `1`, `untyped int`},
{`package issue47243_f; var x int32; var _ = 1 << 2`, `2`, `untyped int`},
{`package issue47243_g; var x int32; var _ = int(1) << 2`, `2`, `untyped int`},
{`package issue47243_h; var x int32; var _ = 1 << (2 << x)`, `1`, `int`},
{`package issue47243_i; var x int32; var _ = 1 << (2 << x)`, `(2 << x)`, `untyped int`},
{`package issue47243_j; var x int32; var _ = 1 << (2 << x)`, `2`, `untyped int`},
// tests for broken code that doesn't type-check
{brokenPkg + `x0; func _() { var x struct {f string}; x.f := 0 }`, `x.f`, `string`},
{brokenPkg + `x1; func _() { var z string; type x struct {f string}; y := &x{q: z}}`, `z`, `string`},
{brokenPkg + `x2; func _() { var a, b string; type x struct {f string}; z := &x{f: a, f: b,}}`, `b`, `string`},
{brokenPkg + `x3; var x = panic("");`, `panic`, `func(interface{})`},
{`package x4; func _() { panic("") }`, `panic`, `func(interface{})`},
{brokenPkg + `x5; func _() { var x map[string][...]int; x = map[string][...]int{"": {1,2,3}} }`, `x`, `map[string]invalid type`},
// parameterized functions
{`package p0; func f[T any](T) {}; var _ = f[int]`, `f`, `func[T any](T)`},
{`package p1; func f[T any](T) {}; var _ = f[int]`, `f[int]`, `func(int)`},
{`package p2; func f[T any](T) {}; func _() { f(42) }`, `f`, `func(int)`},
{`package p3; func f[T any](T) {}; func _() { f[int](42) }`, `f[int]`, `func(int)`},
{`package p4; func f[T any](T) {}; func _() { f[int](42) }`, `f`, `func[T any](T)`},
{`package p5; func f[T any](T) {}; func _() { f(42) }`, `f(42)`, `()`},
// type parameters
{`package t0; type t[] int; var _ t`, `t`, `t0.t`}, // t[] is a syntax error that is ignored in this test in favor of t
{`package t1; type t[P any] int; var _ t[int]`, `t`, `t1.t[P any]`},
{`package t2; type t[P interface{}] int; var _ t[int]`, `t`, `t2.t[P interface{}]`},
{`package t3; type t[P, Q interface{}] int; var _ t[int, int]`, `t`, `t3.t[P, Q interface{}]`},
{brokenPkg + `t4; type t[P, Q interface{ m() }] int; var _ t[int, int]`, `t`, `broken_t4.t[P, Q interface{m()}]`},
// instantiated types must be sanitized
{`package g0; type t[P any] int; var x struct{ f t[int] }; var _ = x.f`, `x.f`, `g0.t[int]`},
// go.dev/issue/45096
{`package issue45096; func _[T interface{ ~int8 | ~int16 | ~int32 }](x T) { _ = x < 0 }`, `0`, `T`},
// go.dev/issue/47895
{`package p; import "unsafe"; type S struct { f int }; var s S; var _ = unsafe.Offsetof(s.f)`, `s.f`, `int`},
// go.dev/issue/50093
{`package u0a; func _[_ interface{int}]() {}`, `int`, `int`},
{`package u1a; func _[_ interface{~int}]() {}`, `~int`, `~int`},
{`package u2a; func _[_ interface{int | string}]() {}`, `int | string`, `int | string`},
{`package u3a; func _[_ interface{int | string | ~bool}]() {}`, `int | string | ~bool`, `int | string | ~bool`},
{`package u3a; func _[_ interface{int | string | ~bool}]() {}`, `int | string`, `int | string`},
{`package u3a; func _[_ interface{int | string | ~bool}]() {}`, `~bool`, `~bool`},
{`package u3a; func _[_ interface{int | string | ~float64|~bool}]() {}`, `int | string | ~float64`, `int | string | ~float64`},
{`package u0b; func _[_ int]() {}`, `int`, `int`},
{`package u1b; func _[_ ~int]() {}`, `~int`, `~int`},
{`package u2b; func _[_ int | string]() {}`, `int | string`, `int | string`},
{`package u3b; func _[_ int | string | ~bool]() {}`, `int | string | ~bool`, `int | string | ~bool`},
{`package u3b; func _[_ int | string | ~bool]() {}`, `int | string`, `int | string`},
{`package u3b; func _[_ int | string | ~bool]() {}`, `~bool`, `~bool`},
{`package u3b; func _[_ int | string | ~float64|~bool]() {}`, `int | string | ~float64`, `int | string | ~float64`},
{`package u0c; type _ interface{int}`, `int`, `int`},
{`package u1c; type _ interface{~int}`, `~int`, `~int`},
{`package u2c; type _ interface{int | string}`, `int | string`, `int | string`},
{`package u3c; type _ interface{int | string | ~bool}`, `int | string | ~bool`, `int | string | ~bool`},
{`package u3c; type _ interface{int | string | ~bool}`, `int | string`, `int | string`},
{`package u3c; type _ interface{int | string | ~bool}`, `~bool`, `~bool`},
{`package u3c; type _ interface{int | string | ~float64|~bool}`, `int | string | ~float64`, `int | string | ~float64`},
// reverse type inference
{`package r1; var _ func(int) = g; func g[P any](P) {}`, `g`, `func(int)`},
{`package r2; var _ func(int) = g[int]; func g[P any](P) {}`, `g`, `func[P any](P)`}, // go.dev/issues/60212
{`package r3; var _ func(int) = g[int]; func g[P any](P) {}`, `g[int]`, `func(int)`},
{`package r4; var _ func(int, string) = g; func g[P, Q any](P, Q) {}`, `g`, `func(int, string)`},
{`package r5; var _ func(int, string) = g[int]; func g[P, Q any](P, Q) {}`, `g`, `func[P, Q any](P, Q)`}, // go.dev/issues/60212
{`package r6; var _ func(int, string) = g[int]; func g[P, Q any](P, Q) {}`, `g[int]`, `func(int, string)`},
{`package s1; func _() { f(g) }; func f(func(int)) {}; func g[P any](P) {}`, `g`, `func(int)`},
{`package s2; func _() { f(g[int]) }; func f(func(int)) {}; func g[P any](P) {}`, `g`, `func[P any](P)`}, // go.dev/issues/60212
{`package s3; func _() { f(g[int]) }; func f(func(int)) {}; func g[P any](P) {}`, `g[int]`, `func(int)`},
{`package s4; func _() { f(g) }; func f(func(int, string)) {}; func g[P, Q any](P, Q) {}`, `g`, `func(int, string)`},
{`package s5; func _() { f(g[int]) }; func f(func(int, string)) {}; func g[P, Q any](P, Q) {}`, `g`, `func[P, Q any](P, Q)`}, // go.dev/issues/60212
{`package s6; func _() { f(g[int]) }; func f(func(int, string)) {}; func g[P, Q any](P, Q) {}`, `g[int]`, `func(int, string)`},
{`package s7; func _() { f(g, h) }; func f[P any](func(int, P), func(P, string)) {}; func g[P any](P, P) {}; func h[P, Q any](P, Q) {}`, `g`, `func(int, int)`},
{`package s8; func _() { f(g, h) }; func f[P any](func(int, P), func(P, string)) {}; func g[P any](P, P) {}; func h[P, Q any](P, Q) {}`, `h`, `func(int, string)`},
{`package s9; func _() { f(g, h[int]) }; func f[P any](func(int, P), func(P, string)) {}; func g[P any](P, P) {}; func h[P, Q any](P, Q) {}`, `h`, `func[P, Q any](P, Q)`}, // go.dev/issues/60212
{`package s10; func _() { f(g, h[int]) }; func f[P any](func(int, P), func(P, string)) {}; func g[P any](P, P) {}; func h[P, Q any](P, Q) {}`, `h[int]`, `func(int, string)`},
}
for _, test := range tests {
info := Info{Types: make(map[syntax.Expr]TypeAndValue)}
var name string
if strings.HasPrefix(test.src, brokenPkg) {
pkg, err := typecheck(test.src, nil, &info)
if err == nil {
t.Errorf("package %s: expected to fail but passed", pkg.Name())
continue
}
if pkg != nil {
name = pkg.Name()
}
} else {
name = mustTypecheck(test.src, nil, &info).Name()
}
// look for expression type
var typ Type
for e, tv := range info.Types {
if ExprString(e) == test.expr {
typ = tv.Type
break
}
}
if typ == nil {
t.Errorf("package %s: no type found for %s", name, test.expr)
continue
}
// check that type is correct
if got := typ.String(); got != test.typ {
t.Errorf("package %s: expr = %s: got %s; want %s", name, test.expr, got, test.typ)
}
}
}
func TestInstanceInfo(t *testing.T) {
const lib = `package lib
func F[P any](P) {}
type T[P any] []P
`
type testInst struct {
name string
targs []string
typ string
}
var tests = []struct {
src string
instances []testInst // recorded instances in source order
}{
{`package p0; func f[T any](T) {}; func _() { f(42) }`,
[]testInst{{`f`, []string{`int`}, `func(int)`}},
},
{`package p1; func f[T any](T) T { panic(0) }; func _() { f('@') }`,
[]testInst{{`f`, []string{`rune`}, `func(rune) rune`}},
},
{`package p2; func f[T any](...T) T { panic(0) }; func _() { f(0i) }`,
[]testInst{{`f`, []string{`complex128`}, `func(...complex128) complex128`}},
},
{`package p3; func f[A, B, C any](A, *B, []C) {}; func _() { f(1.2, new(string), []byte{}) }`,
[]testInst{{`f`, []string{`float64`, `string`, `byte`}, `func(float64, *string, []byte)`}},
},
{`package p4; func f[A, B any](A, *B, ...[]B) {}; func _() { f(1.2, new(byte)) }`,
[]testInst{{`f`, []string{`float64`, `byte`}, `func(float64, *byte, ...[]byte)`}},
},
{`package s1; func f[T any, P interface{*T}](x T) {}; func _(x string) { f(x) }`,
[]testInst{{`f`, []string{`string`, `*string`}, `func(x string)`}},
},
{`package s2; func f[T any, P interface{*T}](x []T) {}; func _(x []int) { f(x) }`,
[]testInst{{`f`, []string{`int`, `*int`}, `func(x []int)`}},
},
{`package s3; type C[T any] interface{chan<- T}; func f[T any, P C[T]](x []T) {}; func _(x []int) { f(x) }`,
[]testInst{
{`C`, []string{`T`}, `interface{chan<- T}`},
{`f`, []string{`int`, `chan<- int`}, `func(x []int)`},
},
},
{`package s4; type C[T any] interface{chan<- T}; func f[T any, P C[T], Q C[[]*P]](x []T) {}; func _(x []int) { f(x) }`,
[]testInst{
{`C`, []string{`T`}, `interface{chan<- T}`},
{`C`, []string{`[]*P`}, `interface{chan<- []*P}`},
{`f`, []string{`int`, `chan<- int`, `chan<- []*chan<- int`}, `func(x []int)`},
},
},
{`package t1; func f[T any, P interface{*T}]() T { panic(0) }; func _() { _ = f[string] }`,
[]testInst{{`f`, []string{`string`, `*string`}, `func() string`}},
},
{`package t2; func f[T any, P interface{*T}]() T { panic(0) }; func _() { _ = (f[string]) }`,
[]testInst{{`f`, []string{`string`, `*string`}, `func() string`}},
},
{`package t3; type C[T any] interface{chan<- T}; func f[T any, P C[T], Q C[[]*P]]() []T { return nil }; func _() { _ = f[int] }`,
[]testInst{
{`C`, []string{`T`}, `interface{chan<- T}`},
{`C`, []string{`[]*P`}, `interface{chan<- []*P}`},
{`f`, []string{`int`, `chan<- int`, `chan<- []*chan<- int`}, `func() []int`},
},
},
{`package t4; type C[T any] interface{chan<- T}; func f[T any, P C[T], Q C[[]*P]]() []T { return nil }; func _() { _ = (f[int]) }`,
[]testInst{
{`C`, []string{`T`}, `interface{chan<- T}`},
{`C`, []string{`[]*P`}, `interface{chan<- []*P}`},
{`f`, []string{`int`, `chan<- int`, `chan<- []*chan<- int`}, `func() []int`},
},
},
{`package i0; import "lib"; func _() { lib.F(42) }`,
[]testInst{{`F`, []string{`int`}, `func(int)`}},
},
{`package duplfunc0; func f[T any](T) {}; func _() { f(42); f("foo"); f[int](3) }`,
[]testInst{
{`f`, []string{`int`}, `func(int)`},
{`f`, []string{`string`}, `func(string)`},
{`f`, []string{`int`}, `func(int)`},
},
},
{`package duplfunc1; import "lib"; func _() { lib.F(42); lib.F("foo"); lib.F(3) }`,
[]testInst{
{`F`, []string{`int`}, `func(int)`},
{`F`, []string{`string`}, `func(string)`},
{`F`, []string{`int`}, `func(int)`},
},
},
{`package type0; type T[P interface{~int}] struct{ x P }; var _ T[int]`,
[]testInst{{`T`, []string{`int`}, `struct{x int}`}},
},
{`package type1; type T[P interface{~int}] struct{ x P }; var _ (T[int])`,
[]testInst{{`T`, []string{`int`}, `struct{x int}`}},
},
{`package type2; type T[P interface{~int}] struct{ x P }; var _ T[(int)]`,
[]testInst{{`T`, []string{`int`}, `struct{x int}`}},
},
{`package type3; type T[P1 interface{~[]P2}, P2 any] struct{ x P1; y P2 }; var _ T[[]int, int]`,
[]testInst{{`T`, []string{`[]int`, `int`}, `struct{x []int; y int}`}},
},
{`package type4; import "lib"; var _ lib.T[int]`,
[]testInst{{`T`, []string{`int`}, `[]int`}},
},
{`package dupltype0; type T[P interface{~int}] struct{ x P }; var x T[int]; var y T[int]`,
[]testInst{
{`T`, []string{`int`}, `struct{x int}`},
{`T`, []string{`int`}, `struct{x int}`},
},
},
{`package dupltype1; type T[P ~int] struct{ x P }; func (r *T[Q]) add(z T[Q]) { r.x += z.x }`,
[]testInst{
{`T`, []string{`Q`}, `struct{x Q}`},
{`T`, []string{`Q`}, `struct{x Q}`},
},
},
{`package dupltype1; import "lib"; var x lib.T[int]; var y lib.T[int]; var z lib.T[string]`,
[]testInst{
{`T`, []string{`int`}, `[]int`},
{`T`, []string{`int`}, `[]int`},
{`T`, []string{`string`}, `[]string`},
},
},
{`package issue51803; func foo[T any](T) {}; func _() { foo[int]( /* leave arg away on purpose */ ) }`,
[]testInst{{`foo`, []string{`int`}, `func(int)`}},
},
// reverse type inference
{`package reverse1a; var f func(int) = g; func g[P any](P) {}`,
[]testInst{{`g`, []string{`int`}, `func(int)`}},
},
{`package reverse1b; func f(func(int)) {}; func g[P any](P) {}; func _() { f(g) }`,
[]testInst{{`g`, []string{`int`}, `func(int)`}},
},
{`package reverse2a; var f func(int, string) = g; func g[P, Q any](P, Q) {}`,
[]testInst{{`g`, []string{`int`, `string`}, `func(int, string)`}},
},
{`package reverse2b; func f(func(int, string)) {}; func g[P, Q any](P, Q) {}; func _() { f(g) }`,
[]testInst{{`g`, []string{`int`, `string`}, `func(int, string)`}},
},
{`package reverse2c; func f(func(int, string)) {}; func g[P, Q any](P, Q) {}; func _() { f(g[int]) }`,
[]testInst{{`g`, []string{`int`, `string`}, `func(int, string)`}},
},
// reverse3a not possible (cannot assign to generic function outside of argument passing)
{`package reverse3b; func f[R any](func(int) R) {}; func g[P any](P) string { return "" }; func _() { f(g) }`,
[]testInst{
{`f`, []string{`string`}, `func(func(int) string)`},
{`g`, []string{`int`}, `func(int) string`},
},
},
{`package reverse4a; var _, _ func([]int, *float32) = g, h; func g[P, Q any]([]P, *Q) {}; func h[R any]([]R, *float32) {}`,
[]testInst{
{`g`, []string{`int`, `float32`}, `func([]int, *float32)`},
{`h`, []string{`int`}, `func([]int, *float32)`},
},
},
{`package reverse4b; func f(_, _ func([]int, *float32)) {}; func g[P, Q any]([]P, *Q) {}; func h[R any]([]R, *float32) {}; func _() { f(g, h) }`,
[]testInst{
{`g`, []string{`int`, `float32`}, `func([]int, *float32)`},
{`h`, []string{`int`}, `func([]int, *float32)`},
},
},
{`package issue59956; func f(func(int), func(string), func(bool)) {}; func g[P any](P) {}; func _() { f(g, g, g) }`,
[]testInst{
{`g`, []string{`int`}, `func(int)`},
{`g`, []string{`string`}, `func(string)`},
{`g`, []string{`bool`}, `func(bool)`},
},
},
}
for _, test := range tests {
imports := make(testImporter)
conf := Config{Importer: imports}
instMap := make(map[*syntax.Name]Instance)
useMap := make(map[*syntax.Name]Object)
makePkg := func(src string) *Package {
pkg, err := typecheck(src, &conf, &Info{Instances: instMap, Uses: useMap})
// allow error for issue51803
if err != nil && (pkg == nil || pkg.Name() != "issue51803") {
t.Fatal(err)
}
imports[pkg.Name()] = pkg
return pkg
}
makePkg(lib)
pkg := makePkg(test.src)
t.Run(pkg.Name(), func(t *testing.T) {
// Sort instances in source order for stability.
instances := sortedInstances(instMap)
if got, want := len(instances), len(test.instances); got != want {
t.Fatalf("got %d instances, want %d", got, want)
}
// Pairwise compare with the expected instances.
for ii, inst := range instances {
var targs []Type
for i := 0; i < inst.Inst.TypeArgs.Len(); i++ {
targs = append(targs, inst.Inst.TypeArgs.At(i))
}
typ := inst.Inst.Type
testInst := test.instances[ii]
if got := inst.Name.Value; got != testInst.name {
t.Fatalf("got name %s, want %s", got, testInst.name)
}
if len(targs) != len(testInst.targs) {
t.Fatalf("got %d type arguments; want %d", len(targs), len(testInst.targs))
}
for i, targ := range targs {
if got := targ.String(); got != testInst.targs[i] {
t.Errorf("type argument %d: got %s; want %s", i, got, testInst.targs[i])
}
}
if got := typ.Underlying().String(); got != testInst.typ {
t.Errorf("package %s: got %s; want %s", pkg.Name(), got, testInst.typ)
}
// Verify the invariant that re-instantiating the corresponding generic
// type with TypeArgs results in an identical instance.
ptype := useMap[inst.Name].Type()
lister, _ := ptype.(interface{ TypeParams() *TypeParamList })
if lister == nil || lister.TypeParams().Len() == 0 {
t.Fatalf("info.Types[%v] = %v, want parameterized type", inst.Name, ptype)
}
inst2, err := Instantiate(nil, ptype, targs, true)
if err != nil {
t.Errorf("Instantiate(%v, %v) failed: %v", ptype, targs, err)
}
if !Identical(inst.Inst.Type, inst2) {
t.Errorf("%v and %v are not identical", inst.Inst.Type, inst2)
}
}
})
}
}
type recordedInstance struct {
Name *syntax.Name
Inst Instance
}
func sortedInstances(m map[*syntax.Name]Instance) (instances []recordedInstance) {
for id, inst := range m {
instances = append(instances, recordedInstance{id, inst})
}
sort.Slice(instances, func(i, j int) bool {
return CmpPos(instances[i].Name.Pos(), instances[j].Name.Pos()) < 0
})
return instances
}
func TestDefsInfo(t *testing.T) {
var tests = []struct {
src string
obj string
want string
}{
{`package p0; const x = 42`, `x`, `const p0.x untyped int`},
{`package p1; const x int = 42`, `x`, `const p1.x int`},
{`package p2; var x int`, `x`, `var p2.x int`},
{`package p3; type x int`, `x`, `type p3.x int`},
{`package p4; func f()`, `f`, `func p4.f()`},
{`package p5; func f() int { x, _ := 1, 2; return x }`, `_`, `var _ int`},
// Tests using generics.
{`package g0; type x[T any] int`, `x`, `type g0.x[T any] int`},
{`package g1; func f[T any]() {}`, `f`, `func g1.f[T any]()`},
{`package g2; type x[T any] int; func (*x[_]) m() {}`, `m`, `func (*g2.x[_]).m()`},
}
for _, test := range tests {
info := Info{
Defs: make(map[*syntax.Name]Object),
}
name := mustTypecheck(test.src, nil, &info).Name()
// find object
var def Object
for id, obj := range info.Defs {
if id.Value == test.obj {
def = obj
break
}
}
if def == nil {
t.Errorf("package %s: %s not found", name, test.obj)
continue
}
if got := def.String(); got != test.want {
t.Errorf("package %s: got %s; want %s", name, got, test.want)
}
}
}
func TestUsesInfo(t *testing.T) {
var tests = []struct {
src string
obj string
want string
}{
{`package p0; func _() { _ = x }; const x = 42`, `x`, `const p0.x untyped int`},
{`package p1; func _() { _ = x }; const x int = 42`, `x`, `const p1.x int`},
{`package p2; func _() { _ = x }; var x int`, `x`, `var p2.x int`},
{`package p3; func _() { type _ x }; type x int`, `x`, `type p3.x int`},
{`package p4; func _() { _ = f }; func f()`, `f`, `func p4.f()`},
// Tests using generics.
{`package g0; func _[T any]() { _ = x }; const x = 42`, `x`, `const g0.x untyped int`},
{`package g1; func _[T any](x T) { }`, `T`, `type parameter T any`},
{`package g2; type N[A any] int; var _ N[int]`, `N`, `type g2.N[A any] int`},
{`package g3; type N[A any] int; func (N[_]) m() {}`, `N`, `type g3.N[A any] int`},
// Uses of fields are instantiated.
{`package s1; type N[A any] struct{ a A }; var f = N[int]{}.a`, `a`, `field a int`},
{`package s2; type N[A any] struct{ a A }; func (r N[B]) m(b B) { r.a = b }`, `a`, `field a B`},
// Uses of methods are uses of the instantiated method.
{`package m0; type N[A any] int; func (r N[B]) m() { r.n() }; func (N[C]) n() {}`, `n`, `func (m0.N[B]).n()`},
{`package m1; type N[A any] int; func (r N[B]) m() { }; var f = N[int].m`, `m`, `func (m1.N[int]).m()`},
{`package m2; func _[A any](v interface{ m() A }) { v.m() }`, `m`, `func (interface).m() A`},
{`package m3; func f[A any]() interface{ m() A } { return nil }; var _ = f[int]().m()`, `m`, `func (interface).m() int`},
{`package m4; type T[A any] func() interface{ m() A }; var x T[int]; var y = x().m`, `m`, `func (interface).m() int`},
{`package m5; type T[A any] interface{ m() A }; func _[B any](t T[B]) { t.m() }`, `m`, `func (m5.T[B]).m() B`},
{`package m6; type T[A any] interface{ m() }; func _[B any](t T[B]) { t.m() }`, `m`, `func (m6.T[B]).m()`},
{`package m7; type T[A any] interface{ m() A }; func _(t T[int]) { t.m() }`, `m`, `func (m7.T[int]).m() int`},
{`package m8; type T[A any] interface{ m() }; func _(t T[int]) { t.m() }`, `m`, `func (m8.T[int]).m()`},
{`package m9; type T[A any] interface{ m() }; func _(t T[int]) { _ = t.m }`, `m`, `func (m9.T[int]).m()`},
{
`package m10; type E[A any] interface{ m() }; type T[B any] interface{ E[B]; n() }; func _(t T[int]) { t.m() }`,
`m`,
`func (m10.E[int]).m()`,
},
}
for _, test := range tests {
info := Info{
Uses: make(map[*syntax.Name]Object),
}
name := mustTypecheck(test.src, nil, &info).Name()
// find object
var use Object
for id, obj := range info.Uses {
if id.Value == test.obj {
if use != nil {
panic(fmt.Sprintf("multiple uses of %q", id.Value))
}
use = obj
}
}
if use == nil {
t.Errorf("package %s: %s not found", name, test.obj)
continue
}
if got := use.String(); got != test.want {
t.Errorf("package %s: got %s; want %s", name, got, test.want)
}
}
}
func TestGenericMethodInfo(t *testing.T) {
src := `package p
type N[A any] int
func (r N[B]) m() { r.m(); r.n() }
func (r *N[C]) n() { }
`
f := mustParse(src)
info := Info{
Defs: make(map[*syntax.Name]Object),
Uses: make(map[*syntax.Name]Object),
Selections: make(map[*syntax.SelectorExpr]*Selection),
}
var conf Config
pkg, err := conf.Check("p", []*syntax.File{f}, &info)
if err != nil {
t.Fatal(err)
}
N := pkg.Scope().Lookup("N").Type().(*Named)
// Find the generic methods stored on N.
gm, gn := N.Method(0), N.Method(1)
if gm.Name() == "n" {
gm, gn = gn, gm
}
// Collect objects from info.
var dm, dn *Func // the declared methods
var dmm, dmn *Func // the methods used in the body of m
for _, decl := range f.DeclList {
fdecl, ok := decl.(*syntax.FuncDecl)
if !ok {
continue
}
def := info.Defs[fdecl.Name].(*Func)
switch fdecl.Name.Value {
case "m":
dm = def
syntax.Inspect(fdecl.Body, func(n syntax.Node) bool {
if call, ok := n.(*syntax.CallExpr); ok {
sel := call.Fun.(*syntax.SelectorExpr)
use := info.Uses[sel.Sel].(*Func)
selection := info.Selections[sel]
if selection.Kind() != MethodVal {
t.Errorf("Selection kind = %v, want %v", selection.Kind(), MethodVal)
}
if selection.Obj() != use {
t.Errorf("info.Selections contains %v, want %v", selection.Obj(), use)
}
switch sel.Sel.Value {
case "m":
dmm = use
case "n":
dmn = use
}
}
return true
})
case "n":
dn = def
}
}
if gm != dm {
t.Errorf(`N.Method(...) returns %v for "m", but Info.Defs has %v`, gm, dm)
}
if gn != dn {
t.Errorf(`N.Method(...) returns %v for "m", but Info.Defs has %v`, gm, dm)
}
if dmm != dm {
t.Errorf(`Inside "m", r.m uses %v, want the defined func %v`, dmm, dm)
}
if dmn == dn {
t.Errorf(`Inside "m", r.n uses %v, want a func distinct from %v`, dmm, dm)
}
}
func TestImplicitsInfo(t *testing.T) {
testenv.MustHaveGoBuild(t)
var tests = []struct {
src string
want string
}{
{`package p2; import . "fmt"; var _ = Println`, ""}, // no Implicits entry
{`package p0; import local "fmt"; var _ = local.Println`, ""}, // no Implicits entry
{`package p1; import "fmt"; var _ = fmt.Println`, "importSpec: package fmt"},
{`package p3; func f(x interface{}) { switch x.(type) { case int: } }`, ""}, // no Implicits entry
{`package p4; func f(x interface{}) { switch t := x.(type) { case int: _ = t } }`, "caseClause: var t int"},
{`package p5; func f(x interface{}) { switch t := x.(type) { case int, uint: _ = t } }`, "caseClause: var t interface{}"},
{`package p6; func f(x interface{}) { switch t := x.(type) { default: _ = t } }`, "caseClause: var t interface{}"},
{`package p7; func f(x int) {}`, ""}, // no Implicits entry
{`package p8; func f(int) {}`, "field: var int"},
{`package p9; func f() (complex64) { return 0 }`, "field: var complex64"},
{`package p10; type T struct{}; func (*T) f() {}`, "field: var *p10.T"},
// Tests using generics.
{`package f0; func f[T any](x int) {}`, ""}, // no Implicits entry
{`package f1; func f[T any](int) {}`, "field: var int"},
{`package f2; func f[T any](T) {}`, "field: var T"},
{`package f3; func f[T any]() (complex64) { return 0 }`, "field: var complex64"},
{`package f4; func f[T any](t T) (T) { return t }`, "field: var T"},
{`package t0; type T[A any] struct{}; func (*T[_]) f() {}`, "field: var *t0.T[_]"},
{`package t1; type T[A any] struct{}; func _(x interface{}) { switch t := x.(type) { case T[int]: _ = t } }`, "caseClause: var t t1.T[int]"},
{`package t2; type T[A any] struct{}; func _[P any](x interface{}) { switch t := x.(type) { case T[P]: _ = t } }`, "caseClause: var t t2.T[P]"},
{`package t3; func _[P any](x interface{}) { switch t := x.(type) { case P: _ = t } }`, "caseClause: var t P"},
}
for _, test := range tests {
info := Info{
Implicits: make(map[syntax.Node]Object),
}
name := mustTypecheck(test.src, nil, &info).Name()
// the test cases expect at most one Implicits entry
if len(info.Implicits) > 1 {
t.Errorf("package %s: %d Implicits entries found", name, len(info.Implicits))
continue
}
// extract Implicits entry, if any
var got string
for n, obj := range info.Implicits {
switch x := n.(type) {
case *syntax.ImportDecl:
got = "importSpec"
case *syntax.CaseClause:
got = "caseClause"
case *syntax.Field:
got = "field"
default:
t.Fatalf("package %s: unexpected %T", name, x)
}
got += ": " + obj.String()
}
// verify entry
if got != test.want {
t.Errorf("package %s: got %q; want %q", name, got, test.want)
}
}
}
func TestPkgNameOf(t *testing.T) {
testenv.MustHaveGoBuild(t)
const src = `
package p
import (
. "os"
_ "io"
"math"
"path/filepath"
snort "sort"
)
// avoid imported and not used errors
var (
_ = Open // os.Open
_ = math.Sin
_ = filepath.Abs
_ = snort.Ints
)
`
var tests = []struct {
path string // path string enclosed in "'s
want string
}{
{`"os"`, "."},
{`"io"`, "_"},
{`"math"`, "math"},
{`"path/filepath"`, "filepath"},
{`"sort"`, "snort"},
}
f := mustParse(src)
info := Info{
Defs: make(map[*syntax.Name]Object),
Implicits: make(map[syntax.Node]Object),
}
var conf Config
conf.Importer = defaultImporter()
_, err := conf.Check("p", []*syntax.File{f}, &info)
if err != nil {
t.Fatal(err)
}
// map import paths to importDecl
imports := make(map[string]*syntax.ImportDecl)
for _, d := range f.DeclList {
if imp, _ := d.(*syntax.ImportDecl); imp != nil {
imports[imp.Path.Value] = imp
}
}
for _, test := range tests {
imp := imports[test.path]
if imp == nil {
t.Fatalf("invalid test case: import path %s not found", test.path)
}
got := info.PkgNameOf(imp)
if got == nil {
t.Fatalf("import %s: package name not found", test.path)
}
if got.Name() != test.want {
t.Errorf("import %s: got %s; want %s", test.path, got.Name(), test.want)
}
}
// test non-existing importDecl
if got := info.PkgNameOf(new(syntax.ImportDecl)); got != nil {
t.Errorf("got %s for non-existing import declaration", got.Name())
}
}
func predString(tv TypeAndValue) string {
var buf strings.Builder
pred := func(b bool, s string) {
if b {
if buf.Len() > 0 {
buf.WriteString(", ")
}
buf.WriteString(s)
}
}
pred(tv.IsVoid(), "void")
pred(tv.IsType(), "type")
pred(tv.IsBuiltin(), "builtin")
pred(tv.IsValue() && tv.Value != nil, "const")
pred(tv.IsValue() && tv.Value == nil, "value")
pred(tv.IsNil(), "nil")
pred(tv.Addressable(), "addressable")
pred(tv.Assignable(), "assignable")
pred(tv.HasOk(), "hasOk")
if buf.Len() == 0 {
return "invalid"
}
return buf.String()
}
func TestPredicatesInfo(t *testing.T) {
testenv.MustHaveGoBuild(t)
var tests = []struct {
src string
expr string
pred string
}{
// void
{`package n0; func f() { f() }`, `f()`, `void`},
// types
{`package t0; type _ int`, `int`, `type`},
{`package t1; type _ []int`, `[]int`, `type`},
{`package t2; type _ func()`, `func()`, `type`},
{`package t3; type _ func(int)`, `int`, `type`},
{`package t3; type _ func(...int)`, `...int`, `type`},
// built-ins
{`package b0; var _ = len("")`, `len`, `builtin`},
{`package b1; var _ = (len)("")`, `(len)`, `builtin`},
// constants
{`package c0; var _ = 42`, `42`, `const`},
{`package c1; var _ = "foo" + "bar"`, `"foo" + "bar"`, `const`},
{`package c2; const (i = 1i; _ = i)`, `i`, `const`},
// values
{`package v0; var (a, b int; _ = a + b)`, `a + b`, `value`},
{`package v1; var _ = &[]int{1}`, `[]int{β¦}`, `value`},
{`package v2; var _ = func(){}`, `func() {}`, `value`},
{`package v4; func f() { _ = f }`, `f`, `value`},
{`package v3; var _ *int = nil`, `nil`, `value, nil`},
{`package v3; var _ *int = (nil)`, `(nil)`, `value, nil`},
// addressable (and thus assignable) operands
{`package a0; var (x int; _ = x)`, `x`, `value, addressable, assignable`},
{`package a1; var (p *int; _ = *p)`, `*p`, `value, addressable, assignable`},
{`package a2; var (s []int; _ = s[0])`, `s[0]`, `value, addressable, assignable`},
{`package a3; var (s struct{f int}; _ = s.f)`, `s.f`, `value, addressable, assignable`},
{`package a4; var (a [10]int; _ = a[0])`, `a[0]`, `value, addressable, assignable`},
{`package a5; func _(x int) { _ = x }`, `x`, `value, addressable, assignable`},
{`package a6; func _()(x int) { _ = x; return }`, `x`, `value, addressable, assignable`},
{`package a7; type T int; func (x T) _() { _ = x }`, `x`, `value, addressable, assignable`},
// composite literals are not addressable
// assignable but not addressable values
{`package s0; var (m map[int]int; _ = m[0])`, `m[0]`, `value, assignable, hasOk`},
{`package s1; var (m map[int]int; _, _ = m[0])`, `m[0]`, `value, assignable, hasOk`},
// hasOk expressions
{`package k0; var (ch chan int; _ = <-ch)`, `<-ch`, `value, hasOk`},
{`package k1; var (ch chan int; _, _ = <-ch)`, `<-ch`, `value, hasOk`},
// missing entries
// - package names are collected in the Uses map
// - identifiers being declared are collected in the Defs map
{`package m0; import "os"; func _() { _ = os.Stdout }`, `os`, `<missing>`},
{`package m1; import p "os"; func _() { _ = p.Stdout }`, `p`, `<missing>`},
{`package m2; const c = 0`, `c`, `<missing>`},
{`package m3; type T int`, `T`, `<missing>`},
{`package m4; var v int`, `v`, `<missing>`},
{`package m5; func f() {}`, `f`, `<missing>`},
{`package m6; func _(x int) {}`, `x`, `<missing>`},
{`package m6; func _()(x int) { return }`, `x`, `<missing>`},
{`package m6; type T int; func (x T) _() {}`, `x`, `<missing>`},
}
for _, test := range tests {
info := Info{Types: make(map[syntax.Expr]TypeAndValue)}
name := mustTypecheck(test.src, nil, &info).Name()
// look for expression predicates
got := "<missing>"
for e, tv := range info.Types {
//println(name, ExprString(e))
if ExprString(e) == test.expr {
got = predString(tv)
break
}
}
if got != test.pred {
t.Errorf("package %s: got %s; want %s", name, got, test.pred)
}
}
}
func TestScopesInfo(t *testing.T) {
testenv.MustHaveGoBuild(t)
var tests = []struct {
src string
scopes []string // list of scope descriptors of the form kind:varlist
}{
{`package p0`, []string{
"file:",
}},
{`package p1; import ( "fmt"; m "math"; _ "os" ); var ( _ = fmt.Println; _ = m.Pi )`, []string{
"file:fmt m",
}},
{`package p2; func _() {}`, []string{
"file:", "func:",
}},
{`package p3; func _(x, y int) {}`, []string{
"file:", "func:x y",
}},
{`package p4; func _(x, y int) { x, z := 1, 2; _ = z }`, []string{
"file:", "func:x y z", // redeclaration of x
}},
{`package p5; func _(x, y int) (u, _ int) { return }`, []string{
"file:", "func:u x y",
}},
{`package p6; func _() { { var x int; _ = x } }`, []string{
"file:", "func:", "block:x",
}},
{`package p7; func _() { if true {} }`, []string{
"file:", "func:", "if:", "block:",
}},
{`package p8; func _() { if x := 0; x < 0 { y := x; _ = y } }`, []string{
"file:", "func:", "if:x", "block:y",
}},
{`package p9; func _() { switch x := 0; x {} }`, []string{
"file:", "func:", "switch:x",
}},
{`package p10; func _() { switch x := 0; x { case 1: y := x; _ = y; default: }}`, []string{
"file:", "func:", "switch:x", "case:y", "case:",
}},
{`package p11; func _(t interface{}) { switch t.(type) {} }`, []string{
"file:", "func:t", "switch:",
}},
{`package p12; func _(t interface{}) { switch t := t; t.(type) {} }`, []string{
"file:", "func:t", "switch:t",
}},
{`package p13; func _(t interface{}) { switch x := t.(type) { case int: _ = x } }`, []string{
"file:", "func:t", "switch:", "case:x", // x implicitly declared
}},
{`package p14; func _() { select{} }`, []string{
"file:", "func:",
}},
{`package p15; func _(c chan int) { select{ case <-c: } }`, []string{
"file:", "func:c", "comm:",
}},
{`package p16; func _(c chan int) { select{ case i := <-c: x := i; _ = x} }`, []string{
"file:", "func:c", "comm:i x",
}},
{`package p17; func _() { for{} }`, []string{
"file:", "func:", "for:", "block:",
}},
{`package p18; func _(n int) { for i := 0; i < n; i++ { _ = i } }`, []string{
"file:", "func:n", "for:i", "block:",
}},
{`package p19; func _(a []int) { for i := range a { _ = i} }`, []string{
"file:", "func:a", "for:i", "block:",
}},
{`package p20; var s int; func _(a []int) { for i, x := range a { s += x; _ = i } }`, []string{
"file:", "func:a", "for:i x", "block:",
}},
}
for _, test := range tests {
info := Info{Scopes: make(map[syntax.Node]*Scope)}
name := mustTypecheck(test.src, nil, &info).Name()
// number of scopes must match
if len(info.Scopes) != len(test.scopes) {
t.Errorf("package %s: got %d scopes; want %d", name, len(info.Scopes), len(test.scopes))
}
// scope descriptions must match
for node, scope := range info.Scopes {
var kind string
switch node.(type) {
case *syntax.File:
kind = "file"
case *syntax.FuncType:
kind = "func"
case *syntax.BlockStmt:
kind = "block"
case *syntax.IfStmt:
kind = "if"
case *syntax.SwitchStmt:
kind = "switch"
case *syntax.SelectStmt:
kind = "select"
case *syntax.CaseClause:
kind = "case"
case *syntax.CommClause:
kind = "comm"
case *syntax.ForStmt:
kind = "for"
default:
kind = fmt.Sprintf("%T", node)
}
// look for matching scope description
desc := kind + ":" + strings.Join(scope.Names(), " ")
found := false
for _, d := range test.scopes {
if desc == d {
found = true
break
}
}
if !found {
t.Errorf("package %s: no matching scope found for %s", name, desc)
}
}
}
}
func TestInitOrderInfo(t *testing.T) {
var tests = []struct {
src string
inits []string
}{
{`package p0; var (x = 1; y = x)`, []string{
"x = 1", "y = x",
}},
{`package p1; var (a = 1; b = 2; c = 3)`, []string{
"a = 1", "b = 2", "c = 3",
}},
{`package p2; var (a, b, c = 1, 2, 3)`, []string{
"a = 1", "b = 2", "c = 3",
}},
{`package p3; var _ = f(); func f() int { return 1 }`, []string{
"_ = f()", // blank var
}},
{`package p4; var (a = 0; x = y; y = z; z = 0)`, []string{
"a = 0", "z = 0", "y = z", "x = y",
}},
{`package p5; var (a, _ = m[0]; m map[int]string)`, []string{
"a, _ = m[0]", // blank var
}},
{`package p6; var a, b = f(); func f() (_, _ int) { return z, z }; var z = 0`, []string{
"z = 0", "a, b = f()",
}},
{`package p7; var (a = func() int { return b }(); b = 1)`, []string{
"b = 1", "a = func() int {β¦}()",
}},
{`package p8; var (a, b = func() (_, _ int) { return c, c }(); c = 1)`, []string{
"c = 1", "a, b = func() (_, _ int) {β¦}()",
}},
{`package p9; type T struct{}; func (T) m() int { _ = y; return 0 }; var x, y = T.m, 1`, []string{
"y = 1", "x = T.m",
}},
{`package p10; var (d = c + b; a = 0; b = 0; c = 0)`, []string{
"a = 0", "b = 0", "c = 0", "d = c + b",
}},
{`package p11; var (a = e + c; b = d + c; c = 0; d = 0; e = 0)`, []string{
"c = 0", "d = 0", "b = d + c", "e = 0", "a = e + c",
}},
// emit an initializer for n:1 initializations only once (not for each node
// on the lhs which may appear in different order in the dependency graph)
{`package p12; var (a = x; b = 0; x, y = m[0]; m map[int]int)`, []string{
"b = 0", "x, y = m[0]", "a = x",
}},
// test case from spec section on package initialization
{`package p12
var (
a = c + b
b = f()
c = f()
d = 3
)
func f() int {
d++
return d
}`, []string{
"d = 3", "b = f()", "c = f()", "a = c + b",
}},
// test case for go.dev/issue/7131
{`package main
var counter int
func next() int { counter++; return counter }
var _ = makeOrder()
func makeOrder() []int { return []int{f, b, d, e, c, a} }
var a = next()
var b, c = next(), next()
var d, e, f = next(), next(), next()
`, []string{
"a = next()", "b = next()", "c = next()", "d = next()", "e = next()", "f = next()", "_ = makeOrder()",
}},
// test case for go.dev/issue/10709
{`package p13
var (
v = t.m()
t = makeT(0)
)
type T struct{}
func (T) m() int { return 0 }
func makeT(n int) T {
if n > 0 {
return makeT(n-1)
}
return T{}
}`, []string{
"t = makeT(0)", "v = t.m()",
}},
// test case for go.dev/issue/10709: same as test before, but variable decls swapped
{`package p14
var (
t = makeT(0)
v = t.m()
)
type T struct{}
func (T) m() int { return 0 }
func makeT(n int) T {
if n > 0 {
return makeT(n-1)
}
return T{}
}`, []string{
"t = makeT(0)", "v = t.m()",
}},
// another candidate possibly causing problems with go.dev/issue/10709
{`package p15
var y1 = f1()
func f1() int { return g1() }
func g1() int { f1(); return x1 }
var x1 = 0
var y2 = f2()
func f2() int { return g2() }
func g2() int { return x2 }
var x2 = 0`, []string{
"x1 = 0", "y1 = f1()", "x2 = 0", "y2 = f2()",
}},
}
for _, test := range tests {
info := Info{}
name := mustTypecheck(test.src, nil, &info).Name()
// number of initializers must match
if len(info.InitOrder) != len(test.inits) {
t.Errorf("package %s: got %d initializers; want %d", name, len(info.InitOrder), len(test.inits))
continue
}
// initializers must match
for i, want := range test.inits {
got := info.InitOrder[i].String()
if got != want {
t.Errorf("package %s, init %d: got %s; want %s", name, i, got, want)
continue
}
}
}
}
func TestMultiFileInitOrder(t *testing.T) {
fileA := mustParse(`package main; var a = 1`)
fileB := mustParse(`package main; var b = 2`)
// The initialization order must not depend on the parse
// order of the files, only on the presentation order to
// the type-checker.
for _, test := range []struct {
files []*syntax.File
want string
}{
{[]*syntax.File{fileA, fileB}, "[a = 1 b = 2]"},
{[]*syntax.File{fileB, fileA}, "[b = 2 a = 1]"},
} {
var info Info
if _, err := new(Config).Check("main", test.files, &info); err != nil {
t.Fatal(err)
}
if got := fmt.Sprint(info.InitOrder); got != test.want {
t.Fatalf("got %s; want %s", got, test.want)
}
}
}
func TestFiles(t *testing.T) {
var sources = []string{
"package p; type T struct{}; func (T) m1() {}",
"package p; func (T) m2() {}; var x interface{ m1(); m2() } = T{}",
"package p; func (T) m3() {}; var y interface{ m1(); m2(); m3() } = T{}",
"package p",
}
var conf Config
pkg := NewPackage("p", "p")
var info Info
check := NewChecker(&conf, pkg, &info)
for _, src := range sources {
if err := check.Files([]*syntax.File{mustParse(src)}); err != nil {
t.Error(err)
}
}
// check InitOrder is [x y]
var vars []string
for _, init := range info.InitOrder {
for _, v := range init.Lhs {
vars = append(vars, v.Name())
}
}
if got, want := fmt.Sprint(vars), "[x y]"; got != want {
t.Errorf("InitOrder == %s, want %s", got, want)
}
}
type testImporter map[string]*Package
func (m testImporter) Import(path string) (*Package, error) {
if pkg := m[path]; pkg != nil {
return pkg, nil
}
return nil, fmt.Errorf("package %q not found", path)
}
func TestSelection(t *testing.T) {
selections := make(map[*syntax.SelectorExpr]*Selection)
imports := make(testImporter)
conf := Config{Importer: imports}
makePkg := func(path, src string) {
pkg := mustTypecheck(src, &conf, &Info{Selections: selections})
imports[path] = pkg
}
const libSrc = `
package lib
type T float64
const C T = 3
var V T
func F() {}
func (T) M() {}
`
const mainSrc = `
package main
import "lib"
type A struct {
*B
C
}
type B struct {
b int
}
func (B) f(int)
type C struct {
c int
}
type G[P any] struct {
p P
}
func (G[P]) m(P) {}
var Inst G[int]
func (C) g()
func (*C) h()
func main() {
// qualified identifiers
var _ lib.T
_ = lib.C
_ = lib.F
_ = lib.V
_ = lib.T.M
// fields
_ = A{}.B
_ = new(A).B
_ = A{}.C
_ = new(A).C
_ = A{}.b
_ = new(A).b
_ = A{}.c
_ = new(A).c
_ = Inst.p
_ = G[string]{}.p
// methods
_ = A{}.f
_ = new(A).f
_ = A{}.g
_ = new(A).g
_ = new(A).h
_ = B{}.f
_ = new(B).f
_ = C{}.g
_ = new(C).g
_ = new(C).h
_ = Inst.m
// method expressions
_ = A.f
_ = (*A).f
_ = B.f
_ = (*B).f
_ = G[string].m
}`
wantOut := map[string][2]string{
"lib.T.M": {"method expr (lib.T) M(lib.T)", ".[0]"},
"A{}.B": {"field (main.A) B *main.B", ".[0]"},
"new(A).B": {"field (*main.A) B *main.B", "->[0]"},
"A{}.C": {"field (main.A) C main.C", ".[1]"},
"new(A).C": {"field (*main.A) C main.C", "->[1]"},
"A{}.b": {"field (main.A) b int", "->[0 0]"},
"new(A).b": {"field (*main.A) b int", "->[0 0]"},
"A{}.c": {"field (main.A) c int", ".[1 0]"},
"new(A).c": {"field (*main.A) c int", "->[1 0]"},
"Inst.p": {"field (main.G[int]) p int", ".[0]"},
"A{}.f": {"method (main.A) f(int)", "->[0 0]"},
"new(A).f": {"method (*main.A) f(int)", "->[0 0]"},
"A{}.g": {"method (main.A) g()", ".[1 0]"},
"new(A).g": {"method (*main.A) g()", "->[1 0]"},
"new(A).h": {"method (*main.A) h()", "->[1 1]"}, // TODO(gri) should this report .[1 1] ?
"B{}.f": {"method (main.B) f(int)", ".[0]"},
"new(B).f": {"method (*main.B) f(int)", "->[0]"},
"C{}.g": {"method (main.C) g()", ".[0]"},
"new(C).g": {"method (*main.C) g()", "->[0]"},
"new(C).h": {"method (*main.C) h()", "->[1]"}, // TODO(gri) should this report .[1] ?
"Inst.m": {"method (main.G[int]) m(int)", ".[0]"},
"A.f": {"method expr (main.A) f(main.A, int)", "->[0 0]"},
"(*A).f": {"method expr (*main.A) f(*main.A, int)", "->[0 0]"},
"B.f": {"method expr (main.B) f(main.B, int)", ".[0]"},
"(*B).f": {"method expr (*main.B) f(*main.B, int)", "->[0]"},
"G[string].m": {"method expr (main.G[string]) m(main.G[string], string)", ".[0]"},
"G[string]{}.p": {"field (main.G[string]) p string", ".[0]"},
}
makePkg("lib", libSrc)
makePkg("main", mainSrc)
for e, sel := range selections {
_ = sel.String() // assertion: must not panic
start := indexFor(mainSrc, syntax.StartPos(e))
end := indexFor(mainSrc, syntax.EndPos(e))
segment := mainSrc[start:end] // (all SelectorExprs are in main, not lib)
direct := "."
if sel.Indirect() {
direct = "->"
}
got := [2]string{
sel.String(),
fmt.Sprintf("%s%v", direct, sel.Index()),
}
want := wantOut[segment]
if want != got {
t.Errorf("%s: got %q; want %q", segment, got, want)
}
delete(wantOut, segment)
// We must explicitly assert properties of the
// Signature's receiver since it doesn't participate
// in Identical() or String().
sig, _ := sel.Type().(*Signature)
if sel.Kind() == MethodVal {
got := sig.Recv().Type()
want := sel.Recv()
if !Identical(got, want) {
t.Errorf("%s: Recv() = %s, want %s", segment, got, want)
}
} else if sig != nil && sig.Recv() != nil {
t.Errorf("%s: signature has receiver %s", sig, sig.Recv().Type())
}
}
// Assert that all wantOut entries were used exactly once.
for segment := range wantOut {
t.Errorf("no syntax.Selection found with syntax %q", segment)
}
}
// indexFor returns the index into s corresponding to the position pos.
func indexFor(s string, pos syntax.Pos) int {
i, line := 0, 1 // string index and corresponding line
target := int(pos.Line())
for line < target && i < len(s) {
if s[i] == '\n' {
line++
}
i++
}
return i + int(pos.Col()-1) // columns are 1-based
}
func TestIssue8518(t *testing.T) {
imports := make(testImporter)
conf := Config{
Error: func(err error) { t.Log(err) }, // don't exit after first error
Importer: imports,
}
makePkg := func(path, src string) {
imports[path], _ = conf.Check(path, []*syntax.File{mustParse(src)}, nil) // errors logged via conf.Error
}
const libSrc = `
package a
import "missing"
const C1 = foo
const C2 = missing.C
`
const mainSrc = `
package main
import "a"
var _ = a.C1
var _ = a.C2
`
makePkg("a", libSrc)
makePkg("main", mainSrc) // don't crash when type-checking this package
}
func TestIssue59603(t *testing.T) {
imports := make(testImporter)
conf := Config{
Error: func(err error) { t.Log(err) }, // don't exit after first error
Importer: imports,
}
makePkg := func(path, src string) {
imports[path], _ = conf.Check(path, []*syntax.File{mustParse(src)}, nil) // errors logged via conf.Error
}
const libSrc = `
package a
const C = foo
`
const mainSrc = `
package main
import "a"
const _ = a.C
`
makePkg("a", libSrc)
makePkg("main", mainSrc) // don't crash when type-checking this package
}
func TestLookupFieldOrMethodOnNil(t *testing.T) {
// LookupFieldOrMethod on a nil type is expected to produce a run-time panic.
defer func() {
const want = "LookupFieldOrMethod on nil type"
p := recover()
if s, ok := p.(string); !ok || s != want {
t.Fatalf("got %v, want %s", p, want)
}
}()
LookupFieldOrMethod(nil, false, nil, "")
}
func TestLookupFieldOrMethod(t *testing.T) {
// Test cases assume a lookup of the form a.f or x.f, where a stands for an
// addressable value, and x for a non-addressable value (even though a variable
// for ease of test case writing).
var tests = []struct {
src string
found bool
index []int
indirect bool
}{
// field lookups
{"var x T; type T struct{}", false, nil, false},
{"var x T; type T struct{ f int }", true, []int{0}, false},
{"var x T; type T struct{ a, b, f, c int }", true, []int{2}, false},
// field lookups on a generic type
{"var x T[int]; type T[P any] struct{}", false, nil, false},
{"var x T[int]; type T[P any] struct{ f P }", true, []int{0}, false},
{"var x T[int]; type T[P any] struct{ a, b, f, c P }", true, []int{2}, false},
// method lookups
{"var a T; type T struct{}; func (T) f() {}", true, []int{0}, false},
{"var a *T; type T struct{}; func (T) f() {}", true, []int{0}, true},
{"var a T; type T struct{}; func (*T) f() {}", true, []int{0}, false},
{"var a *T; type T struct{}; func (*T) f() {}", true, []int{0}, true}, // TODO(gri) should this report indirect = false?
// method lookups on a generic type
{"var a T[int]; type T[P any] struct{}; func (T[P]) f() {}", true, []int{0}, false},
{"var a *T[int]; type T[P any] struct{}; func (T[P]) f() {}", true, []int{0}, true},
{"var a T[int]; type T[P any] struct{}; func (*T[P]) f() {}", true, []int{0}, false},
{"var a *T[int]; type T[P any] struct{}; func (*T[P]) f() {}", true, []int{0}, true}, // TODO(gri) should this report indirect = false?
// collisions
{"type ( E1 struct{ f int }; E2 struct{ f int }; x struct{ E1; *E2 })", false, []int{1, 0}, false},
{"type ( E1 struct{ f int }; E2 struct{}; x struct{ E1; *E2 }); func (E2) f() {}", false, []int{1, 0}, false},
// collisions on a generic type
{"type ( E1[P any] struct{ f P }; E2[P any] struct{ f P }; x struct{ E1[int]; *E2[int] })", false, []int{1, 0}, false},
{"type ( E1[P any] struct{ f P }; E2[P any] struct{}; x struct{ E1[int]; *E2[int] }); func (E2[P]) f() {}", false, []int{1, 0}, false},
// outside methodset
// (*T).f method exists, but value of type T is not addressable
{"var x T; type T struct{}; func (*T) f() {}", false, nil, true},
// outside method set of a generic type
{"var x T[int]; type T[P any] struct{}; func (*T[P]) f() {}", false, nil, true},
// recursive generic types; see go.dev/issue/52715
{"var a T[int]; type ( T[P any] struct { *N[P] }; N[P any] struct { *T[P] } ); func (N[P]) f() {}", true, []int{0, 0}, true},
{"var a T[int]; type ( T[P any] struct { *N[P] }; N[P any] struct { *T[P] } ); func (T[P]) f() {}", true, []int{0}, false},
}
for _, test := range tests {
pkg := mustTypecheck("package p;"+test.src, nil, nil)
obj := pkg.Scope().Lookup("a")
if obj == nil {
if obj = pkg.Scope().Lookup("x"); obj == nil {
t.Errorf("%s: incorrect test case - no object a or x", test.src)
continue
}
}
f, index, indirect := LookupFieldOrMethod(obj.Type(), obj.Name() == "a", pkg, "f")
if (f != nil) != test.found {
if f == nil {
t.Errorf("%s: got no object; want one", test.src)
} else {
t.Errorf("%s: got object = %v; want none", test.src, f)
}
}
if !sameSlice(index, test.index) {
t.Errorf("%s: got index = %v; want %v", test.src, index, test.index)
}
if indirect != test.indirect {
t.Errorf("%s: got indirect = %v; want %v", test.src, indirect, test.indirect)
}
}
}
// Test for go.dev/issue/52715
func TestLookupFieldOrMethod_RecursiveGeneric(t *testing.T) {
const src = `
package pkg
type Tree[T any] struct {
*Node[T]
}
func (*Tree[R]) N(r R) R { return r }
type Node[T any] struct {
*Tree[T]
}
type Instance = *Tree[int]
`
f := mustParse(src)
pkg := NewPackage("pkg", f.PkgName.Value)
if err := NewChecker(nil, pkg, nil).Files([]*syntax.File{f}); err != nil {
panic(err)
}
T := pkg.Scope().Lookup("Instance").Type()
_, _, _ = LookupFieldOrMethod(T, false, pkg, "M") // verify that LookupFieldOrMethod terminates
}
func sameSlice(a, b []int) bool {
if len(a) != len(b) {
return false
}
for i, x := range a {
if x != b[i] {
return false
}
}
return true
}
// TestScopeLookupParent ensures that (*Scope).LookupParent returns
// the correct result at various positions within the source.
func TestScopeLookupParent(t *testing.T) {
imports := make(testImporter)
conf := Config{
Importer: imports,
EnableAlias: true, // must match default Universe.Lookup behavior
}
var info Info
makePkg := func(path, src string) {
var err error
imports[path], err = conf.Check(path, []*syntax.File{mustParse(src)}, &info)
if err != nil {
t.Fatal(err)
}
}
makePkg("lib", "package lib; var X int")
// Each /*name=kind:line*/ comment makes the test look up the
// name at that point and checks that it resolves to a decl of
// the specified kind and line number. "undef" means undefined.
// Note that type switch case clauses with an empty body (but for
// comments) need the ";" to ensure that the recorded scope extends
// past the comments.
mainSrc := `
/*lib=pkgname:5*/ /*X=var:1*/ /*Pi=const:8*/ /*T=typename:9*/ /*Y=var:10*/ /*F=func:12*/
package main
import "lib"
import . "lib"
const Pi = 3.1415
type T struct{}
var Y, _ = lib.X, X
func F[T *U, U any](param1, param2 int) /*param1=undef*/ (res1 /*res1=undef*/, res2 int) /*param1=var:12*/ /*res1=var:12*/ /*U=typename:12*/ {
const pi, e = 3.1415, /*pi=undef*/ 2.71828 /*pi=const:13*/ /*e=const:13*/
type /*t=undef*/ t /*t=typename:14*/ *t
print(Y) /*Y=var:10*/
x, Y := Y, /*x=undef*/ /*Y=var:10*/ Pi /*x=var:16*/ /*Y=var:16*/ ; _ = x; _ = Y
var F = /*F=func:12*/ F[*int, int] /*F=var:17*/ ; _ = F
var a []int
for i, x := range a /*i=undef*/ /*x=var:16*/ { _ = i; _ = x }
var i interface{}
switch y := i.(type) { /*y=undef*/
case /*y=undef*/ int /*y=undef*/ : /*y=var:23*/ ;
case float32, /*y=undef*/ float64 /*y=undef*/ : /*y=var:23*/ ;
default /*y=undef*/ : /*y=var:23*/
println(y)
}
/*y=undef*/
switch int := i.(type) {
case /*int=typename:0*/ int /*int=typename:0*/ : /*int=var:31*/
println(int)
default /*int=typename:0*/ : /*int=var:31*/ ;
}
_ = param1
_ = res1
return
}
/*main=undef*/
`
info.Uses = make(map[*syntax.Name]Object)
makePkg("main", mainSrc)
mainScope := imports["main"].Scope()
rx := regexp.MustCompile(`^/\*(\w*)=([\w:]*)\*/$`)
base := syntax.NewFileBase("main")
syntax.CommentsDo(strings.NewReader(mainSrc), func(line, col uint, text string) {
pos := syntax.MakePos(base, line, col)
// Syntax errors are not comments.
if text[0] != '/' {
t.Errorf("%s: %s", pos, text)
return
}
// Parse the assertion in the comment.
m := rx.FindStringSubmatch(text)
if m == nil {
t.Errorf("%s: bad comment: %s", pos, text)
return
}
name, want := m[1], m[2]
// Look up the name in the innermost enclosing scope.
inner := mainScope.Innermost(pos)
if inner == nil {
t.Errorf("%s: at %s: can't find innermost scope", pos, text)
return
}
got := "undef"
if _, obj := inner.LookupParent(name, pos); obj != nil {
kind := strings.ToLower(strings.TrimPrefix(reflect.TypeOf(obj).String(), "*types2."))
got = fmt.Sprintf("%s:%d", kind, obj.Pos().Line())
}
if got != want {
t.Errorf("%s: at %s: %s resolved to %s, want %s", pos, text, name, got, want)
}
})
// Check that for each referring identifier,
// a lookup of its name on the innermost
// enclosing scope returns the correct object.
for id, wantObj := range info.Uses {
inner := mainScope.Innermost(id.Pos())
if inner == nil {
t.Errorf("%s: can't find innermost scope enclosing %q", id.Pos(), id.Value)
continue
}
// Exclude selectors and qualified identifiers---lexical
// refs only. (Ideally, we'd see if the AST parent is a
// SelectorExpr, but that requires PathEnclosingInterval
// from golang.org/x/tools/go/ast/astutil.)
if id.Value == "X" {
continue
}
_, gotObj := inner.LookupParent(id.Value, id.Pos())
if gotObj != wantObj {
// Print the scope tree of mainScope in case of error.
var printScopeTree func(indent string, s *Scope)
printScopeTree = func(indent string, s *Scope) {
t.Logf("%sscope %s %v-%v = %v",
indent,
ScopeComment(s),
s.Pos(),
s.End(),
s.Names())
for i := range s.NumChildren() {
printScopeTree(indent+" ", s.Child(i))
}
}
printScopeTree("", mainScope)
t.Errorf("%s: Scope(%s).LookupParent(%s@%v) got %v, want %v [scopePos=%v]",
id.Pos(),
ScopeComment(inner),
id.Value,
id.Pos(),
gotObj,
wantObj,
ObjectScopePos(wantObj))
continue
}
}
}
// newDefined creates a new defined type named T with the given underlying type.
func newDefined(underlying Type) *Named {
tname := NewTypeName(nopos, nil, "T", nil)
return NewNamed(tname, underlying, nil)
}
func TestConvertibleTo(t *testing.T) {
for _, test := range []struct {
v, t Type
want bool
}{
{Typ[Int], Typ[Int], true},
{Typ[Int], Typ[Float32], true},
{Typ[Int], Typ[String], true},
{newDefined(Typ[Int]), Typ[Int], true},
{newDefined(new(Struct)), new(Struct), true},
{newDefined(Typ[Int]), new(Struct), false},
{Typ[UntypedInt], Typ[Int], true},
{NewSlice(Typ[Int]), NewArray(Typ[Int], 10), true},
{NewSlice(Typ[Int]), NewArray(Typ[Uint], 10), false},
{NewSlice(Typ[Int]), NewPointer(NewArray(Typ[Int], 10)), true},
{NewSlice(Typ[Int]), NewPointer(NewArray(Typ[Uint], 10)), false},
// Untyped string values are not permitted by the spec, so the behavior below is undefined.
{Typ[UntypedString], Typ[String], true},
} {
if got := ConvertibleTo(test.v, test.t); got != test.want {
t.Errorf("ConvertibleTo(%v, %v) = %t, want %t", test.v, test.t, got, test.want)
}
}
}
func TestAssignableTo(t *testing.T) {
for _, test := range []struct {
v, t Type
want bool
}{
{Typ[Int], Typ[Int], true},
{Typ[Int], Typ[Float32], false},
{newDefined(Typ[Int]), Typ[Int], false},
{newDefined(new(Struct)), new(Struct), true},
{Typ[UntypedBool], Typ[Bool], true},
{Typ[UntypedString], Typ[Bool], false},
// Neither untyped string nor untyped numeric assignments arise during
// normal type checking, so the below behavior is technically undefined by
// the spec.
{Typ[UntypedString], Typ[String], true},
{Typ[UntypedInt], Typ[Int], true},
} {
if got := AssignableTo(test.v, test.t); got != test.want {
t.Errorf("AssignableTo(%v, %v) = %t, want %t", test.v, test.t, got, test.want)
}
}
}
func TestIdentical(t *testing.T) {
// For each test, we compare the types of objects X and Y in the source.
tests := []struct {
src string
want bool
}{
// Basic types.
{"var X int; var Y int", true},
{"var X int; var Y string", false},
// TODO: add more tests for complex types.
// Named types.
{"type X int; type Y int", false},
// Aliases.
{"type X = int; type Y = int", true},
// Functions.
{`func X(int) string { return "" }; func Y(int) string { return "" }`, true},
{`func X() string { return "" }; func Y(int) string { return "" }`, false},
{`func X(int) string { return "" }; func Y(int) {}`, false},
// Generic functions. Type parameters should be considered identical modulo
// renaming. See also go.dev/issue/49722.
{`func X[P ~int](){}; func Y[Q ~int]() {}`, true},
{`func X[P1 any, P2 ~*P1](){}; func Y[Q1 any, Q2 ~*Q1]() {}`, true},
{`func X[P1 any, P2 ~[]P1](){}; func Y[Q1 any, Q2 ~*Q1]() {}`, false},
{`func X[P ~int](P){}; func Y[Q ~int](Q) {}`, true},
{`func X[P ~string](P){}; func Y[Q ~int](Q) {}`, false},
{`func X[P ~int]([]P){}; func Y[Q ~int]([]Q) {}`, true},
}
for _, test := range tests {
pkg := mustTypecheck("package p;"+test.src, nil, nil)
X := pkg.Scope().Lookup("X")
Y := pkg.Scope().Lookup("Y")
if X == nil || Y == nil {
t.Fatal("test must declare both X and Y")
}
if got := Identical(X.Type(), Y.Type()); got != test.want {
t.Errorf("Identical(%s, %s) = %t, want %t", X.Type(), Y.Type(), got, test.want)
}
}
}
func TestIdentical_issue15173(t *testing.T) {
// Identical should allow nil arguments and be symmetric.
for _, test := range []struct {
x, y Type
want bool
}{
{Typ[Int], Typ[Int], true},
{Typ[Int], nil, false},
{nil, Typ[Int], false},
{nil, nil, true},
} {
if got := Identical(test.x, test.y); got != test.want {
t.Errorf("Identical(%v, %v) = %t", test.x, test.y, got)
}
}
}
func TestIdenticalUnions(t *testing.T) {
tname := NewTypeName(nopos, nil, "myInt", nil)
myInt := NewNamed(tname, Typ[Int], nil)
tmap := map[string]*Term{
"int": NewTerm(false, Typ[Int]),
"~int": NewTerm(true, Typ[Int]),
"string": NewTerm(false, Typ[String]),
"~string": NewTerm(true, Typ[String]),
"myInt": NewTerm(false, myInt),
}
makeUnion := func(s string) *Union {
parts := strings.Split(s, "|")
var terms []*Term
for _, p := range parts {
term := tmap[p]
if term == nil {
t.Fatalf("missing term %q", p)
}
terms = append(terms, term)
}
return NewUnion(terms)
}
for _, test := range []struct {
x, y string
want bool
}{
// These tests are just sanity checks. The tests for type sets and
// interfaces provide much more test coverage.
{"int|~int", "~int", true},
{"myInt|~int", "~int", true},
{"int|string", "string|int", true},
{"int|int|string", "string|int", true},
{"myInt|string", "int|string", false},
} {
x := makeUnion(test.x)
y := makeUnion(test.y)
if got := Identical(x, y); got != test.want {
t.Errorf("Identical(%v, %v) = %t", test.x, test.y, got)
}
}
}
func TestIssue61737(t *testing.T) {
// This test verifies that it is possible to construct invalid interfaces
// containing duplicate methods using the go/types API.
//
// It must be possible for importers to construct such invalid interfaces.
// Previously, this panicked.
sig1 := NewSignatureType(nil, nil, nil, NewTuple(NewParam(nopos, nil, "", Typ[Int])), nil, false)
sig2 := NewSignatureType(nil, nil, nil, NewTuple(NewParam(nopos, nil, "", Typ[String])), nil, false)
methods := []*Func{
NewFunc(nopos, nil, "M", sig1),
NewFunc(nopos, nil, "M", sig2),
}
embeddedMethods := []*Func{
NewFunc(nopos, nil, "M", sig2),
}
embedded := NewInterfaceType(embeddedMethods, nil)
iface := NewInterfaceType(methods, []Type{embedded})
iface.NumMethods() // unlike go/types, there is no Complete() method, so we complete implicitly
}
func TestNewAlias_Issue65455(t *testing.T) {
obj := NewTypeName(nopos, nil, "A", nil)
alias := NewAlias(obj, Typ[Int])
alias.Underlying() // must not panic
}
func TestIssue15305(t *testing.T) {
const src = "package p; func f() int16; var _ = f(undef)"
f := mustParse(src)
conf := Config{
Error: func(err error) {}, // allow errors
}
info := &Info{
Types: make(map[syntax.Expr]TypeAndValue),
}
conf.Check("p", []*syntax.File{f}, info) // ignore result
for e, tv := range info.Types {
if _, ok := e.(*syntax.CallExpr); ok {
if tv.Type != Typ[Int16] {
t.Errorf("CallExpr has type %v, want int16", tv.Type)
}
return
}
}
t.Errorf("CallExpr has no type")
}
// TestCompositeLitTypes verifies that Info.Types registers the correct
// types for composite literal expressions and composite literal type
// expressions.
func TestCompositeLitTypes(t *testing.T) {
for i, test := range []struct {
lit, typ string
}{
{`[16]byte{}`, `[16]byte`},
{`[...]byte{}`, `[0]byte`}, // test for go.dev/issue/14092
{`[...]int{1, 2, 3}`, `[3]int`}, // test for go.dev/issue/14092
{`[...]int{90: 0, 98: 1, 2}`, `[100]int`}, // test for go.dev/issue/14092
{`[]int{}`, `[]int`},
{`map[string]bool{"foo": true}`, `map[string]bool`},
{`struct{}{}`, `struct{}`},
{`struct{x, y int; z complex128}{}`, `struct{x int; y int; z complex128}`},
} {
f := mustParse(fmt.Sprintf("package p%d; var _ = %s", i, test.lit))
types := make(map[syntax.Expr]TypeAndValue)
if _, err := new(Config).Check("p", []*syntax.File{f}, &Info{Types: types}); err != nil {
t.Fatalf("%s: %v", test.lit, err)
}
cmptype := func(x syntax.Expr, want string) {
tv, ok := types[x]
if !ok {
t.Errorf("%s: no Types entry found", test.lit)
return
}
if tv.Type == nil {
t.Errorf("%s: type is nil", test.lit)
return
}
if got := tv.Type.String(); got != want {
t.Errorf("%s: got %v, want %s", test.lit, got, want)
}
}
// test type of composite literal expression
rhs := f.DeclList[0].(*syntax.VarDecl).Values
cmptype(rhs, test.typ)
// test type of composite literal type expression
cmptype(rhs.(*syntax.CompositeLit).Type, test.typ)
}
}
// TestObjectParents verifies that objects have parent scopes or not
// as specified by the Object interface.
func TestObjectParents(t *testing.T) {
const src = `
package p
const C = 0
type T1 struct {
a, b int
T2
}
type T2 interface {
im1()
im2()
}
func (T1) m1() {}
func (*T1) m2() {}
func f(x int) { y := x; print(y) }
`
f := mustParse(src)
info := &Info{
Defs: make(map[*syntax.Name]Object),
}
if _, err := new(Config).Check("p", []*syntax.File{f}, info); err != nil {
t.Fatal(err)
}
for ident, obj := range info.Defs {
if obj == nil {
// only package names and implicit vars have a nil object
// (in this test we only need to handle the package name)
if ident.Value != "p" {
t.Errorf("%v has nil object", ident)
}
continue
}
// struct fields, type-associated and interface methods
// have no parent scope
wantParent := true
switch obj := obj.(type) {
case *Var:
if obj.IsField() {
wantParent = false
}
case *Func:
if obj.Type().(*Signature).Recv() != nil { // method
wantParent = false
}
}
gotParent := obj.Parent() != nil
switch {
case gotParent && !wantParent:
t.Errorf("%v: want no parent, got %s", ident, obj.Parent())
case !gotParent && wantParent:
t.Errorf("%v: no parent found", ident)
}
}
}
// TestFailedImport tests that we don't get follow-on errors
// elsewhere in a package due to failing to import a package.
func TestFailedImport(t *testing.T) {
testenv.MustHaveGoBuild(t)
const src = `
package p
import foo "go/types/thisdirectorymustnotexistotherwisethistestmayfail/foo" // should only see an error here
const c = foo.C
type T = foo.T
var v T = c
func f(x T) T { return foo.F(x) }
`
f := mustParse(src)
files := []*syntax.File{f}
// type-check using all possible importers
for _, compiler := range []string{"gc", "gccgo", "source"} {
errcount := 0
conf := Config{
Error: func(err error) {
// we should only see the import error
if errcount > 0 || !strings.Contains(err.Error(), "could not import") {
t.Errorf("for %s importer, got unexpected error: %v", compiler, err)
}
errcount++
},
//Importer: importer.For(compiler, nil),
}
info := &Info{
Uses: make(map[*syntax.Name]Object),
}
pkg, _ := conf.Check("p", files, info)
if pkg == nil {
t.Errorf("for %s importer, type-checking failed to return a package", compiler)
continue
}
imports := pkg.Imports()
if len(imports) != 1 {
t.Errorf("for %s importer, got %d imports, want 1", compiler, len(imports))
continue
}
imp := imports[0]
if imp.Name() != "foo" {
t.Errorf(`for %s importer, got %q, want "foo"`, compiler, imp.Name())
continue
}
// verify that all uses of foo refer to the imported package foo (imp)
for ident, obj := range info.Uses {
if ident.Value == "foo" {
if obj, ok := obj.(*PkgName); ok {
if obj.Imported() != imp {
t.Errorf("%s resolved to %v; want %v", ident.Value, obj.Imported(), imp)
}
} else {
t.Errorf("%s resolved to %v; want package name", ident.Value, obj)
}
}
}
}
}
func TestInstantiate(t *testing.T) {
// eventually we like more tests but this is a start
const src = "package p; type T[P any] *T[P]"
pkg := mustTypecheck(src, nil, nil)
// type T should have one type parameter
T := pkg.Scope().Lookup("T").Type().(*Named)
if n := T.TypeParams().Len(); n != 1 {
t.Fatalf("expected 1 type parameter; found %d", n)
}
// instantiation should succeed (no endless recursion)
// even with a nil *Checker
res, err := Instantiate(nil, T, []Type{Typ[Int]}, false)
if err != nil {
t.Fatal(err)
}
// instantiated type should point to itself
if p := res.Underlying().(*Pointer).Elem(); p != res {
t.Fatalf("unexpected result type: %s points to %s", res, p)
}
}
func TestInstantiateConcurrent(t *testing.T) {
const src = `package p
type I[P any] interface {
m(P)
n() P
}
type J = I[int]
type Nested[P any] *interface{b(P)}
type K = Nested[string]
`
pkg := mustTypecheck(src, nil, nil)
insts := []*Interface{
pkg.Scope().Lookup("J").Type().Underlying().(*Interface),
pkg.Scope().Lookup("K").Type().Underlying().(*Pointer).Elem().(*Interface),
}
// Use the interface instances concurrently.
for _, inst := range insts {
var (
counts [2]int // method counts
methods [2][]string // method strings
)
var wg sync.WaitGroup
for i := 0; i < 2; i++ {
i := i
wg.Add(1)
go func() {
defer wg.Done()
counts[i] = inst.NumMethods()
for mi := 0; mi < counts[i]; mi++ {
methods[i] = append(methods[i], inst.Method(mi).String())
}
}()
}
wg.Wait()
if counts[0] != counts[1] {
t.Errorf("mismatching method counts for %s: %d vs %d", inst, counts[0], counts[1])
continue
}
for i := 0; i < counts[0]; i++ {
if m0, m1 := methods[0][i], methods[1][i]; m0 != m1 {
t.Errorf("mismatching methods for %s: %s vs %s", inst, m0, m1)
}
}
}
}
func TestInstantiateErrors(t *testing.T) {
tests := []struct {
src string // by convention, T must be the type being instantiated
targs []Type
wantAt int // -1 indicates no error
}{
{"type T[P interface{~string}] int", []Type{Typ[Int]}, 0},
{"type T[P1 interface{int}, P2 interface{~string}] int", []Type{Typ[Int], Typ[Int]}, 1},
{"type T[P1 any, P2 interface{~[]P1}] int", []Type{Typ[Int], NewSlice(Typ[String])}, 1},
{"type T[P1 interface{~[]P2}, P2 any] int", []Type{NewSlice(Typ[String]), Typ[Int]}, 0},
}
for _, test := range tests {
src := "package p; " + test.src
pkg := mustTypecheck(src, nil, nil)
T := pkg.Scope().Lookup("T").Type().(*Named)
_, err := Instantiate(nil, T, test.targs, true)
if err == nil {
t.Fatalf("Instantiate(%v, %v) returned nil error, want non-nil", T, test.targs)
}
var argErr *ArgumentError
if !errors.As(err, &argErr) {
t.Fatalf("Instantiate(%v, %v): error is not an *ArgumentError", T, test.targs)
}
if argErr.Index != test.wantAt {
t.Errorf("Instantiate(%v, %v): error at index %d, want index %d", T, test.targs, argErr.Index, test.wantAt)
}
}
}
func TestArgumentErrorUnwrapping(t *testing.T) {
var err error = &ArgumentError{
Index: 1,
Err: Error{Msg: "test"},
}
var e Error
if !errors.As(err, &e) {
t.Fatalf("error %v does not wrap types.Error", err)
}
if e.Msg != "test" {
t.Errorf("e.Msg = %q, want %q", e.Msg, "test")
}
}
func TestInstanceIdentity(t *testing.T) {
imports := make(testImporter)
conf := Config{Importer: imports}
makePkg := func(src string) {
f := mustParse(src)
name := f.PkgName.Value
pkg, err := conf.Check(name, []*syntax.File{f}, nil)
if err != nil {
t.Fatal(err)
}
imports[name] = pkg
}
makePkg(`package lib; type T[P any] struct{}`)
makePkg(`package a; import "lib"; var A lib.T[int]`)
makePkg(`package b; import "lib"; var B lib.T[int]`)
a := imports["a"].Scope().Lookup("A")
b := imports["b"].Scope().Lookup("B")
if !Identical(a.Type(), b.Type()) {
t.Errorf("mismatching types: a.A: %s, b.B: %s", a.Type(), b.Type())
}
}
// TestInstantiatedObjects verifies properties of instantiated objects.
func TestInstantiatedObjects(t *testing.T) {
const src = `
package p
type T[P any] struct {
field P
}
func (recv *T[Q]) concreteMethod(mParam Q) (mResult Q) { return }
type FT[P any] func(ftParam P) (ftResult P)
func F[P any](fParam P) (fResult P){ return }
type I[P any] interface {
interfaceMethod(P)
}
type R[P any] T[P]
func (R[P]) m() {} // having a method triggers expansion of R
var (
t T[int]
ft FT[int]
f = F[int]
i I[int]
)
func fn() {
var r R[int]
_ = r
}
`
info := &Info{
Defs: make(map[*syntax.Name]Object),
}
f := mustParse(src)
conf := Config{}
pkg, err := conf.Check(f.PkgName.Value, []*syntax.File{f}, info)
if err != nil {
t.Fatal(err)
}
lookup := func(name string) Type { return pkg.Scope().Lookup(name).Type() }
fnScope := pkg.Scope().Lookup("fn").(*Func).Scope()
tests := []struct {
name string
obj Object
}{
// Struct fields
{"field", lookup("t").Underlying().(*Struct).Field(0)},
{"field", fnScope.Lookup("r").Type().Underlying().(*Struct).Field(0)},
// Methods and method fields
{"concreteMethod", lookup("t").(*Named).Method(0)},
{"recv", lookup("t").(*Named).Method(0).Type().(*Signature).Recv()},
{"mParam", lookup("t").(*Named).Method(0).Type().(*Signature).Params().At(0)},
{"mResult", lookup("t").(*Named).Method(0).Type().(*Signature).Results().At(0)},
// Interface methods
{"interfaceMethod", lookup("i").Underlying().(*Interface).Method(0)},
// Function type fields
{"ftParam", lookup("ft").Underlying().(*Signature).Params().At(0)},
{"ftResult", lookup("ft").Underlying().(*Signature).Results().At(0)},
// Function fields
{"fParam", lookup("f").(*Signature).Params().At(0)},
{"fResult", lookup("f").(*Signature).Results().At(0)},
}
// Collect all identifiers by name.
idents := make(map[string][]*syntax.Name)
syntax.Inspect(f, func(n syntax.Node) bool {
if id, ok := n.(*syntax.Name); ok {
idents[id.Value] = append(idents[id.Value], id)
}
return true
})
for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) {
if got := len(idents[test.name]); got != 1 {
t.Fatalf("found %d identifiers named %s, want 1", got, test.name)
}
ident := idents[test.name][0]
def := info.Defs[ident]
if def == test.obj {
t.Fatalf("info.Defs[%s] contains the test object", test.name)
}
if orig := originObject(test.obj); def != orig {
t.Errorf("info.Defs[%s] does not match obj.Origin()", test.name)
}
if def.Pkg() != test.obj.Pkg() {
t.Errorf("Pkg() = %v, want %v", def.Pkg(), test.obj.Pkg())
}
if def.Name() != test.obj.Name() {
t.Errorf("Name() = %v, want %v", def.Name(), test.obj.Name())
}
if def.Pos() != test.obj.Pos() {
t.Errorf("Pos() = %v, want %v", def.Pos(), test.obj.Pos())
}
if def.Parent() != test.obj.Parent() {
t.Fatalf("Parent() = %v, want %v", def.Parent(), test.obj.Parent())
}
if def.Exported() != test.obj.Exported() {
t.Fatalf("Exported() = %v, want %v", def.Exported(), test.obj.Exported())
}
if def.Id() != test.obj.Id() {
t.Fatalf("Id() = %v, want %v", def.Id(), test.obj.Id())
}
// String and Type are expected to differ.
})
}
}
func originObject(obj Object) Object {
switch obj := obj.(type) {
case *Var:
return obj.Origin()
case *Func:
return obj.Origin()
}
return obj
}
func TestImplements(t *testing.T) {
const src = `
package p
type EmptyIface interface{}
type I interface {
m()
}
type C interface {
m()
~int
}
type Integer interface{
int8 | int16 | int32 | int64
}
type EmptyTypeSet interface{
Integer
~string
}
type N1 int
func (N1) m() {}
type N2 int
func (*N2) m() {}
type N3 int
func (N3) m(int) {}
type N4 string
func (N4) m()
type Bad Bad // invalid type
`
f := mustParse(src)
conf := Config{Error: func(error) {}}
pkg, _ := conf.Check(f.PkgName.Value, []*syntax.File{f}, nil)
lookup := func(tname string) Type { return pkg.Scope().Lookup(tname).Type() }
var (
EmptyIface = lookup("EmptyIface").Underlying().(*Interface)
I = lookup("I").(*Named)
II = I.Underlying().(*Interface)
C = lookup("C").(*Named)
CI = C.Underlying().(*Interface)
Integer = lookup("Integer").Underlying().(*Interface)
EmptyTypeSet = lookup("EmptyTypeSet").Underlying().(*Interface)
N1 = lookup("N1")
N1p = NewPointer(N1)
N2 = lookup("N2")
N2p = NewPointer(N2)
N3 = lookup("N3")
N4 = lookup("N4")
Bad = lookup("Bad")
)
tests := []struct {
V Type
T *Interface
want bool
}{
{I, II, true},
{I, CI, false},
{C, II, true},
{C, CI, true},
{Typ[Int8], Integer, true},
{Typ[Int64], Integer, true},
{Typ[String], Integer, false},
{EmptyTypeSet, II, true},
{EmptyTypeSet, EmptyTypeSet, true},
{Typ[Int], EmptyTypeSet, false},
{N1, II, true},
{N1, CI, true},
{N1p, II, true},
{N1p, CI, false},
{N2, II, false},
{N2, CI, false},
{N2p, II, true},
{N2p, CI, false},
{N3, II, false},
{N3, CI, false},
{N4, II, true},
{N4, CI, false},
{Bad, II, false},
{Bad, CI, false},
{Bad, EmptyIface, true},
}
for _, test := range tests {
if got := Implements(test.V, test.T); got != test.want {
t.Errorf("Implements(%s, %s) = %t, want %t", test.V, test.T, got, test.want)
}
// The type assertion x.(T) is valid if T is an interface or if T implements the type of x.
// The assertion is never valid if T is a bad type.
V := test.T
T := test.V
want := false
if _, ok := T.Underlying().(*Interface); (ok || Implements(T, V)) && T != Bad {
want = true
}
if got := AssertableTo(V, T); got != want {
t.Errorf("AssertableTo(%s, %s) = %t, want %t", V, T, got, want)
}
}
}
func TestMissingMethodAlternative(t *testing.T) {
const src = `
package p
type T interface {
m()
}
type V0 struct{}
func (V0) m() {}
type V1 struct{}
type V2 struct{}
func (V2) m() int
type V3 struct{}
func (*V3) m()
type V4 struct{}
func (V4) M()
`
pkg := mustTypecheck(src, nil, nil)
T := pkg.Scope().Lookup("T").Type().Underlying().(*Interface)
lookup := func(name string) (*Func, bool) {
return MissingMethod(pkg.Scope().Lookup(name).Type(), T, true)
}
// V0 has method m with correct signature. Should not report wrongType.
method, wrongType := lookup("V0")
if method != nil || wrongType {
t.Fatalf("V0: got method = %v, wrongType = %v", method, wrongType)
}
checkMissingMethod := func(tname string, reportWrongType bool) {
method, wrongType := lookup(tname)
if method == nil || method.Name() != "m" || wrongType != reportWrongType {
t.Fatalf("%s: got method = %v, wrongType = %v", tname, method, wrongType)
}
}
// V1 has no method m. Should not report wrongType.
checkMissingMethod("V1", false)
// V2 has method m with wrong signature type (ignoring receiver). Should report wrongType.
checkMissingMethod("V2", true)
// V3 has no method m but it exists on *V3. Should report wrongType.
checkMissingMethod("V3", true)
// V4 has no method m but has M. Should not report wrongType.
checkMissingMethod("V4", false)
}
func TestErrorURL(t *testing.T) {
conf := Config{ErrorURL: " [go.dev/e/%s]"}
// test case for a one-line error
const src1 = `
package p
var _ T
`
_, err := typecheck(src1, &conf, nil)
if err == nil || !strings.HasSuffix(err.Error(), " [go.dev/e/UndeclaredName]") {
t.Errorf("src1: unexpected error: got %v", err)
}
// test case for a multi-line error
const src2 = `
package p
func f() int { return 0 }
var _ = f(1, 2)
`
_, err = typecheck(src2, &conf, nil)
if err == nil || !strings.Contains(err.Error(), " [go.dev/e/WrongArgCount]\n") {
t.Errorf("src1: unexpected error: got %v", err)
}
}
func TestModuleVersion(t *testing.T) {
// version go1.dd must be able to typecheck go1.dd.0, go1.dd.1, etc.
goversion := fmt.Sprintf("go1.%d", goversion.Version)
for _, v := range []string{
goversion,
goversion + ".0",
goversion + ".1",
goversion + ".rc",
} {
conf := Config{GoVersion: v}
pkg := mustTypecheck("package p", &conf, nil)
if pkg.GoVersion() != conf.GoVersion {
t.Errorf("got %s; want %s", pkg.GoVersion(), conf.GoVersion)
}
}
}
func TestFileVersions(t *testing.T) {
for _, test := range []struct {
goVersion string
fileVersion string
wantVersion string
}{
{"", "", ""}, // no versions specified
{"go1.19", "", "go1.19"}, // module version specified
{"", "go1.20", ""}, // file upgrade ignored
{"go1.19", "go1.20", "go1.20"}, // file upgrade permitted
{"go1.20", "go1.19", "go1.20"}, // file downgrade not permitted
{"go1.21", "go1.19", "go1.19"}, // file downgrade permitted (module version is >= go1.21)
// versions containing release numbers
// (file versions containing release numbers are considered invalid)
{"go1.19.0", "", "go1.19.0"}, // no file version specified
{"go1.20", "go1.20.1", "go1.20"}, // file upgrade ignored
{"go1.20.1", "go1.20", "go1.20.1"}, // file upgrade ignored
{"go1.20.1", "go1.21", "go1.21"}, // file upgrade permitted
{"go1.20.1", "go1.19", "go1.20.1"}, // file downgrade not permitted
{"go1.21.1", "go1.19.1", "go1.21.1"}, // file downgrade not permitted (invalid file version)
{"go1.21.1", "go1.19", "go1.19"}, // file downgrade permitted (module version is >= go1.21)
} {
var src string
if test.fileVersion != "" {
src = "//go:build " + test.fileVersion + "\n"
}
src += "package p"
conf := Config{GoVersion: test.goVersion}
versions := make(map[*syntax.PosBase]string)
var info Info
info.FileVersions = versions
mustTypecheck(src, &conf, &info)
n := 0
for _, v := range info.FileVersions {
want := test.wantVersion
if v != want {
t.Errorf("%q: unexpected file version: got %v, want %v", src, v, want)
}
n++
}
if n != 1 {
t.Errorf("%q: incorrect number of map entries: got %d", src, n)
}
}
}
// TestTooNew ensures that "too new" errors are emitted when the file
// or module is tagged with a newer version of Go than this go/types.
func TestTooNew(t *testing.T) {
for _, test := range []struct {
goVersion string // package's Go version (as if derived from go.mod file)
fileVersion string // file's Go version (becomes a build tag)
wantErr string // expected substring of concatenation of all errors
}{
{"go1.98", "", "package requires newer Go version go1.98"},
{"", "go1.99", "p:2:9: file requires newer Go version go1.99"},
{"go1.98", "go1.99", "package requires newer Go version go1.98"}, // (two
{"go1.98", "go1.99", "file requires newer Go version go1.99"}, // errors)
} {
var src string
if test.fileVersion != "" {
src = "//go:build " + test.fileVersion + "\n"
}
src += "package p; func f()"
var errs []error
conf := Config{
GoVersion: test.goVersion,
Error: func(err error) { errs = append(errs, err) },
}
info := &Info{Defs: make(map[*syntax.Name]Object)}
typecheck(src, &conf, info)
got := fmt.Sprint(errs)
if !strings.Contains(got, test.wantErr) {
t.Errorf("%q: unexpected error: got %q, want substring %q",
src, got, test.wantErr)
}
// Assert that declarations were type checked nonetheless.
var gotObjs []string
for id, obj := range info.Defs {
if obj != nil {
objStr := strings.ReplaceAll(fmt.Sprintf("%s:%T", id.Value, obj), "types2", "types")
gotObjs = append(gotObjs, objStr)
}
}
wantObjs := "f:*types.Func"
if !strings.Contains(fmt.Sprint(gotObjs), wantObjs) {
t.Errorf("%q: got %s, want substring %q",
src, gotObjs, wantObjs)
}
}
}
// This is a regression test for #66704.
func TestUnaliasTooSoonInCycle(t *testing.T) {
t.Setenv("GODEBUG", "gotypesalias=1")
const src = `package a
var x T[B] // this appears to cause Unalias to be called on B while still Invalid
type T[_ any] struct{}
type A T[B]
type B = T[A]
`
pkg := mustTypecheck(src, nil, nil)
B := pkg.Scope().Lookup("B")
got, want := Unalias(B.Type()).String(), "a.T[a.A]"
if got != want {
t.Errorf("Unalias(type B = T[A]) = %q, want %q", got, want)
}
}
func TestAlias_Rhs(t *testing.T) {
const src = `package p
type A = B
type B = C
type C = int
`
pkg := mustTypecheck(src, &Config{EnableAlias: true}, nil)
A := pkg.Scope().Lookup("A")
got, want := A.Type().(*Alias).Rhs().String(), "p.B"
if got != want {
t.Errorf("A.Rhs = %s, want %s", got, want)
}
}
// Test the hijacking described of "any" described in golang/go#66921, for
// (concurrent) type checking.
func TestAnyHijacking_Check(t *testing.T) {
for _, enableAlias := range []bool{false, true} {
t.Run(fmt.Sprintf("EnableAlias=%t", enableAlias), func(t *testing.T) {
var wg sync.WaitGroup
for i := 0; i < 10; i++ {
wg.Add(1)
go func() {
defer wg.Done()
pkg := mustTypecheck("package p; var x any", &Config{EnableAlias: enableAlias}, nil)
x := pkg.Scope().Lookup("x")
if _, gotAlias := x.Type().(*Alias); gotAlias != enableAlias {
t.Errorf(`Lookup("x").Type() is %T: got Alias: %t, want %t`, x.Type(), gotAlias, enableAlias)
}
}()
}
wg.Wait()
})
}
}
|
go/src/cmd/compile/internal/types2/api_test.go/0
|
{
"file_path": "go/src/cmd/compile/internal/types2/api_test.go",
"repo_id": "go",
"token_count": 41900
}
| 117 |
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package types2
import (
"cmd/compile/internal/syntax"
"fmt"
"go/constant"
"internal/buildcfg"
. "internal/types/errors"
)
func (check *Checker) declare(scope *Scope, id *syntax.Name, obj Object, pos syntax.Pos) {
// spec: "The blank identifier, represented by the underscore
// character _, may be used in a declaration like any other
// identifier but the declaration does not introduce a new
// binding."
if obj.Name() != "_" {
if alt := scope.Insert(obj); alt != nil {
err := check.newError(DuplicateDecl)
err.addf(obj, "%s redeclared in this block", obj.Name())
err.addAltDecl(alt)
err.report()
return
}
obj.setScopePos(pos)
}
if id != nil {
check.recordDef(id, obj)
}
}
// pathString returns a string of the form a->b-> ... ->g for a path [a, b, ... g].
func pathString(path []Object) string {
var s string
for i, p := range path {
if i > 0 {
s += "->"
}
s += p.Name()
}
return s
}
// objDecl type-checks the declaration of obj in its respective (file) environment.
// For the meaning of def, see Checker.definedType, in typexpr.go.
func (check *Checker) objDecl(obj Object, def *TypeName) {
if check.conf.Trace && obj.Type() == nil {
if check.indent == 0 {
fmt.Println() // empty line between top-level objects for readability
}
check.trace(obj.Pos(), "-- checking %s (%s, objPath = %s)", obj, obj.color(), pathString(check.objPath))
check.indent++
defer func() {
check.indent--
check.trace(obj.Pos(), "=> %s (%s)", obj, obj.color())
}()
}
// Checking the declaration of obj means inferring its type
// (and possibly its value, for constants).
// An object's type (and thus the object) may be in one of
// three states which are expressed by colors:
//
// - an object whose type is not yet known is painted white (initial color)
// - an object whose type is in the process of being inferred is painted grey
// - an object whose type is fully inferred is painted black
//
// During type inference, an object's color changes from white to grey
// to black (pre-declared objects are painted black from the start).
// A black object (i.e., its type) can only depend on (refer to) other black
// ones. White and grey objects may depend on white and black objects.
// A dependency on a grey object indicates a cycle which may or may not be
// valid.
//
// When objects turn grey, they are pushed on the object path (a stack);
// they are popped again when they turn black. Thus, if a grey object (a
// cycle) is encountered, it is on the object path, and all the objects
// it depends on are the remaining objects on that path. Color encoding
// is such that the color value of a grey object indicates the index of
// that object in the object path.
// During type-checking, white objects may be assigned a type without
// traversing through objDecl; e.g., when initializing constants and
// variables. Update the colors of those objects here (rather than
// everywhere where we set the type) to satisfy the color invariants.
if obj.color() == white && obj.Type() != nil {
obj.setColor(black)
return
}
switch obj.color() {
case white:
assert(obj.Type() == nil)
// All color values other than white and black are considered grey.
// Because black and white are < grey, all values >= grey are grey.
// Use those values to encode the object's index into the object path.
obj.setColor(grey + color(check.push(obj)))
defer func() {
check.pop().setColor(black)
}()
case black:
assert(obj.Type() != nil)
return
default:
// Color values other than white or black are considered grey.
fallthrough
case grey:
// We have a (possibly invalid) cycle.
// In the existing code, this is marked by a non-nil type
// for the object except for constants and variables whose
// type may be non-nil (known), or nil if it depends on the
// not-yet known initialization value.
// In the former case, set the type to Typ[Invalid] because
// we have an initialization cycle. The cycle error will be
// reported later, when determining initialization order.
// TODO(gri) Report cycle here and simplify initialization
// order code.
switch obj := obj.(type) {
case *Const:
if !check.validCycle(obj) || obj.typ == nil {
obj.typ = Typ[Invalid]
}
case *Var:
if !check.validCycle(obj) || obj.typ == nil {
obj.typ = Typ[Invalid]
}
case *TypeName:
if !check.validCycle(obj) {
// break cycle
// (without this, calling underlying()
// below may lead to an endless loop
// if we have a cycle for a defined
// (*Named) type)
obj.typ = Typ[Invalid]
}
case *Func:
if !check.validCycle(obj) {
// Don't set obj.typ to Typ[Invalid] here
// because plenty of code type-asserts that
// functions have a *Signature type. Grey
// functions have their type set to an empty
// signature which makes it impossible to
// initialize a variable with the function.
}
default:
panic("unreachable")
}
assert(obj.Type() != nil)
return
}
d := check.objMap[obj]
if d == nil {
check.dump("%v: %s should have been declared", obj.Pos(), obj)
panic("unreachable")
}
// save/restore current environment and set up object environment
defer func(env environment) {
check.environment = env
}(check.environment)
check.environment = environment{
scope: d.file,
}
// Const and var declarations must not have initialization
// cycles. We track them by remembering the current declaration
// in check.decl. Initialization expressions depending on other
// consts, vars, or functions, add dependencies to the current
// check.decl.
switch obj := obj.(type) {
case *Const:
check.decl = d // new package-level const decl
check.constDecl(obj, d.vtyp, d.init, d.inherited)
case *Var:
check.decl = d // new package-level var decl
check.varDecl(obj, d.lhs, d.vtyp, d.init)
case *TypeName:
// invalid recursive types are detected via path
check.typeDecl(obj, d.tdecl, def)
check.collectMethods(obj) // methods can only be added to top-level types
case *Func:
// functions may be recursive - no need to track dependencies
check.funcDecl(obj, d)
default:
panic("unreachable")
}
}
// validCycle reports whether the cycle starting with obj is valid and
// reports an error if it is not.
func (check *Checker) validCycle(obj Object) (valid bool) {
// The object map contains the package scope objects and the non-interface methods.
if debug {
info := check.objMap[obj]
inObjMap := info != nil && (info.fdecl == nil || info.fdecl.Recv == nil) // exclude methods
isPkgObj := obj.Parent() == check.pkg.scope
if isPkgObj != inObjMap {
check.dump("%v: inconsistent object map for %s (isPkgObj = %v, inObjMap = %v)", obj.Pos(), obj, isPkgObj, inObjMap)
panic("unreachable")
}
}
// Count cycle objects.
assert(obj.color() >= grey)
start := obj.color() - grey // index of obj in objPath
cycle := check.objPath[start:]
tparCycle := false // if set, the cycle is through a type parameter list
nval := 0 // number of (constant or variable) values in the cycle; valid if !generic
ndef := 0 // number of type definitions in the cycle; valid if !generic
loop:
for _, obj := range cycle {
switch obj := obj.(type) {
case *Const, *Var:
nval++
case *TypeName:
// If we reach a generic type that is part of a cycle
// and we are in a type parameter list, we have a cycle
// through a type parameter list, which is invalid.
if check.inTParamList && isGeneric(obj.typ) {
tparCycle = true
break loop
}
// Determine if the type name is an alias or not. For
// package-level objects, use the object map which
// provides syntactic information (which doesn't rely
// on the order in which the objects are set up). For
// local objects, we can rely on the order, so use
// the object's predicate.
// TODO(gri) It would be less fragile to always access
// the syntactic information. We should consider storing
// this information explicitly in the object.
var alias bool
if check.conf.EnableAlias {
alias = obj.IsAlias()
} else {
if d := check.objMap[obj]; d != nil {
alias = d.tdecl.Alias // package-level object
} else {
alias = obj.IsAlias() // function local object
}
}
if !alias {
ndef++
}
case *Func:
// ignored for now
default:
panic("unreachable")
}
}
if check.conf.Trace {
check.trace(obj.Pos(), "## cycle detected: objPath = %s->%s (len = %d)", pathString(cycle), obj.Name(), len(cycle))
if tparCycle {
check.trace(obj.Pos(), "## cycle contains: generic type in a type parameter list")
} else {
check.trace(obj.Pos(), "## cycle contains: %d values, %d type definitions", nval, ndef)
}
defer func() {
if valid {
check.trace(obj.Pos(), "=> cycle is valid")
} else {
check.trace(obj.Pos(), "=> error: cycle is invalid")
}
}()
}
if !tparCycle {
// A cycle involving only constants and variables is invalid but we
// ignore them here because they are reported via the initialization
// cycle check.
if nval == len(cycle) {
return true
}
// A cycle involving only types (and possibly functions) must have at least
// one type definition to be permitted: If there is no type definition, we
// have a sequence of alias type names which will expand ad infinitum.
if nval == 0 && ndef > 0 {
return true
}
}
check.cycleError(cycle, firstInSrc(cycle))
return false
}
// cycleError reports a declaration cycle starting with the object at cycle[start].
func (check *Checker) cycleError(cycle []Object, start int) {
// name returns the (possibly qualified) object name.
// This is needed because with generic types, cycles
// may refer to imported types. See go.dev/issue/50788.
// TODO(gri) This functionality is used elsewhere. Factor it out.
name := func(obj Object) string {
return packagePrefix(obj.Pkg(), check.qualifier) + obj.Name()
}
obj := cycle[start]
objName := name(obj)
// If obj is a type alias, mark it as valid (not broken) in order to avoid follow-on errors.
tname, _ := obj.(*TypeName)
if tname != nil && tname.IsAlias() {
// If we use Alias nodes, it is initialized with Typ[Invalid].
// TODO(gri) Adjust this code if we initialize with nil.
if !check.conf.EnableAlias {
check.validAlias(tname, Typ[Invalid])
}
}
// report a more concise error for self references
if len(cycle) == 1 {
if tname != nil {
check.errorf(obj, InvalidDeclCycle, "invalid recursive type: %s refers to itself", objName)
} else {
check.errorf(obj, InvalidDeclCycle, "invalid cycle in declaration: %s refers to itself", objName)
}
return
}
err := check.newError(InvalidDeclCycle)
if tname != nil {
err.addf(obj, "invalid recursive type %s", objName)
} else {
err.addf(obj, "invalid cycle in declaration of %s", objName)
}
i := start
for range cycle {
err.addf(obj, "%s refers to", objName)
i++
if i >= len(cycle) {
i = 0
}
obj = cycle[i]
objName = name(obj)
}
err.addf(obj, "%s", objName)
err.report()
}
// firstInSrc reports the index of the object with the "smallest"
// source position in path. path must not be empty.
func firstInSrc(path []Object) int {
fst, pos := 0, path[0].Pos()
for i, t := range path[1:] {
if cmpPos(t.Pos(), pos) < 0 {
fst, pos = i+1, t.Pos()
}
}
return fst
}
func (check *Checker) constDecl(obj *Const, typ, init syntax.Expr, inherited bool) {
assert(obj.typ == nil)
// use the correct value of iota and errpos
defer func(iota constant.Value, errpos syntax.Pos) {
check.iota = iota
check.errpos = errpos
}(check.iota, check.errpos)
check.iota = obj.val
check.errpos = nopos
// provide valid constant value under all circumstances
obj.val = constant.MakeUnknown()
// determine type, if any
if typ != nil {
t := check.typ(typ)
if !isConstType(t) {
// don't report an error if the type is an invalid C (defined) type
// (go.dev/issue/22090)
if isValid(under(t)) {
check.errorf(typ, InvalidConstType, "invalid constant type %s", t)
}
obj.typ = Typ[Invalid]
return
}
obj.typ = t
}
// check initialization
var x operand
if init != nil {
if inherited {
// The initialization expression is inherited from a previous
// constant declaration, and (error) positions refer to that
// expression and not the current constant declaration. Use
// the constant identifier position for any errors during
// init expression evaluation since that is all we have
// (see issues go.dev/issue/42991, go.dev/issue/42992).
check.errpos = obj.pos
}
check.expr(nil, &x, init)
}
check.initConst(obj, &x)
}
func (check *Checker) varDecl(obj *Var, lhs []*Var, typ, init syntax.Expr) {
assert(obj.typ == nil)
// determine type, if any
if typ != nil {
obj.typ = check.varType(typ)
// We cannot spread the type to all lhs variables if there
// are more than one since that would mark them as checked
// (see Checker.objDecl) and the assignment of init exprs,
// if any, would not be checked.
//
// TODO(gri) If we have no init expr, we should distribute
// a given type otherwise we need to re-evaluate the type
// expr for each lhs variable, leading to duplicate work.
}
// check initialization
if init == nil {
if typ == nil {
// error reported before by arityMatch
obj.typ = Typ[Invalid]
}
return
}
if lhs == nil || len(lhs) == 1 {
assert(lhs == nil || lhs[0] == obj)
var x operand
check.expr(newTarget(obj.typ, obj.name), &x, init)
check.initVar(obj, &x, "variable declaration")
return
}
if debug {
// obj must be one of lhs
found := false
for _, lhs := range lhs {
if obj == lhs {
found = true
break
}
}
if !found {
panic("inconsistent lhs")
}
}
// We have multiple variables on the lhs and one init expr.
// Make sure all variables have been given the same type if
// one was specified, otherwise they assume the type of the
// init expression values (was go.dev/issue/15755).
if typ != nil {
for _, lhs := range lhs {
lhs.typ = obj.typ
}
}
check.initVars(lhs, []syntax.Expr{init}, nil)
}
// isImportedConstraint reports whether typ is an imported type constraint.
func (check *Checker) isImportedConstraint(typ Type) bool {
named := asNamed(typ)
if named == nil || named.obj.pkg == check.pkg || named.obj.pkg == nil {
return false
}
u, _ := named.under().(*Interface)
return u != nil && !u.IsMethodSet()
}
func (check *Checker) typeDecl(obj *TypeName, tdecl *syntax.TypeDecl, def *TypeName) {
assert(obj.typ == nil)
// Only report a version error if we have not reported one already.
versionErr := false
var rhs Type
check.later(func() {
if t := asNamed(obj.typ); t != nil { // type may be invalid
check.validType(t)
}
// If typ is local, an error was already reported where typ is specified/defined.
_ = !versionErr && check.isImportedConstraint(rhs) && check.verifyVersionf(tdecl.Type, go1_18, "using type constraint %s", rhs)
}).describef(obj, "validType(%s)", obj.Name())
// First type parameter, or nil.
var tparam0 *syntax.Field
if len(tdecl.TParamList) > 0 {
tparam0 = tdecl.TParamList[0]
}
// alias declaration
if tdecl.Alias {
// Report highest version requirement first so that fixing a version issue
// avoids possibly two -lang changes (first to Go 1.9 and then to Go 1.23).
if !versionErr && tparam0 != nil && !check.verifyVersionf(tparam0, go1_23, "generic type alias") {
versionErr = true
}
if !versionErr && !check.verifyVersionf(tdecl, go1_9, "type alias") {
versionErr = true
}
if check.conf.EnableAlias {
// TODO(gri) Should be able to use nil instead of Typ[Invalid] to mark
// the alias as incomplete. Currently this causes problems
// with certain cycles. Investigate.
//
// NOTE(adonovan): to avoid the Invalid being prematurely observed
// by (e.g.) a var whose type is an unfinished cycle,
// Unalias does not memoize if Invalid. Perhaps we should use a
// special sentinel distinct from Invalid.
alias := check.newAlias(obj, Typ[Invalid])
setDefType(def, alias)
// handle type parameters even if not allowed (Alias type is supported)
if tparam0 != nil {
if !versionErr && !buildcfg.Experiment.AliasTypeParams {
check.error(tdecl, UnsupportedFeature, "generic type alias requires GOEXPERIMENT=aliastypeparams")
versionErr = true
}
check.openScope(tdecl, "type parameters")
defer check.closeScope()
check.collectTypeParams(&alias.tparams, tdecl.TParamList)
}
rhs = check.definedType(tdecl.Type, obj)
assert(rhs != nil)
alias.fromRHS = rhs
Unalias(alias) // resolve alias.actual
} else {
if !versionErr && tparam0 != nil {
check.error(tdecl, UnsupportedFeature, "generic type alias requires GODEBUG=gotypesalias=1 or unset")
versionErr = true
}
check.brokenAlias(obj)
rhs = check.typ(tdecl.Type)
check.validAlias(obj, rhs)
}
return
}
// type definition or generic type declaration
if !versionErr && tparam0 != nil && !check.verifyVersionf(tparam0, go1_18, "type parameter") {
versionErr = true
}
named := check.newNamed(obj, nil, nil)
setDefType(def, named)
if tdecl.TParamList != nil {
check.openScope(tdecl, "type parameters")
defer check.closeScope()
check.collectTypeParams(&named.tparams, tdecl.TParamList)
}
// determine underlying type of named
rhs = check.definedType(tdecl.Type, obj)
assert(rhs != nil)
named.fromRHS = rhs
// If the underlying type was not set while type-checking the right-hand
// side, it is invalid and an error should have been reported elsewhere.
if named.underlying == nil {
named.underlying = Typ[Invalid]
}
// Disallow a lone type parameter as the RHS of a type declaration (go.dev/issue/45639).
// We don't need this restriction anymore if we make the underlying type of a type
// parameter its constraint interface: if the RHS is a lone type parameter, we will
// use its underlying type (like we do for any RHS in a type declaration), and its
// underlying type is an interface and the type declaration is well defined.
if isTypeParam(rhs) {
check.error(tdecl.Type, MisplacedTypeParam, "cannot use a type parameter as RHS in type declaration")
named.underlying = Typ[Invalid]
}
}
func (check *Checker) collectTypeParams(dst **TypeParamList, list []*syntax.Field) {
tparams := make([]*TypeParam, len(list))
// Declare type parameters up-front.
// The scope of type parameters starts at the beginning of the type parameter
// list (so we can have mutually recursive parameterized type bounds).
if len(list) > 0 {
scopePos := list[0].Pos()
for i, f := range list {
tparams[i] = check.declareTypeParam(f.Name, scopePos)
}
}
// Set the type parameters before collecting the type constraints because
// the parameterized type may be used by the constraints (go.dev/issue/47887).
// Example: type T[P T[P]] interface{}
*dst = bindTParams(tparams)
// Signal to cycle detection that we are in a type parameter list.
// We can only be inside one type parameter list at any given time:
// function closures may appear inside a type parameter list but they
// cannot be generic, and their bodies are processed in delayed and
// sequential fashion. Note that with each new declaration, we save
// the existing environment and restore it when done; thus inTParamList
// is true exactly only when we are in a specific type parameter list.
assert(!check.inTParamList)
check.inTParamList = true
defer func() {
check.inTParamList = false
}()
// Keep track of bounds for later validation.
var bound Type
for i, f := range list {
// Optimization: Re-use the previous type bound if it hasn't changed.
// This also preserves the grouped output of type parameter lists
// when printing type strings.
if i == 0 || f.Type != list[i-1].Type {
bound = check.bound(f.Type)
if isTypeParam(bound) {
// We may be able to allow this since it is now well-defined what
// the underlying type and thus type set of a type parameter is.
// But we may need some additional form of cycle detection within
// type parameter lists.
check.error(f.Type, MisplacedTypeParam, "cannot use a type parameter as constraint")
bound = Typ[Invalid]
}
}
tparams[i].bound = bound
}
}
func (check *Checker) bound(x syntax.Expr) Type {
// A type set literal of the form ~T and A|B may only appear as constraint;
// embed it in an implicit interface so that only interface type-checking
// needs to take care of such type expressions.
if op, _ := x.(*syntax.Operation); op != nil && (op.Op == syntax.Tilde || op.Op == syntax.Or) {
t := check.typ(&syntax.InterfaceType{MethodList: []*syntax.Field{{Type: x}}})
// mark t as implicit interface if all went well
if t, _ := t.(*Interface); t != nil {
t.implicit = true
}
return t
}
return check.typ(x)
}
func (check *Checker) declareTypeParam(name *syntax.Name, scopePos syntax.Pos) *TypeParam {
// Use Typ[Invalid] for the type constraint to ensure that a type
// is present even if the actual constraint has not been assigned
// yet.
// TODO(gri) Need to systematically review all uses of type parameter
// constraints to make sure we don't rely on them if they
// are not properly set yet.
tname := NewTypeName(name.Pos(), check.pkg, name.Value, nil)
tpar := check.newTypeParam(tname, Typ[Invalid]) // assigns type to tname as a side-effect
check.declare(check.scope, name, tname, scopePos)
return tpar
}
func (check *Checker) collectMethods(obj *TypeName) {
// get associated methods
// (Checker.collectObjects only collects methods with non-blank names;
// Checker.resolveBaseTypeName ensures that obj is not an alias name
// if it has attached methods.)
methods := check.methods[obj]
if methods == nil {
return
}
delete(check.methods, obj)
assert(!check.objMap[obj].tdecl.Alias) // don't use TypeName.IsAlias (requires fully set up object)
// use an objset to check for name conflicts
var mset objset
// spec: "If the base type is a struct type, the non-blank method
// and field names must be distinct."
base := asNamed(obj.typ) // shouldn't fail but be conservative
if base != nil {
assert(base.TypeArgs().Len() == 0) // collectMethods should not be called on an instantiated type
// See go.dev/issue/52529: we must delay the expansion of underlying here, as
// base may not be fully set-up.
check.later(func() {
check.checkFieldUniqueness(base)
}).describef(obj, "verifying field uniqueness for %v", base)
// Checker.Files may be called multiple times; additional package files
// may add methods to already type-checked types. Add pre-existing methods
// so that we can detect redeclarations.
for i := 0; i < base.NumMethods(); i++ {
m := base.Method(i)
assert(m.name != "_")
assert(mset.insert(m) == nil)
}
}
// add valid methods
for _, m := range methods {
// spec: "For a base type, the non-blank names of methods bound
// to it must be unique."
assert(m.name != "_")
if alt := mset.insert(m); alt != nil {
if alt.Pos().IsKnown() {
check.errorf(m.pos, DuplicateMethod, "method %s.%s already declared at %v", obj.Name(), m.name, alt.Pos())
} else {
check.errorf(m.pos, DuplicateMethod, "method %s.%s already declared", obj.Name(), m.name)
}
continue
}
if base != nil {
base.AddMethod(m)
}
}
}
func (check *Checker) checkFieldUniqueness(base *Named) {
if t, _ := base.under().(*Struct); t != nil {
var mset objset
for i := 0; i < base.NumMethods(); i++ {
m := base.Method(i)
assert(m.name != "_")
assert(mset.insert(m) == nil)
}
// Check that any non-blank field names of base are distinct from its
// method names.
for _, fld := range t.fields {
if fld.name != "_" {
if alt := mset.insert(fld); alt != nil {
// Struct fields should already be unique, so we should only
// encounter an alternate via collision with a method name.
_ = alt.(*Func)
// For historical consistency, we report the primary error on the
// method, and the alt decl on the field.
err := check.newError(DuplicateFieldAndMethod)
err.addf(alt, "field and method with the same name %s", fld.name)
err.addAltDecl(fld)
err.report()
}
}
}
}
}
func (check *Checker) funcDecl(obj *Func, decl *declInfo) {
assert(obj.typ == nil)
// func declarations cannot use iota
assert(check.iota == nil)
sig := new(Signature)
obj.typ = sig // guard against cycles
// Avoid cycle error when referring to method while type-checking the signature.
// This avoids a nuisance in the best case (non-parameterized receiver type) and
// since the method is not a type, we get an error. If we have a parameterized
// receiver type, instantiating the receiver type leads to the instantiation of
// its methods, and we don't want a cycle error in that case.
// TODO(gri) review if this is correct and/or whether we still need this?
saved := obj.color_
obj.color_ = black
fdecl := decl.fdecl
check.funcType(sig, fdecl.Recv, fdecl.TParamList, fdecl.Type)
obj.color_ = saved
// Set the scope's extent to the complete "func (...) { ... }"
// so that Scope.Innermost works correctly.
sig.scope.pos = fdecl.Pos()
sig.scope.end = syntax.EndPos(fdecl)
if len(fdecl.TParamList) > 0 && fdecl.Body == nil {
check.softErrorf(fdecl, BadDecl, "generic function is missing function body")
}
// function body must be type-checked after global declarations
// (functions implemented elsewhere have no body)
if !check.conf.IgnoreFuncBodies && fdecl.Body != nil {
check.later(func() {
check.funcBody(decl, obj.name, sig, fdecl.Body, nil)
}).describef(obj, "func %s", obj.name)
}
}
func (check *Checker) declStmt(list []syntax.Decl) {
pkg := check.pkg
first := -1 // index of first ConstDecl in the current group, or -1
var last *syntax.ConstDecl // last ConstDecl with init expressions, or nil
for index, decl := range list {
if _, ok := decl.(*syntax.ConstDecl); !ok {
first = -1 // we're not in a constant declaration
}
switch s := decl.(type) {
case *syntax.ConstDecl:
top := len(check.delayed)
// iota is the index of the current constDecl within the group
if first < 0 || s.Group == nil || list[index-1].(*syntax.ConstDecl).Group != s.Group {
first = index
last = nil
}
iota := constant.MakeInt64(int64(index - first))
// determine which initialization expressions to use
inherited := true
switch {
case s.Type != nil || s.Values != nil:
last = s
inherited = false
case last == nil:
last = new(syntax.ConstDecl) // make sure last exists
inherited = false
}
// declare all constants
lhs := make([]*Const, len(s.NameList))
values := syntax.UnpackListExpr(last.Values)
for i, name := range s.NameList {
obj := NewConst(name.Pos(), pkg, name.Value, nil, iota)
lhs[i] = obj
var init syntax.Expr
if i < len(values) {
init = values[i]
}
check.constDecl(obj, last.Type, init, inherited)
}
// Constants must always have init values.
check.arity(s.Pos(), s.NameList, values, true, inherited)
// process function literals in init expressions before scope changes
check.processDelayed(top)
// spec: "The scope of a constant or variable identifier declared
// inside a function begins at the end of the ConstSpec or VarSpec
// (ShortVarDecl for short variable declarations) and ends at the
// end of the innermost containing block."
scopePos := syntax.EndPos(s)
for i, name := range s.NameList {
check.declare(check.scope, name, lhs[i], scopePos)
}
case *syntax.VarDecl:
top := len(check.delayed)
lhs0 := make([]*Var, len(s.NameList))
for i, name := range s.NameList {
lhs0[i] = NewVar(name.Pos(), pkg, name.Value, nil)
}
// initialize all variables
values := syntax.UnpackListExpr(s.Values)
for i, obj := range lhs0 {
var lhs []*Var
var init syntax.Expr
switch len(values) {
case len(s.NameList):
// lhs and rhs match
init = values[i]
case 1:
// rhs is expected to be a multi-valued expression
lhs = lhs0
init = values[0]
default:
if i < len(values) {
init = values[i]
}
}
check.varDecl(obj, lhs, s.Type, init)
if len(values) == 1 {
// If we have a single lhs variable we are done either way.
// If we have a single rhs expression, it must be a multi-
// valued expression, in which case handling the first lhs
// variable will cause all lhs variables to have a type
// assigned, and we are done as well.
if debug {
for _, obj := range lhs0 {
assert(obj.typ != nil)
}
}
break
}
}
// If we have no type, we must have values.
if s.Type == nil || values != nil {
check.arity(s.Pos(), s.NameList, values, false, false)
}
// process function literals in init expressions before scope changes
check.processDelayed(top)
// declare all variables
// (only at this point are the variable scopes (parents) set)
scopePos := syntax.EndPos(s) // see constant declarations
for i, name := range s.NameList {
// see constant declarations
check.declare(check.scope, name, lhs0[i], scopePos)
}
case *syntax.TypeDecl:
obj := NewTypeName(s.Name.Pos(), pkg, s.Name.Value, nil)
// spec: "The scope of a type identifier declared inside a function
// begins at the identifier in the TypeSpec and ends at the end of
// the innermost containing block."
scopePos := s.Name.Pos()
check.declare(check.scope, s.Name, obj, scopePos)
// mark and unmark type before calling typeDecl; its type is still nil (see Checker.objDecl)
obj.setColor(grey + color(check.push(obj)))
check.typeDecl(obj, s, nil)
check.pop().setColor(black)
default:
check.errorf(s, InvalidSyntaxTree, "unknown syntax.Decl node %T", s)
}
}
}
|
go/src/cmd/compile/internal/types2/decl.go/0
|
{
"file_path": "go/src/cmd/compile/internal/types2/decl.go",
"repo_id": "go",
"token_count": 10561
}
| 118 |
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package types2
import (
"cmd/compile/internal/syntax"
. "internal/types/errors"
"strconv"
)
// ----------------------------------------------------------------------------
// API
// A Struct represents a struct type.
type Struct struct {
fields []*Var // fields != nil indicates the struct is set up (possibly with len(fields) == 0)
tags []string // field tags; nil if there are no tags
}
// NewStruct returns a new struct with the given fields and corresponding field tags.
// If a field with index i has a tag, tags[i] must be that tag, but len(tags) may be
// only as long as required to hold the tag with the largest index i. Consequently,
// if no field has a tag, tags may be nil.
func NewStruct(fields []*Var, tags []string) *Struct {
var fset objset
for _, f := range fields {
if f.name != "_" && fset.insert(f) != nil {
panic("multiple fields with the same name")
}
}
if len(tags) > len(fields) {
panic("more tags than fields")
}
s := &Struct{fields: fields, tags: tags}
s.markComplete()
return s
}
// NumFields returns the number of fields in the struct (including blank and embedded fields).
func (s *Struct) NumFields() int { return len(s.fields) }
// Field returns the i'th field for 0 <= i < NumFields().
func (s *Struct) Field(i int) *Var { return s.fields[i] }
// Tag returns the i'th field tag for 0 <= i < NumFields().
func (s *Struct) Tag(i int) string {
if i < len(s.tags) {
return s.tags[i]
}
return ""
}
func (s *Struct) Underlying() Type { return s }
func (s *Struct) String() string { return TypeString(s, nil) }
// ----------------------------------------------------------------------------
// Implementation
func (s *Struct) markComplete() {
if s.fields == nil {
s.fields = make([]*Var, 0)
}
}
func (check *Checker) structType(styp *Struct, e *syntax.StructType) {
if e.FieldList == nil {
styp.markComplete()
return
}
// struct fields and tags
var fields []*Var
var tags []string
// for double-declaration checks
var fset objset
// current field typ and tag
var typ Type
var tag string
add := func(ident *syntax.Name, embedded bool) {
if tag != "" && tags == nil {
tags = make([]string, len(fields))
}
if tags != nil {
tags = append(tags, tag)
}
pos := ident.Pos()
name := ident.Value
fld := NewField(pos, check.pkg, name, typ, embedded)
// spec: "Within a struct, non-blank field names must be unique."
if name == "_" || check.declareInSet(&fset, pos, fld) {
fields = append(fields, fld)
check.recordDef(ident, fld)
}
}
// addInvalid adds an embedded field of invalid type to the struct for
// fields with errors; this keeps the number of struct fields in sync
// with the source as long as the fields are _ or have different names
// (go.dev/issue/25627).
addInvalid := func(ident *syntax.Name) {
typ = Typ[Invalid]
tag = ""
add(ident, true)
}
var prev syntax.Expr
for i, f := range e.FieldList {
// Fields declared syntactically with the same type (e.g.: a, b, c T)
// share the same type expression. Only check type if it's a new type.
if i == 0 || f.Type != prev {
typ = check.varType(f.Type)
prev = f.Type
}
tag = ""
if i < len(e.TagList) {
tag = check.tag(e.TagList[i])
}
if f.Name != nil {
// named field
add(f.Name, false)
} else {
// embedded field
// spec: "An embedded type must be specified as a type name T or as a
// pointer to a non-interface type name *T, and T itself may not be a
// pointer type."
pos := syntax.StartPos(f.Type) // position of type, for errors
name := embeddedFieldIdent(f.Type)
if name == nil {
check.errorf(pos, InvalidSyntaxTree, "invalid embedded field type %s", f.Type)
name = syntax.NewName(pos, "_")
addInvalid(name)
continue
}
add(name, true) // struct{p.T} field has position of T
// Because we have a name, typ must be of the form T or *T, where T is the name
// of a (named or alias) type, and t (= deref(typ)) must be the type of T.
// We must delay this check to the end because we don't want to instantiate
// (via under(t)) a possibly incomplete type.
embeddedTyp := typ // for closure below
embeddedPos := pos
check.later(func() {
t, isPtr := deref(embeddedTyp)
switch u := under(t).(type) {
case *Basic:
if !isValid(t) {
// error was reported before
return
}
// unsafe.Pointer is treated like a regular pointer
if u.kind == UnsafePointer {
check.error(embeddedPos, InvalidPtrEmbed, "embedded field type cannot be unsafe.Pointer")
}
case *Pointer:
check.error(embeddedPos, InvalidPtrEmbed, "embedded field type cannot be a pointer")
case *Interface:
if isTypeParam(t) {
// The error code here is inconsistent with other error codes for
// invalid embedding, because this restriction may be relaxed in the
// future, and so it did not warrant a new error code.
check.error(embeddedPos, MisplacedTypeParam, "embedded field type cannot be a (pointer to a) type parameter")
break
}
if isPtr {
check.error(embeddedPos, InvalidPtrEmbed, "embedded field type cannot be a pointer to an interface")
}
}
}).describef(embeddedPos, "check embedded type %s", embeddedTyp)
}
}
styp.fields = fields
styp.tags = tags
styp.markComplete()
}
func embeddedFieldIdent(e syntax.Expr) *syntax.Name {
switch e := e.(type) {
case *syntax.Name:
return e
case *syntax.Operation:
if base := ptrBase(e); base != nil {
// *T is valid, but **T is not
if op, _ := base.(*syntax.Operation); op == nil || ptrBase(op) == nil {
return embeddedFieldIdent(e.X)
}
}
case *syntax.SelectorExpr:
return e.Sel
case *syntax.IndexExpr:
return embeddedFieldIdent(e.X)
}
return nil // invalid embedded field
}
func (check *Checker) declareInSet(oset *objset, pos syntax.Pos, obj Object) bool {
if alt := oset.insert(obj); alt != nil {
err := check.newError(DuplicateDecl)
err.addf(pos, "%s redeclared", obj.Name())
err.addAltDecl(alt)
err.report()
return false
}
return true
}
func (check *Checker) tag(t *syntax.BasicLit) string {
// If t.Bad, an error was reported during parsing.
if t != nil && !t.Bad {
if t.Kind == syntax.StringLit {
if val, err := strconv.Unquote(t.Value); err == nil {
return val
}
}
check.errorf(t, InvalidSyntaxTree, "incorrect tag syntax: %q", t.Value)
}
return ""
}
func ptrBase(x *syntax.Operation) syntax.Expr {
if x.Op == syntax.Mul && x.Y == nil {
return x.X
}
return nil
}
|
go/src/cmd/compile/internal/types2/struct.go/0
|
{
"file_path": "go/src/cmd/compile/internal/types2/struct.go",
"repo_id": "go",
"token_count": 2430
}
| 119 |
// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This file implements type-checking of identifiers and type expressions.
package types2
import (
"cmd/compile/internal/syntax"
"fmt"
"go/constant"
. "internal/types/errors"
"strings"
)
// ident type-checks identifier e and initializes x with the value or type of e.
// If an error occurred, x.mode is set to invalid.
// For the meaning of def, see Checker.definedType, below.
// If wantType is set, the identifier e is expected to denote a type.
func (check *Checker) ident(x *operand, e *syntax.Name, def *TypeName, wantType bool) {
x.mode = invalid
x.expr = e
// Note that we cannot use check.lookup here because the returned scope
// may be different from obj.Parent(). See also Scope.LookupParent doc.
scope, obj := check.scope.LookupParent(e.Value, check.pos)
switch obj {
case nil:
if e.Value == "_" {
check.error(e, InvalidBlank, "cannot use _ as value or type")
} else {
check.errorf(e, UndeclaredName, "undefined: %s", e.Value)
}
return
case universeComparable:
if !check.verifyVersionf(e, go1_18, "predeclared %s", e.Value) {
return // avoid follow-on errors
}
}
// Because the representation of any depends on gotypesalias, we don't check
// pointer identity here.
if obj.Name() == "any" && obj.Parent() == Universe {
if !check.verifyVersionf(e, go1_18, "predeclared %s", e.Value) {
return // avoid follow-on errors
}
}
check.recordUse(e, obj)
// If we want a type but don't have one, stop right here and avoid potential problems
// with missing underlying types. This also gives better error messages in some cases
// (see go.dev/issue/65344).
_, gotType := obj.(*TypeName)
if !gotType && wantType {
check.errorf(e, NotAType, "%s is not a type", obj.Name())
// avoid "declared but not used" errors
// (don't use Checker.use - we don't want to evaluate too much)
if v, _ := obj.(*Var); v != nil && v.pkg == check.pkg /* see Checker.use1 */ {
v.used = true
}
return
}
// Type-check the object.
// Only call Checker.objDecl if the object doesn't have a type yet
// (in which case we must actually determine it) or the object is a
// TypeName and we also want a type (in which case we might detect
// a cycle which needs to be reported). Otherwise we can skip the
// call and avoid a possible cycle error in favor of the more
// informative "not a type/value" error that this function's caller
// will issue (see go.dev/issue/25790).
typ := obj.Type()
if typ == nil || gotType && wantType {
check.objDecl(obj, def)
typ = obj.Type() // type must have been assigned by Checker.objDecl
}
assert(typ != nil)
// The object may have been dot-imported.
// If so, mark the respective package as used.
// (This code is only needed for dot-imports. Without them,
// we only have to mark variables, see *Var case below).
if pkgName := check.dotImportMap[dotImportKey{scope, obj.Name()}]; pkgName != nil {
pkgName.used = true
}
switch obj := obj.(type) {
case *PkgName:
check.errorf(e, InvalidPkgUse, "use of package %s not in selector", obj.name)
return
case *Const:
check.addDeclDep(obj)
if !isValid(typ) {
return
}
if obj == universeIota {
if check.iota == nil {
check.error(e, InvalidIota, "cannot use iota outside constant declaration")
return
}
x.val = check.iota
} else {
x.val = obj.val
}
assert(x.val != nil)
x.mode = constant_
case *TypeName:
if !check.conf.EnableAlias && check.isBrokenAlias(obj) {
check.errorf(e, InvalidDeclCycle, "invalid use of type alias %s in recursive type (see go.dev/issue/50729)", obj.name)
return
}
x.mode = typexpr
case *Var:
// It's ok to mark non-local variables, but ignore variables
// from other packages to avoid potential race conditions with
// dot-imported variables.
if obj.pkg == check.pkg {
obj.used = true
}
check.addDeclDep(obj)
if !isValid(typ) {
return
}
x.mode = variable
case *Func:
check.addDeclDep(obj)
x.mode = value
case *Builtin:
x.id = obj.id
x.mode = builtin
case *Nil:
x.mode = nilvalue
default:
panic("unreachable")
}
x.typ = typ
}
// typ type-checks the type expression e and returns its type, or Typ[Invalid].
// The type must not be an (uninstantiated) generic type.
func (check *Checker) typ(e syntax.Expr) Type {
return check.definedType(e, nil)
}
// varType type-checks the type expression e and returns its type, or Typ[Invalid].
// The type must not be an (uninstantiated) generic type and it must not be a
// constraint interface.
func (check *Checker) varType(e syntax.Expr) Type {
typ := check.definedType(e, nil)
check.validVarType(e, typ)
return typ
}
// validVarType reports an error if typ is a constraint interface.
// The expression e is used for error reporting, if any.
func (check *Checker) validVarType(e syntax.Expr, typ Type) {
// If we have a type parameter there's nothing to do.
if isTypeParam(typ) {
return
}
// We don't want to call under() or complete interfaces while we are in
// the middle of type-checking parameter declarations that might belong
// to interface methods. Delay this check to the end of type-checking.
check.later(func() {
if t, _ := under(typ).(*Interface); t != nil {
pos := syntax.StartPos(e)
tset := computeInterfaceTypeSet(check, pos, t) // TODO(gri) is this the correct position?
if !tset.IsMethodSet() {
if tset.comparable {
check.softErrorf(pos, MisplacedConstraintIface, "cannot use type %s outside a type constraint: interface is (or embeds) comparable", typ)
} else {
check.softErrorf(pos, MisplacedConstraintIface, "cannot use type %s outside a type constraint: interface contains type constraints", typ)
}
}
}
}).describef(e, "check var type %s", typ)
}
// definedType is like typ but also accepts a type name def.
// If def != nil, e is the type specification for the type named def, declared
// in a type declaration, and def.typ.underlying will be set to the type of e
// before any components of e are type-checked.
func (check *Checker) definedType(e syntax.Expr, def *TypeName) Type {
typ := check.typInternal(e, def)
assert(isTyped(typ))
if isGeneric(typ) {
check.errorf(e, WrongTypeArgCount, "cannot use generic type %s without instantiation", typ)
typ = Typ[Invalid]
}
check.recordTypeAndValue(e, typexpr, typ, nil)
return typ
}
// genericType is like typ but the type must be an (uninstantiated) generic
// type. If cause is non-nil and the type expression was a valid type but not
// generic, cause will be populated with a message describing the error.
func (check *Checker) genericType(e syntax.Expr, cause *string) Type {
typ := check.typInternal(e, nil)
assert(isTyped(typ))
if isValid(typ) && !isGeneric(typ) {
if cause != nil {
*cause = check.sprintf("%s is not a generic type", typ)
}
typ = Typ[Invalid]
}
// TODO(gri) what is the correct call below?
check.recordTypeAndValue(e, typexpr, typ, nil)
return typ
}
// goTypeName returns the Go type name for typ and
// removes any occurrences of "types2." from that name.
func goTypeName(typ Type) string {
return strings.ReplaceAll(fmt.Sprintf("%T", typ), "types2.", "")
}
// typInternal drives type checking of types.
// Must only be called by definedType or genericType.
func (check *Checker) typInternal(e0 syntax.Expr, def *TypeName) (T Type) {
if check.conf.Trace {
check.trace(e0.Pos(), "-- type %s", e0)
check.indent++
defer func() {
check.indent--
var under Type
if T != nil {
// Calling under() here may lead to endless instantiations.
// Test case: type T[P any] *T[P]
under = safeUnderlying(T)
}
if T == under {
check.trace(e0.Pos(), "=> %s // %s", T, goTypeName(T))
} else {
check.trace(e0.Pos(), "=> %s (under = %s) // %s", T, under, goTypeName(T))
}
}()
}
switch e := e0.(type) {
case *syntax.BadExpr:
// ignore - error reported before
case *syntax.Name:
var x operand
check.ident(&x, e, def, true)
switch x.mode {
case typexpr:
typ := x.typ
setDefType(def, typ)
return typ
case invalid:
// ignore - error reported before
case novalue:
check.errorf(&x, NotAType, "%s used as type", &x)
default:
check.errorf(&x, NotAType, "%s is not a type", &x)
}
case *syntax.SelectorExpr:
var x operand
check.selector(&x, e, def, true)
switch x.mode {
case typexpr:
typ := x.typ
setDefType(def, typ)
return typ
case invalid:
// ignore - error reported before
case novalue:
check.errorf(&x, NotAType, "%s used as type", &x)
default:
check.errorf(&x, NotAType, "%s is not a type", &x)
}
case *syntax.IndexExpr:
check.verifyVersionf(e, go1_18, "type instantiation")
return check.instantiatedType(e.X, syntax.UnpackListExpr(e.Index), def)
case *syntax.ParenExpr:
// Generic types must be instantiated before they can be used in any form.
// Consequently, generic types cannot be parenthesized.
return check.definedType(e.X, def)
case *syntax.ArrayType:
typ := new(Array)
setDefType(def, typ)
if e.Len != nil {
typ.len = check.arrayLength(e.Len)
} else {
// [...]array
check.error(e, BadDotDotDotSyntax, "invalid use of [...] array (outside a composite literal)")
typ.len = -1
}
typ.elem = check.varType(e.Elem)
if typ.len >= 0 {
return typ
}
// report error if we encountered [...]
case *syntax.SliceType:
typ := new(Slice)
setDefType(def, typ)
typ.elem = check.varType(e.Elem)
return typ
case *syntax.DotsType:
// dots are handled explicitly where they are legal
// (array composite literals and parameter lists)
check.error(e, InvalidDotDotDot, "invalid use of '...'")
check.use(e.Elem)
case *syntax.StructType:
typ := new(Struct)
setDefType(def, typ)
check.structType(typ, e)
return typ
case *syntax.Operation:
if e.Op == syntax.Mul && e.Y == nil {
typ := new(Pointer)
typ.base = Typ[Invalid] // avoid nil base in invalid recursive type declaration
setDefType(def, typ)
typ.base = check.varType(e.X)
// If typ.base is invalid, it's unlikely that *base is particularly
// useful - even a valid dereferenciation will lead to an invalid
// type again, and in some cases we get unexpected follow-on errors
// (e.g., go.dev/issue/49005). Return an invalid type instead.
if !isValid(typ.base) {
return Typ[Invalid]
}
return typ
}
check.errorf(e0, NotAType, "%s is not a type", e0)
check.use(e0)
case *syntax.FuncType:
typ := new(Signature)
setDefType(def, typ)
check.funcType(typ, nil, nil, e)
return typ
case *syntax.InterfaceType:
typ := check.newInterface()
setDefType(def, typ)
check.interfaceType(typ, e, def)
return typ
case *syntax.MapType:
typ := new(Map)
setDefType(def, typ)
typ.key = check.varType(e.Key)
typ.elem = check.varType(e.Value)
// spec: "The comparison operators == and != must be fully defined
// for operands of the key type; thus the key type must not be a
// function, map, or slice."
//
// Delay this check because it requires fully setup types;
// it is safe to continue in any case (was go.dev/issue/6667).
check.later(func() {
if !Comparable(typ.key) {
var why string
if isTypeParam(typ.key) {
why = " (missing comparable constraint)"
}
check.errorf(e.Key, IncomparableMapKey, "invalid map key type %s%s", typ.key, why)
}
}).describef(e.Key, "check map key %s", typ.key)
return typ
case *syntax.ChanType:
typ := new(Chan)
setDefType(def, typ)
dir := SendRecv
switch e.Dir {
case 0:
// nothing to do
case syntax.SendOnly:
dir = SendOnly
case syntax.RecvOnly:
dir = RecvOnly
default:
check.errorf(e, InvalidSyntaxTree, "unknown channel direction %d", e.Dir)
// ok to continue
}
typ.dir = dir
typ.elem = check.varType(e.Elem)
return typ
default:
check.errorf(e0, NotAType, "%s is not a type", e0)
check.use(e0)
}
typ := Typ[Invalid]
setDefType(def, typ)
return typ
}
func setDefType(def *TypeName, typ Type) {
if def != nil {
switch t := def.typ.(type) {
case *Alias:
// t.fromRHS should always be set, either to an invalid type
// in the beginning, or to typ in certain cyclic declarations.
if t.fromRHS != Typ[Invalid] && t.fromRHS != typ {
panic(sprintf(nil, true, "t.fromRHS = %s, typ = %s\n", t.fromRHS, typ))
}
t.fromRHS = typ
case *Basic:
assert(t == Typ[Invalid])
case *Named:
t.underlying = typ
default:
panic(fmt.Sprintf("unexpected type %T", t))
}
}
}
func (check *Checker) instantiatedType(x syntax.Expr, xlist []syntax.Expr, def *TypeName) (res Type) {
if check.conf.Trace {
check.trace(x.Pos(), "-- instantiating type %s with %s", x, xlist)
check.indent++
defer func() {
check.indent--
// Don't format the underlying here. It will always be nil.
check.trace(x.Pos(), "=> %s", res)
}()
}
defer func() {
setDefType(def, res)
}()
var cause string
gtyp := check.genericType(x, &cause)
if cause != "" {
check.errorf(x, NotAGenericType, invalidOp+"%s%s (%s)", x, xlist, cause)
}
if !isValid(gtyp) {
return gtyp // error already reported
}
// evaluate arguments
targs := check.typeList(xlist)
if targs == nil {
return Typ[Invalid]
}
if orig, _ := gtyp.(*Alias); orig != nil {
return check.instance(x.Pos(), orig, targs, nil, check.context())
}
orig := asNamed(gtyp)
if orig == nil {
panic(fmt.Sprintf("%v: cannot instantiate %v", x.Pos(), gtyp))
}
// create the instance
inst := asNamed(check.instance(x.Pos(), orig, targs, nil, check.context()))
// orig.tparams may not be set up, so we need to do expansion later.
check.later(func() {
// This is an instance from the source, not from recursive substitution,
// and so it must be resolved during type-checking so that we can report
// errors.
check.recordInstance(x, inst.TypeArgs().list(), inst)
if check.validateTArgLen(x.Pos(), inst.obj.name, inst.TypeParams().Len(), inst.TypeArgs().Len()) {
if i, err := check.verify(x.Pos(), inst.TypeParams().list(), inst.TypeArgs().list(), check.context()); err != nil {
// best position for error reporting
pos := x.Pos()
if i < len(xlist) {
pos = syntax.StartPos(xlist[i])
}
check.softErrorf(pos, InvalidTypeArg, "%s", err)
} else {
check.mono.recordInstance(check.pkg, x.Pos(), inst.TypeParams().list(), inst.TypeArgs().list(), xlist)
}
}
// TODO(rfindley): remove this call: we don't need to call validType here,
// as cycles can only occur for types used inside a Named type declaration,
// and so it suffices to call validType from declared types.
check.validType(inst)
}).describef(x, "resolve instance %s", inst)
return inst
}
// arrayLength type-checks the array length expression e
// and returns the constant length >= 0, or a value < 0
// to indicate an error (and thus an unknown length).
func (check *Checker) arrayLength(e syntax.Expr) int64 {
// If e is an identifier, the array declaration might be an
// attempt at a parameterized type declaration with missing
// constraint. Provide an error message that mentions array
// length.
if name, _ := e.(*syntax.Name); name != nil {
obj := check.lookup(name.Value)
if obj == nil {
check.errorf(name, InvalidArrayLen, "undefined array length %s or missing type constraint", name.Value)
return -1
}
if _, ok := obj.(*Const); !ok {
check.errorf(name, InvalidArrayLen, "invalid array length %s", name.Value)
return -1
}
}
var x operand
check.expr(nil, &x, e)
if x.mode != constant_ {
if x.mode != invalid {
check.errorf(&x, InvalidArrayLen, "array length %s must be constant", &x)
}
return -1
}
if isUntyped(x.typ) || isInteger(x.typ) {
if val := constant.ToInt(x.val); val.Kind() == constant.Int {
if representableConst(val, check, Typ[Int], nil) {
if n, ok := constant.Int64Val(val); ok && n >= 0 {
return n
}
}
}
}
var msg string
if isInteger(x.typ) {
msg = "invalid array length %s"
} else {
msg = "array length %s must be integer"
}
check.errorf(&x, InvalidArrayLen, msg, &x)
return -1
}
// typeList provides the list of types corresponding to the incoming expression list.
// If an error occurred, the result is nil, but all list elements were type-checked.
func (check *Checker) typeList(list []syntax.Expr) []Type {
res := make([]Type, len(list)) // res != nil even if len(list) == 0
for i, x := range list {
t := check.varType(x)
if !isValid(t) {
res = nil
}
if res != nil {
res[i] = t
}
}
return res
}
|
go/src/cmd/compile/internal/types2/typexpr.go/0
|
{
"file_path": "go/src/cmd/compile/internal/types2/typexpr.go",
"repo_id": "go",
"token_count": 6190
}
| 120 |
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package walk
import (
"fmt"
"go/constant"
"cmd/compile/internal/base"
"cmd/compile/internal/ir"
"cmd/compile/internal/reflectdata"
"cmd/compile/internal/ssa"
"cmd/compile/internal/staticinit"
"cmd/compile/internal/typecheck"
"cmd/compile/internal/types"
"cmd/internal/objabi"
"cmd/internal/src"
)
// Rewrite tree to use separate statements to enforce
// order of evaluation. Makes walk easier, because it
// can (after this runs) reorder at will within an expression.
//
// Rewrite m[k] op= r into m[k] = m[k] op r if op is / or %.
//
// Introduce temporaries as needed by runtime routines.
// For example, the map runtime routines take the map key
// by reference, so make sure all map keys are addressable
// by copying them to temporaries as needed.
// The same is true for channel operations.
//
// Arrange that map index expressions only appear in direct
// assignments x = m[k] or m[k] = x, never in larger expressions.
//
// Arrange that receive expressions only appear in direct assignments
// x = <-c or as standalone statements <-c, never in larger expressions.
// orderState holds state during the ordering process.
type orderState struct {
out []ir.Node // list of generated statements
temp []*ir.Name // stack of temporary variables
free map[string][]*ir.Name // free list of unused temporaries, by type.LinkString().
edit func(ir.Node) ir.Node // cached closure of o.exprNoLHS
}
// order rewrites fn.Nbody to apply the ordering constraints
// described in the comment at the top of the file.
func order(fn *ir.Func) {
if base.Flag.W > 1 {
s := fmt.Sprintf("\nbefore order %v", fn.Sym())
ir.DumpList(s, fn.Body)
}
ir.SetPos(fn) // Set reasonable position for instrumenting code. See issue 53688.
orderBlock(&fn.Body, map[string][]*ir.Name{})
}
// append typechecks stmt and appends it to out.
func (o *orderState) append(stmt ir.Node) {
o.out = append(o.out, typecheck.Stmt(stmt))
}
// newTemp allocates a new temporary with the given type,
// pushes it onto the temp stack, and returns it.
// If clear is true, newTemp emits code to zero the temporary.
func (o *orderState) newTemp(t *types.Type, clear bool) *ir.Name {
var v *ir.Name
key := t.LinkString()
if a := o.free[key]; len(a) > 0 {
v = a[len(a)-1]
if !types.Identical(t, v.Type()) {
base.Fatalf("expected %L to have type %v", v, t)
}
o.free[key] = a[:len(a)-1]
} else {
v = typecheck.TempAt(base.Pos, ir.CurFunc, t)
}
if clear {
o.append(ir.NewAssignStmt(base.Pos, v, nil))
}
o.temp = append(o.temp, v)
return v
}
// copyExpr behaves like newTemp but also emits
// code to initialize the temporary to the value n.
func (o *orderState) copyExpr(n ir.Node) *ir.Name {
return o.copyExpr1(n, false)
}
// copyExprClear is like copyExpr but clears the temp before assignment.
// It is provided for use when the evaluation of tmp = n turns into
// a function call that is passed a pointer to the temporary as the output space.
// If the call blocks before tmp has been written,
// the garbage collector will still treat the temporary as live,
// so we must zero it before entering that call.
// Today, this only happens for channel receive operations.
// (The other candidate would be map access, but map access
// returns a pointer to the result data instead of taking a pointer
// to be filled in.)
func (o *orderState) copyExprClear(n ir.Node) *ir.Name {
return o.copyExpr1(n, true)
}
func (o *orderState) copyExpr1(n ir.Node, clear bool) *ir.Name {
t := n.Type()
v := o.newTemp(t, clear)
o.append(ir.NewAssignStmt(base.Pos, v, n))
return v
}
// cheapExpr returns a cheap version of n.
// The definition of cheap is that n is a variable or constant.
// If not, cheapExpr allocates a new tmp, emits tmp = n,
// and then returns tmp.
func (o *orderState) cheapExpr(n ir.Node) ir.Node {
if n == nil {
return nil
}
switch n.Op() {
case ir.ONAME, ir.OLITERAL, ir.ONIL:
return n
case ir.OLEN, ir.OCAP:
n := n.(*ir.UnaryExpr)
l := o.cheapExpr(n.X)
if l == n.X {
return n
}
a := ir.Copy(n).(*ir.UnaryExpr)
a.X = l
return typecheck.Expr(a)
}
return o.copyExpr(n)
}
// safeExpr returns a safe version of n.
// The definition of safe is that n can appear multiple times
// without violating the semantics of the original program,
// and that assigning to the safe version has the same effect
// as assigning to the original n.
//
// The intended use is to apply to x when rewriting x += y into x = x + y.
func (o *orderState) safeExpr(n ir.Node) ir.Node {
switch n.Op() {
case ir.ONAME, ir.OLITERAL, ir.ONIL:
return n
case ir.OLEN, ir.OCAP:
n := n.(*ir.UnaryExpr)
l := o.safeExpr(n.X)
if l == n.X {
return n
}
a := ir.Copy(n).(*ir.UnaryExpr)
a.X = l
return typecheck.Expr(a)
case ir.ODOT:
n := n.(*ir.SelectorExpr)
l := o.safeExpr(n.X)
if l == n.X {
return n
}
a := ir.Copy(n).(*ir.SelectorExpr)
a.X = l
return typecheck.Expr(a)
case ir.ODOTPTR:
n := n.(*ir.SelectorExpr)
l := o.cheapExpr(n.X)
if l == n.X {
return n
}
a := ir.Copy(n).(*ir.SelectorExpr)
a.X = l
return typecheck.Expr(a)
case ir.ODEREF:
n := n.(*ir.StarExpr)
l := o.cheapExpr(n.X)
if l == n.X {
return n
}
a := ir.Copy(n).(*ir.StarExpr)
a.X = l
return typecheck.Expr(a)
case ir.OINDEX, ir.OINDEXMAP:
n := n.(*ir.IndexExpr)
var l ir.Node
if n.X.Type().IsArray() {
l = o.safeExpr(n.X)
} else {
l = o.cheapExpr(n.X)
}
r := o.cheapExpr(n.Index)
if l == n.X && r == n.Index {
return n
}
a := ir.Copy(n).(*ir.IndexExpr)
a.X = l
a.Index = r
return typecheck.Expr(a)
default:
base.Fatalf("order.safeExpr %v", n.Op())
return nil // not reached
}
}
// addrTemp ensures that n is okay to pass by address to runtime routines.
// If the original argument n is not okay, addrTemp creates a tmp, emits
// tmp = n, and then returns tmp.
// The result of addrTemp MUST be assigned back to n, e.g.
//
// n.Left = o.addrTemp(n.Left)
func (o *orderState) addrTemp(n ir.Node) ir.Node {
if n.Op() == ir.OLITERAL || n.Op() == ir.ONIL {
// TODO: expand this to all static composite literal nodes?
n = typecheck.DefaultLit(n, nil)
types.CalcSize(n.Type())
vstat := readonlystaticname(n.Type())
var s staticinit.Schedule
s.StaticAssign(vstat, 0, n, n.Type())
if s.Out != nil {
base.Fatalf("staticassign of const generated code: %+v", n)
}
vstat = typecheck.Expr(vstat).(*ir.Name)
return vstat
}
// Prevent taking the address of an SSA-able local variable (#63332).
//
// TODO(mdempsky): Note that OuterValue unwraps OCONVNOPs, but
// IsAddressable does not. It should be possible to skip copying for
// at least some of these OCONVNOPs (e.g., reinsert them after the
// OADDR operation), but at least walkCompare needs to be fixed to
// support that (see trybot failures on go.dev/cl/541715, PS1).
if ir.IsAddressable(n) {
if name, ok := ir.OuterValue(n).(*ir.Name); ok && name.Op() == ir.ONAME {
if name.Class == ir.PAUTO && !name.Addrtaken() && ssa.CanSSA(name.Type()) {
goto Copy
}
}
return n
}
Copy:
return o.copyExpr(n)
}
// mapKeyTemp prepares n to be a key in a map runtime call and returns n.
// The first parameter is the position of n's containing node, for use in case
// that n's position is not unique (e.g., if n is an ONAME).
func (o *orderState) mapKeyTemp(outerPos src.XPos, t *types.Type, n ir.Node) ir.Node {
pos := outerPos
if ir.HasUniquePos(n) {
pos = n.Pos()
}
// Most map calls need to take the address of the key.
// Exception: map*_fast* calls. See golang.org/issue/19015.
alg := mapfast(t)
if alg == mapslow {
return o.addrTemp(n)
}
var kt *types.Type
switch alg {
case mapfast32:
kt = types.Types[types.TUINT32]
case mapfast64:
kt = types.Types[types.TUINT64]
case mapfast32ptr, mapfast64ptr:
kt = types.Types[types.TUNSAFEPTR]
case mapfaststr:
kt = types.Types[types.TSTRING]
}
nt := n.Type()
switch {
case nt == kt:
return n
case nt.Kind() == kt.Kind(), nt.IsPtrShaped() && kt.IsPtrShaped():
// can directly convert (e.g. named type to underlying type, or one pointer to another)
return typecheck.Expr(ir.NewConvExpr(pos, ir.OCONVNOP, kt, n))
case nt.IsInteger() && kt.IsInteger():
// can directly convert (e.g. int32 to uint32)
if n.Op() == ir.OLITERAL && nt.IsSigned() {
// avoid constant overflow error
n = ir.NewConstExpr(constant.MakeUint64(uint64(ir.Int64Val(n))), n)
n.SetType(kt)
return n
}
return typecheck.Expr(ir.NewConvExpr(pos, ir.OCONV, kt, n))
default:
// Unsafe cast through memory.
// We'll need to do a load with type kt. Create a temporary of type kt to
// ensure sufficient alignment. nt may be under-aligned.
if uint8(kt.Alignment()) < uint8(nt.Alignment()) {
base.Fatalf("mapKeyTemp: key type is not sufficiently aligned, kt=%v nt=%v", kt, nt)
}
tmp := o.newTemp(kt, true)
// *(*nt)(&tmp) = n
var e ir.Node = typecheck.NodAddr(tmp)
e = ir.NewConvExpr(pos, ir.OCONVNOP, nt.PtrTo(), e)
e = ir.NewStarExpr(pos, e)
o.append(ir.NewAssignStmt(pos, e, n))
return tmp
}
}
// mapKeyReplaceStrConv replaces OBYTES2STR by OBYTES2STRTMP
// in n to avoid string allocations for keys in map lookups.
// Returns a bool that signals if a modification was made.
//
// For:
//
// x = m[string(k)]
// x = m[T1{... Tn{..., string(k), ...}}]
//
// where k is []byte, T1 to Tn is a nesting of struct and array literals,
// the allocation of backing bytes for the string can be avoided
// by reusing the []byte backing array. These are special cases
// for avoiding allocations when converting byte slices to strings.
// It would be nice to handle these generally, but because
// []byte keys are not allowed in maps, the use of string(k)
// comes up in important cases in practice. See issue 3512.
func mapKeyReplaceStrConv(n ir.Node) bool {
var replaced bool
switch n.Op() {
case ir.OBYTES2STR:
n := n.(*ir.ConvExpr)
n.SetOp(ir.OBYTES2STRTMP)
replaced = true
case ir.OSTRUCTLIT:
n := n.(*ir.CompLitExpr)
for _, elem := range n.List {
elem := elem.(*ir.StructKeyExpr)
if mapKeyReplaceStrConv(elem.Value) {
replaced = true
}
}
case ir.OARRAYLIT:
n := n.(*ir.CompLitExpr)
for _, elem := range n.List {
if elem.Op() == ir.OKEY {
elem = elem.(*ir.KeyExpr).Value
}
if mapKeyReplaceStrConv(elem) {
replaced = true
}
}
}
return replaced
}
type ordermarker int
// markTemp returns the top of the temporary variable stack.
func (o *orderState) markTemp() ordermarker {
return ordermarker(len(o.temp))
}
// popTemp pops temporaries off the stack until reaching the mark,
// which must have been returned by markTemp.
func (o *orderState) popTemp(mark ordermarker) {
for _, n := range o.temp[mark:] {
key := n.Type().LinkString()
o.free[key] = append(o.free[key], n)
}
o.temp = o.temp[:mark]
}
// stmtList orders each of the statements in the list.
func (o *orderState) stmtList(l ir.Nodes) {
s := l
for i := range s {
orderMakeSliceCopy(s[i:])
o.stmt(s[i])
}
}
// orderMakeSliceCopy matches the pattern:
//
// m = OMAKESLICE([]T, x); OCOPY(m, s)
//
// and rewrites it to:
//
// m = OMAKESLICECOPY([]T, x, s); nil
func orderMakeSliceCopy(s []ir.Node) {
if base.Flag.N != 0 || base.Flag.Cfg.Instrumenting {
return
}
if len(s) < 2 || s[0] == nil || s[0].Op() != ir.OAS || s[1] == nil || s[1].Op() != ir.OCOPY {
return
}
as := s[0].(*ir.AssignStmt)
cp := s[1].(*ir.BinaryExpr)
if as.Y == nil || as.Y.Op() != ir.OMAKESLICE || ir.IsBlank(as.X) ||
as.X.Op() != ir.ONAME || cp.X.Op() != ir.ONAME || cp.Y.Op() != ir.ONAME ||
as.X.Name() != cp.X.Name() || cp.X.Name() == cp.Y.Name() {
// The line above this one is correct with the differing equality operators:
// we want as.X and cp.X to be the same name,
// but we want the initial data to be coming from a different name.
return
}
mk := as.Y.(*ir.MakeExpr)
if mk.Esc() == ir.EscNone || mk.Len == nil || mk.Cap != nil {
return
}
mk.SetOp(ir.OMAKESLICECOPY)
mk.Cap = cp.Y
// Set bounded when m = OMAKESLICE([]T, len(s)); OCOPY(m, s)
mk.SetBounded(mk.Len.Op() == ir.OLEN && ir.SameSafeExpr(mk.Len.(*ir.UnaryExpr).X, cp.Y))
as.Y = typecheck.Expr(mk)
s[1] = nil // remove separate copy call
}
// edge inserts coverage instrumentation for libfuzzer.
func (o *orderState) edge() {
if base.Debug.Libfuzzer == 0 {
return
}
// Create a new uint8 counter to be allocated in section __sancov_cntrs
counter := staticinit.StaticName(types.Types[types.TUINT8])
counter.SetLibfuzzer8BitCounter(true)
// As well as setting SetLibfuzzer8BitCounter, we preemptively set the
// symbol type to SLIBFUZZER_8BIT_COUNTER so that the race detector
// instrumentation pass (which does not have access to the flags set by
// SetLibfuzzer8BitCounter) knows to ignore them. This information is
// lost by the time it reaches the compile step, so SetLibfuzzer8BitCounter
// is still necessary.
counter.Linksym().Type = objabi.SLIBFUZZER_8BIT_COUNTER
// We guarantee that the counter never becomes zero again once it has been
// incremented once. This implementation follows the NeverZero optimization
// presented by the paper:
// "AFL++: Combining Incremental Steps of Fuzzing Research"
// The NeverZero policy avoids the overflow to 0 by setting the counter to one
// after it reaches 255 and so, if an edge is executed at least one time, the entry is
// never 0.
// Another policy presented in the paper is the Saturated Counters policy which
// freezes the counter when it reaches the value of 255. However, a range
// of experiments showed that that decreases overall performance.
o.append(ir.NewIfStmt(base.Pos,
ir.NewBinaryExpr(base.Pos, ir.OEQ, counter, ir.NewInt(base.Pos, 0xff)),
[]ir.Node{ir.NewAssignStmt(base.Pos, counter, ir.NewInt(base.Pos, 1))},
[]ir.Node{ir.NewAssignOpStmt(base.Pos, ir.OADD, counter, ir.NewInt(base.Pos, 1))}))
}
// orderBlock orders the block of statements in n into a new slice,
// and then replaces the old slice in n with the new slice.
// free is a map that can be used to obtain temporary variables by type.
func orderBlock(n *ir.Nodes, free map[string][]*ir.Name) {
if len(*n) != 0 {
// Set reasonable position for instrumenting code. See issue 53688.
// It would be nice if ir.Nodes had a position (the opening {, probably),
// but it doesn't. So we use the first statement's position instead.
ir.SetPos((*n)[0])
}
var order orderState
order.free = free
mark := order.markTemp()
order.edge()
order.stmtList(*n)
order.popTemp(mark)
*n = order.out
}
// exprInPlace orders the side effects in *np and
// leaves them as the init list of the final *np.
// The result of exprInPlace MUST be assigned back to n, e.g.
//
// n.Left = o.exprInPlace(n.Left)
func (o *orderState) exprInPlace(n ir.Node) ir.Node {
var order orderState
order.free = o.free
n = order.expr(n, nil)
n = ir.InitExpr(order.out, n)
// insert new temporaries from order
// at head of outer list.
o.temp = append(o.temp, order.temp...)
return n
}
// orderStmtInPlace orders the side effects of the single statement *np
// and replaces it with the resulting statement list.
// The result of orderStmtInPlace MUST be assigned back to n, e.g.
//
// n.Left = orderStmtInPlace(n.Left)
//
// free is a map that can be used to obtain temporary variables by type.
func orderStmtInPlace(n ir.Node, free map[string][]*ir.Name) ir.Node {
var order orderState
order.free = free
mark := order.markTemp()
order.stmt(n)
order.popTemp(mark)
return ir.NewBlockStmt(src.NoXPos, order.out)
}
// init moves n's init list to o.out.
func (o *orderState) init(n ir.Node) {
if ir.MayBeShared(n) {
// For concurrency safety, don't mutate potentially shared nodes.
// First, ensure that no work is required here.
if len(n.Init()) > 0 {
base.Fatalf("order.init shared node with ninit")
}
return
}
o.stmtList(ir.TakeInit(n))
}
// call orders the call expression n.
// n.Op is OCALLFUNC/OCALLINTER or a builtin like OCOPY.
func (o *orderState) call(nn ir.Node) {
if len(nn.Init()) > 0 {
// Caller should have already called o.init(nn).
base.Fatalf("%v with unexpected ninit", nn.Op())
}
if nn.Op() == ir.OCALLMETH {
base.FatalfAt(nn.Pos(), "OCALLMETH missed by typecheck")
}
// Builtin functions.
if nn.Op() != ir.OCALLFUNC && nn.Op() != ir.OCALLINTER {
switch n := nn.(type) {
default:
base.Fatalf("unexpected call: %+v", n)
case *ir.UnaryExpr:
n.X = o.expr(n.X, nil)
case *ir.ConvExpr:
n.X = o.expr(n.X, nil)
case *ir.BinaryExpr:
n.X = o.expr(n.X, nil)
n.Y = o.expr(n.Y, nil)
case *ir.MakeExpr:
n.Len = o.expr(n.Len, nil)
n.Cap = o.expr(n.Cap, nil)
case *ir.CallExpr:
o.exprList(n.Args)
}
return
}
n := nn.(*ir.CallExpr)
typecheck.AssertFixedCall(n)
if ir.IsFuncPCIntrinsic(n) && ir.IsIfaceOfFunc(n.Args[0]) != nil {
// For internal/abi.FuncPCABIxxx(fn), if fn is a defined function,
// do not introduce temporaries here, so it is easier to rewrite it
// to symbol address reference later in walk.
return
}
n.Fun = o.expr(n.Fun, nil)
o.exprList(n.Args)
}
// mapAssign appends n to o.out.
func (o *orderState) mapAssign(n ir.Node) {
switch n.Op() {
default:
base.Fatalf("order.mapAssign %v", n.Op())
case ir.OAS:
n := n.(*ir.AssignStmt)
if n.X.Op() == ir.OINDEXMAP {
n.Y = o.safeMapRHS(n.Y)
}
o.out = append(o.out, n)
case ir.OASOP:
n := n.(*ir.AssignOpStmt)
if n.X.Op() == ir.OINDEXMAP {
n.Y = o.safeMapRHS(n.Y)
}
o.out = append(o.out, n)
}
}
func (o *orderState) safeMapRHS(r ir.Node) ir.Node {
// Make sure we evaluate the RHS before starting the map insert.
// We need to make sure the RHS won't panic. See issue 22881.
if r.Op() == ir.OAPPEND {
r := r.(*ir.CallExpr)
s := r.Args[1:]
for i, n := range s {
s[i] = o.cheapExpr(n)
}
return r
}
return o.cheapExpr(r)
}
// stmt orders the statement n, appending to o.out.
func (o *orderState) stmt(n ir.Node) {
if n == nil {
return
}
lno := ir.SetPos(n)
o.init(n)
switch n.Op() {
default:
base.Fatalf("order.stmt %v", n.Op())
case ir.OINLMARK:
o.out = append(o.out, n)
case ir.OAS:
n := n.(*ir.AssignStmt)
t := o.markTemp()
// There's a delicate interaction here between two OINDEXMAP
// optimizations.
//
// First, we want to handle m[k] = append(m[k], ...) with a single
// runtime call to mapassign. This requires the m[k] expressions to
// satisfy ir.SameSafeExpr in walkAssign.
//
// But if k is a slow map key type that's passed by reference (e.g.,
// byte), then we want to avoid marking user variables as addrtaken,
// if that might prevent the compiler from keeping k in a register.
//
// TODO(mdempsky): It would be better if walk was responsible for
// inserting temporaries as needed.
mapAppend := n.X.Op() == ir.OINDEXMAP && n.Y.Op() == ir.OAPPEND &&
ir.SameSafeExpr(n.X, n.Y.(*ir.CallExpr).Args[0])
n.X = o.expr(n.X, nil)
if mapAppend {
indexLHS := n.X.(*ir.IndexExpr)
indexLHS.X = o.cheapExpr(indexLHS.X)
indexLHS.Index = o.cheapExpr(indexLHS.Index)
call := n.Y.(*ir.CallExpr)
arg0 := call.Args[0]
// ir.SameSafeExpr skips OCONVNOPs, so we must do the same here (#66096).
for arg0.Op() == ir.OCONVNOP {
arg0 = arg0.(*ir.ConvExpr).X
}
indexRHS := arg0.(*ir.IndexExpr)
indexRHS.X = indexLHS.X
indexRHS.Index = indexLHS.Index
o.exprList(call.Args[1:])
} else {
n.Y = o.expr(n.Y, n.X)
}
o.mapAssign(n)
o.popTemp(t)
case ir.OASOP:
n := n.(*ir.AssignOpStmt)
t := o.markTemp()
n.X = o.expr(n.X, nil)
n.Y = o.expr(n.Y, nil)
if base.Flag.Cfg.Instrumenting || n.X.Op() == ir.OINDEXMAP && (n.AsOp == ir.ODIV || n.AsOp == ir.OMOD) {
// Rewrite m[k] op= r into m[k] = m[k] op r so
// that we can ensure that if op panics
// because r is zero, the panic happens before
// the map assignment.
// DeepCopy is a big hammer here, but safeExpr
// makes sure there is nothing too deep being copied.
l1 := o.safeExpr(n.X)
l2 := ir.DeepCopy(src.NoXPos, l1)
if l2.Op() == ir.OINDEXMAP {
l2 := l2.(*ir.IndexExpr)
l2.Assigned = false
}
l2 = o.copyExpr(l2)
r := o.expr(typecheck.Expr(ir.NewBinaryExpr(n.Pos(), n.AsOp, l2, n.Y)), nil)
as := typecheck.Stmt(ir.NewAssignStmt(n.Pos(), l1, r))
o.mapAssign(as)
o.popTemp(t)
return
}
o.mapAssign(n)
o.popTemp(t)
case ir.OAS2:
n := n.(*ir.AssignListStmt)
t := o.markTemp()
o.exprList(n.Lhs)
o.exprList(n.Rhs)
o.out = append(o.out, n)
o.popTemp(t)
// Special: avoid copy of func call n.Right
case ir.OAS2FUNC:
n := n.(*ir.AssignListStmt)
t := o.markTemp()
o.exprList(n.Lhs)
call := n.Rhs[0]
o.init(call)
if ic, ok := call.(*ir.InlinedCallExpr); ok {
o.stmtList(ic.Body)
n.SetOp(ir.OAS2)
n.Rhs = ic.ReturnVars
o.exprList(n.Rhs)
o.out = append(o.out, n)
} else {
o.call(call)
o.as2func(n)
}
o.popTemp(t)
// Special: use temporary variables to hold result,
// so that runtime can take address of temporary.
// No temporary for blank assignment.
//
// OAS2MAPR: make sure key is addressable if needed,
// and make sure OINDEXMAP is not copied out.
case ir.OAS2DOTTYPE, ir.OAS2RECV, ir.OAS2MAPR:
n := n.(*ir.AssignListStmt)
t := o.markTemp()
o.exprList(n.Lhs)
switch r := n.Rhs[0]; r.Op() {
case ir.ODOTTYPE2:
r := r.(*ir.TypeAssertExpr)
r.X = o.expr(r.X, nil)
case ir.ODYNAMICDOTTYPE2:
r := r.(*ir.DynamicTypeAssertExpr)
r.X = o.expr(r.X, nil)
r.RType = o.expr(r.RType, nil)
r.ITab = o.expr(r.ITab, nil)
case ir.ORECV:
r := r.(*ir.UnaryExpr)
r.X = o.expr(r.X, nil)
case ir.OINDEXMAP:
r := r.(*ir.IndexExpr)
r.X = o.expr(r.X, nil)
r.Index = o.expr(r.Index, nil)
// See similar conversion for OINDEXMAP below.
_ = mapKeyReplaceStrConv(r.Index)
r.Index = o.mapKeyTemp(r.Pos(), r.X.Type(), r.Index)
default:
base.Fatalf("order.stmt: %v", r.Op())
}
o.as2ok(n)
o.popTemp(t)
// Special: does not save n onto out.
case ir.OBLOCK:
n := n.(*ir.BlockStmt)
o.stmtList(n.List)
// Special: n->left is not an expression; save as is.
case ir.OBREAK,
ir.OCONTINUE,
ir.ODCL,
ir.OFALL,
ir.OGOTO,
ir.OLABEL,
ir.OTAILCALL:
o.out = append(o.out, n)
// Special: handle call arguments.
case ir.OCALLFUNC, ir.OCALLINTER:
n := n.(*ir.CallExpr)
t := o.markTemp()
o.call(n)
o.out = append(o.out, n)
o.popTemp(t)
case ir.OINLCALL:
n := n.(*ir.InlinedCallExpr)
o.stmtList(n.Body)
// discard results; double-check for no side effects
for _, result := range n.ReturnVars {
if staticinit.AnySideEffects(result) {
base.FatalfAt(result.Pos(), "inlined call result has side effects: %v", result)
}
}
case ir.OCHECKNIL, ir.OCLEAR, ir.OCLOSE, ir.OPANIC, ir.ORECV:
n := n.(*ir.UnaryExpr)
t := o.markTemp()
n.X = o.expr(n.X, nil)
o.out = append(o.out, n)
o.popTemp(t)
case ir.OCOPY:
n := n.(*ir.BinaryExpr)
t := o.markTemp()
n.X = o.expr(n.X, nil)
n.Y = o.expr(n.Y, nil)
o.out = append(o.out, n)
o.popTemp(t)
case ir.OPRINT, ir.OPRINTLN, ir.ORECOVERFP:
n := n.(*ir.CallExpr)
t := o.markTemp()
o.call(n)
o.out = append(o.out, n)
o.popTemp(t)
// Special: order arguments to inner call but not call itself.
case ir.ODEFER, ir.OGO:
n := n.(*ir.GoDeferStmt)
t := o.markTemp()
o.init(n.Call)
o.call(n.Call)
o.out = append(o.out, n)
o.popTemp(t)
case ir.ODELETE:
n := n.(*ir.CallExpr)
t := o.markTemp()
n.Args[0] = o.expr(n.Args[0], nil)
n.Args[1] = o.expr(n.Args[1], nil)
n.Args[1] = o.mapKeyTemp(n.Pos(), n.Args[0].Type(), n.Args[1])
o.out = append(o.out, n)
o.popTemp(t)
// Clean temporaries from condition evaluation at
// beginning of loop body and after for statement.
case ir.OFOR:
n := n.(*ir.ForStmt)
t := o.markTemp()
n.Cond = o.exprInPlace(n.Cond)
orderBlock(&n.Body, o.free)
n.Post = orderStmtInPlace(n.Post, o.free)
o.out = append(o.out, n)
o.popTemp(t)
// Clean temporaries from condition at
// beginning of both branches.
case ir.OIF:
n := n.(*ir.IfStmt)
t := o.markTemp()
n.Cond = o.exprInPlace(n.Cond)
o.popTemp(t)
orderBlock(&n.Body, o.free)
orderBlock(&n.Else, o.free)
o.out = append(o.out, n)
case ir.ORANGE:
// n.Right is the expression being ranged over.
// order it, and then make a copy if we need one.
// We almost always do, to ensure that we don't
// see any value changes made during the loop.
// Usually the copy is cheap (e.g., array pointer,
// chan, slice, string are all tiny).
// The exception is ranging over an array value
// (not a slice, not a pointer to array),
// which must make a copy to avoid seeing updates made during
// the range body. Ranging over an array value is uncommon though.
// Mark []byte(str) range expression to reuse string backing storage.
// It is safe because the storage cannot be mutated.
n := n.(*ir.RangeStmt)
if x, ok := n.X.(*ir.ConvExpr); ok {
switch x.Op() {
case ir.OSTR2BYTES:
x.SetOp(ir.OSTR2BYTESTMP)
fallthrough
case ir.OSTR2BYTESTMP:
x.MarkNonNil() // "range []byte(nil)" is fine
}
}
t := o.markTemp()
n.X = o.expr(n.X, nil)
orderBody := true
xt := typecheck.RangeExprType(n.X.Type())
switch k := xt.Kind(); {
default:
base.Fatalf("order.stmt range %v", n.Type())
case types.IsInt[k]:
// Used only once, no need to copy.
case k == types.TARRAY, k == types.TSLICE:
if n.Value == nil || ir.IsBlank(n.Value) {
// for i := range x will only use x once, to compute len(x).
// No need to copy it.
break
}
fallthrough
case k == types.TCHAN, k == types.TSTRING:
// chan, string, slice, array ranges use value multiple times.
// make copy.
r := n.X
if r.Type().IsString() && r.Type() != types.Types[types.TSTRING] {
r = ir.NewConvExpr(base.Pos, ir.OCONV, nil, r)
r.SetType(types.Types[types.TSTRING])
r = typecheck.Expr(r)
}
n.X = o.copyExpr(r)
case k == types.TMAP:
if isMapClear(n) {
// Preserve the body of the map clear pattern so it can
// be detected during walk. The loop body will not be used
// when optimizing away the range loop to a runtime call.
orderBody = false
break
}
// copy the map value in case it is a map literal.
// TODO(rsc): Make tmp = literal expressions reuse tmp.
// For maps tmp is just one word so it hardly matters.
r := n.X
n.X = o.copyExpr(r)
// n.Prealloc is the temp for the iterator.
// MapIterType contains pointers and needs to be zeroed.
n.Prealloc = o.newTemp(reflectdata.MapIterType(), true)
}
n.Key = o.exprInPlace(n.Key)
n.Value = o.exprInPlace(n.Value)
if orderBody {
orderBlock(&n.Body, o.free)
}
o.out = append(o.out, n)
o.popTemp(t)
case ir.ORETURN:
n := n.(*ir.ReturnStmt)
o.exprList(n.Results)
o.out = append(o.out, n)
// Special: clean case temporaries in each block entry.
// Select must enter one of its blocks, so there is no
// need for a cleaning at the end.
// Doubly special: evaluation order for select is stricter
// than ordinary expressions. Even something like p.c
// has to be hoisted into a temporary, so that it cannot be
// reordered after the channel evaluation for a different
// case (if p were nil, then the timing of the fault would
// give this away).
case ir.OSELECT:
n := n.(*ir.SelectStmt)
t := o.markTemp()
for _, ncas := range n.Cases {
r := ncas.Comm
ir.SetPos(ncas)
// Append any new body prologue to ninit.
// The next loop will insert ninit into nbody.
if len(ncas.Init()) != 0 {
base.Fatalf("order select ninit")
}
if r == nil {
continue
}
switch r.Op() {
default:
ir.Dump("select case", r)
base.Fatalf("unknown op in select %v", r.Op())
case ir.OSELRECV2:
// case x, ok = <-c
r := r.(*ir.AssignListStmt)
recv := r.Rhs[0].(*ir.UnaryExpr)
recv.X = o.expr(recv.X, nil)
if !ir.IsAutoTmp(recv.X) {
recv.X = o.copyExpr(recv.X)
}
init := ir.TakeInit(r)
colas := r.Def
do := func(i int, t *types.Type) {
n := r.Lhs[i]
if ir.IsBlank(n) {
return
}
// If this is case x := <-ch or case x, y := <-ch, the case has
// the ODCL nodes to declare x and y. We want to delay that
// declaration (and possible allocation) until inside the case body.
// Delete the ODCL nodes here and recreate them inside the body below.
if colas {
if len(init) > 0 && init[0].Op() == ir.ODCL && init[0].(*ir.Decl).X == n {
init = init[1:]
// iimport may have added a default initialization assignment,
// due to how it handles ODCL statements.
if len(init) > 0 && init[0].Op() == ir.OAS && init[0].(*ir.AssignStmt).X == n {
init = init[1:]
}
}
dcl := typecheck.Stmt(ir.NewDecl(base.Pos, ir.ODCL, n.(*ir.Name)))
ncas.PtrInit().Append(dcl)
}
tmp := o.newTemp(t, t.HasPointers())
as := typecheck.Stmt(ir.NewAssignStmt(base.Pos, n, typecheck.Conv(tmp, n.Type())))
ncas.PtrInit().Append(as)
r.Lhs[i] = tmp
}
do(0, recv.X.Type().Elem())
do(1, types.Types[types.TBOOL])
if len(init) != 0 {
ir.DumpList("ninit", init)
base.Fatalf("ninit on select recv")
}
orderBlock(ncas.PtrInit(), o.free)
case ir.OSEND:
r := r.(*ir.SendStmt)
if len(r.Init()) != 0 {
ir.DumpList("ninit", r.Init())
base.Fatalf("ninit on select send")
}
// case c <- x
// r->left is c, r->right is x, both are always evaluated.
r.Chan = o.expr(r.Chan, nil)
if !ir.IsAutoTmp(r.Chan) {
r.Chan = o.copyExpr(r.Chan)
}
r.Value = o.expr(r.Value, nil)
if !ir.IsAutoTmp(r.Value) {
r.Value = o.copyExpr(r.Value)
}
}
}
// Now that we have accumulated all the temporaries, clean them.
// Also insert any ninit queued during the previous loop.
// (The temporary cleaning must follow that ninit work.)
for _, cas := range n.Cases {
orderBlock(&cas.Body, o.free)
// TODO(mdempsky): Is this actually necessary?
// walkSelect appears to walk Ninit.
cas.Body.Prepend(ir.TakeInit(cas)...)
}
o.out = append(o.out, n)
o.popTemp(t)
// Special: value being sent is passed as a pointer; make it addressable.
case ir.OSEND:
n := n.(*ir.SendStmt)
t := o.markTemp()
n.Chan = o.expr(n.Chan, nil)
n.Value = o.expr(n.Value, nil)
if base.Flag.Cfg.Instrumenting {
// Force copying to the stack so that (chan T)(nil) <- x
// is still instrumented as a read of x.
n.Value = o.copyExpr(n.Value)
} else {
n.Value = o.addrTemp(n.Value)
}
o.out = append(o.out, n)
o.popTemp(t)
// TODO(rsc): Clean temporaries more aggressively.
// Note that because walkSwitch will rewrite some of the
// switch into a binary search, this is not as easy as it looks.
// (If we ran that code here we could invoke order.stmt on
// the if-else chain instead.)
// For now just clean all the temporaries at the end.
// In practice that's fine.
case ir.OSWITCH:
n := n.(*ir.SwitchStmt)
if base.Debug.Libfuzzer != 0 && !hasDefaultCase(n) {
// Add empty "default:" case for instrumentation.
n.Cases = append(n.Cases, ir.NewCaseStmt(base.Pos, nil, nil))
}
t := o.markTemp()
n.Tag = o.expr(n.Tag, nil)
for _, ncas := range n.Cases {
o.exprListInPlace(ncas.List)
orderBlock(&ncas.Body, o.free)
}
o.out = append(o.out, n)
o.popTemp(t)
}
base.Pos = lno
}
func hasDefaultCase(n *ir.SwitchStmt) bool {
for _, ncas := range n.Cases {
if len(ncas.List) == 0 {
return true
}
}
return false
}
// exprList orders the expression list l into o.
func (o *orderState) exprList(l ir.Nodes) {
s := l
for i := range s {
s[i] = o.expr(s[i], nil)
}
}
// exprListInPlace orders the expression list l but saves
// the side effects on the individual expression ninit lists.
func (o *orderState) exprListInPlace(l ir.Nodes) {
s := l
for i := range s {
s[i] = o.exprInPlace(s[i])
}
}
func (o *orderState) exprNoLHS(n ir.Node) ir.Node {
return o.expr(n, nil)
}
// expr orders a single expression, appending side
// effects to o.out as needed.
// If this is part of an assignment lhs = *np, lhs is given.
// Otherwise lhs == nil. (When lhs != nil it may be possible
// to avoid copying the result of the expression to a temporary.)
// The result of expr MUST be assigned back to n, e.g.
//
// n.Left = o.expr(n.Left, lhs)
func (o *orderState) expr(n, lhs ir.Node) ir.Node {
if n == nil {
return n
}
lno := ir.SetPos(n)
n = o.expr1(n, lhs)
base.Pos = lno
return n
}
func (o *orderState) expr1(n, lhs ir.Node) ir.Node {
o.init(n)
switch n.Op() {
default:
if o.edit == nil {
o.edit = o.exprNoLHS // create closure once
}
ir.EditChildren(n, o.edit)
return n
// Addition of strings turns into a function call.
// Allocate a temporary to hold the strings.
// Fewer than 5 strings use direct runtime helpers.
case ir.OADDSTR:
n := n.(*ir.AddStringExpr)
o.exprList(n.List)
if len(n.List) > 5 {
t := types.NewArray(types.Types[types.TSTRING], int64(len(n.List)))
n.Prealloc = o.newTemp(t, false)
}
// Mark string(byteSlice) arguments to reuse byteSlice backing
// buffer during conversion. String concatenation does not
// memorize the strings for later use, so it is safe.
// However, we can do it only if there is at least one non-empty string literal.
// Otherwise if all other arguments are empty strings,
// concatstrings will return the reference to the temp string
// to the caller.
hasbyte := false
haslit := false
for _, n1 := range n.List {
hasbyte = hasbyte || n1.Op() == ir.OBYTES2STR
haslit = haslit || n1.Op() == ir.OLITERAL && len(ir.StringVal(n1)) != 0
}
if haslit && hasbyte {
for _, n2 := range n.List {
if n2.Op() == ir.OBYTES2STR {
n2 := n2.(*ir.ConvExpr)
n2.SetOp(ir.OBYTES2STRTMP)
}
}
}
return n
case ir.OINDEXMAP:
n := n.(*ir.IndexExpr)
n.X = o.expr(n.X, nil)
n.Index = o.expr(n.Index, nil)
needCopy := false
if !n.Assigned {
// Enforce that any []byte slices we are not copying
// can not be changed before the map index by forcing
// the map index to happen immediately following the
// conversions. See copyExpr a few lines below.
needCopy = mapKeyReplaceStrConv(n.Index)
if base.Flag.Cfg.Instrumenting {
// Race detector needs the copy.
needCopy = true
}
}
// key may need to be be addressable
n.Index = o.mapKeyTemp(n.Pos(), n.X.Type(), n.Index)
if needCopy {
return o.copyExpr(n)
}
return n
// concrete type (not interface) argument might need an addressable
// temporary to pass to the runtime conversion routine.
case ir.OCONVIFACE:
n := n.(*ir.ConvExpr)
n.X = o.expr(n.X, nil)
if n.X.Type().IsInterface() {
return n
}
if _, _, needsaddr := dataWordFuncName(n.X.Type()); needsaddr || isStaticCompositeLiteral(n.X) {
// Need a temp if we need to pass the address to the conversion function.
// We also process static composite literal node here, making a named static global
// whose address we can put directly in an interface (see OCONVIFACE case in walk).
n.X = o.addrTemp(n.X)
}
return n
case ir.OCONVNOP:
n := n.(*ir.ConvExpr)
if n.X.Op() == ir.OCALLMETH {
base.FatalfAt(n.X.Pos(), "OCALLMETH missed by typecheck")
}
if n.Type().IsKind(types.TUNSAFEPTR) && n.X.Type().IsKind(types.TUINTPTR) && (n.X.Op() == ir.OCALLFUNC || n.X.Op() == ir.OCALLINTER) {
call := n.X.(*ir.CallExpr)
// When reordering unsafe.Pointer(f()) into a separate
// statement, the conversion and function call must stay
// together. See golang.org/issue/15329.
o.init(call)
o.call(call)
if lhs == nil || lhs.Op() != ir.ONAME || base.Flag.Cfg.Instrumenting {
return o.copyExpr(n)
}
} else {
n.X = o.expr(n.X, nil)
}
return n
case ir.OANDAND, ir.OOROR:
// ... = LHS && RHS
//
// var r bool
// r = LHS
// if r { // or !r, for OROR
// r = RHS
// }
// ... = r
n := n.(*ir.LogicalExpr)
r := o.newTemp(n.Type(), false)
// Evaluate left-hand side.
lhs := o.expr(n.X, nil)
o.out = append(o.out, typecheck.Stmt(ir.NewAssignStmt(base.Pos, r, lhs)))
// Evaluate right-hand side, save generated code.
saveout := o.out
o.out = nil
t := o.markTemp()
o.edge()
rhs := o.expr(n.Y, nil)
o.out = append(o.out, typecheck.Stmt(ir.NewAssignStmt(base.Pos, r, rhs)))
o.popTemp(t)
gen := o.out
o.out = saveout
// If left-hand side doesn't cause a short-circuit, issue right-hand side.
nif := ir.NewIfStmt(base.Pos, r, nil, nil)
if n.Op() == ir.OANDAND {
nif.Body = gen
} else {
nif.Else = gen
}
o.out = append(o.out, nif)
return r
case ir.OCALLMETH:
base.FatalfAt(n.Pos(), "OCALLMETH missed by typecheck")
panic("unreachable")
case ir.OCALLFUNC,
ir.OCALLINTER,
ir.OCAP,
ir.OCOMPLEX,
ir.OCOPY,
ir.OIMAG,
ir.OLEN,
ir.OMAKECHAN,
ir.OMAKEMAP,
ir.OMAKESLICE,
ir.OMAKESLICECOPY,
ir.OMAX,
ir.OMIN,
ir.ONEW,
ir.OREAL,
ir.ORECOVERFP,
ir.OSTR2BYTES,
ir.OSTR2BYTESTMP,
ir.OSTR2RUNES:
if isRuneCount(n) {
// len([]rune(s)) is rewritten to runtime.countrunes(s) later.
conv := n.(*ir.UnaryExpr).X.(*ir.ConvExpr)
conv.X = o.expr(conv.X, nil)
} else {
o.call(n)
}
if lhs == nil || lhs.Op() != ir.ONAME || base.Flag.Cfg.Instrumenting {
return o.copyExpr(n)
}
return n
case ir.OINLCALL:
n := n.(*ir.InlinedCallExpr)
o.stmtList(n.Body)
return n.SingleResult()
case ir.OAPPEND:
// Check for append(x, make([]T, y)...) .
n := n.(*ir.CallExpr)
if isAppendOfMake(n) {
n.Args[0] = o.expr(n.Args[0], nil) // order x
mk := n.Args[1].(*ir.MakeExpr)
mk.Len = o.expr(mk.Len, nil) // order y
} else {
o.exprList(n.Args)
}
if lhs == nil || lhs.Op() != ir.ONAME && !ir.SameSafeExpr(lhs, n.Args[0]) {
return o.copyExpr(n)
}
return n
case ir.OSLICE, ir.OSLICEARR, ir.OSLICESTR, ir.OSLICE3, ir.OSLICE3ARR:
n := n.(*ir.SliceExpr)
n.X = o.expr(n.X, nil)
n.Low = o.cheapExpr(o.expr(n.Low, nil))
n.High = o.cheapExpr(o.expr(n.High, nil))
n.Max = o.cheapExpr(o.expr(n.Max, nil))
if lhs == nil || lhs.Op() != ir.ONAME && !ir.SameSafeExpr(lhs, n.X) {
return o.copyExpr(n)
}
return n
case ir.OCLOSURE:
n := n.(*ir.ClosureExpr)
if n.Transient() && len(n.Func.ClosureVars) > 0 {
n.Prealloc = o.newTemp(typecheck.ClosureType(n), false)
}
return n
case ir.OMETHVALUE:
n := n.(*ir.SelectorExpr)
n.X = o.expr(n.X, nil)
if n.Transient() {
t := typecheck.MethodValueType(n)
n.Prealloc = o.newTemp(t, false)
}
return n
case ir.OSLICELIT:
n := n.(*ir.CompLitExpr)
o.exprList(n.List)
if n.Transient() {
t := types.NewArray(n.Type().Elem(), n.Len)
n.Prealloc = o.newTemp(t, false)
}
return n
case ir.ODOTTYPE, ir.ODOTTYPE2:
n := n.(*ir.TypeAssertExpr)
n.X = o.expr(n.X, nil)
if !types.IsDirectIface(n.Type()) || base.Flag.Cfg.Instrumenting {
return o.copyExprClear(n)
}
return n
case ir.ORECV:
n := n.(*ir.UnaryExpr)
n.X = o.expr(n.X, nil)
return o.copyExprClear(n)
case ir.OEQ, ir.ONE, ir.OLT, ir.OLE, ir.OGT, ir.OGE:
n := n.(*ir.BinaryExpr)
n.X = o.expr(n.X, nil)
n.Y = o.expr(n.Y, nil)
t := n.X.Type()
switch {
case t.IsString():
// Mark string(byteSlice) arguments to reuse byteSlice backing
// buffer during conversion. String comparison does not
// memorize the strings for later use, so it is safe.
if n.X.Op() == ir.OBYTES2STR {
n.X.(*ir.ConvExpr).SetOp(ir.OBYTES2STRTMP)
}
if n.Y.Op() == ir.OBYTES2STR {
n.Y.(*ir.ConvExpr).SetOp(ir.OBYTES2STRTMP)
}
case t.IsStruct() || t.IsArray():
// for complex comparisons, we need both args to be
// addressable so we can pass them to the runtime.
n.X = o.addrTemp(n.X)
n.Y = o.addrTemp(n.Y)
}
return n
case ir.OMAPLIT:
// Order map by converting:
// map[int]int{
// a(): b(),
// c(): d(),
// e(): f(),
// }
// to
// m := map[int]int{}
// m[a()] = b()
// m[c()] = d()
// m[e()] = f()
// Then order the result.
// Without this special case, order would otherwise compute all
// the keys and values before storing any of them to the map.
// See issue 26552.
n := n.(*ir.CompLitExpr)
entries := n.List
statics := entries[:0]
var dynamics []*ir.KeyExpr
for _, r := range entries {
r := r.(*ir.KeyExpr)
if !isStaticCompositeLiteral(r.Key) || !isStaticCompositeLiteral(r.Value) {
dynamics = append(dynamics, r)
continue
}
// Recursively ordering some static entries can change them to dynamic;
// e.g., OCONVIFACE nodes. See #31777.
r = o.expr(r, nil).(*ir.KeyExpr)
if !isStaticCompositeLiteral(r.Key) || !isStaticCompositeLiteral(r.Value) {
dynamics = append(dynamics, r)
continue
}
statics = append(statics, r)
}
n.List = statics
if len(dynamics) == 0 {
return n
}
// Emit the creation of the map (with all its static entries).
m := o.newTemp(n.Type(), false)
as := ir.NewAssignStmt(base.Pos, m, n)
typecheck.Stmt(as)
o.stmt(as)
// Emit eval+insert of dynamic entries, one at a time.
for _, r := range dynamics {
lhs := typecheck.AssignExpr(ir.NewIndexExpr(base.Pos, m, r.Key)).(*ir.IndexExpr)
base.AssertfAt(lhs.Op() == ir.OINDEXMAP, lhs.Pos(), "want OINDEXMAP, have %+v", lhs)
lhs.RType = n.RType
as := ir.NewAssignStmt(base.Pos, lhs, r.Value)
typecheck.Stmt(as)
o.stmt(as)
}
// Remember that we issued these assignments so we can include that count
// in the map alloc hint.
// We're assuming here that all the keys in the map literal are distinct.
// If any are equal, this will be an overcount. Probably not worth accounting
// for that, as equal keys in map literals are rare, and at worst we waste
// a bit of space.
n.Len += int64(len(dynamics))
return m
}
// No return - type-assertions above. Each case must return for itself.
}
// as2func orders OAS2FUNC nodes. It creates temporaries to ensure left-to-right assignment.
// The caller should order the right-hand side of the assignment before calling order.as2func.
// It rewrites,
//
// a, b, a = ...
//
// as
//
// tmp1, tmp2, tmp3 = ...
// a, b, a = tmp1, tmp2, tmp3
//
// This is necessary to ensure left to right assignment order.
func (o *orderState) as2func(n *ir.AssignListStmt) {
results := n.Rhs[0].Type()
as := ir.NewAssignListStmt(n.Pos(), ir.OAS2, nil, nil)
for i, nl := range n.Lhs {
if !ir.IsBlank(nl) {
typ := results.Field(i).Type
tmp := o.newTemp(typ, typ.HasPointers())
n.Lhs[i] = tmp
as.Lhs = append(as.Lhs, nl)
as.Rhs = append(as.Rhs, tmp)
}
}
o.out = append(o.out, n)
o.stmt(typecheck.Stmt(as))
}
// as2ok orders OAS2XXX with ok.
// Just like as2func, this also adds temporaries to ensure left-to-right assignment.
func (o *orderState) as2ok(n *ir.AssignListStmt) {
as := ir.NewAssignListStmt(n.Pos(), ir.OAS2, nil, nil)
do := func(i int, typ *types.Type) {
if nl := n.Lhs[i]; !ir.IsBlank(nl) {
var tmp ir.Node = o.newTemp(typ, typ.HasPointers())
n.Lhs[i] = tmp
as.Lhs = append(as.Lhs, nl)
if i == 1 {
// The "ok" result is an untyped boolean according to the Go
// spec. We need to explicitly convert it to the LHS type in
// case the latter is a defined boolean type (#8475).
tmp = typecheck.Conv(tmp, nl.Type())
}
as.Rhs = append(as.Rhs, tmp)
}
}
do(0, n.Rhs[0].Type())
do(1, types.Types[types.TBOOL])
o.out = append(o.out, n)
o.stmt(typecheck.Stmt(as))
}
|
go/src/cmd/compile/internal/walk/order.go/0
|
{
"file_path": "go/src/cmd/compile/internal/walk/order.go",
"repo_id": "go",
"token_count": 18655
}
| 121 |
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
// This file contains functions and apis to support the "go tool
// covdata" sub-commands that relate to dumping text format summaries
// and reports: "pkglist", "func", "debugdump", "percent", and
// "textfmt".
import (
"flag"
"fmt"
"internal/coverage"
"internal/coverage/calloc"
"internal/coverage/cformat"
"internal/coverage/cmerge"
"internal/coverage/decodecounter"
"internal/coverage/decodemeta"
"internal/coverage/pods"
"os"
"sort"
"strings"
)
var textfmtoutflag *string
var liveflag *bool
func makeDumpOp(cmd string) covOperation {
if cmd == textfmtMode || cmd == percentMode {
textfmtoutflag = flag.String("o", "", "Output text format to file")
}
if cmd == debugDumpMode {
liveflag = flag.Bool("live", false, "Select only live (executed) functions for dump output.")
}
d := &dstate{
cmd: cmd,
cm: &cmerge.Merger{},
}
// For these modes (percent, pkglist, func, etc), use a relaxed
// policy when it comes to counter mode clashes. For a percent
// report, for example, we only care whether a given line is
// executed at least once, so it's ok to (effectively) merge
// together runs derived from different counter modes.
if d.cmd == percentMode || d.cmd == funcMode || d.cmd == pkglistMode {
d.cm.SetModeMergePolicy(cmerge.ModeMergeRelaxed)
}
if d.cmd == pkglistMode {
d.pkgpaths = make(map[string]struct{})
}
return d
}
// dstate encapsulates state and provides methods for implementing
// various dump operations. Specifically, dstate implements the
// CovDataVisitor interface, and is designed to be used in
// concert with the CovDataReader utility, which abstracts away most
// of the grubby details of reading coverage data files.
type dstate struct {
// for batch allocation of counter arrays
calloc.BatchCounterAlloc
// counter merging state + methods
cm *cmerge.Merger
// counter data formatting helper
format *cformat.Formatter
// 'mm' stores values read from a counter data file; the pkfunc key
// is a pkgid/funcid pair that uniquely identifies a function in
// instrumented application.
mm map[pkfunc]decodecounter.FuncPayload
// pkm maps package ID to the number of functions in the package
// with that ID. It is used to report inconsistencies in counter
// data (for example, a counter data entry with pkgid=N funcid=10
// where package N only has 3 functions).
pkm map[uint32]uint32
// pkgpaths records all package import paths encountered while
// visiting coverage data files (used to implement the "pkglist"
// subcommand).
pkgpaths map[string]struct{}
// Current package name and import path.
pkgName string
pkgImportPath string
// Module path for current package (may be empty).
modulePath string
// Dump subcommand (ex: "textfmt", "debugdump", etc).
cmd string
// File to which we will write text format output, if enabled.
textfmtoutf *os.File
// Total and covered statements (used by "debugdump" subcommand).
totalStmts, coveredStmts int
// Records whether preamble has been emitted for current pkg
// (used when in "debugdump" mode)
preambleEmitted bool
}
func (d *dstate) Usage(msg string) {
if len(msg) > 0 {
fmt.Fprintf(os.Stderr, "error: %s\n", msg)
}
fmt.Fprintf(os.Stderr, "usage: go tool covdata %s -i=<directories>\n\n", d.cmd)
flag.PrintDefaults()
fmt.Fprintf(os.Stderr, "\nExamples:\n\n")
switch d.cmd {
case pkglistMode:
fmt.Fprintf(os.Stderr, " go tool covdata pkglist -i=dir1,dir2\n\n")
fmt.Fprintf(os.Stderr, " \treads coverage data files from dir1+dirs2\n")
fmt.Fprintf(os.Stderr, " \tand writes out a list of the import paths\n")
fmt.Fprintf(os.Stderr, " \tof all compiled packages.\n")
case textfmtMode:
fmt.Fprintf(os.Stderr, " go tool covdata textfmt -i=dir1,dir2 -o=out.txt\n\n")
fmt.Fprintf(os.Stderr, " \tmerges data from input directories dir1+dir2\n")
fmt.Fprintf(os.Stderr, " \tand emits text format into file 'out.txt'\n")
case percentMode:
fmt.Fprintf(os.Stderr, " go tool covdata percent -i=dir1,dir2\n\n")
fmt.Fprintf(os.Stderr, " \tmerges data from input directories dir1+dir2\n")
fmt.Fprintf(os.Stderr, " \tand emits percentage of statements covered\n\n")
case funcMode:
fmt.Fprintf(os.Stderr, " go tool covdata func -i=dir1,dir2\n\n")
fmt.Fprintf(os.Stderr, " \treads coverage data files from dir1+dirs2\n")
fmt.Fprintf(os.Stderr, " \tand writes out coverage profile data for\n")
fmt.Fprintf(os.Stderr, " \teach function.\n")
case debugDumpMode:
fmt.Fprintf(os.Stderr, " go tool covdata debugdump [flags] -i=dir1,dir2\n\n")
fmt.Fprintf(os.Stderr, " \treads coverage data from dir1+dir2 and dumps\n")
fmt.Fprintf(os.Stderr, " \tcontents in human-readable form to stdout, for\n")
fmt.Fprintf(os.Stderr, " \tdebugging purposes.\n")
default:
panic("unexpected")
}
Exit(2)
}
// Setup is called once at program startup time to vet flag values
// and do any necessary setup operations.
func (d *dstate) Setup() {
if *indirsflag == "" {
d.Usage("select input directories with '-i' option")
}
if d.cmd == textfmtMode || (d.cmd == percentMode && *textfmtoutflag != "") {
if *textfmtoutflag == "" {
d.Usage("select output file name with '-o' option")
}
var err error
d.textfmtoutf, err = os.Create(*textfmtoutflag)
if err != nil {
d.Usage(fmt.Sprintf("unable to open textfmt output file %q: %v", *textfmtoutflag, err))
}
}
if d.cmd == debugDumpMode {
fmt.Printf("/* WARNING: the format of this dump is not stable and is\n")
fmt.Printf(" * expected to change from one Go release to the next.\n")
fmt.Printf(" *\n")
fmt.Printf(" * produced by:\n")
args := append([]string{os.Args[0]}, debugDumpMode)
args = append(args, os.Args[1:]...)
fmt.Printf(" *\t%s\n", strings.Join(args, " "))
fmt.Printf(" */\n")
}
}
func (d *dstate) BeginPod(p pods.Pod) {
d.mm = make(map[pkfunc]decodecounter.FuncPayload)
}
func (d *dstate) EndPod(p pods.Pod) {
if d.cmd == debugDumpMode {
d.cm.ResetModeAndGranularity()
}
}
func (d *dstate) BeginCounterDataFile(cdf string, cdr *decodecounter.CounterDataReader, dirIdx int) {
dbgtrace(2, "visit counter data file %s dirIdx %d", cdf, dirIdx)
if d.cmd == debugDumpMode {
fmt.Printf("data file %s", cdf)
if cdr.Goos() != "" {
fmt.Printf(" GOOS=%s", cdr.Goos())
}
if cdr.Goarch() != "" {
fmt.Printf(" GOARCH=%s", cdr.Goarch())
}
if len(cdr.OsArgs()) != 0 {
fmt.Printf(" program args: %+v\n", cdr.OsArgs())
}
fmt.Printf("\n")
}
}
func (d *dstate) EndCounterDataFile(cdf string, cdr *decodecounter.CounterDataReader, dirIdx int) {
}
func (d *dstate) VisitFuncCounterData(data decodecounter.FuncPayload) {
if nf, ok := d.pkm[data.PkgIdx]; !ok || data.FuncIdx > nf {
warn("func payload inconsistency: id [p=%d,f=%d] nf=%d len(ctrs)=%d in VisitFuncCounterData, ignored", data.PkgIdx, data.FuncIdx, nf, len(data.Counters))
return
}
key := pkfunc{pk: data.PkgIdx, fcn: data.FuncIdx}
val, found := d.mm[key]
dbgtrace(5, "ctr visit pk=%d fid=%d found=%v len(val.ctrs)=%d len(data.ctrs)=%d", data.PkgIdx, data.FuncIdx, found, len(val.Counters), len(data.Counters))
if len(val.Counters) < len(data.Counters) {
t := val.Counters
val.Counters = d.AllocateCounters(len(data.Counters))
copy(val.Counters, t)
}
err, overflow := d.cm.MergeCounters(val.Counters, data.Counters)
if err != nil {
fatal("%v", err)
}
if overflow {
warn("uint32 overflow during counter merge")
}
d.mm[key] = val
}
func (d *dstate) EndCounters() {
}
func (d *dstate) VisitMetaDataFile(mdf string, mfr *decodemeta.CoverageMetaFileReader) {
newgran := mfr.CounterGranularity()
newmode := mfr.CounterMode()
if err := d.cm.SetModeAndGranularity(mdf, newmode, newgran); err != nil {
fatal("%v", err)
}
if d.cmd == debugDumpMode {
fmt.Printf("Cover mode: %s\n", newmode.String())
fmt.Printf("Cover granularity: %s\n", newgran.String())
}
if d.format == nil {
d.format = cformat.NewFormatter(mfr.CounterMode())
}
// To provide an additional layer of checking when reading counter
// data, walk the meta-data file to determine the set of legal
// package/function combinations. This will help catch bugs in the
// counter file reader.
d.pkm = make(map[uint32]uint32)
np := uint32(mfr.NumPackages())
payload := []byte{}
for pkIdx := uint32(0); pkIdx < np; pkIdx++ {
var pd *decodemeta.CoverageMetaDataDecoder
var err error
pd, payload, err = mfr.GetPackageDecoder(pkIdx, payload)
if err != nil {
fatal("reading pkg %d from meta-file %s: %s", pkIdx, mdf, err)
}
d.pkm[pkIdx] = pd.NumFuncs()
}
}
func (d *dstate) BeginPackage(pd *decodemeta.CoverageMetaDataDecoder, pkgIdx uint32) {
d.preambleEmitted = false
d.pkgImportPath = pd.PackagePath()
d.pkgName = pd.PackageName()
d.modulePath = pd.ModulePath()
if d.cmd == pkglistMode {
d.pkgpaths[d.pkgImportPath] = struct{}{}
}
d.format.SetPackage(pd.PackagePath())
}
func (d *dstate) EndPackage(pd *decodemeta.CoverageMetaDataDecoder, pkgIdx uint32) {
}
func (d *dstate) VisitFunc(pkgIdx uint32, fnIdx uint32, fd *coverage.FuncDesc) {
var counters []uint32
key := pkfunc{pk: pkgIdx, fcn: fnIdx}
v, haveCounters := d.mm[key]
dbgtrace(5, "meta visit pk=%d fid=%d fname=%s file=%s found=%v len(val.ctrs)=%d", pkgIdx, fnIdx, fd.Funcname, fd.Srcfile, haveCounters, len(v.Counters))
suppressOutput := false
if haveCounters {
counters = v.Counters
} else if d.cmd == debugDumpMode && *liveflag {
suppressOutput = true
}
if d.cmd == debugDumpMode && !suppressOutput {
if !d.preambleEmitted {
fmt.Printf("\nPackage path: %s\n", d.pkgImportPath)
fmt.Printf("Package name: %s\n", d.pkgName)
fmt.Printf("Module path: %s\n", d.modulePath)
d.preambleEmitted = true
}
fmt.Printf("\nFunc: %s\n", fd.Funcname)
fmt.Printf("Srcfile: %s\n", fd.Srcfile)
fmt.Printf("Literal: %v\n", fd.Lit)
}
for i := 0; i < len(fd.Units); i++ {
u := fd.Units[i]
var count uint32
if counters != nil {
count = counters[i]
}
d.format.AddUnit(fd.Srcfile, fd.Funcname, fd.Lit, u, count)
if d.cmd == debugDumpMode && !suppressOutput {
fmt.Printf("%d: L%d:C%d -- L%d:C%d ",
i, u.StLine, u.StCol, u.EnLine, u.EnCol)
if u.Parent != 0 {
fmt.Printf("Parent:%d = %d\n", u.Parent, count)
} else {
fmt.Printf("NS=%d = %d\n", u.NxStmts, count)
}
}
d.totalStmts += int(u.NxStmts)
if count != 0 {
d.coveredStmts += int(u.NxStmts)
}
}
}
func (d *dstate) Finish() {
// d.format maybe nil here if the specified input dir was empty.
if d.format != nil {
if d.cmd == percentMode {
d.format.EmitPercent(os.Stdout, nil, "", false, false)
}
if d.cmd == funcMode {
d.format.EmitFuncs(os.Stdout)
}
if d.textfmtoutf != nil {
if err := d.format.EmitTextual(d.textfmtoutf); err != nil {
fatal("writing to %s: %v", *textfmtoutflag, err)
}
}
}
if d.textfmtoutf != nil {
if err := d.textfmtoutf.Close(); err != nil {
fatal("closing textfmt output file %s: %v", *textfmtoutflag, err)
}
}
if d.cmd == debugDumpMode {
fmt.Printf("totalStmts: %d coveredStmts: %d\n", d.totalStmts, d.coveredStmts)
}
if d.cmd == pkglistMode {
pkgs := make([]string, 0, len(d.pkgpaths))
for p := range d.pkgpaths {
pkgs = append(pkgs, p)
}
sort.Strings(pkgs)
for _, p := range pkgs {
fmt.Printf("%s\n", p)
}
}
}
|
go/src/cmd/covdata/dump.go/0
|
{
"file_path": "go/src/cmd/covdata/dump.go",
"repo_id": "go",
"token_count": 4703
}
| 122 |
// Copyright 2020 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import "testing"
func TestPackageName(t *testing.T) {
var tests = []struct {
fileName, pkgName string
}{
{"", ""},
{"///", ""},
{"fmt", ""}, // No Go file, improper form.
{"fmt/foo.go", "fmt"},
{"encoding/binary/foo.go", "binary"},
{"encoding/binary/////foo.go", "binary"},
}
var tf templateFile
for _, test := range tests {
tf.Name = test.fileName
td := templateData{
Files: []*templateFile{&tf},
}
got := td.PackageName()
if got != test.pkgName {
t.Errorf("%s: got %s want %s", test.fileName, got, test.pkgName)
}
}
}
|
go/src/cmd/cover/pkgname_test.go/0
|
{
"file_path": "go/src/cmd/cover/pkgname_test.go",
"repo_id": "go",
"token_count": 282
}
| 123 |
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"internal/platform"
"testing"
)
// TestMustLinkExternal verifies that the mustLinkExternal helper
// function matches internal/platform.MustLinkExternal.
func TestMustLinkExternal(t *testing.T) {
for _, goos := range okgoos {
for _, goarch := range okgoarch {
for _, cgoEnabled := range []bool{true, false} {
got := mustLinkExternal(goos, goarch, cgoEnabled)
want := platform.MustLinkExternal(goos, goarch, cgoEnabled)
if got != want {
t.Errorf("mustLinkExternal(%q, %q, %v) = %v; want %v", goos, goarch, cgoEnabled, got, want)
}
}
}
}
}
|
go/src/cmd/dist/build_test.go/0
|
{
"file_path": "go/src/cmd/dist/build_test.go",
"repo_id": "go",
"token_count": 271
}
| 124 |
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
"sync"
"time"
)
// lockedWriter serializes Write calls to an underlying Writer.
type lockedWriter struct {
lock sync.Mutex
w io.Writer
}
func (w *lockedWriter) Write(b []byte) (int, error) {
w.lock.Lock()
defer w.lock.Unlock()
return w.w.Write(b)
}
// testJSONFilter is an io.Writer filter that replaces the Package field in
// test2json output.
type testJSONFilter struct {
w io.Writer // Underlying writer
variant string // Add ":variant" to Package field
lineBuf bytes.Buffer // Buffer for incomplete lines
}
func (f *testJSONFilter) Write(b []byte) (int, error) {
bn := len(b)
// Process complete lines, and buffer any incomplete lines.
for len(b) > 0 {
nl := bytes.IndexByte(b, '\n')
if nl < 0 {
f.lineBuf.Write(b)
break
}
var line []byte
if f.lineBuf.Len() > 0 {
// We have buffered data. Add the rest of the line from b and
// process the complete line.
f.lineBuf.Write(b[:nl+1])
line = f.lineBuf.Bytes()
} else {
// Process a complete line from b.
line = b[:nl+1]
}
b = b[nl+1:]
f.process(line)
f.lineBuf.Reset()
}
return bn, nil
}
func (f *testJSONFilter) Flush() {
// Write any remaining partial line to the underlying writer.
if f.lineBuf.Len() > 0 {
f.w.Write(f.lineBuf.Bytes())
f.lineBuf.Reset()
}
}
func (f *testJSONFilter) process(line []byte) {
if len(line) > 0 && line[0] == '{' {
// Plausible test2json output. Parse it generically.
//
// We go to some effort here to preserve key order while doing this
// generically. This will stay robust to changes in the test2json
// struct, or other additions outside of it. If humans are ever looking
// at the output, it's really nice to keep field order because it
// preserves a lot of regularity in the output.
dec := json.NewDecoder(bytes.NewBuffer(line))
dec.UseNumber()
val, err := decodeJSONValue(dec)
if err == nil && val.atom == json.Delim('{') {
// Rewrite the Package field.
found := false
for i := 0; i < len(val.seq); i += 2 {
if val.seq[i].atom == "Package" {
if pkg, ok := val.seq[i+1].atom.(string); ok {
val.seq[i+1].atom = pkg + ":" + f.variant
found = true
break
}
}
}
if found {
data, err := json.Marshal(val)
if err != nil {
// Should never happen.
panic(fmt.Sprintf("failed to round-trip JSON %q: %s", line, err))
}
f.w.Write(data)
// Copy any trailing text. We expect at most a "\n" here, but
// there could be other text and we want to feed that through.
io.Copy(f.w, dec.Buffered())
return
}
}
}
// Something went wrong. Just pass the line through.
f.w.Write(line)
}
type jsonValue struct {
atom json.Token // If json.Delim, then seq will be filled
seq []jsonValue // If atom == json.Delim('{'), alternating pairs
}
var jsonPop = errors.New("end of JSON sequence")
func decodeJSONValue(dec *json.Decoder) (jsonValue, error) {
t, err := dec.Token()
if err != nil {
if err == io.EOF {
err = io.ErrUnexpectedEOF
}
return jsonValue{}, err
}
switch t := t.(type) {
case json.Delim:
if t == '}' || t == ']' {
return jsonValue{}, jsonPop
}
var seq []jsonValue
for {
val, err := decodeJSONValue(dec)
if err == jsonPop {
break
} else if err != nil {
return jsonValue{}, err
}
seq = append(seq, val)
}
return jsonValue{t, seq}, nil
default:
return jsonValue{t, nil}, nil
}
}
func (v jsonValue) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
var marshal1 func(v jsonValue) error
marshal1 = func(v jsonValue) error {
if t, ok := v.atom.(json.Delim); ok {
buf.WriteRune(rune(t))
for i, v2 := range v.seq {
if t == '{' && i%2 == 1 {
buf.WriteByte(':')
} else if i > 0 {
buf.WriteByte(',')
}
if err := marshal1(v2); err != nil {
return err
}
}
if t == '{' {
buf.WriteByte('}')
} else {
buf.WriteByte(']')
}
return nil
}
bytes, err := json.Marshal(v.atom)
if err != nil {
return err
}
buf.Write(bytes)
return nil
}
err := marshal1(v)
return buf.Bytes(), err
}
func synthesizeSkipEvent(enc *json.Encoder, pkg, msg string) {
type event struct {
Time time.Time
Action string
Package string
Output string `json:",omitempty"`
}
ev := event{Time: time.Now(), Package: pkg, Action: "start"}
enc.Encode(ev)
ev.Action = "output"
ev.Output = msg
enc.Encode(ev)
ev.Action = "skip"
ev.Output = ""
enc.Encode(ev)
}
|
go/src/cmd/dist/testjson.go/0
|
{
"file_path": "go/src/cmd/dist/testjson.go",
"repo_id": "go",
"token_count": 1933
}
| 125 |
// Package comment B.
package merge
// B doc.
func B() {
// B comment.
}
|
go/src/cmd/doc/testdata/merge/bb.go/0
|
{
"file_path": "go/src/cmd/doc/testdata/merge/bb.go",
"repo_id": "go",
"token_count": 28
}
| 126 |
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
func init() {
addTestCases(gotypesTests, gotypes)
}
var gotypesTests = []testCase{
{
Name: "gotypes.0",
In: `package main
import "golang.org/x/tools/go/types"
import "golang.org/x/tools/go/exact"
var _ = exact.Kind
func f() {
_ = exact.MakeBool(true)
}
`,
Out: `package main
import "go/types"
import "go/constant"
var _ = constant.Kind
func f() {
_ = constant.MakeBool(true)
}
`,
},
{
Name: "gotypes.1",
In: `package main
import "golang.org/x/tools/go/types"
import foo "golang.org/x/tools/go/exact"
var _ = foo.Kind
func f() {
_ = foo.MakeBool(true)
}
`,
Out: `package main
import "go/types"
import "go/constant"
var _ = foo.Kind
func f() {
_ = foo.MakeBool(true)
}
`,
},
{
Name: "gotypes.0",
In: `package main
import "golang.org/x/tools/go/types"
import "golang.org/x/tools/go/exact"
var _ = exact.Kind
var constant = 23 // Use of new package name.
func f() {
_ = exact.MakeBool(true)
}
`,
Out: `package main
import "go/types"
import "go/constant"
var _ = constant_.Kind
var constant = 23 // Use of new package name.
func f() {
_ = constant_.MakeBool(true)
}
`,
},
}
|
go/src/cmd/fix/gotypes_test.go/0
|
{
"file_path": "go/src/cmd/fix/gotypes_test.go",
"repo_id": "go",
"token_count": 541
}
| 127 |
// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build go1.1
package main
// Test that go1.1 tag above is included in builds. main.go refers to this definition.
const go11tag = true
|
go/src/cmd/go/go11.go/0
|
{
"file_path": "go/src/cmd/go/go11.go",
"repo_id": "go",
"token_count": 85
}
| 128 |
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package base
import (
"os"
"os/signal"
"sync"
)
// Interrupted is closed when the go command receives an interrupt signal.
var Interrupted = make(chan struct{})
// processSignals setups signal handler.
func processSignals() {
sig := make(chan os.Signal, 1)
signal.Notify(sig, signalsToIgnore...)
go func() {
<-sig
close(Interrupted)
}()
}
var onceProcessSignals sync.Once
// StartSigHandlers starts the signal handlers.
func StartSigHandlers() {
onceProcessSignals.Do(processSignals)
}
|
go/src/cmd/go/internal/base/signal.go/0
|
{
"file_path": "go/src/cmd/go/internal/base/signal.go",
"repo_id": "go",
"token_count": 217
}
| 129 |
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package doc implements the βgo docβ command.
package doc
import (
"cmd/go/internal/base"
"cmd/go/internal/cfg"
"context"
)
var CmdDoc = &base.Command{
Run: runDoc,
UsageLine: "go doc [doc flags] [package|[package.]symbol[.methodOrField]]",
CustomFlags: true,
Short: "show documentation for package or symbol",
Long: `
Doc prints the documentation comments associated with the item identified by its
arguments (a package, const, func, type, var, method, or struct field)
followed by a one-line summary of each of the first-level items "under"
that item (package-level declarations for a package, methods for a type,
etc.).
Doc accepts zero, one, or two arguments.
Given no arguments, that is, when run as
go doc
it prints the package documentation for the package in the current directory.
If the package is a command (package main), the exported symbols of the package
are elided from the presentation unless the -cmd flag is provided.
When run with one argument, the argument is treated as a Go-syntax-like
representation of the item to be documented. What the argument selects depends
on what is installed in GOROOT and GOPATH, as well as the form of the argument,
which is schematically one of these:
go doc <pkg>
go doc <sym>[.<methodOrField>]
go doc [<pkg>.]<sym>[.<methodOrField>]
go doc [<pkg>.][<sym>.]<methodOrField>
The first item in this list matched by the argument is the one whose documentation
is printed. (See the examples below.) However, if the argument starts with a capital
letter it is assumed to identify a symbol or method in the current directory.
For packages, the order of scanning is determined lexically in breadth-first order.
That is, the package presented is the one that matches the search and is nearest
the root and lexically first at its level of the hierarchy. The GOROOT tree is
always scanned in its entirety before GOPATH.
If there is no package specified or matched, the package in the current
directory is selected, so "go doc Foo" shows the documentation for symbol Foo in
the current package.
The package path must be either a qualified path or a proper suffix of a
path. The go tool's usual package mechanism does not apply: package path
elements like . and ... are not implemented by go doc.
When run with two arguments, the first is a package path (full path or suffix),
and the second is a symbol, or symbol with method or struct field:
go doc <pkg> <sym>[.<methodOrField>]
In all forms, when matching symbols, lower-case letters in the argument match
either case but upper-case letters match exactly. This means that there may be
multiple matches of a lower-case argument in a package if different symbols have
different cases. If this occurs, documentation for all matches is printed.
Examples:
go doc
Show documentation for current package.
go doc Foo
Show documentation for Foo in the current package.
(Foo starts with a capital letter so it cannot match
a package path.)
go doc encoding/json
Show documentation for the encoding/json package.
go doc json
Shorthand for encoding/json.
go doc json.Number (or go doc json.number)
Show documentation and method summary for json.Number.
go doc json.Number.Int64 (or go doc json.number.int64)
Show documentation for json.Number's Int64 method.
go doc cmd/doc
Show package docs for the doc command.
go doc -cmd cmd/doc
Show package docs and exported symbols within the doc command.
go doc template.new
Show documentation for html/template's New function.
(html/template is lexically before text/template)
go doc text/template.new # One argument
Show documentation for text/template's New function.
go doc text/template new # Two arguments
Show documentation for text/template's New function.
At least in the current tree, these invocations all print the
documentation for json.Decoder's Decode method:
go doc json.Decoder.Decode
go doc json.decoder.decode
go doc json.decode
cd go/src/encoding/json; go doc decode
Flags:
-all
Show all the documentation for the package.
-c
Respect case when matching symbols.
-cmd
Treat a command (package main) like a regular package.
Otherwise package main's exported symbols are hidden
when showing the package's top-level documentation.
-short
One-line representation for each symbol.
-src
Show the full source code for the symbol. This will
display the full Go source of its declaration and
definition, such as a function definition (including
the body), type declaration or enclosing const
block. The output may therefore include unexported
details.
-u
Show documentation for unexported as well as exported
symbols, methods, and fields.
`,
}
func runDoc(ctx context.Context, cmd *base.Command, args []string) {
base.Run(cfg.BuildToolexec, base.Tool("doc"), args)
}
|
go/src/cmd/go/internal/doc/doc.go/0
|
{
"file_path": "go/src/cmd/go/internal/doc/doc.go",
"repo_id": "go",
"token_count": 1362
}
| 130 |
//go:build linux
// +build linux
package android
import _ "f"
|
go/src/cmd/go/internal/imports/testdata/android/f.go/0
|
{
"file_path": "go/src/cmd/go/internal/imports/testdata/android/f.go",
"repo_id": "go",
"token_count": 22
}
| 131 |
package x
import "import1"
|
go/src/cmd/go/internal/imports/testdata/star/x.go/0
|
{
"file_path": "go/src/cmd/go/internal/imports/testdata/star/x.go",
"repo_id": "go",
"token_count": 10
}
| 132 |
// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// go mod graph
package modcmd
import (
"bufio"
"context"
"os"
"cmd/go/internal/base"
"cmd/go/internal/cfg"
"cmd/go/internal/gover"
"cmd/go/internal/modload"
"cmd/go/internal/toolchain"
"golang.org/x/mod/module"
)
var cmdGraph = &base.Command{
UsageLine: "go mod graph [-go=version] [-x]",
Short: "print module requirement graph",
Long: `
Graph prints the module requirement graph (with replacements applied)
in text form. Each line in the output has two space-separated fields: a module
and one of its requirements. Each module is identified as a string of the form
path@version, except for the main module, which has no @version suffix.
The -go flag causes graph to report the module graph as loaded by the
given Go version, instead of the version indicated by the 'go' directive
in the go.mod file.
The -x flag causes graph to print the commands graph executes.
See https://golang.org/ref/mod#go-mod-graph for more about 'go mod graph'.
`,
Run: runGraph,
}
var (
graphGo goVersionFlag
)
func init() {
cmdGraph.Flag.Var(&graphGo, "go", "")
cmdGraph.Flag.BoolVar(&cfg.BuildX, "x", false, "")
base.AddChdirFlag(&cmdGraph.Flag)
base.AddModCommonFlags(&cmdGraph.Flag)
}
func runGraph(ctx context.Context, cmd *base.Command, args []string) {
modload.InitWorkfile()
if len(args) > 0 {
base.Fatalf("go: 'go mod graph' accepts no arguments")
}
modload.ForceUseModules = true
modload.RootMode = modload.NeedRoot
goVersion := graphGo.String()
if goVersion != "" && gover.Compare(gover.Local(), goVersion) < 0 {
toolchain.SwitchOrFatal(ctx, &gover.TooNewError{
What: "-go flag",
GoVersion: goVersion,
})
}
mg, err := modload.LoadModGraph(ctx, goVersion)
if err != nil {
base.Fatal(err)
}
w := bufio.NewWriter(os.Stdout)
defer w.Flush()
format := func(m module.Version) {
w.WriteString(m.Path)
if m.Version != "" {
w.WriteString("@")
w.WriteString(m.Version)
}
}
mg.WalkBreadthFirst(func(m module.Version) {
reqs, _ := mg.RequiredBy(m)
for _, r := range reqs {
format(m)
w.WriteByte(' ')
format(r)
w.WriteByte('\n')
}
})
}
|
go/src/cmd/go/internal/modcmd/graph.go/0
|
{
"file_path": "go/src/cmd/go/internal/modcmd/graph.go",
"repo_id": "go",
"token_count": 841
}
| 133 |
// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package modfetch
import (
"archive/zip"
"bytes"
"context"
"errors"
"fmt"
"io"
"io/fs"
"os"
"path"
"path/filepath"
"sort"
"strings"
"time"
"cmd/go/internal/gover"
"cmd/go/internal/modfetch/codehost"
"golang.org/x/mod/modfile"
"golang.org/x/mod/module"
"golang.org/x/mod/semver"
modzip "golang.org/x/mod/zip"
)
// A codeRepo implements modfetch.Repo using an underlying codehost.Repo.
type codeRepo struct {
modPath string
// code is the repository containing this module.
code codehost.Repo
// codeRoot is the import path at the root of code.
codeRoot string
// codeDir is the directory (relative to root) at which we expect to find the module.
// If pathMajor is non-empty and codeRoot is not the full modPath,
// then we look in both codeDir and codeDir/pathMajor[1:].
codeDir string
// pathMajor is the suffix of modPath that indicates its major version,
// or the empty string if modPath is at major version 0 or 1.
//
// pathMajor is typically of the form "/vN", but possibly ".vN", or
// ".vN-unstable" for modules resolved using gopkg.in.
pathMajor string
// pathPrefix is the prefix of modPath that excludes pathMajor.
// It is used only for logging.
pathPrefix string
// pseudoMajor is the major version prefix to require when generating
// pseudo-versions for this module, derived from the module path. pseudoMajor
// is empty if the module path does not include a version suffix (that is,
// accepts either v0 or v1).
pseudoMajor string
}
// newCodeRepo returns a Repo that reads the source code for the module with the
// given path, from the repo stored in code, with the root of the repo
// containing the path given by codeRoot.
func newCodeRepo(code codehost.Repo, codeRoot, path string) (Repo, error) {
if !hasPathPrefix(path, codeRoot) {
return nil, fmt.Errorf("mismatched repo: found %s for %s", codeRoot, path)
}
pathPrefix, pathMajor, ok := module.SplitPathVersion(path)
if !ok {
return nil, fmt.Errorf("invalid module path %q", path)
}
if codeRoot == path {
pathPrefix = path
}
pseudoMajor := module.PathMajorPrefix(pathMajor)
// Compute codeDir = bar, the subdirectory within the repo
// corresponding to the module root.
//
// At this point we might have:
// path = github.com/rsc/foo/bar/v2
// codeRoot = github.com/rsc/foo
// pathPrefix = github.com/rsc/foo/bar
// pathMajor = /v2
// pseudoMajor = v2
//
// which gives
// codeDir = bar
//
// We know that pathPrefix is a prefix of path, and codeRoot is a prefix of
// path, but codeRoot may or may not be a prefix of pathPrefix, because
// codeRoot may be the entire path (in which case codeDir should be empty).
// That occurs in two situations.
//
// One is when a go-import meta tag resolves the complete module path,
// including the pathMajor suffix:
// path = nanomsg.org/go/mangos/v2
// codeRoot = nanomsg.org/go/mangos/v2
// pathPrefix = nanomsg.org/go/mangos
// pathMajor = /v2
// pseudoMajor = v2
//
// The other is similar: for gopkg.in only, the major version is encoded
// with a dot rather than a slash, and thus can't be in a subdirectory.
// path = gopkg.in/yaml.v2
// codeRoot = gopkg.in/yaml.v2
// pathPrefix = gopkg.in/yaml
// pathMajor = .v2
// pseudoMajor = v2
//
codeDir := ""
if codeRoot != path {
if !hasPathPrefix(pathPrefix, codeRoot) {
return nil, fmt.Errorf("repository rooted at %s cannot contain module %s", codeRoot, path)
}
codeDir = strings.Trim(pathPrefix[len(codeRoot):], "/")
}
r := &codeRepo{
modPath: path,
code: code,
codeRoot: codeRoot,
codeDir: codeDir,
pathPrefix: pathPrefix,
pathMajor: pathMajor,
pseudoMajor: pseudoMajor,
}
return r, nil
}
func (r *codeRepo) ModulePath() string {
return r.modPath
}
func (r *codeRepo) CheckReuse(ctx context.Context, old *codehost.Origin) error {
return r.code.CheckReuse(ctx, old, r.codeDir)
}
func (r *codeRepo) Versions(ctx context.Context, prefix string) (*Versions, error) {
// Special case: gopkg.in/macaroon-bakery.v2-unstable
// does not use the v2 tags (those are for macaroon-bakery.v2).
// It has no possible tags at all.
if strings.HasPrefix(r.modPath, "gopkg.in/") && strings.HasSuffix(r.modPath, "-unstable") {
return &Versions{}, nil
}
p := prefix
if r.codeDir != "" {
p = r.codeDir + "/" + p
}
tags, err := r.code.Tags(ctx, p)
if err != nil {
return nil, &module.ModuleError{
Path: r.modPath,
Err: err,
}
}
if tags.Origin != nil {
tags.Origin.Subdir = r.codeDir
}
var list, incompatible []string
for _, tag := range tags.List {
if !strings.HasPrefix(tag.Name, p) {
continue
}
v := tag.Name
if r.codeDir != "" {
v = v[len(r.codeDir)+1:]
}
// Note: ./codehost/codehost.go's isOriginTag knows about these conditions too.
// If these are relaxed, isOriginTag will need to be relaxed as well.
if v == "" || v != semver.Canonical(v) {
// Ignore non-canonical tags: Stat rewrites those to canonical
// pseudo-versions. Note that we compare against semver.Canonical here
// instead of module.CanonicalVersion: revToRev strips "+incompatible"
// suffixes before looking up tags, so a tag like "v2.0.0+incompatible"
// would not resolve at all. (The Go version string "v2.0.0+incompatible"
// refers to the "v2.0.0" version tag, which we handle below.)
continue
}
if module.IsPseudoVersion(v) {
// Ignore tags that look like pseudo-versions: Stat rewrites those
// unambiguously to the underlying commit, and tagToVersion drops them.
continue
}
if err := module.CheckPathMajor(v, r.pathMajor); err != nil {
if r.codeDir == "" && r.pathMajor == "" && semver.Major(v) > "v1" {
incompatible = append(incompatible, v)
}
continue
}
list = append(list, v)
}
semver.Sort(list)
semver.Sort(incompatible)
return r.appendIncompatibleVersions(ctx, tags.Origin, list, incompatible)
}
// appendIncompatibleVersions appends "+incompatible" versions to list if
// appropriate, returning the final list.
//
// The incompatible list contains candidate versions without the '+incompatible'
// prefix.
//
// Both list and incompatible must be sorted in semantic order.
func (r *codeRepo) appendIncompatibleVersions(ctx context.Context, origin *codehost.Origin, list, incompatible []string) (*Versions, error) {
versions := &Versions{
Origin: origin,
List: list,
}
if len(incompatible) == 0 || r.pathMajor != "" {
// No +incompatible versions are possible, so no need to check them.
return versions, nil
}
versionHasGoMod := func(v string) (bool, error) {
_, err := r.code.ReadFile(ctx, v, "go.mod", codehost.MaxGoMod)
if err == nil {
return true, nil
}
if !os.IsNotExist(err) {
return false, &module.ModuleError{
Path: r.modPath,
Err: err,
}
}
return false, nil
}
if len(list) > 0 {
ok, err := versionHasGoMod(list[len(list)-1])
if err != nil {
return nil, err
}
if ok {
// The latest compatible version has a go.mod file, so assume that all
// subsequent versions do as well, and do not include any +incompatible
// versions. Even if we are wrong, the author clearly intends module
// consumers to be on the v0/v1 line instead of a higher +incompatible
// version. (See https://golang.org/issue/34189.)
//
// We know of at least two examples where this behavior is desired
// (github.com/russross/blackfriday@v2.0.0 and
// github.com/libp2p/go-libp2p@v6.0.23), and (as of 2019-10-29) have no
// concrete examples for which it is undesired.
return versions, nil
}
}
var (
lastMajor string
lastMajorHasGoMod bool
)
for i, v := range incompatible {
major := semver.Major(v)
if major != lastMajor {
rem := incompatible[i:]
j := sort.Search(len(rem), func(j int) bool {
return semver.Major(rem[j]) != major
})
latestAtMajor := rem[j-1]
var err error
lastMajor = major
lastMajorHasGoMod, err = versionHasGoMod(latestAtMajor)
if err != nil {
return nil, err
}
}
if lastMajorHasGoMod {
// The latest release of this major version has a go.mod file, so it is
// not allowed as +incompatible. It would be confusing to include some
// minor versions of this major version as +incompatible but require
// semantic import versioning for others, so drop all +incompatible
// versions for this major version.
//
// If we're wrong about a minor version in the middle, users will still be
// able to 'go get' specific tags for that version explicitly β they just
// won't appear in 'go list' or as the results for queries with inequality
// bounds.
continue
}
versions.List = append(versions.List, v+"+incompatible")
}
return versions, nil
}
func (r *codeRepo) Stat(ctx context.Context, rev string) (*RevInfo, error) {
if rev == "latest" {
return r.Latest(ctx)
}
codeRev := r.revToRev(rev)
info, err := r.code.Stat(ctx, codeRev)
if err != nil {
// Note: info may be non-nil to supply Origin for caching error.
var revInfo *RevInfo
if info != nil {
revInfo = &RevInfo{
Origin: info.Origin,
Version: rev,
}
}
return revInfo, &module.ModuleError{
Path: r.modPath,
Err: &module.InvalidVersionError{
Version: rev,
Err: err,
},
}
}
return r.convert(ctx, info, rev)
}
func (r *codeRepo) Latest(ctx context.Context) (*RevInfo, error) {
info, err := r.code.Latest(ctx)
if err != nil {
if info != nil {
return &RevInfo{Origin: info.Origin}, err
}
return nil, err
}
return r.convert(ctx, info, "")
}
// convert converts a version as reported by the code host to a version as
// interpreted by the module system.
//
// If statVers is a valid module version, it is used for the Version field.
// Otherwise, the Version is derived from the passed-in info and recent tags.
func (r *codeRepo) convert(ctx context.Context, info *codehost.RevInfo, statVers string) (revInfo *RevInfo, err error) {
defer func() {
if info.Origin == nil {
return
}
if revInfo == nil {
revInfo = new(RevInfo)
} else if revInfo.Origin != nil {
panic("internal error: RevInfo Origin unexpectedly already populated")
}
origin := *info.Origin
revInfo.Origin = &origin
origin.Subdir = r.codeDir
v := revInfo.Version
if module.IsPseudoVersion(v) && (v != statVers || !strings.HasPrefix(v, "v0.0.0-")) {
// Add tags that are relevant to pseudo-version calculation to origin.
prefix := r.codeDir
if prefix != "" {
prefix += "/"
}
if r.pathMajor != "" { // "/v2" or "/.v2"
prefix += r.pathMajor[1:] + "." // += "v2."
}
tags, tagsErr := r.code.Tags(ctx, prefix)
if tagsErr != nil {
revInfo.Origin = nil
if err == nil {
err = tagsErr
}
} else {
origin.TagPrefix = tags.Origin.TagPrefix
origin.TagSum = tags.Origin.TagSum
}
}
}()
// If this is a plain tag (no dir/ prefix)
// and the module path is unversioned,
// and if the underlying file tree has no go.mod,
// then allow using the tag with a +incompatible suffix.
//
// (If the version is +incompatible, then the go.mod file must not exist:
// +incompatible is not an ongoing opt-out from semantic import versioning.)
incompatibleOk := map[string]bool{}
canUseIncompatible := func(v string) bool {
if r.codeDir != "" || r.pathMajor != "" {
// A non-empty codeDir indicates a module within a subdirectory,
// which necessarily has a go.mod file indicating the module boundary.
// A non-empty pathMajor indicates a module path with a major-version
// suffix, which must match.
return false
}
ok, seen := incompatibleOk[""]
if !seen {
_, errGoMod := r.code.ReadFile(ctx, info.Name, "go.mod", codehost.MaxGoMod)
ok = (errGoMod != nil)
incompatibleOk[""] = ok
}
if !ok {
// A go.mod file exists at the repo root.
return false
}
// Per https://go.dev/issue/51324, previous versions of the 'go' command
// didn't always check for go.mod files in subdirectories, so if the user
// requests a +incompatible version explicitly, we should continue to allow
// it. Otherwise, if vN/go.mod exists, expect that release tags for that
// major version are intended for the vN module.
if v != "" && !strings.HasSuffix(statVers, "+incompatible") {
major := semver.Major(v)
ok, seen = incompatibleOk[major]
if !seen {
_, errGoModSub := r.code.ReadFile(ctx, info.Name, path.Join(major, "go.mod"), codehost.MaxGoMod)
ok = (errGoModSub != nil)
incompatibleOk[major] = ok
}
if !ok {
return false
}
}
return true
}
// checkCanonical verifies that the canonical version v is compatible with the
// module path represented by r, adding a "+incompatible" suffix if needed.
//
// If statVers is also canonical, checkCanonical also verifies that v is
// either statVers or statVers with the added "+incompatible" suffix.
checkCanonical := func(v string) (*RevInfo, error) {
// If r.codeDir is non-empty, then the go.mod file must exist: the module
// author β not the module consumer, β gets to decide how to carve up the repo
// into modules.
//
// Conversely, if the go.mod file exists, the module author β not the module
// consumer β gets to determine the module's path
//
// r.findDir verifies both of these conditions. Execute it now so that
// r.Stat will correctly return a notExistError if the go.mod location or
// declared module path doesn't match.
_, _, _, err := r.findDir(ctx, v)
if err != nil {
// TODO: It would be nice to return an error like "not a module".
// Right now we return "missing go.mod", which is a little confusing.
return nil, &module.ModuleError{
Path: r.modPath,
Err: &module.InvalidVersionError{
Version: v,
Err: notExistError{err: err},
},
}
}
invalidf := func(format string, args ...any) error {
return &module.ModuleError{
Path: r.modPath,
Err: &module.InvalidVersionError{
Version: v,
Err: fmt.Errorf(format, args...),
},
}
}
// Add the +incompatible suffix if needed or requested explicitly, and
// verify that its presence or absence is appropriate for this version
// (which depends on whether it has an explicit go.mod file).
if v == strings.TrimSuffix(statVers, "+incompatible") {
v = statVers
}
base := strings.TrimSuffix(v, "+incompatible")
var errIncompatible error
if !module.MatchPathMajor(base, r.pathMajor) {
if canUseIncompatible(base) {
v = base + "+incompatible"
} else {
if r.pathMajor != "" {
errIncompatible = invalidf("module path includes a major version suffix, so major version must match")
} else {
errIncompatible = invalidf("module contains a go.mod file, so module path must match major version (%q)", path.Join(r.pathPrefix, semver.Major(v)))
}
}
} else if strings.HasSuffix(v, "+incompatible") {
errIncompatible = invalidf("+incompatible suffix not allowed: major version %s is compatible", semver.Major(v))
}
if statVers != "" && statVers == module.CanonicalVersion(statVers) {
// Since the caller-requested version is canonical, it would be very
// confusing to resolve it to anything but itself, possibly with a
// "+incompatible" suffix. Error out explicitly.
if statBase := strings.TrimSuffix(statVers, "+incompatible"); statBase != base {
return nil, &module.ModuleError{
Path: r.modPath,
Err: &module.InvalidVersionError{
Version: statVers,
Err: fmt.Errorf("resolves to version %v (%s is not a tag)", v, statBase),
},
}
}
}
if errIncompatible != nil {
return nil, errIncompatible
}
return &RevInfo{
Name: info.Name,
Short: info.Short,
Time: info.Time,
Version: v,
}, nil
}
// Determine version.
if module.IsPseudoVersion(statVers) {
// Validate the go.mod location and major version before
// we check for an ancestor tagged with the pseudo-version base.
//
// We can rule out an invalid subdirectory or major version with only
// shallow commit information, but checking the pseudo-version base may
// require downloading a (potentially more expensive) full history.
revInfo, err = checkCanonical(statVers)
if err != nil {
return revInfo, err
}
if err := r.validatePseudoVersion(ctx, info, statVers); err != nil {
return nil, err
}
return revInfo, nil
}
// statVers is not a pseudo-version, so we need to either resolve it to a
// canonical version or verify that it is already a canonical tag
// (not a branch).
// Derive or verify a version from a code repo tag.
// Tag must have a prefix matching codeDir.
tagPrefix := ""
if r.codeDir != "" {
tagPrefix = r.codeDir + "/"
}
isRetracted, err := r.retractedVersions(ctx)
if err != nil {
isRetracted = func(string) bool { return false }
}
// tagToVersion returns the version obtained by trimming tagPrefix from tag.
// If the tag is invalid, retracted, or a pseudo-version, tagToVersion returns
// an empty version.
tagToVersion := func(tag string) (v string, tagIsCanonical bool) {
if !strings.HasPrefix(tag, tagPrefix) {
return "", false
}
trimmed := tag[len(tagPrefix):]
// Tags that look like pseudo-versions would be confusing. Ignore them.
if module.IsPseudoVersion(tag) {
return "", false
}
v = semver.Canonical(trimmed) // Not module.Canonical: we don't want to pick up an explicit "+incompatible" suffix from the tag.
if v == "" || !strings.HasPrefix(trimmed, v) {
return "", false // Invalid or incomplete version (just vX or vX.Y).
}
if v == trimmed {
tagIsCanonical = true
}
return v, tagIsCanonical
}
// If the VCS gave us a valid version, use that.
if v, tagIsCanonical := tagToVersion(info.Version); tagIsCanonical {
if info, err := checkCanonical(v); err == nil {
return info, err
}
}
// Look through the tags on the revision for either a usable canonical version
// or an appropriate base for a pseudo-version.
var (
highestCanonical string
pseudoBase string
)
for _, pathTag := range info.Tags {
v, tagIsCanonical := tagToVersion(pathTag)
if statVers != "" && semver.Compare(v, statVers) == 0 {
// The tag is equivalent to the version requested by the user.
if tagIsCanonical {
// This tag is the canonical form of the requested version,
// not some other form with extra build metadata.
// Use this tag so that the resolved version will match exactly.
// (If it isn't actually allowed, we'll error out in checkCanonical.)
return checkCanonical(v)
} else {
// The user explicitly requested something equivalent to this tag. We
// can't use the version from the tag directly: since the tag is not
// canonical, it could be ambiguous. For example, tags v0.0.1+a and
// v0.0.1+b might both exist and refer to different revisions.
//
// The tag is otherwise valid for the module, so we can at least use it as
// the base of an unambiguous pseudo-version.
//
// If multiple tags match, tagToVersion will canonicalize them to the same
// base version.
pseudoBase = v
}
}
// Save the highest non-retracted canonical tag for the revision.
// If we don't find a better match, we'll use it as the canonical version.
if tagIsCanonical && semver.Compare(highestCanonical, v) < 0 && !isRetracted(v) {
if module.MatchPathMajor(v, r.pathMajor) || canUseIncompatible(v) {
highestCanonical = v
}
}
}
// If we found a valid canonical tag for the revision, return it.
// Even if we found a good pseudo-version base, a canonical version is better.
if highestCanonical != "" {
return checkCanonical(highestCanonical)
}
// Find the highest tagged version in the revision's history, subject to
// major version and +incompatible constraints. Use that version as the
// pseudo-version base so that the pseudo-version sorts higher. Ignore
// retracted versions.
tagAllowed := func(tag string) bool {
v, _ := tagToVersion(tag)
if v == "" {
return false
}
if !module.MatchPathMajor(v, r.pathMajor) && !canUseIncompatible(v) {
return false
}
return !isRetracted(v)
}
if pseudoBase == "" {
tag, err := r.code.RecentTag(ctx, info.Name, tagPrefix, tagAllowed)
if err != nil && !errors.Is(err, errors.ErrUnsupported) {
return nil, err
}
if tag != "" {
pseudoBase, _ = tagToVersion(tag)
}
}
return checkCanonical(module.PseudoVersion(r.pseudoMajor, pseudoBase, info.Time, info.Short))
}
// validatePseudoVersion checks that version has a major version compatible with
// r.modPath and encodes a base version and commit metadata that agrees with
// info.
//
// Note that verifying a nontrivial base version in particular may be somewhat
// expensive: in order to do so, r.code.DescendsFrom will need to fetch at least
// enough of the commit history to find a path between version and its base.
// Fortunately, many pseudo-versions β such as those for untagged repositories β
// have trivial bases!
func (r *codeRepo) validatePseudoVersion(ctx context.Context, info *codehost.RevInfo, version string) (err error) {
defer func() {
if err != nil {
if _, ok := err.(*module.ModuleError); !ok {
if _, ok := err.(*module.InvalidVersionError); !ok {
err = &module.InvalidVersionError{Version: version, Pseudo: true, Err: err}
}
err = &module.ModuleError{Path: r.modPath, Err: err}
}
}
}()
rev, err := module.PseudoVersionRev(version)
if err != nil {
return err
}
if rev != info.Short {
switch {
case strings.HasPrefix(rev, info.Short):
return fmt.Errorf("revision is longer than canonical (expected %s)", info.Short)
case strings.HasPrefix(info.Short, rev):
return fmt.Errorf("revision is shorter than canonical (expected %s)", info.Short)
default:
return fmt.Errorf("does not match short name of revision (expected %s)", info.Short)
}
}
t, err := module.PseudoVersionTime(version)
if err != nil {
return err
}
if !t.Equal(info.Time.Truncate(time.Second)) {
return fmt.Errorf("does not match version-control timestamp (expected %s)", info.Time.UTC().Format(module.PseudoVersionTimestampFormat))
}
tagPrefix := ""
if r.codeDir != "" {
tagPrefix = r.codeDir + "/"
}
// A pseudo-version should have a precedence just above its parent revisions,
// and no higher. Otherwise, it would be possible for library authors to "pin"
// dependency versions (and bypass the usual minimum version selection) by
// naming an extremely high pseudo-version rather than an accurate one.
//
// Moreover, if we allow a pseudo-version to use any arbitrary pre-release
// tag, we end up with infinitely many possible names for each commit. Each
// name consumes resources in the module cache and proxies, so we want to
// restrict them to a finite set under control of the module author.
//
// We address both of these issues by requiring the tag upon which the
// pseudo-version is based to refer to some ancestor of the revision. We
// prefer the highest such tag when constructing a new pseudo-version, but do
// not enforce that property when resolving existing pseudo-versions: we don't
// know when the parent tags were added, and the highest-tagged parent may not
// have existed when the pseudo-version was first resolved.
base, err := module.PseudoVersionBase(strings.TrimSuffix(version, "+incompatible"))
if err != nil {
return err
}
if base == "" {
if r.pseudoMajor == "" && semver.Major(version) == "v1" {
return fmt.Errorf("major version without preceding tag must be v0, not v1")
}
return nil
} else {
for _, tag := range info.Tags {
versionOnly := strings.TrimPrefix(tag, tagPrefix)
if versionOnly == base {
// The base version is canonical, so if the version from the tag is
// literally equal (not just equivalent), then the tag is canonical too.
//
// We allow pseudo-versions to be derived from non-canonical tags on the
// same commit, so that tags like "v1.1.0+some-metadata" resolve as
// close as possible to the canonical version ("v1.1.0") while still
// enforcing a total ordering ("v1.1.1-0.[β¦]" with a unique suffix).
//
// However, canonical tags already have a total ordering, so there is no
// reason not to use the canonical tag directly, and we know that the
// canonical tag must already exist because the pseudo-version is
// derived from it. In that case, referring to the revision by a
// pseudo-version derived from its own canonical tag is just confusing.
return fmt.Errorf("tag (%s) found on revision %s is already canonical, so should not be replaced with a pseudo-version derived from that tag", tag, rev)
}
}
}
tags, err := r.code.Tags(ctx, tagPrefix+base)
if err != nil {
return err
}
var lastTag string // Prefer to log some real tag rather than a canonically-equivalent base.
ancestorFound := false
for _, tag := range tags.List {
versionOnly := strings.TrimPrefix(tag.Name, tagPrefix)
if semver.Compare(versionOnly, base) == 0 {
lastTag = tag.Name
ancestorFound, err = r.code.DescendsFrom(ctx, info.Name, tag.Name)
if ancestorFound {
break
}
}
}
if lastTag == "" {
return fmt.Errorf("preceding tag (%s) not found", base)
}
if !ancestorFound {
if err != nil {
return err
}
rev, err := module.PseudoVersionRev(version)
if err != nil {
return fmt.Errorf("not a descendent of preceding tag (%s)", lastTag)
}
return fmt.Errorf("revision %s is not a descendent of preceding tag (%s)", rev, lastTag)
}
return nil
}
func (r *codeRepo) revToRev(rev string) string {
if semver.IsValid(rev) {
if module.IsPseudoVersion(rev) {
r, _ := module.PseudoVersionRev(rev)
return r
}
if semver.Build(rev) == "+incompatible" {
rev = rev[:len(rev)-len("+incompatible")]
}
if r.codeDir == "" {
return rev
}
return r.codeDir + "/" + rev
}
return rev
}
func (r *codeRepo) versionToRev(version string) (rev string, err error) {
if !semver.IsValid(version) {
return "", &module.ModuleError{
Path: r.modPath,
Err: &module.InvalidVersionError{
Version: version,
Err: errors.New("syntax error"),
},
}
}
return r.revToRev(version), nil
}
// findDir locates the directory within the repo containing the module.
//
// If r.pathMajor is non-empty, this can be either r.codeDir or β if a go.mod
// file exists β r.codeDir/r.pathMajor[1:].
func (r *codeRepo) findDir(ctx context.Context, version string) (rev, dir string, gomod []byte, err error) {
rev, err = r.versionToRev(version)
if err != nil {
return "", "", nil, err
}
// Load info about go.mod but delay consideration
// (except I/O error) until we rule out v2/go.mod.
file1 := path.Join(r.codeDir, "go.mod")
gomod1, err1 := r.code.ReadFile(ctx, rev, file1, codehost.MaxGoMod)
if err1 != nil && !os.IsNotExist(err1) {
return "", "", nil, fmt.Errorf("reading %s/%s at revision %s: %v", r.codeRoot, file1, rev, err1)
}
mpath1 := modfile.ModulePath(gomod1)
found1 := err1 == nil && (isMajor(mpath1, r.pathMajor) || r.canReplaceMismatchedVersionDueToBug(mpath1))
var file2 string
if r.pathMajor != "" && r.codeRoot != r.modPath && !strings.HasPrefix(r.pathMajor, ".") {
// Suppose pathMajor is "/v2".
// Either go.mod should claim v2 and v2/go.mod should not exist,
// or v2/go.mod should exist and claim v2. Not both.
// Note that we don't check the full path, just the major suffix,
// because of replacement modules. This might be a fork of
// the real module, found at a different path, usable only in
// a replace directive.
dir2 := path.Join(r.codeDir, r.pathMajor[1:])
file2 = path.Join(dir2, "go.mod")
gomod2, err2 := r.code.ReadFile(ctx, rev, file2, codehost.MaxGoMod)
if err2 != nil && !os.IsNotExist(err2) {
return "", "", nil, fmt.Errorf("reading %s/%s at revision %s: %v", r.codeRoot, file2, rev, err2)
}
mpath2 := modfile.ModulePath(gomod2)
found2 := err2 == nil && isMajor(mpath2, r.pathMajor)
if found1 && found2 {
return "", "", nil, fmt.Errorf("%s/%s and ...%s/go.mod both have ...%s module paths at revision %s", r.pathPrefix, file1, r.pathMajor, r.pathMajor, rev)
}
if found2 {
return rev, dir2, gomod2, nil
}
if err2 == nil {
if mpath2 == "" {
return "", "", nil, fmt.Errorf("%s/%s is missing module path at revision %s", r.codeRoot, file2, rev)
}
return "", "", nil, fmt.Errorf("%s/%s has non-...%s module path %q at revision %s", r.codeRoot, file2, r.pathMajor, mpath2, rev)
}
}
// Not v2/go.mod, so it's either go.mod or nothing. Which is it?
if found1 {
// Explicit go.mod with matching major version ok.
return rev, r.codeDir, gomod1, nil
}
if err1 == nil {
// Explicit go.mod with non-matching major version disallowed.
suffix := ""
if file2 != "" {
suffix = fmt.Sprintf(" (and ...%s/go.mod does not exist)", r.pathMajor)
}
if mpath1 == "" {
return "", "", nil, fmt.Errorf("%s is missing module path%s at revision %s", file1, suffix, rev)
}
if r.pathMajor != "" { // ".v1", ".v2" for gopkg.in
return "", "", nil, fmt.Errorf("%s has non-...%s module path %q%s at revision %s", file1, r.pathMajor, mpath1, suffix, rev)
}
if _, _, ok := module.SplitPathVersion(mpath1); !ok {
return "", "", nil, fmt.Errorf("%s has malformed module path %q%s at revision %s", file1, mpath1, suffix, rev)
}
return "", "", nil, fmt.Errorf("%s has post-%s module path %q%s at revision %s", file1, semver.Major(version), mpath1, suffix, rev)
}
if r.codeDir == "" && (r.pathMajor == "" || strings.HasPrefix(r.pathMajor, ".")) {
// Implicit go.mod at root of repo OK for v0/v1 and for gopkg.in.
return rev, "", nil, nil
}
// Implicit go.mod below root of repo or at v2+ disallowed.
// Be clear about possibility of using either location for v2+.
if file2 != "" {
return "", "", nil, fmt.Errorf("missing %s/go.mod and ...%s/go.mod at revision %s", r.pathPrefix, r.pathMajor, rev)
}
return "", "", nil, fmt.Errorf("missing %s/go.mod at revision %s", r.pathPrefix, rev)
}
// isMajor reports whether the versions allowed for mpath are compatible with
// the major version(s) implied by pathMajor, or false if mpath has an invalid
// version suffix.
func isMajor(mpath, pathMajor string) bool {
if mpath == "" {
// If we don't have a path, we don't know what version(s) it is compatible with.
return false
}
_, mpathMajor, ok := module.SplitPathVersion(mpath)
if !ok {
// An invalid module path is not compatible with any version.
return false
}
if pathMajor == "" {
// All of the valid versions for a gopkg.in module that requires major
// version v0 or v1 are compatible with the "v0 or v1" implied by an empty
// pathMajor.
switch module.PathMajorPrefix(mpathMajor) {
case "", "v0", "v1":
return true
default:
return false
}
}
if mpathMajor == "" {
// Even if pathMajor is ".v0" or ".v1", we can't be sure that a module
// without a suffix is tagged appropriately. Besides, we don't expect clones
// of non-gopkg.in modules to have gopkg.in paths, so a non-empty,
// non-gopkg.in mpath is probably the wrong module for any such pathMajor
// anyway.
return false
}
// If both pathMajor and mpathMajor are non-empty, then we only care that they
// have the same major-version validation rules. A clone fetched via a /v2
// path might replace a module with path gopkg.in/foo.v2-unstable, and that's
// ok.
return pathMajor[1:] == mpathMajor[1:]
}
// canReplaceMismatchedVersionDueToBug reports whether versions of r
// could replace versions of mpath with otherwise-mismatched major versions
// due to a historical bug in the Go command (golang.org/issue/34254).
func (r *codeRepo) canReplaceMismatchedVersionDueToBug(mpath string) bool {
// The bug caused us to erroneously accept unversioned paths as replacements
// for versioned gopkg.in paths.
unversioned := r.pathMajor == ""
replacingGopkgIn := strings.HasPrefix(mpath, "gopkg.in/")
return unversioned && replacingGopkgIn
}
func (r *codeRepo) GoMod(ctx context.Context, version string) (data []byte, err error) {
if version != module.CanonicalVersion(version) {
return nil, fmt.Errorf("version %s is not canonical", version)
}
if module.IsPseudoVersion(version) {
// findDir ignores the metadata encoded in a pseudo-version,
// only using the revision at the end.
// Invoke Stat to verify the metadata explicitly so we don't return
// a bogus file for an invalid version.
_, err := r.Stat(ctx, version)
if err != nil {
return nil, err
}
}
rev, dir, gomod, err := r.findDir(ctx, version)
if err != nil {
return nil, err
}
if gomod != nil {
return gomod, nil
}
data, err = r.code.ReadFile(ctx, rev, path.Join(dir, "go.mod"), codehost.MaxGoMod)
if err != nil {
if os.IsNotExist(err) {
return LegacyGoMod(r.modPath), nil
}
return nil, err
}
return data, nil
}
// LegacyGoMod generates a fake go.mod file for a module that doesn't have one.
// The go.mod file contains a module directive and nothing else: no go version,
// no requirements.
//
// We used to try to build a go.mod reflecting pre-existing
// package management metadata files, but the conversion
// was inherently imperfect (because those files don't have
// exactly the same semantics as go.mod) and, when done
// for dependencies in the middle of a build, impossible to
// correct. So we stopped.
func LegacyGoMod(modPath string) []byte {
return fmt.Appendf(nil, "module %s\n", modfile.AutoQuote(modPath))
}
func (r *codeRepo) modPrefix(rev string) string {
return r.modPath + "@" + rev
}
func (r *codeRepo) retractedVersions(ctx context.Context) (func(string) bool, error) {
vs, err := r.Versions(ctx, "")
if err != nil {
return nil, err
}
versions := vs.List
for i, v := range versions {
if strings.HasSuffix(v, "+incompatible") {
// We're looking for the latest release tag that may list retractions in a
// go.mod file. +incompatible versions necessarily do not, and they start
// at major version 2 β which is higher than any version that could
// validly contain a go.mod file.
versions = versions[:i]
break
}
}
if len(versions) == 0 {
return func(string) bool { return false }, nil
}
var highest string
for i := len(versions) - 1; i >= 0; i-- {
v := versions[i]
if semver.Prerelease(v) == "" {
highest = v
break
}
}
if highest == "" {
highest = versions[len(versions)-1]
}
data, err := r.GoMod(ctx, highest)
if err != nil {
return nil, err
}
f, err := modfile.ParseLax("go.mod", data, nil)
if err != nil {
return nil, err
}
retractions := make([]modfile.VersionInterval, 0, len(f.Retract))
for _, r := range f.Retract {
retractions = append(retractions, r.VersionInterval)
}
return func(v string) bool {
for _, r := range retractions {
if semver.Compare(r.Low, v) <= 0 && semver.Compare(v, r.High) <= 0 {
return true
}
}
return false
}, nil
}
func (r *codeRepo) Zip(ctx context.Context, dst io.Writer, version string) error {
if version != module.CanonicalVersion(version) {
return fmt.Errorf("version %s is not canonical", version)
}
if module.IsPseudoVersion(version) {
// findDir ignores the metadata encoded in a pseudo-version,
// only using the revision at the end.
// Invoke Stat to verify the metadata explicitly so we don't return
// a bogus file for an invalid version.
_, err := r.Stat(ctx, version)
if err != nil {
return err
}
}
rev, subdir, _, err := r.findDir(ctx, version)
if err != nil {
return err
}
if gomod, err := r.code.ReadFile(ctx, rev, filepath.Join(subdir, "go.mod"), codehost.MaxGoMod); err == nil {
goVers := gover.GoModLookup(gomod, "go")
if gover.Compare(goVers, gover.Local()) > 0 {
return &gover.TooNewError{What: r.ModulePath() + "@" + version, GoVersion: goVers}
}
} else if !errors.Is(err, fs.ErrNotExist) {
return err
}
dl, err := r.code.ReadZip(ctx, rev, subdir, codehost.MaxZipFile)
if err != nil {
return err
}
defer dl.Close()
subdir = strings.Trim(subdir, "/")
// Spool to local file.
f, err := os.CreateTemp("", "go-codehost-")
if err != nil {
dl.Close()
return err
}
defer os.Remove(f.Name())
defer f.Close()
maxSize := int64(codehost.MaxZipFile)
lr := &io.LimitedReader{R: dl, N: maxSize + 1}
if _, err := io.Copy(f, lr); err != nil {
dl.Close()
return err
}
dl.Close()
if lr.N <= 0 {
return fmt.Errorf("downloaded zip file too large")
}
size := (maxSize + 1) - lr.N
if _, err := f.Seek(0, 0); err != nil {
return err
}
// Translate from zip file we have to zip file we want.
zr, err := zip.NewReader(f, size)
if err != nil {
return err
}
var files []modzip.File
if subdir != "" {
subdir += "/"
}
haveLICENSE := false
topPrefix := ""
for _, zf := range zr.File {
if topPrefix == "" {
i := strings.Index(zf.Name, "/")
if i < 0 {
return fmt.Errorf("missing top-level directory prefix")
}
topPrefix = zf.Name[:i+1]
}
var name string
var found bool
if name, found = strings.CutPrefix(zf.Name, topPrefix); !found {
return fmt.Errorf("zip file contains more than one top-level directory")
}
if name, found = strings.CutPrefix(name, subdir); !found {
continue
}
if name == "" || strings.HasSuffix(name, "/") {
continue
}
files = append(files, zipFile{name: name, f: zf})
if name == "LICENSE" {
haveLICENSE = true
}
}
if !haveLICENSE && subdir != "" {
data, err := r.code.ReadFile(ctx, rev, "LICENSE", codehost.MaxLICENSE)
if err == nil {
files = append(files, dataFile{name: "LICENSE", data: data})
}
}
return modzip.Create(dst, module.Version{Path: r.modPath, Version: version}, files)
}
type zipFile struct {
name string
f *zip.File
}
func (f zipFile) Path() string { return f.name }
func (f zipFile) Lstat() (fs.FileInfo, error) { return f.f.FileInfo(), nil }
func (f zipFile) Open() (io.ReadCloser, error) { return f.f.Open() }
type dataFile struct {
name string
data []byte
}
func (f dataFile) Path() string { return f.name }
func (f dataFile) Lstat() (fs.FileInfo, error) { return dataFileInfo{f}, nil }
func (f dataFile) Open() (io.ReadCloser, error) {
return io.NopCloser(bytes.NewReader(f.data)), nil
}
type dataFileInfo struct {
f dataFile
}
func (fi dataFileInfo) Name() string { return path.Base(fi.f.name) }
func (fi dataFileInfo) Size() int64 { return int64(len(fi.f.data)) }
func (fi dataFileInfo) Mode() fs.FileMode { return 0644 }
func (fi dataFileInfo) ModTime() time.Time { return time.Time{} }
func (fi dataFileInfo) IsDir() bool { return false }
func (fi dataFileInfo) Sys() any { return nil }
func (fi dataFileInfo) String() string {
return fs.FormatFileInfo(fi)
}
// hasPathPrefix reports whether the path s begins with the
// elements in prefix.
func hasPathPrefix(s, prefix string) bool {
switch {
default:
return false
case len(s) == len(prefix):
return s == prefix
case len(s) > len(prefix):
if prefix != "" && prefix[len(prefix)-1] == '/' {
return strings.HasPrefix(s, prefix)
}
return s[len(prefix)] == '/' && s[:len(prefix)] == prefix
}
}
|
go/src/cmd/go/internal/modfetch/coderepo.go/0
|
{
"file_path": "go/src/cmd/go/internal/modfetch/coderepo.go",
"repo_id": "go",
"token_count": 14144
}
| 134 |
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package modindex
import (
"bytes"
"encoding/binary"
"errors"
"fmt"
"go/build"
"go/build/constraint"
"go/token"
"internal/godebug"
"internal/goroot"
"path"
"path/filepath"
"runtime"
"runtime/debug"
"sort"
"strings"
"sync"
"time"
"unsafe"
"cmd/go/internal/base"
"cmd/go/internal/cache"
"cmd/go/internal/cfg"
"cmd/go/internal/fsys"
"cmd/go/internal/imports"
"cmd/go/internal/par"
"cmd/go/internal/str"
)
// enabled is used to flag off the behavior of the module index on tip.
// It will be removed before the release.
// TODO(matloob): Remove enabled once we have more confidence on the
// module index.
var enabled = godebug.New("#goindex").Value() != "0"
// Module represents and encoded module index file. It is used to
// do the equivalent of build.Import of packages in the module and answer other
// questions based on the index file's data.
type Module struct {
modroot string
d *decoder
n int // number of packages
}
// moduleHash returns an ActionID corresponding to the state of the module
// located at filesystem path modroot.
func moduleHash(modroot string, ismodcache bool) (cache.ActionID, error) {
// We expect modules stored within the module cache to be checksummed and
// immutable, and we expect released modules within GOROOT to change only
// infrequently (when the Go version changes).
if !ismodcache {
// The contents of this module may change over time. We don't want to pay
// the cost to detect changes and re-index whenever they occur, so just
// don't index it at all.
//
// Note that this is true even for modules in GOROOT/src: non-release builds
// of the Go toolchain may have arbitrary development changes on top of the
// commit reported by runtime.Version, or could be completely artificial due
// to lacking a `git` binary (like "devel gomote.XXXXX", as synthesized by
// "gomote push" as of 2022-06-15). (Release builds shouldn't have
// modifications, but we don't want to use a behavior for releases that we
// haven't tested during development.)
return cache.ActionID{}, ErrNotIndexed
}
h := cache.NewHash("moduleIndex")
// TODO(bcmills): Since modules in the index are checksummed, we could
// probably improve the cache hit rate by keying off of the module
// path@version (perhaps including the checksum?) instead of the module root
// directory.
fmt.Fprintf(h, "module index %s %s %v\n", runtime.Version(), indexVersion, modroot)
return h.Sum(), nil
}
const modTimeCutoff = 2 * time.Second
// dirHash returns an ActionID corresponding to the state of the package
// located at filesystem path pkgdir.
func dirHash(modroot, pkgdir string) (cache.ActionID, error) {
h := cache.NewHash("moduleIndex")
fmt.Fprintf(h, "modroot %s\n", modroot)
fmt.Fprintf(h, "package %s %s %v\n", runtime.Version(), indexVersion, pkgdir)
entries, err := fsys.ReadDir(pkgdir)
if err != nil {
// pkgdir might not be a directory. give up on hashing.
return cache.ActionID{}, ErrNotIndexed
}
cutoff := time.Now().Add(-modTimeCutoff)
for _, info := range entries {
if info.IsDir() {
continue
}
if !info.Mode().IsRegular() {
return cache.ActionID{}, ErrNotIndexed
}
// To avoid problems for very recent files where a new
// write might not change the mtime due to file system
// mtime precision, reject caching if a file was read that
// is less than modTimeCutoff old.
//
// This is the same strategy used for hashing test inputs.
// See hashOpen in cmd/go/internal/test/test.go for the
// corresponding code.
if info.ModTime().After(cutoff) {
return cache.ActionID{}, ErrNotIndexed
}
fmt.Fprintf(h, "file %v %v %v\n", info.Name(), info.ModTime(), info.Size())
}
return h.Sum(), nil
}
var ErrNotIndexed = errors.New("not in module index")
var (
errDisabled = fmt.Errorf("%w: module indexing disabled", ErrNotIndexed)
errNotFromModuleCache = fmt.Errorf("%w: not from module cache", ErrNotIndexed)
)
// GetPackage returns the IndexPackage for the directory at the given path.
// It will return ErrNotIndexed if the directory should be read without
// using the index, for instance because the index is disabled, or the package
// is not in a module.
func GetPackage(modroot, pkgdir string) (*IndexPackage, error) {
mi, err := GetModule(modroot)
if err == nil {
return mi.Package(relPath(pkgdir, modroot)), nil
}
if !errors.Is(err, errNotFromModuleCache) {
return nil, err
}
if cfg.BuildContext.Compiler == "gccgo" && str.HasPathPrefix(modroot, cfg.GOROOTsrc) {
return nil, err // gccgo has no sources for GOROOT packages.
}
return openIndexPackage(modroot, pkgdir)
}
// GetModule returns the Module for the given modroot.
// It will return ErrNotIndexed if the directory should be read without
// using the index, for instance because the index is disabled, or the package
// is not in a module.
func GetModule(modroot string) (*Module, error) {
dir, _ := cache.DefaultDir()
if !enabled || dir == "off" {
return nil, errDisabled
}
if modroot == "" {
panic("modindex.GetPackage called with empty modroot")
}
if cfg.BuildMod == "vendor" {
// Even if the main module is in the module cache,
// its vendored dependencies are not loaded from their
// usual cached locations.
return nil, errNotFromModuleCache
}
modroot = filepath.Clean(modroot)
if str.HasFilePathPrefix(modroot, cfg.GOROOTsrc) || !str.HasFilePathPrefix(modroot, cfg.GOMODCACHE) {
return nil, errNotFromModuleCache
}
return openIndexModule(modroot, true)
}
var mcache par.ErrCache[string, *Module]
// openIndexModule returns the module index for modPath.
// It will return ErrNotIndexed if the module can not be read
// using the index because it contains symlinks.
func openIndexModule(modroot string, ismodcache bool) (*Module, error) {
return mcache.Do(modroot, func() (*Module, error) {
fsys.Trace("openIndexModule", modroot)
id, err := moduleHash(modroot, ismodcache)
if err != nil {
return nil, err
}
data, _, err := cache.GetMmap(cache.Default(), id)
if err != nil {
// Couldn't read from modindex. Assume we couldn't read from
// the index because the module hasn't been indexed yet.
data, err = indexModule(modroot)
if err != nil {
return nil, err
}
if err = cache.PutBytes(cache.Default(), id, data); err != nil {
return nil, err
}
}
mi, err := fromBytes(modroot, data)
if err != nil {
return nil, err
}
return mi, nil
})
}
var pcache par.ErrCache[[2]string, *IndexPackage]
func openIndexPackage(modroot, pkgdir string) (*IndexPackage, error) {
return pcache.Do([2]string{modroot, pkgdir}, func() (*IndexPackage, error) {
fsys.Trace("openIndexPackage", pkgdir)
id, err := dirHash(modroot, pkgdir)
if err != nil {
return nil, err
}
data, _, err := cache.GetMmap(cache.Default(), id)
if err != nil {
// Couldn't read from index. Assume we couldn't read from
// the index because the package hasn't been indexed yet.
data = indexPackage(modroot, pkgdir)
if err = cache.PutBytes(cache.Default(), id, data); err != nil {
return nil, err
}
}
pkg, err := packageFromBytes(modroot, data)
if err != nil {
return nil, err
}
return pkg, nil
})
}
var errCorrupt = errors.New("corrupt index")
// protect marks the start of a large section of code that accesses the index.
// It should be used as:
//
// defer unprotect(protect, &err)
//
// It should not be used for trivial accesses which would be
// dwarfed by the overhead of the defer.
func protect() bool {
return debug.SetPanicOnFault(true)
}
var isTest = false
// unprotect marks the end of a large section of code that accesses the index.
// It should be used as:
//
// defer unprotect(protect, &err)
//
// end looks for panics due to errCorrupt or bad mmap accesses.
// When it finds them, it adds explanatory text, consumes the panic, and sets *errp instead.
// If errp is nil, end adds the explanatory text but then calls base.Fatalf.
func unprotect(old bool, errp *error) {
// SetPanicOnFault's errors _may_ satisfy this interface. Even though it's not guaranteed
// that all its errors satisfy this interface, we'll only check for these errors so that
// we don't suppress panics that could have been produced from other sources.
type addrer interface {
Addr() uintptr
}
debug.SetPanicOnFault(old)
if e := recover(); e != nil {
if _, ok := e.(addrer); ok || e == errCorrupt {
// This panic was almost certainly caused by SetPanicOnFault or our panic(errCorrupt).
err := fmt.Errorf("error reading module index: %v", e)
if errp != nil {
*errp = err
return
}
if isTest {
panic(err)
}
base.Fatalf("%v", err)
}
// The panic was likely not caused by SetPanicOnFault.
panic(e)
}
}
// fromBytes returns a *Module given the encoded representation.
func fromBytes(moddir string, data []byte) (m *Module, err error) {
if !enabled {
panic("use of index")
}
defer unprotect(protect(), &err)
if !bytes.HasPrefix(data, []byte(indexVersion+"\n")) {
return nil, errCorrupt
}
const hdr = len(indexVersion + "\n")
d := &decoder{data: data}
str := d.intAt(hdr)
if str < hdr+8 || len(d.data) < str {
return nil, errCorrupt
}
d.data, d.str = data[:str], d.data[str:]
// Check that string table looks valid.
// First string is empty string (length 0),
// and we leave a marker byte 0xFF at the end
// just to make sure that the file is not truncated.
if len(d.str) == 0 || d.str[0] != 0 || d.str[len(d.str)-1] != 0xFF {
return nil, errCorrupt
}
n := d.intAt(hdr + 4)
if n < 0 || n > (len(d.data)-8)/8 {
return nil, errCorrupt
}
m = &Module{
moddir,
d,
n,
}
return m, nil
}
// packageFromBytes returns a *IndexPackage given the encoded representation.
func packageFromBytes(modroot string, data []byte) (p *IndexPackage, err error) {
m, err := fromBytes(modroot, data)
if err != nil {
return nil, err
}
if m.n != 1 {
return nil, fmt.Errorf("corrupt single-package index")
}
return m.pkg(0), nil
}
// pkgDir returns the dir string of the i'th package in the index.
func (m *Module) pkgDir(i int) string {
if i < 0 || i >= m.n {
panic(errCorrupt)
}
return m.d.stringAt(12 + 8 + 8*i)
}
// pkgOff returns the offset of the data for the i'th package in the index.
func (m *Module) pkgOff(i int) int {
if i < 0 || i >= m.n {
panic(errCorrupt)
}
return m.d.intAt(12 + 8 + 8*i + 4)
}
// Walk calls f for each package in the index, passing the path to that package relative to the module root.
func (m *Module) Walk(f func(path string)) {
defer unprotect(protect(), nil)
for i := 0; i < m.n; i++ {
f(m.pkgDir(i))
}
}
// relPath returns the path relative to the module's root.
func relPath(path, modroot string) string {
return str.TrimFilePathPrefix(filepath.Clean(path), filepath.Clean(modroot))
}
var installgorootAll = godebug.New("installgoroot").Value() == "all"
// Import is the equivalent of build.Import given the information in Module.
func (rp *IndexPackage) Import(bctxt build.Context, mode build.ImportMode) (p *build.Package, err error) {
defer unprotect(protect(), &err)
ctxt := (*Context)(&bctxt)
p = &build.Package{}
p.ImportPath = "."
p.Dir = filepath.Join(rp.modroot, rp.dir)
var pkgerr error
switch ctxt.Compiler {
case "gccgo", "gc":
default:
// Save error for end of function.
pkgerr = fmt.Errorf("import %q: unknown compiler %q", p.Dir, ctxt.Compiler)
}
if p.Dir == "" {
return p, fmt.Errorf("import %q: import of unknown directory", p.Dir)
}
// goroot and gopath
inTestdata := func(sub string) bool {
return strings.Contains(sub, "/testdata/") || strings.HasSuffix(sub, "/testdata") || str.HasPathPrefix(sub, "testdata")
}
var pkga string
if !inTestdata(rp.dir) {
// In build.go, p.Root should only be set in the non-local-import case, or in
// GOROOT or GOPATH. Since module mode only calls Import with path set to "."
// and the module index doesn't apply outside modules, the GOROOT case is
// the only case where p.Root needs to be set.
if ctxt.GOROOT != "" && str.HasFilePathPrefix(p.Dir, cfg.GOROOTsrc) && p.Dir != cfg.GOROOTsrc {
p.Root = ctxt.GOROOT
p.Goroot = true
modprefix := str.TrimFilePathPrefix(rp.modroot, cfg.GOROOTsrc)
p.ImportPath = rp.dir
if modprefix != "" {
p.ImportPath = filepath.Join(modprefix, p.ImportPath)
}
// Set GOROOT-specific fields (sometimes for modules in a GOPATH directory).
// The fields set below (SrcRoot, PkgRoot, BinDir, PkgTargetRoot, and PkgObj)
// are only set in build.Import if p.Root != "".
var pkgtargetroot string
suffix := ""
if ctxt.InstallSuffix != "" {
suffix = "_" + ctxt.InstallSuffix
}
switch ctxt.Compiler {
case "gccgo":
pkgtargetroot = "pkg/gccgo_" + ctxt.GOOS + "_" + ctxt.GOARCH + suffix
dir, elem := path.Split(p.ImportPath)
pkga = pkgtargetroot + "/" + dir + "lib" + elem + ".a"
case "gc":
pkgtargetroot = "pkg/" + ctxt.GOOS + "_" + ctxt.GOARCH + suffix
pkga = pkgtargetroot + "/" + p.ImportPath + ".a"
}
p.SrcRoot = ctxt.joinPath(p.Root, "src")
p.PkgRoot = ctxt.joinPath(p.Root, "pkg")
p.BinDir = ctxt.joinPath(p.Root, "bin")
if pkga != "" {
// Always set PkgTargetRoot. It might be used when building in shared
// mode.
p.PkgTargetRoot = ctxt.joinPath(p.Root, pkgtargetroot)
// Set the install target if applicable.
if !p.Goroot || (installgorootAll && p.ImportPath != "unsafe" && p.ImportPath != "builtin") {
p.PkgObj = ctxt.joinPath(p.Root, pkga)
}
}
}
}
if rp.error != nil {
if errors.Is(rp.error, errCannotFindPackage) && ctxt.Compiler == "gccgo" && p.Goroot {
return p, nil
}
return p, rp.error
}
if mode&build.FindOnly != 0 {
return p, pkgerr
}
// We need to do a second round of bad file processing.
var badGoError error
badGoFiles := make(map[string]bool)
badGoFile := func(name string, err error) {
if badGoError == nil {
badGoError = err
}
if !badGoFiles[name] {
p.InvalidGoFiles = append(p.InvalidGoFiles, name)
badGoFiles[name] = true
}
}
var Sfiles []string // files with ".S"(capital S)/.sx(capital s equivalent for case insensitive filesystems)
var firstFile string
embedPos := make(map[string][]token.Position)
testEmbedPos := make(map[string][]token.Position)
xTestEmbedPos := make(map[string][]token.Position)
importPos := make(map[string][]token.Position)
testImportPos := make(map[string][]token.Position)
xTestImportPos := make(map[string][]token.Position)
allTags := make(map[string]bool)
for _, tf := range rp.sourceFiles {
name := tf.name()
// Check errors for go files and call badGoFiles to put them in
// InvalidGoFiles if they do have an error.
if strings.HasSuffix(name, ".go") {
if error := tf.error(); error != "" {
badGoFile(name, errors.New(tf.error()))
continue
} else if parseError := tf.parseError(); parseError != "" {
badGoFile(name, parseErrorFromString(tf.parseError()))
// Fall through: we still want to list files with parse errors.
}
}
var shouldBuild = true
if !ctxt.goodOSArchFile(name, allTags) && !ctxt.UseAllFiles {
shouldBuild = false
} else if goBuildConstraint := tf.goBuildConstraint(); goBuildConstraint != "" {
x, err := constraint.Parse(goBuildConstraint)
if err != nil {
return p, fmt.Errorf("%s: parsing //go:build line: %v", name, err)
}
shouldBuild = ctxt.eval(x, allTags)
} else if plusBuildConstraints := tf.plusBuildConstraints(); len(plusBuildConstraints) > 0 {
for _, text := range plusBuildConstraints {
if x, err := constraint.Parse(text); err == nil {
if !ctxt.eval(x, allTags) {
shouldBuild = false
}
}
}
}
ext := nameExt(name)
if !shouldBuild || tf.ignoreFile() {
if ext == ".go" {
p.IgnoredGoFiles = append(p.IgnoredGoFiles, name)
} else if fileListForExt(p, ext) != nil {
p.IgnoredOtherFiles = append(p.IgnoredOtherFiles, name)
}
continue
}
// Going to save the file. For non-Go files, can stop here.
switch ext {
case ".go":
// keep going
case ".S", ".sx":
// special case for cgo, handled at end
Sfiles = append(Sfiles, name)
continue
default:
if list := fileListForExt(p, ext); list != nil {
*list = append(*list, name)
}
continue
}
pkg := tf.pkgName()
if pkg == "documentation" {
p.IgnoredGoFiles = append(p.IgnoredGoFiles, name)
continue
}
isTest := strings.HasSuffix(name, "_test.go")
isXTest := false
if isTest && strings.HasSuffix(tf.pkgName(), "_test") && p.Name != tf.pkgName() {
isXTest = true
pkg = pkg[:len(pkg)-len("_test")]
}
if !isTest && tf.binaryOnly() {
p.BinaryOnly = true
}
if p.Name == "" {
p.Name = pkg
firstFile = name
} else if pkg != p.Name {
// TODO(#45999): The choice of p.Name is arbitrary based on file iteration
// order. Instead of resolving p.Name arbitrarily, we should clear out the
// existing Name and mark the existing files as also invalid.
badGoFile(name, &MultiplePackageError{
Dir: p.Dir,
Packages: []string{p.Name, pkg},
Files: []string{firstFile, name},
})
}
// Grab the first package comment as docs, provided it is not from a test file.
if p.Doc == "" && !isTest && !isXTest {
if synopsis := tf.synopsis(); synopsis != "" {
p.Doc = synopsis
}
}
// Record Imports and information about cgo.
isCgo := false
imports := tf.imports()
for _, imp := range imports {
if imp.path == "C" {
if isTest {
badGoFile(name, fmt.Errorf("use of cgo in test %s not supported", name))
continue
}
isCgo = true
}
}
if directives := tf.cgoDirectives(); directives != "" {
if err := ctxt.saveCgo(name, p, directives); err != nil {
badGoFile(name, err)
}
}
var fileList *[]string
var importMap, embedMap map[string][]token.Position
var directives *[]build.Directive
switch {
case isCgo:
allTags["cgo"] = true
if ctxt.CgoEnabled {
fileList = &p.CgoFiles
importMap = importPos
embedMap = embedPos
directives = &p.Directives
} else {
// Ignore Imports and Embeds from cgo files if cgo is disabled.
fileList = &p.IgnoredGoFiles
}
case isXTest:
fileList = &p.XTestGoFiles
importMap = xTestImportPos
embedMap = xTestEmbedPos
directives = &p.XTestDirectives
case isTest:
fileList = &p.TestGoFiles
importMap = testImportPos
embedMap = testEmbedPos
directives = &p.TestDirectives
default:
fileList = &p.GoFiles
importMap = importPos
embedMap = embedPos
directives = &p.Directives
}
*fileList = append(*fileList, name)
if importMap != nil {
for _, imp := range imports {
importMap[imp.path] = append(importMap[imp.path], imp.position)
}
}
if embedMap != nil {
for _, e := range tf.embeds() {
embedMap[e.pattern] = append(embedMap[e.pattern], e.position)
}
}
if directives != nil {
*directives = append(*directives, tf.directives()...)
}
}
p.EmbedPatterns, p.EmbedPatternPos = cleanDecls(embedPos)
p.TestEmbedPatterns, p.TestEmbedPatternPos = cleanDecls(testEmbedPos)
p.XTestEmbedPatterns, p.XTestEmbedPatternPos = cleanDecls(xTestEmbedPos)
p.Imports, p.ImportPos = cleanDecls(importPos)
p.TestImports, p.TestImportPos = cleanDecls(testImportPos)
p.XTestImports, p.XTestImportPos = cleanDecls(xTestImportPos)
for tag := range allTags {
p.AllTags = append(p.AllTags, tag)
}
sort.Strings(p.AllTags)
if len(p.CgoFiles) > 0 {
p.SFiles = append(p.SFiles, Sfiles...)
sort.Strings(p.SFiles)
} else {
p.IgnoredOtherFiles = append(p.IgnoredOtherFiles, Sfiles...)
sort.Strings(p.IgnoredOtherFiles)
}
if badGoError != nil {
return p, badGoError
}
if len(p.GoFiles)+len(p.CgoFiles)+len(p.TestGoFiles)+len(p.XTestGoFiles) == 0 {
return p, &build.NoGoError{Dir: p.Dir}
}
return p, pkgerr
}
// IsStandardPackage reports whether path is a standard package
// for the goroot and compiler using the module index if possible,
// and otherwise falling back to internal/goroot.IsStandardPackage
func IsStandardPackage(goroot_, compiler, path string) bool {
if !enabled || compiler != "gc" {
return goroot.IsStandardPackage(goroot_, compiler, path)
}
reldir := filepath.FromSlash(path) // relative dir path in module index for package
modroot := filepath.Join(goroot_, "src")
if str.HasFilePathPrefix(reldir, "cmd") {
reldir = str.TrimFilePathPrefix(reldir, "cmd")
modroot = filepath.Join(modroot, "cmd")
}
if pkg, err := GetPackage(modroot, filepath.Join(modroot, reldir)); err == nil {
hasGo, err := pkg.IsDirWithGoFiles()
return err == nil && hasGo
} else if errors.Is(err, ErrNotIndexed) {
// Fall back because package isn't indexable. (Probably because
// a file was modified recently)
return goroot.IsStandardPackage(goroot_, compiler, path)
}
return false
}
// IsDirWithGoFiles is the equivalent of fsys.IsDirWithGoFiles using the information in the index.
func (rp *IndexPackage) IsDirWithGoFiles() (_ bool, err error) {
defer func() {
if e := recover(); e != nil {
err = fmt.Errorf("error reading module index: %v", e)
}
}()
for _, sf := range rp.sourceFiles {
if strings.HasSuffix(sf.name(), ".go") {
return true, nil
}
}
return false, nil
}
// ScanDir implements imports.ScanDir using the information in the index.
func (rp *IndexPackage) ScanDir(tags map[string]bool) (sortedImports []string, sortedTestImports []string, err error) {
// TODO(matloob) dir should eventually be relative to indexed directory
// TODO(matloob): skip reading raw package and jump straight to data we need?
defer func() {
if e := recover(); e != nil {
err = fmt.Errorf("error reading module index: %v", e)
}
}()
imports_ := make(map[string]bool)
testImports := make(map[string]bool)
numFiles := 0
Files:
for _, sf := range rp.sourceFiles {
name := sf.name()
if strings.HasPrefix(name, "_") || strings.HasPrefix(name, ".") || !strings.HasSuffix(name, ".go") || !imports.MatchFile(name, tags) {
continue
}
// The following section exists for backwards compatibility reasons:
// scanDir ignores files with import "C" when collecting the list
// of imports unless the "cgo" tag is provided. The following comment
// is copied from the original.
//
// import "C" is implicit requirement of cgo tag.
// When listing files on the command line (explicitFiles=true)
// we do not apply build tag filtering but we still do apply
// cgo filtering, so no explicitFiles check here.
// Why? Because we always have, and it's not worth breaking
// that behavior now.
imps := sf.imports() // TODO(matloob): directly read import paths to avoid the extra strings?
for _, imp := range imps {
if imp.path == "C" && !tags["cgo"] && !tags["*"] {
continue Files
}
}
if !shouldBuild(sf, tags) {
continue
}
numFiles++
m := imports_
if strings.HasSuffix(name, "_test.go") {
m = testImports
}
for _, p := range imps {
m[p.path] = true
}
}
if numFiles == 0 {
return nil, nil, imports.ErrNoGo
}
return keys(imports_), keys(testImports), nil
}
func keys(m map[string]bool) []string {
list := make([]string, 0, len(m))
for k := range m {
list = append(list, k)
}
sort.Strings(list)
return list
}
// implements imports.ShouldBuild in terms of an index sourcefile.
func shouldBuild(sf *sourceFile, tags map[string]bool) bool {
if goBuildConstraint := sf.goBuildConstraint(); goBuildConstraint != "" {
x, err := constraint.Parse(goBuildConstraint)
if err != nil {
return false
}
return imports.Eval(x, tags, true)
}
plusBuildConstraints := sf.plusBuildConstraints()
for _, text := range plusBuildConstraints {
if x, err := constraint.Parse(text); err == nil {
if !imports.Eval(x, tags, true) {
return false
}
}
}
return true
}
// IndexPackage holds the information in the index
// needed to load a package in a specific directory.
type IndexPackage struct {
error error
dir string // directory of the package relative to the modroot
modroot string
// Source files
sourceFiles []*sourceFile
}
var errCannotFindPackage = errors.New("cannot find package")
// Package and returns finds the package with the given path (relative to the module root).
// If the package does not exist, Package returns an IndexPackage that will return an
// appropriate error from its methods.
func (m *Module) Package(path string) *IndexPackage {
defer unprotect(protect(), nil)
i, ok := sort.Find(m.n, func(i int) int {
return strings.Compare(path, m.pkgDir(i))
})
if !ok {
return &IndexPackage{error: fmt.Errorf("%w %q in:\n\t%s", errCannotFindPackage, path, filepath.Join(m.modroot, path))}
}
return m.pkg(i)
}
// pkg returns the i'th IndexPackage in m.
func (m *Module) pkg(i int) *IndexPackage {
r := m.d.readAt(m.pkgOff(i))
p := new(IndexPackage)
if errstr := r.string(); errstr != "" {
p.error = errors.New(errstr)
}
p.dir = r.string()
p.sourceFiles = make([]*sourceFile, r.int())
for i := range p.sourceFiles {
p.sourceFiles[i] = &sourceFile{
d: m.d,
pos: r.int(),
}
}
p.modroot = m.modroot
return p
}
// sourceFile represents the information of a given source file in the module index.
type sourceFile struct {
d *decoder // encoding of this source file
pos int // start of sourceFile encoding in d
onceReadImports sync.Once
savedImports []rawImport // saved imports so that they're only read once
}
// Offsets for fields in the sourceFile.
const (
sourceFileError = 4 * iota
sourceFileParseError
sourceFileSynopsis
sourceFileName
sourceFilePkgName
sourceFileIgnoreFile
sourceFileBinaryOnly
sourceFileCgoDirectives
sourceFileGoBuildConstraint
sourceFileNumPlusBuildConstraints
)
func (sf *sourceFile) error() string {
return sf.d.stringAt(sf.pos + sourceFileError)
}
func (sf *sourceFile) parseError() string {
return sf.d.stringAt(sf.pos + sourceFileParseError)
}
func (sf *sourceFile) synopsis() string {
return sf.d.stringAt(sf.pos + sourceFileSynopsis)
}
func (sf *sourceFile) name() string {
return sf.d.stringAt(sf.pos + sourceFileName)
}
func (sf *sourceFile) pkgName() string {
return sf.d.stringAt(sf.pos + sourceFilePkgName)
}
func (sf *sourceFile) ignoreFile() bool {
return sf.d.boolAt(sf.pos + sourceFileIgnoreFile)
}
func (sf *sourceFile) binaryOnly() bool {
return sf.d.boolAt(sf.pos + sourceFileBinaryOnly)
}
func (sf *sourceFile) cgoDirectives() string {
return sf.d.stringAt(sf.pos + sourceFileCgoDirectives)
}
func (sf *sourceFile) goBuildConstraint() string {
return sf.d.stringAt(sf.pos + sourceFileGoBuildConstraint)
}
func (sf *sourceFile) plusBuildConstraints() []string {
pos := sf.pos + sourceFileNumPlusBuildConstraints
n := sf.d.intAt(pos)
pos += 4
ret := make([]string, n)
for i := 0; i < n; i++ {
ret[i] = sf.d.stringAt(pos)
pos += 4
}
return ret
}
func (sf *sourceFile) importsOffset() int {
pos := sf.pos + sourceFileNumPlusBuildConstraints
n := sf.d.intAt(pos)
// each build constraint is 1 uint32
return pos + 4 + n*4
}
func (sf *sourceFile) embedsOffset() int {
pos := sf.importsOffset()
n := sf.d.intAt(pos)
// each import is 5 uint32s (string + tokpos)
return pos + 4 + n*(4*5)
}
func (sf *sourceFile) directivesOffset() int {
pos := sf.embedsOffset()
n := sf.d.intAt(pos)
// each embed is 5 uint32s (string + tokpos)
return pos + 4 + n*(4*5)
}
func (sf *sourceFile) imports() []rawImport {
sf.onceReadImports.Do(func() {
importsOffset := sf.importsOffset()
r := sf.d.readAt(importsOffset)
numImports := r.int()
ret := make([]rawImport, numImports)
for i := 0; i < numImports; i++ {
ret[i] = rawImport{r.string(), r.tokpos()}
}
sf.savedImports = ret
})
return sf.savedImports
}
func (sf *sourceFile) embeds() []embed {
embedsOffset := sf.embedsOffset()
r := sf.d.readAt(embedsOffset)
numEmbeds := r.int()
ret := make([]embed, numEmbeds)
for i := range ret {
ret[i] = embed{r.string(), r.tokpos()}
}
return ret
}
func (sf *sourceFile) directives() []build.Directive {
directivesOffset := sf.directivesOffset()
r := sf.d.readAt(directivesOffset)
numDirectives := r.int()
ret := make([]build.Directive, numDirectives)
for i := range ret {
ret[i] = build.Directive{Text: r.string(), Pos: r.tokpos()}
}
return ret
}
func asString(b []byte) string {
return unsafe.String(unsafe.SliceData(b), len(b))
}
// A decoder helps decode the index format.
type decoder struct {
data []byte // data after header
str []byte // string table
}
// intAt returns the int at the given offset in d.data.
func (d *decoder) intAt(off int) int {
if off < 0 || len(d.data)-off < 4 {
panic(errCorrupt)
}
i := binary.LittleEndian.Uint32(d.data[off : off+4])
if int32(i)>>31 != 0 {
panic(errCorrupt)
}
return int(i)
}
// boolAt returns the bool at the given offset in d.data.
func (d *decoder) boolAt(off int) bool {
return d.intAt(off) != 0
}
// stringAt returns the string pointed at by the int at the given offset in d.data.
func (d *decoder) stringAt(off int) string {
return d.stringTableAt(d.intAt(off))
}
// stringTableAt returns the string at the given offset in the string table d.str.
func (d *decoder) stringTableAt(off int) string {
if off < 0 || off >= len(d.str) {
panic(errCorrupt)
}
s := d.str[off:]
v, n := binary.Uvarint(s)
if n <= 0 || v > uint64(len(s[n:])) {
panic(errCorrupt)
}
return asString(s[n : n+int(v)])
}
// A reader reads sequential fields from a section of the index format.
type reader struct {
d *decoder
pos int
}
// readAt returns a reader starting at the given position in d.
func (d *decoder) readAt(pos int) *reader {
return &reader{d, pos}
}
// int reads the next int.
func (r *reader) int() int {
i := r.d.intAt(r.pos)
r.pos += 4
return i
}
// string reads the next string.
func (r *reader) string() string {
return r.d.stringTableAt(r.int())
}
// bool reads the next bool.
func (r *reader) bool() bool {
return r.int() != 0
}
// tokpos reads the next token.Position.
func (r *reader) tokpos() token.Position {
return token.Position{
Filename: r.string(),
Offset: r.int(),
Line: r.int(),
Column: r.int(),
}
}
|
go/src/cmd/go/internal/modindex/read.go/0
|
{
"file_path": "go/src/cmd/go/internal/modindex/read.go",
"repo_id": "go",
"token_count": 11293
}
| 135 |
// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package modload
import (
"context"
"internal/testenv"
"regexp"
"strings"
"testing"
"golang.org/x/mod/module"
)
var importTests = []struct {
path string
m module.Version
err string
}{
{
path: "golang.org/x/net/context",
m: module.Version{
Path: "golang.org/x/net",
},
},
{
path: "golang.org/x/net",
err: `module golang.org/x/net@.* found \(v[01]\.\d+\.\d+\), but does not contain package golang.org/x/net`,
},
{
path: "golang.org/x/text",
m: module.Version{
Path: "golang.org/x/text",
},
},
{
path: "github.com/rsc/quote/buggy",
m: module.Version{
Path: "github.com/rsc/quote",
Version: "v1.5.2",
},
},
{
path: "github.com/rsc/quote",
m: module.Version{
Path: "github.com/rsc/quote",
Version: "v1.5.2",
},
},
{
path: "golang.org/x/foo/bar",
err: "cannot find module providing package golang.org/x/foo/bar",
},
}
func TestQueryImport(t *testing.T) {
testenv.MustHaveExternalNetwork(t)
testenv.MustHaveExecPath(t, "git")
oldAllowMissingModuleImports := allowMissingModuleImports
oldRootMode := RootMode
defer func() {
allowMissingModuleImports = oldAllowMissingModuleImports
RootMode = oldRootMode
}()
allowMissingModuleImports = true
RootMode = NoRoot
ctx := context.Background()
rs := LoadModFile(ctx)
for _, tt := range importTests {
t.Run(strings.ReplaceAll(tt.path, "/", "_"), func(t *testing.T) {
// Note that there is no build list, so Import should always fail.
m, err := queryImport(ctx, tt.path, rs)
if tt.err == "" {
if err != nil {
t.Fatalf("queryImport(_, %q): %v", tt.path, err)
}
} else {
if err == nil {
t.Fatalf("queryImport(_, %q) = %v, nil; expected error", tt.path, m)
}
if !regexp.MustCompile(tt.err).MatchString(err.Error()) {
t.Fatalf("queryImport(_, %q): error %q, want error matching %#q", tt.path, err, tt.err)
}
}
if m.Path != tt.m.Path || (tt.m.Version != "" && m.Version != tt.m.Version) {
t.Errorf("queryImport(_, %q) = %v, _; want %v", tt.path, m, tt.m)
}
})
}
}
|
go/src/cmd/go/internal/modload/import_test.go/0
|
{
"file_path": "go/src/cmd/go/internal/modload/import_test.go",
"repo_id": "go",
"token_count": 985
}
| 136 |
// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package mvs implements Minimal Version Selection.
// See https://research.swtch.com/vgo-mvs.
package mvs
import (
"fmt"
"slices"
"sort"
"sync"
"cmd/go/internal/par"
"golang.org/x/mod/module"
)
// A Reqs is the requirement graph on which Minimal Version Selection (MVS) operates.
//
// The version strings are opaque except for the special version "none"
// (see the documentation for module.Version). In particular, MVS does not
// assume that the version strings are semantic versions; instead, the Max method
// gives access to the comparison operation.
//
// It must be safe to call methods on a Reqs from multiple goroutines simultaneously.
// Because a Reqs may read the underlying graph from the network on demand,
// the MVS algorithms parallelize the traversal to overlap network delays.
type Reqs interface {
// Required returns the module versions explicitly required by m itself.
// The caller must not modify the returned list.
Required(m module.Version) ([]module.Version, error)
// Max returns the maximum of v1 and v2 (it returns either v1 or v2)
// in the module with path p.
//
// For all versions v, Max(v, "none") must be v,
// and for the target passed as the first argument to MVS functions,
// Max(target, v) must be target.
//
// Note that v1 < v2 can be written Max(v1, v2) != v1
// and similarly v1 <= v2 can be written Max(v1, v2) == v2.
Max(p, v1, v2 string) string
}
// An UpgradeReqs is a Reqs that can also identify available upgrades.
type UpgradeReqs interface {
Reqs
// Upgrade returns the upgraded version of m,
// for use during an UpgradeAll operation.
// If m should be kept as is, Upgrade returns m.
// If m is not yet used in the build, then m.Version will be "none".
// More typically, m.Version will be the version required
// by some other module in the build.
//
// If no module version is available for the given path,
// Upgrade returns a non-nil error.
// TODO(rsc): Upgrade must be able to return errors,
// but should "no latest version" just return m instead?
Upgrade(m module.Version) (module.Version, error)
}
// A DowngradeReqs is a Reqs that can also identify available downgrades.
type DowngradeReqs interface {
Reqs
// Previous returns the version of m.Path immediately prior to m.Version,
// or "none" if no such version is known.
Previous(m module.Version) (module.Version, error)
}
// BuildList returns the build list for the target module.
//
// target is the root vertex of a module requirement graph. For cmd/go, this is
// typically the main module, but note that this algorithm is not intended to
// be Go-specific: module paths and versions are treated as opaque values.
//
// reqs describes the module requirement graph and provides an opaque method
// for comparing versions.
//
// BuildList traverses the graph and returns a list containing the highest
// version for each visited module. The first element of the returned list is
// target itself; reqs.Max requires target.Version to compare higher than all
// other versions, so no other version can be selected. The remaining elements
// of the list are sorted by path.
//
// See https://research.swtch.com/vgo-mvs for details.
func BuildList(targets []module.Version, reqs Reqs) ([]module.Version, error) {
return buildList(targets, reqs, nil)
}
func buildList(targets []module.Version, reqs Reqs, upgrade func(module.Version) (module.Version, error)) ([]module.Version, error) {
cmp := func(p, v1, v2 string) int {
if reqs.Max(p, v1, v2) != v1 {
return -1
}
if reqs.Max(p, v2, v1) != v2 {
return 1
}
return 0
}
var (
mu sync.Mutex
g = NewGraph(cmp, targets)
upgrades = map[module.Version]module.Version{}
errs = map[module.Version]error{} // (non-nil errors only)
)
// Explore work graph in parallel in case reqs.Required
// does high-latency network operations.
var work par.Work[module.Version]
for _, target := range targets {
work.Add(target)
}
work.Do(10, func(m module.Version) {
var required []module.Version
var err error
if m.Version != "none" {
required, err = reqs.Required(m)
}
u := m
if upgrade != nil {
upgradeTo, upErr := upgrade(m)
if upErr == nil {
u = upgradeTo
} else if err == nil {
err = upErr
}
}
mu.Lock()
if err != nil {
errs[m] = err
}
if u != m {
upgrades[m] = u
required = append([]module.Version{u}, required...)
}
g.Require(m, required)
mu.Unlock()
for _, r := range required {
work.Add(r)
}
})
// If there was an error, find the shortest path from the target to the
// node where the error occurred so we can report a useful error message.
if len(errs) > 0 {
errPath := g.FindPath(func(m module.Version) bool {
return errs[m] != nil
})
if len(errPath) == 0 {
panic("internal error: could not reconstruct path to module with error")
}
err := errs[errPath[len(errPath)-1]]
isUpgrade := func(from, to module.Version) bool {
if u, ok := upgrades[from]; ok {
return u == to
}
return false
}
return nil, NewBuildListError(err, errPath, isUpgrade)
}
// The final list is the minimum version of each module found in the graph.
list := g.BuildList()
if vs := list[:len(targets)]; !slices.Equal(vs, targets) {
// target.Version will be "" for modload, the main client of MVS.
// "" denotes the main module, which has no version. However, MVS treats
// version strings as opaque, so "" is not a special value here.
// See golang.org/issue/31491, golang.org/issue/29773.
panic(fmt.Sprintf("mistake: chose versions %+v instead of targets %+v", vs, targets))
}
return list, nil
}
// Req returns the minimal requirement list for the target module,
// with the constraint that all module paths listed in base must
// appear in the returned list.
func Req(mainModule module.Version, base []string, reqs Reqs) ([]module.Version, error) {
list, err := BuildList([]module.Version{mainModule}, reqs)
if err != nil {
return nil, err
}
// Note: Not running in parallel because we assume
// that list came from a previous operation that paged
// in all the requirements, so there's no I/O to overlap now.
max := map[string]string{}
for _, m := range list {
max[m.Path] = m.Version
}
// Compute postorder, cache requirements.
var postorder []module.Version
reqCache := map[module.Version][]module.Version{}
reqCache[mainModule] = nil
var walk func(module.Version) error
walk = func(m module.Version) error {
_, ok := reqCache[m]
if ok {
return nil
}
required, err := reqs.Required(m)
if err != nil {
return err
}
reqCache[m] = required
for _, m1 := range required {
if err := walk(m1); err != nil {
return err
}
}
postorder = append(postorder, m)
return nil
}
for _, m := range list {
if err := walk(m); err != nil {
return nil, err
}
}
// Walk modules in reverse post-order, only adding those not implied already.
have := map[module.Version]bool{}
walk = func(m module.Version) error {
if have[m] {
return nil
}
have[m] = true
for _, m1 := range reqCache[m] {
walk(m1)
}
return nil
}
// First walk the base modules that must be listed.
var min []module.Version
haveBase := map[string]bool{}
for _, path := range base {
if haveBase[path] {
continue
}
m := module.Version{Path: path, Version: max[path]}
min = append(min, m)
walk(m)
haveBase[path] = true
}
// Now the reverse postorder to bring in anything else.
for i := len(postorder) - 1; i >= 0; i-- {
m := postorder[i]
if max[m.Path] != m.Version {
// Older version.
continue
}
if !have[m] {
min = append(min, m)
walk(m)
}
}
sort.Slice(min, func(i, j int) bool {
return min[i].Path < min[j].Path
})
return min, nil
}
// UpgradeAll returns a build list for the target module
// in which every module is upgraded to its latest version.
func UpgradeAll(target module.Version, reqs UpgradeReqs) ([]module.Version, error) {
return buildList([]module.Version{target}, reqs, func(m module.Version) (module.Version, error) {
if m.Path == target.Path {
return target, nil
}
return reqs.Upgrade(m)
})
}
// Upgrade returns a build list for the target module
// in which the given additional modules are upgraded.
func Upgrade(target module.Version, reqs UpgradeReqs, upgrade ...module.Version) ([]module.Version, error) {
list, err := reqs.Required(target)
if err != nil {
return nil, err
}
pathInList := make(map[string]bool, len(list))
for _, m := range list {
pathInList[m.Path] = true
}
list = append([]module.Version(nil), list...)
upgradeTo := make(map[string]string, len(upgrade))
for _, u := range upgrade {
if !pathInList[u.Path] {
list = append(list, module.Version{Path: u.Path, Version: "none"})
}
if prev, dup := upgradeTo[u.Path]; dup {
upgradeTo[u.Path] = reqs.Max(u.Path, prev, u.Version)
} else {
upgradeTo[u.Path] = u.Version
}
}
return buildList([]module.Version{target}, &override{target, list, reqs}, func(m module.Version) (module.Version, error) {
if v, ok := upgradeTo[m.Path]; ok {
return module.Version{Path: m.Path, Version: v}, nil
}
return m, nil
})
}
// Downgrade returns a build list for the target module
// in which the given additional modules are downgraded,
// potentially overriding the requirements of the target.
//
// The versions to be downgraded may be unreachable from reqs.Latest and
// reqs.Previous, but the methods of reqs must otherwise handle such versions
// correctly.
func Downgrade(target module.Version, reqs DowngradeReqs, downgrade ...module.Version) ([]module.Version, error) {
// Per https://research.swtch.com/vgo-mvs#algorithm_4:
// βTo avoid an unnecessary downgrade to E 1.1, we must also add a new
// requirement on E 1.2. We can apply Algorithm R to find the minimal set of
// new requirements to write to go.mod.β
//
// In order to generate those new requirements, we need to identify versions
// for every module in the build list β not just reqs.Required(target).
list, err := BuildList([]module.Version{target}, reqs)
if err != nil {
return nil, err
}
list = list[1:] // remove target
max := make(map[string]string)
for _, r := range list {
max[r.Path] = r.Version
}
for _, d := range downgrade {
if v, ok := max[d.Path]; !ok || reqs.Max(d.Path, v, d.Version) != d.Version {
max[d.Path] = d.Version
}
}
var (
added = make(map[module.Version]bool)
rdeps = make(map[module.Version][]module.Version)
excluded = make(map[module.Version]bool)
)
var exclude func(module.Version)
exclude = func(m module.Version) {
if excluded[m] {
return
}
excluded[m] = true
for _, p := range rdeps[m] {
exclude(p)
}
}
var add func(module.Version)
add = func(m module.Version) {
if added[m] {
return
}
added[m] = true
if v, ok := max[m.Path]; ok && reqs.Max(m.Path, m.Version, v) != v {
// m would upgrade an existing dependency β it is not a strict downgrade,
// and because it was already present as a dependency, it could affect the
// behavior of other relevant packages.
exclude(m)
return
}
list, err := reqs.Required(m)
if err != nil {
// If we can't load the requirements, we couldn't load the go.mod file.
// There are a number of reasons this can happen, but this usually
// means an older version of the module had a missing or invalid
// go.mod file. For example, if example.com/mod released v2.0.0 before
// migrating to modules (v2.0.0+incompatible), then added a valid go.mod
// in v2.0.1, downgrading from v2.0.1 would cause this error.
//
// TODO(golang.org/issue/31730, golang.org/issue/30134): if the error
// is transient (we couldn't download go.mod), return the error from
// Downgrade. Currently, we can't tell what kind of error it is.
exclude(m)
return
}
for _, r := range list {
add(r)
if excluded[r] {
exclude(m)
return
}
rdeps[r] = append(rdeps[r], m)
}
}
downgraded := make([]module.Version, 0, len(list)+1)
downgraded = append(downgraded, target)
List:
for _, r := range list {
add(r)
for excluded[r] {
p, err := reqs.Previous(r)
if err != nil {
// This is likely a transient error reaching the repository,
// rather than a permanent error with the retrieved version.
//
// TODO(golang.org/issue/31730, golang.org/issue/30134):
// decode what to do based on the actual error.
return nil, err
}
// If the target version is a pseudo-version, it may not be
// included when iterating over prior versions using reqs.Previous.
// Insert it into the right place in the iteration.
// If v is excluded, p should be returned again by reqs.Previous on the next iteration.
if v := max[r.Path]; reqs.Max(r.Path, v, r.Version) != v && reqs.Max(r.Path, p.Version, v) != p.Version {
p.Version = v
}
if p.Version == "none" {
continue List
}
add(p)
r = p
}
downgraded = append(downgraded, r)
}
// The downgrades we computed above only downgrade to versions enumerated by
// reqs.Previous. However, reqs.Previous omits some versions β such as
// pseudo-versions and retracted versions β that may be selected as transitive
// requirements of other modules.
//
// If one of those requirements pulls the version back up above the version
// identified by reqs.Previous, then the transitive dependencies of that that
// initially-downgraded version should no longer matter β in particular, we
// should not add new dependencies on module paths that nothing else in the
// updated module graph even requires.
//
// In order to eliminate those spurious dependencies, we recompute the build
// list with the actual versions of the downgraded modules as selected by MVS,
// instead of our initial downgrades.
// (See the downhiddenartifact and downhiddencross test cases).
actual, err := BuildList([]module.Version{target}, &override{
target: target,
list: downgraded,
Reqs: reqs,
})
if err != nil {
return nil, err
}
actualVersion := make(map[string]string, len(actual))
for _, m := range actual {
actualVersion[m.Path] = m.Version
}
downgraded = downgraded[:0]
for _, m := range list {
if v, ok := actualVersion[m.Path]; ok {
downgraded = append(downgraded, module.Version{Path: m.Path, Version: v})
}
}
return BuildList([]module.Version{target}, &override{
target: target,
list: downgraded,
Reqs: reqs,
})
}
type override struct {
target module.Version
list []module.Version
Reqs
}
func (r *override) Required(m module.Version) ([]module.Version, error) {
if m == r.target {
return r.list, nil
}
return r.Reqs.Required(m)
}
|
go/src/cmd/go/internal/mvs/mvs.go/0
|
{
"file_path": "go/src/cmd/go/internal/mvs/mvs.go",
"repo_id": "go",
"token_count": 5132
}
| 137 |
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package script implements a small, customizable, platform-agnostic scripting
// language.
//
// Scripts are run by an [Engine] configured with a set of available commands
// and conditions that guard those commands. Each script has an associated
// working directory and environment, along with a buffer containing the stdout
// and stderr output of a prior command, tracked in a [State] that commands can
// inspect and modify.
//
// The default commands configured by [NewEngine] resemble a simplified Unix
// shell.
//
// # Script Language
//
// Each line of a script is parsed into a sequence of space-separated command
// words, with environment variable expansion within each word and # marking an
// end-of-line comment. Additional variables named ':' and '/' are expanded
// within script arguments (expanding to the value of os.PathListSeparator and
// os.PathSeparator respectively) but are not inherited in subprocess
// environments.
//
// Adding single quotes around text keeps spaces in that text from being treated
// as word separators and also disables environment variable expansion.
// Inside a single-quoted block of text, a repeated single quote indicates
// a literal single quote, as in:
//
// 'Don''t communicate by sharing memory.'
//
// A line beginning with # is a comment and conventionally explains what is
// being done or tested at the start of a new section of the script.
//
// Commands are executed one at a time, and errors are checked for each command;
// if any command fails unexpectedly, no subsequent commands in the script are
// executed. The command prefix ! indicates that the command on the rest of the
// line (typically go or a matching predicate) must fail instead of succeeding.
// The command prefix ? indicates that the command may or may not succeed, but
// the script should continue regardless.
//
// The command prefix [cond] indicates that the command on the rest of the line
// should only run when the condition is satisfied.
//
// A condition can be negated: [!root] means to run the rest of the line only if
// the user is not root. Multiple conditions may be given for a single command,
// for example, '[linux] [amd64] skip'. The command will run if all conditions
// are satisfied.
package script
import (
"bufio"
"context"
"errors"
"fmt"
"io"
"sort"
"strings"
"time"
)
// An Engine stores the configuration for executing a set of scripts.
//
// The same Engine may execute multiple scripts concurrently.
type Engine struct {
Cmds map[string]Cmd
Conds map[string]Cond
// If Quiet is true, Execute deletes log prints from the previous
// section when starting a new section.
Quiet bool
}
// NewEngine returns an Engine configured with a basic set of commands and conditions.
func NewEngine() *Engine {
return &Engine{
Cmds: DefaultCmds(),
Conds: DefaultConds(),
}
}
// A Cmd is a command that is available to a script.
type Cmd interface {
// Run begins running the command.
//
// If the command produces output or can be run in the background, run returns
// a WaitFunc that will be called to obtain the result of the command and
// update the engine's stdout and stderr buffers.
//
// Run itself and the returned WaitFunc may inspect and/or modify the State,
// but the State's methods must not be called concurrently after Run has
// returned.
//
// Run may retain and access the args slice until the WaitFunc has returned.
Run(s *State, args ...string) (WaitFunc, error)
// Usage returns the usage for the command, which the caller must not modify.
Usage() *CmdUsage
}
// A WaitFunc is a function called to retrieve the results of a Cmd.
type WaitFunc func(*State) (stdout, stderr string, err error)
// A CmdUsage describes the usage of a Cmd, independent of its name
// (which can change based on its registration).
type CmdUsage struct {
Summary string // in the style of the Name section of a Unix 'man' page, omitting the name
Args string // a brief synopsis of the command's arguments (only)
Detail []string // zero or more sentences in the style of the Description section of a Unix 'man' page
// If Async is true, the Cmd is meaningful to run in the background, and its
// Run method must return either a non-nil WaitFunc or a non-nil error.
Async bool
// RegexpArgs reports which arguments, if any, should be treated as regular
// expressions. It takes as input the raw, unexpanded arguments and returns
// the list of argument indices that will be interpreted as regular
// expressions.
//
// If RegexpArgs is nil, all arguments are assumed not to be regular
// expressions.
RegexpArgs func(rawArgs ...string) []int
}
// A Cond is a condition deciding whether a command should be run.
type Cond interface {
// Eval reports whether the condition applies to the given State.
//
// If the condition's usage reports that it is a prefix,
// the condition must be used with a suffix.
// Otherwise, the passed-in suffix argument is always the empty string.
Eval(s *State, suffix string) (bool, error)
// Usage returns the usage for the condition, which the caller must not modify.
Usage() *CondUsage
}
// A CondUsage describes the usage of a Cond, independent of its name
// (which can change based on its registration).
type CondUsage struct {
Summary string // a single-line summary of when the condition is true
// If Prefix is true, the condition is a prefix and requires a
// colon-separated suffix (like "[GOOS:linux]" for the "GOOS" condition).
// The suffix may be the empty string (like "[prefix:]").
Prefix bool
}
// Execute reads and executes script, writing the output to log.
//
// Execute stops and returns an error at the first command that does not succeed.
// The returned error's text begins with "file:line: ".
//
// If the script runs to completion or ends by a 'stop' command,
// Execute returns nil.
//
// Execute does not stop background commands started by the script
// before returning. To stop those, use [State.CloseAndWait] or the
// [Wait] command.
func (e *Engine) Execute(s *State, file string, script *bufio.Reader, log io.Writer) (err error) {
defer func(prev *Engine) { s.engine = prev }(s.engine)
s.engine = e
var sectionStart time.Time
// endSection flushes the logs for the current section from s.log to log.
// ok indicates whether all commands in the section succeeded.
endSection := func(ok bool) error {
var err error
if sectionStart.IsZero() {
// We didn't write a section header or record a timestamp, so just dump the
// whole log without those.
if s.log.Len() > 0 {
err = s.flushLog(log)
}
} else if s.log.Len() == 0 {
// Adding elapsed time for doing nothing is meaningless, so don't.
_, err = io.WriteString(log, "\n")
} else {
// Insert elapsed time for section at the end of the section's comment.
_, err = fmt.Fprintf(log, " (%.3fs)\n", time.Since(sectionStart).Seconds())
if err == nil && (!ok || !e.Quiet) {
err = s.flushLog(log)
} else {
s.log.Reset()
}
}
sectionStart = time.Time{}
return err
}
var lineno int
lineErr := func(err error) error {
if errors.As(err, new(*CommandError)) {
return err
}
return fmt.Errorf("%s:%d: %w", file, lineno, err)
}
// In case of failure or panic, flush any pending logs for the section.
defer func() {
if sErr := endSection(false); sErr != nil && err == nil {
err = lineErr(sErr)
}
}()
for {
if err := s.ctx.Err(); err != nil {
// This error wasn't produced by any particular command,
// so don't wrap it in a CommandError.
return lineErr(err)
}
line, err := script.ReadString('\n')
if err == io.EOF {
if line == "" {
break // Reached the end of the script.
}
// If the script doesn't end in a newline, interpret the final line.
} else if err != nil {
return lineErr(err)
}
line = strings.TrimSuffix(line, "\n")
lineno++
// The comment character "#" at the start of the line delimits a section of
// the script.
if strings.HasPrefix(line, "#") {
// If there was a previous section, the fact that we are starting a new
// one implies the success of the previous one.
//
// At the start of the script, the state may also contain accumulated logs
// from commands executed on the State outside of the engine in order to
// set it up; flush those logs too.
if err := endSection(true); err != nil {
return lineErr(err)
}
// Log the section start without a newline so that we can add
// a timestamp for the section when it ends.
_, err = fmt.Fprintf(log, "%s", line)
sectionStart = time.Now()
if err != nil {
return lineErr(err)
}
continue
}
cmd, err := parse(file, lineno, line)
if cmd == nil && err == nil {
continue // Ignore blank lines.
}
s.Logf("> %s\n", line)
if err != nil {
return lineErr(err)
}
// Evaluate condition guards.
ok, err := e.conditionsActive(s, cmd.conds)
if err != nil {
return lineErr(err)
}
if !ok {
s.Logf("[condition not met]\n")
continue
}
impl := e.Cmds[cmd.name]
// Expand variables in arguments.
var regexpArgs []int
if impl != nil {
usage := impl.Usage()
if usage.RegexpArgs != nil {
// First join rawArgs without expansion to pass to RegexpArgs.
rawArgs := make([]string, 0, len(cmd.rawArgs))
for _, frags := range cmd.rawArgs {
var b strings.Builder
for _, frag := range frags {
b.WriteString(frag.s)
}
rawArgs = append(rawArgs, b.String())
}
regexpArgs = usage.RegexpArgs(rawArgs...)
}
}
cmd.args = expandArgs(s, cmd.rawArgs, regexpArgs)
// Run the command.
err = e.runCommand(s, cmd, impl)
if err != nil {
if stop := (stopError{}); errors.As(err, &stop) {
// Since the 'stop' command halts execution of the entire script,
// log its message separately from the section in which it appears.
err = endSection(true)
s.Logf("%v\n", stop)
if err == nil {
return nil
}
}
return lineErr(err)
}
}
if err := endSection(true); err != nil {
return lineErr(err)
}
return nil
}
// A command is a complete command parsed from a script.
type command struct {
file string
line int
want expectedStatus
conds []condition // all must be satisfied
name string // the name of the command; must be non-empty
rawArgs [][]argFragment
args []string // shell-expanded arguments following name
background bool // command should run in background (ends with a trailing &)
}
// An expectedStatus describes the expected outcome of a command.
// Script execution halts when a command does not match its expected status.
type expectedStatus string
const (
success expectedStatus = ""
failure expectedStatus = "!"
successOrFailure expectedStatus = "?"
)
type argFragment struct {
s string
quoted bool // if true, disable variable expansion for this fragment
}
type condition struct {
want bool
tag string
}
const argSepChars = " \t\r\n#"
// parse parses a single line as a list of space-separated arguments.
// subject to environment variable expansion (but not resplitting).
// Single quotes around text disable splitting and expansion.
// To embed a single quote, double it:
//
// 'Don''t communicate by sharing memory.'
func parse(filename string, lineno int, line string) (cmd *command, err error) {
cmd = &command{file: filename, line: lineno}
var (
rawArg []argFragment // text fragments of current arg so far (need to add line[start:i])
start = -1 // if >= 0, position where current arg text chunk starts
quoted = false // currently processing quoted text
)
flushArg := func() error {
if len(rawArg) == 0 {
return nil // Nothing to flush.
}
defer func() { rawArg = nil }()
if cmd.name == "" && len(rawArg) == 1 && !rawArg[0].quoted {
arg := rawArg[0].s
// Command prefix ! means negate the expectations about this command:
// go command should fail, match should not be found, etc.
// Prefix ? means allow either success or failure.
switch want := expectedStatus(arg); want {
case failure, successOrFailure:
if cmd.want != "" {
return errors.New("duplicated '!' or '?' token")
}
cmd.want = want
return nil
}
// Command prefix [cond] means only run this command if cond is satisfied.
if strings.HasPrefix(arg, "[") && strings.HasSuffix(arg, "]") {
want := true
arg = strings.TrimSpace(arg[1 : len(arg)-1])
if strings.HasPrefix(arg, "!") {
want = false
arg = strings.TrimSpace(arg[1:])
}
if arg == "" {
return errors.New("empty condition")
}
cmd.conds = append(cmd.conds, condition{want: want, tag: arg})
return nil
}
if arg == "" {
return errors.New("empty command")
}
cmd.name = arg
return nil
}
cmd.rawArgs = append(cmd.rawArgs, rawArg)
return nil
}
for i := 0; ; i++ {
if !quoted && (i >= len(line) || strings.ContainsRune(argSepChars, rune(line[i]))) {
// Found arg-separating space.
if start >= 0 {
rawArg = append(rawArg, argFragment{s: line[start:i], quoted: false})
start = -1
}
if err := flushArg(); err != nil {
return nil, err
}
if i >= len(line) || line[i] == '#' {
break
}
continue
}
if i >= len(line) {
return nil, errors.New("unterminated quoted argument")
}
if line[i] == '\'' {
if !quoted {
// starting a quoted chunk
if start >= 0 {
rawArg = append(rawArg, argFragment{s: line[start:i], quoted: false})
}
start = i + 1
quoted = true
continue
}
// 'foo''bar' means foo'bar, like in rc shell and Pascal.
if i+1 < len(line) && line[i+1] == '\'' {
rawArg = append(rawArg, argFragment{s: line[start:i], quoted: true})
start = i + 1
i++ // skip over second ' before next iteration
continue
}
// ending a quoted chunk
rawArg = append(rawArg, argFragment{s: line[start:i], quoted: true})
start = i + 1
quoted = false
continue
}
// found character worth saving; make sure we're saving
if start < 0 {
start = i
}
}
if cmd.name == "" {
if cmd.want != "" || len(cmd.conds) > 0 || len(cmd.rawArgs) > 0 || cmd.background {
// The line contains a command prefix or suffix, but no actual command.
return nil, errors.New("missing command")
}
// The line is blank, or contains only a comment.
return nil, nil
}
if n := len(cmd.rawArgs); n > 0 {
last := cmd.rawArgs[n-1]
if len(last) == 1 && !last[0].quoted && last[0].s == "&" {
cmd.background = true
cmd.rawArgs = cmd.rawArgs[:n-1]
}
}
return cmd, nil
}
// expandArgs expands the shell variables in rawArgs and joins them to form the
// final arguments to pass to a command.
func expandArgs(s *State, rawArgs [][]argFragment, regexpArgs []int) []string {
args := make([]string, 0, len(rawArgs))
for i, frags := range rawArgs {
isRegexp := false
for _, j := range regexpArgs {
if i == j {
isRegexp = true
break
}
}
var b strings.Builder
for _, frag := range frags {
if frag.quoted {
b.WriteString(frag.s)
} else {
b.WriteString(s.ExpandEnv(frag.s, isRegexp))
}
}
args = append(args, b.String())
}
return args
}
// quoteArgs returns a string that parse would parse as args when passed to a command.
//
// TODO(bcmills): This function should have a fuzz test.
func quoteArgs(args []string) string {
var b strings.Builder
for i, arg := range args {
if i > 0 {
b.WriteString(" ")
}
if strings.ContainsAny(arg, "'"+argSepChars) {
// Quote the argument to a form that would be parsed as a single argument.
b.WriteString("'")
b.WriteString(strings.ReplaceAll(arg, "'", "''"))
b.WriteString("'")
} else {
b.WriteString(arg)
}
}
return b.String()
}
func (e *Engine) conditionsActive(s *State, conds []condition) (bool, error) {
for _, cond := range conds {
var impl Cond
prefix, suffix, ok := strings.Cut(cond.tag, ":")
if ok {
impl = e.Conds[prefix]
if impl == nil {
return false, fmt.Errorf("unknown condition prefix %q", prefix)
}
if !impl.Usage().Prefix {
return false, fmt.Errorf("condition %q cannot be used with a suffix", prefix)
}
} else {
impl = e.Conds[cond.tag]
if impl == nil {
return false, fmt.Errorf("unknown condition %q", cond.tag)
}
if impl.Usage().Prefix {
return false, fmt.Errorf("condition %q requires a suffix", cond.tag)
}
}
active, err := impl.Eval(s, suffix)
if err != nil {
return false, fmt.Errorf("evaluating condition %q: %w", cond.tag, err)
}
if active != cond.want {
return false, nil
}
}
return true, nil
}
func (e *Engine) runCommand(s *State, cmd *command, impl Cmd) error {
if impl == nil {
return cmdError(cmd, errors.New("unknown command"))
}
async := impl.Usage().Async
if cmd.background && !async {
return cmdError(cmd, errors.New("command cannot be run in background"))
}
wait, runErr := impl.Run(s, cmd.args...)
if wait == nil {
if async && runErr == nil {
return cmdError(cmd, errors.New("internal error: async command returned a nil WaitFunc"))
}
return checkStatus(cmd, runErr)
}
if runErr != nil {
return cmdError(cmd, errors.New("internal error: command returned both an error and a WaitFunc"))
}
if cmd.background {
s.background = append(s.background, backgroundCmd{
command: cmd,
wait: wait,
})
// Clear stdout and stderr, since they no longer correspond to the last
// command executed.
s.stdout = ""
s.stderr = ""
return nil
}
if wait != nil {
stdout, stderr, waitErr := wait(s)
s.stdout = stdout
s.stderr = stderr
if stdout != "" {
s.Logf("[stdout]\n%s", stdout)
}
if stderr != "" {
s.Logf("[stderr]\n%s", stderr)
}
if cmdErr := checkStatus(cmd, waitErr); cmdErr != nil {
return cmdErr
}
if waitErr != nil {
// waitErr was expected (by cmd.want), so log it instead of returning it.
s.Logf("[%v]\n", waitErr)
}
}
return nil
}
func checkStatus(cmd *command, err error) error {
if err == nil {
if cmd.want == failure {
return cmdError(cmd, ErrUnexpectedSuccess)
}
return nil
}
if s := (stopError{}); errors.As(err, &s) {
// This error originated in the Stop command.
// Propagate it as-is.
return cmdError(cmd, err)
}
if w := (waitError{}); errors.As(err, &w) {
// This error was surfaced from a background process by a call to Wait.
// Add a call frame for Wait itself, but ignore its "want" field.
// (Wait itself cannot fail to wait on commands or else it would leak
// processes and/or goroutines β so a negative assertion for it would be at
// best ambiguous.)
return cmdError(cmd, err)
}
if cmd.want == success {
return cmdError(cmd, err)
}
if cmd.want == failure && (errors.Is(err, context.DeadlineExceeded) || errors.Is(err, context.Canceled)) {
// The command was terminated because the script is no longer interested in
// its output, so we don't know what it would have done had it run to
// completion β for all we know, it could have exited without error if it
// ran just a smidge faster.
return cmdError(cmd, err)
}
return nil
}
// ListCmds prints to w a list of the named commands,
// annotating each with its arguments and a short usage summary.
// If verbose is true, ListCmds prints full details for each command.
//
// Each of the name arguments should be a command name.
// If no names are passed as arguments, ListCmds lists all the
// commands registered in e.
func (e *Engine) ListCmds(w io.Writer, verbose bool, names ...string) error {
if names == nil {
names = make([]string, 0, len(e.Cmds))
for name := range e.Cmds {
names = append(names, name)
}
sort.Strings(names)
}
for _, name := range names {
cmd := e.Cmds[name]
usage := cmd.Usage()
suffix := ""
if usage.Async {
suffix = " [&]"
}
_, err := fmt.Fprintf(w, "%s %s%s\n\t%s\n", name, usage.Args, suffix, usage.Summary)
if err != nil {
return err
}
if verbose {
if _, err := io.WriteString(w, "\n"); err != nil {
return err
}
for _, line := range usage.Detail {
if err := wrapLine(w, line, 60, "\t"); err != nil {
return err
}
}
if _, err := io.WriteString(w, "\n"); err != nil {
return err
}
}
}
return nil
}
func wrapLine(w io.Writer, line string, cols int, indent string) error {
line = strings.TrimLeft(line, " ")
for len(line) > cols {
bestSpace := -1
for i, r := range line {
if r == ' ' {
if i <= cols || bestSpace < 0 {
bestSpace = i
}
if i > cols {
break
}
}
}
if bestSpace < 0 {
break
}
if _, err := fmt.Fprintf(w, "%s%s\n", indent, line[:bestSpace]); err != nil {
return err
}
line = line[bestSpace+1:]
}
_, err := fmt.Fprintf(w, "%s%s\n", indent, line)
return err
}
// ListConds prints to w a list of conditions, one per line,
// annotating each with a description and whether the condition
// is true in the state s (if s is non-nil).
//
// Each of the tag arguments should be a condition string of
// the form "name" or "name:suffix". If no tags are passed as
// arguments, ListConds lists all conditions registered in
// the engine e.
func (e *Engine) ListConds(w io.Writer, s *State, tags ...string) error {
if tags == nil {
tags = make([]string, 0, len(e.Conds))
for name := range e.Conds {
tags = append(tags, name)
}
sort.Strings(tags)
}
for _, tag := range tags {
if prefix, suffix, ok := strings.Cut(tag, ":"); ok {
cond := e.Conds[prefix]
if cond == nil {
return fmt.Errorf("unknown condition prefix %q", prefix)
}
usage := cond.Usage()
if !usage.Prefix {
return fmt.Errorf("condition %q cannot be used with a suffix", prefix)
}
activeStr := ""
if s != nil {
if active, _ := cond.Eval(s, suffix); active {
activeStr = " (active)"
}
}
_, err := fmt.Fprintf(w, "[%s]%s\n\t%s\n", tag, activeStr, usage.Summary)
if err != nil {
return err
}
continue
}
cond := e.Conds[tag]
if cond == nil {
return fmt.Errorf("unknown condition %q", tag)
}
var err error
usage := cond.Usage()
if usage.Prefix {
_, err = fmt.Fprintf(w, "[%s:*]\n\t%s\n", tag, usage.Summary)
} else {
activeStr := ""
if s != nil {
if ok, _ := cond.Eval(s, ""); ok {
activeStr = " (active)"
}
}
_, err = fmt.Fprintf(w, "[%s]%s\n\t%s\n", tag, activeStr, usage.Summary)
}
if err != nil {
return err
}
}
return nil
}
|
go/src/cmd/go/internal/script/engine.go/0
|
{
"file_path": "go/src/cmd/go/internal/script/engine.go",
"repo_id": "go",
"token_count": 8042
}
| 138 |
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package test
import (
"cmd/go/internal/cfg"
"cmd/go/internal/test/internal/genflags"
"internal/testenv"
"maps"
"os"
"testing"
)
func TestMain(m *testing.M) {
cfg.SetGOROOT(testenv.GOROOT(nil), false)
os.Exit(m.Run())
}
func TestPassFlagToTest(t *testing.T) {
wantNames := genflags.ShortTestFlags()
missing := map[string]bool{}
for _, name := range wantNames {
if !passFlagToTest[name] {
missing[name] = true
}
}
if len(missing) > 0 {
t.Errorf("passFlagToTest is missing entries: %v", missing)
}
extra := maps.Clone(passFlagToTest)
for _, name := range wantNames {
delete(extra, name)
}
if len(extra) > 0 {
t.Errorf("passFlagToTest contains extra entries: %v", extra)
}
if t.Failed() {
t.Logf("To regenerate:\n\tgo generate cmd/go/internal/test")
}
}
func TestPassAnalyzersToVet(t *testing.T) {
testenv.MustHaveGoBuild(t) // runs 'go tool vet -flags'
wantNames, err := genflags.VetAnalyzers()
if err != nil {
t.Fatal(err)
}
missing := map[string]bool{}
for _, name := range wantNames {
if !passAnalyzersToVet[name] {
missing[name] = true
}
}
if len(missing) > 0 {
t.Errorf("passAnalyzersToVet is missing entries: %v", missing)
}
extra := maps.Clone(passAnalyzersToVet)
for _, name := range wantNames {
delete(extra, name)
}
if len(extra) > 0 {
t.Errorf("passFlagToTest contains extra entries: %v", extra)
}
if t.Failed() {
t.Logf("To regenerate:\n\tgo generate cmd/go/internal/test")
}
}
|
go/src/cmd/go/internal/test/flagdefs_test.go/0
|
{
"file_path": "go/src/cmd/go/internal/test/flagdefs_test.go",
"repo_id": "go",
"token_count": 645
}
| 139 |
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package toolchain
import (
"context"
"fmt"
"os"
"path/filepath"
"sort"
"strings"
"cmd/go/internal/base"
"cmd/go/internal/cfg"
"cmd/go/internal/gover"
"cmd/go/internal/modfetch"
"cmd/internal/telemetry/counter"
)
// A Switcher collects errors to be reported and then decides
// between reporting the errors or switching to a new toolchain
// to resolve them.
//
// The client calls [Switcher.Error] repeatedly with errors encountered
// and then calls [Switcher.Switch]. If the errors included any
// *gover.TooNewErrors (potentially wrapped) and switching is
// permitted by GOTOOLCHAIN, Switch switches to a new toolchain.
// Otherwise Switch prints all the errors using base.Error.
//
// See https://go.dev/doc/toolchain#switch.
type Switcher struct {
TooNew *gover.TooNewError // max go requirement observed
Errors []error // errors collected so far
}
// Error reports the error to the Switcher,
// which saves it for processing during Switch.
func (s *Switcher) Error(err error) {
s.Errors = append(s.Errors, err)
s.addTooNew(err)
}
// addTooNew adds any TooNew errors that can be found in err.
func (s *Switcher) addTooNew(err error) {
switch err := err.(type) {
case interface{ Unwrap() []error }:
for _, e := range err.Unwrap() {
s.addTooNew(e)
}
case interface{ Unwrap() error }:
s.addTooNew(err.Unwrap())
case *gover.TooNewError:
if s.TooNew == nil ||
gover.Compare(err.GoVersion, s.TooNew.GoVersion) > 0 ||
gover.Compare(err.GoVersion, s.TooNew.GoVersion) == 0 && err.What < s.TooNew.What {
s.TooNew = err
}
}
}
// NeedSwitch reports whether Switch would attempt to switch toolchains.
func (s *Switcher) NeedSwitch() bool {
return s.TooNew != nil && (HasAuto() || HasPath())
}
// Switch decides whether to switch to a newer toolchain
// to resolve any of the saved errors.
// It switches if toolchain switches are permitted and there is at least one TooNewError.
//
// If Switch decides not to switch toolchains, it prints the errors using base.Error and returns.
//
// If Switch decides to switch toolchains but cannot identify a toolchain to use.
// it prints the errors along with one more about not being able to find the toolchain
// and returns.
//
// Otherwise, Switch prints an informational message giving a reason for the
// switch and the toolchain being invoked and then switches toolchains.
// This operation never returns.
func (s *Switcher) Switch(ctx context.Context) {
if !s.NeedSwitch() {
for _, err := range s.Errors {
base.Error(err)
}
return
}
// Switch to newer Go toolchain if necessary and possible.
tv, err := NewerToolchain(ctx, s.TooNew.GoVersion)
if err != nil {
for _, err := range s.Errors {
base.Error(err)
}
base.Error(fmt.Errorf("switching to go >= %v: %w", s.TooNew.GoVersion, err))
return
}
fmt.Fprintf(os.Stderr, "go: %v requires go >= %v; switching to %v\n", s.TooNew.What, s.TooNew.GoVersion, tv)
counterSwitchExec.Inc()
Exec(tv)
panic("unreachable")
}
var counterSwitchExec = counter.New("go/toolchain/switch-exec")
// SwitchOrFatal attempts a toolchain switch based on the information in err
// and otherwise falls back to base.Fatal(err).
func SwitchOrFatal(ctx context.Context, err error) {
var s Switcher
s.Error(err)
s.Switch(ctx)
base.Exit()
}
// NewerToolchain returns the name of the toolchain to use when we need
// to switch to a newer toolchain that must support at least the given Go version.
// See https://go.dev/doc/toolchain#switch.
//
// If the latest major release is 1.N.0, we use the latest patch release of 1.(N-1) if that's >= version.
// Otherwise we use the latest 1.N if that's allowed.
// Otherwise we use the latest release.
func NewerToolchain(ctx context.Context, version string) (string, error) {
fetch := autoToolchains
if !HasAuto() {
fetch = pathToolchains
}
list, err := fetch(ctx)
if err != nil {
return "", err
}
return newerToolchain(version, list)
}
// autoToolchains returns the list of toolchain versions available to GOTOOLCHAIN=auto or =min+auto mode.
func autoToolchains(ctx context.Context) ([]string, error) {
var versions *modfetch.Versions
err := modfetch.TryProxies(func(proxy string) error {
v, err := modfetch.Lookup(ctx, proxy, "go").Versions(ctx, "")
if err != nil {
return err
}
versions = v
return nil
})
if err != nil {
return nil, err
}
return versions.List, nil
}
// pathToolchains returns the list of toolchain versions available to GOTOOLCHAIN=path or =min+path mode.
func pathToolchains(ctx context.Context) ([]string, error) {
have := make(map[string]bool)
var list []string
for _, dir := range pathDirs() {
if dir == "" || !filepath.IsAbs(dir) {
// Refuse to use local directories in $PATH (hard-coding exec.ErrDot).
continue
}
entries, err := os.ReadDir(dir)
if err != nil {
continue
}
for _, de := range entries {
if de.IsDir() || !strings.HasPrefix(de.Name(), "go1.") {
continue
}
info, err := de.Info()
if err != nil {
continue
}
v, ok := pathVersion(dir, de, info)
if !ok || !strings.HasPrefix(v, "1.") || have[v] {
continue
}
have[v] = true
list = append(list, v)
}
}
sort.Slice(list, func(i, j int) bool {
return gover.Compare(list[i], list[j]) < 0
})
return list, nil
}
// newerToolchain implements NewerToolchain where the list of choices is known.
// It is separated out for easier testing of this logic.
func newerToolchain(need string, list []string) (string, error) {
// Consider each release in the list, from newest to oldest,
// considering only entries >= need and then only entries
// that are the latest in their language family
// (the latest 1.40, the latest 1.39, and so on).
// We prefer the latest patch release before the most recent release family,
// so if the latest release is 1.40.1 we'll take the latest 1.39.X.
// Failing that, we prefer the latest patch release before the most recent
// prerelease family, so if the latest release is 1.40rc1 is out but 1.39 is okay,
// we'll still take 1.39.X.
// Failing that we'll take the latest release.
latest := ""
for i := len(list) - 1; i >= 0; i-- {
v := list[i]
if gover.Compare(v, need) < 0 {
break
}
if gover.Lang(latest) == gover.Lang(v) {
continue
}
newer := latest
latest = v
if newer != "" && !gover.IsPrerelease(newer) {
// latest is the last patch release of Go 1.X, and we saw a non-prerelease of Go 1.(X+1),
// so latest is the one we want.
break
}
}
if latest == "" {
return "", fmt.Errorf("no releases found for go >= %v", need)
}
return "go" + latest, nil
}
// HasAuto reports whether the GOTOOLCHAIN setting allows "auto" upgrades.
func HasAuto() bool {
env := cfg.Getenv("GOTOOLCHAIN")
return env == "auto" || strings.HasSuffix(env, "+auto")
}
// HasPath reports whether the GOTOOLCHAIN setting allows "path" upgrades.
func HasPath() bool {
env := cfg.Getenv("GOTOOLCHAIN")
return env == "path" || strings.HasSuffix(env, "+path")
}
|
go/src/cmd/go/internal/toolchain/switch.go/0
|
{
"file_path": "go/src/cmd/go/internal/toolchain/switch.go",
"repo_id": "go",
"token_count": 2458
}
| 140 |
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package vcweb
import (
"bufio"
"bytes"
"cmd/go/internal/script"
"context"
"errors"
"fmt"
"internal/txtar"
"io"
"log"
"net/http"
"os"
"os/exec"
"path/filepath"
"runtime"
"strconv"
"strings"
"time"
"golang.org/x/mod/module"
"golang.org/x/mod/zip"
)
// newScriptEngine returns a script engine augmented with commands for
// reproducing version-control repositories by replaying commits.
func newScriptEngine() *script.Engine {
conds := script.DefaultConds()
interrupt := func(cmd *exec.Cmd) error { return cmd.Process.Signal(os.Interrupt) }
gracePeriod := 30 * time.Second // arbitrary
cmds := script.DefaultCmds()
cmds["at"] = scriptAt()
cmds["bzr"] = script.Program("bzr", interrupt, gracePeriod)
cmds["fossil"] = script.Program("fossil", interrupt, gracePeriod)
cmds["git"] = script.Program("git", interrupt, gracePeriod)
cmds["hg"] = script.Program("hg", interrupt, gracePeriod)
cmds["handle"] = scriptHandle()
cmds["modzip"] = scriptModzip()
cmds["svnadmin"] = script.Program("svnadmin", interrupt, gracePeriod)
cmds["svn"] = script.Program("svn", interrupt, gracePeriod)
cmds["unquote"] = scriptUnquote()
return &script.Engine{
Cmds: cmds,
Conds: conds,
}
}
// loadScript interprets the given script content using the vcweb script engine.
// loadScript always returns either a non-nil handler or a non-nil error.
//
// The script content must be a txtar archive with a comment containing a script
// with exactly one "handle" command and zero or more VCS commands to prepare
// the repository to be served.
func (s *Server) loadScript(ctx context.Context, logger *log.Logger, scriptPath string, scriptContent []byte, workDir string) (http.Handler, error) {
ar := txtar.Parse(scriptContent)
if err := os.MkdirAll(workDir, 0755); err != nil {
return nil, err
}
st, err := s.newState(ctx, workDir)
if err != nil {
return nil, err
}
if err := st.ExtractFiles(ar); err != nil {
return nil, err
}
scriptName := filepath.Base(scriptPath)
scriptLog := new(strings.Builder)
err = s.engine.Execute(st, scriptName, bufio.NewReader(bytes.NewReader(ar.Comment)), scriptLog)
closeErr := st.CloseAndWait(scriptLog)
logger.Printf("%s:", scriptName)
io.WriteString(logger.Writer(), scriptLog.String())
io.WriteString(logger.Writer(), "\n")
if err != nil {
return nil, err
}
if closeErr != nil {
return nil, err
}
sc, err := getScriptCtx(st)
if err != nil {
return nil, err
}
if sc.handler == nil {
return nil, errors.New("script completed without setting handler")
}
return sc.handler, nil
}
// newState returns a new script.State for executing scripts in workDir.
func (s *Server) newState(ctx context.Context, workDir string) (*script.State, error) {
ctx = &scriptCtx{
Context: ctx,
server: s,
}
st, err := script.NewState(ctx, workDir, s.env)
if err != nil {
return nil, err
}
return st, nil
}
// scriptEnviron returns a new environment that attempts to provide predictable
// behavior for the supported version-control tools.
func scriptEnviron(homeDir string) []string {
env := []string{
"USER=gopher",
homeEnvName() + "=" + homeDir,
"GIT_CONFIG_NOSYSTEM=1",
"HGRCPATH=" + filepath.Join(homeDir, ".hgrc"),
"HGENCODING=utf-8",
}
// Preserve additional environment variables that may be needed by VCS tools.
for _, k := range []string{
pathEnvName(),
tempEnvName(),
"SYSTEMROOT", // must be preserved on Windows to find DLLs; golang.org/issue/25210
"WINDIR", // must be preserved on Windows to be able to run PowerShell command; golang.org/issue/30711
"ComSpec", // must be preserved on Windows to be able to run Batch files; golang.org/issue/56555
"DYLD_LIBRARY_PATH", // must be preserved on macOS systems to find shared libraries
"LD_LIBRARY_PATH", // must be preserved on Unix systems to find shared libraries
"LIBRARY_PATH", // allow override of non-standard static library paths
"PYTHONPATH", // may be needed by hg to find imported modules
} {
if v, ok := os.LookupEnv(k); ok {
env = append(env, k+"="+v)
}
}
if os.Getenv("GO_BUILDER_NAME") != "" || os.Getenv("GIT_TRACE_CURL") == "1" {
// To help diagnose https://go.dev/issue/52545,
// enable tracing for Git HTTPS requests.
env = append(env,
"GIT_TRACE_CURL=1",
"GIT_TRACE_CURL_NO_DATA=1",
"GIT_REDACT_COOKIES=o,SSO,GSSO_Uberproxy")
}
return env
}
// homeEnvName returns the environment variable used by os.UserHomeDir
// to locate the user's home directory.
func homeEnvName() string {
switch runtime.GOOS {
case "windows":
return "USERPROFILE"
case "plan9":
return "home"
default:
return "HOME"
}
}
// tempEnvName returns the environment variable used by os.TempDir
// to locate the default directory for temporary files.
func tempEnvName() string {
switch runtime.GOOS {
case "windows":
return "TMP"
case "plan9":
return "TMPDIR" // actually plan 9 doesn't have one at all but this is fine
default:
return "TMPDIR"
}
}
// pathEnvName returns the environment variable used by exec.LookPath to
// identify directories to search for executables.
func pathEnvName() string {
switch runtime.GOOS {
case "plan9":
return "path"
default:
return "PATH"
}
}
// A scriptCtx is a context.Context that stores additional state for script
// commands.
type scriptCtx struct {
context.Context
server *Server
commitTime time.Time
handlerName string
handler http.Handler
}
// scriptCtxKey is the key associating the *scriptCtx in a script's Context..
type scriptCtxKey struct{}
func (sc *scriptCtx) Value(key any) any {
if key == (scriptCtxKey{}) {
return sc
}
return sc.Context.Value(key)
}
func getScriptCtx(st *script.State) (*scriptCtx, error) {
sc, ok := st.Context().Value(scriptCtxKey{}).(*scriptCtx)
if !ok {
return nil, errors.New("scriptCtx not found in State.Context")
}
return sc, nil
}
func scriptAt() script.Cmd {
return script.Command(
script.CmdUsage{
Summary: "set the current commit time for all version control systems",
Args: "time",
Detail: []string{
"The argument must be an absolute timestamp in RFC3339 format.",
},
},
func(st *script.State, args ...string) (script.WaitFunc, error) {
if len(args) != 1 {
return nil, script.ErrUsage
}
sc, err := getScriptCtx(st)
if err != nil {
return nil, err
}
sc.commitTime, err = time.ParseInLocation(time.RFC3339, args[0], time.UTC)
if err == nil {
st.Setenv("GIT_COMMITTER_DATE", args[0])
st.Setenv("GIT_AUTHOR_DATE", args[0])
}
return nil, err
})
}
func scriptHandle() script.Cmd {
return script.Command(
script.CmdUsage{
Summary: "set the HTTP handler that will serve the script's output",
Args: "handler [dir]",
Detail: []string{
"The handler will be passed the script's current working directory and environment as arguments.",
"Valid handlers include 'dir' (for general http.Dir serving), 'bzr', 'fossil', 'git', and 'hg'",
},
},
func(st *script.State, args ...string) (script.WaitFunc, error) {
if len(args) == 0 || len(args) > 2 {
return nil, script.ErrUsage
}
sc, err := getScriptCtx(st)
if err != nil {
return nil, err
}
if sc.handler != nil {
return nil, fmt.Errorf("server handler already set to %s", sc.handlerName)
}
name := args[0]
h, ok := sc.server.vcsHandlers[name]
if !ok {
return nil, fmt.Errorf("unrecognized VCS %q", name)
}
sc.handlerName = name
if !h.Available() {
return nil, ServerNotInstalledError{name}
}
dir := st.Getwd()
if len(args) >= 2 {
dir = st.Path(args[1])
}
sc.handler, err = h.Handler(dir, st.Environ(), sc.server.logger)
return nil, err
})
}
func scriptModzip() script.Cmd {
return script.Command(
script.CmdUsage{
Summary: "create a Go module zip file from a directory",
Args: "zipfile path@version dir",
},
func(st *script.State, args ...string) (wait script.WaitFunc, err error) {
if len(args) != 3 {
return nil, script.ErrUsage
}
zipPath := st.Path(args[0])
mPath, version, ok := strings.Cut(args[1], "@")
if !ok {
return nil, script.ErrUsage
}
dir := st.Path(args[2])
if err := os.MkdirAll(filepath.Dir(zipPath), 0755); err != nil {
return nil, err
}
f, err := os.Create(zipPath)
if err != nil {
return nil, err
}
defer func() {
if closeErr := f.Close(); err == nil {
err = closeErr
}
}()
return nil, zip.CreateFromDir(f, module.Version{Path: mPath, Version: version}, dir)
})
}
func scriptUnquote() script.Cmd {
return script.Command(
script.CmdUsage{
Summary: "unquote the argument as a Go string",
Args: "string",
},
func(st *script.State, args ...string) (script.WaitFunc, error) {
if len(args) != 1 {
return nil, script.ErrUsage
}
s, err := strconv.Unquote(`"` + args[0] + `"`)
if err != nil {
return nil, err
}
wait := func(*script.State) (stdout, stderr string, err error) {
return s, "", nil
}
return wait, nil
})
}
|
go/src/cmd/go/internal/vcweb/script.go/0
|
{
"file_path": "go/src/cmd/go/internal/vcweb/script.go",
"repo_id": "go",
"token_count": 3524
}
| 141 |
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package web
import (
"net/url"
"testing"
)
func TestURLToFilePath(t *testing.T) {
for _, tc := range urlTests {
if tc.url == "" {
continue
}
tc := tc
t.Run(tc.url, func(t *testing.T) {
u, err := url.Parse(tc.url)
if err != nil {
t.Fatalf("url.Parse(%q): %v", tc.url, err)
}
path, err := urlToFilePath(u)
if err != nil {
if err.Error() == tc.wantErr {
return
}
if tc.wantErr == "" {
t.Fatalf("urlToFilePath(%v): %v; want <nil>", u, err)
} else {
t.Fatalf("urlToFilePath(%v): %v; want %s", u, err, tc.wantErr)
}
}
if path != tc.filePath || tc.wantErr != "" {
t.Fatalf("urlToFilePath(%v) = %q, <nil>; want %q, %s", u, path, tc.filePath, tc.wantErr)
}
})
}
}
func TestURLFromFilePath(t *testing.T) {
for _, tc := range urlTests {
if tc.filePath == "" {
continue
}
tc := tc
t.Run(tc.filePath, func(t *testing.T) {
u, err := urlFromFilePath(tc.filePath)
if err != nil {
if err.Error() == tc.wantErr {
return
}
if tc.wantErr == "" {
t.Fatalf("urlFromFilePath(%v): %v; want <nil>", tc.filePath, err)
} else {
t.Fatalf("urlFromFilePath(%v): %v; want %s", tc.filePath, err, tc.wantErr)
}
}
if tc.wantErr != "" {
t.Fatalf("urlFromFilePath(%v) = <nil>; want error: %s", tc.filePath, tc.wantErr)
}
wantURL := tc.url
if tc.canonicalURL != "" {
wantURL = tc.canonicalURL
}
if u.String() != wantURL {
t.Errorf("urlFromFilePath(%v) = %v; want %s", tc.filePath, u, wantURL)
}
})
}
}
|
go/src/cmd/go/internal/web/url_test.go/0
|
{
"file_path": "go/src/cmd/go/internal/web/url_test.go",
"repo_id": "go",
"token_count": 829
}
| 142 |
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build unix
package work
import (
"bytes"
"internal/testenv"
"strings"
"testing"
"unicode"
)
func FuzzSplitPkgConfigOutput(f *testing.F) {
testenv.MustHaveExecPath(f, "/bin/sh")
f.Add([]byte(`$FOO`))
f.Add([]byte(`\$FOO`))
f.Add([]byte(`${FOO}`))
f.Add([]byte(`\${FOO}`))
f.Add([]byte(`$(/bin/false)`))
f.Add([]byte(`\$(/bin/false)`))
f.Add([]byte(`$((0))`))
f.Add([]byte(`\$((0))`))
f.Add([]byte(`unescaped space`))
f.Add([]byte(`escaped\ space`))
f.Add([]byte(`"unterminated quote`))
f.Add([]byte(`'unterminated quote`))
f.Add([]byte(`unterminated escape\`))
f.Add([]byte(`"quote with unterminated escape\`))
f.Add([]byte(`'quoted "double quotes"'`))
f.Add([]byte(`"quoted 'single quotes'"`))
f.Add([]byte(`"\$0"`))
f.Add([]byte(`"\$\0"`))
f.Add([]byte(`"\$"`))
f.Add([]byte(`"\$ "`))
// Example positive inputs from TestSplitPkgConfigOutput.
// Some bare newlines have been removed so that the inputs
// are valid in the shell script we use for comparison.
f.Add([]byte(`-r:foo -L/usr/white\ space/lib -lfoo\ bar -lbar\ baz`))
f.Add([]byte(`-lextra\ fun\ arg\\`))
f.Add([]byte("\textra whitespace\r"))
f.Add([]byte(" \r "))
f.Add([]byte(`"-r:foo" "-L/usr/white space/lib" "-lfoo bar" "-lbar baz"`))
f.Add([]byte(`"-lextra fun arg\\"`))
f.Add([]byte(`" \r\n\ "`))
f.Add([]byte(`""`))
f.Add([]byte(``))
f.Add([]byte(`"\\"`))
f.Add([]byte(`"\x"`))
f.Add([]byte(`"\\x"`))
f.Add([]byte(`'\\'`))
f.Add([]byte(`'\x'`))
f.Add([]byte(`"\\x"`))
f.Add([]byte("\\\n"))
f.Add([]byte(`-fPIC -I/test/include/foo -DQUOTED='"/test/share/doc"'`))
f.Add([]byte(`-fPIC -I/test/include/foo -DQUOTED="/test/share/doc"`))
f.Add([]byte(`-fPIC -I/test/include/foo -DQUOTED=\"/test/share/doc\"`))
f.Add([]byte(`-fPIC -I/test/include/foo -DQUOTED='/test/share/doc'`))
f.Add([]byte(`-DQUOTED='/te\st/share/d\oc'`))
f.Add([]byte(`-Dhello=10 -Dworld=+32 -DDEFINED_FROM_PKG_CONFIG=hello\ world`))
f.Add([]byte(`"broken\"" \\\a "a"`))
// Example negative inputs from TestSplitPkgConfigOutput.
f.Add([]byte(`" \r\n `))
f.Add([]byte(`"-r:foo" "-L/usr/white space/lib "-lfoo bar" "-lbar baz"`))
f.Add([]byte(`"-lextra fun arg\\`))
f.Add([]byte(`broken flag\`))
f.Add([]byte(`extra broken flag \`))
f.Add([]byte(`\`))
f.Add([]byte(`"broken\"" "extra" \`))
f.Fuzz(func(t *testing.T, b []byte) {
t.Parallel()
if bytes.ContainsAny(b, "*?[#~%\x00{}!") {
t.Skipf("skipping %#q: contains a sometimes-quoted character", b)
}
// splitPkgConfigOutput itself rejects inputs that contain unquoted
// shell operator characters. (Quoted shell characters are fine.)
for _, c := range b {
if c > unicode.MaxASCII {
t.Skipf("skipping %#q: contains a non-ASCII character %q", b, c)
}
if !unicode.IsGraphic(rune(c)) && !unicode.IsSpace(rune(c)) {
t.Skipf("skipping %#q: contains non-graphic character %q", b, c)
}
}
args, err := splitPkgConfigOutput(b)
if err != nil {
// We haven't checked that the shell would actually reject this input too,
// but if splitPkgConfigOutput rejected it it's probably too dangerous to
// run in the script.
t.Logf("%#q: %v", b, err)
return
}
t.Logf("splitPkgConfigOutput(%#q) = %#q", b, args)
if len(args) == 0 {
t.Skipf("skipping %#q: contains no arguments", b)
}
var buf strings.Builder
for _, arg := range args {
buf.WriteString(arg)
buf.WriteString("\n")
}
wantOut := buf.String()
if strings.Count(wantOut, "\n") != len(args)+bytes.Count(b, []byte("\n")) {
// One of the newlines in b was treated as a delimiter and not part of an
// argument. Our bash test script would interpret that as a syntax error.
t.Skipf("skipping %#q: contains a bare newline", b)
}
// We use the printf shell command to echo the arguments because, per
// https://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html#tag_20_37_16:
// βIt is not possible to use echo portably across all POSIX systems unless
// both -n (as the first argument) and escape sequences are omitted.β
cmd := testenv.Command(t, "/bin/sh", "-c", "printf '%s\n' "+string(b))
cmd.Env = append(cmd.Environ(), "LC_ALL=POSIX", "POSIXLY_CORRECT=1")
cmd.Stderr = new(strings.Builder)
out, err := cmd.Output()
if err != nil {
t.Fatalf("%#q: %v\n%s", cmd.Args, err, cmd.Stderr)
}
if string(out) != wantOut {
t.Logf("%#q:\n%#q", cmd.Args, out)
t.Logf("want:\n%#q", wantOut)
t.Errorf("parsed args do not match")
}
})
}
|
go/src/cmd/go/internal/work/shell_test.go/0
|
{
"file_path": "go/src/cmd/go/internal/work/shell_test.go",
"repo_id": "go",
"token_count": 2110
}
| 143 |
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main_test
import (
"errors"
"internal/testenv"
"internal/testpty"
"io"
"os"
"testing"
"golang.org/x/term"
)
func TestTerminalPassthrough(t *testing.T) {
// Check that if 'go test' is run with a terminal connected to stdin/stdout,
// then the go command passes that terminal down to the test binary
// invocation (rather than, e.g., putting a pipe in the way).
//
// See issue 18153.
testenv.MustHaveGoBuild(t)
// Start with a "self test" to make sure that if we *don't* pass in a
// terminal, the test can correctly detect that. (cmd/go doesn't guarantee
// that it won't add a terminal in the middle, but that would be pretty weird.)
t.Run("pipe", func(t *testing.T) {
r, w, err := os.Pipe()
if err != nil {
t.Fatalf("pipe failed: %s", err)
}
defer r.Close()
defer w.Close()
stdout, stderr := runTerminalPassthrough(t, r, w)
if stdout {
t.Errorf("stdout is unexpectedly a terminal")
}
if stderr {
t.Errorf("stderr is unexpectedly a terminal")
}
})
// Now test with a read PTY.
t.Run("pty", func(t *testing.T) {
r, processTTY, err := testpty.Open()
if errors.Is(err, testpty.ErrNotSupported) {
t.Skipf("%s", err)
} else if err != nil {
t.Fatalf("failed to open test PTY: %s", err)
}
defer r.Close()
w, err := os.OpenFile(processTTY, os.O_RDWR, 0)
if err != nil {
t.Fatal(err)
}
defer w.Close()
stdout, stderr := runTerminalPassthrough(t, r, w)
if !stdout {
t.Errorf("stdout is not a terminal")
}
if !stderr {
t.Errorf("stderr is not a terminal")
}
})
}
func runTerminalPassthrough(t *testing.T, r, w *os.File) (stdout, stderr bool) {
cmd := testenv.Command(t, testGo, "test", "-run=^$")
cmd.Env = append(cmd.Environ(), "GO_TEST_TERMINAL_PASSTHROUGH=1")
cmd.Stdout = w
cmd.Stderr = w
// The behavior of reading from a PTY after the child closes it is very
// strange: on Linux, Read returns EIO, and on at least some versions of
// macOS, unread output may be discarded (see https://go.dev/issue/57141).
//
// To avoid that situation, we keep the child process running until the
// parent has finished reading from the PTY, at which point we unblock the
// child by closing its stdin pipe.
stdin, err := cmd.StdinPipe()
if err != nil {
t.Fatal(err)
}
t.Logf("running %s", cmd)
err = cmd.Start()
if err != nil {
t.Fatalf("starting subprocess: %s", err)
}
w.Close()
t.Cleanup(func() {
stdin.Close()
if err := cmd.Wait(); err != nil {
t.Errorf("suprocess failed with: %s", err)
}
})
buf := make([]byte, 2)
n, err := io.ReadFull(r, buf)
if err != nil || !(buf[0] == '1' || buf[0] == 'X') || !(buf[1] == '2' || buf[1] == 'X') {
t.Logf("read error: %v", err)
t.Fatalf("expected 2 bytes matching `[1X][2X]`; got %q", buf[:n])
}
return buf[0] == '1', buf[1] == '2'
}
func init() {
if os.Getenv("GO_TEST_TERMINAL_PASSTHROUGH") == "" {
return
}
if term.IsTerminal(1) {
os.Stdout.WriteString("1")
} else {
os.Stdout.WriteString("X")
}
if term.IsTerminal(2) {
os.Stdout.WriteString("2")
} else {
os.Stdout.WriteString("X")
}
// Before exiting, wait for the parent process to read the PTY output,
// at which point it will close stdin.
io.Copy(io.Discard, os.Stdin)
os.Exit(0)
}
|
go/src/cmd/go/terminal_test.go/0
|
{
"file_path": "go/src/cmd/go/terminal_test.go",
"repo_id": "go",
"token_count": 1389
}
| 144 |
The scripts in this directory set up version-control repos for use in
tests of cmd/go and its subpackages.
They are written in a dialect of the same script language as in
cmd/go/testdata/script, and the outputs are hosted by the server in
cmd/go/internal/vcweb.
To see the conditions and commands available for these scripts, run:
go test cmd/go/internal/vcweb -v --run=TestHelp
To host these scripts in a standalone server, run:
go test cmd/go/internal/vcweb/vcstest -v --port=0
|
go/src/cmd/go/testdata/vcstest/README/0
|
{
"file_path": "go/src/cmd/go/testdata/vcstest/README",
"repo_id": "go",
"token_count": 140
}
| 145 |
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
/*
Gofmt formats Go programs.
It uses tabs for indentation and blanks for alignment.
Alignment assumes that an editor is using a fixed-width font.
Without an explicit path, it processes the standard input. Given a file,
it operates on that file; given a directory, it operates on all .go files in
that directory, recursively. (Files starting with a period are ignored.)
By default, gofmt prints the reformatted sources to standard output.
Usage:
gofmt [flags] [path ...]
The flags are:
-d
Do not print reformatted sources to standard output.
If a file's formatting is different than gofmt's, print diffs
to standard output.
-e
Print all (including spurious) errors.
-l
Do not print reformatted sources to standard output.
If a file's formatting is different from gofmt's, print its name
to standard output.
-r rule
Apply the rewrite rule to the source before reformatting.
-s
Try to simplify code (after applying the rewrite rule, if any).
-w
Do not print reformatted sources to standard output.
If a file's formatting is different from gofmt's, overwrite it
with gofmt's version. If an error occurred during overwriting,
the original file is restored from an automatic backup.
Debugging support:
-cpuprofile filename
Write cpu profile to the specified file.
The rewrite rule specified with the -r flag must be a string of the form:
pattern -> replacement
Both pattern and replacement must be valid Go expressions.
In the pattern, single-character lowercase identifiers serve as
wildcards matching arbitrary sub-expressions; those expressions
will be substituted for the same identifiers in the replacement.
When gofmt reads from standard input, it accepts either a full Go program
or a program fragment. A program fragment must be a syntactically
valid declaration list, statement list, or expression. When formatting
such a fragment, gofmt preserves leading indentation as well as leading
and trailing spaces, so that individual sections of a Go program can be
formatted by piping them through gofmt.
# Examples
To check files for unnecessary parentheses:
gofmt -r '(a) -> a' -l *.go
To remove the parentheses:
gofmt -r '(a) -> a' -w *.go
To convert the package tree from explicit slice upper bounds to implicit ones:
gofmt -r 'Ξ±[Ξ²:len(Ξ±)] -> Ξ±[Ξ²:]' -w $GOROOT/src
# The simplify command
When invoked with -s gofmt will make the following source transformations where possible.
An array, slice, or map composite literal of the form:
[]T{T{}, T{}}
will be simplified to:
[]T{{}, {}}
A slice expression of the form:
s[a:len(s)]
will be simplified to:
s[a:]
A range of the form:
for x, _ = range v {...}
will be simplified to:
for x = range v {...}
A range of the form:
for _ = range v {...}
will be simplified to:
for range v {...}
This may result in changes that are incompatible with earlier versions of Go.
*/
package main
// BUG(rsc): The implementation of -r is a bit slow.
// BUG(gri): If -w fails, the restored original file may not have some of the
// original file attributes.
|
go/src/cmd/gofmt/doc.go/0
|
{
"file_path": "go/src/cmd/gofmt/doc.go",
"repo_id": "go",
"token_count": 915
}
| 146 |
package p
const (
// 0-octals
_ = 0
_ = 0123
_ = 0123456
_ = 0_123
_ = 0123_456
// decimals
_ = 1
_ = 1234
_ = 1234567
_ = 1_234
_ = 1_234_567
// hexadecimals
_ = 0x0
_ = 0x1234
_ = 0xcafef00d
_ = 0x0
_ = 0x1234
_ = 0xCAFEf00d
_ = 0x_0
_ = 0x_1234
_ = 0x_CAFE_f00d
// octals
_ = 0o0
_ = 0o1234
_ = 0o01234567
_ = 0o0
_ = 0o1234
_ = 0o01234567
_ = 0o_0
_ = 0o_1234
_ = 0o0123_4567
_ = 0o_0
_ = 0o_1234
_ = 0o0123_4567
// binaries
_ = 0b0
_ = 0b1011
_ = 0b00101101
_ = 0b0
_ = 0b1011
_ = 0b00101101
_ = 0b_0
_ = 0b10_11
_ = 0b_0010_1101
// decimal floats
_ = 0.
_ = 123.
_ = 0123.
_ = .0
_ = .123
_ = .0123
_ = 0e0
_ = 123e+0
_ = 0123e-1
_ = 0e-0
_ = 123e+0
_ = 0123e123
_ = 0.e+1
_ = 123.e-10
_ = 0123.e123
_ = .0e-1
_ = .123e+10
_ = .0123e123
_ = 0.0
_ = 123.123
_ = 0123.0123
_ = 0.0e1
_ = 123.123e-10
_ = 0123.0123e+456
_ = 1_2_3.
_ = 0_123.
_ = 0_0e0
_ = 1_2_3e0
_ = 0_123e0
_ = 0e-0_0
_ = 1_2_3e+0
_ = 0123e1_2_3
_ = 0.e+1
_ = 123.e-1_0
_ = 01_23.e123
_ = .0e-1
_ = .123e+10
_ = .0123e123
_ = 1_2_3.123
_ = 0123.01_23
// hexadecimal floats
_ = 0x0.p+0
_ = 0xdeadcafe.p-10
_ = 0x1234.p123
_ = 0x.1p-0
_ = 0x.deadcafep2
_ = 0x.1234p+10
_ = 0x0p0
_ = 0xdeadcafep+1
_ = 0x1234p-10
_ = 0x0.0p0
_ = 0xdead.cafep+1
_ = 0x12.34p-10
_ = 0xdead_cafep+1
_ = 0x_1234p-10
_ = 0x_dead_cafe.p-10
_ = 0x12_34.p1_2_3
_ = 0x1_2_3_4.p-1_2_3
// imaginaries
_ = 0i
_ = 0i
_ = 8i
_ = 0i
_ = 123i
_ = 123i
_ = 56789i
_ = 1234i
_ = 1234567i
_ = 0i
_ = 0i
_ = 8i
_ = 0i
_ = 123i
_ = 123i
_ = 56_789i
_ = 1_234i
_ = 1_234_567i
_ = 0.i
_ = 123.i
_ = 0123.i
_ = 000123.i
_ = 0e0i
_ = 123e0i
_ = 0123e0i
_ = 000123e0i
_ = 0.e+1i
_ = 123.e-1_0i
_ = 01_23.e123i
_ = 00_01_23.e123i
_ = 0b1010i
_ = 0b1010i
_ = 0o660i
_ = 0o660i
_ = 0xabcDEFi
_ = 0xabcDEFi
_ = 0xabcDEFp0i
_ = 0xabcDEFp0i
)
|
go/src/cmd/gofmt/testdata/go2numbers.golden/0
|
{
"file_path": "go/src/cmd/gofmt/testdata/go2numbers.golden",
"repo_id": "go",
"token_count": 1264
}
| 147 |
//gofmt -r=(x)->x
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Rewriting of parenthesized expressions (x) -> x
// must not drop parentheses if that would lead to
// wrong association of the operands.
// Was issue 1847.
package main
// From example 1 of issue 1847.
func _() {
var t = (&T{1000}).Id()
}
// From example 2 of issue 1847.
func _() {
fmt.Println((*xpp).a)
}
// Some more test cases.
func _() {
_ = (-x).f
_ = (*x).f
_ = (&x).f
_ = (!x).f
_ = -x.f
_ = *x.f
_ = &x.f
_ = !x.f
(-x).f()
(*x).f()
(&x).f()
(!x).f()
_ = -x.f()
_ = *x.f()
_ = &x.f()
_ = !x.f()
_ = (-x).f
_ = (*x).f
_ = (&x).f
_ = (!x).f
_ = -x.f
_ = *x.f
_ = &x.f
_ = !x.f
(-x).f()
(*x).f()
(&x).f()
(!x).f()
_ = -x.f()
_ = *x.f()
_ = &x.f()
_ = !x.f()
_ = -x.f
_ = *x.f
_ = &x.f
_ = !x.f
_ = -x.f
_ = *x.f
_ = &x.f
_ = !x.f
_ = -x.f()
_ = *x.f()
_ = &x.f()
_ = !x.f()
_ = -x.f()
_ = *x.f()
_ = &x.f()
_ = !x.f()
}
|
go/src/cmd/gofmt/testdata/rewrite4.golden/0
|
{
"file_path": "go/src/cmd/gofmt/testdata/rewrite4.golden",
"repo_id": "go",
"token_count": 572
}
| 148 |
//gofmt -stdin
var x int
func f() {
y := z
/* this is a comment */
// this is a comment too
}
|
go/src/cmd/gofmt/testdata/stdin2.golden/0
|
{
"file_path": "go/src/cmd/gofmt/testdata/stdin2.golden",
"repo_id": "go",
"token_count": 43
}
| 149 |
// Copyright 2020 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//gofmt
package typeparams
type T[P any] struct{}
type T[P1, P2, P3 any] struct{}
type T[P C] struct{}
type T[P1, P2, P3 C] struct{}
type T[P C[P]] struct{}
type T[P1, P2, P3 C[P1, P2, P3]] struct{}
func f[P any](x P)
func f[P1, P2, P3 any](x1 P1, x2 P2, x3 P3) struct{}
func f[P interface{}](x P)
func f[P1, P2, P3 interface {
m1(P1)
~P2 | ~P3
}](x1 P1, x2 P2, x3 P3) struct{}
func f[P any](T1[P], T2[P]) T3[P]
func (x T[P]) m()
func (T[P]) m(x T[P]) P
func _() {
type _ []T[P]
var _ []T[P]
_ = []T[P]{}
}
|
go/src/cmd/gofmt/testdata/typeparams.golden/0
|
{
"file_path": "go/src/cmd/gofmt/testdata/typeparams.golden",
"repo_id": "go",
"token_count": 339
}
| 150 |
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package bio
import (
"io"
"log"
)
// MustClose closes Closer c and calls log.Fatal if it returns a non-nil error.
func MustClose(c io.Closer) {
if err := c.Close(); err != nil {
log.Fatal(err)
}
}
// MustWriter returns a Writer that wraps the provided Writer,
// except that it calls log.Fatal instead of returning a non-nil error.
func MustWriter(w io.Writer) io.Writer {
return mustWriter{w}
}
type mustWriter struct {
w io.Writer
}
func (w mustWriter) Write(b []byte) (int, error) {
n, err := w.w.Write(b)
if err != nil {
log.Fatal(err)
}
return n, nil
}
func (w mustWriter) WriteString(s string) (int, error) {
n, err := io.WriteString(w.w, s)
if err != nil {
log.Fatal(err)
}
return n, nil
}
|
go/src/cmd/internal/bio/must.go/0
|
{
"file_path": "go/src/cmd/internal/bio/must.go",
"repo_id": "go",
"token_count": 323
}
| 151 |
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package cov_test
import (
"cmd/internal/cov"
"fmt"
"internal/coverage"
"internal/coverage/decodecounter"
"internal/coverage/decodemeta"
"internal/coverage/pods"
"internal/goexperiment"
"internal/testenv"
"os"
"path/filepath"
"testing"
)
// visitor implements the CovDataVisitor interface in a very stripped
// down way, just keeps track of interesting events.
type visitor struct {
metaFileCount int
counterFileCount int
funcCounterData int
metaFuncCount int
}
func (v *visitor) BeginPod(p pods.Pod) {}
func (v *visitor) EndPod(p pods.Pod) {}
func (v *visitor) VisitMetaDataFile(mdf string, mfr *decodemeta.CoverageMetaFileReader) {
v.metaFileCount++
}
func (v *visitor) BeginCounterDataFile(cdf string, cdr *decodecounter.CounterDataReader, dirIdx int) {
v.counterFileCount++
}
func (v *visitor) EndCounterDataFile(cdf string, cdr *decodecounter.CounterDataReader, dirIdx int) {}
func (v *visitor) VisitFuncCounterData(payload decodecounter.FuncPayload) { v.funcCounterData++ }
func (v *visitor) EndCounters() {}
func (v *visitor) BeginPackage(pd *decodemeta.CoverageMetaDataDecoder, pkgIdx uint32) {}
func (v *visitor) EndPackage(pd *decodemeta.CoverageMetaDataDecoder, pkgIdx uint32) {}
func (v *visitor) VisitFunc(pkgIdx uint32, fnIdx uint32, fd *coverage.FuncDesc) { v.metaFuncCount++ }
func (v *visitor) Finish() {}
func TestIssue58411(t *testing.T) {
testenv.MustHaveGoBuild(t)
if !goexperiment.CoverageRedesign {
t.Skipf("skipping since this test requires 'go build -cover'")
}
// Build a tiny test program with -cover. Smallness is important;
// it is one of the factors that triggers issue 58411.
d := t.TempDir()
exepath := filepath.Join(d, "small.exe")
path := filepath.Join("testdata", "small.go")
cmd := testenv.Command(t, testenv.GoToolPath(t), "build",
"-o", exepath, "-cover", path)
b, err := cmd.CombinedOutput()
if len(b) != 0 {
t.Logf("## build output:\n%s", b)
}
if err != nil {
t.Fatalf("build error: %v", err)
}
// Run to produce coverage data. Note the large argument; we need a large
// argument (more than 4k) to trigger the bug, but the overall file
// has to remain small (since large files will be read with mmap).
covdir := filepath.Join(d, "covdata")
if err = os.Mkdir(covdir, 0777); err != nil {
t.Fatalf("creating covdir: %v", err)
}
large := fmt.Sprintf("%07999d", 0)
cmd = testenv.Command(t, exepath, "1", "2", "3", large)
cmd.Dir = covdir
cmd.Env = append(os.Environ(), "GOCOVERDIR="+covdir)
b, err = cmd.CombinedOutput()
if err != nil {
t.Logf("## run output:\n%s", b)
t.Fatalf("build error: %v", err)
}
vis := &visitor{}
// Read resulting coverage data. Without the fix, this would
// yield a "short read" error.
const verbosityLevel = 0
const flags = 0
cdr := cov.MakeCovDataReader(vis, []string{covdir}, verbosityLevel, flags, nil)
err = cdr.Visit()
if err != nil {
t.Fatalf("visit failed: %v", err)
}
// make sure we saw a few things just for grins
const want = "{metaFileCount:1 counterFileCount:1 funcCounterData:1 metaFuncCount:1}"
got := fmt.Sprintf("%+v", *vis)
if want != got {
t.Errorf("visitor contents: want %v got %v\n", want, got)
}
}
|
go/src/cmd/internal/cov/read_test.go/0
|
{
"file_path": "go/src/cmd/internal/cov/read_test.go",
"repo_id": "go",
"token_count": 1456
}
| 152 |
// Copyright 2020 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package goobj
import (
"bufio"
"bytes"
"fmt"
"internal/buildcfg"
"internal/testenv"
"os"
"testing"
"cmd/internal/bio"
"cmd/internal/objabi"
)
func dummyWriter(buf *bytes.Buffer) *Writer {
wr := &bio.Writer{Writer: bufio.NewWriter(buf)} // hacky: no file, so cannot seek
return NewWriter(wr)
}
func TestReadWrite(t *testing.T) {
// Test that we get the same data in a write-read roundtrip.
// Write a symbol, a relocation, and an aux info.
var buf bytes.Buffer
w := dummyWriter(&buf)
var s Sym
s.SetABI(1)
s.SetType(uint8(objabi.STEXT))
s.SetFlag(0x12)
s.SetSiz(12345)
s.SetAlign(8)
s.Write(w)
var r Reloc
r.SetOff(12)
r.SetSiz(4)
r.SetType(uint16(objabi.R_ADDR))
r.SetAdd(54321)
r.SetSym(SymRef{11, 22})
r.Write(w)
var a Aux
a.SetType(AuxFuncInfo)
a.SetSym(SymRef{33, 44})
a.Write(w)
w.wr.Flush()
// Read them back and check.
b := buf.Bytes()
var s2 Sym
s2.fromBytes(b)
if s2.ABI() != 1 || s2.Type() != uint8(objabi.STEXT) || s2.Flag() != 0x12 || s2.Siz() != 12345 || s2.Align() != 8 {
t.Errorf("read Sym2 mismatch: got %v %v %v %v %v", s2.ABI(), s2.Type(), s2.Flag(), s2.Siz(), s2.Align())
}
b = b[SymSize:]
var r2 Reloc
r2.fromBytes(b)
if r2.Off() != 12 || r2.Siz() != 4 || r2.Type() != uint16(objabi.R_ADDR) || r2.Add() != 54321 || r2.Sym() != (SymRef{11, 22}) {
t.Errorf("read Reloc2 mismatch: got %v %v %v %v %v", r2.Off(), r2.Siz(), r2.Type(), r2.Add(), r2.Sym())
}
b = b[RelocSize:]
var a2 Aux
a2.fromBytes(b)
if a2.Type() != AuxFuncInfo || a2.Sym() != (SymRef{33, 44}) {
t.Errorf("read Aux2 mismatch: got %v %v", a2.Type(), a2.Sym())
}
}
var issue41621prolog = `
package main
var lines = []string{
`
var issue41621epilog = `
}
func getLines() []string {
return lines
}
func main() {
println(getLines())
}
`
func TestIssue41621LargeNumberOfRelocations(t *testing.T) {
if testing.Short() || (buildcfg.GOARCH != "amd64") {
t.Skipf("Skipping large number of relocations test in short mode or on %s", buildcfg.GOARCH)
}
testenv.MustHaveGoBuild(t)
tmpdir, err := os.MkdirTemp("", "lotsofrelocs")
if err != nil {
t.Fatalf("can't create temp directory: %v\n", err)
}
defer os.RemoveAll(tmpdir)
// Emit testcase.
var w bytes.Buffer
fmt.Fprintf(&w, issue41621prolog)
for i := 0; i < 1048576+13; i++ {
fmt.Fprintf(&w, "\t\"%d\",\n", i)
}
fmt.Fprintf(&w, issue41621epilog)
err = os.WriteFile(tmpdir+"/large.go", w.Bytes(), 0666)
if err != nil {
t.Fatalf("can't write output: %v\n", err)
}
// Emit go.mod
w.Reset()
fmt.Fprintf(&w, "module issue41621\n\ngo 1.12\n")
err = os.WriteFile(tmpdir+"/go.mod", w.Bytes(), 0666)
if err != nil {
t.Fatalf("can't write output: %v\n", err)
}
w.Reset()
// Build.
cmd := testenv.Command(t, testenv.GoToolPath(t), "build", "-o", "large")
cmd.Dir = tmpdir
out, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("Build failed: %v, output: %s", err, out)
}
}
|
go/src/cmd/internal/goobj/objfile_test.go/0
|
{
"file_path": "go/src/cmd/internal/goobj/objfile_test.go",
"repo_id": "go",
"token_count": 1364
}
| 153 |
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package arm
var cnames5 = []string{
"NONE",
"REG",
"REGREG",
"REGREG2",
"REGLIST",
"SHIFT",
"SHIFTADDR",
"FREG",
"PSR",
"FCR",
"SPR",
"RCON",
"NCON",
"RCON2A",
"RCON2S",
"SCON",
"LCON",
"LCONADDR",
"ZFCON",
"SFCON",
"LFCON",
"RACON",
"LACON",
"SBRA",
"LBRA",
"HAUTO",
"FAUTO",
"HFAUTO",
"SAUTO",
"LAUTO",
"HOREG",
"FOREG",
"HFOREG",
"SOREG",
"ROREG",
"SROREG",
"LOREG",
"PC",
"SP",
"HREG",
"ADDR",
"C_TLS_LE",
"C_TLS_IE",
"TEXTSIZE",
"GOK",
"NCLASS",
"SCOND = (1<<4)-1",
"SBIT = 1<<4",
"PBIT = 1<<5",
"WBIT = 1<<6",
"FBIT = 1<<7",
"UBIT = 1<<7",
"SCOND_XOR = 14",
"SCOND_EQ = 0 ^ C_SCOND_XOR",
"SCOND_NE = 1 ^ C_SCOND_XOR",
"SCOND_HS = 2 ^ C_SCOND_XOR",
"SCOND_LO = 3 ^ C_SCOND_XOR",
"SCOND_MI = 4 ^ C_SCOND_XOR",
"SCOND_PL = 5 ^ C_SCOND_XOR",
"SCOND_VS = 6 ^ C_SCOND_XOR",
"SCOND_VC = 7 ^ C_SCOND_XOR",
"SCOND_HI = 8 ^ C_SCOND_XOR",
"SCOND_LS = 9 ^ C_SCOND_XOR",
"SCOND_GE = 10 ^ C_SCOND_XOR",
"SCOND_LT = 11 ^ C_SCOND_XOR",
"SCOND_GT = 12 ^ C_SCOND_XOR",
"SCOND_LE = 13 ^ C_SCOND_XOR",
"SCOND_NONE = 14 ^ C_SCOND_XOR",
"SCOND_NV = 15 ^ C_SCOND_XOR",
}
|
go/src/cmd/internal/obj/arm/anames5.go/0
|
{
"file_path": "go/src/cmd/internal/obj/arm/anames5.go",
"repo_id": "go",
"token_count": 732
}
| 154 |
// Derived from Inferno utils/6l/obj.c and utils/6l/span.c
// https://bitbucket.org/inferno-os/inferno-os/src/master/utils/6l/obj.c
// https://bitbucket.org/inferno-os/inferno-os/src/master/utils/6l/span.c
//
// Copyright Β© 1994-1999 Lucent Technologies Inc. All rights reserved.
// Portions Copyright Β© 1995-1997 C H Forsyth (forsyth@terzarima.net)
// Portions Copyright Β© 1997-1999 Vita Nuova Limited
// Portions Copyright Β© 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com)
// Portions Copyright Β© 2004,2006 Bruce Ellis
// Portions Copyright Β© 2005-2007 C H Forsyth (forsyth@terzarima.net)
// Revisions Copyright Β© 2000-2007 Lucent Technologies Inc. and others
// Portions Copyright Β© 2009 The Go Authors. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package obj
import (
"cmd/internal/objabi"
"log"
"math"
)
// Grow increases the length of s.P to lsiz.
func (s *LSym) Grow(lsiz int64) {
siz := int(lsiz)
if int64(siz) != lsiz {
log.Fatalf("LSym.Grow size %d too long", lsiz)
}
if len(s.P) >= siz {
return
}
s.P = append(s.P, make([]byte, siz-len(s.P))...)
}
// GrowCap increases the capacity of s.P to c.
func (s *LSym) GrowCap(c int64) {
if int64(cap(s.P)) >= c {
return
}
if s.P == nil {
s.P = make([]byte, 0, c)
return
}
b := make([]byte, len(s.P), c)
copy(b, s.P)
s.P = b
}
// prepwrite prepares to write data of size siz into s at offset off.
func (s *LSym) prepwrite(ctxt *Link, off int64, siz int) {
if off < 0 || siz < 0 || off >= 1<<30 {
ctxt.Diag("prepwrite: bad off=%d siz=%d s=%v", off, siz, s)
}
switch s.Type {
case objabi.Sxxx, objabi.SBSS:
s.Type = objabi.SDATA
case objabi.SNOPTRBSS:
s.Type = objabi.SNOPTRDATA
case objabi.STLSBSS:
ctxt.Diag("cannot supply data for %v var %v", s.Type, s.Name)
}
l := off + int64(siz)
s.Grow(l)
if l > s.Size {
s.Size = l
}
}
// WriteFloat32 writes f into s at offset off.
func (s *LSym) WriteFloat32(ctxt *Link, off int64, f float32) {
s.prepwrite(ctxt, off, 4)
ctxt.Arch.ByteOrder.PutUint32(s.P[off:], math.Float32bits(f))
}
// WriteFloat64 writes f into s at offset off.
func (s *LSym) WriteFloat64(ctxt *Link, off int64, f float64) {
s.prepwrite(ctxt, off, 8)
ctxt.Arch.ByteOrder.PutUint64(s.P[off:], math.Float64bits(f))
}
// WriteInt writes an integer i of size siz into s at offset off.
func (s *LSym) WriteInt(ctxt *Link, off int64, siz int, i int64) {
s.prepwrite(ctxt, off, siz)
switch siz {
default:
ctxt.Diag("WriteInt: bad integer size: %d", siz)
case 1:
s.P[off] = byte(i)
case 2:
ctxt.Arch.ByteOrder.PutUint16(s.P[off:], uint16(i))
case 4:
ctxt.Arch.ByteOrder.PutUint32(s.P[off:], uint32(i))
case 8:
ctxt.Arch.ByteOrder.PutUint64(s.P[off:], uint64(i))
}
}
func (s *LSym) writeAddr(ctxt *Link, off int64, siz int, rsym *LSym, roff int64, rtype objabi.RelocType) {
// Allow 4-byte addresses for DWARF.
if siz != ctxt.Arch.PtrSize && siz != 4 {
ctxt.Diag("WriteAddr: bad address size %d in %s", siz, s.Name)
}
s.prepwrite(ctxt, off, siz)
r := Addrel(s)
r.Off = int32(off)
if int64(r.Off) != off {
ctxt.Diag("WriteAddr: off overflow %d in %s", off, s.Name)
}
r.Siz = uint8(siz)
r.Sym = rsym
r.Type = rtype
r.Add = roff
}
// WriteAddr writes an address of size siz into s at offset off.
// rsym and roff specify the relocation for the address.
func (s *LSym) WriteAddr(ctxt *Link, off int64, siz int, rsym *LSym, roff int64) {
s.writeAddr(ctxt, off, siz, rsym, roff, objabi.R_ADDR)
}
// WriteWeakAddr writes an address of size siz into s at offset off.
// rsym and roff specify the relocation for the address.
// This is a weak reference.
func (s *LSym) WriteWeakAddr(ctxt *Link, off int64, siz int, rsym *LSym, roff int64) {
s.writeAddr(ctxt, off, siz, rsym, roff, objabi.R_WEAKADDR)
}
// WriteCURelativeAddr writes a pointer-sized address into s at offset off.
// rsym and roff specify the relocation for the address which will be
// resolved by the linker to an offset from the DW_AT_low_pc attribute of
// the DWARF Compile Unit of rsym.
func (s *LSym) WriteCURelativeAddr(ctxt *Link, off int64, rsym *LSym, roff int64) {
s.writeAddr(ctxt, off, ctxt.Arch.PtrSize, rsym, roff, objabi.R_ADDRCUOFF)
}
// WriteOff writes a 4 byte offset to rsym+roff into s at offset off.
// After linking the 4 bytes stored at s+off will be
// rsym+roff-(start of section that s is in).
func (s *LSym) WriteOff(ctxt *Link, off int64, rsym *LSym, roff int64) {
s.prepwrite(ctxt, off, 4)
r := Addrel(s)
r.Off = int32(off)
if int64(r.Off) != off {
ctxt.Diag("WriteOff: off overflow %d in %s", off, s.Name)
}
r.Siz = 4
r.Sym = rsym
r.Type = objabi.R_ADDROFF
r.Add = roff
}
// WriteWeakOff writes a weak 4 byte offset to rsym+roff into s at offset off.
// After linking the 4 bytes stored at s+off will be
// rsym+roff-(start of section that s is in).
func (s *LSym) WriteWeakOff(ctxt *Link, off int64, rsym *LSym, roff int64) {
s.prepwrite(ctxt, off, 4)
r := Addrel(s)
r.Off = int32(off)
if int64(r.Off) != off {
ctxt.Diag("WriteOff: off overflow %d in %s", off, s.Name)
}
r.Siz = 4
r.Sym = rsym
r.Type = objabi.R_WEAKADDROFF
r.Add = roff
}
// WriteString writes a string of size siz into s at offset off.
func (s *LSym) WriteString(ctxt *Link, off int64, siz int, str string) {
if siz < len(str) {
ctxt.Diag("WriteString: bad string size: %d < %d", siz, len(str))
}
s.prepwrite(ctxt, off, siz)
copy(s.P[off:off+int64(siz)], str)
}
// WriteBytes writes a slice of bytes into s at offset off.
func (s *LSym) WriteBytes(ctxt *Link, off int64, b []byte) int64 {
s.prepwrite(ctxt, off, len(b))
copy(s.P[off:], b)
return off + int64(len(b))
}
func Addrel(s *LSym) *Reloc {
if s.R == nil {
s.R = make([]Reloc, 0, 4)
}
s.R = append(s.R, Reloc{})
return &s.R[len(s.R)-1]
}
|
go/src/cmd/internal/obj/data.go/0
|
{
"file_path": "go/src/cmd/internal/obj/data.go",
"repo_id": "go",
"token_count": 2718
}
| 155 |
// Code generated by stringer -i a.out.go -o anames.go -p mips; DO NOT EDIT.
package mips
import "cmd/internal/obj"
var Anames = []string{
obj.A_ARCHSPECIFIC: "ABSD",
"ABSF",
"ABSW",
"ADD",
"ADDD",
"ADDF",
"ADDU",
"ADDW",
"AND",
"BEQ",
"BFPF",
"BFPT",
"BGEZ",
"BGEZAL",
"BGTZ",
"BLEZ",
"BLTZ",
"BLTZAL",
"BNE",
"BREAK",
"CLO",
"CLZ",
"CMOVF",
"CMOVN",
"CMOVT",
"CMOVZ",
"CMPEQD",
"CMPEQF",
"CMPGED",
"CMPGEF",
"CMPGTD",
"CMPGTF",
"DIV",
"DIVD",
"DIVF",
"DIVU",
"DIVW",
"GOK",
"LL",
"LLV",
"LUI",
"MADD",
"MOVB",
"MOVBU",
"MOVD",
"MOVDF",
"MOVDW",
"MOVF",
"MOVFD",
"MOVFW",
"MOVH",
"MOVHU",
"MOVW",
"MOVWD",
"MOVWF",
"MOVWL",
"MOVWR",
"MSUB",
"MUL",
"MULD",
"MULF",
"MULU",
"MULW",
"NEGD",
"NEGF",
"NEGW",
"NEGV",
"NOOP",
"NOR",
"OR",
"REM",
"REMU",
"RFE",
"ROTR",
"ROTRV",
"SC",
"SCV",
"SEB",
"SEH",
"SGT",
"SGTU",
"SLL",
"SQRTD",
"SQRTF",
"SRA",
"SRL",
"SUB",
"SUBD",
"SUBF",
"SUBU",
"SUBW",
"SYNC",
"SYSCALL",
"TEQ",
"TLBP",
"TLBR",
"TLBWI",
"TLBWR",
"TNE",
"WORD",
"WSBH",
"XOR",
"MOVV",
"MOVVL",
"MOVVR",
"SLLV",
"SRAV",
"SRLV",
"DIVV",
"DIVVU",
"REMV",
"REMVU",
"MULV",
"MULVU",
"ADDV",
"ADDVU",
"SUBV",
"SUBVU",
"DSBH",
"DSHD",
"TRUNCFV",
"TRUNCDV",
"TRUNCFW",
"TRUNCDW",
"MOVWU",
"MOVFV",
"MOVDV",
"MOVVF",
"MOVVD",
"VMOVB",
"VMOVH",
"VMOVW",
"VMOVD",
"LAST",
}
|
go/src/cmd/internal/obj/mips/anames.go/0
|
{
"file_path": "go/src/cmd/internal/obj/mips/anames.go",
"repo_id": "go",
"token_count": 962
}
| 156 |
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
/*
Package ppc64 implements a PPC64 assembler that assembles Go asm into
the corresponding PPC64 instructions as defined by the Power ISA 3.0B.
This document provides information on how to write code in Go assembler
for PPC64, focusing on the differences between Go and PPC64 assembly language.
It assumes some knowledge of PPC64 assembler. The original implementation of
PPC64 in Go defined many opcodes that are different from PPC64 opcodes, but
updates to the Go assembly language used mnemonics that are mostly similar if not
identical to the PPC64 mneumonics, such as VMX and VSX instructions. Not all detail
is included here; refer to the Power ISA document if interested in more detail.
Starting with Go 1.15 the Go objdump supports the -gnu option, which provides a
side by side view of the Go assembler and the PPC64 assembler output. This is
extremely helpful in determining what final PPC64 assembly is generated from the
corresponding Go assembly.
In the examples below, the Go assembly is on the left, PPC64 assembly on the right.
1. Operand ordering
In Go asm, the last operand (right) is the target operand, but with PPC64 asm,
the first operand (left) is the target. The order of the remaining operands is
not consistent: in general opcodes with 3 operands that perform math or logical
operations have their operands in reverse order. Opcodes for vector instructions
and those with more than 3 operands usually have operands in the same order except
for the target operand, which is first in PPC64 asm and last in Go asm.
Example:
ADD R3, R4, R5 <=> add r5, r4, r3
2. Constant operands
In Go asm, an operand that starts with '$' indicates a constant value. If the
instruction using the constant has an immediate version of the opcode, then an
immediate value is used with the opcode if possible.
Example:
ADD $1, R3, R4 <=> addi r4, r3, 1
3. Opcodes setting condition codes
In PPC64 asm, some instructions other than compares have variations that can set
the condition code where meaningful. This is indicated by adding '.' to the end
of the PPC64 instruction. In Go asm, these instructions have 'CC' at the end of
the opcode. The possible settings of the condition code depend on the instruction.
CR0 is the default for fixed-point instructions; CR1 for floating point; CR6 for
vector instructions.
Example:
ANDCC R3, R4, R5 <=> and. r5, r3, r4 (set CR0)
4. Loads and stores from memory
In Go asm, opcodes starting with 'MOV' indicate a load or store. When the target
is a memory reference, then it is a store; when the target is a register and the
source is a memory reference, then it is a load.
MOV{B,H,W,D} variations identify the size as byte, halfword, word, doubleword.
Adding 'Z' to the opcode for a load indicates zero extend; if omitted it is sign extend.
Adding 'U' to a load or store indicates an update of the base register with the offset.
Adding 'BR' to an opcode indicates byte-reversed load or store, or the order opposite
of the expected endian order. If 'BR' is used then zero extend is assumed.
Memory references n(Ra) indicate the address in Ra + n. When used with an update form
of an opcode, the value in Ra is incremented by n.
Memory references (Ra+Rb) or (Ra)(Rb) indicate the address Ra + Rb, used by indexed
loads or stores. Both forms are accepted. When used with an update then the base register
is updated by the value in the index register.
Examples:
MOVD (R3), R4 <=> ld r4,0(r3)
MOVW (R3), R4 <=> lwa r4,0(r3)
MOVWZU 4(R3), R4 <=> lwzu r4,4(r3)
MOVWZ (R3+R5), R4 <=> lwzx r4,r3,r5
MOVHZ (R3), R4 <=> lhz r4,0(r3)
MOVHU 2(R3), R4 <=> lhau r4,2(r3)
MOVBZ (R3), R4 <=> lbz r4,0(r3)
MOVD R4,(R3) <=> std r4,0(r3)
MOVW R4,(R3) <=> stw r4,0(r3)
MOVW R4,(R3+R5) <=> stwx r4,r3,r5
MOVWU R4,4(R3) <=> stwu r4,4(r3)
MOVH R4,2(R3) <=> sth r4,2(r3)
MOVBU R4,(R3)(R5) <=> stbux r4,r3,r5
4. Compares
When an instruction does a compare or other operation that might
result in a condition code, then the resulting condition is set
in a field of the condition register. The condition register consists
of 8 4-bit fields named CR0 - CR7. When a compare instruction
identifies a CR then the resulting condition is set in that field
to be read by a later branch or isel instruction. Within these fields,
bits are set to indicate less than, greater than, or equal conditions.
Once an instruction sets a condition, then a subsequent branch, isel or
other instruction can read the condition field and operate based on the
bit settings.
Examples:
CMP R3, R4 <=> cmp r3, r4 (CR0 assumed)
CMP R3, R4, CR1 <=> cmp cr1, r3, r4
Note that the condition register is the target operand of compare opcodes, so
the remaining operands are in the same order for Go asm and PPC64 asm.
When CR0 is used then it is implicit and does not need to be specified.
5. Branches
Many branches are represented as a form of the BC instruction. There are
other extended opcodes to make it easier to see what type of branch is being
used.
The following is a brief description of the BC instruction and its commonly
used operands.
BC op1, op2, op3
op1: type of branch
16 -> bctr (branch on ctr)
12 -> bcr (branch if cr bit is set)
8 -> bcr+bctr (branch on ctr and cr values)
4 -> bcr != 0 (branch if specified cr bit is not set)
There are more combinations but these are the most common.
op2: condition register field and condition bit
This contains an immediate value indicating which condition field
to read and what bits to test. Each field is 4 bits long with CR0
at bit 0, CR1 at bit 4, etc. The value is computed as 4*CR+condition
with these condition values:
0 -> LT
1 -> GT
2 -> EQ
3 -> OVG
Thus 0 means test CR0 for LT, 5 means CR1 for GT, 30 means CR7 for EQ.
op3: branch target
Examples:
BC 12, 0, target <=> blt cr0, target
BC 12, 2, target <=> beq cr0, target
BC 12, 5, target <=> bgt cr1, target
BC 12, 30, target <=> beq cr7, target
BC 4, 6, target <=> bne cr1, target
BC 4, 1, target <=> ble cr1, target
The following extended opcodes are available for ease of use and readability:
BNE CR2, target <=> bne cr2, target
BEQ CR4, target <=> beq cr4, target
BLT target <=> blt target (cr0 default)
BGE CR7, target <=> bge cr7, target
Refer to the ISA for more information on additional values for the BC instruction,
how to handle OVG information, and much more.
5. Align directive
Starting with Go 1.12, Go asm supports the PCALIGN directive, which indicates
that the next instruction should be aligned to the specified value. Currently
8 and 16 are the only supported values, and a maximum of 2 NOPs will be added
to align the code. That means in the case where the code is aligned to 4 but
PCALIGN $16 is at that location, the code will only be aligned to 8 to avoid
adding 3 NOPs.
The purpose of this directive is to improve performance for cases like loops
where better alignment (8 or 16 instead of 4) might be helpful. This directive
exists in PPC64 assembler and is frequently used by PPC64 assembler writers.
PCALIGN $16
PCALIGN $8
By default, functions in Go are aligned to 16 bytes, as is the case in all
other compilers for PPC64. If there is a PCALIGN directive requesting alignment
greater than 16, then the alignment of the containing function must be
promoted to that same alignment or greater.
The behavior of PCALIGN is changed in Go 1.21 to be more straightforward to
ensure the alignment required for some instructions in power10. The acceptable
values are 8, 16, 32 and 64, and the use of those values will always provide the
specified alignment.
6. Shift instructions
The simple scalar shifts on PPC64 expect a shift count that fits in 5 bits for
32-bit values or 6 bit for 64-bit values. If the shift count is a constant value
greater than the max then the assembler sets it to the max for that size (31 for
32 bit values, 63 for 64 bit values). If the shift count is in a register, then
only the low 5 or 6 bits of the register will be used as the shift count. The
Go compiler will add appropriate code to compare the shift value to achieve the
correct result, and the assembler does not add extra checking.
Examples:
SRAD $8,R3,R4 => sradi r4,r3,8
SRD $8,R3,R4 => rldicl r4,r3,56,8
SLD $8,R3,R4 => rldicr r4,r3,8,55
SRAW $16,R4,R5 => srawi r5,r4,16
SRW $40,R4,R5 => rlwinm r5,r4,0,0,31
SLW $12,R4,R5 => rlwinm r5,r4,12,0,19
Some non-simple shifts have operands in the Go assembly which don't map directly
onto operands in the PPC64 assembly. When an operand in a shift instruction in the
Go assembly is a bit mask, that mask is represented as a start and end bit in the
PPC64 assembly instead of a mask. See the ISA for more detail on these types of shifts.
Here are a few examples:
RLWMI $7,R3,$65535,R6 => rlwimi r6,r3,7,16,31
RLDMI $0,R4,$7,R6 => rldimi r6,r4,0,61
More recently, Go opcodes were added which map directly onto the PPC64 opcodes. It is
recommended to use the newer opcodes to avoid confusion.
RLDICL $0,R4,$15,R6 => rldicl r6,r4,0,15
RLDICR $0,R4,$15,R6 => rldicr r6.r4,0,15
# Register naming
1. Special register usage in Go asm
The following registers should not be modified by user Go assembler code.
R0: Go code expects this register to contain the value 0.
R1: Stack pointer
R2: TOC pointer when compiled with -shared or -dynlink (a.k.a position independent code)
R13: TLS pointer
R30: g (goroutine)
Register names:
Rn is used for general purpose registers. (0-31)
Fn is used for floating point registers. (0-31)
Vn is used for vector registers. Slot 0 of Vn overlaps with Fn. (0-31)
VSn is used for vector-scalar registers. V0-V31 overlap with VS32-VS63. (0-63)
CTR represents the count register.
LR represents the link register.
CR represents the condition register
CRn represents a condition register field. (0-7)
CRnLT represents CR bit 0 of CR field n. (0-7)
CRnGT represents CR bit 1 of CR field n. (0-7)
CRnEQ represents CR bit 2 of CR field n. (0-7)
CRnSO represents CR bit 3 of CR field n. (0-7)
# GOPPC64 >= power10 and its effects on Go asm
When GOPPC64=power10 is used to compile a Go program for ppc64le/linux, MOV*, FMOV*, and ADD
opcodes which would require 2 or more machine instructions to emulate a 32 bit constant, or
symbolic reference are implemented using prefixed instructions.
A user who wishes granular control over the generated machine code is advised to use Go asm
opcodes which explicitly translate to one PPC64 machine instruction. Most common opcodes
are supported.
Some examples of how pseudo-op assembly changes with GOPPC64:
Go asm GOPPC64 <= power9 GOPPC64 >= power10
MOVD mypackageΒ·foo(SB), R3 addis r2, r3, ... pld r3, ...
ld r3, r3, ...
MOVD 131072(R3), R4 addis r31, r4, 2 pld r4, 131072(r3)
ld r4, 0(R3)
ADD $131073, R3 lis r31, 2 paddi r3, r3, 131073
addi r31, 1
add r3,r31,r3
MOVD $131073, R3 lis r3, 2 pli r3, 131073
addi r3, 1
MOVD $mypackageΒ·foo(SB), R3 addis r2, r3, ... pla r3, ...
addi r3, r3, ...
*/
package ppc64
|
go/src/cmd/internal/obj/ppc64/doc.go/0
|
{
"file_path": "go/src/cmd/internal/obj/ppc64/doc.go",
"repo_id": "go",
"token_count": 4043
}
| 157 |
// Inferno utils/6l/span.c
// https://bitbucket.org/inferno-os/inferno-os/src/master/utils/6l/span.c
//
// Copyright Β© 1994-1999 Lucent Technologies Inc. All rights reserved.
// Portions Copyright Β© 1995-1997 C H Forsyth (forsyth@terzarima.net)
// Portions Copyright Β© 1997-1999 Vita Nuova Limited
// Portions Copyright Β© 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com)
// Portions Copyright Β© 2004,2006 Bruce Ellis
// Portions Copyright Β© 2005-2007 C H Forsyth (forsyth@terzarima.net)
// Revisions Copyright Β© 2000-2007 Lucent Technologies Inc. and others
// Portions Copyright Β© 2009 The Go Authors. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package x86
import (
"cmd/internal/obj"
"cmd/internal/objabi"
"cmd/internal/sys"
"encoding/binary"
"fmt"
"internal/buildcfg"
"log"
"strings"
)
var (
plan9privates *obj.LSym
)
// Instruction layout.
// Loop alignment constants:
// want to align loop entry to loopAlign-byte boundary,
// and willing to insert at most maxLoopPad bytes of NOP to do so.
// We define a loop entry as the target of a backward jump.
//
// gcc uses maxLoopPad = 10 for its 'generic x86-64' config,
// and it aligns all jump targets, not just backward jump targets.
//
// As of 6/1/2012, the effect of setting maxLoopPad = 10 here
// is very slight but negative, so the alignment is disabled by
// setting MaxLoopPad = 0. The code is here for reference and
// for future experiments.
const (
loopAlign = 16
maxLoopPad = 0
)
// Bit flags that are used to express jump target properties.
const (
// branchBackwards marks targets that are located behind.
// Used to express jumps to loop headers.
branchBackwards = (1 << iota)
// branchShort marks branches those target is close,
// with offset is in -128..127 range.
branchShort
// branchLoopHead marks loop entry.
// Used to insert padding for misaligned loops.
branchLoopHead
)
// opBytes holds optab encoding bytes.
// Each ytab reserves fixed amount of bytes in this array.
//
// The size should be the minimal number of bytes that
// are enough to hold biggest optab op lines.
type opBytes [31]uint8
type Optab struct {
as obj.As
ytab []ytab
prefix uint8
op opBytes
}
type movtab struct {
as obj.As
ft uint8
f3t uint8
tt uint8
code uint8
op [4]uint8
}
const (
Yxxx = iota
Ynone
Yi0 // $0
Yi1 // $1
Yu2 // $x, x fits in uint2
Yi8 // $x, x fits in int8
Yu8 // $x, x fits in uint8
Yu7 // $x, x in 0..127 (fits in both int8 and uint8)
Ys32
Yi32
Yi64
Yiauto
Yal
Ycl
Yax
Ycx
Yrb
Yrl
Yrl32 // Yrl on 32-bit system
Yrf
Yf0
Yrx
Ymb
Yml
Ym
Ybr
Ycs
Yss
Yds
Yes
Yfs
Ygs
Ygdtr
Yidtr
Yldtr
Ymsw
Ytask
Ycr0
Ycr1
Ycr2
Ycr3
Ycr4
Ycr5
Ycr6
Ycr7
Ycr8
Ydr0
Ydr1
Ydr2
Ydr3
Ydr4
Ydr5
Ydr6
Ydr7
Ytr0
Ytr1
Ytr2
Ytr3
Ytr4
Ytr5
Ytr6
Ytr7
Ymr
Ymm
Yxr0 // X0 only. "<XMM0>" notation in Intel manual.
YxrEvexMulti4 // [ X<n> - X<n+3> ]; multisource YxrEvex
Yxr // X0..X15
YxrEvex // X0..X31
Yxm
YxmEvex // YxrEvex+Ym
Yxvm // VSIB vector array; vm32x/vm64x
YxvmEvex // Yxvm which permits High-16 X register as index.
YyrEvexMulti4 // [ Y<n> - Y<n+3> ]; multisource YyrEvex
Yyr // Y0..Y15
YyrEvex // Y0..Y31
Yym
YymEvex // YyrEvex+Ym
Yyvm // VSIB vector array; vm32y/vm64y
YyvmEvex // Yyvm which permits High-16 Y register as index.
YzrMulti4 // [ Z<n> - Z<n+3> ]; multisource YzrEvex
Yzr // Z0..Z31
Yzm // Yzr+Ym
Yzvm // VSIB vector array; vm32z/vm64z
Yk0 // K0
Yknot0 // K1..K7; write mask
Yk // K0..K7; used for KOP
Ykm // Yk+Ym; used for KOP
Ytls
Ytextsize
Yindir
Ymax
)
const (
Zxxx = iota
Zlit
Zlitm_r
Zlitr_m
Zlit_m_r
Z_rp
Zbr
Zcall
Zcallcon
Zcallduff
Zcallind
Zcallindreg
Zib_
Zib_rp
Zibo_m
Zibo_m_xm
Zil_
Zil_rp
Ziq_rp
Zilo_m
Zjmp
Zjmpcon
Zloop
Zo_iw
Zm_o
Zm_r
Z_m_r
Zm2_r
Zm_r_xm
Zm_r_i_xm
Zm_r_xm_nr
Zr_m_xm_nr
Zibm_r // mmx1,mmx2/mem64,imm8
Zibr_m
Zmb_r
Zaut_r
Zo_m
Zo_m64
Zpseudo
Zr_m
Zr_m_xm
Zrp_
Z_ib
Z_il
Zm_ibo
Zm_ilo
Zib_rr
Zil_rr
Zbyte
Zvex_rm_v_r
Zvex_rm_v_ro
Zvex_r_v_rm
Zvex_i_rm_vo
Zvex_v_rm_r
Zvex_i_rm_r
Zvex_i_r_v
Zvex_i_rm_v_r
Zvex
Zvex_rm_r_vo
Zvex_i_r_rm
Zvex_hr_rm_v_r
Zevex_first
Zevex_i_r_k_rm
Zevex_i_r_rm
Zevex_i_rm_k_r
Zevex_i_rm_k_vo
Zevex_i_rm_r
Zevex_i_rm_v_k_r
Zevex_i_rm_v_r
Zevex_i_rm_vo
Zevex_k_rmo
Zevex_r_k_rm
Zevex_r_v_k_rm
Zevex_r_v_rm
Zevex_rm_k_r
Zevex_rm_v_k_r
Zevex_rm_v_r
Zevex_last
Zmax
)
const (
Px = 0
Px1 = 1 // symbolic; exact value doesn't matter
P32 = 0x32 // 32-bit only
Pe = 0x66 // operand escape
Pm = 0x0f // 2byte opcode escape
Pq = 0xff // both escapes: 66 0f
Pb = 0xfe // byte operands
Pf2 = 0xf2 // xmm escape 1: f2 0f
Pf3 = 0xf3 // xmm escape 2: f3 0f
Pef3 = 0xf5 // xmm escape 2 with 16-bit prefix: 66 f3 0f
Pq3 = 0x67 // xmm escape 3: 66 48 0f
Pq4 = 0x68 // xmm escape 4: 66 0F 38
Pq4w = 0x69 // Pq4 with Rex.w 66 0F 38
Pq5 = 0x6a // xmm escape 5: F3 0F 38
Pq5w = 0x6b // Pq5 with Rex.w F3 0F 38
Pfw = 0xf4 // Pf3 with Rex.w: f3 48 0f
Pw = 0x48 // Rex.w
Pw8 = 0x90 // symbolic; exact value doesn't matter
Py = 0x80 // defaults to 64-bit mode
Py1 = 0x81 // symbolic; exact value doesn't matter
Py3 = 0x83 // symbolic; exact value doesn't matter
Pavx = 0x84 // symbolic; exact value doesn't matter
RxrEvex = 1 << 4 // AVX512 extension to REX.R/VEX.R
Rxw = 1 << 3 // =1, 64-bit operand size
Rxr = 1 << 2 // extend modrm reg
Rxx = 1 << 1 // extend sib index
Rxb = 1 << 0 // extend modrm r/m, sib base, or opcode reg
)
const (
// Encoding for VEX prefix in tables.
// The P, L, and W fields are chosen to match
// their eventual locations in the VEX prefix bytes.
// Encoding for VEX prefix in tables.
// The P, L, and W fields are chosen to match
// their eventual locations in the VEX prefix bytes.
// Using spare bit to make leading [E]VEX encoding byte different from
// 0x0f even if all other VEX fields are 0.
avxEscape = 1 << 6
// P field - 2 bits
vex66 = 1 << 0
vexF3 = 2 << 0
vexF2 = 3 << 0
// L field - 1 bit
vexLZ = 0 << 2
vexLIG = 0 << 2
vex128 = 0 << 2
vex256 = 1 << 2
// W field - 1 bit
vexWIG = 0 << 7
vexW0 = 0 << 7
vexW1 = 1 << 7
// M field - 5 bits, but mostly reserved; we can store up to 3
vex0F = 1 << 3
vex0F38 = 2 << 3
vex0F3A = 3 << 3
)
var ycover [Ymax * Ymax]uint8
var reg [MAXREG]int
var regrex [MAXREG + 1]int
var ynone = []ytab{
{Zlit, 1, argList{}},
}
var ytext = []ytab{
{Zpseudo, 0, argList{Ymb, Ytextsize}},
{Zpseudo, 1, argList{Ymb, Yi32, Ytextsize}},
}
var ynop = []ytab{
{Zpseudo, 0, argList{}},
{Zpseudo, 0, argList{Yiauto}},
{Zpseudo, 0, argList{Yml}},
{Zpseudo, 0, argList{Yrf}},
{Zpseudo, 0, argList{Yxr}},
{Zpseudo, 0, argList{Yiauto}},
{Zpseudo, 0, argList{Yml}},
{Zpseudo, 0, argList{Yrf}},
{Zpseudo, 1, argList{Yxr}},
}
var yfuncdata = []ytab{
{Zpseudo, 0, argList{Yi32, Ym}},
}
var ypcdata = []ytab{
{Zpseudo, 0, argList{Yi32, Yi32}},
}
var yxorb = []ytab{
{Zib_, 1, argList{Yi32, Yal}},
{Zibo_m, 2, argList{Yi32, Ymb}},
{Zr_m, 1, argList{Yrb, Ymb}},
{Zm_r, 1, argList{Ymb, Yrb}},
}
var yaddl = []ytab{
{Zibo_m, 2, argList{Yi8, Yml}},
{Zil_, 1, argList{Yi32, Yax}},
{Zilo_m, 2, argList{Yi32, Yml}},
{Zr_m, 1, argList{Yrl, Yml}},
{Zm_r, 1, argList{Yml, Yrl}},
}
var yincl = []ytab{
{Z_rp, 1, argList{Yrl}},
{Zo_m, 2, argList{Yml}},
}
var yincq = []ytab{
{Zo_m, 2, argList{Yml}},
}
var ycmpb = []ytab{
{Z_ib, 1, argList{Yal, Yi32}},
{Zm_ibo, 2, argList{Ymb, Yi32}},
{Zm_r, 1, argList{Ymb, Yrb}},
{Zr_m, 1, argList{Yrb, Ymb}},
}
var ycmpl = []ytab{
{Zm_ibo, 2, argList{Yml, Yi8}},
{Z_il, 1, argList{Yax, Yi32}},
{Zm_ilo, 2, argList{Yml, Yi32}},
{Zm_r, 1, argList{Yml, Yrl}},
{Zr_m, 1, argList{Yrl, Yml}},
}
var yshb = []ytab{
{Zo_m, 2, argList{Yi1, Ymb}},
{Zibo_m, 2, argList{Yu8, Ymb}},
{Zo_m, 2, argList{Ycx, Ymb}},
}
var yshl = []ytab{
{Zo_m, 2, argList{Yi1, Yml}},
{Zibo_m, 2, argList{Yu8, Yml}},
{Zo_m, 2, argList{Ycl, Yml}},
{Zo_m, 2, argList{Ycx, Yml}},
}
var ytestl = []ytab{
{Zil_, 1, argList{Yi32, Yax}},
{Zilo_m, 2, argList{Yi32, Yml}},
{Zr_m, 1, argList{Yrl, Yml}},
{Zm_r, 1, argList{Yml, Yrl}},
}
var ymovb = []ytab{
{Zr_m, 1, argList{Yrb, Ymb}},
{Zm_r, 1, argList{Ymb, Yrb}},
{Zib_rp, 1, argList{Yi32, Yrb}},
{Zibo_m, 2, argList{Yi32, Ymb}},
}
var ybtl = []ytab{
{Zibo_m, 2, argList{Yi8, Yml}},
{Zr_m, 1, argList{Yrl, Yml}},
}
var ymovw = []ytab{
{Zr_m, 1, argList{Yrl, Yml}},
{Zm_r, 1, argList{Yml, Yrl}},
{Zil_rp, 1, argList{Yi32, Yrl}},
{Zilo_m, 2, argList{Yi32, Yml}},
{Zaut_r, 2, argList{Yiauto, Yrl}},
}
var ymovl = []ytab{
{Zr_m, 1, argList{Yrl, Yml}},
{Zm_r, 1, argList{Yml, Yrl}},
{Zil_rp, 1, argList{Yi32, Yrl}},
{Zilo_m, 2, argList{Yi32, Yml}},
{Zm_r_xm, 1, argList{Yml, Ymr}}, // MMX MOVD
{Zr_m_xm, 1, argList{Ymr, Yml}}, // MMX MOVD
{Zm_r_xm, 2, argList{Yml, Yxr}}, // XMM MOVD (32 bit)
{Zr_m_xm, 2, argList{Yxr, Yml}}, // XMM MOVD (32 bit)
{Zaut_r, 2, argList{Yiauto, Yrl}},
}
var yret = []ytab{
{Zo_iw, 1, argList{}},
{Zo_iw, 1, argList{Yi32}},
}
var ymovq = []ytab{
// valid in 32-bit mode
{Zm_r_xm_nr, 1, argList{Ym, Ymr}}, // 0x6f MMX MOVQ (shorter encoding)
{Zr_m_xm_nr, 1, argList{Ymr, Ym}}, // 0x7f MMX MOVQ
{Zm_r_xm_nr, 2, argList{Yxr, Ymr}}, // Pf2, 0xd6 MOVDQ2Q
{Zm_r_xm_nr, 2, argList{Yxm, Yxr}}, // Pf3, 0x7e MOVQ xmm1/m64 -> xmm2
{Zr_m_xm_nr, 2, argList{Yxr, Yxm}}, // Pe, 0xd6 MOVQ xmm1 -> xmm2/m64
// valid only in 64-bit mode, usually with 64-bit prefix
{Zr_m, 1, argList{Yrl, Yml}}, // 0x89
{Zm_r, 1, argList{Yml, Yrl}}, // 0x8b
{Zilo_m, 2, argList{Ys32, Yrl}}, // 32 bit signed 0xc7,(0)
{Ziq_rp, 1, argList{Yi64, Yrl}}, // 0xb8 -- 32/64 bit immediate
{Zilo_m, 2, argList{Yi32, Yml}}, // 0xc7,(0)
{Zm_r_xm, 1, argList{Ymm, Ymr}}, // 0x6e MMX MOVD
{Zr_m_xm, 1, argList{Ymr, Ymm}}, // 0x7e MMX MOVD
{Zm_r_xm, 2, argList{Yml, Yxr}}, // Pe, 0x6e MOVD xmm load
{Zr_m_xm, 2, argList{Yxr, Yml}}, // Pe, 0x7e MOVD xmm store
{Zaut_r, 1, argList{Yiauto, Yrl}}, // 0 built-in LEAQ
}
var ymovbe = []ytab{
{Zlitm_r, 3, argList{Ym, Yrl}},
{Zlitr_m, 3, argList{Yrl, Ym}},
}
var ym_rl = []ytab{
{Zm_r, 1, argList{Ym, Yrl}},
}
var yrl_m = []ytab{
{Zr_m, 1, argList{Yrl, Ym}},
}
var ymb_rl = []ytab{
{Zmb_r, 1, argList{Ymb, Yrl}},
}
var yml_rl = []ytab{
{Zm_r, 1, argList{Yml, Yrl}},
}
var yrl_ml = []ytab{
{Zr_m, 1, argList{Yrl, Yml}},
}
var yml_mb = []ytab{
{Zr_m, 1, argList{Yrb, Ymb}},
{Zm_r, 1, argList{Ymb, Yrb}},
}
var yrb_mb = []ytab{
{Zr_m, 1, argList{Yrb, Ymb}},
}
var yxchg = []ytab{
{Z_rp, 1, argList{Yax, Yrl}},
{Zrp_, 1, argList{Yrl, Yax}},
{Zr_m, 1, argList{Yrl, Yml}},
{Zm_r, 1, argList{Yml, Yrl}},
}
var ydivl = []ytab{
{Zm_o, 2, argList{Yml}},
}
var ydivb = []ytab{
{Zm_o, 2, argList{Ymb}},
}
var yimul = []ytab{
{Zm_o, 2, argList{Yml}},
{Zib_rr, 1, argList{Yi8, Yrl}},
{Zil_rr, 1, argList{Yi32, Yrl}},
{Zm_r, 2, argList{Yml, Yrl}},
}
var yimul3 = []ytab{
{Zibm_r, 2, argList{Yi8, Yml, Yrl}},
{Zibm_r, 2, argList{Yi32, Yml, Yrl}},
}
var ybyte = []ytab{
{Zbyte, 1, argList{Yi64}},
}
var yin = []ytab{
{Zib_, 1, argList{Yi32}},
{Zlit, 1, argList{}},
}
var yint = []ytab{
{Zib_, 1, argList{Yi32}},
}
var ypushl = []ytab{
{Zrp_, 1, argList{Yrl}},
{Zm_o, 2, argList{Ym}},
{Zib_, 1, argList{Yi8}},
{Zil_, 1, argList{Yi32}},
}
var ypopl = []ytab{
{Z_rp, 1, argList{Yrl}},
{Zo_m, 2, argList{Ym}},
}
var ywrfsbase = []ytab{
{Zm_o, 2, argList{Yrl}},
}
var yrdrand = []ytab{
{Zo_m, 2, argList{Yrl}},
}
var yclflush = []ytab{
{Zo_m, 2, argList{Ym}},
}
var ybswap = []ytab{
{Z_rp, 2, argList{Yrl}},
}
var yscond = []ytab{
{Zo_m, 2, argList{Ymb}},
}
var yjcond = []ytab{
{Zbr, 0, argList{Ybr}},
{Zbr, 0, argList{Yi0, Ybr}},
{Zbr, 1, argList{Yi1, Ybr}},
}
var yloop = []ytab{
{Zloop, 1, argList{Ybr}},
}
var ycall = []ytab{
{Zcallindreg, 0, argList{Yml}},
{Zcallindreg, 2, argList{Yrx, Yrx}},
{Zcallind, 2, argList{Yindir}},
{Zcall, 0, argList{Ybr}},
{Zcallcon, 1, argList{Yi32}},
}
var yduff = []ytab{
{Zcallduff, 1, argList{Yi32}},
}
var yjmp = []ytab{
{Zo_m64, 2, argList{Yml}},
{Zjmp, 0, argList{Ybr}},
{Zjmpcon, 1, argList{Yi32}},
}
var yfmvd = []ytab{
{Zm_o, 2, argList{Ym, Yf0}},
{Zo_m, 2, argList{Yf0, Ym}},
{Zm_o, 2, argList{Yrf, Yf0}},
{Zo_m, 2, argList{Yf0, Yrf}},
}
var yfmvdp = []ytab{
{Zo_m, 2, argList{Yf0, Ym}},
{Zo_m, 2, argList{Yf0, Yrf}},
}
var yfmvf = []ytab{
{Zm_o, 2, argList{Ym, Yf0}},
{Zo_m, 2, argList{Yf0, Ym}},
}
var yfmvx = []ytab{
{Zm_o, 2, argList{Ym, Yf0}},
}
var yfmvp = []ytab{
{Zo_m, 2, argList{Yf0, Ym}},
}
var yfcmv = []ytab{
{Zm_o, 2, argList{Yrf, Yf0}},
}
var yfadd = []ytab{
{Zm_o, 2, argList{Ym, Yf0}},
{Zm_o, 2, argList{Yrf, Yf0}},
{Zo_m, 2, argList{Yf0, Yrf}},
}
var yfxch = []ytab{
{Zo_m, 2, argList{Yf0, Yrf}},
{Zm_o, 2, argList{Yrf, Yf0}},
}
var ycompp = []ytab{
{Zo_m, 2, argList{Yf0, Yrf}}, // botch is really f0,f1
}
var ystsw = []ytab{
{Zo_m, 2, argList{Ym}},
{Zlit, 1, argList{Yax}},
}
var ysvrs_mo = []ytab{
{Zm_o, 2, argList{Ym}},
}
// unaryDst version of "ysvrs_mo".
var ysvrs_om = []ytab{
{Zo_m, 2, argList{Ym}},
}
var ymm = []ytab{
{Zm_r_xm, 1, argList{Ymm, Ymr}},
{Zm_r_xm, 2, argList{Yxm, Yxr}},
}
var yxm = []ytab{
{Zm_r_xm, 1, argList{Yxm, Yxr}},
}
var yxm_q4 = []ytab{
{Zm_r, 1, argList{Yxm, Yxr}},
}
var yxcvm1 = []ytab{
{Zm_r_xm, 2, argList{Yxm, Yxr}},
{Zm_r_xm, 2, argList{Yxm, Ymr}},
}
var yxcvm2 = []ytab{
{Zm_r_xm, 2, argList{Yxm, Yxr}},
{Zm_r_xm, 2, argList{Ymm, Yxr}},
}
var yxr = []ytab{
{Zm_r_xm, 1, argList{Yxr, Yxr}},
}
var yxr_ml = []ytab{
{Zr_m_xm, 1, argList{Yxr, Yml}},
}
var ymr = []ytab{
{Zm_r, 1, argList{Ymr, Ymr}},
}
var ymr_ml = []ytab{
{Zr_m_xm, 1, argList{Ymr, Yml}},
}
var yxcmpi = []ytab{
{Zm_r_i_xm, 2, argList{Yxm, Yxr, Yi8}},
}
var yxmov = []ytab{
{Zm_r_xm, 1, argList{Yxm, Yxr}},
{Zr_m_xm, 1, argList{Yxr, Yxm}},
}
var yxcvfl = []ytab{
{Zm_r_xm, 1, argList{Yxm, Yrl}},
}
var yxcvlf = []ytab{
{Zm_r_xm, 1, argList{Yml, Yxr}},
}
var yxcvfq = []ytab{
{Zm_r_xm, 2, argList{Yxm, Yrl}},
}
var yxcvqf = []ytab{
{Zm_r_xm, 2, argList{Yml, Yxr}},
}
var yps = []ytab{
{Zm_r_xm, 1, argList{Ymm, Ymr}},
{Zibo_m_xm, 2, argList{Yi8, Ymr}},
{Zm_r_xm, 2, argList{Yxm, Yxr}},
{Zibo_m_xm, 3, argList{Yi8, Yxr}},
}
var yxrrl = []ytab{
{Zm_r, 1, argList{Yxr, Yrl}},
}
var ymrxr = []ytab{
{Zm_r, 1, argList{Ymr, Yxr}},
{Zm_r_xm, 1, argList{Yxm, Yxr}},
}
var ymshuf = []ytab{
{Zibm_r, 2, argList{Yi8, Ymm, Ymr}},
}
var ymshufb = []ytab{
{Zm2_r, 2, argList{Yxm, Yxr}},
}
// It should never have more than 1 entry,
// because some optab entries have opcode sequences that
// are longer than 2 bytes (zoffset=2 here),
// ROUNDPD and ROUNDPS and recently added BLENDPD,
// to name a few.
var yxshuf = []ytab{
{Zibm_r, 2, argList{Yu8, Yxm, Yxr}},
}
var yextrw = []ytab{
{Zibm_r, 2, argList{Yu8, Yxr, Yrl}},
{Zibr_m, 2, argList{Yu8, Yxr, Yml}},
}
var yextr = []ytab{
{Zibr_m, 3, argList{Yu8, Yxr, Ymm}},
}
var yinsrw = []ytab{
{Zibm_r, 2, argList{Yu8, Yml, Yxr}},
}
var yinsr = []ytab{
{Zibm_r, 3, argList{Yu8, Ymm, Yxr}},
}
var ypsdq = []ytab{
{Zibo_m, 2, argList{Yi8, Yxr}},
}
var ymskb = []ytab{
{Zm_r_xm, 2, argList{Yxr, Yrl}},
{Zm_r_xm, 1, argList{Ymr, Yrl}},
}
var ycrc32l = []ytab{
{Zlitm_r, 0, argList{Yml, Yrl}},
}
var ycrc32b = []ytab{
{Zlitm_r, 0, argList{Ymb, Yrl}},
}
var yprefetch = []ytab{
{Zm_o, 2, argList{Ym}},
}
var yaes = []ytab{
{Zlitm_r, 2, argList{Yxm, Yxr}},
}
var yxbegin = []ytab{
{Zjmp, 1, argList{Ybr}},
}
var yxabort = []ytab{
{Zib_, 1, argList{Yu8}},
}
var ylddqu = []ytab{
{Zm_r, 1, argList{Ym, Yxr}},
}
var ypalignr = []ytab{
{Zibm_r, 2, argList{Yu8, Yxm, Yxr}},
}
var ysha256rnds2 = []ytab{
{Zlit_m_r, 0, argList{Yxr0, Yxm, Yxr}},
}
var yblendvpd = []ytab{
{Z_m_r, 1, argList{Yxr0, Yxm, Yxr}},
}
var ymmxmm0f38 = []ytab{
{Zlitm_r, 3, argList{Ymm, Ymr}},
{Zlitm_r, 5, argList{Yxm, Yxr}},
}
var yextractps = []ytab{
{Zibr_m, 2, argList{Yu2, Yxr, Yml}},
}
var ysha1rnds4 = []ytab{
{Zibm_r, 2, argList{Yu2, Yxm, Yxr}},
}
// You are doasm, holding in your hand a *obj.Prog with p.As set to, say,
// ACRC32, and p.From and p.To as operands (obj.Addr). The linker scans optab
// to find the entry with the given p.As and then looks through the ytable for
// that instruction (the second field in the optab struct) for a line whose
// first two values match the Ytypes of the p.From and p.To operands. The
// function oclass computes the specific Ytype of an operand and then the set
// of more general Ytypes that it satisfies is implied by the ycover table, set
// up in instinit. For example, oclass distinguishes the constants 0 and 1
// from the more general 8-bit constants, but instinit says
//
// ycover[Yi0*Ymax+Ys32] = 1
// ycover[Yi1*Ymax+Ys32] = 1
// ycover[Yi8*Ymax+Ys32] = 1
//
// which means that Yi0, Yi1, and Yi8 all count as Ys32 (signed 32)
// if that's what an instruction can handle.
//
// In parallel with the scan through the ytable for the appropriate line, there
// is a z pointer that starts out pointing at the strange magic byte list in
// the Optab struct. With each step past a non-matching ytable line, z
// advances by the 4th entry in the line. When a matching line is found, that
// z pointer has the extra data to use in laying down the instruction bytes.
// The actual bytes laid down are a function of the 3rd entry in the line (that
// is, the Ztype) and the z bytes.
//
// For example, let's look at AADDL. The optab line says:
//
// {AADDL, yaddl, Px, opBytes{0x83, 00, 0x05, 0x81, 00, 0x01, 0x03}},
//
// and yaddl says
//
// var yaddl = []ytab{
// {Yi8, Ynone, Yml, Zibo_m, 2},
// {Yi32, Ynone, Yax, Zil_, 1},
// {Yi32, Ynone, Yml, Zilo_m, 2},
// {Yrl, Ynone, Yml, Zr_m, 1},
// {Yml, Ynone, Yrl, Zm_r, 1},
// }
//
// so there are 5 possible types of ADDL instruction that can be laid down, and
// possible states used to lay them down (Ztype and z pointer, assuming z
// points at opBytes{0x83, 00, 0x05,0x81, 00, 0x01, 0x03}) are:
//
// Yi8, Yml -> Zibo_m, z (0x83, 00)
// Yi32, Yax -> Zil_, z+2 (0x05)
// Yi32, Yml -> Zilo_m, z+2+1 (0x81, 0x00)
// Yrl, Yml -> Zr_m, z+2+1+2 (0x01)
// Yml, Yrl -> Zm_r, z+2+1+2+1 (0x03)
//
// The Pconstant in the optab line controls the prefix bytes to emit. That's
// relatively straightforward as this program goes.
//
// The switch on yt.zcase in doasm implements the various Z cases. Zibo_m, for
// example, is an opcode byte (z[0]) then an asmando (which is some kind of
// encoded addressing mode for the Yml arg), and then a single immediate byte.
// Zilo_m is the same but a long (32-bit) immediate.
var optab =
// as, ytab, andproto, opcode
[...]Optab{
{obj.AXXX, nil, 0, opBytes{}},
{AAAA, ynone, P32, opBytes{0x37}},
{AAAD, ynone, P32, opBytes{0xd5, 0x0a}},
{AAAM, ynone, P32, opBytes{0xd4, 0x0a}},
{AAAS, ynone, P32, opBytes{0x3f}},
{AADCB, yxorb, Pb, opBytes{0x14, 0x80, 02, 0x10, 0x12}},
{AADCL, yaddl, Px, opBytes{0x83, 02, 0x15, 0x81, 02, 0x11, 0x13}},
{AADCQ, yaddl, Pw, opBytes{0x83, 02, 0x15, 0x81, 02, 0x11, 0x13}},
{AADCW, yaddl, Pe, opBytes{0x83, 02, 0x15, 0x81, 02, 0x11, 0x13}},
{AADCXL, yml_rl, Pq4, opBytes{0xf6}},
{AADCXQ, yml_rl, Pq4w, opBytes{0xf6}},
{AADDB, yxorb, Pb, opBytes{0x04, 0x80, 00, 0x00, 0x02}},
{AADDL, yaddl, Px, opBytes{0x83, 00, 0x05, 0x81, 00, 0x01, 0x03}},
{AADDPD, yxm, Pq, opBytes{0x58}},
{AADDPS, yxm, Pm, opBytes{0x58}},
{AADDQ, yaddl, Pw, opBytes{0x83, 00, 0x05, 0x81, 00, 0x01, 0x03}},
{AADDSD, yxm, Pf2, opBytes{0x58}},
{AADDSS, yxm, Pf3, opBytes{0x58}},
{AADDSUBPD, yxm, Pq, opBytes{0xd0}},
{AADDSUBPS, yxm, Pf2, opBytes{0xd0}},
{AADDW, yaddl, Pe, opBytes{0x83, 00, 0x05, 0x81, 00, 0x01, 0x03}},
{AADOXL, yml_rl, Pq5, opBytes{0xf6}},
{AADOXQ, yml_rl, Pq5w, opBytes{0xf6}},
{AADJSP, nil, 0, opBytes{}},
{AANDB, yxorb, Pb, opBytes{0x24, 0x80, 04, 0x20, 0x22}},
{AANDL, yaddl, Px, opBytes{0x83, 04, 0x25, 0x81, 04, 0x21, 0x23}},
{AANDNPD, yxm, Pq, opBytes{0x55}},
{AANDNPS, yxm, Pm, opBytes{0x55}},
{AANDPD, yxm, Pq, opBytes{0x54}},
{AANDPS, yxm, Pm, opBytes{0x54}},
{AANDQ, yaddl, Pw, opBytes{0x83, 04, 0x25, 0x81, 04, 0x21, 0x23}},
{AANDW, yaddl, Pe, opBytes{0x83, 04, 0x25, 0x81, 04, 0x21, 0x23}},
{AARPL, yrl_ml, P32, opBytes{0x63}},
{ABOUNDL, yrl_m, P32, opBytes{0x62}},
{ABOUNDW, yrl_m, Pe, opBytes{0x62}},
{ABSFL, yml_rl, Pm, opBytes{0xbc}},
{ABSFQ, yml_rl, Pw, opBytes{0x0f, 0xbc}},
{ABSFW, yml_rl, Pq, opBytes{0xbc}},
{ABSRL, yml_rl, Pm, opBytes{0xbd}},
{ABSRQ, yml_rl, Pw, opBytes{0x0f, 0xbd}},
{ABSRW, yml_rl, Pq, opBytes{0xbd}},
{ABSWAPL, ybswap, Px, opBytes{0x0f, 0xc8}},
{ABSWAPQ, ybswap, Pw, opBytes{0x0f, 0xc8}},
{ABTCL, ybtl, Pm, opBytes{0xba, 07, 0xbb}},
{ABTCQ, ybtl, Pw, opBytes{0x0f, 0xba, 07, 0x0f, 0xbb}},
{ABTCW, ybtl, Pq, opBytes{0xba, 07, 0xbb}},
{ABTL, ybtl, Pm, opBytes{0xba, 04, 0xa3}},
{ABTQ, ybtl, Pw, opBytes{0x0f, 0xba, 04, 0x0f, 0xa3}},
{ABTRL, ybtl, Pm, opBytes{0xba, 06, 0xb3}},
{ABTRQ, ybtl, Pw, opBytes{0x0f, 0xba, 06, 0x0f, 0xb3}},
{ABTRW, ybtl, Pq, opBytes{0xba, 06, 0xb3}},
{ABTSL, ybtl, Pm, opBytes{0xba, 05, 0xab}},
{ABTSQ, ybtl, Pw, opBytes{0x0f, 0xba, 05, 0x0f, 0xab}},
{ABTSW, ybtl, Pq, opBytes{0xba, 05, 0xab}},
{ABTW, ybtl, Pq, opBytes{0xba, 04, 0xa3}},
{ABYTE, ybyte, Px, opBytes{1}},
{obj.ACALL, ycall, Px, opBytes{0xff, 02, 0xff, 0x15, 0xe8}},
{ACBW, ynone, Pe, opBytes{0x98}},
{ACDQ, ynone, Px, opBytes{0x99}},
{ACDQE, ynone, Pw, opBytes{0x98}},
{ACLAC, ynone, Pm, opBytes{01, 0xca}},
{ACLC, ynone, Px, opBytes{0xf8}},
{ACLD, ynone, Px, opBytes{0xfc}},
{ACLDEMOTE, yclflush, Pm, opBytes{0x1c, 00}},
{ACLFLUSH, yclflush, Pm, opBytes{0xae, 07}},
{ACLFLUSHOPT, yclflush, Pq, opBytes{0xae, 07}},
{ACLI, ynone, Px, opBytes{0xfa}},
{ACLTS, ynone, Pm, opBytes{0x06}},
{ACLWB, yclflush, Pq, opBytes{0xae, 06}},
{ACMC, ynone, Px, opBytes{0xf5}},
{ACMOVLCC, yml_rl, Pm, opBytes{0x43}},
{ACMOVLCS, yml_rl, Pm, opBytes{0x42}},
{ACMOVLEQ, yml_rl, Pm, opBytes{0x44}},
{ACMOVLGE, yml_rl, Pm, opBytes{0x4d}},
{ACMOVLGT, yml_rl, Pm, opBytes{0x4f}},
{ACMOVLHI, yml_rl, Pm, opBytes{0x47}},
{ACMOVLLE, yml_rl, Pm, opBytes{0x4e}},
{ACMOVLLS, yml_rl, Pm, opBytes{0x46}},
{ACMOVLLT, yml_rl, Pm, opBytes{0x4c}},
{ACMOVLMI, yml_rl, Pm, opBytes{0x48}},
{ACMOVLNE, yml_rl, Pm, opBytes{0x45}},
{ACMOVLOC, yml_rl, Pm, opBytes{0x41}},
{ACMOVLOS, yml_rl, Pm, opBytes{0x40}},
{ACMOVLPC, yml_rl, Pm, opBytes{0x4b}},
{ACMOVLPL, yml_rl, Pm, opBytes{0x49}},
{ACMOVLPS, yml_rl, Pm, opBytes{0x4a}},
{ACMOVQCC, yml_rl, Pw, opBytes{0x0f, 0x43}},
{ACMOVQCS, yml_rl, Pw, opBytes{0x0f, 0x42}},
{ACMOVQEQ, yml_rl, Pw, opBytes{0x0f, 0x44}},
{ACMOVQGE, yml_rl, Pw, opBytes{0x0f, 0x4d}},
{ACMOVQGT, yml_rl, Pw, opBytes{0x0f, 0x4f}},
{ACMOVQHI, yml_rl, Pw, opBytes{0x0f, 0x47}},
{ACMOVQLE, yml_rl, Pw, opBytes{0x0f, 0x4e}},
{ACMOVQLS, yml_rl, Pw, opBytes{0x0f, 0x46}},
{ACMOVQLT, yml_rl, Pw, opBytes{0x0f, 0x4c}},
{ACMOVQMI, yml_rl, Pw, opBytes{0x0f, 0x48}},
{ACMOVQNE, yml_rl, Pw, opBytes{0x0f, 0x45}},
{ACMOVQOC, yml_rl, Pw, opBytes{0x0f, 0x41}},
{ACMOVQOS, yml_rl, Pw, opBytes{0x0f, 0x40}},
{ACMOVQPC, yml_rl, Pw, opBytes{0x0f, 0x4b}},
{ACMOVQPL, yml_rl, Pw, opBytes{0x0f, 0x49}},
{ACMOVQPS, yml_rl, Pw, opBytes{0x0f, 0x4a}},
{ACMOVWCC, yml_rl, Pq, opBytes{0x43}},
{ACMOVWCS, yml_rl, Pq, opBytes{0x42}},
{ACMOVWEQ, yml_rl, Pq, opBytes{0x44}},
{ACMOVWGE, yml_rl, Pq, opBytes{0x4d}},
{ACMOVWGT, yml_rl, Pq, opBytes{0x4f}},
{ACMOVWHI, yml_rl, Pq, opBytes{0x47}},
{ACMOVWLE, yml_rl, Pq, opBytes{0x4e}},
{ACMOVWLS, yml_rl, Pq, opBytes{0x46}},
{ACMOVWLT, yml_rl, Pq, opBytes{0x4c}},
{ACMOVWMI, yml_rl, Pq, opBytes{0x48}},
{ACMOVWNE, yml_rl, Pq, opBytes{0x45}},
{ACMOVWOC, yml_rl, Pq, opBytes{0x41}},
{ACMOVWOS, yml_rl, Pq, opBytes{0x40}},
{ACMOVWPC, yml_rl, Pq, opBytes{0x4b}},
{ACMOVWPL, yml_rl, Pq, opBytes{0x49}},
{ACMOVWPS, yml_rl, Pq, opBytes{0x4a}},
{ACMPB, ycmpb, Pb, opBytes{0x3c, 0x80, 07, 0x38, 0x3a}},
{ACMPL, ycmpl, Px, opBytes{0x83, 07, 0x3d, 0x81, 07, 0x39, 0x3b}},
{ACMPPD, yxcmpi, Px, opBytes{Pe, 0xc2}},
{ACMPPS, yxcmpi, Pm, opBytes{0xc2, 0}},
{ACMPQ, ycmpl, Pw, opBytes{0x83, 07, 0x3d, 0x81, 07, 0x39, 0x3b}},
{ACMPSB, ynone, Pb, opBytes{0xa6}},
{ACMPSD, yxcmpi, Px, opBytes{Pf2, 0xc2}},
{ACMPSL, ynone, Px, opBytes{0xa7}},
{ACMPSQ, ynone, Pw, opBytes{0xa7}},
{ACMPSS, yxcmpi, Px, opBytes{Pf3, 0xc2}},
{ACMPSW, ynone, Pe, opBytes{0xa7}},
{ACMPW, ycmpl, Pe, opBytes{0x83, 07, 0x3d, 0x81, 07, 0x39, 0x3b}},
{ACOMISD, yxm, Pe, opBytes{0x2f}},
{ACOMISS, yxm, Pm, opBytes{0x2f}},
{ACPUID, ynone, Pm, opBytes{0xa2}},
{ACVTPL2PD, yxcvm2, Px, opBytes{Pf3, 0xe6, Pe, 0x2a}},
{ACVTPL2PS, yxcvm2, Pm, opBytes{0x5b, 0, 0x2a, 0}},
{ACVTPD2PL, yxcvm1, Px, opBytes{Pf2, 0xe6, Pe, 0x2d}},
{ACVTPD2PS, yxm, Pe, opBytes{0x5a}},
{ACVTPS2PL, yxcvm1, Px, opBytes{Pe, 0x5b, Pm, 0x2d}},
{ACVTPS2PD, yxm, Pm, opBytes{0x5a}},
{ACVTSD2SL, yxcvfl, Pf2, opBytes{0x2d}},
{ACVTSD2SQ, yxcvfq, Pw, opBytes{Pf2, 0x2d}},
{ACVTSD2SS, yxm, Pf2, opBytes{0x5a}},
{ACVTSL2SD, yxcvlf, Pf2, opBytes{0x2a}},
{ACVTSQ2SD, yxcvqf, Pw, opBytes{Pf2, 0x2a}},
{ACVTSL2SS, yxcvlf, Pf3, opBytes{0x2a}},
{ACVTSQ2SS, yxcvqf, Pw, opBytes{Pf3, 0x2a}},
{ACVTSS2SD, yxm, Pf3, opBytes{0x5a}},
{ACVTSS2SL, yxcvfl, Pf3, opBytes{0x2d}},
{ACVTSS2SQ, yxcvfq, Pw, opBytes{Pf3, 0x2d}},
{ACVTTPD2PL, yxcvm1, Px, opBytes{Pe, 0xe6, Pe, 0x2c}},
{ACVTTPS2PL, yxcvm1, Px, opBytes{Pf3, 0x5b, Pm, 0x2c}},
{ACVTTSD2SL, yxcvfl, Pf2, opBytes{0x2c}},
{ACVTTSD2SQ, yxcvfq, Pw, opBytes{Pf2, 0x2c}},
{ACVTTSS2SL, yxcvfl, Pf3, opBytes{0x2c}},
{ACVTTSS2SQ, yxcvfq, Pw, opBytes{Pf3, 0x2c}},
{ACWD, ynone, Pe, opBytes{0x99}},
{ACWDE, ynone, Px, opBytes{0x98}},
{ACQO, ynone, Pw, opBytes{0x99}},
{ADAA, ynone, P32, opBytes{0x27}},
{ADAS, ynone, P32, opBytes{0x2f}},
{ADECB, yscond, Pb, opBytes{0xfe, 01}},
{ADECL, yincl, Px1, opBytes{0x48, 0xff, 01}},
{ADECQ, yincq, Pw, opBytes{0xff, 01}},
{ADECW, yincq, Pe, opBytes{0xff, 01}},
{ADIVB, ydivb, Pb, opBytes{0xf6, 06}},
{ADIVL, ydivl, Px, opBytes{0xf7, 06}},
{ADIVPD, yxm, Pe, opBytes{0x5e}},
{ADIVPS, yxm, Pm, opBytes{0x5e}},
{ADIVQ, ydivl, Pw, opBytes{0xf7, 06}},
{ADIVSD, yxm, Pf2, opBytes{0x5e}},
{ADIVSS, yxm, Pf3, opBytes{0x5e}},
{ADIVW, ydivl, Pe, opBytes{0xf7, 06}},
{ADPPD, yxshuf, Pq, opBytes{0x3a, 0x41, 0}},
{ADPPS, yxshuf, Pq, opBytes{0x3a, 0x40, 0}},
{AEMMS, ynone, Pm, opBytes{0x77}},
{AEXTRACTPS, yextractps, Pq, opBytes{0x3a, 0x17, 0}},
{AENTER, nil, 0, opBytes{}}, // botch
{AFXRSTOR, ysvrs_mo, Pm, opBytes{0xae, 01, 0xae, 01}},
{AFXSAVE, ysvrs_om, Pm, opBytes{0xae, 00, 0xae, 00}},
{AFXRSTOR64, ysvrs_mo, Pw, opBytes{0x0f, 0xae, 01, 0x0f, 0xae, 01}},
{AFXSAVE64, ysvrs_om, Pw, opBytes{0x0f, 0xae, 00, 0x0f, 0xae, 00}},
{AHLT, ynone, Px, opBytes{0xf4}},
{AIDIVB, ydivb, Pb, opBytes{0xf6, 07}},
{AIDIVL, ydivl, Px, opBytes{0xf7, 07}},
{AIDIVQ, ydivl, Pw, opBytes{0xf7, 07}},
{AIDIVW, ydivl, Pe, opBytes{0xf7, 07}},
{AIMULB, ydivb, Pb, opBytes{0xf6, 05}},
{AIMULL, yimul, Px, opBytes{0xf7, 05, 0x6b, 0x69, Pm, 0xaf}},
{AIMULQ, yimul, Pw, opBytes{0xf7, 05, 0x6b, 0x69, Pm, 0xaf}},
{AIMULW, yimul, Pe, opBytes{0xf7, 05, 0x6b, 0x69, Pm, 0xaf}},
{AIMUL3W, yimul3, Pe, opBytes{0x6b, 00, 0x69, 00}},
{AIMUL3L, yimul3, Px, opBytes{0x6b, 00, 0x69, 00}},
{AIMUL3Q, yimul3, Pw, opBytes{0x6b, 00, 0x69, 00}},
{AINB, yin, Pb, opBytes{0xe4, 0xec}},
{AINW, yin, Pe, opBytes{0xe5, 0xed}},
{AINL, yin, Px, opBytes{0xe5, 0xed}},
{AINCB, yscond, Pb, opBytes{0xfe, 00}},
{AINCL, yincl, Px1, opBytes{0x40, 0xff, 00}},
{AINCQ, yincq, Pw, opBytes{0xff, 00}},
{AINCW, yincq, Pe, opBytes{0xff, 00}},
{AINSB, ynone, Pb, opBytes{0x6c}},
{AINSL, ynone, Px, opBytes{0x6d}},
{AINSERTPS, yxshuf, Pq, opBytes{0x3a, 0x21, 0}},
{AINSW, ynone, Pe, opBytes{0x6d}},
{AICEBP, ynone, Px, opBytes{0xf1}},
{AINT, yint, Px, opBytes{0xcd}},
{AINTO, ynone, P32, opBytes{0xce}},
{AIRETL, ynone, Px, opBytes{0xcf}},
{AIRETQ, ynone, Pw, opBytes{0xcf}},
{AIRETW, ynone, Pe, opBytes{0xcf}},
{AJCC, yjcond, Px, opBytes{0x73, 0x83, 00}},
{AJCS, yjcond, Px, opBytes{0x72, 0x82}},
{AJCXZL, yloop, Px, opBytes{0xe3}},
{AJCXZW, yloop, Px, opBytes{0xe3}},
{AJCXZQ, yloop, Px, opBytes{0xe3}},
{AJEQ, yjcond, Px, opBytes{0x74, 0x84}},
{AJGE, yjcond, Px, opBytes{0x7d, 0x8d}},
{AJGT, yjcond, Px, opBytes{0x7f, 0x8f}},
{AJHI, yjcond, Px, opBytes{0x77, 0x87}},
{AJLE, yjcond, Px, opBytes{0x7e, 0x8e}},
{AJLS, yjcond, Px, opBytes{0x76, 0x86}},
{AJLT, yjcond, Px, opBytes{0x7c, 0x8c}},
{AJMI, yjcond, Px, opBytes{0x78, 0x88}},
{obj.AJMP, yjmp, Px, opBytes{0xff, 04, 0xeb, 0xe9}},
{AJNE, yjcond, Px, opBytes{0x75, 0x85}},
{AJOC, yjcond, Px, opBytes{0x71, 0x81, 00}},
{AJOS, yjcond, Px, opBytes{0x70, 0x80, 00}},
{AJPC, yjcond, Px, opBytes{0x7b, 0x8b}},
{AJPL, yjcond, Px, opBytes{0x79, 0x89}},
{AJPS, yjcond, Px, opBytes{0x7a, 0x8a}},
{AHADDPD, yxm, Pq, opBytes{0x7c}},
{AHADDPS, yxm, Pf2, opBytes{0x7c}},
{AHSUBPD, yxm, Pq, opBytes{0x7d}},
{AHSUBPS, yxm, Pf2, opBytes{0x7d}},
{ALAHF, ynone, Px, opBytes{0x9f}},
{ALARL, yml_rl, Pm, opBytes{0x02}},
{ALARQ, yml_rl, Pw, opBytes{0x0f, 0x02}},
{ALARW, yml_rl, Pq, opBytes{0x02}},
{ALDDQU, ylddqu, Pf2, opBytes{0xf0}},
{ALDMXCSR, ysvrs_mo, Pm, opBytes{0xae, 02, 0xae, 02}},
{ALEAL, ym_rl, Px, opBytes{0x8d}},
{ALEAQ, ym_rl, Pw, opBytes{0x8d}},
{ALEAVEL, ynone, P32, opBytes{0xc9}},
{ALEAVEQ, ynone, Py, opBytes{0xc9}},
{ALEAVEW, ynone, Pe, opBytes{0xc9}},
{ALEAW, ym_rl, Pe, opBytes{0x8d}},
{ALOCK, ynone, Px, opBytes{0xf0}},
{ALODSB, ynone, Pb, opBytes{0xac}},
{ALODSL, ynone, Px, opBytes{0xad}},
{ALODSQ, ynone, Pw, opBytes{0xad}},
{ALODSW, ynone, Pe, opBytes{0xad}},
{ALONG, ybyte, Px, opBytes{4}},
{ALOOP, yloop, Px, opBytes{0xe2}},
{ALOOPEQ, yloop, Px, opBytes{0xe1}},
{ALOOPNE, yloop, Px, opBytes{0xe0}},
{ALTR, ydivl, Pm, opBytes{0x00, 03}},
{ALZCNTL, yml_rl, Pf3, opBytes{0xbd}},
{ALZCNTQ, yml_rl, Pfw, opBytes{0xbd}},
{ALZCNTW, yml_rl, Pef3, opBytes{0xbd}},
{ALSLL, yml_rl, Pm, opBytes{0x03}},
{ALSLW, yml_rl, Pq, opBytes{0x03}},
{ALSLQ, yml_rl, Pw, opBytes{0x0f, 0x03}},
{AMASKMOVOU, yxr, Pe, opBytes{0xf7}},
{AMASKMOVQ, ymr, Pm, opBytes{0xf7}},
{AMAXPD, yxm, Pe, opBytes{0x5f}},
{AMAXPS, yxm, Pm, opBytes{0x5f}},
{AMAXSD, yxm, Pf2, opBytes{0x5f}},
{AMAXSS, yxm, Pf3, opBytes{0x5f}},
{AMINPD, yxm, Pe, opBytes{0x5d}},
{AMINPS, yxm, Pm, opBytes{0x5d}},
{AMINSD, yxm, Pf2, opBytes{0x5d}},
{AMINSS, yxm, Pf3, opBytes{0x5d}},
{AMONITOR, ynone, Px, opBytes{0x0f, 0x01, 0xc8, 0}},
{AMWAIT, ynone, Px, opBytes{0x0f, 0x01, 0xc9, 0}},
{AMOVAPD, yxmov, Pe, opBytes{0x28, 0x29}},
{AMOVAPS, yxmov, Pm, opBytes{0x28, 0x29}},
{AMOVB, ymovb, Pb, opBytes{0x88, 0x8a, 0xb0, 0xc6, 00}},
{AMOVBLSX, ymb_rl, Pm, opBytes{0xbe}},
{AMOVBLZX, ymb_rl, Pm, opBytes{0xb6}},
{AMOVBQSX, ymb_rl, Pw, opBytes{0x0f, 0xbe}},
{AMOVBQZX, ymb_rl, Pw, opBytes{0x0f, 0xb6}},
{AMOVBWSX, ymb_rl, Pq, opBytes{0xbe}},
{AMOVSWW, ymb_rl, Pe, opBytes{0x0f, 0xbf}},
{AMOVBWZX, ymb_rl, Pq, opBytes{0xb6}},
{AMOVZWW, ymb_rl, Pe, opBytes{0x0f, 0xb7}},
{AMOVO, yxmov, Pe, opBytes{0x6f, 0x7f}},
{AMOVOU, yxmov, Pf3, opBytes{0x6f, 0x7f}},
{AMOVHLPS, yxr, Pm, opBytes{0x12}},
{AMOVHPD, yxmov, Pe, opBytes{0x16, 0x17}},
{AMOVHPS, yxmov, Pm, opBytes{0x16, 0x17}},
{AMOVL, ymovl, Px, opBytes{0x89, 0x8b, 0xb8, 0xc7, 00, 0x6e, 0x7e, Pe, 0x6e, Pe, 0x7e, 0}},
{AMOVLHPS, yxr, Pm, opBytes{0x16}},
{AMOVLPD, yxmov, Pe, opBytes{0x12, 0x13}},
{AMOVLPS, yxmov, Pm, opBytes{0x12, 0x13}},
{AMOVLQSX, yml_rl, Pw, opBytes{0x63}},
{AMOVLQZX, yml_rl, Px, opBytes{0x8b}},
{AMOVMSKPD, yxrrl, Pq, opBytes{0x50}},
{AMOVMSKPS, yxrrl, Pm, opBytes{0x50}},
{AMOVNTO, yxr_ml, Pe, opBytes{0xe7}},
{AMOVNTDQA, ylddqu, Pq4, opBytes{0x2a}},
{AMOVNTPD, yxr_ml, Pe, opBytes{0x2b}},
{AMOVNTPS, yxr_ml, Pm, opBytes{0x2b}},
{AMOVNTQ, ymr_ml, Pm, opBytes{0xe7}},
{AMOVQ, ymovq, Pw8, opBytes{0x6f, 0x7f, Pf2, 0xd6, Pf3, 0x7e, Pe, 0xd6, 0x89, 0x8b, 0xc7, 00, 0xb8, 0xc7, 00, 0x6e, 0x7e, Pe, 0x6e, Pe, 0x7e, 0}},
{AMOVQOZX, ymrxr, Pf3, opBytes{0xd6, 0x7e}},
{AMOVSB, ynone, Pb, opBytes{0xa4}},
{AMOVSD, yxmov, Pf2, opBytes{0x10, 0x11}},
{AMOVSL, ynone, Px, opBytes{0xa5}},
{AMOVSQ, ynone, Pw, opBytes{0xa5}},
{AMOVSS, yxmov, Pf3, opBytes{0x10, 0x11}},
{AMOVSW, ynone, Pe, opBytes{0xa5}},
{AMOVUPD, yxmov, Pe, opBytes{0x10, 0x11}},
{AMOVUPS, yxmov, Pm, opBytes{0x10, 0x11}},
{AMOVW, ymovw, Pe, opBytes{0x89, 0x8b, 0xb8, 0xc7, 00, 0}},
{AMOVWLSX, yml_rl, Pm, opBytes{0xbf}},
{AMOVWLZX, yml_rl, Pm, opBytes{0xb7}},
{AMOVWQSX, yml_rl, Pw, opBytes{0x0f, 0xbf}},
{AMOVWQZX, yml_rl, Pw, opBytes{0x0f, 0xb7}},
{AMPSADBW, yxshuf, Pq, opBytes{0x3a, 0x42, 0}},
{AMULB, ydivb, Pb, opBytes{0xf6, 04}},
{AMULL, ydivl, Px, opBytes{0xf7, 04}},
{AMULPD, yxm, Pe, opBytes{0x59}},
{AMULPS, yxm, Ym, opBytes{0x59}},
{AMULQ, ydivl, Pw, opBytes{0xf7, 04}},
{AMULSD, yxm, Pf2, opBytes{0x59}},
{AMULSS, yxm, Pf3, opBytes{0x59}},
{AMULW, ydivl, Pe, opBytes{0xf7, 04}},
{ANEGB, yscond, Pb, opBytes{0xf6, 03}},
{ANEGL, yscond, Px, opBytes{0xf7, 03}},
{ANEGQ, yscond, Pw, opBytes{0xf7, 03}},
{ANEGW, yscond, Pe, opBytes{0xf7, 03}},
{obj.ANOP, ynop, Px, opBytes{0, 0}},
{ANOTB, yscond, Pb, opBytes{0xf6, 02}},
{ANOTL, yscond, Px, opBytes{0xf7, 02}}, // TODO(rsc): yscond is wrong here.
{ANOTQ, yscond, Pw, opBytes{0xf7, 02}},
{ANOTW, yscond, Pe, opBytes{0xf7, 02}},
{AORB, yxorb, Pb, opBytes{0x0c, 0x80, 01, 0x08, 0x0a}},
{AORL, yaddl, Px, opBytes{0x83, 01, 0x0d, 0x81, 01, 0x09, 0x0b}},
{AORPD, yxm, Pq, opBytes{0x56}},
{AORPS, yxm, Pm, opBytes{0x56}},
{AORQ, yaddl, Pw, opBytes{0x83, 01, 0x0d, 0x81, 01, 0x09, 0x0b}},
{AORW, yaddl, Pe, opBytes{0x83, 01, 0x0d, 0x81, 01, 0x09, 0x0b}},
{AOUTB, yin, Pb, opBytes{0xe6, 0xee}},
{AOUTL, yin, Px, opBytes{0xe7, 0xef}},
{AOUTW, yin, Pe, opBytes{0xe7, 0xef}},
{AOUTSB, ynone, Pb, opBytes{0x6e}},
{AOUTSL, ynone, Px, opBytes{0x6f}},
{AOUTSW, ynone, Pe, opBytes{0x6f}},
{APABSB, yxm_q4, Pq4, opBytes{0x1c}},
{APABSD, yxm_q4, Pq4, opBytes{0x1e}},
{APABSW, yxm_q4, Pq4, opBytes{0x1d}},
{APACKSSLW, ymm, Py1, opBytes{0x6b, Pe, 0x6b}},
{APACKSSWB, ymm, Py1, opBytes{0x63, Pe, 0x63}},
{APACKUSDW, yxm_q4, Pq4, opBytes{0x2b}},
{APACKUSWB, ymm, Py1, opBytes{0x67, Pe, 0x67}},
{APADDB, ymm, Py1, opBytes{0xfc, Pe, 0xfc}},
{APADDL, ymm, Py1, opBytes{0xfe, Pe, 0xfe}},
{APADDQ, yxm, Pe, opBytes{0xd4}},
{APADDSB, ymm, Py1, opBytes{0xec, Pe, 0xec}},
{APADDSW, ymm, Py1, opBytes{0xed, Pe, 0xed}},
{APADDUSB, ymm, Py1, opBytes{0xdc, Pe, 0xdc}},
{APADDUSW, ymm, Py1, opBytes{0xdd, Pe, 0xdd}},
{APADDW, ymm, Py1, opBytes{0xfd, Pe, 0xfd}},
{APALIGNR, ypalignr, Pq, opBytes{0x3a, 0x0f}},
{APAND, ymm, Py1, opBytes{0xdb, Pe, 0xdb}},
{APANDN, ymm, Py1, opBytes{0xdf, Pe, 0xdf}},
{APAUSE, ynone, Px, opBytes{0xf3, 0x90}},
{APAVGB, ymm, Py1, opBytes{0xe0, Pe, 0xe0}},
{APAVGW, ymm, Py1, opBytes{0xe3, Pe, 0xe3}},
{APBLENDW, yxshuf, Pq, opBytes{0x3a, 0x0e, 0}},
{APCMPEQB, ymm, Py1, opBytes{0x74, Pe, 0x74}},
{APCMPEQL, ymm, Py1, opBytes{0x76, Pe, 0x76}},
{APCMPEQQ, yxm_q4, Pq4, opBytes{0x29}},
{APCMPEQW, ymm, Py1, opBytes{0x75, Pe, 0x75}},
{APCMPGTB, ymm, Py1, opBytes{0x64, Pe, 0x64}},
{APCMPGTL, ymm, Py1, opBytes{0x66, Pe, 0x66}},
{APCMPGTQ, yxm_q4, Pq4, opBytes{0x37}},
{APCMPGTW, ymm, Py1, opBytes{0x65, Pe, 0x65}},
{APCMPISTRI, yxshuf, Pq, opBytes{0x3a, 0x63, 0}},
{APCMPISTRM, yxshuf, Pq, opBytes{0x3a, 0x62, 0}},
{APEXTRW, yextrw, Pq, opBytes{0xc5, 0, 0x3a, 0x15, 0}},
{APEXTRB, yextr, Pq, opBytes{0x3a, 0x14, 00}},
{APEXTRD, yextr, Pq, opBytes{0x3a, 0x16, 00}},
{APEXTRQ, yextr, Pq3, opBytes{0x3a, 0x16, 00}},
{APHADDD, ymmxmm0f38, Px, opBytes{0x0F, 0x38, 0x02, 0, 0x66, 0x0F, 0x38, 0x02, 0}},
{APHADDSW, yxm_q4, Pq4, opBytes{0x03}},
{APHADDW, yxm_q4, Pq4, opBytes{0x01}},
{APHMINPOSUW, yxm_q4, Pq4, opBytes{0x41}},
{APHSUBD, yxm_q4, Pq4, opBytes{0x06}},
{APHSUBSW, yxm_q4, Pq4, opBytes{0x07}},
{APHSUBW, yxm_q4, Pq4, opBytes{0x05}},
{APINSRW, yinsrw, Pq, opBytes{0xc4, 00}},
{APINSRB, yinsr, Pq, opBytes{0x3a, 0x20, 00}},
{APINSRD, yinsr, Pq, opBytes{0x3a, 0x22, 00}},
{APINSRQ, yinsr, Pq3, opBytes{0x3a, 0x22, 00}},
{APMADDUBSW, yxm_q4, Pq4, opBytes{0x04}},
{APMADDWL, ymm, Py1, opBytes{0xf5, Pe, 0xf5}},
{APMAXSB, yxm_q4, Pq4, opBytes{0x3c}},
{APMAXSD, yxm_q4, Pq4, opBytes{0x3d}},
{APMAXSW, yxm, Pe, opBytes{0xee}},
{APMAXUB, yxm, Pe, opBytes{0xde}},
{APMAXUD, yxm_q4, Pq4, opBytes{0x3f}},
{APMAXUW, yxm_q4, Pq4, opBytes{0x3e}},
{APMINSB, yxm_q4, Pq4, opBytes{0x38}},
{APMINSD, yxm_q4, Pq4, opBytes{0x39}},
{APMINSW, yxm, Pe, opBytes{0xea}},
{APMINUB, yxm, Pe, opBytes{0xda}},
{APMINUD, yxm_q4, Pq4, opBytes{0x3b}},
{APMINUW, yxm_q4, Pq4, opBytes{0x3a}},
{APMOVMSKB, ymskb, Px, opBytes{Pe, 0xd7, 0xd7}},
{APMOVSXBD, yxm_q4, Pq4, opBytes{0x21}},
{APMOVSXBQ, yxm_q4, Pq4, opBytes{0x22}},
{APMOVSXBW, yxm_q4, Pq4, opBytes{0x20}},
{APMOVSXDQ, yxm_q4, Pq4, opBytes{0x25}},
{APMOVSXWD, yxm_q4, Pq4, opBytes{0x23}},
{APMOVSXWQ, yxm_q4, Pq4, opBytes{0x24}},
{APMOVZXBD, yxm_q4, Pq4, opBytes{0x31}},
{APMOVZXBQ, yxm_q4, Pq4, opBytes{0x32}},
{APMOVZXBW, yxm_q4, Pq4, opBytes{0x30}},
{APMOVZXDQ, yxm_q4, Pq4, opBytes{0x35}},
{APMOVZXWD, yxm_q4, Pq4, opBytes{0x33}},
{APMOVZXWQ, yxm_q4, Pq4, opBytes{0x34}},
{APMULDQ, yxm_q4, Pq4, opBytes{0x28}},
{APMULHRSW, yxm_q4, Pq4, opBytes{0x0b}},
{APMULHUW, ymm, Py1, opBytes{0xe4, Pe, 0xe4}},
{APMULHW, ymm, Py1, opBytes{0xe5, Pe, 0xe5}},
{APMULLD, yxm_q4, Pq4, opBytes{0x40}},
{APMULLW, ymm, Py1, opBytes{0xd5, Pe, 0xd5}},
{APMULULQ, ymm, Py1, opBytes{0xf4, Pe, 0xf4}},
{APOPAL, ynone, P32, opBytes{0x61}},
{APOPAW, ynone, Pe, opBytes{0x61}},
{APOPCNTW, yml_rl, Pef3, opBytes{0xb8}},
{APOPCNTL, yml_rl, Pf3, opBytes{0xb8}},
{APOPCNTQ, yml_rl, Pfw, opBytes{0xb8}},
{APOPFL, ynone, P32, opBytes{0x9d}},
{APOPFQ, ynone, Py, opBytes{0x9d}},
{APOPFW, ynone, Pe, opBytes{0x9d}},
{APOPL, ypopl, P32, opBytes{0x58, 0x8f, 00}},
{APOPQ, ypopl, Py, opBytes{0x58, 0x8f, 00}},
{APOPW, ypopl, Pe, opBytes{0x58, 0x8f, 00}},
{APOR, ymm, Py1, opBytes{0xeb, Pe, 0xeb}},
{APSADBW, yxm, Pq, opBytes{0xf6}},
{APSHUFHW, yxshuf, Pf3, opBytes{0x70, 00}},
{APSHUFL, yxshuf, Pq, opBytes{0x70, 00}},
{APSHUFLW, yxshuf, Pf2, opBytes{0x70, 00}},
{APSHUFW, ymshuf, Pm, opBytes{0x70, 00}},
{APSHUFB, ymshufb, Pq, opBytes{0x38, 0x00}},
{APSIGNB, yxm_q4, Pq4, opBytes{0x08}},
{APSIGND, yxm_q4, Pq4, opBytes{0x0a}},
{APSIGNW, yxm_q4, Pq4, opBytes{0x09}},
{APSLLO, ypsdq, Pq, opBytes{0x73, 07}},
{APSLLL, yps, Py3, opBytes{0xf2, 0x72, 06, Pe, 0xf2, Pe, 0x72, 06}},
{APSLLQ, yps, Py3, opBytes{0xf3, 0x73, 06, Pe, 0xf3, Pe, 0x73, 06}},
{APSLLW, yps, Py3, opBytes{0xf1, 0x71, 06, Pe, 0xf1, Pe, 0x71, 06}},
{APSRAL, yps, Py3, opBytes{0xe2, 0x72, 04, Pe, 0xe2, Pe, 0x72, 04}},
{APSRAW, yps, Py3, opBytes{0xe1, 0x71, 04, Pe, 0xe1, Pe, 0x71, 04}},
{APSRLO, ypsdq, Pq, opBytes{0x73, 03}},
{APSRLL, yps, Py3, opBytes{0xd2, 0x72, 02, Pe, 0xd2, Pe, 0x72, 02}},
{APSRLQ, yps, Py3, opBytes{0xd3, 0x73, 02, Pe, 0xd3, Pe, 0x73, 02}},
{APSRLW, yps, Py3, opBytes{0xd1, 0x71, 02, Pe, 0xd1, Pe, 0x71, 02}},
{APSUBB, yxm, Pe, opBytes{0xf8}},
{APSUBL, yxm, Pe, opBytes{0xfa}},
{APSUBQ, yxm, Pe, opBytes{0xfb}},
{APSUBSB, yxm, Pe, opBytes{0xe8}},
{APSUBSW, yxm, Pe, opBytes{0xe9}},
{APSUBUSB, yxm, Pe, opBytes{0xd8}},
{APSUBUSW, yxm, Pe, opBytes{0xd9}},
{APSUBW, yxm, Pe, opBytes{0xf9}},
{APTEST, yxm_q4, Pq4, opBytes{0x17}},
{APUNPCKHBW, ymm, Py1, opBytes{0x68, Pe, 0x68}},
{APUNPCKHLQ, ymm, Py1, opBytes{0x6a, Pe, 0x6a}},
{APUNPCKHQDQ, yxm, Pe, opBytes{0x6d}},
{APUNPCKHWL, ymm, Py1, opBytes{0x69, Pe, 0x69}},
{APUNPCKLBW, ymm, Py1, opBytes{0x60, Pe, 0x60}},
{APUNPCKLLQ, ymm, Py1, opBytes{0x62, Pe, 0x62}},
{APUNPCKLQDQ, yxm, Pe, opBytes{0x6c}},
{APUNPCKLWL, ymm, Py1, opBytes{0x61, Pe, 0x61}},
{APUSHAL, ynone, P32, opBytes{0x60}},
{APUSHAW, ynone, Pe, opBytes{0x60}},
{APUSHFL, ynone, P32, opBytes{0x9c}},
{APUSHFQ, ynone, Py, opBytes{0x9c}},
{APUSHFW, ynone, Pe, opBytes{0x9c}},
{APUSHL, ypushl, P32, opBytes{0x50, 0xff, 06, 0x6a, 0x68}},
{APUSHQ, ypushl, Py, opBytes{0x50, 0xff, 06, 0x6a, 0x68}},
{APUSHW, ypushl, Pe, opBytes{0x50, 0xff, 06, 0x6a, 0x68}},
{APXOR, ymm, Py1, opBytes{0xef, Pe, 0xef}},
{AQUAD, ybyte, Px, opBytes{8}},
{ARCLB, yshb, Pb, opBytes{0xd0, 02, 0xc0, 02, 0xd2, 02}},
{ARCLL, yshl, Px, opBytes{0xd1, 02, 0xc1, 02, 0xd3, 02, 0xd3, 02}},
{ARCLQ, yshl, Pw, opBytes{0xd1, 02, 0xc1, 02, 0xd3, 02, 0xd3, 02}},
{ARCLW, yshl, Pe, opBytes{0xd1, 02, 0xc1, 02, 0xd3, 02, 0xd3, 02}},
{ARCPPS, yxm, Pm, opBytes{0x53}},
{ARCPSS, yxm, Pf3, opBytes{0x53}},
{ARCRB, yshb, Pb, opBytes{0xd0, 03, 0xc0, 03, 0xd2, 03}},
{ARCRL, yshl, Px, opBytes{0xd1, 03, 0xc1, 03, 0xd3, 03, 0xd3, 03}},
{ARCRQ, yshl, Pw, opBytes{0xd1, 03, 0xc1, 03, 0xd3, 03, 0xd3, 03}},
{ARCRW, yshl, Pe, opBytes{0xd1, 03, 0xc1, 03, 0xd3, 03, 0xd3, 03}},
{AREP, ynone, Px, opBytes{0xf3}},
{AREPN, ynone, Px, opBytes{0xf2}},
{obj.ARET, ynone, Px, opBytes{0xc3}},
{ARETFW, yret, Pe, opBytes{0xcb, 0xca}},
{ARETFL, yret, Px, opBytes{0xcb, 0xca}},
{ARETFQ, yret, Pw, opBytes{0xcb, 0xca}},
{AROLB, yshb, Pb, opBytes{0xd0, 00, 0xc0, 00, 0xd2, 00}},
{AROLL, yshl, Px, opBytes{0xd1, 00, 0xc1, 00, 0xd3, 00, 0xd3, 00}},
{AROLQ, yshl, Pw, opBytes{0xd1, 00, 0xc1, 00, 0xd3, 00, 0xd3, 00}},
{AROLW, yshl, Pe, opBytes{0xd1, 00, 0xc1, 00, 0xd3, 00, 0xd3, 00}},
{ARORB, yshb, Pb, opBytes{0xd0, 01, 0xc0, 01, 0xd2, 01}},
{ARORL, yshl, Px, opBytes{0xd1, 01, 0xc1, 01, 0xd3, 01, 0xd3, 01}},
{ARORQ, yshl, Pw, opBytes{0xd1, 01, 0xc1, 01, 0xd3, 01, 0xd3, 01}},
{ARORW, yshl, Pe, opBytes{0xd1, 01, 0xc1, 01, 0xd3, 01, 0xd3, 01}},
{ARSQRTPS, yxm, Pm, opBytes{0x52}},
{ARSQRTSS, yxm, Pf3, opBytes{0x52}},
{ASAHF, ynone, Px, opBytes{0x9e, 00, 0x86, 0xe0, 0x50, 0x9d}}, // XCHGB AH,AL; PUSH AX; POPFL
{ASALB, yshb, Pb, opBytes{0xd0, 04, 0xc0, 04, 0xd2, 04}},
{ASALL, yshl, Px, opBytes{0xd1, 04, 0xc1, 04, 0xd3, 04, 0xd3, 04}},
{ASALQ, yshl, Pw, opBytes{0xd1, 04, 0xc1, 04, 0xd3, 04, 0xd3, 04}},
{ASALW, yshl, Pe, opBytes{0xd1, 04, 0xc1, 04, 0xd3, 04, 0xd3, 04}},
{ASARB, yshb, Pb, opBytes{0xd0, 07, 0xc0, 07, 0xd2, 07}},
{ASARL, yshl, Px, opBytes{0xd1, 07, 0xc1, 07, 0xd3, 07, 0xd3, 07}},
{ASARQ, yshl, Pw, opBytes{0xd1, 07, 0xc1, 07, 0xd3, 07, 0xd3, 07}},
{ASARW, yshl, Pe, opBytes{0xd1, 07, 0xc1, 07, 0xd3, 07, 0xd3, 07}},
{ASBBB, yxorb, Pb, opBytes{0x1c, 0x80, 03, 0x18, 0x1a}},
{ASBBL, yaddl, Px, opBytes{0x83, 03, 0x1d, 0x81, 03, 0x19, 0x1b}},
{ASBBQ, yaddl, Pw, opBytes{0x83, 03, 0x1d, 0x81, 03, 0x19, 0x1b}},
{ASBBW, yaddl, Pe, opBytes{0x83, 03, 0x1d, 0x81, 03, 0x19, 0x1b}},
{ASCASB, ynone, Pb, opBytes{0xae}},
{ASCASL, ynone, Px, opBytes{0xaf}},
{ASCASQ, ynone, Pw, opBytes{0xaf}},
{ASCASW, ynone, Pe, opBytes{0xaf}},
{ASETCC, yscond, Pb, opBytes{0x0f, 0x93, 00}},
{ASETCS, yscond, Pb, opBytes{0x0f, 0x92, 00}},
{ASETEQ, yscond, Pb, opBytes{0x0f, 0x94, 00}},
{ASETGE, yscond, Pb, opBytes{0x0f, 0x9d, 00}},
{ASETGT, yscond, Pb, opBytes{0x0f, 0x9f, 00}},
{ASETHI, yscond, Pb, opBytes{0x0f, 0x97, 00}},
{ASETLE, yscond, Pb, opBytes{0x0f, 0x9e, 00}},
{ASETLS, yscond, Pb, opBytes{0x0f, 0x96, 00}},
{ASETLT, yscond, Pb, opBytes{0x0f, 0x9c, 00}},
{ASETMI, yscond, Pb, opBytes{0x0f, 0x98, 00}},
{ASETNE, yscond, Pb, opBytes{0x0f, 0x95, 00}},
{ASETOC, yscond, Pb, opBytes{0x0f, 0x91, 00}},
{ASETOS, yscond, Pb, opBytes{0x0f, 0x90, 00}},
{ASETPC, yscond, Pb, opBytes{0x0f, 0x9b, 00}},
{ASETPL, yscond, Pb, opBytes{0x0f, 0x99, 00}},
{ASETPS, yscond, Pb, opBytes{0x0f, 0x9a, 00}},
{ASHLB, yshb, Pb, opBytes{0xd0, 04, 0xc0, 04, 0xd2, 04}},
{ASHLL, yshl, Px, opBytes{0xd1, 04, 0xc1, 04, 0xd3, 04, 0xd3, 04}},
{ASHLQ, yshl, Pw, opBytes{0xd1, 04, 0xc1, 04, 0xd3, 04, 0xd3, 04}},
{ASHLW, yshl, Pe, opBytes{0xd1, 04, 0xc1, 04, 0xd3, 04, 0xd3, 04}},
{ASHRB, yshb, Pb, opBytes{0xd0, 05, 0xc0, 05, 0xd2, 05}},
{ASHRL, yshl, Px, opBytes{0xd1, 05, 0xc1, 05, 0xd3, 05, 0xd3, 05}},
{ASHRQ, yshl, Pw, opBytes{0xd1, 05, 0xc1, 05, 0xd3, 05, 0xd3, 05}},
{ASHRW, yshl, Pe, opBytes{0xd1, 05, 0xc1, 05, 0xd3, 05, 0xd3, 05}},
{ASHUFPD, yxshuf, Pq, opBytes{0xc6, 00}},
{ASHUFPS, yxshuf, Pm, opBytes{0xc6, 00}},
{ASQRTPD, yxm, Pe, opBytes{0x51}},
{ASQRTPS, yxm, Pm, opBytes{0x51}},
{ASQRTSD, yxm, Pf2, opBytes{0x51}},
{ASQRTSS, yxm, Pf3, opBytes{0x51}},
{ASTC, ynone, Px, opBytes{0xf9}},
{ASTD, ynone, Px, opBytes{0xfd}},
{ASTI, ynone, Px, opBytes{0xfb}},
{ASTMXCSR, ysvrs_om, Pm, opBytes{0xae, 03, 0xae, 03}},
{ASTOSB, ynone, Pb, opBytes{0xaa}},
{ASTOSL, ynone, Px, opBytes{0xab}},
{ASTOSQ, ynone, Pw, opBytes{0xab}},
{ASTOSW, ynone, Pe, opBytes{0xab}},
{ASUBB, yxorb, Pb, opBytes{0x2c, 0x80, 05, 0x28, 0x2a}},
{ASUBL, yaddl, Px, opBytes{0x83, 05, 0x2d, 0x81, 05, 0x29, 0x2b}},
{ASUBPD, yxm, Pe, opBytes{0x5c}},
{ASUBPS, yxm, Pm, opBytes{0x5c}},
{ASUBQ, yaddl, Pw, opBytes{0x83, 05, 0x2d, 0x81, 05, 0x29, 0x2b}},
{ASUBSD, yxm, Pf2, opBytes{0x5c}},
{ASUBSS, yxm, Pf3, opBytes{0x5c}},
{ASUBW, yaddl, Pe, opBytes{0x83, 05, 0x2d, 0x81, 05, 0x29, 0x2b}},
{ASWAPGS, ynone, Pm, opBytes{0x01, 0xf8}},
{ASYSCALL, ynone, Px, opBytes{0x0f, 0x05}}, // fast syscall
{ATESTB, yxorb, Pb, opBytes{0xa8, 0xf6, 00, 0x84, 0x84}},
{ATESTL, ytestl, Px, opBytes{0xa9, 0xf7, 00, 0x85, 0x85}},
{ATESTQ, ytestl, Pw, opBytes{0xa9, 0xf7, 00, 0x85, 0x85}},
{ATESTW, ytestl, Pe, opBytes{0xa9, 0xf7, 00, 0x85, 0x85}},
{ATPAUSE, ywrfsbase, Pq, opBytes{0xae, 06}},
{obj.ATEXT, ytext, Px, opBytes{}},
{AUCOMISD, yxm, Pe, opBytes{0x2e}},
{AUCOMISS, yxm, Pm, opBytes{0x2e}},
{AUNPCKHPD, yxm, Pe, opBytes{0x15}},
{AUNPCKHPS, yxm, Pm, opBytes{0x15}},
{AUNPCKLPD, yxm, Pe, opBytes{0x14}},
{AUNPCKLPS, yxm, Pm, opBytes{0x14}},
{AUMONITOR, ywrfsbase, Pf3, opBytes{0xae, 06}},
{AVERR, ydivl, Pm, opBytes{0x00, 04}},
{AVERW, ydivl, Pm, opBytes{0x00, 05}},
{AWAIT, ynone, Px, opBytes{0x9b}},
{AWORD, ybyte, Px, opBytes{2}},
{AXCHGB, yml_mb, Pb, opBytes{0x86, 0x86}},
{AXCHGL, yxchg, Px, opBytes{0x90, 0x90, 0x87, 0x87}},
{AXCHGQ, yxchg, Pw, opBytes{0x90, 0x90, 0x87, 0x87}},
{AXCHGW, yxchg, Pe, opBytes{0x90, 0x90, 0x87, 0x87}},
{AXLAT, ynone, Px, opBytes{0xd7}},
{AXORB, yxorb, Pb, opBytes{0x34, 0x80, 06, 0x30, 0x32}},
{AXORL, yaddl, Px, opBytes{0x83, 06, 0x35, 0x81, 06, 0x31, 0x33}},
{AXORPD, yxm, Pe, opBytes{0x57}},
{AXORPS, yxm, Pm, opBytes{0x57}},
{AXORQ, yaddl, Pw, opBytes{0x83, 06, 0x35, 0x81, 06, 0x31, 0x33}},
{AXORW, yaddl, Pe, opBytes{0x83, 06, 0x35, 0x81, 06, 0x31, 0x33}},
{AFMOVB, yfmvx, Px, opBytes{0xdf, 04}},
{AFMOVBP, yfmvp, Px, opBytes{0xdf, 06}},
{AFMOVD, yfmvd, Px, opBytes{0xdd, 00, 0xdd, 02, 0xd9, 00, 0xdd, 02}},
{AFMOVDP, yfmvdp, Px, opBytes{0xdd, 03, 0xdd, 03}},
{AFMOVF, yfmvf, Px, opBytes{0xd9, 00, 0xd9, 02}},
{AFMOVFP, yfmvp, Px, opBytes{0xd9, 03}},
{AFMOVL, yfmvf, Px, opBytes{0xdb, 00, 0xdb, 02}},
{AFMOVLP, yfmvp, Px, opBytes{0xdb, 03}},
{AFMOVV, yfmvx, Px, opBytes{0xdf, 05}},
{AFMOVVP, yfmvp, Px, opBytes{0xdf, 07}},
{AFMOVW, yfmvf, Px, opBytes{0xdf, 00, 0xdf, 02}},
{AFMOVWP, yfmvp, Px, opBytes{0xdf, 03}},
{AFMOVX, yfmvx, Px, opBytes{0xdb, 05}},
{AFMOVXP, yfmvp, Px, opBytes{0xdb, 07}},
{AFCMOVCC, yfcmv, Px, opBytes{0xdb, 00}},
{AFCMOVCS, yfcmv, Px, opBytes{0xda, 00}},
{AFCMOVEQ, yfcmv, Px, opBytes{0xda, 01}},
{AFCMOVHI, yfcmv, Px, opBytes{0xdb, 02}},
{AFCMOVLS, yfcmv, Px, opBytes{0xda, 02}},
{AFCMOVB, yfcmv, Px, opBytes{0xda, 00}},
{AFCMOVBE, yfcmv, Px, opBytes{0xda, 02}},
{AFCMOVNB, yfcmv, Px, opBytes{0xdb, 00}},
{AFCMOVNBE, yfcmv, Px, opBytes{0xdb, 02}},
{AFCMOVE, yfcmv, Px, opBytes{0xda, 01}},
{AFCMOVNE, yfcmv, Px, opBytes{0xdb, 01}},
{AFCMOVNU, yfcmv, Px, opBytes{0xdb, 03}},
{AFCMOVU, yfcmv, Px, opBytes{0xda, 03}},
{AFCMOVUN, yfcmv, Px, opBytes{0xda, 03}},
{AFCOMD, yfadd, Px, opBytes{0xdc, 02, 0xd8, 02, 0xdc, 02}}, // botch
{AFCOMDP, yfadd, Px, opBytes{0xdc, 03, 0xd8, 03, 0xdc, 03}}, // botch
{AFCOMDPP, ycompp, Px, opBytes{0xde, 03}},
{AFCOMF, yfmvx, Px, opBytes{0xd8, 02}},
{AFCOMFP, yfmvx, Px, opBytes{0xd8, 03}},
{AFCOMI, yfcmv, Px, opBytes{0xdb, 06}},
{AFCOMIP, yfcmv, Px, opBytes{0xdf, 06}},
{AFCOML, yfmvx, Px, opBytes{0xda, 02}},
{AFCOMLP, yfmvx, Px, opBytes{0xda, 03}},
{AFCOMW, yfmvx, Px, opBytes{0xde, 02}},
{AFCOMWP, yfmvx, Px, opBytes{0xde, 03}},
{AFUCOM, ycompp, Px, opBytes{0xdd, 04}},
{AFUCOMI, ycompp, Px, opBytes{0xdb, 05}},
{AFUCOMIP, ycompp, Px, opBytes{0xdf, 05}},
{AFUCOMP, ycompp, Px, opBytes{0xdd, 05}},
{AFUCOMPP, ycompp, Px, opBytes{0xda, 13}},
{AFADDDP, ycompp, Px, opBytes{0xde, 00}},
{AFADDW, yfmvx, Px, opBytes{0xde, 00}},
{AFADDL, yfmvx, Px, opBytes{0xda, 00}},
{AFADDF, yfmvx, Px, opBytes{0xd8, 00}},
{AFADDD, yfadd, Px, opBytes{0xdc, 00, 0xd8, 00, 0xdc, 00}},
{AFMULDP, ycompp, Px, opBytes{0xde, 01}},
{AFMULW, yfmvx, Px, opBytes{0xde, 01}},
{AFMULL, yfmvx, Px, opBytes{0xda, 01}},
{AFMULF, yfmvx, Px, opBytes{0xd8, 01}},
{AFMULD, yfadd, Px, opBytes{0xdc, 01, 0xd8, 01, 0xdc, 01}},
{AFSUBDP, ycompp, Px, opBytes{0xde, 05}},
{AFSUBW, yfmvx, Px, opBytes{0xde, 04}},
{AFSUBL, yfmvx, Px, opBytes{0xda, 04}},
{AFSUBF, yfmvx, Px, opBytes{0xd8, 04}},
{AFSUBD, yfadd, Px, opBytes{0xdc, 04, 0xd8, 04, 0xdc, 05}},
{AFSUBRDP, ycompp, Px, opBytes{0xde, 04}},
{AFSUBRW, yfmvx, Px, opBytes{0xde, 05}},
{AFSUBRL, yfmvx, Px, opBytes{0xda, 05}},
{AFSUBRF, yfmvx, Px, opBytes{0xd8, 05}},
{AFSUBRD, yfadd, Px, opBytes{0xdc, 05, 0xd8, 05, 0xdc, 04}},
{AFDIVDP, ycompp, Px, opBytes{0xde, 07}},
{AFDIVW, yfmvx, Px, opBytes{0xde, 06}},
{AFDIVL, yfmvx, Px, opBytes{0xda, 06}},
{AFDIVF, yfmvx, Px, opBytes{0xd8, 06}},
{AFDIVD, yfadd, Px, opBytes{0xdc, 06, 0xd8, 06, 0xdc, 07}},
{AFDIVRDP, ycompp, Px, opBytes{0xde, 06}},
{AFDIVRW, yfmvx, Px, opBytes{0xde, 07}},
{AFDIVRL, yfmvx, Px, opBytes{0xda, 07}},
{AFDIVRF, yfmvx, Px, opBytes{0xd8, 07}},
{AFDIVRD, yfadd, Px, opBytes{0xdc, 07, 0xd8, 07, 0xdc, 06}},
{AFXCHD, yfxch, Px, opBytes{0xd9, 01, 0xd9, 01}},
{AFFREE, nil, 0, opBytes{}},
{AFLDCW, ysvrs_mo, Px, opBytes{0xd9, 05, 0xd9, 05}},
{AFLDENV, ysvrs_mo, Px, opBytes{0xd9, 04, 0xd9, 04}},
{AFRSTOR, ysvrs_mo, Px, opBytes{0xdd, 04, 0xdd, 04}},
{AFSAVE, ysvrs_om, Px, opBytes{0xdd, 06, 0xdd, 06}},
{AFSTCW, ysvrs_om, Px, opBytes{0xd9, 07, 0xd9, 07}},
{AFSTENV, ysvrs_om, Px, opBytes{0xd9, 06, 0xd9, 06}},
{AFSTSW, ystsw, Px, opBytes{0xdd, 07, 0xdf, 0xe0}},
{AF2XM1, ynone, Px, opBytes{0xd9, 0xf0}},
{AFABS, ynone, Px, opBytes{0xd9, 0xe1}},
{AFBLD, ysvrs_mo, Px, opBytes{0xdf, 04}},
{AFBSTP, yclflush, Px, opBytes{0xdf, 06}},
{AFCHS, ynone, Px, opBytes{0xd9, 0xe0}},
{AFCLEX, ynone, Px, opBytes{0xdb, 0xe2}},
{AFCOS, ynone, Px, opBytes{0xd9, 0xff}},
{AFDECSTP, ynone, Px, opBytes{0xd9, 0xf6}},
{AFINCSTP, ynone, Px, opBytes{0xd9, 0xf7}},
{AFINIT, ynone, Px, opBytes{0xdb, 0xe3}},
{AFLD1, ynone, Px, opBytes{0xd9, 0xe8}},
{AFLDL2E, ynone, Px, opBytes{0xd9, 0xea}},
{AFLDL2T, ynone, Px, opBytes{0xd9, 0xe9}},
{AFLDLG2, ynone, Px, opBytes{0xd9, 0xec}},
{AFLDLN2, ynone, Px, opBytes{0xd9, 0xed}},
{AFLDPI, ynone, Px, opBytes{0xd9, 0xeb}},
{AFLDZ, ynone, Px, opBytes{0xd9, 0xee}},
{AFNOP, ynone, Px, opBytes{0xd9, 0xd0}},
{AFPATAN, ynone, Px, opBytes{0xd9, 0xf3}},
{AFPREM, ynone, Px, opBytes{0xd9, 0xf8}},
{AFPREM1, ynone, Px, opBytes{0xd9, 0xf5}},
{AFPTAN, ynone, Px, opBytes{0xd9, 0xf2}},
{AFRNDINT, ynone, Px, opBytes{0xd9, 0xfc}},
{AFSCALE, ynone, Px, opBytes{0xd9, 0xfd}},
{AFSIN, ynone, Px, opBytes{0xd9, 0xfe}},
{AFSINCOS, ynone, Px, opBytes{0xd9, 0xfb}},
{AFSQRT, ynone, Px, opBytes{0xd9, 0xfa}},
{AFTST, ynone, Px, opBytes{0xd9, 0xe4}},
{AFXAM, ynone, Px, opBytes{0xd9, 0xe5}},
{AFXTRACT, ynone, Px, opBytes{0xd9, 0xf4}},
{AFYL2X, ynone, Px, opBytes{0xd9, 0xf1}},
{AFYL2XP1, ynone, Px, opBytes{0xd9, 0xf9}},
{ACMPXCHGB, yrb_mb, Pb, opBytes{0x0f, 0xb0}},
{ACMPXCHGL, yrl_ml, Px, opBytes{0x0f, 0xb1}},
{ACMPXCHGW, yrl_ml, Pe, opBytes{0x0f, 0xb1}},
{ACMPXCHGQ, yrl_ml, Pw, opBytes{0x0f, 0xb1}},
{ACMPXCHG8B, yscond, Pm, opBytes{0xc7, 01}},
{ACMPXCHG16B, yscond, Pw, opBytes{0x0f, 0xc7, 01}},
{AINVD, ynone, Pm, opBytes{0x08}},
{AINVLPG, ydivb, Pm, opBytes{0x01, 07}},
{AINVPCID, ycrc32l, Pe, opBytes{0x0f, 0x38, 0x82, 0}},
{ALFENCE, ynone, Pm, opBytes{0xae, 0xe8}},
{AMFENCE, ynone, Pm, opBytes{0xae, 0xf0}},
{AMOVNTIL, yrl_ml, Pm, opBytes{0xc3}},
{AMOVNTIQ, yrl_ml, Pw, opBytes{0x0f, 0xc3}},
{ARDPKRU, ynone, Pm, opBytes{0x01, 0xee, 0}},
{ARDMSR, ynone, Pm, opBytes{0x32}},
{ARDPMC, ynone, Pm, opBytes{0x33}},
{ARDTSC, ynone, Pm, opBytes{0x31}},
{ARSM, ynone, Pm, opBytes{0xaa}},
{ASFENCE, ynone, Pm, opBytes{0xae, 0xf8}},
{ASYSRET, ynone, Pm, opBytes{0x07}},
{AWBINVD, ynone, Pm, opBytes{0x09}},
{AWRMSR, ynone, Pm, opBytes{0x30}},
{AWRPKRU, ynone, Pm, opBytes{0x01, 0xef, 0}},
{AXADDB, yrb_mb, Pb, opBytes{0x0f, 0xc0}},
{AXADDL, yrl_ml, Px, opBytes{0x0f, 0xc1}},
{AXADDQ, yrl_ml, Pw, opBytes{0x0f, 0xc1}},
{AXADDW, yrl_ml, Pe, opBytes{0x0f, 0xc1}},
{ACRC32B, ycrc32b, Px, opBytes{0xf2, 0x0f, 0x38, 0xf0, 0}},
{ACRC32L, ycrc32l, Px, opBytes{0xf2, 0x0f, 0x38, 0xf1, 0}},
{ACRC32Q, ycrc32l, Pw, opBytes{0xf2, 0x0f, 0x38, 0xf1, 0}},
{ACRC32W, ycrc32l, Pe, opBytes{0xf2, 0x0f, 0x38, 0xf1, 0}},
{APREFETCHT0, yprefetch, Pm, opBytes{0x18, 01}},
{APREFETCHT1, yprefetch, Pm, opBytes{0x18, 02}},
{APREFETCHT2, yprefetch, Pm, opBytes{0x18, 03}},
{APREFETCHNTA, yprefetch, Pm, opBytes{0x18, 00}},
{AMOVQL, yrl_ml, Px, opBytes{0x89}},
{obj.AUNDEF, ynone, Px, opBytes{0x0f, 0x0b}},
{AAESENC, yaes, Pq, opBytes{0x38, 0xdc, 0}},
{AAESENCLAST, yaes, Pq, opBytes{0x38, 0xdd, 0}},
{AAESDEC, yaes, Pq, opBytes{0x38, 0xde, 0}},
{AAESDECLAST, yaes, Pq, opBytes{0x38, 0xdf, 0}},
{AAESIMC, yaes, Pq, opBytes{0x38, 0xdb, 0}},
{AAESKEYGENASSIST, yxshuf, Pq, opBytes{0x3a, 0xdf, 0}},
{AROUNDPD, yxshuf, Pq, opBytes{0x3a, 0x09, 0}},
{AROUNDPS, yxshuf, Pq, opBytes{0x3a, 0x08, 0}},
{AROUNDSD, yxshuf, Pq, opBytes{0x3a, 0x0b, 0}},
{AROUNDSS, yxshuf, Pq, opBytes{0x3a, 0x0a, 0}},
{APSHUFD, yxshuf, Pq, opBytes{0x70, 0}},
{APCLMULQDQ, yxshuf, Pq, opBytes{0x3a, 0x44, 0}},
{APCMPESTRI, yxshuf, Pq, opBytes{0x3a, 0x61, 0}},
{APCMPESTRM, yxshuf, Pq, opBytes{0x3a, 0x60, 0}},
{AMOVDDUP, yxm, Pf2, opBytes{0x12}},
{AMOVSHDUP, yxm, Pf3, opBytes{0x16}},
{AMOVSLDUP, yxm, Pf3, opBytes{0x12}},
{ARDTSCP, ynone, Pm, opBytes{0x01, 0xf9, 0}},
{ASTAC, ynone, Pm, opBytes{0x01, 0xcb, 0}},
{AUD1, ynone, Pm, opBytes{0xb9, 0}},
{AUD2, ynone, Pm, opBytes{0x0b, 0}},
{AUMWAIT, ywrfsbase, Pf2, opBytes{0xae, 06}},
{ASYSENTER, ynone, Px, opBytes{0x0f, 0x34, 0}},
{ASYSENTER64, ynone, Pw, opBytes{0x0f, 0x34, 0}},
{ASYSEXIT, ynone, Px, opBytes{0x0f, 0x35, 0}},
{ASYSEXIT64, ynone, Pw, opBytes{0x0f, 0x35, 0}},
{ALMSW, ydivl, Pm, opBytes{0x01, 06}},
{ALLDT, ydivl, Pm, opBytes{0x00, 02}},
{ALIDT, ysvrs_mo, Pm, opBytes{0x01, 03}},
{ALGDT, ysvrs_mo, Pm, opBytes{0x01, 02}},
{ATZCNTW, ycrc32l, Pe, opBytes{0xf3, 0x0f, 0xbc, 0}},
{ATZCNTL, ycrc32l, Px, opBytes{0xf3, 0x0f, 0xbc, 0}},
{ATZCNTQ, ycrc32l, Pw, opBytes{0xf3, 0x0f, 0xbc, 0}},
{AXRSTOR, ydivl, Px, opBytes{0x0f, 0xae, 05}},
{AXRSTOR64, ydivl, Pw, opBytes{0x0f, 0xae, 05}},
{AXRSTORS, ydivl, Px, opBytes{0x0f, 0xc7, 03}},
{AXRSTORS64, ydivl, Pw, opBytes{0x0f, 0xc7, 03}},
{AXSAVE, yclflush, Px, opBytes{0x0f, 0xae, 04}},
{AXSAVE64, yclflush, Pw, opBytes{0x0f, 0xae, 04}},
{AXSAVEOPT, yclflush, Px, opBytes{0x0f, 0xae, 06}},
{AXSAVEOPT64, yclflush, Pw, opBytes{0x0f, 0xae, 06}},
{AXSAVEC, yclflush, Px, opBytes{0x0f, 0xc7, 04}},
{AXSAVEC64, yclflush, Pw, opBytes{0x0f, 0xc7, 04}},
{AXSAVES, yclflush, Px, opBytes{0x0f, 0xc7, 05}},
{AXSAVES64, yclflush, Pw, opBytes{0x0f, 0xc7, 05}},
{ASGDT, yclflush, Pm, opBytes{0x01, 00}},
{ASIDT, yclflush, Pm, opBytes{0x01, 01}},
{ARDRANDW, yrdrand, Pe, opBytes{0x0f, 0xc7, 06}},
{ARDRANDL, yrdrand, Px, opBytes{0x0f, 0xc7, 06}},
{ARDRANDQ, yrdrand, Pw, opBytes{0x0f, 0xc7, 06}},
{ARDSEEDW, yrdrand, Pe, opBytes{0x0f, 0xc7, 07}},
{ARDSEEDL, yrdrand, Px, opBytes{0x0f, 0xc7, 07}},
{ARDSEEDQ, yrdrand, Pw, opBytes{0x0f, 0xc7, 07}},
{ASTRW, yincq, Pe, opBytes{0x0f, 0x00, 01}},
{ASTRL, yincq, Px, opBytes{0x0f, 0x00, 01}},
{ASTRQ, yincq, Pw, opBytes{0x0f, 0x00, 01}},
{AXSETBV, ynone, Pm, opBytes{0x01, 0xd1, 0}},
{AMOVBEW, ymovbe, Pq, opBytes{0x38, 0xf0, 0, 0x38, 0xf1, 0}},
{AMOVBEL, ymovbe, Pm, opBytes{0x38, 0xf0, 0, 0x38, 0xf1, 0}},
{AMOVBEQ, ymovbe, Pw, opBytes{0x0f, 0x38, 0xf0, 0, 0x0f, 0x38, 0xf1, 0}},
{ANOPW, ydivl, Pe, opBytes{0x0f, 0x1f, 00}},
{ANOPL, ydivl, Px, opBytes{0x0f, 0x1f, 00}},
{ASLDTW, yincq, Pe, opBytes{0x0f, 0x00, 00}},
{ASLDTL, yincq, Px, opBytes{0x0f, 0x00, 00}},
{ASLDTQ, yincq, Pw, opBytes{0x0f, 0x00, 00}},
{ASMSWW, yincq, Pe, opBytes{0x0f, 0x01, 04}},
{ASMSWL, yincq, Px, opBytes{0x0f, 0x01, 04}},
{ASMSWQ, yincq, Pw, opBytes{0x0f, 0x01, 04}},
{ABLENDVPS, yblendvpd, Pq4, opBytes{0x14}},
{ABLENDVPD, yblendvpd, Pq4, opBytes{0x15}},
{APBLENDVB, yblendvpd, Pq4, opBytes{0x10}},
{ASHA1MSG1, yaes, Px, opBytes{0x0f, 0x38, 0xc9, 0}},
{ASHA1MSG2, yaes, Px, opBytes{0x0f, 0x38, 0xca, 0}},
{ASHA1NEXTE, yaes, Px, opBytes{0x0f, 0x38, 0xc8, 0}},
{ASHA256MSG1, yaes, Px, opBytes{0x0f, 0x38, 0xcc, 0}},
{ASHA256MSG2, yaes, Px, opBytes{0x0f, 0x38, 0xcd, 0}},
{ASHA1RNDS4, ysha1rnds4, Pm, opBytes{0x3a, 0xcc, 0}},
{ASHA256RNDS2, ysha256rnds2, Px, opBytes{0x0f, 0x38, 0xcb, 0}},
{ARDFSBASEL, yrdrand, Pf3, opBytes{0xae, 00}},
{ARDFSBASEQ, yrdrand, Pfw, opBytes{0xae, 00}},
{ARDGSBASEL, yrdrand, Pf3, opBytes{0xae, 01}},
{ARDGSBASEQ, yrdrand, Pfw, opBytes{0xae, 01}},
{AWRFSBASEL, ywrfsbase, Pf3, opBytes{0xae, 02}},
{AWRFSBASEQ, ywrfsbase, Pfw, opBytes{0xae, 02}},
{AWRGSBASEL, ywrfsbase, Pf3, opBytes{0xae, 03}},
{AWRGSBASEQ, ywrfsbase, Pfw, opBytes{0xae, 03}},
{ALFSW, ym_rl, Pe, opBytes{0x0f, 0xb4}},
{ALFSL, ym_rl, Px, opBytes{0x0f, 0xb4}},
{ALFSQ, ym_rl, Pw, opBytes{0x0f, 0xb4}},
{ALGSW, ym_rl, Pe, opBytes{0x0f, 0xb5}},
{ALGSL, ym_rl, Px, opBytes{0x0f, 0xb5}},
{ALGSQ, ym_rl, Pw, opBytes{0x0f, 0xb5}},
{ALSSW, ym_rl, Pe, opBytes{0x0f, 0xb2}},
{ALSSL, ym_rl, Px, opBytes{0x0f, 0xb2}},
{ALSSQ, ym_rl, Pw, opBytes{0x0f, 0xb2}},
{ARDPID, yrdrand, Pf3, opBytes{0xc7, 07}},
{ABLENDPD, yxshuf, Pq, opBytes{0x3a, 0x0d, 0}},
{ABLENDPS, yxshuf, Pq, opBytes{0x3a, 0x0c, 0}},
{AXACQUIRE, ynone, Px, opBytes{0xf2}},
{AXRELEASE, ynone, Px, opBytes{0xf3}},
{AXBEGIN, yxbegin, Px, opBytes{0xc7, 0xf8}},
{AXABORT, yxabort, Px, opBytes{0xc6, 0xf8}},
{AXEND, ynone, Px, opBytes{0x0f, 01, 0xd5}},
{AXTEST, ynone, Px, opBytes{0x0f, 01, 0xd6}},
{AXGETBV, ynone, Pm, opBytes{01, 0xd0}},
{obj.AFUNCDATA, yfuncdata, Px, opBytes{0, 0}},
{obj.APCDATA, ypcdata, Px, opBytes{0, 0}},
{obj.ADUFFCOPY, yduff, Px, opBytes{0xe8}},
{obj.ADUFFZERO, yduff, Px, opBytes{0xe8}},
{obj.AEND, nil, 0, opBytes{}},
{0, nil, 0, opBytes{}},
}
var opindex [(ALAST + 1) & obj.AMask]*Optab
// useAbs reports whether s describes a symbol that must avoid pc-relative addressing.
// This happens on systems like Solaris that call .so functions instead of system calls.
// It does not seem to be necessary for any other systems. This is probably working
// around a Solaris-specific bug that should be fixed differently, but we don't know
// what that bug is. And this does fix it.
func useAbs(ctxt *obj.Link, s *obj.LSym) bool {
if ctxt.Headtype == objabi.Hsolaris {
// All the Solaris dynamic imports from libc.so begin with "libc_".
return strings.HasPrefix(s.Name, "libc_")
}
return ctxt.Arch.Family == sys.I386 && !ctxt.Flag_shared
}
// single-instruction no-ops of various lengths.
// constructed by hand and disassembled with gdb to verify.
// see http://www.agner.org/optimize/optimizing_assembly.pdf for discussion.
var nop = [][16]uint8{
{0x90},
{0x66, 0x90},
{0x0F, 0x1F, 0x00},
{0x0F, 0x1F, 0x40, 0x00},
{0x0F, 0x1F, 0x44, 0x00, 0x00},
{0x66, 0x0F, 0x1F, 0x44, 0x00, 0x00},
{0x0F, 0x1F, 0x80, 0x00, 0x00, 0x00, 0x00},
{0x0F, 0x1F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x66, 0x0F, 0x1F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00},
}
// Native Client rejects the repeated 0x66 prefix.
// {0x66, 0x66, 0x0F, 0x1F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00},
func fillnop(p []byte, n int) {
var m int
for n > 0 {
m = n
if m > len(nop) {
m = len(nop)
}
copy(p[:m], nop[m-1][:m])
p = p[m:]
n -= m
}
}
func noppad(ctxt *obj.Link, s *obj.LSym, c int32, pad int32) int32 {
s.Grow(int64(c) + int64(pad))
fillnop(s.P[c:], int(pad))
return c + pad
}
func spadjop(ctxt *obj.Link, l, q obj.As) obj.As {
if ctxt.Arch.Family != sys.AMD64 || ctxt.Arch.PtrSize == 4 {
return l
}
return q
}
// isJump returns whether p is a jump instruction.
// It is used to ensure that no standalone or macro-fused jump will straddle
// or end on a 32 byte boundary by inserting NOPs before the jumps.
func isJump(p *obj.Prog) bool {
return p.To.Target() != nil || p.As == obj.AJMP || p.As == obj.ACALL ||
p.As == obj.ARET || p.As == obj.ADUFFCOPY || p.As == obj.ADUFFZERO
}
// lookForJCC returns the first real instruction starting from p, if that instruction is a conditional
// jump. Otherwise, nil is returned.
func lookForJCC(p *obj.Prog) *obj.Prog {
// Skip any PCDATA, FUNCDATA or NOP instructions
var q *obj.Prog
for q = p.Link; q != nil && (q.As == obj.APCDATA || q.As == obj.AFUNCDATA || q.As == obj.ANOP); q = q.Link {
}
if q == nil || q.To.Target() == nil || p.As == obj.AJMP || p.As == obj.ACALL {
return nil
}
switch q.As {
case AJOS, AJOC, AJCS, AJCC, AJEQ, AJNE, AJLS, AJHI,
AJMI, AJPL, AJPS, AJPC, AJLT, AJGE, AJLE, AJGT:
default:
return nil
}
return q
}
// fusedJump determines whether p can be fused with a subsequent conditional jump instruction.
// If it can, we return true followed by the total size of the fused jump. If it can't, we return false.
// Macro fusion rules are derived from the Intel Optimization Manual (April 2019) section 3.4.2.2.
func fusedJump(p *obj.Prog) (bool, uint8) {
var fusedSize uint8
// The first instruction in a macro fused pair may be preceded by the LOCK prefix,
// or possibly an XACQUIRE/XRELEASE prefix followed by a LOCK prefix. If it is, we
// need to be careful to insert any padding before the locks rather than directly after them.
if p.As == AXRELEASE || p.As == AXACQUIRE {
fusedSize += p.Isize
for p = p.Link; p != nil && (p.As == obj.APCDATA || p.As == obj.AFUNCDATA); p = p.Link {
}
if p == nil {
return false, 0
}
}
if p.As == ALOCK {
fusedSize += p.Isize
for p = p.Link; p != nil && (p.As == obj.APCDATA || p.As == obj.AFUNCDATA); p = p.Link {
}
if p == nil {
return false, 0
}
}
cmp := p.As == ACMPB || p.As == ACMPL || p.As == ACMPQ || p.As == ACMPW
cmpAddSub := p.As == AADDB || p.As == AADDL || p.As == AADDW || p.As == AADDQ ||
p.As == ASUBB || p.As == ASUBL || p.As == ASUBW || p.As == ASUBQ || cmp
testAnd := p.As == ATESTB || p.As == ATESTL || p.As == ATESTQ || p.As == ATESTW ||
p.As == AANDB || p.As == AANDL || p.As == AANDQ || p.As == AANDW
incDec := p.As == AINCB || p.As == AINCL || p.As == AINCQ || p.As == AINCW ||
p.As == ADECB || p.As == ADECL || p.As == ADECQ || p.As == ADECW
if !cmpAddSub && !testAnd && !incDec {
return false, 0
}
if !incDec {
var argOne obj.AddrType
var argTwo obj.AddrType
if cmp {
argOne = p.From.Type
argTwo = p.To.Type
} else {
argOne = p.To.Type
argTwo = p.From.Type
}
if argOne == obj.TYPE_REG {
if argTwo != obj.TYPE_REG && argTwo != obj.TYPE_CONST && argTwo != obj.TYPE_MEM {
return false, 0
}
} else if argOne == obj.TYPE_MEM {
if argTwo != obj.TYPE_REG {
return false, 0
}
} else {
return false, 0
}
}
fusedSize += p.Isize
jmp := lookForJCC(p)
if jmp == nil {
return false, 0
}
fusedSize += jmp.Isize
if testAnd {
return true, fusedSize
}
if jmp.As == AJOC || jmp.As == AJOS || jmp.As == AJMI ||
jmp.As == AJPL || jmp.As == AJPS || jmp.As == AJPC {
return false, 0
}
if cmpAddSub {
return true, fusedSize
}
if jmp.As == AJCS || jmp.As == AJCC || jmp.As == AJHI || jmp.As == AJLS {
return false, 0
}
return true, fusedSize
}
type padJumpsCtx int32
func makePjcCtx(ctxt *obj.Link) padJumpsCtx {
// Disable jump padding on 32 bit builds by setting
// padJumps to 0.
if ctxt.Arch.Family == sys.I386 {
return padJumpsCtx(0)
}
// Disable jump padding for hand written assembly code.
if ctxt.IsAsm {
return padJumpsCtx(0)
}
return padJumpsCtx(32)
}
// padJump detects whether the instruction being assembled is a standalone or a macro-fused
// jump that needs to be padded. If it is, NOPs are inserted to ensure that the jump does
// not cross or end on a 32 byte boundary.
func (pjc padJumpsCtx) padJump(ctxt *obj.Link, s *obj.LSym, p *obj.Prog, c int32) int32 {
if pjc == 0 {
return c
}
var toPad int32
fj, fjSize := fusedJump(p)
mask := int32(pjc - 1)
if fj {
if (c&mask)+int32(fjSize) >= int32(pjc) {
toPad = int32(pjc) - (c & mask)
}
} else if isJump(p) {
if (c&mask)+int32(p.Isize) >= int32(pjc) {
toPad = int32(pjc) - (c & mask)
}
}
if toPad <= 0 {
return c
}
return noppad(ctxt, s, c, toPad)
}
// reAssemble is called if an instruction's size changes during assembly. If
// it does and the instruction is a standalone or a macro-fused jump we need to
// reassemble.
func (pjc padJumpsCtx) reAssemble(p *obj.Prog) bool {
if pjc == 0 {
return false
}
fj, _ := fusedJump(p)
return fj || isJump(p)
}
type nopPad struct {
p *obj.Prog // Instruction before the pad
n int32 // Size of the pad
}
// requireAlignment ensures that the function alignment is at
// least as high as a, which should be a power of two
// and between 8 and 2048, inclusive.
//
// the boolean result indicates whether the alignment meets those constraints
func requireAlignment(a int64, ctxt *obj.Link, cursym *obj.LSym) bool {
if !((a&(a-1) == 0) && 8 <= a && a <= 2048) {
ctxt.Diag("alignment value of an instruction must be a power of two and in the range [8, 2048], got %d\n", a)
return false
}
// By default function alignment is 32 bytes for amd64
if cursym.Func().Align < int32(a) {
cursym.Func().Align = int32(a)
}
return true
}
func span6(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) {
if ctxt.Retpoline && ctxt.Arch.Family == sys.I386 {
ctxt.Diag("-spectre=ret not supported on 386")
ctxt.Retpoline = false // don't keep printing
}
pjc := makePjcCtx(ctxt)
if s.P != nil {
return
}
if ycover[0] == 0 {
ctxt.Diag("x86 tables not initialized, call x86.instinit first")
}
for p := s.Func().Text; p != nil; p = p.Link {
if p.To.Type == obj.TYPE_BRANCH && p.To.Target() == nil {
p.To.SetTarget(p)
}
if p.As == AADJSP {
p.To.Type = obj.TYPE_REG
p.To.Reg = REG_SP
// Generate 'ADDQ $x, SP' or 'SUBQ $x, SP', with x positive.
// One exception: It is smaller to encode $-0x80 than $0x80.
// For that case, flip the sign and the op:
// Instead of 'ADDQ $0x80, SP', generate 'SUBQ $-0x80, SP'.
switch v := p.From.Offset; {
case v == 0:
p.As = obj.ANOP
case v == 0x80 || (v < 0 && v != -0x80):
p.As = spadjop(ctxt, AADDL, AADDQ)
p.From.Offset *= -1
default:
p.As = spadjop(ctxt, ASUBL, ASUBQ)
}
}
if ctxt.Retpoline && (p.As == obj.ACALL || p.As == obj.AJMP) && (p.To.Type == obj.TYPE_REG || p.To.Type == obj.TYPE_MEM) {
if p.To.Type != obj.TYPE_REG {
ctxt.Diag("non-retpoline-compatible: %v", p)
continue
}
p.To.Type = obj.TYPE_BRANCH
p.To.Name = obj.NAME_EXTERN
p.To.Sym = ctxt.Lookup("runtime.retpoline" + obj.Rconv(int(p.To.Reg)))
p.To.Reg = 0
p.To.Offset = 0
}
}
var count int64 // rough count of number of instructions
for p := s.Func().Text; p != nil; p = p.Link {
count++
p.Back = branchShort // use short branches first time through
if q := p.To.Target(); q != nil && (q.Back&branchShort != 0) {
p.Back |= branchBackwards
q.Back |= branchLoopHead
}
}
s.GrowCap(count * 5) // preallocate roughly 5 bytes per instruction
var ab AsmBuf
var n int
var c int32
errors := ctxt.Errors
var nops []nopPad // Padding for a particular assembly (reuse slice storage if multiple assemblies)
nrelocs0 := len(s.R)
for {
// This loop continues while there are reasons to re-assemble
// whole block, like the presence of long forward jumps.
reAssemble := false
for i := range s.R[nrelocs0:] {
s.R[nrelocs0+i] = obj.Reloc{}
}
s.R = s.R[:nrelocs0] // preserve marker relocations generated by the compiler
s.P = s.P[:0]
c = 0
var pPrev *obj.Prog
nops = nops[:0]
for p := s.Func().Text; p != nil; p = p.Link {
c0 := c
c = pjc.padJump(ctxt, s, p, c)
if p.As == obj.APCALIGN || p.As == obj.APCALIGNMAX {
v := obj.AlignmentPadding(c, p, ctxt, s)
if v > 0 {
s.Grow(int64(c) + int64(v))
fillnop(s.P[c:], int(v))
}
p.Pc = int64(c)
c += int32(v)
pPrev = p
continue
}
if maxLoopPad > 0 && p.Back&branchLoopHead != 0 && c&(loopAlign-1) != 0 {
// pad with NOPs
v := -c & (loopAlign - 1)
if v <= maxLoopPad {
s.Grow(int64(c) + int64(v))
fillnop(s.P[c:], int(v))
c += v
}
}
p.Pc = int64(c)
// process forward jumps to p
for q := p.Rel; q != nil; q = q.Forwd {
v := int32(p.Pc - (q.Pc + int64(q.Isize)))
if q.Back&branchShort != 0 {
if v > 127 {
reAssemble = true
q.Back ^= branchShort
}
if q.As == AJCXZL || q.As == AXBEGIN {
s.P[q.Pc+2] = byte(v)
} else {
s.P[q.Pc+1] = byte(v)
}
} else {
binary.LittleEndian.PutUint32(s.P[q.Pc+int64(q.Isize)-4:], uint32(v))
}
}
p.Rel = nil
p.Pc = int64(c)
ab.asmins(ctxt, s, p)
m := ab.Len()
if int(p.Isize) != m {
p.Isize = uint8(m)
if pjc.reAssemble(p) {
// We need to re-assemble here to check for jumps and fused jumps
// that span or end on 32 byte boundaries.
reAssemble = true
}
}
s.Grow(p.Pc + int64(m))
copy(s.P[p.Pc:], ab.Bytes())
// If there was padding, remember it.
if pPrev != nil && !ctxt.IsAsm && c > c0 {
nops = append(nops, nopPad{p: pPrev, n: c - c0})
}
c += int32(m)
pPrev = p
}
n++
if n > 1000 {
ctxt.Diag("span must be looping")
log.Fatalf("loop")
}
if !reAssemble {
break
}
if ctxt.Errors > errors {
return
}
}
// splice padding nops into Progs
for _, n := range nops {
pp := n.p
np := &obj.Prog{Link: pp.Link, Ctxt: pp.Ctxt, As: obj.ANOP, Pos: pp.Pos.WithNotStmt(), Pc: pp.Pc + int64(pp.Isize), Isize: uint8(n.n)}
pp.Link = np
}
s.Size = int64(c)
if false { /* debug['a'] > 1 */
fmt.Printf("span1 %s %d (%d tries)\n %.6x", s.Name, s.Size, n, 0)
var i int
for i = 0; i < len(s.P); i++ {
fmt.Printf(" %.2x", s.P[i])
if i%16 == 15 {
fmt.Printf("\n %.6x", uint(i+1))
}
}
if i%16 != 0 {
fmt.Printf("\n")
}
for i := 0; i < len(s.R); i++ {
r := &s.R[i]
fmt.Printf(" rel %#.4x/%d %s%+d\n", uint32(r.Off), r.Siz, r.Sym.Name, r.Add)
}
}
// Mark nonpreemptible instruction sequences.
// The 2-instruction TLS access sequence
// MOVQ TLS, BX
// MOVQ 0(BX)(TLS*1), BX
// is not async preemptible, as if it is preempted and resumed on
// a different thread, the TLS address may become invalid.
if !CanUse1InsnTLS(ctxt) {
useTLS := func(p *obj.Prog) bool {
// Only need to mark the second instruction, which has
// REG_TLS as Index. (It is okay to interrupt and restart
// the first instruction.)
return p.From.Index == REG_TLS
}
obj.MarkUnsafePoints(ctxt, s.Func().Text, newprog, useTLS, nil)
}
// Now that we know byte offsets, we can generate jump table entries.
// TODO: could this live in obj instead of obj/$ARCH?
for _, jt := range s.Func().JumpTables {
for i, p := range jt.Targets {
// The ith jumptable entry points to the p.Pc'th
// byte in the function symbol s.
jt.Sym.WriteAddr(ctxt, int64(i)*8, 8, s, p.Pc)
}
}
}
func instinit(ctxt *obj.Link) {
if ycover[0] != 0 {
// Already initialized; stop now.
// This happens in the cmd/asm tests,
// each of which re-initializes the arch.
return
}
switch ctxt.Headtype {
case objabi.Hplan9:
plan9privates = ctxt.Lookup("_privates")
}
for i := range avxOptab {
c := avxOptab[i].as
if opindex[c&obj.AMask] != nil {
ctxt.Diag("phase error in avxOptab: %d (%v)", i, c)
}
opindex[c&obj.AMask] = &avxOptab[i]
}
for i := 1; optab[i].as != 0; i++ {
c := optab[i].as
if opindex[c&obj.AMask] != nil {
ctxt.Diag("phase error in optab: %d (%v)", i, c)
}
opindex[c&obj.AMask] = &optab[i]
}
for i := 0; i < Ymax; i++ {
ycover[i*Ymax+i] = 1
}
ycover[Yi0*Ymax+Yu2] = 1
ycover[Yi1*Ymax+Yu2] = 1
ycover[Yi0*Ymax+Yi8] = 1
ycover[Yi1*Ymax+Yi8] = 1
ycover[Yu2*Ymax+Yi8] = 1
ycover[Yu7*Ymax+Yi8] = 1
ycover[Yi0*Ymax+Yu7] = 1
ycover[Yi1*Ymax+Yu7] = 1
ycover[Yu2*Ymax+Yu7] = 1
ycover[Yi0*Ymax+Yu8] = 1
ycover[Yi1*Ymax+Yu8] = 1
ycover[Yu2*Ymax+Yu8] = 1
ycover[Yu7*Ymax+Yu8] = 1
ycover[Yi0*Ymax+Ys32] = 1
ycover[Yi1*Ymax+Ys32] = 1
ycover[Yu2*Ymax+Ys32] = 1
ycover[Yu7*Ymax+Ys32] = 1
ycover[Yu8*Ymax+Ys32] = 1
ycover[Yi8*Ymax+Ys32] = 1
ycover[Yi0*Ymax+Yi32] = 1
ycover[Yi1*Ymax+Yi32] = 1
ycover[Yu2*Ymax+Yi32] = 1
ycover[Yu7*Ymax+Yi32] = 1
ycover[Yu8*Ymax+Yi32] = 1
ycover[Yi8*Ymax+Yi32] = 1
ycover[Ys32*Ymax+Yi32] = 1
ycover[Yi0*Ymax+Yi64] = 1
ycover[Yi1*Ymax+Yi64] = 1
ycover[Yu7*Ymax+Yi64] = 1
ycover[Yu2*Ymax+Yi64] = 1
ycover[Yu8*Ymax+Yi64] = 1
ycover[Yi8*Ymax+Yi64] = 1
ycover[Ys32*Ymax+Yi64] = 1
ycover[Yi32*Ymax+Yi64] = 1
ycover[Yal*Ymax+Yrb] = 1
ycover[Ycl*Ymax+Yrb] = 1
ycover[Yax*Ymax+Yrb] = 1
ycover[Ycx*Ymax+Yrb] = 1
ycover[Yrx*Ymax+Yrb] = 1
ycover[Yrl*Ymax+Yrb] = 1 // but not Yrl32
ycover[Ycl*Ymax+Ycx] = 1
ycover[Yax*Ymax+Yrx] = 1
ycover[Ycx*Ymax+Yrx] = 1
ycover[Yax*Ymax+Yrl] = 1
ycover[Ycx*Ymax+Yrl] = 1
ycover[Yrx*Ymax+Yrl] = 1
ycover[Yrl32*Ymax+Yrl] = 1
ycover[Yf0*Ymax+Yrf] = 1
ycover[Yal*Ymax+Ymb] = 1
ycover[Ycl*Ymax+Ymb] = 1
ycover[Yax*Ymax+Ymb] = 1
ycover[Ycx*Ymax+Ymb] = 1
ycover[Yrx*Ymax+Ymb] = 1
ycover[Yrb*Ymax+Ymb] = 1
ycover[Yrl*Ymax+Ymb] = 1 // but not Yrl32
ycover[Ym*Ymax+Ymb] = 1
ycover[Yax*Ymax+Yml] = 1
ycover[Ycx*Ymax+Yml] = 1
ycover[Yrx*Ymax+Yml] = 1
ycover[Yrl*Ymax+Yml] = 1
ycover[Yrl32*Ymax+Yml] = 1
ycover[Ym*Ymax+Yml] = 1
ycover[Yax*Ymax+Ymm] = 1
ycover[Ycx*Ymax+Ymm] = 1
ycover[Yrx*Ymax+Ymm] = 1
ycover[Yrl*Ymax+Ymm] = 1
ycover[Yrl32*Ymax+Ymm] = 1
ycover[Ym*Ymax+Ymm] = 1
ycover[Ymr*Ymax+Ymm] = 1
ycover[Yxr0*Ymax+Yxr] = 1
ycover[Ym*Ymax+Yxm] = 1
ycover[Yxr0*Ymax+Yxm] = 1
ycover[Yxr*Ymax+Yxm] = 1
ycover[Ym*Ymax+Yym] = 1
ycover[Yyr*Ymax+Yym] = 1
ycover[Yxr0*Ymax+YxrEvex] = 1
ycover[Yxr*Ymax+YxrEvex] = 1
ycover[Ym*Ymax+YxmEvex] = 1
ycover[Yxr0*Ymax+YxmEvex] = 1
ycover[Yxr*Ymax+YxmEvex] = 1
ycover[YxrEvex*Ymax+YxmEvex] = 1
ycover[Yyr*Ymax+YyrEvex] = 1
ycover[Ym*Ymax+YymEvex] = 1
ycover[Yyr*Ymax+YymEvex] = 1
ycover[YyrEvex*Ymax+YymEvex] = 1
ycover[Ym*Ymax+Yzm] = 1
ycover[Yzr*Ymax+Yzm] = 1
ycover[Yk0*Ymax+Yk] = 1
ycover[Yknot0*Ymax+Yk] = 1
ycover[Yk0*Ymax+Ykm] = 1
ycover[Yknot0*Ymax+Ykm] = 1
ycover[Yk*Ymax+Ykm] = 1
ycover[Ym*Ymax+Ykm] = 1
ycover[Yxvm*Ymax+YxvmEvex] = 1
ycover[Yyvm*Ymax+YyvmEvex] = 1
for i := 0; i < MAXREG; i++ {
reg[i] = -1
if i >= REG_AL && i <= REG_R15B {
reg[i] = (i - REG_AL) & 7
if i >= REG_SPB && i <= REG_DIB {
regrex[i] = 0x40
}
if i >= REG_R8B && i <= REG_R15B {
regrex[i] = Rxr | Rxx | Rxb
}
}
if i >= REG_AH && i <= REG_BH {
reg[i] = 4 + ((i - REG_AH) & 7)
}
if i >= REG_AX && i <= REG_R15 {
reg[i] = (i - REG_AX) & 7
if i >= REG_R8 {
regrex[i] = Rxr | Rxx | Rxb
}
}
if i >= REG_F0 && i <= REG_F0+7 {
reg[i] = (i - REG_F0) & 7
}
if i >= REG_M0 && i <= REG_M0+7 {
reg[i] = (i - REG_M0) & 7
}
if i >= REG_K0 && i <= REG_K0+7 {
reg[i] = (i - REG_K0) & 7
}
if i >= REG_X0 && i <= REG_X0+15 {
reg[i] = (i - REG_X0) & 7
if i >= REG_X0+8 {
regrex[i] = Rxr | Rxx | Rxb
}
}
if i >= REG_X16 && i <= REG_X16+15 {
reg[i] = (i - REG_X16) & 7
if i >= REG_X16+8 {
regrex[i] = Rxr | Rxx | Rxb | RxrEvex
} else {
regrex[i] = RxrEvex
}
}
if i >= REG_Y0 && i <= REG_Y0+15 {
reg[i] = (i - REG_Y0) & 7
if i >= REG_Y0+8 {
regrex[i] = Rxr | Rxx | Rxb
}
}
if i >= REG_Y16 && i <= REG_Y16+15 {
reg[i] = (i - REG_Y16) & 7
if i >= REG_Y16+8 {
regrex[i] = Rxr | Rxx | Rxb | RxrEvex
} else {
regrex[i] = RxrEvex
}
}
if i >= REG_Z0 && i <= REG_Z0+15 {
reg[i] = (i - REG_Z0) & 7
if i > REG_Z0+7 {
regrex[i] = Rxr | Rxx | Rxb
}
}
if i >= REG_Z16 && i <= REG_Z16+15 {
reg[i] = (i - REG_Z16) & 7
if i >= REG_Z16+8 {
regrex[i] = Rxr | Rxx | Rxb | RxrEvex
} else {
regrex[i] = RxrEvex
}
}
if i >= REG_CR+8 && i <= REG_CR+15 {
regrex[i] = Rxr
}
}
}
var isAndroid = buildcfg.GOOS == "android"
func prefixof(ctxt *obj.Link, a *obj.Addr) int {
if a.Reg < REG_CS && a.Index < REG_CS { // fast path
return 0
}
if a.Type == obj.TYPE_MEM && a.Name == obj.NAME_NONE {
switch a.Reg {
case REG_CS:
return 0x2e
case REG_DS:
return 0x3e
case REG_ES:
return 0x26
case REG_FS:
return 0x64
case REG_GS:
return 0x65
case REG_TLS:
// NOTE: Systems listed here should be only systems that
// support direct TLS references like 8(TLS) implemented as
// direct references from FS or GS. Systems that require
// the initial-exec model, where you load the TLS base into
// a register and then index from that register, do not reach
// this code and should not be listed.
if ctxt.Arch.Family == sys.I386 {
switch ctxt.Headtype {
default:
if isAndroid {
return 0x65 // GS
}
log.Fatalf("unknown TLS base register for %v", ctxt.Headtype)
case objabi.Hdarwin,
objabi.Hdragonfly,
objabi.Hfreebsd,
objabi.Hnetbsd,
objabi.Hopenbsd:
return 0x65 // GS
}
}
switch ctxt.Headtype {
default:
log.Fatalf("unknown TLS base register for %v", ctxt.Headtype)
case objabi.Hlinux:
if isAndroid {
return 0x64 // FS
}
if ctxt.Flag_shared {
log.Fatalf("unknown TLS base register for linux with -shared")
} else {
return 0x64 // FS
}
case objabi.Hdragonfly,
objabi.Hfreebsd,
objabi.Hnetbsd,
objabi.Hopenbsd,
objabi.Hsolaris:
return 0x64 // FS
case objabi.Hdarwin:
return 0x65 // GS
}
}
}
switch a.Index {
case REG_CS:
return 0x2e
case REG_DS:
return 0x3e
case REG_ES:
return 0x26
case REG_TLS:
if ctxt.Flag_shared && ctxt.Headtype != objabi.Hwindows {
// When building for inclusion into a shared library, an instruction of the form
// MOV off(CX)(TLS*1), AX
// becomes
// mov %gs:off(%ecx), %eax // on i386
// mov %fs:off(%rcx), %rax // on amd64
// which assumes that the correct TLS offset has been loaded into CX (today
// there is only one TLS variable -- g -- so this is OK). When not building for
// a shared library the instruction it becomes
// mov 0x0(%ecx), %eax // on i386
// mov 0x0(%rcx), %rax // on amd64
// and a R_TLS_LE relocation, and so does not require a prefix.
if ctxt.Arch.Family == sys.I386 {
return 0x65 // GS
}
return 0x64 // FS
}
case REG_FS:
return 0x64
case REG_GS:
return 0x65
}
return 0
}
// oclassRegList returns multisource operand class for addr.
func oclassRegList(ctxt *obj.Link, addr *obj.Addr) int {
// TODO(quasilyte): when oclass register case is refactored into
// lookup table, use it here to get register kind more easily.
// Helper functions like regIsXmm should go away too (they will become redundant).
regIsXmm := func(r int) bool { return r >= REG_X0 && r <= REG_X31 }
regIsYmm := func(r int) bool { return r >= REG_Y0 && r <= REG_Y31 }
regIsZmm := func(r int) bool { return r >= REG_Z0 && r <= REG_Z31 }
reg0, reg1 := decodeRegisterRange(addr.Offset)
low := regIndex(int16(reg0))
high := regIndex(int16(reg1))
if ctxt.Arch.Family == sys.I386 {
if low >= 8 || high >= 8 {
return Yxxx
}
}
switch high - low {
case 3:
switch {
case regIsXmm(reg0) && regIsXmm(reg1):
return YxrEvexMulti4
case regIsYmm(reg0) && regIsYmm(reg1):
return YyrEvexMulti4
case regIsZmm(reg0) && regIsZmm(reg1):
return YzrMulti4
default:
return Yxxx
}
default:
return Yxxx
}
}
// oclassVMem returns V-mem (vector memory with VSIB) operand class.
// For addr that is not V-mem returns (Yxxx, false).
func oclassVMem(ctxt *obj.Link, addr *obj.Addr) (int, bool) {
switch addr.Index {
case REG_X0 + 0,
REG_X0 + 1,
REG_X0 + 2,
REG_X0 + 3,
REG_X0 + 4,
REG_X0 + 5,
REG_X0 + 6,
REG_X0 + 7:
return Yxvm, true
case REG_X8 + 0,
REG_X8 + 1,
REG_X8 + 2,
REG_X8 + 3,
REG_X8 + 4,
REG_X8 + 5,
REG_X8 + 6,
REG_X8 + 7:
if ctxt.Arch.Family == sys.I386 {
return Yxxx, true
}
return Yxvm, true
case REG_X16 + 0,
REG_X16 + 1,
REG_X16 + 2,
REG_X16 + 3,
REG_X16 + 4,
REG_X16 + 5,
REG_X16 + 6,
REG_X16 + 7,
REG_X16 + 8,
REG_X16 + 9,
REG_X16 + 10,
REG_X16 + 11,
REG_X16 + 12,
REG_X16 + 13,
REG_X16 + 14,
REG_X16 + 15:
if ctxt.Arch.Family == sys.I386 {
return Yxxx, true
}
return YxvmEvex, true
case REG_Y0 + 0,
REG_Y0 + 1,
REG_Y0 + 2,
REG_Y0 + 3,
REG_Y0 + 4,
REG_Y0 + 5,
REG_Y0 + 6,
REG_Y0 + 7:
return Yyvm, true
case REG_Y8 + 0,
REG_Y8 + 1,
REG_Y8 + 2,
REG_Y8 + 3,
REG_Y8 + 4,
REG_Y8 + 5,
REG_Y8 + 6,
REG_Y8 + 7:
if ctxt.Arch.Family == sys.I386 {
return Yxxx, true
}
return Yyvm, true
case REG_Y16 + 0,
REG_Y16 + 1,
REG_Y16 + 2,
REG_Y16 + 3,
REG_Y16 + 4,
REG_Y16 + 5,
REG_Y16 + 6,
REG_Y16 + 7,
REG_Y16 + 8,
REG_Y16 + 9,
REG_Y16 + 10,
REG_Y16 + 11,
REG_Y16 + 12,
REG_Y16 + 13,
REG_Y16 + 14,
REG_Y16 + 15:
if ctxt.Arch.Family == sys.I386 {
return Yxxx, true
}
return YyvmEvex, true
case REG_Z0 + 0,
REG_Z0 + 1,
REG_Z0 + 2,
REG_Z0 + 3,
REG_Z0 + 4,
REG_Z0 + 5,
REG_Z0 + 6,
REG_Z0 + 7:
return Yzvm, true
case REG_Z8 + 0,
REG_Z8 + 1,
REG_Z8 + 2,
REG_Z8 + 3,
REG_Z8 + 4,
REG_Z8 + 5,
REG_Z8 + 6,
REG_Z8 + 7,
REG_Z8 + 8,
REG_Z8 + 9,
REG_Z8 + 10,
REG_Z8 + 11,
REG_Z8 + 12,
REG_Z8 + 13,
REG_Z8 + 14,
REG_Z8 + 15,
REG_Z8 + 16,
REG_Z8 + 17,
REG_Z8 + 18,
REG_Z8 + 19,
REG_Z8 + 20,
REG_Z8 + 21,
REG_Z8 + 22,
REG_Z8 + 23:
if ctxt.Arch.Family == sys.I386 {
return Yxxx, true
}
return Yzvm, true
}
return Yxxx, false
}
func oclass(ctxt *obj.Link, p *obj.Prog, a *obj.Addr) int {
switch a.Type {
case obj.TYPE_REGLIST:
return oclassRegList(ctxt, a)
case obj.TYPE_NONE:
return Ynone
case obj.TYPE_BRANCH:
return Ybr
case obj.TYPE_INDIR:
if a.Name != obj.NAME_NONE && a.Reg == REG_NONE && a.Index == REG_NONE && a.Scale == 0 {
return Yindir
}
return Yxxx
case obj.TYPE_MEM:
// Pseudo registers have negative index, but SP is
// not pseudo on x86, hence REG_SP check is not redundant.
if a.Index == REG_SP || a.Index < 0 {
// Can't use FP/SB/PC/SP as the index register.
return Yxxx
}
if vmem, ok := oclassVMem(ctxt, a); ok {
return vmem
}
if ctxt.Arch.Family == sys.AMD64 {
switch a.Name {
case obj.NAME_EXTERN, obj.NAME_STATIC, obj.NAME_GOTREF:
// Global variables can't use index registers and their
// base register is %rip (%rip is encoded as REG_NONE).
if a.Reg != REG_NONE || a.Index != REG_NONE || a.Scale != 0 {
return Yxxx
}
case obj.NAME_AUTO, obj.NAME_PARAM:
// These names must have a base of SP. The old compiler
// uses 0 for the base register. SSA uses REG_SP.
if a.Reg != REG_SP && a.Reg != 0 {
return Yxxx
}
case obj.NAME_NONE:
// everything is ok
default:
// unknown name
return Yxxx
}
}
return Ym
case obj.TYPE_ADDR:
switch a.Name {
case obj.NAME_GOTREF:
ctxt.Diag("unexpected TYPE_ADDR with NAME_GOTREF")
return Yxxx
case obj.NAME_EXTERN,
obj.NAME_STATIC:
if a.Sym != nil && useAbs(ctxt, a.Sym) {
return Yi32
}
return Yiauto // use pc-relative addressing
case obj.NAME_AUTO,
obj.NAME_PARAM:
return Yiauto
}
// TODO(rsc): DUFFZERO/DUFFCOPY encoding forgot to set a->index
// and got Yi32 in an earlier version of this code.
// Keep doing that until we fix yduff etc.
if a.Sym != nil && strings.HasPrefix(a.Sym.Name, "runtime.duff") {
return Yi32
}
if a.Sym != nil || a.Name != obj.NAME_NONE {
ctxt.Diag("unexpected addr: %v", obj.Dconv(p, a))
}
fallthrough
case obj.TYPE_CONST:
if a.Sym != nil {
ctxt.Diag("TYPE_CONST with symbol: %v", obj.Dconv(p, a))
}
v := a.Offset
if ctxt.Arch.Family == sys.I386 {
v = int64(int32(v))
}
switch {
case v == 0:
return Yi0
case v == 1:
return Yi1
case v >= 0 && v <= 3:
return Yu2
case v >= 0 && v <= 127:
return Yu7
case v >= 0 && v <= 255:
return Yu8
case v >= -128 && v <= 127:
return Yi8
}
if ctxt.Arch.Family == sys.I386 {
return Yi32
}
l := int32(v)
if int64(l) == v {
return Ys32 // can sign extend
}
if v>>32 == 0 {
return Yi32 // unsigned
}
return Yi64
case obj.TYPE_TEXTSIZE:
return Ytextsize
}
if a.Type != obj.TYPE_REG {
ctxt.Diag("unexpected addr1: type=%d %v", a.Type, obj.Dconv(p, a))
return Yxxx
}
switch a.Reg {
case REG_AL:
return Yal
case REG_AX:
return Yax
/*
case REG_SPB:
*/
case REG_BPB,
REG_SIB,
REG_DIB,
REG_R8B,
REG_R9B,
REG_R10B,
REG_R11B,
REG_R12B,
REG_R13B,
REG_R14B,
REG_R15B:
if ctxt.Arch.Family == sys.I386 {
return Yxxx
}
fallthrough
case REG_DL,
REG_BL,
REG_AH,
REG_CH,
REG_DH,
REG_BH:
return Yrb
case REG_CL:
return Ycl
case REG_CX:
return Ycx
case REG_DX, REG_BX:
return Yrx
case REG_R8, // not really Yrl
REG_R9,
REG_R10,
REG_R11,
REG_R12,
REG_R13,
REG_R14,
REG_R15:
if ctxt.Arch.Family == sys.I386 {
return Yxxx
}
fallthrough
case REG_SP, REG_BP, REG_SI, REG_DI:
if ctxt.Arch.Family == sys.I386 {
return Yrl32
}
return Yrl
case REG_F0 + 0:
return Yf0
case REG_F0 + 1,
REG_F0 + 2,
REG_F0 + 3,
REG_F0 + 4,
REG_F0 + 5,
REG_F0 + 6,
REG_F0 + 7:
return Yrf
case REG_M0 + 0,
REG_M0 + 1,
REG_M0 + 2,
REG_M0 + 3,
REG_M0 + 4,
REG_M0 + 5,
REG_M0 + 6,
REG_M0 + 7:
return Ymr
case REG_X0:
return Yxr0
case REG_X0 + 1,
REG_X0 + 2,
REG_X0 + 3,
REG_X0 + 4,
REG_X0 + 5,
REG_X0 + 6,
REG_X0 + 7,
REG_X0 + 8,
REG_X0 + 9,
REG_X0 + 10,
REG_X0 + 11,
REG_X0 + 12,
REG_X0 + 13,
REG_X0 + 14,
REG_X0 + 15:
return Yxr
case REG_X0 + 16,
REG_X0 + 17,
REG_X0 + 18,
REG_X0 + 19,
REG_X0 + 20,
REG_X0 + 21,
REG_X0 + 22,
REG_X0 + 23,
REG_X0 + 24,
REG_X0 + 25,
REG_X0 + 26,
REG_X0 + 27,
REG_X0 + 28,
REG_X0 + 29,
REG_X0 + 30,
REG_X0 + 31:
return YxrEvex
case REG_Y0 + 0,
REG_Y0 + 1,
REG_Y0 + 2,
REG_Y0 + 3,
REG_Y0 + 4,
REG_Y0 + 5,
REG_Y0 + 6,
REG_Y0 + 7,
REG_Y0 + 8,
REG_Y0 + 9,
REG_Y0 + 10,
REG_Y0 + 11,
REG_Y0 + 12,
REG_Y0 + 13,
REG_Y0 + 14,
REG_Y0 + 15:
return Yyr
case REG_Y0 + 16,
REG_Y0 + 17,
REG_Y0 + 18,
REG_Y0 + 19,
REG_Y0 + 20,
REG_Y0 + 21,
REG_Y0 + 22,
REG_Y0 + 23,
REG_Y0 + 24,
REG_Y0 + 25,
REG_Y0 + 26,
REG_Y0 + 27,
REG_Y0 + 28,
REG_Y0 + 29,
REG_Y0 + 30,
REG_Y0 + 31:
return YyrEvex
case REG_Z0 + 0,
REG_Z0 + 1,
REG_Z0 + 2,
REG_Z0 + 3,
REG_Z0 + 4,
REG_Z0 + 5,
REG_Z0 + 6,
REG_Z0 + 7:
return Yzr
case REG_Z0 + 8,
REG_Z0 + 9,
REG_Z0 + 10,
REG_Z0 + 11,
REG_Z0 + 12,
REG_Z0 + 13,
REG_Z0 + 14,
REG_Z0 + 15,
REG_Z0 + 16,
REG_Z0 + 17,
REG_Z0 + 18,
REG_Z0 + 19,
REG_Z0 + 20,
REG_Z0 + 21,
REG_Z0 + 22,
REG_Z0 + 23,
REG_Z0 + 24,
REG_Z0 + 25,
REG_Z0 + 26,
REG_Z0 + 27,
REG_Z0 + 28,
REG_Z0 + 29,
REG_Z0 + 30,
REG_Z0 + 31:
if ctxt.Arch.Family == sys.I386 {
return Yxxx
}
return Yzr
case REG_K0:
return Yk0
case REG_K0 + 1,
REG_K0 + 2,
REG_K0 + 3,
REG_K0 + 4,
REG_K0 + 5,
REG_K0 + 6,
REG_K0 + 7:
return Yknot0
case REG_CS:
return Ycs
case REG_SS:
return Yss
case REG_DS:
return Yds
case REG_ES:
return Yes
case REG_FS:
return Yfs
case REG_GS:
return Ygs
case REG_TLS:
return Ytls
case REG_GDTR:
return Ygdtr
case REG_IDTR:
return Yidtr
case REG_LDTR:
return Yldtr
case REG_MSW:
return Ymsw
case REG_TASK:
return Ytask
case REG_CR + 0:
return Ycr0
case REG_CR + 1:
return Ycr1
case REG_CR + 2:
return Ycr2
case REG_CR + 3:
return Ycr3
case REG_CR + 4:
return Ycr4
case REG_CR + 5:
return Ycr5
case REG_CR + 6:
return Ycr6
case REG_CR + 7:
return Ycr7
case REG_CR + 8:
return Ycr8
case REG_DR + 0:
return Ydr0
case REG_DR + 1:
return Ydr1
case REG_DR + 2:
return Ydr2
case REG_DR + 3:
return Ydr3
case REG_DR + 4:
return Ydr4
case REG_DR + 5:
return Ydr5
case REG_DR + 6:
return Ydr6
case REG_DR + 7:
return Ydr7
case REG_TR + 0:
return Ytr0
case REG_TR + 1:
return Ytr1
case REG_TR + 2:
return Ytr2
case REG_TR + 3:
return Ytr3
case REG_TR + 4:
return Ytr4
case REG_TR + 5:
return Ytr5
case REG_TR + 6:
return Ytr6
case REG_TR + 7:
return Ytr7
}
return Yxxx
}
// AsmBuf is a simple buffer to assemble variable-length x86 instructions into
// and hold assembly state.
type AsmBuf struct {
buf [100]byte
off int
rexflag int
vexflag bool // Per inst: true for VEX-encoded
evexflag bool // Per inst: true for EVEX-encoded
rep bool
repn bool
lock bool
evex evexBits // Initialized when evexflag is true
}
// Put1 appends one byte to the end of the buffer.
func (ab *AsmBuf) Put1(x byte) {
ab.buf[ab.off] = x
ab.off++
}
// Put2 appends two bytes to the end of the buffer.
func (ab *AsmBuf) Put2(x, y byte) {
ab.buf[ab.off+0] = x
ab.buf[ab.off+1] = y
ab.off += 2
}
// Put3 appends three bytes to the end of the buffer.
func (ab *AsmBuf) Put3(x, y, z byte) {
ab.buf[ab.off+0] = x
ab.buf[ab.off+1] = y
ab.buf[ab.off+2] = z
ab.off += 3
}
// Put4 appends four bytes to the end of the buffer.
func (ab *AsmBuf) Put4(x, y, z, w byte) {
ab.buf[ab.off+0] = x
ab.buf[ab.off+1] = y
ab.buf[ab.off+2] = z
ab.buf[ab.off+3] = w
ab.off += 4
}
// PutInt16 writes v into the buffer using little-endian encoding.
func (ab *AsmBuf) PutInt16(v int16) {
ab.buf[ab.off+0] = byte(v)
ab.buf[ab.off+1] = byte(v >> 8)
ab.off += 2
}
// PutInt32 writes v into the buffer using little-endian encoding.
func (ab *AsmBuf) PutInt32(v int32) {
ab.buf[ab.off+0] = byte(v)
ab.buf[ab.off+1] = byte(v >> 8)
ab.buf[ab.off+2] = byte(v >> 16)
ab.buf[ab.off+3] = byte(v >> 24)
ab.off += 4
}
// PutInt64 writes v into the buffer using little-endian encoding.
func (ab *AsmBuf) PutInt64(v int64) {
ab.buf[ab.off+0] = byte(v)
ab.buf[ab.off+1] = byte(v >> 8)
ab.buf[ab.off+2] = byte(v >> 16)
ab.buf[ab.off+3] = byte(v >> 24)
ab.buf[ab.off+4] = byte(v >> 32)
ab.buf[ab.off+5] = byte(v >> 40)
ab.buf[ab.off+6] = byte(v >> 48)
ab.buf[ab.off+7] = byte(v >> 56)
ab.off += 8
}
// Put copies b into the buffer.
func (ab *AsmBuf) Put(b []byte) {
copy(ab.buf[ab.off:], b)
ab.off += len(b)
}
// PutOpBytesLit writes zero terminated sequence of bytes from op,
// starting at specified offset (e.g. z counter value).
// Trailing 0 is not written.
//
// Intended to be used for literal Z cases.
// Literal Z cases usually have "Zlit" in their name (Zlit, Zlitr_m, Zlitm_r).
func (ab *AsmBuf) PutOpBytesLit(offset int, op *opBytes) {
for int(op[offset]) != 0 {
ab.Put1(byte(op[offset]))
offset++
}
}
// Insert inserts b at offset i.
func (ab *AsmBuf) Insert(i int, b byte) {
ab.off++
copy(ab.buf[i+1:ab.off], ab.buf[i:ab.off-1])
ab.buf[i] = b
}
// Last returns the byte at the end of the buffer.
func (ab *AsmBuf) Last() byte { return ab.buf[ab.off-1] }
// Len returns the length of the buffer.
func (ab *AsmBuf) Len() int { return ab.off }
// Bytes returns the contents of the buffer.
func (ab *AsmBuf) Bytes() []byte { return ab.buf[:ab.off] }
// Reset empties the buffer.
func (ab *AsmBuf) Reset() { ab.off = 0 }
// At returns the byte at offset i.
func (ab *AsmBuf) At(i int) byte { return ab.buf[i] }
// asmidx emits SIB byte.
func (ab *AsmBuf) asmidx(ctxt *obj.Link, scale int, index int, base int) {
var i int
// X/Y index register is used in VSIB.
switch index {
default:
goto bad
case REG_NONE:
i = 4 << 3
goto bas
case REG_R8,
REG_R9,
REG_R10,
REG_R11,
REG_R12,
REG_R13,
REG_R14,
REG_R15,
REG_X8,
REG_X9,
REG_X10,
REG_X11,
REG_X12,
REG_X13,
REG_X14,
REG_X15,
REG_X16,
REG_X17,
REG_X18,
REG_X19,
REG_X20,
REG_X21,
REG_X22,
REG_X23,
REG_X24,
REG_X25,
REG_X26,
REG_X27,
REG_X28,
REG_X29,
REG_X30,
REG_X31,
REG_Y8,
REG_Y9,
REG_Y10,
REG_Y11,
REG_Y12,
REG_Y13,
REG_Y14,
REG_Y15,
REG_Y16,
REG_Y17,
REG_Y18,
REG_Y19,
REG_Y20,
REG_Y21,
REG_Y22,
REG_Y23,
REG_Y24,
REG_Y25,
REG_Y26,
REG_Y27,
REG_Y28,
REG_Y29,
REG_Y30,
REG_Y31,
REG_Z8,
REG_Z9,
REG_Z10,
REG_Z11,
REG_Z12,
REG_Z13,
REG_Z14,
REG_Z15,
REG_Z16,
REG_Z17,
REG_Z18,
REG_Z19,
REG_Z20,
REG_Z21,
REG_Z22,
REG_Z23,
REG_Z24,
REG_Z25,
REG_Z26,
REG_Z27,
REG_Z28,
REG_Z29,
REG_Z30,
REG_Z31:
if ctxt.Arch.Family == sys.I386 {
goto bad
}
fallthrough
case REG_AX,
REG_CX,
REG_DX,
REG_BX,
REG_BP,
REG_SI,
REG_DI,
REG_X0,
REG_X1,
REG_X2,
REG_X3,
REG_X4,
REG_X5,
REG_X6,
REG_X7,
REG_Y0,
REG_Y1,
REG_Y2,
REG_Y3,
REG_Y4,
REG_Y5,
REG_Y6,
REG_Y7,
REG_Z0,
REG_Z1,
REG_Z2,
REG_Z3,
REG_Z4,
REG_Z5,
REG_Z6,
REG_Z7:
i = reg[index] << 3
}
switch scale {
default:
goto bad
case 1:
break
case 2:
i |= 1 << 6
case 4:
i |= 2 << 6
case 8:
i |= 3 << 6
}
bas:
switch base {
default:
goto bad
case REG_NONE: // must be mod=00
i |= 5
case REG_R8,
REG_R9,
REG_R10,
REG_R11,
REG_R12,
REG_R13,
REG_R14,
REG_R15:
if ctxt.Arch.Family == sys.I386 {
goto bad
}
fallthrough
case REG_AX,
REG_CX,
REG_DX,
REG_BX,
REG_SP,
REG_BP,
REG_SI,
REG_DI:
i |= reg[base]
}
ab.Put1(byte(i))
return
bad:
ctxt.Diag("asmidx: bad address %d/%d/%d", scale, index, base)
ab.Put1(0)
}
func (ab *AsmBuf) relput4(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog, a *obj.Addr) {
var rel obj.Reloc
v := vaddr(ctxt, p, a, &rel)
if rel.Siz != 0 {
if rel.Siz != 4 {
ctxt.Diag("bad reloc")
}
r := obj.Addrel(cursym)
*r = rel
r.Off = int32(p.Pc + int64(ab.Len()))
}
ab.PutInt32(int32(v))
}
func vaddr(ctxt *obj.Link, p *obj.Prog, a *obj.Addr, r *obj.Reloc) int64 {
if r != nil {
*r = obj.Reloc{}
}
switch a.Name {
case obj.NAME_STATIC,
obj.NAME_GOTREF,
obj.NAME_EXTERN:
s := a.Sym
if r == nil {
ctxt.Diag("need reloc for %v", obj.Dconv(p, a))
log.Fatalf("reloc")
}
if a.Name == obj.NAME_GOTREF {
r.Siz = 4
r.Type = objabi.R_GOTPCREL
} else if useAbs(ctxt, s) {
r.Siz = 4
r.Type = objabi.R_ADDR
} else {
r.Siz = 4
r.Type = objabi.R_PCREL
}
r.Off = -1 // caller must fill in
r.Sym = s
r.Add = a.Offset
return 0
}
if (a.Type == obj.TYPE_MEM || a.Type == obj.TYPE_ADDR) && a.Reg == REG_TLS {
if r == nil {
ctxt.Diag("need reloc for %v", obj.Dconv(p, a))
log.Fatalf("reloc")
}
if !ctxt.Flag_shared || isAndroid || ctxt.Headtype == objabi.Hdarwin {
r.Type = objabi.R_TLS_LE
r.Siz = 4
r.Off = -1 // caller must fill in
r.Add = a.Offset
}
return 0
}
return a.Offset
}
func (ab *AsmBuf) asmandsz(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog, a *obj.Addr, r int, rex int, m64 int) {
var base int
var rel obj.Reloc
rex &= 0x40 | Rxr
if a.Offset != int64(int32(a.Offset)) {
// The rules are slightly different for 386 and AMD64,
// mostly for historical reasons. We may unify them later,
// but it must be discussed beforehand.
//
// For 64bit mode only LEAL is allowed to overflow.
// It's how https://golang.org/cl/59630 made it.
// crypto/sha1/sha1block_amd64.s depends on this feature.
//
// For 32bit mode rules are more permissive.
// If offset fits uint32, it's permitted.
// This is allowed for assembly that wants to use 32-bit hex
// constants, e.g. LEAL 0x99999999(AX), AX.
overflowOK := (ctxt.Arch.Family == sys.AMD64 && p.As == ALEAL) ||
(ctxt.Arch.Family != sys.AMD64 &&
int64(uint32(a.Offset)) == a.Offset &&
ab.rexflag&Rxw == 0)
if !overflowOK {
ctxt.Diag("offset too large in %s", p)
}
}
v := int32(a.Offset)
rel.Siz = 0
switch a.Type {
case obj.TYPE_ADDR:
if a.Name == obj.NAME_NONE {
ctxt.Diag("unexpected TYPE_ADDR with NAME_NONE")
}
if a.Index == REG_TLS {
ctxt.Diag("unexpected TYPE_ADDR with index==REG_TLS")
}
goto bad
case obj.TYPE_REG:
const regFirst = REG_AL
const regLast = REG_Z31
if a.Reg < regFirst || regLast < a.Reg {
goto bad
}
if v != 0 {
goto bad
}
ab.Put1(byte(3<<6 | reg[a.Reg]<<0 | r<<3))
ab.rexflag |= regrex[a.Reg]&(0x40|Rxb) | rex
return
}
if a.Type != obj.TYPE_MEM {
goto bad
}
if a.Index != REG_NONE && a.Index != REG_TLS && !(REG_CS <= a.Index && a.Index <= REG_GS) {
base := int(a.Reg)
switch a.Name {
case obj.NAME_EXTERN,
obj.NAME_GOTREF,
obj.NAME_STATIC:
if !useAbs(ctxt, a.Sym) && ctxt.Arch.Family == sys.AMD64 {
goto bad
}
if ctxt.Arch.Family == sys.I386 && ctxt.Flag_shared {
// The base register has already been set. It holds the PC
// of this instruction returned by a PC-reading thunk.
// See obj6.go:rewriteToPcrel.
} else {
base = REG_NONE
}
v = int32(vaddr(ctxt, p, a, &rel))
case obj.NAME_AUTO,
obj.NAME_PARAM:
base = REG_SP
}
ab.rexflag |= regrex[int(a.Index)]&Rxx | regrex[base]&Rxb | rex
if base == REG_NONE {
ab.Put1(byte(0<<6 | 4<<0 | r<<3))
ab.asmidx(ctxt, int(a.Scale), int(a.Index), base)
goto putrelv
}
if v == 0 && rel.Siz == 0 && base != REG_BP && base != REG_R13 {
ab.Put1(byte(0<<6 | 4<<0 | r<<3))
ab.asmidx(ctxt, int(a.Scale), int(a.Index), base)
return
}
if disp8, ok := toDisp8(v, p, ab); ok && rel.Siz == 0 {
ab.Put1(byte(1<<6 | 4<<0 | r<<3))
ab.asmidx(ctxt, int(a.Scale), int(a.Index), base)
ab.Put1(disp8)
return
}
ab.Put1(byte(2<<6 | 4<<0 | r<<3))
ab.asmidx(ctxt, int(a.Scale), int(a.Index), base)
goto putrelv
}
base = int(a.Reg)
switch a.Name {
case obj.NAME_STATIC,
obj.NAME_GOTREF,
obj.NAME_EXTERN:
if a.Sym == nil {
ctxt.Diag("bad addr: %v", p)
}
if ctxt.Arch.Family == sys.I386 && ctxt.Flag_shared {
// The base register has already been set. It holds the PC
// of this instruction returned by a PC-reading thunk.
// See obj6.go:rewriteToPcrel.
} else {
base = REG_NONE
}
v = int32(vaddr(ctxt, p, a, &rel))
case obj.NAME_AUTO,
obj.NAME_PARAM:
base = REG_SP
}
if base == REG_TLS {
v = int32(vaddr(ctxt, p, a, &rel))
}
ab.rexflag |= regrex[base]&Rxb | rex
if base == REG_NONE || (REG_CS <= base && base <= REG_GS) || base == REG_TLS {
if (a.Sym == nil || !useAbs(ctxt, a.Sym)) && base == REG_NONE && (a.Name == obj.NAME_STATIC || a.Name == obj.NAME_EXTERN || a.Name == obj.NAME_GOTREF) || ctxt.Arch.Family != sys.AMD64 {
if a.Name == obj.NAME_GOTREF && (a.Offset != 0 || a.Index != 0 || a.Scale != 0) {
ctxt.Diag("%v has offset against gotref", p)
}
ab.Put1(byte(0<<6 | 5<<0 | r<<3))
goto putrelv
}
// temporary
ab.Put2(
byte(0<<6|4<<0|r<<3), // sib present
0<<6|4<<3|5<<0, // DS:d32
)
goto putrelv
}
if base == REG_SP || base == REG_R12 {
if v == 0 {
ab.Put1(byte(0<<6 | reg[base]<<0 | r<<3))
ab.asmidx(ctxt, int(a.Scale), REG_NONE, base)
return
}
if disp8, ok := toDisp8(v, p, ab); ok {
ab.Put1(byte(1<<6 | reg[base]<<0 | r<<3))
ab.asmidx(ctxt, int(a.Scale), REG_NONE, base)
ab.Put1(disp8)
return
}
ab.Put1(byte(2<<6 | reg[base]<<0 | r<<3))
ab.asmidx(ctxt, int(a.Scale), REG_NONE, base)
goto putrelv
}
if REG_AX <= base && base <= REG_R15 {
if a.Index == REG_TLS && !ctxt.Flag_shared && !isAndroid &&
ctxt.Headtype != objabi.Hwindows {
rel = obj.Reloc{}
rel.Type = objabi.R_TLS_LE
rel.Siz = 4
rel.Sym = nil
rel.Add = int64(v)
v = 0
}
if v == 0 && rel.Siz == 0 && base != REG_BP && base != REG_R13 {
ab.Put1(byte(0<<6 | reg[base]<<0 | r<<3))
return
}
if disp8, ok := toDisp8(v, p, ab); ok && rel.Siz == 0 {
ab.Put2(byte(1<<6|reg[base]<<0|r<<3), disp8)
return
}
ab.Put1(byte(2<<6 | reg[base]<<0 | r<<3))
goto putrelv
}
goto bad
putrelv:
if rel.Siz != 0 {
if rel.Siz != 4 {
ctxt.Diag("bad rel")
goto bad
}
r := obj.Addrel(cursym)
*r = rel
r.Off = int32(p.Pc + int64(ab.Len()))
}
ab.PutInt32(v)
return
bad:
ctxt.Diag("asmand: bad address %v", obj.Dconv(p, a))
}
func (ab *AsmBuf) asmand(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog, a *obj.Addr, ra *obj.Addr) {
ab.asmandsz(ctxt, cursym, p, a, reg[ra.Reg], regrex[ra.Reg], 0)
}
func (ab *AsmBuf) asmando(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog, a *obj.Addr, o int) {
ab.asmandsz(ctxt, cursym, p, a, o, 0, 0)
}
func bytereg(a *obj.Addr, t *uint8) {
if a.Type == obj.TYPE_REG && a.Index == REG_NONE && (REG_AX <= a.Reg && a.Reg <= REG_R15) {
a.Reg += REG_AL - REG_AX
*t = 0
}
}
func unbytereg(a *obj.Addr, t *uint8) {
if a.Type == obj.TYPE_REG && a.Index == REG_NONE && (REG_AL <= a.Reg && a.Reg <= REG_R15B) {
a.Reg += REG_AX - REG_AL
*t = 0
}
}
const (
movLit uint8 = iota // Like Zlit
movRegMem
movMemReg
movRegMem2op
movMemReg2op
movFullPtr // Load full pointer, trash heap (unsupported)
movDoubleShift
movTLSReg
)
var ymovtab = []movtab{
// push
{APUSHL, Ycs, Ynone, Ynone, movLit, [4]uint8{0x0e, 0}},
{APUSHL, Yss, Ynone, Ynone, movLit, [4]uint8{0x16, 0}},
{APUSHL, Yds, Ynone, Ynone, movLit, [4]uint8{0x1e, 0}},
{APUSHL, Yes, Ynone, Ynone, movLit, [4]uint8{0x06, 0}},
{APUSHL, Yfs, Ynone, Ynone, movLit, [4]uint8{0x0f, 0xa0, 0}},
{APUSHL, Ygs, Ynone, Ynone, movLit, [4]uint8{0x0f, 0xa8, 0}},
{APUSHQ, Yfs, Ynone, Ynone, movLit, [4]uint8{0x0f, 0xa0, 0}},
{APUSHQ, Ygs, Ynone, Ynone, movLit, [4]uint8{0x0f, 0xa8, 0}},
{APUSHW, Ycs, Ynone, Ynone, movLit, [4]uint8{Pe, 0x0e, 0}},
{APUSHW, Yss, Ynone, Ynone, movLit, [4]uint8{Pe, 0x16, 0}},
{APUSHW, Yds, Ynone, Ynone, movLit, [4]uint8{Pe, 0x1e, 0}},
{APUSHW, Yes, Ynone, Ynone, movLit, [4]uint8{Pe, 0x06, 0}},
{APUSHW, Yfs, Ynone, Ynone, movLit, [4]uint8{Pe, 0x0f, 0xa0, 0}},
{APUSHW, Ygs, Ynone, Ynone, movLit, [4]uint8{Pe, 0x0f, 0xa8, 0}},
// pop
{APOPL, Ynone, Ynone, Yds, movLit, [4]uint8{0x1f, 0}},
{APOPL, Ynone, Ynone, Yes, movLit, [4]uint8{0x07, 0}},
{APOPL, Ynone, Ynone, Yss, movLit, [4]uint8{0x17, 0}},
{APOPL, Ynone, Ynone, Yfs, movLit, [4]uint8{0x0f, 0xa1, 0}},
{APOPL, Ynone, Ynone, Ygs, movLit, [4]uint8{0x0f, 0xa9, 0}},
{APOPQ, Ynone, Ynone, Yfs, movLit, [4]uint8{0x0f, 0xa1, 0}},
{APOPQ, Ynone, Ynone, Ygs, movLit, [4]uint8{0x0f, 0xa9, 0}},
{APOPW, Ynone, Ynone, Yds, movLit, [4]uint8{Pe, 0x1f, 0}},
{APOPW, Ynone, Ynone, Yes, movLit, [4]uint8{Pe, 0x07, 0}},
{APOPW, Ynone, Ynone, Yss, movLit, [4]uint8{Pe, 0x17, 0}},
{APOPW, Ynone, Ynone, Yfs, movLit, [4]uint8{Pe, 0x0f, 0xa1, 0}},
{APOPW, Ynone, Ynone, Ygs, movLit, [4]uint8{Pe, 0x0f, 0xa9, 0}},
// mov seg
{AMOVW, Yes, Ynone, Yml, movRegMem, [4]uint8{0x8c, 0, 0, 0}},
{AMOVW, Ycs, Ynone, Yml, movRegMem, [4]uint8{0x8c, 1, 0, 0}},
{AMOVW, Yss, Ynone, Yml, movRegMem, [4]uint8{0x8c, 2, 0, 0}},
{AMOVW, Yds, Ynone, Yml, movRegMem, [4]uint8{0x8c, 3, 0, 0}},
{AMOVW, Yfs, Ynone, Yml, movRegMem, [4]uint8{0x8c, 4, 0, 0}},
{AMOVW, Ygs, Ynone, Yml, movRegMem, [4]uint8{0x8c, 5, 0, 0}},
{AMOVW, Yml, Ynone, Yes, movMemReg, [4]uint8{0x8e, 0, 0, 0}},
{AMOVW, Yml, Ynone, Ycs, movMemReg, [4]uint8{0x8e, 1, 0, 0}},
{AMOVW, Yml, Ynone, Yss, movMemReg, [4]uint8{0x8e, 2, 0, 0}},
{AMOVW, Yml, Ynone, Yds, movMemReg, [4]uint8{0x8e, 3, 0, 0}},
{AMOVW, Yml, Ynone, Yfs, movMemReg, [4]uint8{0x8e, 4, 0, 0}},
{AMOVW, Yml, Ynone, Ygs, movMemReg, [4]uint8{0x8e, 5, 0, 0}},
// mov cr
{AMOVL, Ycr0, Ynone, Yrl, movRegMem2op, [4]uint8{0x0f, 0x20, 0, 0}},
{AMOVL, Ycr2, Ynone, Yrl, movRegMem2op, [4]uint8{0x0f, 0x20, 2, 0}},
{AMOVL, Ycr3, Ynone, Yrl, movRegMem2op, [4]uint8{0x0f, 0x20, 3, 0}},
{AMOVL, Ycr4, Ynone, Yrl, movRegMem2op, [4]uint8{0x0f, 0x20, 4, 0}},
{AMOVL, Ycr8, Ynone, Yrl, movRegMem2op, [4]uint8{0x0f, 0x20, 8, 0}},
{AMOVQ, Ycr0, Ynone, Yrl, movRegMem2op, [4]uint8{0x0f, 0x20, 0, 0}},
{AMOVQ, Ycr2, Ynone, Yrl, movRegMem2op, [4]uint8{0x0f, 0x20, 2, 0}},
{AMOVQ, Ycr3, Ynone, Yrl, movRegMem2op, [4]uint8{0x0f, 0x20, 3, 0}},
{AMOVQ, Ycr4, Ynone, Yrl, movRegMem2op, [4]uint8{0x0f, 0x20, 4, 0}},
{AMOVQ, Ycr8, Ynone, Yrl, movRegMem2op, [4]uint8{0x0f, 0x20, 8, 0}},
{AMOVL, Yrl, Ynone, Ycr0, movMemReg2op, [4]uint8{0x0f, 0x22, 0, 0}},
{AMOVL, Yrl, Ynone, Ycr2, movMemReg2op, [4]uint8{0x0f, 0x22, 2, 0}},
{AMOVL, Yrl, Ynone, Ycr3, movMemReg2op, [4]uint8{0x0f, 0x22, 3, 0}},
{AMOVL, Yrl, Ynone, Ycr4, movMemReg2op, [4]uint8{0x0f, 0x22, 4, 0}},
{AMOVL, Yrl, Ynone, Ycr8, movMemReg2op, [4]uint8{0x0f, 0x22, 8, 0}},
{AMOVQ, Yrl, Ynone, Ycr0, movMemReg2op, [4]uint8{0x0f, 0x22, 0, 0}},
{AMOVQ, Yrl, Ynone, Ycr2, movMemReg2op, [4]uint8{0x0f, 0x22, 2, 0}},
{AMOVQ, Yrl, Ynone, Ycr3, movMemReg2op, [4]uint8{0x0f, 0x22, 3, 0}},
{AMOVQ, Yrl, Ynone, Ycr4, movMemReg2op, [4]uint8{0x0f, 0x22, 4, 0}},
{AMOVQ, Yrl, Ynone, Ycr8, movMemReg2op, [4]uint8{0x0f, 0x22, 8, 0}},
// mov dr
{AMOVL, Ydr0, Ynone, Yrl, movRegMem2op, [4]uint8{0x0f, 0x21, 0, 0}},
{AMOVL, Ydr6, Ynone, Yrl, movRegMem2op, [4]uint8{0x0f, 0x21, 6, 0}},
{AMOVL, Ydr7, Ynone, Yrl, movRegMem2op, [4]uint8{0x0f, 0x21, 7, 0}},
{AMOVQ, Ydr0, Ynone, Yrl, movRegMem2op, [4]uint8{0x0f, 0x21, 0, 0}},
{AMOVQ, Ydr2, Ynone, Yrl, movRegMem2op, [4]uint8{0x0f, 0x21, 2, 0}},
{AMOVQ, Ydr3, Ynone, Yrl, movRegMem2op, [4]uint8{0x0f, 0x21, 3, 0}},
{AMOVQ, Ydr6, Ynone, Yrl, movRegMem2op, [4]uint8{0x0f, 0x21, 6, 0}},
{AMOVQ, Ydr7, Ynone, Yrl, movRegMem2op, [4]uint8{0x0f, 0x21, 7, 0}},
{AMOVL, Yrl, Ynone, Ydr0, movMemReg2op, [4]uint8{0x0f, 0x23, 0, 0}},
{AMOVL, Yrl, Ynone, Ydr6, movMemReg2op, [4]uint8{0x0f, 0x23, 6, 0}},
{AMOVL, Yrl, Ynone, Ydr7, movMemReg2op, [4]uint8{0x0f, 0x23, 7, 0}},
{AMOVQ, Yrl, Ynone, Ydr0, movMemReg2op, [4]uint8{0x0f, 0x23, 0, 0}},
{AMOVQ, Yrl, Ynone, Ydr2, movMemReg2op, [4]uint8{0x0f, 0x23, 2, 0}},
{AMOVQ, Yrl, Ynone, Ydr3, movMemReg2op, [4]uint8{0x0f, 0x23, 3, 0}},
{AMOVQ, Yrl, Ynone, Ydr6, movMemReg2op, [4]uint8{0x0f, 0x23, 6, 0}},
{AMOVQ, Yrl, Ynone, Ydr7, movMemReg2op, [4]uint8{0x0f, 0x23, 7, 0}},
// mov tr
{AMOVL, Ytr6, Ynone, Yml, movRegMem2op, [4]uint8{0x0f, 0x24, 6, 0}},
{AMOVL, Ytr7, Ynone, Yml, movRegMem2op, [4]uint8{0x0f, 0x24, 7, 0}},
{AMOVL, Yml, Ynone, Ytr6, movMemReg2op, [4]uint8{0x0f, 0x26, 6, 0xff}},
{AMOVL, Yml, Ynone, Ytr7, movMemReg2op, [4]uint8{0x0f, 0x26, 7, 0xff}},
// lgdt, sgdt, lidt, sidt
{AMOVL, Ym, Ynone, Ygdtr, movMemReg2op, [4]uint8{0x0f, 0x01, 2, 0}},
{AMOVL, Ygdtr, Ynone, Ym, movRegMem2op, [4]uint8{0x0f, 0x01, 0, 0}},
{AMOVL, Ym, Ynone, Yidtr, movMemReg2op, [4]uint8{0x0f, 0x01, 3, 0}},
{AMOVL, Yidtr, Ynone, Ym, movRegMem2op, [4]uint8{0x0f, 0x01, 1, 0}},
{AMOVQ, Ym, Ynone, Ygdtr, movMemReg2op, [4]uint8{0x0f, 0x01, 2, 0}},
{AMOVQ, Ygdtr, Ynone, Ym, movRegMem2op, [4]uint8{0x0f, 0x01, 0, 0}},
{AMOVQ, Ym, Ynone, Yidtr, movMemReg2op, [4]uint8{0x0f, 0x01, 3, 0}},
{AMOVQ, Yidtr, Ynone, Ym, movRegMem2op, [4]uint8{0x0f, 0x01, 1, 0}},
// lldt, sldt
{AMOVW, Yml, Ynone, Yldtr, movMemReg2op, [4]uint8{0x0f, 0x00, 2, 0}},
{AMOVW, Yldtr, Ynone, Yml, movRegMem2op, [4]uint8{0x0f, 0x00, 0, 0}},
// lmsw, smsw
{AMOVW, Yml, Ynone, Ymsw, movMemReg2op, [4]uint8{0x0f, 0x01, 6, 0}},
{AMOVW, Ymsw, Ynone, Yml, movRegMem2op, [4]uint8{0x0f, 0x01, 4, 0}},
// ltr, str
{AMOVW, Yml, Ynone, Ytask, movMemReg2op, [4]uint8{0x0f, 0x00, 3, 0}},
{AMOVW, Ytask, Ynone, Yml, movRegMem2op, [4]uint8{0x0f, 0x00, 1, 0}},
/* load full pointer - unsupported
{AMOVL, Yml, Ycol, movFullPtr, [4]uint8{0, 0, 0, 0}},
{AMOVW, Yml, Ycol, movFullPtr, [4]uint8{Pe, 0, 0, 0}},
*/
// double shift
{ASHLL, Yi8, Yrl, Yml, movDoubleShift, [4]uint8{0xa4, 0xa5, 0, 0}},
{ASHLL, Ycl, Yrl, Yml, movDoubleShift, [4]uint8{0xa4, 0xa5, 0, 0}},
{ASHLL, Ycx, Yrl, Yml, movDoubleShift, [4]uint8{0xa4, 0xa5, 0, 0}},
{ASHRL, Yi8, Yrl, Yml, movDoubleShift, [4]uint8{0xac, 0xad, 0, 0}},
{ASHRL, Ycl, Yrl, Yml, movDoubleShift, [4]uint8{0xac, 0xad, 0, 0}},
{ASHRL, Ycx, Yrl, Yml, movDoubleShift, [4]uint8{0xac, 0xad, 0, 0}},
{ASHLQ, Yi8, Yrl, Yml, movDoubleShift, [4]uint8{Pw, 0xa4, 0xa5, 0}},
{ASHLQ, Ycl, Yrl, Yml, movDoubleShift, [4]uint8{Pw, 0xa4, 0xa5, 0}},
{ASHLQ, Ycx, Yrl, Yml, movDoubleShift, [4]uint8{Pw, 0xa4, 0xa5, 0}},
{ASHRQ, Yi8, Yrl, Yml, movDoubleShift, [4]uint8{Pw, 0xac, 0xad, 0}},
{ASHRQ, Ycl, Yrl, Yml, movDoubleShift, [4]uint8{Pw, 0xac, 0xad, 0}},
{ASHRQ, Ycx, Yrl, Yml, movDoubleShift, [4]uint8{Pw, 0xac, 0xad, 0}},
{ASHLW, Yi8, Yrl, Yml, movDoubleShift, [4]uint8{Pe, 0xa4, 0xa5, 0}},
{ASHLW, Ycl, Yrl, Yml, movDoubleShift, [4]uint8{Pe, 0xa4, 0xa5, 0}},
{ASHLW, Ycx, Yrl, Yml, movDoubleShift, [4]uint8{Pe, 0xa4, 0xa5, 0}},
{ASHRW, Yi8, Yrl, Yml, movDoubleShift, [4]uint8{Pe, 0xac, 0xad, 0}},
{ASHRW, Ycl, Yrl, Yml, movDoubleShift, [4]uint8{Pe, 0xac, 0xad, 0}},
{ASHRW, Ycx, Yrl, Yml, movDoubleShift, [4]uint8{Pe, 0xac, 0xad, 0}},
// load TLS base
{AMOVL, Ytls, Ynone, Yrl, movTLSReg, [4]uint8{0, 0, 0, 0}},
{AMOVQ, Ytls, Ynone, Yrl, movTLSReg, [4]uint8{0, 0, 0, 0}},
{0, 0, 0, 0, 0, [4]uint8{}},
}
func isax(a *obj.Addr) bool {
switch a.Reg {
case REG_AX, REG_AL, REG_AH:
return true
}
return a.Index == REG_AX
}
func subreg(p *obj.Prog, from int, to int) {
if false { /* debug['Q'] */
fmt.Printf("\n%v\ts/%v/%v/\n", p, rconv(from), rconv(to))
}
if int(p.From.Reg) == from {
p.From.Reg = int16(to)
p.Ft = 0
}
if int(p.To.Reg) == from {
p.To.Reg = int16(to)
p.Tt = 0
}
if int(p.From.Index) == from {
p.From.Index = int16(to)
p.Ft = 0
}
if int(p.To.Index) == from {
p.To.Index = int16(to)
p.Tt = 0
}
if false { /* debug['Q'] */
fmt.Printf("%v\n", p)
}
}
func (ab *AsmBuf) mediaop(ctxt *obj.Link, o *Optab, op int, osize int, z int) int {
switch op {
case Pm, Pe, Pf2, Pf3:
if osize != 1 {
if op != Pm {
ab.Put1(byte(op))
}
ab.Put1(Pm)
z++
op = int(o.op[z])
break
}
fallthrough
default:
if ab.Len() == 0 || ab.Last() != Pm {
ab.Put1(Pm)
}
}
ab.Put1(byte(op))
return z
}
var bpduff1 = []byte{
0x48, 0x89, 0x6c, 0x24, 0xf0, // MOVQ BP, -16(SP)
0x48, 0x8d, 0x6c, 0x24, 0xf0, // LEAQ -16(SP), BP
}
var bpduff2 = []byte{
0x48, 0x8b, 0x6d, 0x00, // MOVQ 0(BP), BP
}
// asmevex emits EVEX pregis and opcode byte.
// In addition to asmvex r/m, vvvv and reg fields also requires optional
// K-masking register.
//
// Expects asmbuf.evex to be properly initialized.
func (ab *AsmBuf) asmevex(ctxt *obj.Link, p *obj.Prog, rm, v, r, k *obj.Addr) {
ab.evexflag = true
evex := ab.evex
rexR := byte(1)
evexR := byte(1)
rexX := byte(1)
rexB := byte(1)
if r != nil {
if regrex[r.Reg]&Rxr != 0 {
rexR = 0 // "ModR/M.reg" selector 4th bit.
}
if regrex[r.Reg]&RxrEvex != 0 {
evexR = 0 // "ModR/M.reg" selector 5th bit.
}
}
if rm != nil {
if rm.Index == REG_NONE && regrex[rm.Reg]&RxrEvex != 0 {
rexX = 0
} else if regrex[rm.Index]&Rxx != 0 {
rexX = 0
}
if regrex[rm.Reg]&Rxb != 0 {
rexB = 0
}
}
// P0 = [R][X][B][R'][00][mm]
p0 := (rexR << 7) |
(rexX << 6) |
(rexB << 5) |
(evexR << 4) |
(0 << 2) |
(evex.M() << 0)
vexV := byte(0)
if v != nil {
// 4bit-wide reg index.
vexV = byte(reg[v.Reg]|(regrex[v.Reg]&Rxr)<<1) & 0xF
}
vexV ^= 0x0F
// P1 = [W][vvvv][1][pp]
p1 := (evex.W() << 7) |
(vexV << 3) |
(1 << 2) |
(evex.P() << 0)
suffix := evexSuffixMap[p.Scond]
evexZ := byte(0)
evexLL := evex.L()
evexB := byte(0)
evexV := byte(1)
evexA := byte(0)
if suffix.zeroing {
if !evex.ZeroingEnabled() {
ctxt.Diag("unsupported zeroing: %v", p)
}
if k == nil {
// When you request zeroing you must specify a mask register.
// See issue 57952.
ctxt.Diag("mask register must be specified for .Z instructions: %v", p)
} else if k.Reg == REG_K0 {
// The mask register must not be K0. That restriction is already
// handled by the Yknot0 restriction in the opcode tables, so we
// won't ever reach here. But put something sensible here just in case.
ctxt.Diag("mask register must not be K0 for .Z instructions: %v", p)
}
evexZ = 1
}
switch {
case suffix.rounding != rcUnset:
if rm != nil && rm.Type == obj.TYPE_MEM {
ctxt.Diag("illegal rounding with memory argument: %v", p)
} else if !evex.RoundingEnabled() {
ctxt.Diag("unsupported rounding: %v", p)
}
evexB = 1
evexLL = suffix.rounding
case suffix.broadcast:
if rm == nil || rm.Type != obj.TYPE_MEM {
ctxt.Diag("illegal broadcast without memory argument: %v", p)
} else if !evex.BroadcastEnabled() {
ctxt.Diag("unsupported broadcast: %v", p)
}
evexB = 1
case suffix.sae:
if rm != nil && rm.Type == obj.TYPE_MEM {
ctxt.Diag("illegal SAE with memory argument: %v", p)
} else if !evex.SaeEnabled() {
ctxt.Diag("unsupported SAE: %v", p)
}
evexB = 1
}
if rm != nil && regrex[rm.Index]&RxrEvex != 0 {
evexV = 0
} else if v != nil && regrex[v.Reg]&RxrEvex != 0 {
evexV = 0 // VSR selector 5th bit.
}
if k != nil {
evexA = byte(reg[k.Reg])
}
// P2 = [z][L'L][b][V'][aaa]
p2 := (evexZ << 7) |
(evexLL << 5) |
(evexB << 4) |
(evexV << 3) |
(evexA << 0)
const evexEscapeByte = 0x62
ab.Put4(evexEscapeByte, p0, p1, p2)
ab.Put1(evex.opcode)
}
// Emit VEX prefix and opcode byte.
// The three addresses are the r/m, vvvv, and reg fields.
// The reg and rm arguments appear in the same order as the
// arguments to asmand, which typically follows the call to asmvex.
// The final two arguments are the VEX prefix (see encoding above)
// and the opcode byte.
// For details about vex prefix see:
// https://en.wikipedia.org/wiki/VEX_prefix#Technical_description
func (ab *AsmBuf) asmvex(ctxt *obj.Link, rm, v, r *obj.Addr, vex, opcode uint8) {
ab.vexflag = true
rexR := 0
if r != nil {
rexR = regrex[r.Reg] & Rxr
}
rexB := 0
rexX := 0
if rm != nil {
rexB = regrex[rm.Reg] & Rxb
rexX = regrex[rm.Index] & Rxx
}
vexM := (vex >> 3) & 0x7
vexWLP := vex & 0x87
vexV := byte(0)
if v != nil {
vexV = byte(reg[v.Reg]|(regrex[v.Reg]&Rxr)<<1) & 0xF
}
vexV ^= 0xF
if vexM == 1 && (rexX|rexB) == 0 && vex&vexW1 == 0 {
// Can use 2-byte encoding.
ab.Put2(0xc5, byte(rexR<<5)^0x80|vexV<<3|vexWLP)
} else {
// Must use 3-byte encoding.
ab.Put3(0xc4,
(byte(rexR|rexX|rexB)<<5)^0xE0|vexM,
vexV<<3|vexWLP,
)
}
ab.Put1(opcode)
}
// regIndex returns register index that fits in 5 bits.
//
// R : 3 bit | legacy instructions | N/A
// [R/V]EX.R : 1 bit | REX / VEX extension bit | Rxr
// EVEX.R : 1 bit | EVEX extension bit | RxrEvex
//
// Examples:
//
// REG_Z30 => 30
// REG_X15 => 15
// REG_R9 => 9
// REG_AX => 0
func regIndex(r int16) int {
lower3bits := reg[r]
high4bit := regrex[r] & Rxr << 1
high5bit := regrex[r] & RxrEvex << 0
return lower3bits | high4bit | high5bit
}
// avx2gatherValid reports whether p satisfies AVX2 gather constraints.
// Reports errors via ctxt.
func avx2gatherValid(ctxt *obj.Link, p *obj.Prog) bool {
// If any pair of the index, mask, or destination registers
// are the same, illegal instruction trap (#UD) is triggered.
index := regIndex(p.GetFrom3().Index)
mask := regIndex(p.From.Reg)
dest := regIndex(p.To.Reg)
if dest == mask || dest == index || mask == index {
ctxt.Diag("mask, index, and destination registers should be distinct: %v", p)
return false
}
return true
}
// avx512gatherValid reports whether p satisfies AVX512 gather constraints.
// Reports errors via ctxt.
func avx512gatherValid(ctxt *obj.Link, p *obj.Prog) bool {
// Illegal instruction trap (#UD) is triggered if the destination vector
// register is the same as index vector in VSIB.
index := regIndex(p.From.Index)
dest := regIndex(p.To.Reg)
if dest == index {
ctxt.Diag("index and destination registers should be distinct: %v", p)
return false
}
return true
}
func (ab *AsmBuf) doasm(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog) {
o := opindex[p.As&obj.AMask]
if o == nil {
ctxt.Diag("asmins: missing op %v", p)
return
}
if pre := prefixof(ctxt, &p.From); pre != 0 {
ab.Put1(byte(pre))
}
if pre := prefixof(ctxt, &p.To); pre != 0 {
ab.Put1(byte(pre))
}
// Checks to warn about instruction/arguments combinations that
// will unconditionally trigger illegal instruction trap (#UD).
switch p.As {
case AVGATHERDPD,
AVGATHERQPD,
AVGATHERDPS,
AVGATHERQPS,
AVPGATHERDD,
AVPGATHERQD,
AVPGATHERDQ,
AVPGATHERQQ:
if p.GetFrom3() == nil {
// gathers need a 3rd arg. See issue 58822.
ctxt.Diag("need a third arg for gather instruction: %v", p)
return
}
// AVX512 gather requires explicit K mask.
if p.GetFrom3().Reg >= REG_K0 && p.GetFrom3().Reg <= REG_K7 {
if !avx512gatherValid(ctxt, p) {
return
}
} else {
if !avx2gatherValid(ctxt, p) {
return
}
}
}
if p.Ft == 0 {
p.Ft = uint8(oclass(ctxt, p, &p.From))
}
if p.Tt == 0 {
p.Tt = uint8(oclass(ctxt, p, &p.To))
}
ft := int(p.Ft) * Ymax
var f3t int
tt := int(p.Tt) * Ymax
xo := obj.Bool2int(o.op[0] == 0x0f)
z := 0
var a *obj.Addr
var l int
var op int
var q *obj.Prog
var r *obj.Reloc
var rel obj.Reloc
var v int64
args := make([]int, 0, argListMax)
if ft != Ynone*Ymax {
args = append(args, ft)
}
for i := range p.RestArgs {
args = append(args, oclass(ctxt, p, &p.RestArgs[i].Addr)*Ymax)
}
if tt != Ynone*Ymax {
args = append(args, tt)
}
for _, yt := range o.ytab {
// ytab matching is purely args-based,
// but AVX512 suffixes like "Z" or "RU_SAE" will
// add EVEX-only filter that will reject non-EVEX matches.
//
// Consider "VADDPD.BCST 2032(DX), X0, X0".
// Without this rule, operands will lead to VEX-encoded form
// and produce "c5b15813" encoding.
if !yt.match(args) {
// "xo" is always zero for VEX/EVEX encoded insts.
z += int(yt.zoffset) + xo
} else {
if p.Scond != 0 && !evexZcase(yt.zcase) {
// Do not signal error and continue to search
// for matching EVEX-encoded form.
z += int(yt.zoffset)
continue
}
switch o.prefix {
case Px1: // first option valid only in 32-bit mode
if ctxt.Arch.Family == sys.AMD64 && z == 0 {
z += int(yt.zoffset) + xo
continue
}
case Pq: // 16 bit escape and opcode escape
ab.Put2(Pe, Pm)
case Pq3: // 16 bit escape and opcode escape + REX.W
ab.rexflag |= Pw
ab.Put2(Pe, Pm)
case Pq4: // 66 0F 38
ab.Put3(0x66, 0x0F, 0x38)
case Pq4w: // 66 0F 38 + REX.W
ab.rexflag |= Pw
ab.Put3(0x66, 0x0F, 0x38)
case Pq5: // F3 0F 38
ab.Put3(0xF3, 0x0F, 0x38)
case Pq5w: // F3 0F 38 + REX.W
ab.rexflag |= Pw
ab.Put3(0xF3, 0x0F, 0x38)
case Pf2, // xmm opcode escape
Pf3:
ab.Put2(o.prefix, Pm)
case Pef3:
ab.Put3(Pe, Pf3, Pm)
case Pfw: // xmm opcode escape + REX.W
ab.rexflag |= Pw
ab.Put2(Pf3, Pm)
case Pm: // opcode escape
ab.Put1(Pm)
case Pe: // 16 bit escape
ab.Put1(Pe)
case Pw: // 64-bit escape
if ctxt.Arch.Family != sys.AMD64 {
ctxt.Diag("asmins: illegal 64: %v", p)
}
ab.rexflag |= Pw
case Pw8: // 64-bit escape if z >= 8
if z >= 8 {
if ctxt.Arch.Family != sys.AMD64 {
ctxt.Diag("asmins: illegal 64: %v", p)
}
ab.rexflag |= Pw
}
case Pb: // botch
if ctxt.Arch.Family != sys.AMD64 && (isbadbyte(&p.From) || isbadbyte(&p.To)) {
goto bad
}
// NOTE(rsc): This is probably safe to do always,
// but when enabled it chooses different encodings
// than the old cmd/internal/obj/i386 code did,
// which breaks our "same bits out" checks.
// In particular, CMPB AX, $0 encodes as 80 f8 00
// in the original obj/i386, and it would encode
// (using a valid, shorter form) as 3c 00 if we enabled
// the call to bytereg here.
if ctxt.Arch.Family == sys.AMD64 {
bytereg(&p.From, &p.Ft)
bytereg(&p.To, &p.Tt)
}
case P32: // 32 bit but illegal if 64-bit mode
if ctxt.Arch.Family == sys.AMD64 {
ctxt.Diag("asmins: illegal in 64-bit mode: %v", p)
}
case Py: // 64-bit only, no prefix
if ctxt.Arch.Family != sys.AMD64 {
ctxt.Diag("asmins: illegal in %d-bit mode: %v", ctxt.Arch.RegSize*8, p)
}
case Py1: // 64-bit only if z < 1, no prefix
if z < 1 && ctxt.Arch.Family != sys.AMD64 {
ctxt.Diag("asmins: illegal in %d-bit mode: %v", ctxt.Arch.RegSize*8, p)
}
case Py3: // 64-bit only if z < 3, no prefix
if z < 3 && ctxt.Arch.Family != sys.AMD64 {
ctxt.Diag("asmins: illegal in %d-bit mode: %v", ctxt.Arch.RegSize*8, p)
}
}
if z >= len(o.op) {
log.Fatalf("asmins bad table %v", p)
}
op = int(o.op[z])
if op == 0x0f {
ab.Put1(byte(op))
z++
op = int(o.op[z])
}
switch yt.zcase {
default:
ctxt.Diag("asmins: unknown z %d %v", yt.zcase, p)
return
case Zpseudo:
break
case Zlit:
ab.PutOpBytesLit(z, &o.op)
case Zlitr_m:
ab.PutOpBytesLit(z, &o.op)
ab.asmand(ctxt, cursym, p, &p.To, &p.From)
case Zlitm_r:
ab.PutOpBytesLit(z, &o.op)
ab.asmand(ctxt, cursym, p, &p.From, &p.To)
case Zlit_m_r:
ab.PutOpBytesLit(z, &o.op)
ab.asmand(ctxt, cursym, p, p.GetFrom3(), &p.To)
case Zmb_r:
bytereg(&p.From, &p.Ft)
fallthrough
case Zm_r:
ab.Put1(byte(op))
ab.asmand(ctxt, cursym, p, &p.From, &p.To)
case Z_m_r:
ab.Put1(byte(op))
ab.asmand(ctxt, cursym, p, p.GetFrom3(), &p.To)
case Zm2_r:
ab.Put2(byte(op), o.op[z+1])
ab.asmand(ctxt, cursym, p, &p.From, &p.To)
case Zm_r_xm:
ab.mediaop(ctxt, o, op, int(yt.zoffset), z)
ab.asmand(ctxt, cursym, p, &p.From, &p.To)
case Zm_r_xm_nr:
ab.rexflag = 0
ab.mediaop(ctxt, o, op, int(yt.zoffset), z)
ab.asmand(ctxt, cursym, p, &p.From, &p.To)
case Zm_r_i_xm:
ab.mediaop(ctxt, o, op, int(yt.zoffset), z)
ab.asmand(ctxt, cursym, p, &p.From, p.GetFrom3())
ab.Put1(byte(p.To.Offset))
case Zibm_r, Zibr_m:
ab.PutOpBytesLit(z, &o.op)
if yt.zcase == Zibr_m {
ab.asmand(ctxt, cursym, p, &p.To, p.GetFrom3())
} else {
ab.asmand(ctxt, cursym, p, p.GetFrom3(), &p.To)
}
switch {
default:
ab.Put1(byte(p.From.Offset))
case yt.args[0] == Yi32 && o.prefix == Pe:
ab.PutInt16(int16(p.From.Offset))
case yt.args[0] == Yi32:
ab.PutInt32(int32(p.From.Offset))
}
case Zaut_r:
ab.Put1(0x8d) // leal
if p.From.Type != obj.TYPE_ADDR {
ctxt.Diag("asmins: Zaut sb type ADDR")
}
p.From.Type = obj.TYPE_MEM
ab.asmand(ctxt, cursym, p, &p.From, &p.To)
p.From.Type = obj.TYPE_ADDR
case Zm_o:
ab.Put1(byte(op))
ab.asmando(ctxt, cursym, p, &p.From, int(o.op[z+1]))
case Zr_m:
ab.Put1(byte(op))
ab.asmand(ctxt, cursym, p, &p.To, &p.From)
case Zvex:
ab.asmvex(ctxt, &p.From, p.GetFrom3(), &p.To, o.op[z], o.op[z+1])
case Zvex_rm_v_r:
ab.asmvex(ctxt, &p.From, p.GetFrom3(), &p.To, o.op[z], o.op[z+1])
ab.asmand(ctxt, cursym, p, &p.From, &p.To)
case Zvex_rm_v_ro:
ab.asmvex(ctxt, &p.From, p.GetFrom3(), &p.To, o.op[z], o.op[z+1])
ab.asmando(ctxt, cursym, p, &p.From, int(o.op[z+2]))
case Zvex_i_rm_vo:
ab.asmvex(ctxt, p.GetFrom3(), &p.To, nil, o.op[z], o.op[z+1])
ab.asmando(ctxt, cursym, p, p.GetFrom3(), int(o.op[z+2]))
ab.Put1(byte(p.From.Offset))
case Zvex_i_r_v:
ab.asmvex(ctxt, p.GetFrom3(), &p.To, nil, o.op[z], o.op[z+1])
regnum := byte(0x7)
if p.GetFrom3().Reg >= REG_X0 && p.GetFrom3().Reg <= REG_X15 {
regnum &= byte(p.GetFrom3().Reg - REG_X0)
} else {
regnum &= byte(p.GetFrom3().Reg - REG_Y0)
}
ab.Put1(o.op[z+2] | regnum)
ab.Put1(byte(p.From.Offset))
case Zvex_i_rm_v_r:
imm, from, from3, to := unpackOps4(p)
ab.asmvex(ctxt, from, from3, to, o.op[z], o.op[z+1])
ab.asmand(ctxt, cursym, p, from, to)
ab.Put1(byte(imm.Offset))
case Zvex_i_rm_r:
ab.asmvex(ctxt, p.GetFrom3(), nil, &p.To, o.op[z], o.op[z+1])
ab.asmand(ctxt, cursym, p, p.GetFrom3(), &p.To)
ab.Put1(byte(p.From.Offset))
case Zvex_v_rm_r:
ab.asmvex(ctxt, p.GetFrom3(), &p.From, &p.To, o.op[z], o.op[z+1])
ab.asmand(ctxt, cursym, p, p.GetFrom3(), &p.To)
case Zvex_r_v_rm:
ab.asmvex(ctxt, &p.To, p.GetFrom3(), &p.From, o.op[z], o.op[z+1])
ab.asmand(ctxt, cursym, p, &p.To, &p.From)
case Zvex_rm_r_vo:
ab.asmvex(ctxt, &p.From, &p.To, p.GetFrom3(), o.op[z], o.op[z+1])
ab.asmando(ctxt, cursym, p, &p.From, int(o.op[z+2]))
case Zvex_i_r_rm:
ab.asmvex(ctxt, &p.To, nil, p.GetFrom3(), o.op[z], o.op[z+1])
ab.asmand(ctxt, cursym, p, &p.To, p.GetFrom3())
ab.Put1(byte(p.From.Offset))
case Zvex_hr_rm_v_r:
hr, from, from3, to := unpackOps4(p)
ab.asmvex(ctxt, from, from3, to, o.op[z], o.op[z+1])
ab.asmand(ctxt, cursym, p, from, to)
ab.Put1(byte(regIndex(hr.Reg) << 4))
case Zevex_k_rmo:
ab.evex = newEVEXBits(z, &o.op)
ab.asmevex(ctxt, p, &p.To, nil, nil, &p.From)
ab.asmando(ctxt, cursym, p, &p.To, int(o.op[z+3]))
case Zevex_i_rm_vo:
ab.evex = newEVEXBits(z, &o.op)
ab.asmevex(ctxt, p, p.GetFrom3(), &p.To, nil, nil)
ab.asmando(ctxt, cursym, p, p.GetFrom3(), int(o.op[z+3]))
ab.Put1(byte(p.From.Offset))
case Zevex_i_rm_k_vo:
imm, from, kmask, to := unpackOps4(p)
ab.evex = newEVEXBits(z, &o.op)
ab.asmevex(ctxt, p, from, to, nil, kmask)
ab.asmando(ctxt, cursym, p, from, int(o.op[z+3]))
ab.Put1(byte(imm.Offset))
case Zevex_i_r_rm:
ab.evex = newEVEXBits(z, &o.op)
ab.asmevex(ctxt, p, &p.To, nil, p.GetFrom3(), nil)
ab.asmand(ctxt, cursym, p, &p.To, p.GetFrom3())
ab.Put1(byte(p.From.Offset))
case Zevex_i_r_k_rm:
imm, from, kmask, to := unpackOps4(p)
ab.evex = newEVEXBits(z, &o.op)
ab.asmevex(ctxt, p, to, nil, from, kmask)
ab.asmand(ctxt, cursym, p, to, from)
ab.Put1(byte(imm.Offset))
case Zevex_i_rm_r:
ab.evex = newEVEXBits(z, &o.op)
ab.asmevex(ctxt, p, p.GetFrom3(), nil, &p.To, nil)
ab.asmand(ctxt, cursym, p, p.GetFrom3(), &p.To)
ab.Put1(byte(p.From.Offset))
case Zevex_i_rm_k_r:
imm, from, kmask, to := unpackOps4(p)
ab.evex = newEVEXBits(z, &o.op)
ab.asmevex(ctxt, p, from, nil, to, kmask)
ab.asmand(ctxt, cursym, p, from, to)
ab.Put1(byte(imm.Offset))
case Zevex_i_rm_v_r:
imm, from, from3, to := unpackOps4(p)
ab.evex = newEVEXBits(z, &o.op)
ab.asmevex(ctxt, p, from, from3, to, nil)
ab.asmand(ctxt, cursym, p, from, to)
ab.Put1(byte(imm.Offset))
case Zevex_i_rm_v_k_r:
imm, from, from3, kmask, to := unpackOps5(p)
ab.evex = newEVEXBits(z, &o.op)
ab.asmevex(ctxt, p, from, from3, to, kmask)
ab.asmand(ctxt, cursym, p, from, to)
ab.Put1(byte(imm.Offset))
case Zevex_r_v_rm:
ab.evex = newEVEXBits(z, &o.op)
ab.asmevex(ctxt, p, &p.To, p.GetFrom3(), &p.From, nil)
ab.asmand(ctxt, cursym, p, &p.To, &p.From)
case Zevex_rm_v_r:
ab.evex = newEVEXBits(z, &o.op)
ab.asmevex(ctxt, p, &p.From, p.GetFrom3(), &p.To, nil)
ab.asmand(ctxt, cursym, p, &p.From, &p.To)
case Zevex_rm_k_r:
ab.evex = newEVEXBits(z, &o.op)
ab.asmevex(ctxt, p, &p.From, nil, &p.To, p.GetFrom3())
ab.asmand(ctxt, cursym, p, &p.From, &p.To)
case Zevex_r_k_rm:
ab.evex = newEVEXBits(z, &o.op)
ab.asmevex(ctxt, p, &p.To, nil, &p.From, p.GetFrom3())
ab.asmand(ctxt, cursym, p, &p.To, &p.From)
case Zevex_rm_v_k_r:
from, from3, kmask, to := unpackOps4(p)
ab.evex = newEVEXBits(z, &o.op)
ab.asmevex(ctxt, p, from, from3, to, kmask)
ab.asmand(ctxt, cursym, p, from, to)
case Zevex_r_v_k_rm:
from, from3, kmask, to := unpackOps4(p)
ab.evex = newEVEXBits(z, &o.op)
ab.asmevex(ctxt, p, to, from3, from, kmask)
ab.asmand(ctxt, cursym, p, to, from)
case Zr_m_xm:
ab.mediaop(ctxt, o, op, int(yt.zoffset), z)
ab.asmand(ctxt, cursym, p, &p.To, &p.From)
case Zr_m_xm_nr:
ab.rexflag = 0
ab.mediaop(ctxt, o, op, int(yt.zoffset), z)
ab.asmand(ctxt, cursym, p, &p.To, &p.From)
case Zo_m:
ab.Put1(byte(op))
ab.asmando(ctxt, cursym, p, &p.To, int(o.op[z+1]))
case Zcallindreg:
r = obj.Addrel(cursym)
r.Off = int32(p.Pc)
r.Type = objabi.R_CALLIND
r.Siz = 0
fallthrough
case Zo_m64:
ab.Put1(byte(op))
ab.asmandsz(ctxt, cursym, p, &p.To, int(o.op[z+1]), 0, 1)
case Zm_ibo:
ab.Put1(byte(op))
ab.asmando(ctxt, cursym, p, &p.From, int(o.op[z+1]))
ab.Put1(byte(vaddr(ctxt, p, &p.To, nil)))
case Zibo_m:
ab.Put1(byte(op))
ab.asmando(ctxt, cursym, p, &p.To, int(o.op[z+1]))
ab.Put1(byte(vaddr(ctxt, p, &p.From, nil)))
case Zibo_m_xm:
z = ab.mediaop(ctxt, o, op, int(yt.zoffset), z)
ab.asmando(ctxt, cursym, p, &p.To, int(o.op[z+1]))
ab.Put1(byte(vaddr(ctxt, p, &p.From, nil)))
case Z_ib, Zib_:
if yt.zcase == Zib_ {
a = &p.From
} else {
a = &p.To
}
ab.Put1(byte(op))
if p.As == AXABORT {
ab.Put1(o.op[z+1])
}
ab.Put1(byte(vaddr(ctxt, p, a, nil)))
case Zib_rp:
ab.rexflag |= regrex[p.To.Reg] & (Rxb | 0x40)
ab.Put2(byte(op+reg[p.To.Reg]), byte(vaddr(ctxt, p, &p.From, nil)))
case Zil_rp:
ab.rexflag |= regrex[p.To.Reg] & Rxb
ab.Put1(byte(op + reg[p.To.Reg]))
if o.prefix == Pe {
v = vaddr(ctxt, p, &p.From, nil)
ab.PutInt16(int16(v))
} else {
ab.relput4(ctxt, cursym, p, &p.From)
}
case Zo_iw:
ab.Put1(byte(op))
if p.From.Type != obj.TYPE_NONE {
v = vaddr(ctxt, p, &p.From, nil)
ab.PutInt16(int16(v))
}
case Ziq_rp:
v = vaddr(ctxt, p, &p.From, &rel)
l = int(v >> 32)
if l == 0 && rel.Siz != 8 {
ab.rexflag &^= (0x40 | Rxw)
ab.rexflag |= regrex[p.To.Reg] & Rxb
ab.Put1(byte(0xb8 + reg[p.To.Reg]))
if rel.Type != 0 {
r = obj.Addrel(cursym)
*r = rel
r.Off = int32(p.Pc + int64(ab.Len()))
}
ab.PutInt32(int32(v))
} else if l == -1 && uint64(v)&(uint64(1)<<31) != 0 { // sign extend
ab.Put1(0xc7)
ab.asmando(ctxt, cursym, p, &p.To, 0)
ab.PutInt32(int32(v)) // need all 8
} else {
ab.rexflag |= regrex[p.To.Reg] & Rxb
ab.Put1(byte(op + reg[p.To.Reg]))
if rel.Type != 0 {
r = obj.Addrel(cursym)
*r = rel
r.Off = int32(p.Pc + int64(ab.Len()))
}
ab.PutInt64(v)
}
case Zib_rr:
ab.Put1(byte(op))
ab.asmand(ctxt, cursym, p, &p.To, &p.To)
ab.Put1(byte(vaddr(ctxt, p, &p.From, nil)))
case Z_il, Zil_:
if yt.zcase == Zil_ {
a = &p.From
} else {
a = &p.To
}
ab.Put1(byte(op))
if o.prefix == Pe {
v = vaddr(ctxt, p, a, nil)
ab.PutInt16(int16(v))
} else {
ab.relput4(ctxt, cursym, p, a)
}
case Zm_ilo, Zilo_m:
ab.Put1(byte(op))
if yt.zcase == Zilo_m {
a = &p.From
ab.asmando(ctxt, cursym, p, &p.To, int(o.op[z+1]))
} else {
a = &p.To
ab.asmando(ctxt, cursym, p, &p.From, int(o.op[z+1]))
}
if o.prefix == Pe {
v = vaddr(ctxt, p, a, nil)
ab.PutInt16(int16(v))
} else {
ab.relput4(ctxt, cursym, p, a)
}
case Zil_rr:
ab.Put1(byte(op))
ab.asmand(ctxt, cursym, p, &p.To, &p.To)
if o.prefix == Pe {
v = vaddr(ctxt, p, &p.From, nil)
ab.PutInt16(int16(v))
} else {
ab.relput4(ctxt, cursym, p, &p.From)
}
case Z_rp:
ab.rexflag |= regrex[p.To.Reg] & (Rxb | 0x40)
ab.Put1(byte(op + reg[p.To.Reg]))
case Zrp_:
ab.rexflag |= regrex[p.From.Reg] & (Rxb | 0x40)
ab.Put1(byte(op + reg[p.From.Reg]))
case Zcallcon, Zjmpcon:
if yt.zcase == Zcallcon {
ab.Put1(byte(op))
} else {
ab.Put1(o.op[z+1])
}
r = obj.Addrel(cursym)
r.Off = int32(p.Pc + int64(ab.Len()))
r.Type = objabi.R_PCREL
r.Siz = 4
r.Add = p.To.Offset
ab.PutInt32(0)
case Zcallind:
ab.Put2(byte(op), o.op[z+1])
r = obj.Addrel(cursym)
r.Off = int32(p.Pc + int64(ab.Len()))
if ctxt.Arch.Family == sys.AMD64 {
r.Type = objabi.R_PCREL
} else {
r.Type = objabi.R_ADDR
}
r.Siz = 4
r.Add = p.To.Offset
r.Sym = p.To.Sym
ab.PutInt32(0)
case Zcall, Zcallduff:
if p.To.Sym == nil {
ctxt.Diag("call without target")
ctxt.DiagFlush()
log.Fatalf("bad code")
}
if yt.zcase == Zcallduff && ctxt.Flag_dynlink {
ctxt.Diag("directly calling duff when dynamically linking Go")
}
if yt.zcase == Zcallduff && ctxt.Arch.Family == sys.AMD64 {
// Maintain BP around call, since duffcopy/duffzero can't do it
// (the call jumps into the middle of the function).
// This makes it possible to see call sites for duffcopy/duffzero in
// BP-based profiling tools like Linux perf (which is the
// whole point of maintaining frame pointers in Go).
// MOVQ BP, -16(SP)
// LEAQ -16(SP), BP
ab.Put(bpduff1)
}
ab.Put1(byte(op))
r = obj.Addrel(cursym)
r.Off = int32(p.Pc + int64(ab.Len()))
r.Sym = p.To.Sym
r.Add = p.To.Offset
r.Type = objabi.R_CALL
r.Siz = 4
ab.PutInt32(0)
if yt.zcase == Zcallduff && ctxt.Arch.Family == sys.AMD64 {
// Pop BP pushed above.
// MOVQ 0(BP), BP
ab.Put(bpduff2)
}
// TODO: jump across functions needs reloc
case Zbr, Zjmp, Zloop:
if p.As == AXBEGIN {
ab.Put1(byte(op))
}
if p.To.Sym != nil {
if yt.zcase != Zjmp {
ctxt.Diag("branch to ATEXT")
ctxt.DiagFlush()
log.Fatalf("bad code")
}
ab.Put1(o.op[z+1])
r = obj.Addrel(cursym)
r.Off = int32(p.Pc + int64(ab.Len()))
r.Sym = p.To.Sym
// Note: R_CALL instead of R_PCREL. R_CALL is more permissive in that
// it can point to a trampoline instead of the destination itself.
r.Type = objabi.R_CALL
r.Siz = 4
ab.PutInt32(0)
break
}
// Assumes q is in this function.
// TODO: Check in input, preserve in brchain.
// Fill in backward jump now.
q = p.To.Target()
if q == nil {
ctxt.Diag("jmp/branch/loop without target")
ctxt.DiagFlush()
log.Fatalf("bad code")
}
if p.Back&branchBackwards != 0 {
v = q.Pc - (p.Pc + 2)
if v >= -128 && p.As != AXBEGIN {
if p.As == AJCXZL {
ab.Put1(0x67)
}
ab.Put2(byte(op), byte(v))
} else if yt.zcase == Zloop {
ctxt.Diag("loop too far: %v", p)
} else {
v -= 5 - 2
if p.As == AXBEGIN {
v--
}
if yt.zcase == Zbr {
ab.Put1(0x0f)
v--
}
ab.Put1(o.op[z+1])
ab.PutInt32(int32(v))
}
break
}
// Annotate target; will fill in later.
p.Forwd = q.Rel
q.Rel = p
if p.Back&branchShort != 0 && p.As != AXBEGIN {
if p.As == AJCXZL {
ab.Put1(0x67)
}
ab.Put2(byte(op), 0)
} else if yt.zcase == Zloop {
ctxt.Diag("loop too far: %v", p)
} else {
if yt.zcase == Zbr {
ab.Put1(0x0f)
}
ab.Put1(o.op[z+1])
ab.PutInt32(0)
}
case Zbyte:
v = vaddr(ctxt, p, &p.From, &rel)
if rel.Siz != 0 {
rel.Siz = uint8(op)
r = obj.Addrel(cursym)
*r = rel
r.Off = int32(p.Pc + int64(ab.Len()))
}
ab.Put1(byte(v))
if op > 1 {
ab.Put1(byte(v >> 8))
if op > 2 {
ab.PutInt16(int16(v >> 16))
if op > 4 {
ab.PutInt32(int32(v >> 32))
}
}
}
}
return
}
}
f3t = Ynone * Ymax
if p.GetFrom3() != nil {
f3t = oclass(ctxt, p, p.GetFrom3()) * Ymax
}
for mo := ymovtab; mo[0].as != 0; mo = mo[1:] {
var pp obj.Prog
var t []byte
if p.As == mo[0].as {
if ycover[ft+int(mo[0].ft)] != 0 && ycover[f3t+int(mo[0].f3t)] != 0 && ycover[tt+int(mo[0].tt)] != 0 {
t = mo[0].op[:]
switch mo[0].code {
default:
ctxt.Diag("asmins: unknown mov %d %v", mo[0].code, p)
case movLit:
for z = 0; t[z] != 0; z++ {
ab.Put1(t[z])
}
case movRegMem:
ab.Put1(t[0])
ab.asmando(ctxt, cursym, p, &p.To, int(t[1]))
case movMemReg:
ab.Put1(t[0])
ab.asmando(ctxt, cursym, p, &p.From, int(t[1]))
case movRegMem2op: // r,m - 2op
ab.Put2(t[0], t[1])
ab.asmando(ctxt, cursym, p, &p.To, int(t[2]))
ab.rexflag |= regrex[p.From.Reg] & (Rxr | 0x40)
case movMemReg2op:
ab.Put2(t[0], t[1])
ab.asmando(ctxt, cursym, p, &p.From, int(t[2]))
ab.rexflag |= regrex[p.To.Reg] & (Rxr | 0x40)
case movFullPtr:
if t[0] != 0 {
ab.Put1(t[0])
}
switch p.To.Index {
default:
goto bad
case REG_DS:
ab.Put1(0xc5)
case REG_SS:
ab.Put2(0x0f, 0xb2)
case REG_ES:
ab.Put1(0xc4)
case REG_FS:
ab.Put2(0x0f, 0xb4)
case REG_GS:
ab.Put2(0x0f, 0xb5)
}
ab.asmand(ctxt, cursym, p, &p.From, &p.To)
case movDoubleShift:
if t[0] == Pw {
if ctxt.Arch.Family != sys.AMD64 {
ctxt.Diag("asmins: illegal 64: %v", p)
}
ab.rexflag |= Pw
t = t[1:]
} else if t[0] == Pe {
ab.Put1(Pe)
t = t[1:]
}
switch p.From.Type {
default:
goto bad
case obj.TYPE_CONST:
ab.Put2(0x0f, t[0])
ab.asmandsz(ctxt, cursym, p, &p.To, reg[p.GetFrom3().Reg], regrex[p.GetFrom3().Reg], 0)
ab.Put1(byte(p.From.Offset))
case obj.TYPE_REG:
switch p.From.Reg {
default:
goto bad
case REG_CL, REG_CX:
ab.Put2(0x0f, t[1])
ab.asmandsz(ctxt, cursym, p, &p.To, reg[p.GetFrom3().Reg], regrex[p.GetFrom3().Reg], 0)
}
}
// NOTE: The systems listed here are the ones that use the "TLS initial exec" model,
// where you load the TLS base register into a register and then index off that
// register to access the actual TLS variables. Systems that allow direct TLS access
// are handled in prefixof above and should not be listed here.
case movTLSReg:
if ctxt.Arch.Family == sys.AMD64 && p.As != AMOVQ || ctxt.Arch.Family == sys.I386 && p.As != AMOVL {
ctxt.Diag("invalid load of TLS: %v", p)
}
if ctxt.Arch.Family == sys.I386 {
// NOTE: The systems listed here are the ones that use the "TLS initial exec" model,
// where you load the TLS base register into a register and then index off that
// register to access the actual TLS variables. Systems that allow direct TLS access
// are handled in prefixof above and should not be listed here.
switch ctxt.Headtype {
default:
log.Fatalf("unknown TLS base location for %v", ctxt.Headtype)
case objabi.Hlinux, objabi.Hfreebsd:
if ctxt.Flag_shared {
// Note that this is not generating the same insns as the other cases.
// MOV TLS, dst
// becomes
// call __x86.get_pc_thunk.dst
// movl (gotpc + g@gotntpoff)(dst), dst
// which is encoded as
// call __x86.get_pc_thunk.dst
// movq 0(dst), dst
// and R_CALL & R_TLS_IE relocs. This all assumes the only tls variable we access
// is g, which we can't check here, but will when we assemble the second
// instruction.
dst := p.To.Reg
ab.Put1(0xe8)
r = obj.Addrel(cursym)
r.Off = int32(p.Pc + int64(ab.Len()))
r.Type = objabi.R_CALL
r.Siz = 4
r.Sym = ctxt.Lookup("__x86.get_pc_thunk." + strings.ToLower(rconv(int(dst))))
ab.PutInt32(0)
ab.Put2(0x8B, byte(2<<6|reg[dst]|(reg[dst]<<3)))
r = obj.Addrel(cursym)
r.Off = int32(p.Pc + int64(ab.Len()))
r.Type = objabi.R_TLS_IE
r.Siz = 4
r.Add = 2
ab.PutInt32(0)
} else {
// ELF TLS base is 0(GS).
pp.From = p.From
pp.From.Type = obj.TYPE_MEM
pp.From.Reg = REG_GS
pp.From.Offset = 0
pp.From.Index = REG_NONE
pp.From.Scale = 0
ab.Put2(0x65, // GS
0x8B)
ab.asmand(ctxt, cursym, p, &pp.From, &p.To)
}
case objabi.Hplan9:
pp.From = obj.Addr{}
pp.From.Type = obj.TYPE_MEM
pp.From.Name = obj.NAME_EXTERN
pp.From.Sym = plan9privates
pp.From.Offset = 0
pp.From.Index = REG_NONE
ab.Put1(0x8B)
ab.asmand(ctxt, cursym, p, &pp.From, &p.To)
}
break
}
switch ctxt.Headtype {
default:
log.Fatalf("unknown TLS base location for %v", ctxt.Headtype)
case objabi.Hlinux, objabi.Hfreebsd:
if !ctxt.Flag_shared {
log.Fatalf("unknown TLS base location for linux/freebsd without -shared")
}
// Note that this is not generating the same insn as the other cases.
// MOV TLS, R_to
// becomes
// movq g@gottpoff(%rip), R_to
// which is encoded as
// movq 0(%rip), R_to
// and a R_TLS_IE reloc. This all assumes the only tls variable we access
// is g, which we can't check here, but will when we assemble the second
// instruction.
ab.rexflag = Pw | (regrex[p.To.Reg] & Rxr)
ab.Put2(0x8B, byte(0x05|(reg[p.To.Reg]<<3)))
r = obj.Addrel(cursym)
r.Off = int32(p.Pc + int64(ab.Len()))
r.Type = objabi.R_TLS_IE
r.Siz = 4
r.Add = -4
ab.PutInt32(0)
case objabi.Hplan9:
pp.From = obj.Addr{}
pp.From.Type = obj.TYPE_MEM
pp.From.Name = obj.NAME_EXTERN
pp.From.Sym = plan9privates
pp.From.Offset = 0
pp.From.Index = REG_NONE
ab.rexflag |= Pw
ab.Put1(0x8B)
ab.asmand(ctxt, cursym, p, &pp.From, &p.To)
case objabi.Hsolaris: // TODO(rsc): Delete Hsolaris from list. Should not use this code. See progedit in obj6.c.
// TLS base is 0(FS).
pp.From = p.From
pp.From.Type = obj.TYPE_MEM
pp.From.Name = obj.NAME_NONE
pp.From.Reg = REG_NONE
pp.From.Offset = 0
pp.From.Index = REG_NONE
pp.From.Scale = 0
ab.rexflag |= Pw
ab.Put2(0x64, // FS
0x8B)
ab.asmand(ctxt, cursym, p, &pp.From, &p.To)
}
}
return
}
}
}
goto bad
bad:
if ctxt.Arch.Family != sys.AMD64 {
// here, the assembly has failed.
// if it's a byte instruction that has
// unaddressable registers, try to
// exchange registers and reissue the
// instruction with the operands renamed.
pp := *p
unbytereg(&pp.From, &pp.Ft)
unbytereg(&pp.To, &pp.Tt)
z := int(p.From.Reg)
if p.From.Type == obj.TYPE_REG && z >= REG_BP && z <= REG_DI {
// TODO(rsc): Use this code for x86-64 too. It has bug fixes not present in the amd64 code base.
// For now, different to keep bit-for-bit compatibility.
if ctxt.Arch.Family == sys.I386 {
breg := byteswapreg(ctxt, &p.To)
if breg != REG_AX {
ab.Put1(0x87) // xchg lhs,bx
ab.asmando(ctxt, cursym, p, &p.From, reg[breg])
subreg(&pp, z, breg)
ab.doasm(ctxt, cursym, &pp)
ab.Put1(0x87) // xchg lhs,bx
ab.asmando(ctxt, cursym, p, &p.From, reg[breg])
} else {
ab.Put1(byte(0x90 + reg[z])) // xchg lsh,ax
subreg(&pp, z, REG_AX)
ab.doasm(ctxt, cursym, &pp)
ab.Put1(byte(0x90 + reg[z])) // xchg lsh,ax
}
return
}
if isax(&p.To) || p.To.Type == obj.TYPE_NONE {
// We certainly don't want to exchange
// with AX if the op is MUL or DIV.
ab.Put1(0x87) // xchg lhs,bx
ab.asmando(ctxt, cursym, p, &p.From, reg[REG_BX])
subreg(&pp, z, REG_BX)
ab.doasm(ctxt, cursym, &pp)
ab.Put1(0x87) // xchg lhs,bx
ab.asmando(ctxt, cursym, p, &p.From, reg[REG_BX])
} else {
ab.Put1(byte(0x90 + reg[z])) // xchg lsh,ax
subreg(&pp, z, REG_AX)
ab.doasm(ctxt, cursym, &pp)
ab.Put1(byte(0x90 + reg[z])) // xchg lsh,ax
}
return
}
z = int(p.To.Reg)
if p.To.Type == obj.TYPE_REG && z >= REG_BP && z <= REG_DI {
// TODO(rsc): Use this code for x86-64 too. It has bug fixes not present in the amd64 code base.
// For now, different to keep bit-for-bit compatibility.
if ctxt.Arch.Family == sys.I386 {
breg := byteswapreg(ctxt, &p.From)
if breg != REG_AX {
ab.Put1(0x87) //xchg rhs,bx
ab.asmando(ctxt, cursym, p, &p.To, reg[breg])
subreg(&pp, z, breg)
ab.doasm(ctxt, cursym, &pp)
ab.Put1(0x87) // xchg rhs,bx
ab.asmando(ctxt, cursym, p, &p.To, reg[breg])
} else {
ab.Put1(byte(0x90 + reg[z])) // xchg rsh,ax
subreg(&pp, z, REG_AX)
ab.doasm(ctxt, cursym, &pp)
ab.Put1(byte(0x90 + reg[z])) // xchg rsh,ax
}
return
}
if isax(&p.From) {
ab.Put1(0x87) // xchg rhs,bx
ab.asmando(ctxt, cursym, p, &p.To, reg[REG_BX])
subreg(&pp, z, REG_BX)
ab.doasm(ctxt, cursym, &pp)
ab.Put1(0x87) // xchg rhs,bx
ab.asmando(ctxt, cursym, p, &p.To, reg[REG_BX])
} else {
ab.Put1(byte(0x90 + reg[z])) // xchg rsh,ax
subreg(&pp, z, REG_AX)
ab.doasm(ctxt, cursym, &pp)
ab.Put1(byte(0x90 + reg[z])) // xchg rsh,ax
}
return
}
}
ctxt.Diag("%s: invalid instruction: %v", cursym.Name, p)
}
// byteswapreg returns a byte-addressable register (AX, BX, CX, DX)
// which is not referenced in a.
// If a is empty, it returns BX to account for MULB-like instructions
// that might use DX and AX.
func byteswapreg(ctxt *obj.Link, a *obj.Addr) int {
cana, canb, canc, cand := true, true, true, true
if a.Type == obj.TYPE_NONE {
cana, cand = false, false
}
if a.Type == obj.TYPE_REG || ((a.Type == obj.TYPE_MEM || a.Type == obj.TYPE_ADDR) && a.Name == obj.NAME_NONE) {
switch a.Reg {
case REG_NONE:
cana, cand = false, false
case REG_AX, REG_AL, REG_AH:
cana = false
case REG_BX, REG_BL, REG_BH:
canb = false
case REG_CX, REG_CL, REG_CH:
canc = false
case REG_DX, REG_DL, REG_DH:
cand = false
}
}
if a.Type == obj.TYPE_MEM || a.Type == obj.TYPE_ADDR {
switch a.Index {
case REG_AX:
cana = false
case REG_BX:
canb = false
case REG_CX:
canc = false
case REG_DX:
cand = false
}
}
switch {
case cana:
return REG_AX
case canb:
return REG_BX
case canc:
return REG_CX
case cand:
return REG_DX
default:
ctxt.Diag("impossible byte register")
ctxt.DiagFlush()
log.Fatalf("bad code")
return 0
}
}
func isbadbyte(a *obj.Addr) bool {
return a.Type == obj.TYPE_REG && (REG_BP <= a.Reg && a.Reg <= REG_DI || REG_BPB <= a.Reg && a.Reg <= REG_DIB)
}
func (ab *AsmBuf) asmins(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog) {
ab.Reset()
ab.rexflag = 0
ab.vexflag = false
ab.evexflag = false
mark := ab.Len()
ab.doasm(ctxt, cursym, p)
if ab.rexflag != 0 && !ab.vexflag && !ab.evexflag {
// as befits the whole approach of the architecture,
// the rex prefix must appear before the first opcode byte
// (and thus after any 66/67/f2/f3/26/2e/3e prefix bytes, but
// before the 0f opcode escape!), or it might be ignored.
// note that the handbook often misleadingly shows 66/f2/f3 in `opcode'.
if ctxt.Arch.Family != sys.AMD64 {
ctxt.Diag("asmins: illegal in mode %d: %v (%d %d)", ctxt.Arch.RegSize*8, p, p.Ft, p.Tt)
}
n := ab.Len()
var np int
for np = mark; np < n; np++ {
c := ab.At(np)
if c != 0xf2 && c != 0xf3 && (c < 0x64 || c > 0x67) && c != 0x2e && c != 0x3e && c != 0x26 {
break
}
}
ab.Insert(np, byte(0x40|ab.rexflag))
}
n := ab.Len()
for i := len(cursym.R) - 1; i >= 0; i-- {
r := &cursym.R[i]
if int64(r.Off) < p.Pc {
break
}
if ab.rexflag != 0 && !ab.vexflag && !ab.evexflag {
r.Off++
}
if r.Type == objabi.R_PCREL {
if ctxt.Arch.Family == sys.AMD64 || p.As == obj.AJMP || p.As == obj.ACALL {
// PC-relative addressing is relative to the end of the instruction,
// but the relocations applied by the linker are relative to the end
// of the relocation. Because immediate instruction
// arguments can follow the PC-relative memory reference in the
// instruction encoding, the two may not coincide. In this case,
// adjust addend so that linker can keep relocating relative to the
// end of the relocation.
r.Add -= p.Pc + int64(n) - (int64(r.Off) + int64(r.Siz))
} else if ctxt.Arch.Family == sys.I386 {
// On 386 PC-relative addressing (for non-call/jmp instructions)
// assumes that the previous instruction loaded the PC of the end
// of that instruction into CX, so the adjustment is relative to
// that.
r.Add += int64(r.Off) - p.Pc + int64(r.Siz)
}
}
if r.Type == objabi.R_GOTPCREL && ctxt.Arch.Family == sys.I386 {
// On 386, R_GOTPCREL makes the same assumptions as R_PCREL.
r.Add += int64(r.Off) - p.Pc + int64(r.Siz)
}
}
}
// unpackOps4 extracts 4 operands from p.
func unpackOps4(p *obj.Prog) (arg0, arg1, arg2, dst *obj.Addr) {
return &p.From, &p.RestArgs[0].Addr, &p.RestArgs[1].Addr, &p.To
}
// unpackOps5 extracts 5 operands from p.
func unpackOps5(p *obj.Prog) (arg0, arg1, arg2, arg3, dst *obj.Addr) {
return &p.From, &p.RestArgs[0].Addr, &p.RestArgs[1].Addr, &p.RestArgs[2].Addr, &p.To
}
|
go/src/cmd/internal/obj/x86/asm6.go/0
|
{
"file_path": "go/src/cmd/internal/obj/x86/asm6.go",
"repo_id": "go",
"token_count": 81979
}
| 158 |
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package objabi
import (
"path/filepath"
"runtime"
"testing"
)
// On Windows, "/foo" is reported as a relative path
// (it is relative to the current drive letter),
// so we need add a drive letter to test absolute path cases.
func drive() string {
if runtime.GOOS == "windows" {
return "c:"
}
return ""
}
var absFileTests = []struct {
dir string
file string
rewrites string
abs string
}{
{"/d", "f", "", "/d/f"},
{"/d", drive() + "/f", "", drive() + "/f"},
{"/d", "f/g", "", "/d/f/g"},
{"/d", drive() + "/f/g", "", drive() + "/f/g"},
{"/d", "f", "/d/f", "??"},
{"/d", "f/g", "/d/f", "g"},
{"/d", "f/g", "/d/f=>h", "h/g"},
{"/d", "f/g", "/d/f=>/h", "/h/g"},
{"/d", "f/g", "/d/f=>/h;/d/e=>/i", "/h/g"},
{"/d", "e/f", "/d/f=>/h;/d/e=>/i", "/i/f"},
}
func TestAbsFile(t *testing.T) {
for _, tt := range absFileTests {
abs := filepath.FromSlash(AbsFile(filepath.FromSlash(tt.dir), filepath.FromSlash(tt.file), tt.rewrites))
want := filepath.FromSlash(tt.abs)
if abs != want {
t.Errorf("AbsFile(%q, %q, %q) = %q, want %q", tt.dir, tt.file, tt.rewrites, abs, want)
}
}
}
|
go/src/cmd/internal/objabi/line_test.go/0
|
{
"file_path": "go/src/cmd/internal/objabi/line_test.go",
"repo_id": "go",
"token_count": 572
}
| 159 |
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Parsing of Plan 9 a.out executables.
package objfile
import (
"debug/dwarf"
"debug/plan9obj"
"errors"
"fmt"
"io"
"sort"
)
var validSymType = map[rune]bool{
'T': true,
't': true,
'D': true,
'd': true,
'B': true,
'b': true,
}
type plan9File struct {
plan9 *plan9obj.File
}
func openPlan9(r io.ReaderAt) (rawFile, error) {
f, err := plan9obj.NewFile(r)
if err != nil {
return nil, err
}
return &plan9File{f}, nil
}
func (f *plan9File) symbols() ([]Sym, error) {
plan9Syms, err := f.plan9.Symbols()
if err != nil {
return nil, err
}
// Build sorted list of addresses of all symbols.
// We infer the size of a symbol by looking at where the next symbol begins.
var addrs []uint64
for _, s := range plan9Syms {
if !validSymType[s.Type] {
continue
}
addrs = append(addrs, s.Value)
}
sort.Sort(uint64s(addrs))
var syms []Sym
for _, s := range plan9Syms {
if !validSymType[s.Type] {
continue
}
sym := Sym{Addr: s.Value, Name: s.Name, Code: s.Type}
i := sort.Search(len(addrs), func(x int) bool { return addrs[x] > s.Value })
if i < len(addrs) {
sym.Size = int64(addrs[i] - s.Value)
}
syms = append(syms, sym)
}
return syms, nil
}
func (f *plan9File) pcln() (textStart uint64, symtab, pclntab []byte, err error) {
textStart = f.plan9.LoadAddress + f.plan9.HdrSize
if pclntab, err = loadPlan9Table(f.plan9, "runtime.pclntab", "runtime.epclntab"); err != nil {
// We didn't find the symbols, so look for the names used in 1.3 and earlier.
// TODO: Remove code looking for the old symbols when we no longer care about 1.3.
var err2 error
if pclntab, err2 = loadPlan9Table(f.plan9, "pclntab", "epclntab"); err2 != nil {
return 0, nil, nil, err
}
}
if symtab, err = loadPlan9Table(f.plan9, "runtime.symtab", "runtime.esymtab"); err != nil {
// Same as above.
var err2 error
if symtab, err2 = loadPlan9Table(f.plan9, "symtab", "esymtab"); err2 != nil {
return 0, nil, nil, err
}
}
return textStart, symtab, pclntab, nil
}
func (f *plan9File) text() (textStart uint64, text []byte, err error) {
sect := f.plan9.Section("text")
if sect == nil {
return 0, nil, fmt.Errorf("text section not found")
}
textStart = f.plan9.LoadAddress + f.plan9.HdrSize
text, err = sect.Data()
return
}
func findPlan9Symbol(f *plan9obj.File, name string) (*plan9obj.Sym, error) {
syms, err := f.Symbols()
if err != nil {
return nil, err
}
for _, s := range syms {
if s.Name != name {
continue
}
return &s, nil
}
return nil, fmt.Errorf("no %s symbol found", name)
}
func loadPlan9Table(f *plan9obj.File, sname, ename string) ([]byte, error) {
ssym, err := findPlan9Symbol(f, sname)
if err != nil {
return nil, err
}
esym, err := findPlan9Symbol(f, ename)
if err != nil {
return nil, err
}
sect := f.Section("text")
if sect == nil {
return nil, err
}
data, err := sect.Data()
if err != nil {
return nil, err
}
textStart := f.LoadAddress + f.HdrSize
return data[ssym.Value-textStart : esym.Value-textStart], nil
}
func (f *plan9File) goarch() string {
switch f.plan9.Magic {
case plan9obj.Magic386:
return "386"
case plan9obj.MagicAMD64:
return "amd64"
case plan9obj.MagicARM:
return "arm"
}
return ""
}
func (f *plan9File) loadAddress() (uint64, error) {
return 0, fmt.Errorf("unknown load address")
}
func (f *plan9File) dwarf() (*dwarf.Data, error) {
return nil, errors.New("no DWARF data in Plan 9 file")
}
|
go/src/cmd/internal/objfile/plan9obj.go/0
|
{
"file_path": "go/src/cmd/internal/objfile/plan9obj.go",
"repo_id": "go",
"token_count": 1479
}
| 160 |
go test fuzz v1
[]byte("\x010\x01\r000000000")
|
go/src/cmd/internal/pgo/testdata/fuzz/FuzzRoundTrip/fdc60117b431bbae/0
|
{
"file_path": "go/src/cmd/internal/pgo/testdata/fuzz/FuzzRoundTrip/fdc60117b431bbae",
"repo_id": "go",
"token_count": 21
}
| 161 |
// Copyright 2024 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build cmd_go_bootstrap || compiler_bootstrap
package telemetry
func MaybeParent() {}
func MaybeChild() {}
func Mode() string { return "" }
func SetMode(mode string) error { return nil }
func Dir() string { return "" }
|
go/src/cmd/internal/telemetry/telemetry_bootstrap.go/0
|
{
"file_path": "go/src/cmd/internal/telemetry/telemetry_bootstrap.go",
"repo_id": "go",
"token_count": 160
}
| 162 |
=== RUN TestIndex
--- PASS: TestIndex (0.00s)
=== PASS TestIndex
=== NAME
=== RUN TestLastIndex
--- PASS: TestLastIndex (0.00s)
=== PASS TestLastIndex
=== NAME
=== RUN TestIndexAny
--- PASS: TestIndexAny (0.00s)
=== PASS TestIndexAny
=== NAME
=== RUN TestLastIndexAny
--- PASS: TestLastIndexAny (0.00s)
=== PASS TestLastIndexAny
=== NAME
=== RUN TestIndexByte
--- PASS: TestIndexByte (0.00s)
=== PASS TestIndexByte
=== NAME
=== RUN TestLastIndexByte
--- PASS: TestLastIndexByte (0.00s)
=== PASS TestLastIndexByte
=== NAME
=== RUN TestIndexRandom
--- PASS: TestIndexRandom (0.00s)
=== PASS TestIndexRandom
=== NAME
=== RUN TestIndexRune
--- PASS: TestIndexRune (0.00s)
=== PASS TestIndexRune
=== NAME
=== RUN TestIndexFunc
--- PASS: TestIndexFunc (0.00s)
=== PASS TestIndexFunc
=== NAME
=== RUN ExampleIndex
--- PASS: ExampleIndex (0.00s)
=== NAME
=== RUN ExampleIndexFunc
--- PASS: ExampleIndexFunc (0.00s)
=== NAME
=== RUN ExampleIndexAny
--- PASS: ExampleIndexAny (0.00s)
=== NAME
=== RUN ExampleIndexByte
--- PASS: ExampleIndexByte (0.00s)
=== NAME
=== RUN ExampleIndexRune
--- PASS: ExampleIndexRune (0.00s)
=== NAME
=== RUN ExampleLastIndex
--- PASS: ExampleLastIndex (0.00s)
=== NAME
=== RUN ExampleLastIndexAny
--- PASS: ExampleLastIndexAny (0.00s)
=== NAME
=== RUN ExampleLastIndexByte
--- PASS: ExampleLastIndexByte (0.00s)
=== NAME
=== RUN ExampleLastIndexFunc
--- PASS: ExampleLastIndexFunc (0.00s)
=== NAME
goos: darwin
goarch: amd64
pkg: strings
cpu: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
=== RUN BenchmarkIndexRune
BenchmarkIndexRune
BenchmarkIndexRune-16 87335496 14.27 ns/op
=== NAME
=== RUN BenchmarkIndexRuneLongString
BenchmarkIndexRuneLongString
BenchmarkIndexRuneLongString-16 57104472 18.66 ns/op
=== NAME
=== RUN BenchmarkIndexRuneFastPath
BenchmarkIndexRuneFastPath
BenchmarkIndexRuneFastPath-16 262380160 4.499 ns/op
=== NAME
=== RUN BenchmarkIndex
BenchmarkIndex
BenchmarkIndex-16 248529364 4.697 ns/op
=== NAME
=== RUN BenchmarkLastIndex
BenchmarkLastIndex
BenchmarkLastIndex-16 293688756 4.166 ns/op
=== NAME
=== RUN BenchmarkIndexByte
BenchmarkIndexByte
BenchmarkIndexByte-16 310338391 3.608 ns/op
=== NAME
=== RUN BenchmarkIndexHard1
BenchmarkIndexHard1
BenchmarkIndexHard1-16 12852 92380 ns/op
=== NAME
=== RUN BenchmarkIndexHard2
BenchmarkIndexHard2
BenchmarkIndexHard2-16 8977 135080 ns/op
=== NAME
=== RUN BenchmarkIndexHard3
BenchmarkIndexHard3
BenchmarkIndexHard3-16 1885 532079 ns/op
=== NAME
=== RUN BenchmarkIndexHard4
BenchmarkIndexHard4
BenchmarkIndexHard4-16 2298 533435 ns/op
=== NAME
=== RUN BenchmarkLastIndexHard1
BenchmarkLastIndexHard1
BenchmarkLastIndexHard1-16 813 1295767 ns/op
=== NAME
=== RUN BenchmarkLastIndexHard2
BenchmarkLastIndexHard2
BenchmarkLastIndexHard2-16 784 1389403 ns/op
=== NAME
=== RUN BenchmarkLastIndexHard3
BenchmarkLastIndexHard3
BenchmarkLastIndexHard3-16 913 1316608 ns/op
=== NAME
=== RUN BenchmarkIndexTorture
BenchmarkIndexTorture
BenchmarkIndexTorture-16 98090 10201 ns/op
=== NAME
=== RUN BenchmarkIndexAnyASCII
BenchmarkIndexAnyASCII
=== RUN BenchmarkIndexAnyASCII/1:1
BenchmarkIndexAnyASCII/1:1
BenchmarkIndexAnyASCII/1:1-16 214829462 5.592 ns/op
=== NAME
=== RUN BenchmarkIndexAnyASCII/1:2
BenchmarkIndexAnyASCII/1:2
BenchmarkIndexAnyASCII/1:2-16 155499682 7.214 ns/op
=== NAME
=== RUN BenchmarkIndexAnyASCII/1:4
BenchmarkIndexAnyASCII/1:4
BenchmarkIndexAnyASCII/1:4-16 172757770 7.092 ns/op
=== NAME
PASS
|
go/src/cmd/internal/test2json/testdata/framebig.test/0
|
{
"file_path": "go/src/cmd/internal/test2json/testdata/framebig.test",
"repo_id": "go",
"token_count": 1671
}
| 163 |
=== RUN TestUnicode
ΞΟΞΏΟΟ Ξ½Ξ± ΟΞ¬Ο ΟΟΞ±ΟΞΌΞΞ½Ξ± Ξ³Ο
αλιά ΟΟΟΞ―Ο Ξ½Ξ± ΟΞ¬ΞΈΟ ΟΞ―ΟΞΏΟΞ±. ΞΟΞΏΟΟ Ξ½Ξ± ΟΞ¬Ο ΟΟΞ±ΟΞΌΞΞ½Ξ± Ξ³Ο
αλιά ΟΟΟΞ―Ο Ξ½Ξ± ΟΞ¬ΞΈΟ ΟΞ―ΟΞΏΟΞ±.
η§γ―γ¬γ©γΉγι£γΉγγγΎγγγγγ―η§γε·γ€γγΎγγγη§γ―γ¬γ©γΉγι£γΉγγγΎγγγγγ―η§γε·γ€γγΎγγγ
--- PASS: TestUnicode
ΰΈΰΈ±ΰΈΰΈΰΈ΄ΰΈΰΈΰΈ£ΰΈ°ΰΈΰΈΰΉΰΈΰΉ ΰΉΰΈΰΉΰΈ‘ΰΈ±ΰΈΰΉΰΈ‘ΰΉΰΈΰΈ³ΰΉΰΈ«ΰΉΰΈΰΈ±ΰΈΰΉΰΈΰΉΰΈ ΰΈΰΈ±ΰΈΰΈΰΈ΄ΰΈΰΈΰΈ£ΰΈ°ΰΈΰΈΰΉΰΈΰΉ ΰΉΰΈΰΉΰΈ‘ΰΈ±ΰΈΰΉΰΈ‘ΰΉΰΈΰΈ³ΰΉΰΈ«ΰΉΰΈΰΈ±ΰΈΰΉΰΈΰΉΰΈ
ΧΧ Χ ΧΧΧΧ ΧΧΧΧΧ ΧΧΧΧΧΧͺ ΧΧΧ ΧΧ ΧΧΧΧ§ ΧΧ. ΧΧ Χ ΧΧΧΧ ΧΧΧΧΧ ΧΧΧΧΧΧͺ ΧΧΧ ΧΧ ΧΧΧΧ§ ΧΧ.
PASS
|
go/src/cmd/internal/test2json/testdata/unicode.test/0
|
{
"file_path": "go/src/cmd/internal/test2json/testdata/unicode.test",
"repo_id": "go",
"token_count": 453
}
| 164 |
// Copyright 2020 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package ld
import (
"cmd/internal/obj"
"cmd/link/internal/loader"
"cmd/link/internal/sym"
"sync"
)
type unresolvedSymKey struct {
from loader.Sym // Symbol that referenced unresolved "to"
to loader.Sym // Unresolved symbol referenced by "from"
}
type symNameFn func(s loader.Sym) string
// ErrorReporter is used to make error reporting thread safe.
type ErrorReporter struct {
loader.ErrorReporter
unresSyms map[unresolvedSymKey]bool
unresMutex sync.Mutex
SymName symNameFn
}
// errorUnresolved prints unresolved symbol error for rs that is referenced from s.
func (reporter *ErrorReporter) errorUnresolved(ldr *loader.Loader, s, rs loader.Sym) {
reporter.unresMutex.Lock()
defer reporter.unresMutex.Unlock()
if reporter.unresSyms == nil {
reporter.unresSyms = make(map[unresolvedSymKey]bool)
}
k := unresolvedSymKey{from: s, to: rs}
if !reporter.unresSyms[k] {
reporter.unresSyms[k] = true
name := ldr.SymName(rs)
// Try to find symbol under another ABI.
var reqABI, haveABI obj.ABI
haveABI = ^obj.ABI(0)
reqABI, ok := sym.VersionToABI(ldr.SymVersion(rs))
if ok {
for abi := obj.ABI(0); abi < obj.ABICount; abi++ {
v := sym.ABIToVersion(abi)
if v == -1 {
continue
}
if rs1 := ldr.Lookup(name, v); rs1 != 0 && ldr.SymType(rs1) != sym.Sxxx && ldr.SymType(rs1) != sym.SXREF {
haveABI = abi
}
}
}
// Give a special error message for main symbol (see #24809).
if name == "main.main" {
reporter.Errorf(s, "function main is undeclared in the main package")
} else if haveABI != ^obj.ABI(0) {
reporter.Errorf(s, "relocation target %s not defined for %s (but is defined for %s)", name, reqABI, haveABI)
} else {
reporter.Errorf(s, "relocation target %s not defined", name)
}
}
}
|
go/src/cmd/link/internal/ld/errors.go/0
|
{
"file_path": "go/src/cmd/link/internal/ld/errors.go",
"repo_id": "go",
"token_count": 759
}
| 165 |
// Copyright 2024 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package ld
// This file provides helper functions for updating/rewriting the UUID
// load command within a Go go binary generated on Darwin using
// external linking. Why is it necessary to update the UUID load
// command? See issue #64947 for more detail, but the short answer is
// that newer versions of the Macos toolchain (the newer linker in
// particular) appear to compute the UUID based not just on the
// content of the object files being linked but also on things like
// the timestamps/paths of the objects; this makes it
// difficult/impossible to support reproducible builds. Since we try
// hard to maintain build reproducibility for Go, the APIs here
// compute a new UUID (based on the Go build ID) and write it to the
// final executable generated by the external linker.
import (
"cmd/internal/notsha256"
"debug/macho"
"io"
"os"
"unsafe"
)
// uuidFromGoBuildId hashes the Go build ID and returns a slice of 16
// bytes suitable for use as the payload in a Macho LC_UUID load
// command.
func uuidFromGoBuildId(buildID string) []byte {
if buildID == "" {
return make([]byte, 16)
}
hashedBuildID := notsha256.Sum256([]byte(buildID))
rv := hashedBuildID[:16]
// RFC 4122 conformance (see RFC 4122 Sections 4.2.2, 4.1.3). We
// want the "version" of this UUID to appear as 'hashed' as opposed
// to random or time-based. This is something of a fiction since
// we're not actually hashing using MD5 or SHA1, but it seems better
// to use this UUID flavor than any of the others. This is similar
// to how other linkers handle this (for example this code in lld:
// https://github.com/llvm/llvm-project/blob/2a3a79ce4c2149d7787d56f9841b66cacc9061d0/lld/MachO/Writer.cpp#L524).
rv[6] &= 0xcf
rv[6] |= 0x30
rv[8] &= 0x3f
rv[8] |= 0xc0
return rv
}
// machoRewriteUuid copies over the contents of the Macho executable
// exef into the output file outexe, and in the process updates the
// LC_UUID command to a new value recomputed from the Go build id.
func machoRewriteUuid(ctxt *Link, exef *os.File, exem *macho.File, outexe string) error {
outf, err := os.OpenFile(outexe, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0755)
if err != nil {
return err
}
defer outf.Close()
// Copy over the file.
if _, err := io.Copy(outf, exef); err != nil {
return err
}
// Locate the portion of the binary containing the load commands.
cmdOffset := unsafe.Sizeof(exem.FileHeader)
if is64bit := exem.Magic == macho.Magic64; is64bit {
// mach_header_64 has one extra uint32.
cmdOffset += unsafe.Sizeof(exem.Magic)
}
if _, err := outf.Seek(int64(cmdOffset), 0); err != nil {
return err
}
// Read the load commands, looking for the LC_UUID cmd. If/when we
// locate it, overwrite it with a new value produced by
// uuidFromGoBuildId.
reader := loadCmdReader{next: int64(cmdOffset),
f: outf, order: exem.ByteOrder}
for i := uint32(0); i < exem.Ncmd; i++ {
cmd, err := reader.Next()
if err != nil {
return err
}
if cmd.Cmd == LC_UUID {
var u uuidCmd
if err := reader.ReadAt(0, &u); err != nil {
return err
}
copy(u.Uuid[:], uuidFromGoBuildId(*flagBuildid))
if err := reader.WriteAt(0, &u); err != nil {
return err
}
break
}
}
// We're done
return nil
}
|
go/src/cmd/link/internal/ld/macho_update_uuid.go/0
|
{
"file_path": "go/src/cmd/link/internal/ld/macho_update_uuid.go",
"repo_id": "go",
"token_count": 1198
}
| 166 |
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package ld
import (
"cmd/internal/sys"
"cmd/link/internal/loader"
"cmd/link/internal/sym"
)
var sehp struct {
pdata []sym.LoaderSym
xdata []sym.LoaderSym
}
func writeSEH(ctxt *Link) {
switch ctxt.Arch.Family {
case sys.AMD64:
writeSEHAMD64(ctxt)
}
}
func writeSEHAMD64(ctxt *Link) {
ldr := ctxt.loader
mkSecSym := func(name string, kind sym.SymKind) *loader.SymbolBuilder {
s := ldr.CreateSymForUpdate(name, 0)
s.SetType(kind)
s.SetAlign(4)
return s
}
pdata := mkSecSym(".pdata", sym.SSEHSECT)
xdata := mkSecSym(".xdata", sym.SSEHSECT)
// The .xdata entries have very low cardinality
// as it only contains frame pointer operations,
// which are very similar across functions.
// These are referenced by .pdata entries using
// an RVA, so it is possible, and binary-size wise,
// to deduplicate .xdata entries.
uwcache := make(map[string]int64) // aux symbol name --> .xdata offset
for _, s := range ctxt.Textp {
if fi := ldr.FuncInfo(s); !fi.Valid() {
continue
}
uw := ldr.SEHUnwindSym(s)
if uw == 0 {
continue
}
name := ctxt.SymName(uw)
off, cached := uwcache[name]
if !cached {
off = xdata.Size()
uwcache[name] = off
xdata.AddBytes(ldr.Data(uw))
// The SEH unwind data can contain relocations,
// make sure those are copied over.
rels := ldr.Relocs(uw)
for i := 0; i < rels.Count(); i++ {
r := rels.At(i)
rel, _ := xdata.AddRel(r.Type())
rel.SetOff(int32(off) + r.Off())
rel.SetSiz(r.Siz())
rel.SetSym(r.Sym())
rel.SetAdd(r.Add())
}
}
// Reference:
// https://learn.microsoft.com/en-us/cpp/build/exception-handling-x64#struct-runtime_function
pdata.AddPEImageRelativeAddrPlus(ctxt.Arch, s, 0)
pdata.AddPEImageRelativeAddrPlus(ctxt.Arch, s, ldr.SymSize(s))
pdata.AddPEImageRelativeAddrPlus(ctxt.Arch, xdata.Sym(), off)
}
sehp.pdata = append(sehp.pdata, pdata.Sym())
sehp.xdata = append(sehp.xdata, xdata.Sym())
}
|
go/src/cmd/link/internal/ld/seh.go/0
|
{
"file_path": "go/src/cmd/link/internal/ld/seh.go",
"repo_id": "go",
"token_count": 886
}
| 167 |
// A small test program that uses the net/http package. There is
// nothing special about net/http here, this is just a convenient way
// to pull in a lot of code.
package main
import (
"net/http"
"net/http/httptest"
)
type statusHandler int
func (h *statusHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(int(*h))
}
func main() {
status := statusHandler(http.StatusNotFound)
s := httptest.NewServer(&status)
defer s.Close()
}
|
go/src/cmd/link/internal/ld/testdata/httptest/main/main.go/0
|
{
"file_path": "go/src/cmd/link/internal/ld/testdata/httptest/main/main.go",
"repo_id": "go",
"token_count": 156
}
| 168 |
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
func main() { asmMain() }
func asmMain()
func startSelf()
func startChain()
func chain0()
func chain1()
func chain2()
func chainEnd()
func startRec()
func startRec0()
|
go/src/cmd/link/internal/ld/testdata/stackcheck/main.go/0
|
{
"file_path": "go/src/cmd/link/internal/ld/testdata/stackcheck/main.go",
"repo_id": "go",
"token_count": 106
}
| 169 |
// Inferno utils/5l/asm.c
// https://bitbucket.org/inferno-os/inferno-os/src/master/utils/5l/asm.c
//
// Copyright Β© 1994-1999 Lucent Technologies Inc. All rights reserved.
// Portions Copyright Β© 1995-1997 C H Forsyth (forsyth@terzarima.net)
// Portions Copyright Β© 1997-1999 Vita Nuova Limited
// Portions Copyright Β© 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com)
// Portions Copyright Β© 2004,2006 Bruce Ellis
// Portions Copyright Β© 2005-2007 C H Forsyth (forsyth@terzarima.net)
// Revisions Copyright Β© 2000-2007 Lucent Technologies Inc. and others
// Portions Copyright Β© 2016 The Go Authors. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package mips
import (
"cmd/internal/objabi"
"cmd/internal/sys"
"cmd/link/internal/ld"
"cmd/link/internal/loader"
"cmd/link/internal/sym"
"debug/elf"
)
func gentext(ctxt *ld.Link, ldr *loader.Loader) {
return
}
func elfreloc1(ctxt *ld.Link, out *ld.OutBuf, ldr *loader.Loader, s loader.Sym, r loader.ExtReloc, ri int, sectoff int64) bool {
out.Write32(uint32(sectoff))
elfsym := ld.ElfSymForReloc(ctxt, r.Xsym)
switch r.Type {
default:
return false
case objabi.R_ADDR, objabi.R_DWARFSECREF:
if r.Size != 4 {
return false
}
out.Write32(uint32(elf.R_MIPS_32) | uint32(elfsym)<<8)
case objabi.R_ADDRMIPS:
out.Write32(uint32(elf.R_MIPS_LO16) | uint32(elfsym)<<8)
case objabi.R_ADDRMIPSU:
out.Write32(uint32(elf.R_MIPS_HI16) | uint32(elfsym)<<8)
case objabi.R_ADDRMIPSTLS:
out.Write32(uint32(elf.R_MIPS_TLS_TPREL_LO16) | uint32(elfsym)<<8)
case objabi.R_CALLMIPS, objabi.R_JMPMIPS:
out.Write32(uint32(elf.R_MIPS_26) | uint32(elfsym)<<8)
}
return true
}
func elfsetupplt(ctxt *ld.Link, ldr *loader.Loader, plt, gotplt *loader.SymbolBuilder, dynamic loader.Sym) {
return
}
func machoreloc1(*sys.Arch, *ld.OutBuf, *loader.Loader, loader.Sym, loader.ExtReloc, int64) bool {
return false
}
func applyrel(arch *sys.Arch, ldr *loader.Loader, rt objabi.RelocType, off int32, s loader.Sym, val int64, t int64) int64 {
o := uint32(val)
switch rt {
case objabi.R_ADDRMIPS, objabi.R_ADDRMIPSTLS:
return int64(o&0xffff0000 | uint32(t)&0xffff)
case objabi.R_ADDRMIPSU:
return int64(o&0xffff0000 | uint32((t+(1<<15))>>16)&0xffff)
case objabi.R_CALLMIPS, objabi.R_JMPMIPS:
return int64(o&0xfc000000 | uint32(t>>2)&^0xfc000000)
default:
return val
}
}
func archreloc(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, r loader.Reloc, s loader.Sym, val int64) (o int64, nExtReloc int, ok bool) {
rs := r.Sym()
if target.IsExternal() {
switch r.Type() {
default:
return val, 0, false
case objabi.R_ADDRMIPS, objabi.R_ADDRMIPSU:
// set up addend for eventual relocation via outer symbol.
_, off := ld.FoldSubSymbolOffset(ldr, rs)
xadd := r.Add() + off
return applyrel(target.Arch, ldr, r.Type(), r.Off(), s, val, xadd), 1, true
case objabi.R_ADDRMIPSTLS, objabi.R_CALLMIPS, objabi.R_JMPMIPS:
return applyrel(target.Arch, ldr, r.Type(), r.Off(), s, val, r.Add()), 1, true
}
}
const isOk = true
const noExtReloc = 0
switch rt := r.Type(); rt {
case objabi.R_ADDRMIPS, objabi.R_ADDRMIPSU:
t := ldr.SymValue(rs) + r.Add()
return applyrel(target.Arch, ldr, rt, r.Off(), s, val, t), noExtReloc, isOk
case objabi.R_CALLMIPS, objabi.R_JMPMIPS:
t := ldr.SymValue(rs) + r.Add()
if t&3 != 0 {
ldr.Errorf(s, "direct call is not aligned: %s %x", ldr.SymName(rs), t)
}
// check if target address is in the same 256 MB region as the next instruction
if (ldr.SymValue(s)+int64(r.Off())+4)&0xf0000000 != (t & 0xf0000000) {
ldr.Errorf(s, "direct call too far: %s %x", ldr.SymName(rs), t)
}
return applyrel(target.Arch, ldr, rt, r.Off(), s, val, t), noExtReloc, isOk
case objabi.R_ADDRMIPSTLS:
// thread pointer is at 0x7000 offset from the start of TLS data area
t := ldr.SymValue(rs) + r.Add() - 0x7000
if t < -32768 || t >= 32678 {
ldr.Errorf(s, "TLS offset out of range %d", t)
}
return applyrel(target.Arch, ldr, rt, r.Off(), s, val, t), noExtReloc, isOk
}
return val, 0, false
}
func archrelocvariant(*ld.Target, *loader.Loader, loader.Reloc, sym.RelocVariant, loader.Sym, int64, []byte) int64 {
return -1
}
func extreloc(target *ld.Target, ldr *loader.Loader, r loader.Reloc, s loader.Sym) (loader.ExtReloc, bool) {
switch r.Type() {
case objabi.R_ADDRMIPS, objabi.R_ADDRMIPSU:
return ld.ExtrelocViaOuterSym(ldr, r, s), true
case objabi.R_ADDRMIPSTLS, objabi.R_CALLMIPS, objabi.R_JMPMIPS:
return ld.ExtrelocSimple(ldr, r), true
}
return loader.ExtReloc{}, false
}
|
go/src/cmd/link/internal/mips/asm.go/0
|
{
"file_path": "go/src/cmd/link/internal/mips/asm.go",
"repo_id": "go",
"token_count": 2225
}
| 170 |
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package sym
import "cmd/internal/goobj"
type Library struct {
Objref string
Srcref string
File string
Pkg string
Shlib string
Fingerprint goobj.FingerprintType
Autolib []goobj.ImportedPkg
Imports []*Library
Main bool
Units []*CompilationUnit
Textp []LoaderSym // text syms defined in this library
DupTextSyms []LoaderSym // dupok text syms defined in this library
}
func (l Library) String() string {
return l.Pkg
}
|
go/src/cmd/link/internal/sym/library.go/0
|
{
"file_path": "go/src/cmd/link/internal/sym/library.go",
"repo_id": "go",
"token_count": 246
}
| 171 |
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"cmd/internal/notsha256"
"flag"
"fmt"
"internal/platform"
"internal/testenv"
"os"
"path/filepath"
"runtime"
"strings"
"sync"
"testing"
)
// TestMain executes the test binary as the objdump command if
// GO_OBJDUMPTEST_IS_OBJDUMP is set, and runs the test otherwise.
func TestMain(m *testing.M) {
if os.Getenv("GO_OBJDUMPTEST_IS_OBJDUMP") != "" {
main()
os.Exit(0)
}
os.Setenv("GO_OBJDUMPTEST_IS_OBJDUMP", "1")
os.Exit(m.Run())
}
// objdumpPath returns the path to the "objdump" binary to run.
func objdumpPath(t testing.TB) string {
t.Helper()
testenv.MustHaveExec(t)
objdumpPathOnce.Do(func() {
objdumpExePath, objdumpPathErr = os.Executable()
})
if objdumpPathErr != nil {
t.Fatal(objdumpPathErr)
}
return objdumpExePath
}
var (
objdumpPathOnce sync.Once
objdumpExePath string
objdumpPathErr error
)
var x86Need = []string{ // for both 386 and AMD64
"JMP main.main(SB)",
"CALL main.Println(SB)",
"RET",
}
var amd64GnuNeed = []string{
"jmp",
"callq",
"cmpb",
}
var i386GnuNeed = []string{
"jmp",
"call",
"cmp",
}
var armNeed = []string{
"B main.main(SB)",
"BL main.Println(SB)",
"RET",
}
var arm64Need = []string{
"JMP main.main(SB)",
"CALL main.Println(SB)",
"RET",
}
var armGnuNeed = []string{ // for both ARM and AMR64
"ldr",
"bl",
"cmp",
}
var ppcNeed = []string{
"BR main.main(SB)",
"CALL main.Println(SB)",
"RET",
}
var ppcPIENeed = []string{
"BR",
"CALL",
"RET",
}
var ppcGnuNeed = []string{
"mflr",
"lbz",
"beq",
}
func mustHaveDisasm(t *testing.T) {
switch runtime.GOARCH {
case "loong64":
t.Skipf("skipping on %s", runtime.GOARCH)
case "mips", "mipsle", "mips64", "mips64le":
t.Skipf("skipping on %s, issue 12559", runtime.GOARCH)
case "riscv64":
t.Skipf("skipping on %s, issue 36738", runtime.GOARCH)
case "s390x":
t.Skipf("skipping on %s, issue 15255", runtime.GOARCH)
}
}
var target = flag.String("target", "", "test disassembly of `goos/goarch` binary")
// objdump is fully cross platform: it can handle binaries
// from any known operating system and architecture.
// We could in principle add binaries to testdata and check
// all the supported systems during this test. However, the
// binaries would be about 1 MB each, and we don't want to
// add that much junk to the hg repository. Instead, build a
// binary for the current system (only) and test that objdump
// can handle that one.
func testDisasm(t *testing.T, srcfname string, printCode bool, printGnuAsm bool, flags ...string) {
mustHaveDisasm(t)
goarch := runtime.GOARCH
if *target != "" {
f := strings.Split(*target, "/")
if len(f) != 2 {
t.Fatalf("-target argument must be goos/goarch")
}
defer os.Setenv("GOOS", os.Getenv("GOOS"))
defer os.Setenv("GOARCH", os.Getenv("GOARCH"))
os.Setenv("GOOS", f[0])
os.Setenv("GOARCH", f[1])
goarch = f[1]
}
hash := notsha256.Sum256([]byte(fmt.Sprintf("%v-%v-%v-%v", srcfname, flags, printCode, printGnuAsm)))
tmp := t.TempDir()
hello := filepath.Join(tmp, fmt.Sprintf("hello-%x.exe", hash))
args := []string{"build", "-o", hello}
args = append(args, flags...)
args = append(args, srcfname)
cmd := testenv.Command(t, testenv.GoToolPath(t), args...)
// "Bad line" bug #36683 is sensitive to being run in the source directory.
cmd.Dir = "testdata"
t.Logf("Running %v", cmd.Args)
out, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("go build %s: %v\n%s", srcfname, err, out)
}
need := []string{
"TEXT main.main(SB)",
}
if printCode {
need = append(need, ` Println("hello, world")`)
} else {
need = append(need, srcfname+":6")
}
switch goarch {
case "amd64", "386":
need = append(need, x86Need...)
case "arm":
need = append(need, armNeed...)
case "arm64":
need = append(need, arm64Need...)
case "ppc64", "ppc64le":
var pie bool
for _, flag := range flags {
if flag == "-buildmode=pie" {
pie = true
break
}
}
if pie {
// In PPC64 PIE binaries we use a "local entry point" which is
// function symbol address + 8. Currently we don't symbolize that.
// Expect a different output.
need = append(need, ppcPIENeed...)
} else {
need = append(need, ppcNeed...)
}
}
if printGnuAsm {
switch goarch {
case "amd64":
need = append(need, amd64GnuNeed...)
case "386":
need = append(need, i386GnuNeed...)
case "arm", "arm64":
need = append(need, armGnuNeed...)
case "ppc64", "ppc64le":
need = append(need, ppcGnuNeed...)
}
}
args = []string{
"-s", "main.main",
hello,
}
if printCode {
args = append([]string{"-S"}, args...)
}
if printGnuAsm {
args = append([]string{"-gnu"}, args...)
}
cmd = testenv.Command(t, objdumpPath(t), args...)
cmd.Dir = "testdata" // "Bad line" bug #36683 is sensitive to being run in the source directory
out, err = cmd.CombinedOutput()
t.Logf("Running %v", cmd.Args)
if err != nil {
exename := srcfname[:len(srcfname)-len(filepath.Ext(srcfname))] + ".exe"
t.Fatalf("objdump %q: %v\n%s", exename, err, out)
}
text := string(out)
ok := true
for _, s := range need {
if !strings.Contains(text, s) {
t.Errorf("disassembly missing '%s'", s)
ok = false
}
}
if goarch == "386" {
if strings.Contains(text, "(IP)") {
t.Errorf("disassembly contains PC-Relative addressing on 386")
ok = false
}
}
if !ok || testing.Verbose() {
t.Logf("full disassembly:\n%s", text)
}
}
func testGoAndCgoDisasm(t *testing.T, printCode bool, printGnuAsm bool) {
t.Parallel()
testDisasm(t, "fmthello.go", printCode, printGnuAsm)
if testenv.HasCGO() {
testDisasm(t, "fmthellocgo.go", printCode, printGnuAsm)
}
}
func TestDisasm(t *testing.T) {
testGoAndCgoDisasm(t, false, false)
}
func TestDisasmCode(t *testing.T) {
testGoAndCgoDisasm(t, true, false)
}
func TestDisasmGnuAsm(t *testing.T) {
testGoAndCgoDisasm(t, false, true)
}
func TestDisasmExtld(t *testing.T) {
testenv.MustHaveCGO(t)
switch runtime.GOOS {
case "plan9":
t.Skipf("skipping on %s", runtime.GOOS)
}
t.Parallel()
testDisasm(t, "fmthello.go", false, false, "-ldflags=-linkmode=external")
}
func TestDisasmPIE(t *testing.T) {
if !platform.BuildModeSupported("gc", "pie", runtime.GOOS, runtime.GOARCH) {
t.Skipf("skipping on %s/%s, PIE buildmode not supported", runtime.GOOS, runtime.GOARCH)
}
if !platform.InternalLinkPIESupported(runtime.GOOS, runtime.GOARCH) {
// require cgo on platforms that PIE needs external linking
testenv.MustHaveCGO(t)
}
t.Parallel()
testDisasm(t, "fmthello.go", false, false, "-buildmode=pie")
}
func TestDisasmGoobj(t *testing.T) {
mustHaveDisasm(t)
testenv.MustHaveGoBuild(t)
tmp := t.TempDir()
importcfgfile := filepath.Join(tmp, "hello.importcfg")
testenv.WriteImportcfg(t, importcfgfile, nil, "testdata/fmthello.go")
hello := filepath.Join(tmp, "hello.o")
args := []string{"tool", "compile", "-p=main", "-importcfg=" + importcfgfile, "-o", hello}
args = append(args, "testdata/fmthello.go")
out, err := testenv.Command(t, testenv.GoToolPath(t), args...).CombinedOutput()
if err != nil {
t.Fatalf("go tool compile fmthello.go: %v\n%s", err, out)
}
need := []string{
"main(SB)",
"fmthello.go:6",
}
args = []string{
"-s", "main",
hello,
}
out, err = testenv.Command(t, objdumpPath(t), args...).CombinedOutput()
if err != nil {
t.Fatalf("objdump fmthello.o: %v\n%s", err, out)
}
text := string(out)
ok := true
for _, s := range need {
if !strings.Contains(text, s) {
t.Errorf("disassembly missing '%s'", s)
ok = false
}
}
if runtime.GOARCH == "386" {
if strings.Contains(text, "(IP)") {
t.Errorf("disassembly contains PC-Relative addressing on 386")
ok = false
}
}
if !ok {
t.Logf("full disassembly:\n%s", text)
}
}
func TestGoobjFileNumber(t *testing.T) {
// Test that file table in Go object file is parsed correctly.
testenv.MustHaveGoBuild(t)
mustHaveDisasm(t)
t.Parallel()
tmp := t.TempDir()
obj := filepath.Join(tmp, "p.a")
cmd := testenv.Command(t, testenv.GoToolPath(t), "build", "-o", obj)
cmd.Dir = filepath.Join("testdata/testfilenum")
out, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("build failed: %v\n%s", err, out)
}
cmd = testenv.Command(t, objdumpPath(t), obj)
out, err = cmd.CombinedOutput()
if err != nil {
t.Fatalf("objdump failed: %v\n%s", err, out)
}
text := string(out)
for _, s := range []string{"a.go", "b.go", "c.go"} {
if !strings.Contains(text, s) {
t.Errorf("output missing '%s'", s)
}
}
if t.Failed() {
t.Logf("output:\n%s", text)
}
}
func TestGoObjOtherVersion(t *testing.T) {
testenv.MustHaveExec(t)
t.Parallel()
obj := filepath.Join("testdata", "go116.o")
cmd := testenv.Command(t, objdumpPath(t), obj)
out, err := cmd.CombinedOutput()
if err == nil {
t.Fatalf("objdump go116.o succeeded unexpectedly")
}
if !strings.Contains(string(out), "go object of a different version") {
t.Errorf("unexpected error message:\n%s", out)
}
}
|
go/src/cmd/objdump/objdump_test.go/0
|
{
"file_path": "go/src/cmd/objdump/objdump_test.go",
"repo_id": "go",
"token_count": 3752
}
| 172 |
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"flag"
"fmt"
"os"
"runtime/pprof"
"time"
)
var output = flag.String("output", "", "pprof profile output file")
func main() {
flag.Parse()
if *output == "" {
fmt.Fprintf(os.Stderr, "usage: %s -output file.pprof\n", os.Args[0])
os.Exit(2)
}
f, err := os.Create(*output)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(2)
}
defer f.Close()
if err := pprof.StartCPUProfile(f); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(2)
}
defer pprof.StopCPUProfile()
// Spin for long enough to collect some samples.
start := time.Now()
for time.Since(start) < time.Second {
}
}
|
go/src/cmd/pprof/testdata/cpu.go/0
|
{
"file_path": "go/src/cmd/pprof/testdata/cpu.go",
"repo_id": "go",
"token_count": 323
}
| 173 |
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"fmt"
"internal/trace"
"internal/trace/traceviewer"
"internal/trace/traceviewer/format"
)
var _ generator = &procGenerator{}
type procGenerator struct {
globalRangeGenerator
globalMetricGenerator
procRangeGenerator
stackSampleGenerator[trace.ProcID]
logEventGenerator[trace.ProcID]
gStates map[trace.GoID]*gState[trace.ProcID]
inSyscall map[trace.ProcID]*gState[trace.ProcID]
maxProc trace.ProcID
}
func newProcGenerator() *procGenerator {
pg := new(procGenerator)
rg := func(ev *trace.Event) trace.ProcID {
return ev.Proc()
}
pg.stackSampleGenerator.getResource = rg
pg.logEventGenerator.getResource = rg
pg.gStates = make(map[trace.GoID]*gState[trace.ProcID])
pg.inSyscall = make(map[trace.ProcID]*gState[trace.ProcID])
return pg
}
func (g *procGenerator) Sync() {
g.globalRangeGenerator.Sync()
g.procRangeGenerator.Sync()
}
func (g *procGenerator) GoroutineLabel(ctx *traceContext, ev *trace.Event) {
l := ev.Label()
g.gStates[l.Resource.Goroutine()].setLabel(l.Label)
}
func (g *procGenerator) GoroutineRange(ctx *traceContext, ev *trace.Event) {
r := ev.Range()
switch ev.Kind() {
case trace.EventRangeBegin:
g.gStates[r.Scope.Goroutine()].rangeBegin(ev.Time(), r.Name, ev.Stack())
case trace.EventRangeActive:
g.gStates[r.Scope.Goroutine()].rangeActive(r.Name)
case trace.EventRangeEnd:
gs := g.gStates[r.Scope.Goroutine()]
gs.rangeEnd(ev.Time(), r.Name, ev.Stack(), ctx)
}
}
func (g *procGenerator) GoroutineTransition(ctx *traceContext, ev *trace.Event) {
st := ev.StateTransition()
goID := st.Resource.Goroutine()
// If we haven't seen this goroutine before, create a new
// gState for it.
gs, ok := g.gStates[goID]
if !ok {
gs = newGState[trace.ProcID](goID)
g.gStates[goID] = gs
}
// If we haven't already named this goroutine, try to name it.
gs.augmentName(st.Stack)
// Handle the goroutine state transition.
from, to := st.Goroutine()
if from == to {
// Filter out no-op events.
return
}
if from == trace.GoRunning && !to.Executing() {
if to == trace.GoWaiting {
// Goroutine started blocking.
gs.block(ev.Time(), ev.Stack(), st.Reason, ctx)
} else {
gs.stop(ev.Time(), ev.Stack(), ctx)
}
}
if !from.Executing() && to == trace.GoRunning {
start := ev.Time()
if from == trace.GoUndetermined {
// Back-date the event to the start of the trace.
start = ctx.startTime
}
gs.start(start, ev.Proc(), ctx)
}
if from == trace.GoWaiting {
// Goroutine was unblocked.
gs.unblock(ev.Time(), ev.Stack(), ev.Proc(), ctx)
}
if from == trace.GoNotExist && to == trace.GoRunnable {
// Goroutine was created.
gs.created(ev.Time(), ev.Proc(), ev.Stack())
}
if from == trace.GoSyscall && to != trace.GoRunning {
// Goroutine exited a blocked syscall.
gs.blockedSyscallEnd(ev.Time(), ev.Stack(), ctx)
}
// Handle syscalls.
if to == trace.GoSyscall && ev.Proc() != trace.NoProc {
start := ev.Time()
if from == trace.GoUndetermined {
// Back-date the event to the start of the trace.
start = ctx.startTime
}
// Write down that we've entered a syscall. Note: we might have no P here
// if we're in a cgo callback or this is a transition from GoUndetermined
// (i.e. the G has been blocked in a syscall).
gs.syscallBegin(start, ev.Proc(), ev.Stack())
g.inSyscall[ev.Proc()] = gs
}
// Check if we're exiting a non-blocking syscall.
_, didNotBlock := g.inSyscall[ev.Proc()]
if from == trace.GoSyscall && didNotBlock {
gs.syscallEnd(ev.Time(), false, ctx)
delete(g.inSyscall, ev.Proc())
}
// Note down the goroutine transition.
_, inMarkAssist := gs.activeRanges["GC mark assist"]
ctx.GoroutineTransition(ctx.elapsed(ev.Time()), viewerGState(from, inMarkAssist), viewerGState(to, inMarkAssist))
}
func (g *procGenerator) ProcTransition(ctx *traceContext, ev *trace.Event) {
st := ev.StateTransition()
proc := st.Resource.Proc()
g.maxProc = max(g.maxProc, proc)
viewerEv := traceviewer.InstantEvent{
Resource: uint64(proc),
Stack: ctx.Stack(viewerFrames(ev.Stack())),
}
from, to := st.Proc()
if from == to {
// Filter out no-op events.
return
}
if to.Executing() {
start := ev.Time()
if from == trace.ProcUndetermined {
start = ctx.startTime
}
viewerEv.Name = "proc start"
viewerEv.Arg = format.ThreadIDArg{ThreadID: uint64(ev.Thread())}
viewerEv.Ts = ctx.elapsed(start)
ctx.IncThreadStateCount(ctx.elapsed(start), traceviewer.ThreadStateRunning, 1)
}
if from.Executing() {
start := ev.Time()
viewerEv.Name = "proc stop"
viewerEv.Ts = ctx.elapsed(start)
ctx.IncThreadStateCount(ctx.elapsed(start), traceviewer.ThreadStateRunning, -1)
// Check if this proc was in a syscall before it stopped.
// This means the syscall blocked. We need to emit it to the
// viewer at this point because we only display the time the
// syscall occupied a P when the viewer is in per-P mode.
//
// TODO(mknyszek): We could do better in a per-M mode because
// all events have to happen on *some* thread, and in v2 traces
// we know what that thread is.
gs, ok := g.inSyscall[proc]
if ok {
// Emit syscall slice for blocked syscall.
gs.syscallEnd(start, true, ctx)
gs.stop(start, ev.Stack(), ctx)
delete(g.inSyscall, proc)
}
}
// TODO(mknyszek): Consider modeling procs differently and have them be
// transition to and from NotExist when GOMAXPROCS changes. We can emit
// events for this to clearly delineate GOMAXPROCS changes.
if viewerEv.Name != "" {
ctx.Instant(viewerEv)
}
}
func (g *procGenerator) Finish(ctx *traceContext) {
ctx.SetResourceType("PROCS")
// Finish off ranges first. It doesn't really matter for the global ranges,
// but the proc ranges need to either be a subset of a goroutine slice or
// their own slice entirely. If the former, it needs to end first.
g.procRangeGenerator.Finish(ctx)
g.globalRangeGenerator.Finish(ctx)
// Finish off all the goroutine slices.
for _, gs := range g.gStates {
gs.finish(ctx)
}
// Name all the procs to the emitter.
for i := uint64(0); i <= uint64(g.maxProc); i++ {
ctx.Resource(i, fmt.Sprintf("Proc %v", i))
}
}
|
go/src/cmd/trace/procgen.go/0
|
{
"file_path": "go/src/cmd/trace/procgen.go",
"repo_id": "go",
"token_count": 2398
}
| 174 |
// Copyright 2014 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Package binutils provides access to the GNU binutils.
package binutils
import (
"debug/elf"
"debug/macho"
"debug/pe"
"encoding/binary"
"errors"
"fmt"
"io"
"os"
"os/exec"
"path/filepath"
"regexp"
"runtime"
"strconv"
"strings"
"sync"
"github.com/google/pprof/internal/elfexec"
"github.com/google/pprof/internal/plugin"
)
// A Binutils implements plugin.ObjTool by invoking the GNU binutils.
type Binutils struct {
mu sync.Mutex
rep *binrep
}
var (
objdumpLLVMVerRE = regexp.MustCompile(`LLVM version (?:(\d*)\.(\d*)\.(\d*)|.*(trunk).*)`)
// Defined for testing
elfOpen = elf.Open
)
// binrep is an immutable representation for Binutils. It is atomically
// replaced on every mutation to provide thread-safe access.
type binrep struct {
// Commands to invoke.
llvmSymbolizer string
llvmSymbolizerFound bool
addr2line string
addr2lineFound bool
nm string
nmFound bool
objdump string
objdumpFound bool
isLLVMObjdump bool
// if fast, perform symbolization using nm (symbol names only),
// instead of file-line detail from the slower addr2line.
fast bool
}
// get returns the current representation for bu, initializing it if necessary.
func (bu *Binutils) get() *binrep {
bu.mu.Lock()
r := bu.rep
if r == nil {
r = &binrep{}
initTools(r, "")
bu.rep = r
}
bu.mu.Unlock()
return r
}
// update modifies the rep for bu via the supplied function.
func (bu *Binutils) update(fn func(r *binrep)) {
r := &binrep{}
bu.mu.Lock()
defer bu.mu.Unlock()
if bu.rep == nil {
initTools(r, "")
} else {
*r = *bu.rep
}
fn(r)
bu.rep = r
}
// String returns string representation of the binutils state for debug logging.
func (bu *Binutils) String() string {
r := bu.get()
var llvmSymbolizer, addr2line, nm, objdump string
if r.llvmSymbolizerFound {
llvmSymbolizer = r.llvmSymbolizer
}
if r.addr2lineFound {
addr2line = r.addr2line
}
if r.nmFound {
nm = r.nm
}
if r.objdumpFound {
objdump = r.objdump
}
return fmt.Sprintf("llvm-symbolizer=%q addr2line=%q nm=%q objdump=%q fast=%t",
llvmSymbolizer, addr2line, nm, objdump, r.fast)
}
// SetFastSymbolization sets a toggle that makes binutils use fast
// symbolization (using nm), which is much faster than addr2line but
// provides only symbol name information (no file/line).
func (bu *Binutils) SetFastSymbolization(fast bool) {
bu.update(func(r *binrep) { r.fast = fast })
}
// SetTools processes the contents of the tools option. It
// expects a set of entries separated by commas; each entry is a pair
// of the form t:path, where cmd will be used to look only for the
// tool named t. If t is not specified, the path is searched for all
// tools.
func (bu *Binutils) SetTools(config string) {
bu.update(func(r *binrep) { initTools(r, config) })
}
func initTools(b *binrep, config string) {
// paths collect paths per tool; Key "" contains the default.
paths := make(map[string][]string)
for _, t := range strings.Split(config, ",") {
name, path := "", t
if ct := strings.SplitN(t, ":", 2); len(ct) == 2 {
name, path = ct[0], ct[1]
}
paths[name] = append(paths[name], path)
}
defaultPath := paths[""]
b.llvmSymbolizer, b.llvmSymbolizerFound = chooseExe([]string{"llvm-symbolizer"}, []string{}, append(paths["llvm-symbolizer"], defaultPath...))
b.addr2line, b.addr2lineFound = chooseExe([]string{"addr2line"}, []string{"gaddr2line"}, append(paths["addr2line"], defaultPath...))
// The "-n" option is supported by LLVM since 2011. The output of llvm-nm
// and GNU nm with "-n" option is interchangeable for our purposes, so we do
// not need to differrentiate them.
b.nm, b.nmFound = chooseExe([]string{"llvm-nm", "nm"}, []string{"gnm"}, append(paths["nm"], defaultPath...))
b.objdump, b.objdumpFound, b.isLLVMObjdump = findObjdump(append(paths["objdump"], defaultPath...))
}
// findObjdump finds and returns path to preferred objdump binary.
// Order of preference is: llvm-objdump, objdump.
// On MacOS only, also looks for gobjdump with least preference.
// Accepts a list of paths and returns:
// a string with path to the preferred objdump binary if found,
// or an empty string if not found;
// a boolean if any acceptable objdump was found;
// a boolean indicating if it is an LLVM objdump.
func findObjdump(paths []string) (string, bool, bool) {
objdumpNames := []string{"llvm-objdump", "objdump"}
if runtime.GOOS == "darwin" {
objdumpNames = append(objdumpNames, "gobjdump")
}
for _, objdumpName := range objdumpNames {
if objdump, objdumpFound := findExe(objdumpName, paths); objdumpFound {
cmdOut, err := exec.Command(objdump, "--version").Output()
if err != nil {
continue
}
if isLLVMObjdump(string(cmdOut)) {
return objdump, true, true
}
if isBuObjdump(string(cmdOut)) {
return objdump, true, false
}
}
}
return "", false, false
}
// chooseExe finds and returns path to preferred binary. names is a list of
// names to search on both Linux and OSX. osxNames is a list of names specific
// to OSX. names always has a higher priority than osxNames. The order of
// the name within each list decides its priority (e.g. the first name has a
// higher priority than the second name in the list).
//
// It returns a string with path to the binary and a boolean indicating if any
// acceptable binary was found.
func chooseExe(names, osxNames []string, paths []string) (string, bool) {
if runtime.GOOS == "darwin" {
names = append(names, osxNames...)
}
for _, name := range names {
if binary, found := findExe(name, paths); found {
return binary, true
}
}
return "", false
}
// isLLVMObjdump accepts a string with path to an objdump binary,
// and returns a boolean indicating if the given binary is an LLVM
// objdump binary of an acceptable version.
func isLLVMObjdump(output string) bool {
fields := objdumpLLVMVerRE.FindStringSubmatch(output)
if len(fields) != 5 {
return false
}
if fields[4] == "trunk" {
return true
}
verMajor, err := strconv.Atoi(fields[1])
if err != nil {
return false
}
verPatch, err := strconv.Atoi(fields[3])
if err != nil {
return false
}
if runtime.GOOS == "linux" && verMajor >= 8 {
// Ensure LLVM objdump is at least version 8.0 on Linux.
// Some flags, like --demangle, and double dashes for options are
// not supported by previous versions.
return true
}
if runtime.GOOS == "darwin" {
// Ensure LLVM objdump is at least version 10.0.1 on MacOS.
return verMajor > 10 || (verMajor == 10 && verPatch >= 1)
}
return false
}
// isBuObjdump accepts a string with path to an objdump binary,
// and returns a boolean indicating if the given binary is a GNU
// binutils objdump binary. No version check is performed.
func isBuObjdump(output string) bool {
return strings.Contains(output, "GNU objdump")
}
// findExe looks for an executable command on a set of paths.
// If it cannot find it, returns cmd.
func findExe(cmd string, paths []string) (string, bool) {
for _, p := range paths {
cp := filepath.Join(p, cmd)
if c, err := exec.LookPath(cp); err == nil {
return c, true
}
}
return cmd, false
}
// Disasm returns the assembly instructions for the specified address range
// of a binary.
func (bu *Binutils) Disasm(file string, start, end uint64, intelSyntax bool) ([]plugin.Inst, error) {
b := bu.get()
if !b.objdumpFound {
return nil, errors.New("cannot disasm: no objdump tool available")
}
args := []string{"--disassemble", "--demangle", "--no-show-raw-insn",
"--line-numbers", fmt.Sprintf("--start-address=%#x", start),
fmt.Sprintf("--stop-address=%#x", end)}
if intelSyntax {
if b.isLLVMObjdump {
args = append(args, "--x86-asm-syntax=intel")
} else {
args = append(args, "-M", "intel")
}
}
args = append(args, file)
cmd := exec.Command(b.objdump, args...)
out, err := cmd.Output()
if err != nil {
return nil, fmt.Errorf("%v: %v", cmd.Args, err)
}
return disassemble(out)
}
// Open satisfies the plugin.ObjTool interface.
func (bu *Binutils) Open(name string, start, limit, offset uint64, relocationSymbol string) (plugin.ObjFile, error) {
b := bu.get()
// Make sure file is a supported executable.
// This uses magic numbers, mainly to provide better error messages but
// it should also help speed.
if _, err := os.Stat(name); err != nil {
// For testing, do not require file name to exist.
if strings.Contains(b.addr2line, "testdata/") {
return &fileAddr2Line{file: file{b: b, name: name}}, nil
}
return nil, err
}
// Read the first 4 bytes of the file.
f, err := os.Open(name)
if err != nil {
return nil, fmt.Errorf("error opening %s: %v", name, err)
}
defer f.Close()
var header [4]byte
if _, err = io.ReadFull(f, header[:]); err != nil {
return nil, fmt.Errorf("error reading magic number from %s: %v", name, err)
}
elfMagic := string(header[:])
// Match against supported file types.
if elfMagic == elf.ELFMAG {
f, err := b.openELF(name, start, limit, offset, relocationSymbol)
if err != nil {
return nil, fmt.Errorf("error reading ELF file %s: %v", name, err)
}
return f, nil
}
// Mach-O magic numbers can be big or little endian.
machoMagicLittle := binary.LittleEndian.Uint32(header[:])
machoMagicBig := binary.BigEndian.Uint32(header[:])
if machoMagicLittle == macho.Magic32 || machoMagicLittle == macho.Magic64 ||
machoMagicBig == macho.Magic32 || machoMagicBig == macho.Magic64 {
f, err := b.openMachO(name, start, limit, offset)
if err != nil {
return nil, fmt.Errorf("error reading Mach-O file %s: %v", name, err)
}
return f, nil
}
if machoMagicLittle == macho.MagicFat || machoMagicBig == macho.MagicFat {
f, err := b.openFatMachO(name, start, limit, offset)
if err != nil {
return nil, fmt.Errorf("error reading fat Mach-O file %s: %v", name, err)
}
return f, nil
}
peMagic := string(header[:2])
if peMagic == "MZ" {
f, err := b.openPE(name, start, limit, offset)
if err != nil {
return nil, fmt.Errorf("error reading PE file %s: %v", name, err)
}
return f, nil
}
return nil, fmt.Errorf("unrecognized binary format: %s", name)
}
func (b *binrep) openMachOCommon(name string, of *macho.File, start, limit, offset uint64) (plugin.ObjFile, error) {
// Subtract the load address of the __TEXT section. Usually 0 for shared
// libraries or 0x100000000 for executables. You can check this value by
// running `objdump -private-headers <file>`.
textSegment := of.Segment("__TEXT")
if textSegment == nil {
return nil, fmt.Errorf("could not identify base for %s: no __TEXT segment", name)
}
if textSegment.Addr > start {
return nil, fmt.Errorf("could not identify base for %s: __TEXT segment address (0x%x) > mapping start address (0x%x)",
name, textSegment.Addr, start)
}
base := start - textSegment.Addr
if b.fast || (!b.addr2lineFound && !b.llvmSymbolizerFound) {
return &fileNM{file: file{b: b, name: name, base: base}}, nil
}
return &fileAddr2Line{file: file{b: b, name: name, base: base}}, nil
}
func (b *binrep) openFatMachO(name string, start, limit, offset uint64) (plugin.ObjFile, error) {
of, err := macho.OpenFat(name)
if err != nil {
return nil, fmt.Errorf("error parsing %s: %v", name, err)
}
defer of.Close()
if len(of.Arches) == 0 {
return nil, fmt.Errorf("empty fat Mach-O file: %s", name)
}
var arch macho.Cpu
// Use the host architecture.
// TODO: This is not ideal because the host architecture may not be the one
// that was profiled. E.g. an amd64 host can profile a 386 program.
switch runtime.GOARCH {
case "386":
arch = macho.Cpu386
case "amd64", "amd64p32":
arch = macho.CpuAmd64
case "arm", "armbe", "arm64", "arm64be":
arch = macho.CpuArm
case "ppc":
arch = macho.CpuPpc
case "ppc64", "ppc64le":
arch = macho.CpuPpc64
default:
return nil, fmt.Errorf("unsupported host architecture for %s: %s", name, runtime.GOARCH)
}
for i := range of.Arches {
if of.Arches[i].Cpu == arch {
return b.openMachOCommon(name, of.Arches[i].File, start, limit, offset)
}
}
return nil, fmt.Errorf("architecture not found in %s: %s", name, runtime.GOARCH)
}
func (b *binrep) openMachO(name string, start, limit, offset uint64) (plugin.ObjFile, error) {
of, err := macho.Open(name)
if err != nil {
return nil, fmt.Errorf("error parsing %s: %v", name, err)
}
defer of.Close()
return b.openMachOCommon(name, of, start, limit, offset)
}
func (b *binrep) openELF(name string, start, limit, offset uint64, relocationSymbol string) (plugin.ObjFile, error) {
ef, err := elfOpen(name)
if err != nil {
return nil, fmt.Errorf("error parsing %s: %v", name, err)
}
defer ef.Close()
buildID := ""
if id, err := elfexec.GetBuildID(ef); err == nil {
buildID = fmt.Sprintf("%x", id)
}
var (
kernelOffset *uint64
pageAligned = func(addr uint64) bool { return addr%4096 == 0 }
)
if strings.Contains(name, "vmlinux") || !pageAligned(start) || !pageAligned(limit) || !pageAligned(offset) {
// Reading all Symbols is expensive, and we only rarely need it so
// we don't want to do it every time. But if _stext happens to be
// page-aligned but isn't the same as Vaddr, we would symbolize
// wrong. So if the name the addresses aren't page aligned, or if
// the name is "vmlinux" we read _stext. We can be wrong if: (1)
// someone passes a kernel path that doesn't contain "vmlinux" AND
// (2) _stext is page-aligned AND (3) _stext is not at Vaddr
symbols, err := ef.Symbols()
if err != nil && err != elf.ErrNoSymbols {
return nil, err
}
// The kernel relocation symbol (the mapping start address) can be either
// _text or _stext. When profiles are generated by `perf`, which one was used is
// distinguished by the mapping name for the kernel image:
// '[kernel.kallsyms]_text' or '[kernel.kallsyms]_stext', respectively. If we haven't
// been able to parse it from the mapping, we default to _stext.
if relocationSymbol == "" {
relocationSymbol = "_stext"
}
for _, s := range symbols {
if s.Name == relocationSymbol {
kernelOffset = &s.Value
break
}
}
}
// Check that we can compute a base for the binary. This may not be the
// correct base value, so we don't save it. We delay computing the actual base
// value until we have a sample address for this mapping, so that we can
// correctly identify the associated program segment that is needed to compute
// the base.
if _, err := elfexec.GetBase(&ef.FileHeader, elfexec.FindTextProgHeader(ef), kernelOffset, start, limit, offset); err != nil {
return nil, fmt.Errorf("could not identify base for %s: %v", name, err)
}
if b.fast || (!b.addr2lineFound && !b.llvmSymbolizerFound) {
return &fileNM{file: file{
b: b,
name: name,
buildID: buildID,
m: &elfMapping{start: start, limit: limit, offset: offset, kernelOffset: kernelOffset},
}}, nil
}
return &fileAddr2Line{file: file{
b: b,
name: name,
buildID: buildID,
m: &elfMapping{start: start, limit: limit, offset: offset, kernelOffset: kernelOffset},
}}, nil
}
func (b *binrep) openPE(name string, start, limit, offset uint64) (plugin.ObjFile, error) {
pf, err := pe.Open(name)
if err != nil {
return nil, fmt.Errorf("error parsing %s: %v", name, err)
}
defer pf.Close()
var imageBase uint64
switch h := pf.OptionalHeader.(type) {
case *pe.OptionalHeader32:
imageBase = uint64(h.ImageBase)
case *pe.OptionalHeader64:
imageBase = uint64(h.ImageBase)
default:
return nil, fmt.Errorf("unknown OptionalHeader %T", pf.OptionalHeader)
}
var base uint64
if start > 0 {
base = start - imageBase
}
if b.fast || (!b.addr2lineFound && !b.llvmSymbolizerFound) {
return &fileNM{file: file{b: b, name: name, base: base}}, nil
}
return &fileAddr2Line{file: file{b: b, name: name, base: base}}, nil
}
// elfMapping stores the parameters of a runtime mapping that are needed to
// identify the ELF segment associated with a mapping.
type elfMapping struct {
// Runtime mapping parameters.
start, limit, offset uint64
// Offset of kernel relocation symbol. Only defined for kernel images, nil otherwise.
kernelOffset *uint64
}
// findProgramHeader returns the program segment that matches the current
// mapping and the given address, or an error if it cannot find a unique program
// header.
func (m *elfMapping) findProgramHeader(ef *elf.File, addr uint64) (*elf.ProgHeader, error) {
// For user space executables, we try to find the actual program segment that
// is associated with the given mapping. Skip this search if limit <= start.
// We cannot use just a check on the start address of the mapping to tell if
// it's a kernel / .ko module mapping, because with quipper address remapping
// enabled, the address would be in the lower half of the address space.
if m.kernelOffset != nil || m.start >= m.limit || m.limit >= (uint64(1)<<63) {
// For the kernel, find the program segment that includes the .text section.
return elfexec.FindTextProgHeader(ef), nil
}
// Fetch all the loadable segments.
var phdrs []elf.ProgHeader
for i := range ef.Progs {
if ef.Progs[i].Type == elf.PT_LOAD {
phdrs = append(phdrs, ef.Progs[i].ProgHeader)
}
}
// Some ELF files don't contain any loadable program segments, e.g. .ko
// kernel modules. It's not an error to have no header in such cases.
if len(phdrs) == 0 {
return nil, nil
}
// Get all program headers associated with the mapping.
headers := elfexec.ProgramHeadersForMapping(phdrs, m.offset, m.limit-m.start)
if len(headers) == 0 {
return nil, errors.New("no program header matches mapping info")
}
if len(headers) == 1 {
return headers[0], nil
}
// Use the file offset corresponding to the address to symbolize, to narrow
// down the header.
return elfexec.HeaderForFileOffset(headers, addr-m.start+m.offset)
}
// file implements the binutils.ObjFile interface.
type file struct {
b *binrep
name string
buildID string
baseOnce sync.Once // Ensures the base, baseErr and isData are computed once.
base uint64
baseErr error // Any eventual error while computing the base.
isData bool
// Mapping information. Relevant only for ELF files, nil otherwise.
m *elfMapping
}
// computeBase computes the relocation base for the given binary file only if
// the elfMapping field is set. It populates the base and isData fields and
// returns an error.
func (f *file) computeBase(addr uint64) error {
if f == nil || f.m == nil {
return nil
}
if addr < f.m.start || addr >= f.m.limit {
return fmt.Errorf("specified address %x is outside the mapping range [%x, %x] for file %q", addr, f.m.start, f.m.limit, f.name)
}
ef, err := elfOpen(f.name)
if err != nil {
return fmt.Errorf("error parsing %s: %v", f.name, err)
}
defer ef.Close()
ph, err := f.m.findProgramHeader(ef, addr)
if err != nil {
return fmt.Errorf("failed to find program header for file %q, ELF mapping %#v, address %x: %v", f.name, *f.m, addr, err)
}
base, err := elfexec.GetBase(&ef.FileHeader, ph, f.m.kernelOffset, f.m.start, f.m.limit, f.m.offset)
if err != nil {
return err
}
f.base = base
f.isData = ph != nil && ph.Flags&elf.PF_X == 0
return nil
}
func (f *file) Name() string {
return f.name
}
func (f *file) ObjAddr(addr uint64) (uint64, error) {
f.baseOnce.Do(func() { f.baseErr = f.computeBase(addr) })
if f.baseErr != nil {
return 0, f.baseErr
}
return addr - f.base, nil
}
func (f *file) BuildID() string {
return f.buildID
}
func (f *file) SourceLine(addr uint64) ([]plugin.Frame, error) {
f.baseOnce.Do(func() { f.baseErr = f.computeBase(addr) })
if f.baseErr != nil {
return nil, f.baseErr
}
return nil, nil
}
func (f *file) Close() error {
return nil
}
func (f *file) Symbols(r *regexp.Regexp, addr uint64) ([]*plugin.Sym, error) {
// Get from nm a list of symbols sorted by address.
cmd := exec.Command(f.b.nm, "-n", f.name)
out, err := cmd.Output()
if err != nil {
return nil, fmt.Errorf("%v: %v", cmd.Args, err)
}
return findSymbols(out, f.name, r, addr)
}
// fileNM implements the binutils.ObjFile interface, using 'nm' to map
// addresses to symbols (without file/line number information). It is
// faster than fileAddr2Line.
type fileNM struct {
file
addr2linernm *addr2LinerNM
}
func (f *fileNM) SourceLine(addr uint64) ([]plugin.Frame, error) {
f.baseOnce.Do(func() { f.baseErr = f.computeBase(addr) })
if f.baseErr != nil {
return nil, f.baseErr
}
if f.addr2linernm == nil {
addr2liner, err := newAddr2LinerNM(f.b.nm, f.name, f.base)
if err != nil {
return nil, err
}
f.addr2linernm = addr2liner
}
return f.addr2linernm.addrInfo(addr)
}
// fileAddr2Line implements the binutils.ObjFile interface, using
// llvm-symbolizer, if that's available, or addr2line to map addresses to
// symbols (with file/line number information). It can be slow for large
// binaries with debug information.
type fileAddr2Line struct {
once sync.Once
file
addr2liner *addr2Liner
llvmSymbolizer *llvmSymbolizer
isData bool
}
func (f *fileAddr2Line) SourceLine(addr uint64) ([]plugin.Frame, error) {
f.baseOnce.Do(func() { f.baseErr = f.computeBase(addr) })
if f.baseErr != nil {
return nil, f.baseErr
}
f.once.Do(f.init)
if f.llvmSymbolizer != nil {
return f.llvmSymbolizer.addrInfo(addr)
}
if f.addr2liner != nil {
return f.addr2liner.addrInfo(addr)
}
return nil, fmt.Errorf("could not find local addr2liner")
}
func (f *fileAddr2Line) init() {
if llvmSymbolizer, err := newLLVMSymbolizer(f.b.llvmSymbolizer, f.name, f.base, f.isData); err == nil {
f.llvmSymbolizer = llvmSymbolizer
return
}
if addr2liner, err := newAddr2Liner(f.b.addr2line, f.name, f.base); err == nil {
f.addr2liner = addr2liner
// When addr2line encounters some gcc compiled binaries, it
// drops interesting parts of names in anonymous namespaces.
// Fallback to NM for better function names.
if nm, err := newAddr2LinerNM(f.b.nm, f.name, f.base); err == nil {
f.addr2liner.nm = nm
}
}
}
func (f *fileAddr2Line) Close() error {
if f.llvmSymbolizer != nil {
f.llvmSymbolizer.rw.close()
f.llvmSymbolizer = nil
}
if f.addr2liner != nil {
f.addr2liner.rw.close()
f.addr2liner = nil
}
return nil
}
|
go/src/cmd/vendor/github.com/google/pprof/internal/binutils/binutils.go/0
|
{
"file_path": "go/src/cmd/vendor/github.com/google/pprof/internal/binutils/binutils.go",
"repo_id": "go",
"token_count": 8296
}
| 175 |
body {
overflow: hidden; /* Want scrollbar not here, but in #stack-holder */
}
/* Scrollable container for flame graph */
#stack-holder {
width: 100%;
flex-grow: 1;
overflow-y: auto;
background: #eee; /* Light grey gives better contrast with boxes */
position: relative; /* Allows absolute positioning of child boxes */
}
/* Flame graph */
#stack-chart {
width: 100%;
position: relative; /* Allows absolute positioning of child boxes */
}
/* Shows details of frame that is under the mouse */
#current-details {
position: absolute;
top: 5px;
right: 5px;
font-size: 12pt;
}
/* Background of a single flame-graph frame */
.boxbg {
border-width: 0px;
position: absolute;
overflow: hidden;
box-sizing: border-box;
background: #d8d8d8;
}
.positive { position: absolute; background: #caa; }
.negative { position: absolute; background: #aca; }
/* Not-inlined frames are visually separated from their caller. */
.not-inlined {
border-top: 1px solid black;
}
/* Function name */
.boxtext {
position: absolute;
width: 100%;
padding-left: 2px;
line-height: 18px;
cursor: default;
font-family: "Google Sans", Arial, sans-serif;
font-size: 12pt;
z-index: 2;
}
/* Box highlighting via shadows to avoid size changes */
.hilite { box-shadow: 0px 0px 0px 2px #000; z-index: 1; }
.hilite2 { box-shadow: 0px 0px 0px 2px #000; z-index: 1; }
/* Gap left between callers and callees */
.separator {
position: absolute;
text-align: center;
font-size: 12pt;
font-weight: bold;
}
/* Right-click menu */
#action-menu {
max-width: 15em;
}
/* Right-click menu title */
#action-title {
display: block;
padding: 0.5em 1em;
background: #888;
text-overflow: ellipsis;
overflow: hidden;
}
/* Internal canvas used to measure text size when picking fonts */
#textsizer {
position: absolute;
bottom: -100px;
}
|
go/src/cmd/vendor/github.com/google/pprof/internal/driver/html/stacks.css/0
|
{
"file_path": "go/src/cmd/vendor/github.com/google/pprof/internal/driver/html/stacks.css",
"repo_id": "go",
"token_count": 619
}
| 176 |
// Copyright 2014 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Package measurement export utility functions to manipulate/format performance profile sample values.
package measurement
import (
"fmt"
"math"
"strings"
"time"
"github.com/google/pprof/profile"
)
// ScaleProfiles updates the units in a set of profiles to make them
// compatible. It scales the profiles to the smallest unit to preserve
// data.
func ScaleProfiles(profiles []*profile.Profile) error {
if len(profiles) == 0 {
return nil
}
periodTypes := make([]*profile.ValueType, 0, len(profiles))
for _, p := range profiles {
if p.PeriodType != nil {
periodTypes = append(periodTypes, p.PeriodType)
}
}
periodType, err := CommonValueType(periodTypes)
if err != nil {
return fmt.Errorf("period type: %v", err)
}
// Identify common sample types
numSampleTypes := len(profiles[0].SampleType)
for _, p := range profiles[1:] {
if numSampleTypes != len(p.SampleType) {
return fmt.Errorf("inconsistent samples type count: %d != %d", numSampleTypes, len(p.SampleType))
}
}
sampleType := make([]*profile.ValueType, numSampleTypes)
for i := 0; i < numSampleTypes; i++ {
sampleTypes := make([]*profile.ValueType, len(profiles))
for j, p := range profiles {
sampleTypes[j] = p.SampleType[i]
}
sampleType[i], err = CommonValueType(sampleTypes)
if err != nil {
return fmt.Errorf("sample types: %v", err)
}
}
for _, p := range profiles {
if p.PeriodType != nil && periodType != nil {
period, _ := Scale(p.Period, p.PeriodType.Unit, periodType.Unit)
p.Period, p.PeriodType.Unit = int64(period), periodType.Unit
}
ratios := make([]float64, len(p.SampleType))
for i, st := range p.SampleType {
if sampleType[i] == nil {
ratios[i] = 1
continue
}
ratios[i], _ = Scale(1, st.Unit, sampleType[i].Unit)
p.SampleType[i].Unit = sampleType[i].Unit
}
if err := p.ScaleN(ratios); err != nil {
return fmt.Errorf("scale: %v", err)
}
}
return nil
}
// CommonValueType returns the finest type from a set of compatible
// types.
func CommonValueType(ts []*profile.ValueType) (*profile.ValueType, error) {
if len(ts) <= 1 {
return nil, nil
}
minType := ts[0]
for _, t := range ts[1:] {
if !compatibleValueTypes(minType, t) {
return nil, fmt.Errorf("incompatible types: %v %v", *minType, *t)
}
if ratio, _ := Scale(1, t.Unit, minType.Unit); ratio < 1 {
minType = t
}
}
rcopy := *minType
return &rcopy, nil
}
func compatibleValueTypes(v1, v2 *profile.ValueType) bool {
if v1 == nil || v2 == nil {
return true // No grounds to disqualify.
}
// Remove trailing 's' to permit minor mismatches.
if t1, t2 := strings.TrimSuffix(v1.Type, "s"), strings.TrimSuffix(v2.Type, "s"); t1 != t2 {
return false
}
if v1.Unit == v2.Unit {
return true
}
for _, ut := range UnitTypes {
if ut.sniffUnit(v1.Unit) != nil && ut.sniffUnit(v2.Unit) != nil {
return true
}
}
return false
}
// Scale a measurement from a unit to a different unit and returns
// the scaled value and the target unit. The returned target unit
// will be empty if uninteresting (could be skipped).
func Scale(value int64, fromUnit, toUnit string) (float64, string) {
// Avoid infinite recursion on overflow.
if value < 0 && -value > 0 {
v, u := Scale(-value, fromUnit, toUnit)
return -v, u
}
for _, ut := range UnitTypes {
if v, u, ok := ut.convertUnit(value, fromUnit, toUnit); ok {
return v, u
}
}
// Skip non-interesting units.
switch toUnit {
case "count", "sample", "unit", "minimum", "auto":
return float64(value), ""
default:
return float64(value), toUnit
}
}
// Label returns the label used to describe a certain measurement.
func Label(value int64, unit string) string {
return ScaledLabel(value, unit, "auto")
}
// ScaledLabel scales the passed-in measurement (if necessary) and
// returns the label used to describe a float measurement.
func ScaledLabel(value int64, fromUnit, toUnit string) string {
v, u := Scale(value, fromUnit, toUnit)
sv := strings.TrimSuffix(fmt.Sprintf("%.2f", v), ".00")
if sv == "0" || sv == "-0" {
return "0"
}
return sv + u
}
// Percentage computes the percentage of total of a value, and encodes
// it as a string. At least two digits of precision are printed.
func Percentage(value, total int64) string {
var ratio float64
if total != 0 {
ratio = math.Abs(float64(value)/float64(total)) * 100
}
switch {
case math.Abs(ratio) >= 99.95 && math.Abs(ratio) <= 100.05:
return " 100%"
case math.Abs(ratio) >= 1.0:
return fmt.Sprintf("%5.2f%%", ratio)
default:
return fmt.Sprintf("%5.2g%%", ratio)
}
}
// Unit includes a list of aliases representing a specific unit and a factor
// which one can multiple a value in the specified unit by to get the value
// in terms of the base unit.
type Unit struct {
CanonicalName string
aliases []string
Factor float64
}
// UnitType includes a list of units that are within the same category (i.e.
// memory or time units) and a default unit to use for this type of unit.
type UnitType struct {
DefaultUnit Unit
Units []Unit
}
// findByAlias returns the unit associated with the specified alias. It returns
// nil if the unit with such alias is not found.
func (ut UnitType) findByAlias(alias string) *Unit {
for _, u := range ut.Units {
for _, a := range u.aliases {
if alias == a {
return &u
}
}
}
return nil
}
// sniffUnit simpifies the input alias and returns the unit associated with the
// specified alias. It returns nil if the unit with such alias is not found.
func (ut UnitType) sniffUnit(unit string) *Unit {
unit = strings.ToLower(unit)
if len(unit) > 2 {
unit = strings.TrimSuffix(unit, "s")
}
return ut.findByAlias(unit)
}
// autoScale takes in the value with units of the base unit and returns
// that value scaled to a reasonable unit if a reasonable unit is
// found.
func (ut UnitType) autoScale(value float64) (float64, string, bool) {
var f float64
var unit string
for _, u := range ut.Units {
if u.Factor >= f && (value/u.Factor) >= 1.0 {
f = u.Factor
unit = u.CanonicalName
}
}
if f == 0 {
return 0, "", false
}
return value / f, unit, true
}
// convertUnit converts a value from the fromUnit to the toUnit, autoscaling
// the value if the toUnit is "minimum" or "auto". If the fromUnit is not
// included in the unitType, then a false boolean will be returned. If the
// toUnit is not in the unitType, the value will be returned in terms of the
// default unitType.
func (ut UnitType) convertUnit(value int64, fromUnitStr, toUnitStr string) (float64, string, bool) {
fromUnit := ut.sniffUnit(fromUnitStr)
if fromUnit == nil {
return 0, "", false
}
v := float64(value) * fromUnit.Factor
if toUnitStr == "minimum" || toUnitStr == "auto" {
if v, u, ok := ut.autoScale(v); ok {
return v, u, true
}
return v / ut.DefaultUnit.Factor, ut.DefaultUnit.CanonicalName, true
}
toUnit := ut.sniffUnit(toUnitStr)
if toUnit == nil {
return v / ut.DefaultUnit.Factor, ut.DefaultUnit.CanonicalName, true
}
return v / toUnit.Factor, toUnit.CanonicalName, true
}
// UnitTypes holds the definition of units known to pprof.
var UnitTypes = []UnitType{{
Units: []Unit{
{"B", []string{"b", "byte"}, 1},
{"kB", []string{"kb", "kbyte", "kilobyte"}, float64(1 << 10)},
{"MB", []string{"mb", "mbyte", "megabyte"}, float64(1 << 20)},
{"GB", []string{"gb", "gbyte", "gigabyte"}, float64(1 << 30)},
{"TB", []string{"tb", "tbyte", "terabyte"}, float64(1 << 40)},
{"PB", []string{"pb", "pbyte", "petabyte"}, float64(1 << 50)},
},
DefaultUnit: Unit{"B", []string{"b", "byte"}, 1},
}, {
Units: []Unit{
{"ns", []string{"ns", "nanosecond"}, float64(time.Nanosecond)},
{"us", []string{"ΞΌs", "us", "microsecond"}, float64(time.Microsecond)},
{"ms", []string{"ms", "millisecond"}, float64(time.Millisecond)},
{"s", []string{"s", "sec", "second"}, float64(time.Second)},
{"hrs", []string{"hour", "hr"}, float64(time.Hour)},
},
DefaultUnit: Unit{"s", []string{}, float64(time.Second)},
}, {
Units: []Unit{
{"n*GCU", []string{"nanogcu"}, 1e-9},
{"u*GCU", []string{"microgcu"}, 1e-6},
{"m*GCU", []string{"milligcu"}, 1e-3},
{"GCU", []string{"gcu"}, 1},
{"k*GCU", []string{"kilogcu"}, 1e3},
{"M*GCU", []string{"megagcu"}, 1e6},
{"G*GCU", []string{"gigagcu"}, 1e9},
{"T*GCU", []string{"teragcu"}, 1e12},
{"P*GCU", []string{"petagcu"}, 1e15},
},
DefaultUnit: Unit{"GCU", []string{}, 1.0},
}}
|
go/src/cmd/vendor/github.com/google/pprof/internal/measurement/measurement.go/0
|
{
"file_path": "go/src/cmd/vendor/github.com/google/pprof/internal/measurement/measurement.go",
"repo_id": "go",
"token_count": 3268
}
| 177 |
// Copyright 2014 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// This file implements parsers to convert legacy profiles into the
// profile.proto format.
package profile
import (
"bufio"
"bytes"
"fmt"
"io"
"math"
"regexp"
"strconv"
"strings"
)
var (
countStartRE = regexp.MustCompile(`\A(\S+) profile: total \d+\z`)
countRE = regexp.MustCompile(`\A(\d+) @(( 0x[0-9a-f]+)+)\z`)
heapHeaderRE = regexp.MustCompile(`heap profile: *(\d+): *(\d+) *\[ *(\d+): *(\d+) *\] *@ *(heap[_a-z0-9]*)/?(\d*)`)
heapSampleRE = regexp.MustCompile(`(-?\d+): *(-?\d+) *\[ *(\d+): *(\d+) *] @([ x0-9a-f]*)`)
contentionSampleRE = regexp.MustCompile(`(\d+) *(\d+) @([ x0-9a-f]*)`)
hexNumberRE = regexp.MustCompile(`0x[0-9a-f]+`)
growthHeaderRE = regexp.MustCompile(`heap profile: *(\d+): *(\d+) *\[ *(\d+): *(\d+) *\] @ growthz?`)
fragmentationHeaderRE = regexp.MustCompile(`heap profile: *(\d+): *(\d+) *\[ *(\d+): *(\d+) *\] @ fragmentationz?`)
threadzStartRE = regexp.MustCompile(`--- threadz \d+ ---`)
threadStartRE = regexp.MustCompile(`--- Thread ([[:xdigit:]]+) \(name: (.*)/(\d+)\) stack: ---`)
// Regular expressions to parse process mappings. Support the format used by Linux /proc/.../maps and other tools.
// Recommended format:
// Start End object file name offset(optional) linker build id
// 0x40000-0x80000 /path/to/binary (@FF00) abc123456
spaceDigits = `\s+[[:digit:]]+`
hexPair = `\s+[[:xdigit:]]+:[[:xdigit:]]+`
oSpace = `\s*`
// Capturing expressions.
cHex = `(?:0x)?([[:xdigit:]]+)`
cHexRange = `\s*` + cHex + `[\s-]?` + oSpace + cHex + `:?`
cSpaceString = `(?:\s+(\S+))?`
cSpaceHex = `(?:\s+([[:xdigit:]]+))?`
cSpaceAtOffset = `(?:\s+\(@([[:xdigit:]]+)\))?`
cPerm = `(?:\s+([-rwxp]+))?`
procMapsRE = regexp.MustCompile(`^` + cHexRange + cPerm + cSpaceHex + hexPair + spaceDigits + cSpaceString)
briefMapsRE = regexp.MustCompile(`^` + cHexRange + cPerm + cSpaceString + cSpaceAtOffset + cSpaceHex)
// Regular expression to parse log data, of the form:
// ... file:line] msg...
logInfoRE = regexp.MustCompile(`^[^\[\]]+:[0-9]+]\s`)
)
func isSpaceOrComment(line string) bool {
trimmed := strings.TrimSpace(line)
return len(trimmed) == 0 || trimmed[0] == '#'
}
// parseGoCount parses a Go count profile (e.g., threadcreate or
// goroutine) and returns a new Profile.
func parseGoCount(b []byte) (*Profile, error) {
s := bufio.NewScanner(bytes.NewBuffer(b))
// Skip comments at the beginning of the file.
for s.Scan() && isSpaceOrComment(s.Text()) {
}
if err := s.Err(); err != nil {
return nil, err
}
m := countStartRE.FindStringSubmatch(s.Text())
if m == nil {
return nil, errUnrecognized
}
profileType := m[1]
p := &Profile{
PeriodType: &ValueType{Type: profileType, Unit: "count"},
Period: 1,
SampleType: []*ValueType{{Type: profileType, Unit: "count"}},
}
locations := make(map[uint64]*Location)
for s.Scan() {
line := s.Text()
if isSpaceOrComment(line) {
continue
}
if strings.HasPrefix(line, "---") {
break
}
m := countRE.FindStringSubmatch(line)
if m == nil {
return nil, errMalformed
}
n, err := strconv.ParseInt(m[1], 0, 64)
if err != nil {
return nil, errMalformed
}
fields := strings.Fields(m[2])
locs := make([]*Location, 0, len(fields))
for _, stk := range fields {
addr, err := strconv.ParseUint(stk, 0, 64)
if err != nil {
return nil, errMalformed
}
// Adjust all frames by -1 to land on top of the call instruction.
addr--
loc := locations[addr]
if loc == nil {
loc = &Location{
Address: addr,
}
locations[addr] = loc
p.Location = append(p.Location, loc)
}
locs = append(locs, loc)
}
p.Sample = append(p.Sample, &Sample{
Location: locs,
Value: []int64{n},
})
}
if err := s.Err(); err != nil {
return nil, err
}
if err := parseAdditionalSections(s, p); err != nil {
return nil, err
}
return p, nil
}
// remapLocationIDs ensures there is a location for each address
// referenced by a sample, and remaps the samples to point to the new
// location ids.
func (p *Profile) remapLocationIDs() {
seen := make(map[*Location]bool, len(p.Location))
var locs []*Location
for _, s := range p.Sample {
for _, l := range s.Location {
if seen[l] {
continue
}
l.ID = uint64(len(locs) + 1)
locs = append(locs, l)
seen[l] = true
}
}
p.Location = locs
}
func (p *Profile) remapFunctionIDs() {
seen := make(map[*Function]bool, len(p.Function))
var fns []*Function
for _, l := range p.Location {
for _, ln := range l.Line {
fn := ln.Function
if fn == nil || seen[fn] {
continue
}
fn.ID = uint64(len(fns) + 1)
fns = append(fns, fn)
seen[fn] = true
}
}
p.Function = fns
}
// remapMappingIDs matches location addresses with existing mappings
// and updates them appropriately. This is O(N*M), if this ever shows
// up as a bottleneck, evaluate sorting the mappings and doing a
// binary search, which would make it O(N*log(M)).
func (p *Profile) remapMappingIDs() {
// Some profile handlers will incorrectly set regions for the main
// executable if its section is remapped. Fix them through heuristics.
if len(p.Mapping) > 0 {
// Remove the initial mapping if named '/anon_hugepage' and has a
// consecutive adjacent mapping.
if m := p.Mapping[0]; strings.HasPrefix(m.File, "/anon_hugepage") {
if len(p.Mapping) > 1 && m.Limit == p.Mapping[1].Start {
p.Mapping = p.Mapping[1:]
}
}
}
// Subtract the offset from the start of the main mapping if it
// ends up at a recognizable start address.
if len(p.Mapping) > 0 {
const expectedStart = 0x400000
if m := p.Mapping[0]; m.Start-m.Offset == expectedStart {
m.Start = expectedStart
m.Offset = 0
}
}
// Associate each location with an address to the corresponding
// mapping. Create fake mapping if a suitable one isn't found.
var fake *Mapping
nextLocation:
for _, l := range p.Location {
a := l.Address
if l.Mapping != nil || a == 0 {
continue
}
for _, m := range p.Mapping {
if m.Start <= a && a < m.Limit {
l.Mapping = m
continue nextLocation
}
}
// Work around legacy handlers failing to encode the first
// part of mappings split into adjacent ranges.
for _, m := range p.Mapping {
if m.Offset != 0 && m.Start-m.Offset <= a && a < m.Start {
m.Start -= m.Offset
m.Offset = 0
l.Mapping = m
continue nextLocation
}
}
// If there is still no mapping, create a fake one.
// This is important for the Go legacy handler, which produced
// no mappings.
if fake == nil {
fake = &Mapping{
ID: 1,
Limit: ^uint64(0),
}
p.Mapping = append(p.Mapping, fake)
}
l.Mapping = fake
}
// Reset all mapping IDs.
for i, m := range p.Mapping {
m.ID = uint64(i + 1)
}
}
var cpuInts = []func([]byte) (uint64, []byte){
get32l,
get32b,
get64l,
get64b,
}
func get32l(b []byte) (uint64, []byte) {
if len(b) < 4 {
return 0, nil
}
return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24, b[4:]
}
func get32b(b []byte) (uint64, []byte) {
if len(b) < 4 {
return 0, nil
}
return uint64(b[3]) | uint64(b[2])<<8 | uint64(b[1])<<16 | uint64(b[0])<<24, b[4:]
}
func get64l(b []byte) (uint64, []byte) {
if len(b) < 8 {
return 0, nil
}
return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56, b[8:]
}
func get64b(b []byte) (uint64, []byte) {
if len(b) < 8 {
return 0, nil
}
return uint64(b[7]) | uint64(b[6])<<8 | uint64(b[5])<<16 | uint64(b[4])<<24 | uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56, b[8:]
}
// parseCPU parses a profilez legacy profile and returns a newly
// populated Profile.
//
// The general format for profilez samples is a sequence of words in
// binary format. The first words are a header with the following data:
//
// 1st word -- 0
// 2nd word -- 3
// 3rd word -- 0 if a c++ application, 1 if a java application.
// 4th word -- Sampling period (in microseconds).
// 5th word -- Padding.
func parseCPU(b []byte) (*Profile, error) {
var parse func([]byte) (uint64, []byte)
var n1, n2, n3, n4, n5 uint64
for _, parse = range cpuInts {
var tmp []byte
n1, tmp = parse(b)
n2, tmp = parse(tmp)
n3, tmp = parse(tmp)
n4, tmp = parse(tmp)
n5, tmp = parse(tmp)
if tmp != nil && n1 == 0 && n2 == 3 && n3 == 0 && n4 > 0 && n5 == 0 {
b = tmp
return cpuProfile(b, int64(n4), parse)
}
if tmp != nil && n1 == 0 && n2 == 3 && n3 == 1 && n4 > 0 && n5 == 0 {
b = tmp
return javaCPUProfile(b, int64(n4), parse)
}
}
return nil, errUnrecognized
}
// cpuProfile returns a new Profile from C++ profilez data.
// b is the profile bytes after the header, period is the profiling
// period, and parse is a function to parse 8-byte chunks from the
// profile in its native endianness.
func cpuProfile(b []byte, period int64, parse func(b []byte) (uint64, []byte)) (*Profile, error) {
p := &Profile{
Period: period * 1000,
PeriodType: &ValueType{Type: "cpu", Unit: "nanoseconds"},
SampleType: []*ValueType{
{Type: "samples", Unit: "count"},
{Type: "cpu", Unit: "nanoseconds"},
},
}
var err error
if b, _, err = parseCPUSamples(b, parse, true, p); err != nil {
return nil, err
}
// If *most* samples have the same second-to-the-bottom frame, it
// strongly suggests that it is an uninteresting artifact of
// measurement -- a stack frame pushed by the signal handler. The
// bottom frame is always correct as it is picked up from the signal
// structure, not the stack. Check if this is the case and if so,
// remove.
// Remove up to two frames.
maxiter := 2
// Allow one different sample for this many samples with the same
// second-to-last frame.
similarSamples := 32
margin := len(p.Sample) / similarSamples
for iter := 0; iter < maxiter; iter++ {
addr1 := make(map[uint64]int)
for _, s := range p.Sample {
if len(s.Location) > 1 {
a := s.Location[1].Address
addr1[a] = addr1[a] + 1
}
}
for id1, count := range addr1 {
if count >= len(p.Sample)-margin {
// Found uninteresting frame, strip it out from all samples
for _, s := range p.Sample {
if len(s.Location) > 1 && s.Location[1].Address == id1 {
s.Location = append(s.Location[:1], s.Location[2:]...)
}
}
break
}
}
}
if err := p.ParseMemoryMap(bytes.NewBuffer(b)); err != nil {
return nil, err
}
cleanupDuplicateLocations(p)
return p, nil
}
func cleanupDuplicateLocations(p *Profile) {
// The profile handler may duplicate the leaf frame, because it gets
// its address both from stack unwinding and from the signal
// context. Detect this and delete the duplicate, which has been
// adjusted by -1. The leaf address should not be adjusted as it is
// not a call.
for _, s := range p.Sample {
if len(s.Location) > 1 && s.Location[0].Address == s.Location[1].Address+1 {
s.Location = append(s.Location[:1], s.Location[2:]...)
}
}
}
// parseCPUSamples parses a collection of profilez samples from a
// profile.
//
// profilez samples are a repeated sequence of stack frames of the
// form:
//
// 1st word -- The number of times this stack was encountered.
// 2nd word -- The size of the stack (StackSize).
// 3rd word -- The first address on the stack.
// ...
// StackSize + 2 -- The last address on the stack
//
// The last stack trace is of the form:
//
// 1st word -- 0
// 2nd word -- 1
// 3rd word -- 0
//
// Addresses from stack traces may point to the next instruction after
// each call. Optionally adjust by -1 to land somewhere on the actual
// call (except for the leaf, which is not a call).
func parseCPUSamples(b []byte, parse func(b []byte) (uint64, []byte), adjust bool, p *Profile) ([]byte, map[uint64]*Location, error) {
locs := make(map[uint64]*Location)
for len(b) > 0 {
var count, nstk uint64
count, b = parse(b)
nstk, b = parse(b)
if b == nil || nstk > uint64(len(b)/4) {
return nil, nil, errUnrecognized
}
var sloc []*Location
addrs := make([]uint64, nstk)
for i := 0; i < int(nstk); i++ {
addrs[i], b = parse(b)
}
if count == 0 && nstk == 1 && addrs[0] == 0 {
// End of data marker
break
}
for i, addr := range addrs {
if adjust && i > 0 {
addr--
}
loc := locs[addr]
if loc == nil {
loc = &Location{
Address: addr,
}
locs[addr] = loc
p.Location = append(p.Location, loc)
}
sloc = append(sloc, loc)
}
p.Sample = append(p.Sample,
&Sample{
Value: []int64{int64(count), int64(count) * p.Period},
Location: sloc,
})
}
// Reached the end without finding the EOD marker.
return b, locs, nil
}
// parseHeap parses a heapz legacy or a growthz profile and
// returns a newly populated Profile.
func parseHeap(b []byte) (p *Profile, err error) {
s := bufio.NewScanner(bytes.NewBuffer(b))
if !s.Scan() {
if err := s.Err(); err != nil {
return nil, err
}
return nil, errUnrecognized
}
p = &Profile{}
sampling := ""
hasAlloc := false
line := s.Text()
p.PeriodType = &ValueType{Type: "space", Unit: "bytes"}
if header := heapHeaderRE.FindStringSubmatch(line); header != nil {
sampling, p.Period, hasAlloc, err = parseHeapHeader(line)
if err != nil {
return nil, err
}
} else if header = growthHeaderRE.FindStringSubmatch(line); header != nil {
p.Period = 1
} else if header = fragmentationHeaderRE.FindStringSubmatch(line); header != nil {
p.Period = 1
} else {
return nil, errUnrecognized
}
if hasAlloc {
// Put alloc before inuse so that default pprof selection
// will prefer inuse_space.
p.SampleType = []*ValueType{
{Type: "alloc_objects", Unit: "count"},
{Type: "alloc_space", Unit: "bytes"},
{Type: "inuse_objects", Unit: "count"},
{Type: "inuse_space", Unit: "bytes"},
}
} else {
p.SampleType = []*ValueType{
{Type: "objects", Unit: "count"},
{Type: "space", Unit: "bytes"},
}
}
locs := make(map[uint64]*Location)
for s.Scan() {
line := strings.TrimSpace(s.Text())
if isSpaceOrComment(line) {
continue
}
if isMemoryMapSentinel(line) {
break
}
value, blocksize, addrs, err := parseHeapSample(line, p.Period, sampling, hasAlloc)
if err != nil {
return nil, err
}
var sloc []*Location
for _, addr := range addrs {
// Addresses from stack traces point to the next instruction after
// each call. Adjust by -1 to land somewhere on the actual call.
addr--
loc := locs[addr]
if locs[addr] == nil {
loc = &Location{
Address: addr,
}
p.Location = append(p.Location, loc)
locs[addr] = loc
}
sloc = append(sloc, loc)
}
p.Sample = append(p.Sample, &Sample{
Value: value,
Location: sloc,
NumLabel: map[string][]int64{"bytes": {blocksize}},
})
}
if err := s.Err(); err != nil {
return nil, err
}
if err := parseAdditionalSections(s, p); err != nil {
return nil, err
}
return p, nil
}
func parseHeapHeader(line string) (sampling string, period int64, hasAlloc bool, err error) {
header := heapHeaderRE.FindStringSubmatch(line)
if header == nil {
return "", 0, false, errUnrecognized
}
if len(header[6]) > 0 {
if period, err = strconv.ParseInt(header[6], 10, 64); err != nil {
return "", 0, false, errUnrecognized
}
}
if (header[3] != header[1] && header[3] != "0") || (header[4] != header[2] && header[4] != "0") {
hasAlloc = true
}
switch header[5] {
case "heapz_v2", "heap_v2":
return "v2", period, hasAlloc, nil
case "heapprofile":
return "", 1, hasAlloc, nil
case "heap":
return "v2", period / 2, hasAlloc, nil
default:
return "", 0, false, errUnrecognized
}
}
// parseHeapSample parses a single row from a heap profile into a new Sample.
func parseHeapSample(line string, rate int64, sampling string, includeAlloc bool) (value []int64, blocksize int64, addrs []uint64, err error) {
sampleData := heapSampleRE.FindStringSubmatch(line)
if len(sampleData) != 6 {
return nil, 0, nil, fmt.Errorf("unexpected number of sample values: got %d, want 6", len(sampleData))
}
// This is a local-scoped helper function to avoid needing to pass
// around rate, sampling and many return parameters.
addValues := func(countString, sizeString string, label string) error {
count, err := strconv.ParseInt(countString, 10, 64)
if err != nil {
return fmt.Errorf("malformed sample: %s: %v", line, err)
}
size, err := strconv.ParseInt(sizeString, 10, 64)
if err != nil {
return fmt.Errorf("malformed sample: %s: %v", line, err)
}
if count == 0 && size != 0 {
return fmt.Errorf("%s count was 0 but %s bytes was %d", label, label, size)
}
if count != 0 {
blocksize = size / count
if sampling == "v2" {
count, size = scaleHeapSample(count, size, rate)
}
}
value = append(value, count, size)
return nil
}
if includeAlloc {
if err := addValues(sampleData[3], sampleData[4], "allocation"); err != nil {
return nil, 0, nil, err
}
}
if err := addValues(sampleData[1], sampleData[2], "inuse"); err != nil {
return nil, 0, nil, err
}
addrs, err = parseHexAddresses(sampleData[5])
if err != nil {
return nil, 0, nil, fmt.Errorf("malformed sample: %s: %v", line, err)
}
return value, blocksize, addrs, nil
}
// parseHexAddresses extracts hex numbers from a string, attempts to convert
// each to an unsigned 64-bit number and returns the resulting numbers as a
// slice, or an error if the string contains hex numbers which are too large to
// handle (which means a malformed profile).
func parseHexAddresses(s string) ([]uint64, error) {
hexStrings := hexNumberRE.FindAllString(s, -1)
var addrs []uint64
for _, s := range hexStrings {
if addr, err := strconv.ParseUint(s, 0, 64); err == nil {
addrs = append(addrs, addr)
} else {
return nil, fmt.Errorf("failed to parse as hex 64-bit number: %s", s)
}
}
return addrs, nil
}
// scaleHeapSample adjusts the data from a heapz Sample to
// account for its probability of appearing in the collected
// data. heapz profiles are a sampling of the memory allocations
// requests in a program. We estimate the unsampled value by dividing
// each collected sample by its probability of appearing in the
// profile. heapz v2 profiles rely on a poisson process to determine
// which samples to collect, based on the desired average collection
// rate R. The probability of a sample of size S to appear in that
// profile is 1-exp(-S/R).
func scaleHeapSample(count, size, rate int64) (int64, int64) {
if count == 0 || size == 0 {
return 0, 0
}
if rate <= 1 {
// if rate==1 all samples were collected so no adjustment is needed.
// if rate<1 treat as unknown and skip scaling.
return count, size
}
avgSize := float64(size) / float64(count)
scale := 1 / (1 - math.Exp(-avgSize/float64(rate)))
return int64(float64(count) * scale), int64(float64(size) * scale)
}
// parseContention parses a mutex or contention profile. There are 2 cases:
// "--- contentionz " for legacy C++ profiles (and backwards compatibility)
// "--- mutex:" or "--- contention:" for profiles generated by the Go runtime.
func parseContention(b []byte) (*Profile, error) {
s := bufio.NewScanner(bytes.NewBuffer(b))
if !s.Scan() {
if err := s.Err(); err != nil {
return nil, err
}
return nil, errUnrecognized
}
switch l := s.Text(); {
case strings.HasPrefix(l, "--- contentionz "):
case strings.HasPrefix(l, "--- mutex:"):
case strings.HasPrefix(l, "--- contention:"):
default:
return nil, errUnrecognized
}
p := &Profile{
PeriodType: &ValueType{Type: "contentions", Unit: "count"},
Period: 1,
SampleType: []*ValueType{
{Type: "contentions", Unit: "count"},
{Type: "delay", Unit: "nanoseconds"},
},
}
var cpuHz int64
// Parse text of the form "attribute = value" before the samples.
const delimiter = "="
for s.Scan() {
line := s.Text()
if line = strings.TrimSpace(line); isSpaceOrComment(line) {
continue
}
if strings.HasPrefix(line, "---") {
break
}
attr := strings.SplitN(line, delimiter, 2)
if len(attr) != 2 {
break
}
key, val := strings.TrimSpace(attr[0]), strings.TrimSpace(attr[1])
var err error
switch key {
case "cycles/second":
if cpuHz, err = strconv.ParseInt(val, 0, 64); err != nil {
return nil, errUnrecognized
}
case "sampling period":
if p.Period, err = strconv.ParseInt(val, 0, 64); err != nil {
return nil, errUnrecognized
}
case "ms since reset":
ms, err := strconv.ParseInt(val, 0, 64)
if err != nil {
return nil, errUnrecognized
}
p.DurationNanos = ms * 1000 * 1000
case "format":
// CPP contentionz profiles don't have format.
return nil, errUnrecognized
case "resolution":
// CPP contentionz profiles don't have resolution.
return nil, errUnrecognized
case "discarded samples":
default:
return nil, errUnrecognized
}
}
if err := s.Err(); err != nil {
return nil, err
}
locs := make(map[uint64]*Location)
for {
line := strings.TrimSpace(s.Text())
if strings.HasPrefix(line, "---") {
break
}
if !isSpaceOrComment(line) {
value, addrs, err := parseContentionSample(line, p.Period, cpuHz)
if err != nil {
return nil, err
}
var sloc []*Location
for _, addr := range addrs {
// Addresses from stack traces point to the next instruction after
// each call. Adjust by -1 to land somewhere on the actual call.
addr--
loc := locs[addr]
if locs[addr] == nil {
loc = &Location{
Address: addr,
}
p.Location = append(p.Location, loc)
locs[addr] = loc
}
sloc = append(sloc, loc)
}
p.Sample = append(p.Sample, &Sample{
Value: value,
Location: sloc,
})
}
if !s.Scan() {
break
}
}
if err := s.Err(); err != nil {
return nil, err
}
if err := parseAdditionalSections(s, p); err != nil {
return nil, err
}
return p, nil
}
// parseContentionSample parses a single row from a contention profile
// into a new Sample.
func parseContentionSample(line string, period, cpuHz int64) (value []int64, addrs []uint64, err error) {
sampleData := contentionSampleRE.FindStringSubmatch(line)
if sampleData == nil {
return nil, nil, errUnrecognized
}
v1, err := strconv.ParseInt(sampleData[1], 10, 64)
if err != nil {
return nil, nil, fmt.Errorf("malformed sample: %s: %v", line, err)
}
v2, err := strconv.ParseInt(sampleData[2], 10, 64)
if err != nil {
return nil, nil, fmt.Errorf("malformed sample: %s: %v", line, err)
}
// Unsample values if period and cpuHz are available.
// - Delays are scaled to cycles and then to nanoseconds.
// - Contentions are scaled to cycles.
if period > 0 {
if cpuHz > 0 {
cpuGHz := float64(cpuHz) / 1e9
v1 = int64(float64(v1) * float64(period) / cpuGHz)
}
v2 = v2 * period
}
value = []int64{v2, v1}
addrs, err = parseHexAddresses(sampleData[3])
if err != nil {
return nil, nil, fmt.Errorf("malformed sample: %s: %v", line, err)
}
return value, addrs, nil
}
// parseThread parses a Threadz profile and returns a new Profile.
func parseThread(b []byte) (*Profile, error) {
s := bufio.NewScanner(bytes.NewBuffer(b))
// Skip past comments and empty lines seeking a real header.
for s.Scan() && isSpaceOrComment(s.Text()) {
}
line := s.Text()
if m := threadzStartRE.FindStringSubmatch(line); m != nil {
// Advance over initial comments until first stack trace.
for s.Scan() {
if line = s.Text(); isMemoryMapSentinel(line) || strings.HasPrefix(line, "-") {
break
}
}
} else if t := threadStartRE.FindStringSubmatch(line); len(t) != 4 {
return nil, errUnrecognized
}
p := &Profile{
SampleType: []*ValueType{{Type: "thread", Unit: "count"}},
PeriodType: &ValueType{Type: "thread", Unit: "count"},
Period: 1,
}
locs := make(map[uint64]*Location)
// Recognize each thread and populate profile samples.
for !isMemoryMapSentinel(line) {
if strings.HasPrefix(line, "---- no stack trace for") {
break
}
if t := threadStartRE.FindStringSubmatch(line); len(t) != 4 {
return nil, errUnrecognized
}
var addrs []uint64
var err error
line, addrs, err = parseThreadSample(s)
if err != nil {
return nil, err
}
if len(addrs) == 0 {
// We got a --same as previous threads--. Bump counters.
if len(p.Sample) > 0 {
s := p.Sample[len(p.Sample)-1]
s.Value[0]++
}
continue
}
var sloc []*Location
for i, addr := range addrs {
// Addresses from stack traces point to the next instruction after
// each call. Adjust by -1 to land somewhere on the actual call
// (except for the leaf, which is not a call).
if i > 0 {
addr--
}
loc := locs[addr]
if locs[addr] == nil {
loc = &Location{
Address: addr,
}
p.Location = append(p.Location, loc)
locs[addr] = loc
}
sloc = append(sloc, loc)
}
p.Sample = append(p.Sample, &Sample{
Value: []int64{1},
Location: sloc,
})
}
if err := parseAdditionalSections(s, p); err != nil {
return nil, err
}
cleanupDuplicateLocations(p)
return p, nil
}
// parseThreadSample parses a symbolized or unsymbolized stack trace.
// Returns the first line after the traceback, the sample (or nil if
// it hits a 'same-as-previous' marker) and an error.
func parseThreadSample(s *bufio.Scanner) (nextl string, addrs []uint64, err error) {
var line string
sameAsPrevious := false
for s.Scan() {
line = strings.TrimSpace(s.Text())
if line == "" {
continue
}
if strings.HasPrefix(line, "---") {
break
}
if strings.Contains(line, "same as previous thread") {
sameAsPrevious = true
continue
}
curAddrs, err := parseHexAddresses(line)
if err != nil {
return "", nil, fmt.Errorf("malformed sample: %s: %v", line, err)
}
addrs = append(addrs, curAddrs...)
}
if err := s.Err(); err != nil {
return "", nil, err
}
if sameAsPrevious {
return line, nil, nil
}
return line, addrs, nil
}
// parseAdditionalSections parses any additional sections in the
// profile, ignoring any unrecognized sections.
func parseAdditionalSections(s *bufio.Scanner, p *Profile) error {
for !isMemoryMapSentinel(s.Text()) && s.Scan() {
}
if err := s.Err(); err != nil {
return err
}
return p.ParseMemoryMapFromScanner(s)
}
// ParseProcMaps parses a memory map in the format of /proc/self/maps.
// ParseMemoryMap should be called after setting on a profile to
// associate locations to the corresponding mapping based on their
// address.
func ParseProcMaps(rd io.Reader) ([]*Mapping, error) {
s := bufio.NewScanner(rd)
return parseProcMapsFromScanner(s)
}
func parseProcMapsFromScanner(s *bufio.Scanner) ([]*Mapping, error) {
var mapping []*Mapping
var attrs []string
const delimiter = "="
r := strings.NewReplacer()
for s.Scan() {
line := r.Replace(removeLoggingInfo(s.Text()))
m, err := parseMappingEntry(line)
if err != nil {
if err == errUnrecognized {
// Recognize assignments of the form: attr=value, and replace
// $attr with value on subsequent mappings.
if attr := strings.SplitN(line, delimiter, 2); len(attr) == 2 {
attrs = append(attrs, "$"+strings.TrimSpace(attr[0]), strings.TrimSpace(attr[1]))
r = strings.NewReplacer(attrs...)
}
// Ignore any unrecognized entries
continue
}
return nil, err
}
if m == nil {
continue
}
mapping = append(mapping, m)
}
if err := s.Err(); err != nil {
return nil, err
}
return mapping, nil
}
// removeLoggingInfo detects and removes log prefix entries generated
// by the glog package. If no logging prefix is detected, the string
// is returned unmodified.
func removeLoggingInfo(line string) string {
if match := logInfoRE.FindStringIndex(line); match != nil {
return line[match[1]:]
}
return line
}
// ParseMemoryMap parses a memory map in the format of
// /proc/self/maps, and overrides the mappings in the current profile.
// It renumbers the samples and locations in the profile correspondingly.
func (p *Profile) ParseMemoryMap(rd io.Reader) error {
return p.ParseMemoryMapFromScanner(bufio.NewScanner(rd))
}
// ParseMemoryMapFromScanner parses a memory map in the format of
// /proc/self/maps or a variety of legacy format, and overrides the
// mappings in the current profile. It renumbers the samples and
// locations in the profile correspondingly.
func (p *Profile) ParseMemoryMapFromScanner(s *bufio.Scanner) error {
mapping, err := parseProcMapsFromScanner(s)
if err != nil {
return err
}
p.Mapping = append(p.Mapping, mapping...)
p.massageMappings()
p.remapLocationIDs()
p.remapFunctionIDs()
p.remapMappingIDs()
return nil
}
func parseMappingEntry(l string) (*Mapping, error) {
var start, end, perm, file, offset, buildID string
if me := procMapsRE.FindStringSubmatch(l); len(me) == 6 {
start, end, perm, offset, file = me[1], me[2], me[3], me[4], me[5]
} else if me := briefMapsRE.FindStringSubmatch(l); len(me) == 7 {
start, end, perm, file, offset, buildID = me[1], me[2], me[3], me[4], me[5], me[6]
} else {
return nil, errUnrecognized
}
var err error
mapping := &Mapping{
File: file,
BuildID: buildID,
}
if perm != "" && !strings.Contains(perm, "x") {
// Skip non-executable entries.
return nil, nil
}
if mapping.Start, err = strconv.ParseUint(start, 16, 64); err != nil {
return nil, errUnrecognized
}
if mapping.Limit, err = strconv.ParseUint(end, 16, 64); err != nil {
return nil, errUnrecognized
}
if offset != "" {
if mapping.Offset, err = strconv.ParseUint(offset, 16, 64); err != nil {
return nil, errUnrecognized
}
}
return mapping, nil
}
var memoryMapSentinels = []string{
"--- Memory map: ---",
"MAPPED_LIBRARIES:",
}
// isMemoryMapSentinel returns true if the string contains one of the
// known sentinels for memory map information.
func isMemoryMapSentinel(line string) bool {
for _, s := range memoryMapSentinels {
if strings.Contains(line, s) {
return true
}
}
return false
}
func (p *Profile) addLegacyFrameInfo() {
switch {
case isProfileType(p, heapzSampleTypes):
p.DropFrames, p.KeepFrames = allocRxStr, allocSkipRxStr
case isProfileType(p, contentionzSampleTypes):
p.DropFrames, p.KeepFrames = lockRxStr, ""
default:
p.DropFrames, p.KeepFrames = cpuProfilerRxStr, ""
}
}
var heapzSampleTypes = [][]string{
{"allocations", "size"}, // early Go pprof profiles
{"objects", "space"},
{"inuse_objects", "inuse_space"},
{"alloc_objects", "alloc_space"},
{"alloc_objects", "alloc_space", "inuse_objects", "inuse_space"}, // Go pprof legacy profiles
}
var contentionzSampleTypes = [][]string{
{"contentions", "delay"},
}
func isProfileType(p *Profile, types [][]string) bool {
st := p.SampleType
nextType:
for _, t := range types {
if len(st) != len(t) {
continue
}
for i := range st {
if st[i].Type != t[i] {
continue nextType
}
}
return true
}
return false
}
var allocRxStr = strings.Join([]string{
// POSIX entry points.
`calloc`,
`cfree`,
`malloc`,
`free`,
`memalign`,
`do_memalign`,
`(__)?posix_memalign`,
`pvalloc`,
`valloc`,
`realloc`,
// TC malloc.
`tcmalloc::.*`,
`tc_calloc`,
`tc_cfree`,
`tc_malloc`,
`tc_free`,
`tc_memalign`,
`tc_posix_memalign`,
`tc_pvalloc`,
`tc_valloc`,
`tc_realloc`,
`tc_new`,
`tc_delete`,
`tc_newarray`,
`tc_deletearray`,
`tc_new_nothrow`,
`tc_newarray_nothrow`,
// Memory-allocation routines on OS X.
`malloc_zone_malloc`,
`malloc_zone_calloc`,
`malloc_zone_valloc`,
`malloc_zone_realloc`,
`malloc_zone_memalign`,
`malloc_zone_free`,
// Go runtime
`runtime\..*`,
// Other misc. memory allocation routines
`BaseArena::.*`,
`(::)?do_malloc_no_errno`,
`(::)?do_malloc_pages`,
`(::)?do_malloc`,
`DoSampledAllocation`,
`MallocedMemBlock::MallocedMemBlock`,
`_M_allocate`,
`__builtin_(vec_)?delete`,
`__builtin_(vec_)?new`,
`__gnu_cxx::new_allocator::allocate`,
`__libc_malloc`,
`__malloc_alloc_template::allocate`,
`allocate`,
`cpp_alloc`,
`operator new(\[\])?`,
`simple_alloc::allocate`,
}, `|`)
var allocSkipRxStr = strings.Join([]string{
// Preserve Go runtime frames that appear in the middle/bottom of
// the stack.
`runtime\.panic`,
`runtime\.reflectcall`,
`runtime\.call[0-9]*`,
}, `|`)
var cpuProfilerRxStr = strings.Join([]string{
`ProfileData::Add`,
`ProfileData::prof_handler`,
`CpuProfiler::prof_handler`,
`__pthread_sighandler`,
`__restore`,
}, `|`)
var lockRxStr = strings.Join([]string{
`RecordLockProfileData`,
`(base::)?RecordLockProfileData.*`,
`(base::)?SubmitMutexProfileData.*`,
`(base::)?SubmitSpinLockProfileData.*`,
`(base::Mutex::)?AwaitCommon.*`,
`(base::Mutex::)?Unlock.*`,
`(base::Mutex::)?UnlockSlow.*`,
`(base::Mutex::)?ReaderUnlock.*`,
`(base::MutexLock::)?~MutexLock.*`,
`(Mutex::)?AwaitCommon.*`,
`(Mutex::)?Unlock.*`,
`(Mutex::)?UnlockSlow.*`,
`(Mutex::)?ReaderUnlock.*`,
`(MutexLock::)?~MutexLock.*`,
`(SpinLock::)?Unlock.*`,
`(SpinLock::)?SlowUnlock.*`,
`(SpinLockHolder::)?~SpinLockHolder.*`,
}, `|`)
|
go/src/cmd/vendor/github.com/google/pprof/profile/legacy_profile.go/0
|
{
"file_path": "go/src/cmd/vendor/github.com/google/pprof/profile/legacy_profile.go",
"repo_id": "go",
"token_count": 13153
}
| 178 |
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package ppc64asm
import (
"encoding/binary"
"fmt"
"log"
)
const debugDecode = false
const prefixOpcode = 1
// instFormat is a decoding rule for one specific instruction form.
// an instruction ins matches the rule if ins&Mask == Value
// DontCare bits should be zero, but the machine might not reject
// ones in those bits, they are mainly reserved for future expansion
// of the instruction set.
// The Args are stored in the same order as the instruction manual.
//
// Prefixed instructions are stored as:
//
// prefix << 32 | suffix,
//
// Regular instructions are:
//
// inst << 32
type instFormat struct {
Op Op
Mask uint64
Value uint64
DontCare uint64
Args [6]*argField
}
// argField indicate how to decode an argument to an instruction.
// First parse the value from the BitFields, shift it left by Shift
// bits to get the actual numerical value.
type argField struct {
Type ArgType
Shift uint8
BitFields
}
// Parse parses the Arg out from the given binary instruction i.
func (a argField) Parse(i [2]uint32) Arg {
switch a.Type {
default:
return nil
case TypeUnknown:
return nil
case TypeReg:
return R0 + Reg(a.BitFields.Parse(i))
case TypeCondRegBit:
return Cond0LT + CondReg(a.BitFields.Parse(i))
case TypeCondRegField:
return CR0 + CondReg(a.BitFields.Parse(i))
case TypeFPReg:
return F0 + Reg(a.BitFields.Parse(i))
case TypeVecReg:
return V0 + Reg(a.BitFields.Parse(i))
case TypeVecSReg:
return VS0 + Reg(a.BitFields.Parse(i))
case TypeVecSpReg:
return VS0 + Reg(a.BitFields.Parse(i))*2
case TypeMMAReg:
return A0 + Reg(a.BitFields.Parse(i))
case TypeSpReg:
return SpReg(a.BitFields.Parse(i))
case TypeImmSigned:
return Imm(a.BitFields.ParseSigned(i) << a.Shift)
case TypeImmUnsigned:
return Imm(a.BitFields.Parse(i) << a.Shift)
case TypePCRel:
return PCRel(a.BitFields.ParseSigned(i) << a.Shift)
case TypeLabel:
return Label(a.BitFields.ParseSigned(i) << a.Shift)
case TypeOffset:
return Offset(a.BitFields.ParseSigned(i) << a.Shift)
case TypeNegOffset:
// An oddball encoding of offset for hashchk and similar.
// e.g hashchk offset is 0b1111111000000000 | DX << 8 | D << 3
off := a.BitFields.ParseSigned(i) << a.Shift
neg := int64(-1) << (int(a.Shift) + a.BitFields.NumBits())
return Offset(neg | off)
}
}
type ArgType int8
const (
TypeUnknown ArgType = iota
TypePCRel // PC-relative address
TypeLabel // absolute address
TypeReg // integer register
TypeCondRegBit // conditional register bit (0-31)
TypeCondRegField // conditional register field (0-7)
TypeFPReg // floating point register
TypeVecReg // vector register
TypeVecSReg // VSX register
TypeVecSpReg // VSX register pair (even only encoding)
TypeMMAReg // MMA register
TypeSpReg // special register (depends on Op)
TypeImmSigned // signed immediate
TypeImmUnsigned // unsigned immediate/flag/mask, this is the catch-all type
TypeOffset // signed offset in load/store
TypeNegOffset // A negative 16 bit value 0b1111111xxxxx000 encoded as 0bxxxxx (e.g in the hashchk instruction)
TypeLast // must be the last one
)
func (t ArgType) String() string {
switch t {
default:
return fmt.Sprintf("ArgType(%d)", int(t))
case TypeUnknown:
return "Unknown"
case TypeReg:
return "Reg"
case TypeCondRegBit:
return "CondRegBit"
case TypeCondRegField:
return "CondRegField"
case TypeFPReg:
return "FPReg"
case TypeVecReg:
return "VecReg"
case TypeVecSReg:
return "VecSReg"
case TypeVecSpReg:
return "VecSpReg"
case TypeMMAReg:
return "MMAReg"
case TypeSpReg:
return "SpReg"
case TypeImmSigned:
return "ImmSigned"
case TypeImmUnsigned:
return "ImmUnsigned"
case TypePCRel:
return "PCRel"
case TypeLabel:
return "Label"
case TypeOffset:
return "Offset"
case TypeNegOffset:
return "NegOffset"
}
}
func (t ArgType) GoString() string {
s := t.String()
if t > 0 && t < TypeLast {
return "Type" + s
}
return s
}
var (
// Errors
errShort = fmt.Errorf("truncated instruction")
errUnknown = fmt.Errorf("unknown instruction")
)
var decoderCover []bool
// Decode decodes the leading bytes in src as a single instruction using
// byte order ord.
func Decode(src []byte, ord binary.ByteOrder) (inst Inst, err error) {
if len(src) < 4 {
return inst, errShort
}
if decoderCover == nil {
decoderCover = make([]bool, len(instFormats))
}
inst.Len = 4
ui_extn := [2]uint32{ord.Uint32(src[:inst.Len]), 0}
ui := uint64(ui_extn[0]) << 32
inst.Enc = ui_extn[0]
opcode := inst.Enc >> 26
if opcode == prefixOpcode {
// This is a prefixed instruction
inst.Len = 8
if len(src) < 8 {
return inst, errShort
}
// Merge the suffixed word.
ui_extn[1] = ord.Uint32(src[4:inst.Len])
ui |= uint64(ui_extn[1])
inst.SuffixEnc = ui_extn[1]
}
for i, iform := range instFormats {
if ui&iform.Mask != iform.Value {
continue
}
if ui&iform.DontCare != 0 {
if debugDecode {
log.Printf("Decode(%#x): unused bit is 1 for Op %s", ui, iform.Op)
}
// to match GNU objdump (libopcodes), we ignore don't care bits
}
for i, argfield := range iform.Args {
if argfield == nil {
break
}
inst.Args[i] = argfield.Parse(ui_extn)
}
inst.Op = iform.Op
if debugDecode {
log.Printf("%#x: search entry %d", ui, i)
continue
}
break
}
if inst.Op == 0 && inst.Enc != 0 {
return inst, errUnknown
}
return inst, nil
}
|
go/src/cmd/vendor/golang.org/x/arch/ppc64/ppc64asm/decode.go/0
|
{
"file_path": "go/src/cmd/vendor/golang.org/x/arch/ppc64/ppc64asm/decode.go",
"repo_id": "go",
"token_count": 2339
}
| 179 |
// Copyright 2024 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package relnote
import (
"fmt"
"strings"
md "rsc.io/markdown"
)
// DumpMarkdown writes the internal structure of a markdown
// document to standard output.
// It is intended for debugging.
func DumpMarkdown(d *md.Document) {
dumpBlocks(d.Blocks, 0)
}
func dumpBlocks(bs []md.Block, depth int) {
for _, b := range bs {
dumpBlock(b, depth)
}
}
func dumpBlock(b md.Block, depth int) {
typeName := strings.TrimPrefix(fmt.Sprintf("%T", b), "*markdown.")
dprintf(depth, "%s\n", typeName)
switch b := b.(type) {
case *md.Paragraph:
dumpInlines(b.Text.Inline, depth+1)
case *md.Heading:
dumpInlines(b.Text.Inline, depth+1)
case *md.List:
dumpBlocks(b.Items, depth+1)
case *md.Item:
dumpBlocks(b.Blocks, depth+1)
default:
// TODO(jba): additional cases as needed.
}
}
func dumpInlines(ins []md.Inline, depth int) {
for _, in := range ins {
switch in := in.(type) {
case *md.Plain:
dprintf(depth, "Plain(%q)\n", in.Text)
case *md.Code:
dprintf(depth, "Code(%q)\n", in.Text)
case *md.Link:
dprintf(depth, "Link:\n")
dumpInlines(in.Inner, depth+1)
dprintf(depth+1, "URL: %q\n", in.URL)
case *md.Strong:
dprintf(depth, "Strong(%q):\n", in.Marker)
dumpInlines(in.Inner, depth+1)
case *md.Emph:
dprintf(depth, "Emph(%q):\n", in.Marker)
dumpInlines(in.Inner, depth+1)
case *md.Del:
dprintf(depth, "Del(%q):\n", in.Marker)
dumpInlines(in.Inner, depth+1)
default:
fmt.Printf("%*s%#v\n", depth*4, "", in)
}
}
}
func dprintf(depth int, format string, args ...any) {
fmt.Printf("%*s%s", depth*4, "", fmt.Sprintf(format, args...))
}
|
go/src/cmd/vendor/golang.org/x/build/relnote/dump.go/0
|
{
"file_path": "go/src/cmd/vendor/golang.org/x/build/relnote/dump.go",
"repo_id": "go",
"token_count": 766
}
| 180 |
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package note defines the notes signed by the Go module database server.
//
// A note is text signed by one or more server keys.
// The text should be ignored unless the note is signed by
// a trusted server key and the signature has been verified
// using the server's public key.
//
// A server's public key is identified by a name, typically the "host[/path]"
// giving the base URL of the server's transparency log.
// The syntactic restrictions on a name are that it be non-empty,
// well-formed UTF-8 containing neither Unicode spaces nor plus (U+002B).
//
// A Go module database server signs texts using public key cryptography.
// A given server may have multiple public keys, each
// identified by a 32-bit hash of the public key.
//
// # Verifying Notes
//
// A [Verifier] allows verification of signatures by one server public key.
// It can report the name of the server and the uint32 hash of the key,
// and it can verify a purported signature by that key.
//
// The standard implementation of a Verifier is constructed
// by [NewVerifier] starting from a verifier key, which is a
// plain text string of the form "<name>+<hash>+<keydata>".
//
// A [Verifiers] allows looking up a Verifier by the combination
// of server name and key hash.
//
// The standard implementation of a Verifiers is constructed
// by VerifierList from a list of known verifiers.
//
// A [Note] represents a text with one or more signatures.
// An implementation can reject a note with too many signatures
// (for example, more than 100 signatures).
//
// A [Signature] represents a signature on a note, verified or not.
//
// The [Open] function takes as input a signed message
// and a set of known verifiers. It decodes and verifies
// the message signatures and returns a [Note] structure
// containing the message text and (verified or unverified) signatures.
//
// # Signing Notes
//
// A [Signer] allows signing a text with a given key.
// It can report the name of the server and the hash of the key
// and can sign a raw text using that key.
//
// The standard implementation of a Signer is constructed
// by [NewSigner] starting from an encoded signer key, which is a
// plain text string of the form "PRIVATE+KEY+<name>+<hash>+<keydata>".
// Anyone with an encoded signer key can sign messages using that key,
// so it must be kept secret. The encoding begins with the literal text
// "PRIVATE+KEY" to avoid confusion with the public server key.
//
// The [Sign] function takes as input a Note and a list of Signers
// and returns an encoded, signed message.
//
// # Signed Note Format
//
// A signed note consists of a text ending in newline (U+000A),
// followed by a blank line (only a newline),
// followed by one or more signature lines of this form:
// em dash (U+2014), space (U+0020),
// server name, space, base64-encoded signature, newline.
//
// Signed notes must be valid UTF-8 and must not contain any
// ASCII control characters (those below U+0020) other than newline.
//
// A signature is a base64 encoding of 4+n bytes.
//
// The first four bytes in the signature are the uint32 key hash
// stored in big-endian order.
//
// The remaining n bytes are the result of using the specified key
// to sign the note text (including the final newline but not the
// separating blank line).
//
// # Generating Keys
//
// There is only one key type, Ed25519 with algorithm identifier 1.
// New key types may be introduced in the future as needed,
// although doing so will require deploying the new algorithms to all clients
// before starting to depend on them for signatures.
//
// The [GenerateKey] function generates and returns a new signer
// and corresponding verifier.
//
// # Example
//
// Here is a well-formed signed note:
//
// If you think cryptography is the answer to your problem,
// then you don't know what your problem is.
//
// β PeterNeumann x08go/ZJkuBS9UG/SffcvIAQxVBtiFupLLr8pAcElZInNIuGUgYN1FFYC2pZSNXgKvqfqdngotpRZb6KE6RyyBwJnAM=
//
// It can be constructed and displayed using:
//
// skey := "PRIVATE+KEY+PeterNeumann+c74f20a3+AYEKFALVFGyNhPJEMzD1QIDr+Y7hfZx09iUvxdXHKDFz"
// text := "If you think cryptography is the answer to your problem,\n" +
// "then you don't know what your problem is.\n"
//
// signer, err := note.NewSigner(skey)
// if err != nil {
// log.Fatal(err)
// }
//
// msg, err := note.Sign(¬e.Note{Text: text}, signer)
// if err != nil {
// log.Fatal(err)
// }
// os.Stdout.Write(msg)
//
// The note's text is two lines, including the final newline,
// and the text is purportedly signed by a server named
// "PeterNeumann". (Although server names are canonically
// base URLs, the only syntactic requirement is that they
// not contain spaces or newlines).
//
// If [Open] is given access to a [Verifiers] including the
// [Verifier] for this key, then it will succeed at verifying
// the encoded message and returning the parsed [Note]:
//
// vkey := "PeterNeumann+c74f20a3+ARpc2QcUPDhMQegwxbzhKqiBfsVkmqq/LDE4izWy10TW"
// msg := []byte("If you think cryptography is the answer to your problem,\n" +
// "then you don't know what your problem is.\n" +
// "\n" +
// "β PeterNeumann x08go/ZJkuBS9UG/SffcvIAQxVBtiFupLLr8pAcElZInNIuGUgYN1FFYC2pZSNXgKvqfqdngotpRZb6KE6RyyBwJnAM=\n")
//
// verifier, err := note.NewVerifier(vkey)
// if err != nil {
// log.Fatal(err)
// }
// verifiers := note.VerifierList(verifier)
//
// n, err := note.Open([]byte(msg), verifiers)
// if err != nil {
// log.Fatal(err)
// }
// fmt.Printf("%s (%08x):\n%s", n.Sigs[0].Name, n.Sigs[0].Hash, n.Text)
//
// You can add your own signature to this message by re-signing the note:
//
// skey, vkey, err := note.GenerateKey(rand.Reader, "EnochRoot")
// if err != nil {
// log.Fatal(err)
// }
// _ = vkey // give to verifiers
//
// me, err := note.NewSigner(skey)
// if err != nil {
// log.Fatal(err)
// }
//
// msg, err := note.Sign(n, me)
// if err != nil {
// log.Fatal(err)
// }
// os.Stdout.Write(msg)
//
// This will print a doubly-signed message, like:
//
// If you think cryptography is the answer to your problem,
// then you don't know what your problem is.
//
// β PeterNeumann x08go/ZJkuBS9UG/SffcvIAQxVBtiFupLLr8pAcElZInNIuGUgYN1FFYC2pZSNXgKvqfqdngotpRZb6KE6RyyBwJnAM=
// β EnochRoot rwz+eBzmZa0SO3NbfRGzPCpDckykFXSdeX+MNtCOXm2/5n2tiOHp+vAF1aGrQ5ovTG01oOTGwnWLox33WWd1RvMc+QQ=
package note
import (
"bytes"
"crypto/ed25519"
"crypto/sha256"
"encoding/base64"
"encoding/binary"
"errors"
"fmt"
"io"
"strconv"
"strings"
"unicode"
"unicode/utf8"
)
// A Verifier verifies messages signed with a specific key.
type Verifier interface {
// Name returns the server name associated with the key.
Name() string
// KeyHash returns the key hash.
KeyHash() uint32
// Verify reports whether sig is a valid signature of msg.
Verify(msg, sig []byte) bool
}
// A Signer signs messages using a specific key.
type Signer interface {
// Name returns the server name associated with the key.
Name() string
// KeyHash returns the key hash.
KeyHash() uint32
// Sign returns a signature for the given message.
Sign(msg []byte) ([]byte, error)
}
// keyHash computes the key hash for the given server name and encoded public key.
func keyHash(name string, key []byte) uint32 {
h := sha256.New()
h.Write([]byte(name))
h.Write([]byte("\n"))
h.Write(key)
sum := h.Sum(nil)
return binary.BigEndian.Uint32(sum)
}
var (
errVerifierID = errors.New("malformed verifier id")
errVerifierAlg = errors.New("unknown verifier algorithm")
errVerifierHash = errors.New("invalid verifier hash")
)
const (
algEd25519 = 1
)
// isValidName reports whether name is valid.
// It must be non-empty and not have any Unicode spaces or pluses.
func isValidName(name string) bool {
return name != "" && utf8.ValidString(name) && strings.IndexFunc(name, unicode.IsSpace) < 0 && !strings.Contains(name, "+")
}
// NewVerifier construct a new [Verifier] from an encoded verifier key.
func NewVerifier(vkey string) (Verifier, error) {
name, vkey := chop(vkey, "+")
hash16, key64 := chop(vkey, "+")
hash, err1 := strconv.ParseUint(hash16, 16, 32)
key, err2 := base64.StdEncoding.DecodeString(key64)
if len(hash16) != 8 || err1 != nil || err2 != nil || !isValidName(name) || len(key) == 0 {
return nil, errVerifierID
}
if uint32(hash) != keyHash(name, key) {
return nil, errVerifierHash
}
v := &verifier{
name: name,
hash: uint32(hash),
}
alg, key := key[0], key[1:]
switch alg {
default:
return nil, errVerifierAlg
case algEd25519:
if len(key) != 32 {
return nil, errVerifierID
}
v.verify = func(msg, sig []byte) bool {
return ed25519.Verify(key, msg, sig)
}
}
return v, nil
}
// chop chops s at the first instance of sep, if any,
// and returns the text before and after sep.
// If sep is not present, chop returns before is s and after is empty.
func chop(s, sep string) (before, after string) {
i := strings.Index(s, sep)
if i < 0 {
return s, ""
}
return s[:i], s[i+len(sep):]
}
// verifier is a trivial Verifier implementation.
type verifier struct {
name string
hash uint32
verify func([]byte, []byte) bool
}
func (v *verifier) Name() string { return v.name }
func (v *verifier) KeyHash() uint32 { return v.hash }
func (v *verifier) Verify(msg, sig []byte) bool { return v.verify(msg, sig) }
// NewSigner constructs a new [Signer] from an encoded signer key.
func NewSigner(skey string) (Signer, error) {
priv1, skey := chop(skey, "+")
priv2, skey := chop(skey, "+")
name, skey := chop(skey, "+")
hash16, key64 := chop(skey, "+")
hash, err1 := strconv.ParseUint(hash16, 16, 32)
key, err2 := base64.StdEncoding.DecodeString(key64)
if priv1 != "PRIVATE" || priv2 != "KEY" || len(hash16) != 8 || err1 != nil || err2 != nil || !isValidName(name) || len(key) == 0 {
return nil, errSignerID
}
// Note: hash is the hash of the public key and we have the private key.
// Must verify hash after deriving public key.
s := &signer{
name: name,
hash: uint32(hash),
}
var pubkey []byte
alg, key := key[0], key[1:]
switch alg {
default:
return nil, errSignerAlg
case algEd25519:
if len(key) != 32 {
return nil, errSignerID
}
key = ed25519.NewKeyFromSeed(key)
pubkey = append([]byte{algEd25519}, key[32:]...)
s.sign = func(msg []byte) ([]byte, error) {
return ed25519.Sign(key, msg), nil
}
}
if uint32(hash) != keyHash(name, pubkey) {
return nil, errSignerHash
}
return s, nil
}
var (
errSignerID = errors.New("malformed verifier id")
errSignerAlg = errors.New("unknown verifier algorithm")
errSignerHash = errors.New("invalid verifier hash")
)
// signer is a trivial Signer implementation.
type signer struct {
name string
hash uint32
sign func([]byte) ([]byte, error)
}
func (s *signer) Name() string { return s.name }
func (s *signer) KeyHash() uint32 { return s.hash }
func (s *signer) Sign(msg []byte) ([]byte, error) { return s.sign(msg) }
// GenerateKey generates a signer and verifier key pair for a named server.
// The signer key skey is private and must be kept secret.
func GenerateKey(rand io.Reader, name string) (skey, vkey string, err error) {
pub, priv, err := ed25519.GenerateKey(rand)
if err != nil {
return "", "", err
}
pubkey := append([]byte{algEd25519}, pub...)
privkey := append([]byte{algEd25519}, priv.Seed()...)
h := keyHash(name, pubkey)
skey = fmt.Sprintf("PRIVATE+KEY+%s+%08x+%s", name, h, base64.StdEncoding.EncodeToString(privkey))
vkey = fmt.Sprintf("%s+%08x+%s", name, h, base64.StdEncoding.EncodeToString(pubkey))
return skey, vkey, nil
}
// NewEd25519VerifierKey returns an encoded verifier key using the given name
// and Ed25519 public key.
func NewEd25519VerifierKey(name string, key ed25519.PublicKey) (string, error) {
if len(key) != ed25519.PublicKeySize {
return "", fmt.Errorf("invalid public key size %d, expected %d", len(key), ed25519.PublicKeySize)
}
pubkey := append([]byte{algEd25519}, key...)
hash := keyHash(name, pubkey)
b64Key := base64.StdEncoding.EncodeToString(pubkey)
return fmt.Sprintf("%s+%08x+%s", name, hash, b64Key), nil
}
// A Verifiers is a collection of known verifier keys.
type Verifiers interface {
// Verifier returns the Verifier associated with the key
// identified by the name and hash.
// If the name, hash pair is unknown, Verifier should return
// an UnknownVerifierError.
Verifier(name string, hash uint32) (Verifier, error)
}
// An UnknownVerifierError indicates that the given key is not known.
// The Open function records signatures without associated verifiers as
// unverified signatures.
type UnknownVerifierError struct {
Name string
KeyHash uint32
}
func (e *UnknownVerifierError) Error() string {
return fmt.Sprintf("unknown key %s+%08x", e.Name, e.KeyHash)
}
// An ambiguousVerifierError indicates that the given name and hash
// match multiple keys passed to [VerifierList].
// (If this happens, some malicious actor has taken control of the
// verifier list, at which point we may as well give up entirely,
// but we diagnose the problem instead.)
type ambiguousVerifierError struct {
name string
hash uint32
}
func (e *ambiguousVerifierError) Error() string {
return fmt.Sprintf("ambiguous key %s+%08x", e.name, e.hash)
}
// VerifierList returns a [Verifiers] implementation that uses the given list of verifiers.
func VerifierList(list ...Verifier) Verifiers {
m := make(verifierMap)
for _, v := range list {
k := nameHash{v.Name(), v.KeyHash()}
m[k] = append(m[k], v)
}
return m
}
type nameHash struct {
name string
hash uint32
}
type verifierMap map[nameHash][]Verifier
func (m verifierMap) Verifier(name string, hash uint32) (Verifier, error) {
v, ok := m[nameHash{name, hash}]
if !ok {
return nil, &UnknownVerifierError{name, hash}
}
if len(v) > 1 {
return nil, &ambiguousVerifierError{name, hash}
}
return v[0], nil
}
// A Note is a text and signatures.
type Note struct {
Text string // text of note
Sigs []Signature // verified signatures
UnverifiedSigs []Signature // unverified signatures
}
// A Signature is a single signature found in a note.
type Signature struct {
// Name and Hash give the name and key hash
// for the key that generated the signature.
Name string
Hash uint32
// Base64 records the base64-encoded signature bytes.
Base64 string
}
// An UnverifiedNoteError indicates that the note
// successfully parsed but had no verifiable signatures.
type UnverifiedNoteError struct {
Note *Note
}
func (e *UnverifiedNoteError) Error() string {
return "note has no verifiable signatures"
}
// An InvalidSignatureError indicates that the given key was known
// and the associated Verifier rejected the signature.
type InvalidSignatureError struct {
Name string
Hash uint32
}
func (e *InvalidSignatureError) Error() string {
return fmt.Sprintf("invalid signature for key %s+%08x", e.Name, e.Hash)
}
var (
errMalformedNote = errors.New("malformed note")
errInvalidSigner = errors.New("invalid signer")
errMismatchedVerifier = errors.New("verifier name or hash doesn't match signature")
sigSplit = []byte("\n\n")
sigPrefix = []byte("β ")
)
// Open opens and parses the message msg, checking signatures from the known verifiers.
//
// For each signature in the message, Open calls known.Verifier to find a verifier.
// If known.Verifier returns a verifier and the verifier accepts the signature,
// Open records the signature in the returned note's Sigs field.
// If known.Verifier returns a verifier but the verifier rejects the signature,
// Open returns an InvalidSignatureError.
// If known.Verifier returns an UnknownVerifierError,
// Open records the signature in the returned note's UnverifiedSigs field.
// If known.Verifier returns any other error, Open returns that error.
//
// If no known verifier has signed an otherwise valid note,
// Open returns an [UnverifiedNoteError].
// In this case, the unverified note can be fetched from inside the error.
func Open(msg []byte, known Verifiers) (*Note, error) {
if known == nil {
// Treat nil Verifiers as empty list, to produce useful error instead of crash.
known = VerifierList()
}
// Must have valid UTF-8 with no non-newline ASCII control characters.
for i := 0; i < len(msg); {
r, size := utf8.DecodeRune(msg[i:])
if r < 0x20 && r != '\n' || r == utf8.RuneError && size == 1 {
return nil, errMalformedNote
}
i += size
}
// Must end with signature block preceded by blank line.
split := bytes.LastIndex(msg, sigSplit)
if split < 0 {
return nil, errMalformedNote
}
text, sigs := msg[:split+1], msg[split+2:]
if len(sigs) == 0 || sigs[len(sigs)-1] != '\n' {
return nil, errMalformedNote
}
n := &Note{
Text: string(text),
}
// Parse and verify signatures.
// Ignore duplicate signatures.
seen := make(map[nameHash]bool)
seenUnverified := make(map[string]bool)
numSig := 0
for len(sigs) > 0 {
// Pull out next signature line.
// We know sigs[len(sigs)-1] == '\n', so IndexByte always finds one.
i := bytes.IndexByte(sigs, '\n')
line := sigs[:i]
sigs = sigs[i+1:]
if !bytes.HasPrefix(line, sigPrefix) {
return nil, errMalformedNote
}
line = line[len(sigPrefix):]
name, b64 := chop(string(line), " ")
sig, err := base64.StdEncoding.DecodeString(b64)
if err != nil || !isValidName(name) || b64 == "" || len(sig) < 5 {
return nil, errMalformedNote
}
hash := binary.BigEndian.Uint32(sig[0:4])
sig = sig[4:]
if numSig++; numSig > 100 {
// Avoid spending forever parsing a note with many signatures.
return nil, errMalformedNote
}
v, err := known.Verifier(name, hash)
if _, ok := err.(*UnknownVerifierError); ok {
// Drop repeated identical unverified signatures.
if seenUnverified[string(line)] {
continue
}
seenUnverified[string(line)] = true
n.UnverifiedSigs = append(n.UnverifiedSigs, Signature{Name: name, Hash: hash, Base64: b64})
continue
}
if err != nil {
return nil, err
}
// Check that known.Verifier returned the right verifier.
if v.Name() != name || v.KeyHash() != hash {
return nil, errMismatchedVerifier
}
// Drop repeated signatures by a single verifier.
if seen[nameHash{name, hash}] {
continue
}
seen[nameHash{name, hash}] = true
ok := v.Verify(text, sig)
if !ok {
return nil, &InvalidSignatureError{name, hash}
}
n.Sigs = append(n.Sigs, Signature{Name: name, Hash: hash, Base64: b64})
}
// Parsed and verified all the signatures.
if len(n.Sigs) == 0 {
return nil, &UnverifiedNoteError{n}
}
return n, nil
}
// Sign signs the note with the given signers and returns the encoded message.
// The new signatures from signers are listed in the encoded message after
// the existing signatures already present in n.Sigs.
// If any signer uses the same key as an existing signature,
// the existing signature is elided from the output.
func Sign(n *Note, signers ...Signer) ([]byte, error) {
var buf bytes.Buffer
if !strings.HasSuffix(n.Text, "\n") {
return nil, errMalformedNote
}
buf.WriteString(n.Text)
// Prepare signatures.
var sigs bytes.Buffer
have := make(map[nameHash]bool)
for _, s := range signers {
name := s.Name()
hash := s.KeyHash()
have[nameHash{name, hash}] = true
if !isValidName(name) {
return nil, errInvalidSigner
}
sig, err := s.Sign(buf.Bytes()) // buf holds n.Text
if err != nil {
return nil, err
}
var hbuf [4]byte
binary.BigEndian.PutUint32(hbuf[:], hash)
b64 := base64.StdEncoding.EncodeToString(append(hbuf[:], sig...))
sigs.WriteString("β ")
sigs.WriteString(name)
sigs.WriteString(" ")
sigs.WriteString(b64)
sigs.WriteString("\n")
}
buf.WriteString("\n")
// Emit existing signatures not replaced by new ones.
for _, list := range [][]Signature{n.Sigs, n.UnverifiedSigs} {
for _, sig := range list {
name, hash := sig.Name, sig.Hash
if !isValidName(name) {
return nil, errMalformedNote
}
if have[nameHash{name, hash}] {
continue
}
// Double-check hash against base64.
raw, err := base64.StdEncoding.DecodeString(sig.Base64)
if err != nil || len(raw) < 4 || binary.BigEndian.Uint32(raw) != hash {
return nil, errMalformedNote
}
buf.WriteString("β ")
buf.WriteString(sig.Name)
buf.WriteString(" ")
buf.WriteString(sig.Base64)
buf.WriteString("\n")
}
}
buf.Write(sigs.Bytes())
return buf.Bytes(), nil
}
|
go/src/cmd/vendor/golang.org/x/mod/sumdb/note/note.go/0
|
{
"file_path": "go/src/cmd/vendor/golang.org/x/mod/sumdb/note/note.go",
"repo_id": "go",
"token_count": 7249
}
| 181 |
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Plan 9 system calls.
// This file is compiled as ordinary Go code,
// but it is also input to mksyscall,
// which parses the //sys lines and generates system call stubs.
// Note that sometimes we use a lowercase //sys name and
// wrap it in our own nicer implementation.
package plan9
import (
"bytes"
"syscall"
"unsafe"
)
// A Note is a string describing a process note.
// It implements the os.Signal interface.
type Note string
func (n Note) Signal() {}
func (n Note) String() string {
return string(n)
}
var (
Stdin = 0
Stdout = 1
Stderr = 2
)
// For testing: clients can set this flag to force
// creation of IPv6 sockets to return EAFNOSUPPORT.
var SocketDisableIPv6 bool
func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.ErrorString)
func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.ErrorString)
func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr)
func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
func atoi(b []byte) (n uint) {
n = 0
for i := 0; i < len(b); i++ {
n = n*10 + uint(b[i]-'0')
}
return
}
func cstring(s []byte) string {
i := bytes.IndexByte(s, 0)
if i == -1 {
i = len(s)
}
return string(s[:i])
}
func errstr() string {
var buf [ERRMAX]byte
RawSyscall(SYS_ERRSTR, uintptr(unsafe.Pointer(&buf[0])), uintptr(len(buf)), 0)
buf[len(buf)-1] = 0
return cstring(buf[:])
}
// Implemented in assembly to import from runtime.
func exit(code int)
func Exit(code int) { exit(code) }
func readnum(path string) (uint, error) {
var b [12]byte
fd, e := Open(path, O_RDONLY)
if e != nil {
return 0, e
}
defer Close(fd)
n, e := Pread(fd, b[:], 0)
if e != nil {
return 0, e
}
m := 0
for ; m < n && b[m] == ' '; m++ {
}
return atoi(b[m : n-1]), nil
}
func Getpid() (pid int) {
n, _ := readnum("#c/pid")
return int(n)
}
func Getppid() (ppid int) {
n, _ := readnum("#c/ppid")
return int(n)
}
func Read(fd int, p []byte) (n int, err error) {
return Pread(fd, p, -1)
}
func Write(fd int, p []byte) (n int, err error) {
return Pwrite(fd, p, -1)
}
var ioSync int64
//sys fd2path(fd int, buf []byte) (err error)
func Fd2path(fd int) (path string, err error) {
var buf [512]byte
e := fd2path(fd, buf[:])
if e != nil {
return "", e
}
return cstring(buf[:]), nil
}
//sys pipe(p *[2]int32) (err error)
func Pipe(p []int) (err error) {
if len(p) != 2 {
return syscall.ErrorString("bad arg in system call")
}
var pp [2]int32
err = pipe(&pp)
if err == nil {
p[0] = int(pp[0])
p[1] = int(pp[1])
}
return
}
// Underlying system call writes to newoffset via pointer.
// Implemented in assembly to avoid allocation.
func seek(placeholder uintptr, fd int, offset int64, whence int) (newoffset int64, err string)
func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
newoffset, e := seek(0, fd, offset, whence)
if newoffset == -1 {
err = syscall.ErrorString(e)
}
return
}
func Mkdir(path string, mode uint32) (err error) {
fd, err := Create(path, O_RDONLY, DMDIR|mode)
if fd != -1 {
Close(fd)
}
return
}
type Waitmsg struct {
Pid int
Time [3]uint32
Msg string
}
func (w Waitmsg) Exited() bool { return true }
func (w Waitmsg) Signaled() bool { return false }
func (w Waitmsg) ExitStatus() int {
if len(w.Msg) == 0 {
// a normal exit returns no message
return 0
}
return 1
}
//sys await(s []byte) (n int, err error)
func Await(w *Waitmsg) (err error) {
var buf [512]byte
var f [5][]byte
n, err := await(buf[:])
if err != nil || w == nil {
return
}
nf := 0
p := 0
for i := 0; i < n && nf < len(f)-1; i++ {
if buf[i] == ' ' {
f[nf] = buf[p:i]
p = i + 1
nf++
}
}
f[nf] = buf[p:]
nf++
if nf != len(f) {
return syscall.ErrorString("invalid wait message")
}
w.Pid = int(atoi(f[0]))
w.Time[0] = uint32(atoi(f[1]))
w.Time[1] = uint32(atoi(f[2]))
w.Time[2] = uint32(atoi(f[3]))
w.Msg = cstring(f[4])
if w.Msg == "''" {
// await() returns '' for no error
w.Msg = ""
}
return
}
func Unmount(name, old string) (err error) {
fixwd()
oldp, err := BytePtrFromString(old)
if err != nil {
return err
}
oldptr := uintptr(unsafe.Pointer(oldp))
var r0 uintptr
var e syscall.ErrorString
// bind(2) man page: If name is zero, everything bound or mounted upon old is unbound or unmounted.
if name == "" {
r0, _, e = Syscall(SYS_UNMOUNT, _zero, oldptr, 0)
} else {
namep, err := BytePtrFromString(name)
if err != nil {
return err
}
r0, _, e = Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(namep)), oldptr, 0)
}
if int32(r0) == -1 {
err = e
}
return
}
func Fchdir(fd int) (err error) {
path, err := Fd2path(fd)
if err != nil {
return
}
return Chdir(path)
}
type Timespec struct {
Sec int32
Nsec int32
}
type Timeval struct {
Sec int32
Usec int32
}
func NsecToTimeval(nsec int64) (tv Timeval) {
nsec += 999 // round up to microsecond
tv.Usec = int32(nsec % 1e9 / 1e3)
tv.Sec = int32(nsec / 1e9)
return
}
func nsec() int64 {
var scratch int64
r0, _, _ := Syscall(SYS_NSEC, uintptr(unsafe.Pointer(&scratch)), 0, 0)
// TODO(aram): remove hack after I fix _nsec in the pc64 kernel.
if r0 == 0 {
return scratch
}
return int64(r0)
}
func Gettimeofday(tv *Timeval) error {
nsec := nsec()
*tv = NsecToTimeval(nsec)
return nil
}
func Getpagesize() int { return 0x1000 }
func Getegid() (egid int) { return -1 }
func Geteuid() (euid int) { return -1 }
func Getgid() (gid int) { return -1 }
func Getuid() (uid int) { return -1 }
func Getgroups() (gids []int, err error) {
return make([]int, 0), nil
}
//sys open(path string, mode int) (fd int, err error)
func Open(path string, mode int) (fd int, err error) {
fixwd()
return open(path, mode)
}
//sys create(path string, mode int, perm uint32) (fd int, err error)
func Create(path string, mode int, perm uint32) (fd int, err error) {
fixwd()
return create(path, mode, perm)
}
//sys remove(path string) (err error)
func Remove(path string) error {
fixwd()
return remove(path)
}
//sys stat(path string, edir []byte) (n int, err error)
func Stat(path string, edir []byte) (n int, err error) {
fixwd()
return stat(path, edir)
}
//sys bind(name string, old string, flag int) (err error)
func Bind(name string, old string, flag int) (err error) {
fixwd()
return bind(name, old, flag)
}
//sys mount(fd int, afd int, old string, flag int, aname string) (err error)
func Mount(fd int, afd int, old string, flag int, aname string) (err error) {
fixwd()
return mount(fd, afd, old, flag, aname)
}
//sys wstat(path string, edir []byte) (err error)
func Wstat(path string, edir []byte) (err error) {
fixwd()
return wstat(path, edir)
}
//sys chdir(path string) (err error)
//sys Dup(oldfd int, newfd int) (fd int, err error)
//sys Pread(fd int, p []byte, offset int64) (n int, err error)
//sys Pwrite(fd int, p []byte, offset int64) (n int, err error)
//sys Close(fd int) (err error)
//sys Fstat(fd int, edir []byte) (n int, err error)
//sys Fwstat(fd int, edir []byte) (err error)
|
go/src/cmd/vendor/golang.org/x/sys/plan9/syscall_plan9.go/0
|
{
"file_path": "go/src/cmd/vendor/golang.org/x/sys/plan9/syscall_plan9.go",
"repo_id": "go",
"token_count": 3022
}
| 182 |
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build gc
#include "textflag.h"
//
// System calls for 386, Linux
//
// See ../runtime/sys_linux_386.s for the reason why we always use int 0x80
// instead of the glibc-specific "CALL 0x10(GS)".
#define INVOKE_SYSCALL INT $0x80
// Just jump to package syscall's implementation for all these functions.
// The runtime may know about them.
TEXT Β·Syscall(SB),NOSPLIT,$0-28
JMP syscallΒ·Syscall(SB)
TEXT Β·Syscall6(SB),NOSPLIT,$0-40
JMP syscallΒ·Syscall6(SB)
TEXT Β·SyscallNoError(SB),NOSPLIT,$0-24
CALL runtimeΒ·entersyscall(SB)
MOVL trap+0(FP), AX // syscall entry
MOVL a1+4(FP), BX
MOVL a2+8(FP), CX
MOVL a3+12(FP), DX
MOVL $0, SI
MOVL $0, DI
INVOKE_SYSCALL
MOVL AX, r1+16(FP)
MOVL DX, r2+20(FP)
CALL runtimeΒ·exitsyscall(SB)
RET
TEXT Β·RawSyscall(SB),NOSPLIT,$0-28
JMP syscallΒ·RawSyscall(SB)
TEXT Β·RawSyscall6(SB),NOSPLIT,$0-40
JMP syscallΒ·RawSyscall6(SB)
TEXT Β·RawSyscallNoError(SB),NOSPLIT,$0-24
MOVL trap+0(FP), AX // syscall entry
MOVL a1+4(FP), BX
MOVL a2+8(FP), CX
MOVL a3+12(FP), DX
MOVL $0, SI
MOVL $0, DI
INVOKE_SYSCALL
MOVL AX, r1+16(FP)
MOVL DX, r2+20(FP)
RET
TEXT Β·socketcall(SB),NOSPLIT,$0-36
JMP syscallΒ·socketcall(SB)
TEXT Β·rawsocketcall(SB),NOSPLIT,$0-36
JMP syscallΒ·rawsocketcall(SB)
TEXT Β·seek(SB),NOSPLIT,$0-28
JMP syscallΒ·seek(SB)
|
go/src/cmd/vendor/golang.org/x/sys/unix/asm_linux_386.s/0
|
{
"file_path": "go/src/cmd/vendor/golang.org/x/sys/unix/asm_linux_386.s",
"repo_id": "go",
"token_count": 704
}
| 183 |
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build freebsd
package unix
import (
"errors"
"fmt"
)
// Go implementation of C mostly found in /usr/src/sys/kern/subr_capability.c
const (
// This is the version of CapRights this package understands. See C implementation for parallels.
capRightsGoVersion = CAP_RIGHTS_VERSION_00
capArSizeMin = CAP_RIGHTS_VERSION_00 + 2
capArSizeMax = capRightsGoVersion + 2
)
var (
bit2idx = []int{
-1, 0, 1, -1, 2, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1,
4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
}
)
func capidxbit(right uint64) int {
return int((right >> 57) & 0x1f)
}
func rightToIndex(right uint64) (int, error) {
idx := capidxbit(right)
if idx < 0 || idx >= len(bit2idx) {
return -2, fmt.Errorf("index for right 0x%x out of range", right)
}
return bit2idx[idx], nil
}
func caprver(right uint64) int {
return int(right >> 62)
}
func capver(rights *CapRights) int {
return caprver(rights.Rights[0])
}
func caparsize(rights *CapRights) int {
return capver(rights) + 2
}
// CapRightsSet sets the permissions in setrights in rights.
func CapRightsSet(rights *CapRights, setrights []uint64) error {
// This is essentially a copy of cap_rights_vset()
if capver(rights) != CAP_RIGHTS_VERSION_00 {
return fmt.Errorf("bad rights version %d", capver(rights))
}
n := caparsize(rights)
if n < capArSizeMin || n > capArSizeMax {
return errors.New("bad rights size")
}
for _, right := range setrights {
if caprver(right) != CAP_RIGHTS_VERSION_00 {
return errors.New("bad right version")
}
i, err := rightToIndex(right)
if err != nil {
return err
}
if i >= n {
return errors.New("index overflow")
}
if capidxbit(rights.Rights[i]) != capidxbit(right) {
return errors.New("index mismatch")
}
rights.Rights[i] |= right
if capidxbit(rights.Rights[i]) != capidxbit(right) {
return errors.New("index mismatch (after assign)")
}
}
return nil
}
// CapRightsClear clears the permissions in clearrights from rights.
func CapRightsClear(rights *CapRights, clearrights []uint64) error {
// This is essentially a copy of cap_rights_vclear()
if capver(rights) != CAP_RIGHTS_VERSION_00 {
return fmt.Errorf("bad rights version %d", capver(rights))
}
n := caparsize(rights)
if n < capArSizeMin || n > capArSizeMax {
return errors.New("bad rights size")
}
for _, right := range clearrights {
if caprver(right) != CAP_RIGHTS_VERSION_00 {
return errors.New("bad right version")
}
i, err := rightToIndex(right)
if err != nil {
return err
}
if i >= n {
return errors.New("index overflow")
}
if capidxbit(rights.Rights[i]) != capidxbit(right) {
return errors.New("index mismatch")
}
rights.Rights[i] &= ^(right & 0x01FFFFFFFFFFFFFF)
if capidxbit(rights.Rights[i]) != capidxbit(right) {
return errors.New("index mismatch (after assign)")
}
}
return nil
}
// CapRightsIsSet checks whether all the permissions in setrights are present in rights.
func CapRightsIsSet(rights *CapRights, setrights []uint64) (bool, error) {
// This is essentially a copy of cap_rights_is_vset()
if capver(rights) != CAP_RIGHTS_VERSION_00 {
return false, fmt.Errorf("bad rights version %d", capver(rights))
}
n := caparsize(rights)
if n < capArSizeMin || n > capArSizeMax {
return false, errors.New("bad rights size")
}
for _, right := range setrights {
if caprver(right) != CAP_RIGHTS_VERSION_00 {
return false, errors.New("bad right version")
}
i, err := rightToIndex(right)
if err != nil {
return false, err
}
if i >= n {
return false, errors.New("index overflow")
}
if capidxbit(rights.Rights[i]) != capidxbit(right) {
return false, errors.New("index mismatch")
}
if (rights.Rights[i] & right) != right {
return false, nil
}
}
return true, nil
}
func capright(idx uint64, bit uint64) uint64 {
return ((1 << (57 + idx)) | bit)
}
// CapRightsInit returns a pointer to an initialised CapRights structure filled with rights.
// See man cap_rights_init(3) and rights(4).
func CapRightsInit(rights []uint64) (*CapRights, error) {
var r CapRights
r.Rights[0] = (capRightsGoVersion << 62) | capright(0, 0)
r.Rights[1] = capright(1, 0)
err := CapRightsSet(&r, rights)
if err != nil {
return nil, err
}
return &r, nil
}
// CapRightsLimit reduces the operations permitted on fd to at most those contained in rights.
// The capability rights on fd can never be increased by CapRightsLimit.
// See man cap_rights_limit(2) and rights(4).
func CapRightsLimit(fd uintptr, rights *CapRights) error {
return capRightsLimit(int(fd), rights)
}
// CapRightsGet returns a CapRights structure containing the operations permitted on fd.
// See man cap_rights_get(3) and rights(4).
func CapRightsGet(fd uintptr) (*CapRights, error) {
r, err := CapRightsInit(nil)
if err != nil {
return nil, err
}
err = capRightsGet(capRightsGoVersion, int(fd), r)
if err != nil {
return nil, err
}
return r, nil
}
|
go/src/cmd/vendor/golang.org/x/sys/unix/cap_freebsd.go/0
|
{
"file_path": "go/src/cmd/vendor/golang.org/x/sys/unix/cap_freebsd.go",
"repo_id": "go",
"token_count": 1961
}
| 184 |
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package unix
import "unsafe"
// FcntlInt performs a fcntl syscall on fd with the provided command and argument.
func FcntlInt(fd uintptr, cmd, arg int) (int, error) {
return fcntl(int(fd), cmd, arg)
}
// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
_, err := fcntl(int(fd), cmd, int(uintptr(unsafe.Pointer(lk))))
return err
}
// FcntlFstore performs a fcntl syscall for the F_PREALLOCATE command.
func FcntlFstore(fd uintptr, cmd int, fstore *Fstore_t) error {
_, err := fcntl(int(fd), cmd, int(uintptr(unsafe.Pointer(fstore))))
return err
}
|
go/src/cmd/vendor/golang.org/x/sys/unix/fcntl_darwin.go/0
|
{
"file_path": "go/src/cmd/vendor/golang.org/x/sys/unix/fcntl_darwin.go",
"repo_id": "go",
"token_count": 314
}
| 185 |
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package unix
import (
"errors"
"fmt"
"strconv"
)
// Pledge implements the pledge syscall.
//
// This changes both the promises and execpromises; use PledgePromises or
// PledgeExecpromises to only change the promises or execpromises
// respectively.
//
// For more information see pledge(2).
func Pledge(promises, execpromises string) error {
if err := pledgeAvailable(); err != nil {
return err
}
pptr, err := BytePtrFromString(promises)
if err != nil {
return err
}
exptr, err := BytePtrFromString(execpromises)
if err != nil {
return err
}
return pledge(pptr, exptr)
}
// PledgePromises implements the pledge syscall.
//
// This changes the promises and leaves the execpromises untouched.
//
// For more information see pledge(2).
func PledgePromises(promises string) error {
if err := pledgeAvailable(); err != nil {
return err
}
pptr, err := BytePtrFromString(promises)
if err != nil {
return err
}
return pledge(pptr, nil)
}
// PledgeExecpromises implements the pledge syscall.
//
// This changes the execpromises and leaves the promises untouched.
//
// For more information see pledge(2).
func PledgeExecpromises(execpromises string) error {
if err := pledgeAvailable(); err != nil {
return err
}
exptr, err := BytePtrFromString(execpromises)
if err != nil {
return err
}
return pledge(nil, exptr)
}
// majmin returns major and minor version number for an OpenBSD system.
func majmin() (major int, minor int, err error) {
var v Utsname
err = Uname(&v)
if err != nil {
return
}
major, err = strconv.Atoi(string(v.Release[0]))
if err != nil {
err = errors.New("cannot parse major version number returned by uname")
return
}
minor, err = strconv.Atoi(string(v.Release[2]))
if err != nil {
err = errors.New("cannot parse minor version number returned by uname")
return
}
return
}
// pledgeAvailable checks for availability of the pledge(2) syscall
// based on the running OpenBSD version.
func pledgeAvailable() error {
maj, min, err := majmin()
if err != nil {
return err
}
// Require OpenBSD 6.4 as a minimum.
if maj < 6 || (maj == 6 && min <= 3) {
return fmt.Errorf("cannot call Pledge on OpenBSD %d.%d", maj, min)
}
return nil
}
|
go/src/cmd/vendor/golang.org/x/sys/unix/pledge_openbsd.go/0
|
{
"file_path": "go/src/cmd/vendor/golang.org/x/sys/unix/pledge_openbsd.go",
"repo_id": "go",
"token_count": 780
}
| 186 |
// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build aix && ppc64
package unix
//sysnb Getrlimit(resource int, rlim *Rlimit) (err error)
//sys Seek(fd int, offset int64, whence int) (off int64, err error) = lseek
//sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) = mmap64
func setTimespec(sec, nsec int64) Timespec {
return Timespec{Sec: sec, Nsec: nsec}
}
func setTimeval(sec, usec int64) Timeval {
return Timeval{Sec: int64(sec), Usec: int32(usec)}
}
func (iov *Iovec) SetLen(length int) {
iov.Len = uint64(length)
}
func (msghdr *Msghdr) SetControllen(length int) {
msghdr.Controllen = uint32(length)
}
func (msghdr *Msghdr) SetIovlen(length int) {
msghdr.Iovlen = int32(length)
}
func (cmsg *Cmsghdr) SetLen(length int) {
cmsg.Len = uint32(length)
}
// In order to only have Timespec structure, type of Stat_t's fields
// Atim, Mtim and Ctim is changed from StTimespec to Timespec during
// ztypes generation.
// On ppc64, Timespec.Nsec is an int64 while StTimespec.Nsec is an
// int32, so the fields' value must be modified.
func fixStatTimFields(stat *Stat_t) {
stat.Atim.Nsec >>= 32
stat.Mtim.Nsec >>= 32
stat.Ctim.Nsec >>= 32
}
func Fstat(fd int, stat *Stat_t) error {
err := fstat(fd, stat)
if err != nil {
return err
}
fixStatTimFields(stat)
return nil
}
func Fstatat(dirfd int, path string, stat *Stat_t, flags int) error {
err := fstatat(dirfd, path, stat, flags)
if err != nil {
return err
}
fixStatTimFields(stat)
return nil
}
func Lstat(path string, stat *Stat_t) error {
err := lstat(path, stat)
if err != nil {
return err
}
fixStatTimFields(stat)
return nil
}
func Stat(path string, statptr *Stat_t) error {
err := stat(path, statptr)
if err != nil {
return err
}
fixStatTimFields(statptr)
return nil
}
|
go/src/cmd/vendor/golang.org/x/sys/unix/syscall_aix_ppc64.go/0
|
{
"file_path": "go/src/cmd/vendor/golang.org/x/sys/unix/syscall_aix_ppc64.go",
"repo_id": "go",
"token_count": 754
}
| 187 |
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// illumos system calls not present on Solaris.
//go:build amd64 && illumos
package unix
import (
"unsafe"
)
func bytes2iovec(bs [][]byte) []Iovec {
iovecs := make([]Iovec, len(bs))
for i, b := range bs {
iovecs[i].SetLen(len(b))
if len(b) > 0 {
iovecs[i].Base = &b[0]
} else {
iovecs[i].Base = (*byte)(unsafe.Pointer(&_zero))
}
}
return iovecs
}
//sys readv(fd int, iovs []Iovec) (n int, err error)
func Readv(fd int, iovs [][]byte) (n int, err error) {
iovecs := bytes2iovec(iovs)
n, err = readv(fd, iovecs)
return n, err
}
//sys preadv(fd int, iovs []Iovec, off int64) (n int, err error)
func Preadv(fd int, iovs [][]byte, off int64) (n int, err error) {
iovecs := bytes2iovec(iovs)
n, err = preadv(fd, iovecs, off)
return n, err
}
//sys writev(fd int, iovs []Iovec) (n int, err error)
func Writev(fd int, iovs [][]byte) (n int, err error) {
iovecs := bytes2iovec(iovs)
n, err = writev(fd, iovecs)
return n, err
}
//sys pwritev(fd int, iovs []Iovec, off int64) (n int, err error)
func Pwritev(fd int, iovs [][]byte, off int64) (n int, err error) {
iovecs := bytes2iovec(iovs)
n, err = pwritev(fd, iovecs, off)
return n, err
}
//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) = libsocket.accept4
func Accept4(fd int, flags int) (nfd int, sa Sockaddr, err error) {
var rsa RawSockaddrAny
var len _Socklen = SizeofSockaddrAny
nfd, err = accept4(fd, &rsa, &len, flags)
if err != nil {
return
}
if len > SizeofSockaddrAny {
panic("RawSockaddrAny too small")
}
sa, err = anyToSockaddr(fd, &rsa)
if err != nil {
Close(nfd)
nfd = 0
}
return
}
|
go/src/cmd/vendor/golang.org/x/sys/unix/syscall_illumos.go/0
|
{
"file_path": "go/src/cmd/vendor/golang.org/x/sys/unix/syscall_illumos.go",
"repo_id": "go",
"token_count": 804
}
| 188 |
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build linux && ppc
package unix
import (
"syscall"
"unsafe"
)
//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
//sys Fchown(fd int, uid int, gid int) (err error)
//sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64
//sys Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64
//sys Ftruncate(fd int, length int64) (err error) = SYS_FTRUNCATE64
//sysnb Getegid() (egid int)
//sysnb Geteuid() (euid int)
//sysnb Getgid() (gid int)
//sysnb Getuid() (uid int)
//sys Ioperm(from int, num int, on int) (err error)
//sys Iopl(level int) (err error)
//sys Lchown(path string, uid int, gid int) (err error)
//sys Listen(s int, n int) (err error)
//sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64
//sys Pause() (err error)
//sys pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
//sys pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
//sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error)
//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS__NEWSELECT
//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) = SYS_SENDFILE64
//sys setfsgid(gid int) (prev int, err error)
//sys setfsuid(uid int) (prev int, err error)
//sys Shutdown(fd int, how int) (err error)
//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error)
//sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64
//sys Truncate(path string, length int64) (err error) = SYS_TRUNCATE64
//sys Ustat(dev int, ubuf *Ustat_t) (err error)
//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
//sysnb getgroups(n int, list *_Gid_t) (nn int, err error)
//sysnb setgroups(n int, list *_Gid_t) (err error)
//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
//sysnb socket(domain int, typ int, proto int) (fd int, err error)
//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
//sys futimesat(dirfd int, path string, times *[2]Timeval) (err error)
//sysnb Gettimeofday(tv *Timeval) (err error)
//sysnb Time(t *Time_t) (tt Time_t, err error)
//sys Utime(path string, buf *Utimbuf) (err error)
//sys utimes(path string, times *[2]Timeval) (err error)
func Fadvise(fd int, offset int64, length int64, advice int) (err error) {
_, _, e1 := Syscall6(SYS_FADVISE64_64, uintptr(fd), uintptr(advice), uintptr(offset>>32), uintptr(offset), uintptr(length>>32), uintptr(length))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
func seek(fd int, offset int64, whence int) (int64, syscall.Errno) {
var newoffset int64
offsetLow := uint32(offset & 0xffffffff)
offsetHigh := uint32((offset >> 32) & 0xffffffff)
_, _, err := Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offsetHigh), uintptr(offsetLow), uintptr(unsafe.Pointer(&newoffset)), uintptr(whence), 0)
return newoffset, err
}
func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
newoffset, errno := seek(fd, offset, whence)
if errno != 0 {
return 0, errno
}
return newoffset, nil
}
func Fstatfs(fd int, buf *Statfs_t) (err error) {
_, _, e := Syscall(SYS_FSTATFS64, uintptr(fd), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf)))
if e != 0 {
err = e
}
return
}
func Statfs(path string, buf *Statfs_t) (err error) {
pathp, err := BytePtrFromString(path)
if err != nil {
return err
}
_, _, e := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(pathp)), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf)))
if e != 0 {
err = e
}
return
}
//sys mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error)
func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) {
page := uintptr(offset / 4096)
if offset != int64(page)*4096 {
return 0, EINVAL
}
return mmap2(addr, length, prot, flags, fd, page)
}
func setTimespec(sec, nsec int64) Timespec {
return Timespec{Sec: int32(sec), Nsec: int32(nsec)}
}
func setTimeval(sec, usec int64) Timeval {
return Timeval{Sec: int32(sec), Usec: int32(usec)}
}
type rlimit32 struct {
Cur uint32
Max uint32
}
//sysnb getrlimit(resource int, rlim *rlimit32) (err error) = SYS_UGETRLIMIT
const rlimInf32 = ^uint32(0)
const rlimInf64 = ^uint64(0)
func Getrlimit(resource int, rlim *Rlimit) (err error) {
err = Prlimit(0, resource, nil, rlim)
if err != ENOSYS {
return err
}
rl := rlimit32{}
err = getrlimit(resource, &rl)
if err != nil {
return
}
if rl.Cur == rlimInf32 {
rlim.Cur = rlimInf64
} else {
rlim.Cur = uint64(rl.Cur)
}
if rl.Max == rlimInf32 {
rlim.Max = rlimInf64
} else {
rlim.Max = uint64(rl.Max)
}
return
}
func (r *PtraceRegs) PC() uint32 { return r.Nip }
func (r *PtraceRegs) SetPC(pc uint32) { r.Nip = pc }
func (iov *Iovec) SetLen(length int) {
iov.Len = uint32(length)
}
func (msghdr *Msghdr) SetControllen(length int) {
msghdr.Controllen = uint32(length)
}
func (msghdr *Msghdr) SetIovlen(length int) {
msghdr.Iovlen = uint32(length)
}
func (cmsg *Cmsghdr) SetLen(length int) {
cmsg.Len = uint32(length)
}
func (rsa *RawSockaddrNFCLLCP) SetServiceNameLen(length int) {
rsa.Service_name_len = uint32(length)
}
//sys syncFileRange2(fd int, flags int, off int64, n int64) (err error) = SYS_SYNC_FILE_RANGE2
func SyncFileRange(fd int, off int64, n int64, flags int) error {
// The sync_file_range and sync_file_range2 syscalls differ only in the
// order of their arguments.
return syncFileRange2(fd, flags, off, n)
}
//sys kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error)
func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error {
cmdlineLen := len(cmdline)
if cmdlineLen > 0 {
// Account for the additional NULL byte added by
// BytePtrFromString in kexecFileLoad. The kexec_file_load
// syscall expects a NULL-terminated string.
cmdlineLen++
}
return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags)
}
|
go/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_ppc.go/0
|
{
"file_path": "go/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_ppc.go",
"repo_id": "go",
"token_count": 2830
}
| 189 |
// go run mksyscall.go -tags darwin,amd64 syscall_bsd.go syscall_darwin.go syscall_darwin_amd64.go
// Code generated by the command above; see README.md. DO NOT EDIT.
//go:build darwin && amd64
package unix
import (
"syscall"
"unsafe"
)
var _ syscall.Errno
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func getgroups(ngid int, gid *_Gid_t) (n int, err error) {
r0, _, e1 := syscall_rawSyscall(libc_getgroups_trampoline_addr, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_getgroups_trampoline_addr uintptr
//go:cgo_import_dynamic libc_getgroups getgroups "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func setgroups(ngid int, gid *_Gid_t) (err error) {
_, _, e1 := syscall_rawSyscall(libc_setgroups_trampoline_addr, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_setgroups_trampoline_addr uintptr
//go:cgo_import_dynamic libc_setgroups setgroups "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
r0, _, e1 := syscall_syscall6(libc_wait4_trampoline_addr, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
wpid = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_wait4_trampoline_addr uintptr
//go:cgo_import_dynamic libc_wait4 wait4 "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
r0, _, e1 := syscall_syscall(libc_accept_trampoline_addr, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_accept_trampoline_addr uintptr
//go:cgo_import_dynamic libc_accept accept "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
_, _, e1 := syscall_syscall(libc_bind_trampoline_addr, uintptr(s), uintptr(addr), uintptr(addrlen))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_bind_trampoline_addr uintptr
//go:cgo_import_dynamic libc_bind bind "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
_, _, e1 := syscall_syscall(libc_connect_trampoline_addr, uintptr(s), uintptr(addr), uintptr(addrlen))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_connect_trampoline_addr uintptr
//go:cgo_import_dynamic libc_connect connect "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func socket(domain int, typ int, proto int) (fd int, err error) {
r0, _, e1 := syscall_rawSyscall(libc_socket_trampoline_addr, uintptr(domain), uintptr(typ), uintptr(proto))
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_socket_trampoline_addr uintptr
//go:cgo_import_dynamic libc_socket socket "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
_, _, e1 := syscall_syscall6(libc_getsockopt_trampoline_addr, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_getsockopt_trampoline_addr uintptr
//go:cgo_import_dynamic libc_getsockopt getsockopt "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
_, _, e1 := syscall_syscall6(libc_setsockopt_trampoline_addr, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_setsockopt_trampoline_addr uintptr
//go:cgo_import_dynamic libc_setsockopt setsockopt "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
_, _, e1 := syscall_rawSyscall(libc_getpeername_trampoline_addr, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_getpeername_trampoline_addr uintptr
//go:cgo_import_dynamic libc_getpeername getpeername "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
_, _, e1 := syscall_rawSyscall(libc_getsockname_trampoline_addr, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_getsockname_trampoline_addr uintptr
//go:cgo_import_dynamic libc_getsockname getsockname "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Shutdown(s int, how int) (err error) {
_, _, e1 := syscall_syscall(libc_shutdown_trampoline_addr, uintptr(s), uintptr(how), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_shutdown_trampoline_addr uintptr
//go:cgo_import_dynamic libc_shutdown shutdown "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
_, _, e1 := syscall_rawSyscall6(libc_socketpair_trampoline_addr, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_socketpair_trampoline_addr uintptr
//go:cgo_import_dynamic libc_socketpair socketpair "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
var _p0 unsafe.Pointer
if len(p) > 0 {
_p0 = unsafe.Pointer(&p[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall6(libc_recvfrom_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_recvfrom_trampoline_addr uintptr
//go:cgo_import_dynamic libc_recvfrom recvfrom "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
var _p0 unsafe.Pointer
if len(buf) > 0 {
_p0 = unsafe.Pointer(&buf[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
_, _, e1 := syscall_syscall6(libc_sendto_trampoline_addr, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_sendto_trampoline_addr uintptr
//go:cgo_import_dynamic libc_sendto sendto "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
r0, _, e1 := syscall_syscall(libc_recvmsg_trampoline_addr, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_recvmsg_trampoline_addr uintptr
//go:cgo_import_dynamic libc_recvmsg recvmsg "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
r0, _, e1 := syscall_syscall(libc_sendmsg_trampoline_addr, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_sendmsg_trampoline_addr uintptr
//go:cgo_import_dynamic libc_sendmsg sendmsg "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) {
r0, _, e1 := syscall_syscall6(libc_kevent_trampoline_addr, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_kevent_trampoline_addr uintptr
//go:cgo_import_dynamic libc_kevent kevent "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func utimes(path string, timeval *[2]Timeval) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := syscall_syscall(libc_utimes_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_utimes_trampoline_addr uintptr
//go:cgo_import_dynamic libc_utimes utimes "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func futimes(fd int, timeval *[2]Timeval) (err error) {
_, _, e1 := syscall_syscall(libc_futimes_trampoline_addr, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_futimes_trampoline_addr uintptr
//go:cgo_import_dynamic libc_futimes futimes "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
r0, _, e1 := syscall_syscall(libc_poll_trampoline_addr, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_poll_trampoline_addr uintptr
//go:cgo_import_dynamic libc_poll poll "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Madvise(b []byte, behav int) (err error) {
var _p0 unsafe.Pointer
if len(b) > 0 {
_p0 = unsafe.Pointer(&b[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
_, _, e1 := syscall_syscall(libc_madvise_trampoline_addr, uintptr(_p0), uintptr(len(b)), uintptr(behav))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_madvise_trampoline_addr uintptr
//go:cgo_import_dynamic libc_madvise madvise "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mlock(b []byte) (err error) {
var _p0 unsafe.Pointer
if len(b) > 0 {
_p0 = unsafe.Pointer(&b[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
_, _, e1 := syscall_syscall(libc_mlock_trampoline_addr, uintptr(_p0), uintptr(len(b)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_mlock_trampoline_addr uintptr
//go:cgo_import_dynamic libc_mlock mlock "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mlockall(flags int) (err error) {
_, _, e1 := syscall_syscall(libc_mlockall_trampoline_addr, uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_mlockall_trampoline_addr uintptr
//go:cgo_import_dynamic libc_mlockall mlockall "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mprotect(b []byte, prot int) (err error) {
var _p0 unsafe.Pointer
if len(b) > 0 {
_p0 = unsafe.Pointer(&b[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
_, _, e1 := syscall_syscall(libc_mprotect_trampoline_addr, uintptr(_p0), uintptr(len(b)), uintptr(prot))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_mprotect_trampoline_addr uintptr
//go:cgo_import_dynamic libc_mprotect mprotect "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Msync(b []byte, flags int) (err error) {
var _p0 unsafe.Pointer
if len(b) > 0 {
_p0 = unsafe.Pointer(&b[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
_, _, e1 := syscall_syscall(libc_msync_trampoline_addr, uintptr(_p0), uintptr(len(b)), uintptr(flags))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_msync_trampoline_addr uintptr
//go:cgo_import_dynamic libc_msync msync "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Munlock(b []byte) (err error) {
var _p0 unsafe.Pointer
if len(b) > 0 {
_p0 = unsafe.Pointer(&b[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
_, _, e1 := syscall_syscall(libc_munlock_trampoline_addr, uintptr(_p0), uintptr(len(b)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_munlock_trampoline_addr uintptr
//go:cgo_import_dynamic libc_munlock munlock "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Munlockall() (err error) {
_, _, e1 := syscall_syscall(libc_munlockall_trampoline_addr, 0, 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_munlockall_trampoline_addr uintptr
//go:cgo_import_dynamic libc_munlockall munlockall "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func closedir(dir uintptr) (err error) {
_, _, e1 := syscall_syscall(libc_closedir_trampoline_addr, uintptr(dir), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_closedir_trampoline_addr uintptr
//go:cgo_import_dynamic libc_closedir closedir "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func readdir_r(dir uintptr, entry *Dirent, result **Dirent) (res Errno) {
r0, _, _ := syscall_syscall(libc_readdir_r_trampoline_addr, uintptr(dir), uintptr(unsafe.Pointer(entry)), uintptr(unsafe.Pointer(result)))
res = Errno(r0)
return
}
var libc_readdir_r_trampoline_addr uintptr
//go:cgo_import_dynamic libc_readdir_r readdir_r "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func pipe(p *[2]int32) (err error) {
_, _, e1 := syscall_rawSyscall(libc_pipe_trampoline_addr, uintptr(unsafe.Pointer(p)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_pipe_trampoline_addr uintptr
//go:cgo_import_dynamic libc_pipe pipe "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func getxattr(path string, attr string, dest *byte, size int, position uint32, options int) (sz int, err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
var _p1 *byte
_p1, err = BytePtrFromString(attr)
if err != nil {
return
}
r0, _, e1 := syscall_syscall6(libc_getxattr_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(position), uintptr(options))
sz = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_getxattr_trampoline_addr uintptr
//go:cgo_import_dynamic libc_getxattr getxattr "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func fgetxattr(fd int, attr string, dest *byte, size int, position uint32, options int) (sz int, err error) {
var _p0 *byte
_p0, err = BytePtrFromString(attr)
if err != nil {
return
}
r0, _, e1 := syscall_syscall6(libc_fgetxattr_trampoline_addr, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(position), uintptr(options))
sz = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_fgetxattr_trampoline_addr uintptr
//go:cgo_import_dynamic libc_fgetxattr fgetxattr "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func setxattr(path string, attr string, data *byte, size int, position uint32, options int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
var _p1 *byte
_p1, err = BytePtrFromString(attr)
if err != nil {
return
}
_, _, e1 := syscall_syscall6(libc_setxattr_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(data)), uintptr(size), uintptr(position), uintptr(options))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_setxattr_trampoline_addr uintptr
//go:cgo_import_dynamic libc_setxattr setxattr "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func fsetxattr(fd int, attr string, data *byte, size int, position uint32, options int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(attr)
if err != nil {
return
}
_, _, e1 := syscall_syscall6(libc_fsetxattr_trampoline_addr, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(data)), uintptr(size), uintptr(position), uintptr(options))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_fsetxattr_trampoline_addr uintptr
//go:cgo_import_dynamic libc_fsetxattr fsetxattr "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func removexattr(path string, attr string, options int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
var _p1 *byte
_p1, err = BytePtrFromString(attr)
if err != nil {
return
}
_, _, e1 := syscall_syscall(libc_removexattr_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_removexattr_trampoline_addr uintptr
//go:cgo_import_dynamic libc_removexattr removexattr "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func fremovexattr(fd int, attr string, options int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(attr)
if err != nil {
return
}
_, _, e1 := syscall_syscall(libc_fremovexattr_trampoline_addr, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(options))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_fremovexattr_trampoline_addr uintptr
//go:cgo_import_dynamic libc_fremovexattr fremovexattr "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func listxattr(path string, dest *byte, size int, options int) (sz int, err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
r0, _, e1 := syscall_syscall6(libc_listxattr_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(options), 0, 0)
sz = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_listxattr_trampoline_addr uintptr
//go:cgo_import_dynamic libc_listxattr listxattr "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func flistxattr(fd int, dest *byte, size int, options int) (sz int, err error) {
r0, _, e1 := syscall_syscall6(libc_flistxattr_trampoline_addr, uintptr(fd), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(options), 0, 0)
sz = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_flistxattr_trampoline_addr uintptr
//go:cgo_import_dynamic libc_flistxattr flistxattr "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := syscall_syscall6(libc_utimensat_trampoline_addr, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_utimensat_trampoline_addr uintptr
//go:cgo_import_dynamic libc_utimensat utimensat "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func fcntl(fd int, cmd int, arg int) (val int, err error) {
r0, _, e1 := syscall_syscall(libc_fcntl_trampoline_addr, uintptr(fd), uintptr(cmd), uintptr(arg))
val = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_fcntl_trampoline_addr uintptr
//go:cgo_import_dynamic libc_fcntl fcntl "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func kill(pid int, signum int, posix int) (err error) {
_, _, e1 := syscall_syscall(libc_kill_trampoline_addr, uintptr(pid), uintptr(signum), uintptr(posix))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_kill_trampoline_addr uintptr
//go:cgo_import_dynamic libc_kill kill "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ioctl(fd int, req uint, arg uintptr) (err error) {
_, _, e1 := syscall_syscall(libc_ioctl_trampoline_addr, uintptr(fd), uintptr(req), uintptr(arg))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_ioctl_trampoline_addr uintptr
//go:cgo_import_dynamic libc_ioctl ioctl "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) {
_, _, e1 := syscall_syscall(libc_ioctl_trampoline_addr, uintptr(fd), uintptr(req), uintptr(arg))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func renamexNp(from string, to string, flag uint32) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(from)
if err != nil {
return
}
var _p1 *byte
_p1, err = BytePtrFromString(to)
if err != nil {
return
}
_, _, e1 := syscall_syscall(libc_renamex_np_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flag))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_renamex_np_trampoline_addr uintptr
//go:cgo_import_dynamic libc_renamex_np renamex_np "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(from)
if err != nil {
return
}
var _p1 *byte
_p1, err = BytePtrFromString(to)
if err != nil {
return
}
_, _, e1 := syscall_syscall6(libc_renameatx_np_trampoline_addr, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), uintptr(flag), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_renameatx_np_trampoline_addr uintptr
//go:cgo_import_dynamic libc_renameatx_np renameatx_np "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) {
var _p0 unsafe.Pointer
if len(mib) > 0 {
_p0 = unsafe.Pointer(&mib[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
_, _, e1 := syscall_syscall6(libc_sysctl_trampoline_addr, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_sysctl_trampoline_addr uintptr
//go:cgo_import_dynamic libc_sysctl sysctl "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func pthread_chdir_np(path string) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := syscall_syscall(libc_pthread_chdir_np_trampoline_addr, uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_pthread_chdir_np_trampoline_addr uintptr
//go:cgo_import_dynamic libc_pthread_chdir_np pthread_chdir_np "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func pthread_fchdir_np(fd int) (err error) {
_, _, e1 := syscall_syscall(libc_pthread_fchdir_np_trampoline_addr, uintptr(fd), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_pthread_fchdir_np_trampoline_addr uintptr
//go:cgo_import_dynamic libc_pthread_fchdir_np pthread_fchdir_np "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error) {
_, _, e1 := syscall_syscall6(libc_sendfile_trampoline_addr, uintptr(infd), uintptr(outfd), uintptr(offset), uintptr(unsafe.Pointer(len)), uintptr(hdtr), uintptr(flags))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_sendfile_trampoline_addr uintptr
//go:cgo_import_dynamic libc_sendfile sendfile "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func shmat(id int, addr uintptr, flag int) (ret uintptr, err error) {
r0, _, e1 := syscall_syscall(libc_shmat_trampoline_addr, uintptr(id), uintptr(addr), uintptr(flag))
ret = uintptr(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_shmat_trampoline_addr uintptr
//go:cgo_import_dynamic libc_shmat shmat "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func shmctl(id int, cmd int, buf *SysvShmDesc) (result int, err error) {
r0, _, e1 := syscall_syscall(libc_shmctl_trampoline_addr, uintptr(id), uintptr(cmd), uintptr(unsafe.Pointer(buf)))
result = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_shmctl_trampoline_addr uintptr
//go:cgo_import_dynamic libc_shmctl shmctl "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func shmdt(addr uintptr) (err error) {
_, _, e1 := syscall_syscall(libc_shmdt_trampoline_addr, uintptr(addr), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_shmdt_trampoline_addr uintptr
//go:cgo_import_dynamic libc_shmdt shmdt "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func shmget(key int, size int, flag int) (id int, err error) {
r0, _, e1 := syscall_syscall(libc_shmget_trampoline_addr, uintptr(key), uintptr(size), uintptr(flag))
id = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_shmget_trampoline_addr uintptr
//go:cgo_import_dynamic libc_shmget shmget "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Access(path string, mode uint32) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := syscall_syscall(libc_access_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_access_trampoline_addr uintptr
//go:cgo_import_dynamic libc_access access "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Adjtime(delta *Timeval, olddelta *Timeval) (err error) {
_, _, e1 := syscall_syscall(libc_adjtime_trampoline_addr, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_adjtime_trampoline_addr uintptr
//go:cgo_import_dynamic libc_adjtime adjtime "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Chdir(path string) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := syscall_syscall(libc_chdir_trampoline_addr, uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_chdir_trampoline_addr uintptr
//go:cgo_import_dynamic libc_chdir chdir "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Chflags(path string, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := syscall_syscall(libc_chflags_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_chflags_trampoline_addr uintptr
//go:cgo_import_dynamic libc_chflags chflags "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Chmod(path string, mode uint32) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := syscall_syscall(libc_chmod_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_chmod_trampoline_addr uintptr
//go:cgo_import_dynamic libc_chmod chmod "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Chown(path string, uid int, gid int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := syscall_syscall(libc_chown_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_chown_trampoline_addr uintptr
//go:cgo_import_dynamic libc_chown chown "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Chroot(path string) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := syscall_syscall(libc_chroot_trampoline_addr, uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_chroot_trampoline_addr uintptr
//go:cgo_import_dynamic libc_chroot chroot "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ClockGettime(clockid int32, time *Timespec) (err error) {
_, _, e1 := syscall_syscall(libc_clock_gettime_trampoline_addr, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_clock_gettime_trampoline_addr uintptr
//go:cgo_import_dynamic libc_clock_gettime clock_gettime "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Close(fd int) (err error) {
_, _, e1 := syscall_syscall(libc_close_trampoline_addr, uintptr(fd), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_close_trampoline_addr uintptr
//go:cgo_import_dynamic libc_close close "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Clonefile(src string, dst string, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(src)
if err != nil {
return
}
var _p1 *byte
_p1, err = BytePtrFromString(dst)
if err != nil {
return
}
_, _, e1 := syscall_syscall(libc_clonefile_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_clonefile_trampoline_addr uintptr
//go:cgo_import_dynamic libc_clonefile clonefile "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Clonefileat(srcDirfd int, src string, dstDirfd int, dst string, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(src)
if err != nil {
return
}
var _p1 *byte
_p1, err = BytePtrFromString(dst)
if err != nil {
return
}
_, _, e1 := syscall_syscall6(libc_clonefileat_trampoline_addr, uintptr(srcDirfd), uintptr(unsafe.Pointer(_p0)), uintptr(dstDirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_clonefileat_trampoline_addr uintptr
//go:cgo_import_dynamic libc_clonefileat clonefileat "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Dup(fd int) (nfd int, err error) {
r0, _, e1 := syscall_syscall(libc_dup_trampoline_addr, uintptr(fd), 0, 0)
nfd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_dup_trampoline_addr uintptr
//go:cgo_import_dynamic libc_dup dup "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Dup2(from int, to int) (err error) {
_, _, e1 := syscall_syscall(libc_dup2_trampoline_addr, uintptr(from), uintptr(to), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_dup2_trampoline_addr uintptr
//go:cgo_import_dynamic libc_dup2 dup2 "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Exchangedata(path1 string, path2 string, options int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path1)
if err != nil {
return
}
var _p1 *byte
_p1, err = BytePtrFromString(path2)
if err != nil {
return
}
_, _, e1 := syscall_syscall(libc_exchangedata_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_exchangedata_trampoline_addr uintptr
//go:cgo_import_dynamic libc_exchangedata exchangedata "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Exit(code int) {
syscall_syscall(libc_exit_trampoline_addr, uintptr(code), 0, 0)
return
}
var libc_exit_trampoline_addr uintptr
//go:cgo_import_dynamic libc_exit exit "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := syscall_syscall6(libc_faccessat_trampoline_addr, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_faccessat_trampoline_addr uintptr
//go:cgo_import_dynamic libc_faccessat faccessat "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchdir(fd int) (err error) {
_, _, e1 := syscall_syscall(libc_fchdir_trampoline_addr, uintptr(fd), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_fchdir_trampoline_addr uintptr
//go:cgo_import_dynamic libc_fchdir fchdir "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchflags(fd int, flags int) (err error) {
_, _, e1 := syscall_syscall(libc_fchflags_trampoline_addr, uintptr(fd), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_fchflags_trampoline_addr uintptr
//go:cgo_import_dynamic libc_fchflags fchflags "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchmod(fd int, mode uint32) (err error) {
_, _, e1 := syscall_syscall(libc_fchmod_trampoline_addr, uintptr(fd), uintptr(mode), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_fchmod_trampoline_addr uintptr
//go:cgo_import_dynamic libc_fchmod fchmod "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := syscall_syscall6(libc_fchmodat_trampoline_addr, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_fchmodat_trampoline_addr uintptr
//go:cgo_import_dynamic libc_fchmodat fchmodat "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchown(fd int, uid int, gid int) (err error) {
_, _, e1 := syscall_syscall(libc_fchown_trampoline_addr, uintptr(fd), uintptr(uid), uintptr(gid))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_fchown_trampoline_addr uintptr
//go:cgo_import_dynamic libc_fchown fchown "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := syscall_syscall6(libc_fchownat_trampoline_addr, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_fchownat_trampoline_addr uintptr
//go:cgo_import_dynamic libc_fchownat fchownat "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fclonefileat(srcDirfd int, dstDirfd int, dst string, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(dst)
if err != nil {
return
}
_, _, e1 := syscall_syscall6(libc_fclonefileat_trampoline_addr, uintptr(srcDirfd), uintptr(dstDirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_fclonefileat_trampoline_addr uintptr
//go:cgo_import_dynamic libc_fclonefileat fclonefileat "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Flock(fd int, how int) (err error) {
_, _, e1 := syscall_syscall(libc_flock_trampoline_addr, uintptr(fd), uintptr(how), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_flock_trampoline_addr uintptr
//go:cgo_import_dynamic libc_flock flock "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fpathconf(fd int, name int) (val int, err error) {
r0, _, e1 := syscall_syscall(libc_fpathconf_trampoline_addr, uintptr(fd), uintptr(name), 0)
val = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_fpathconf_trampoline_addr uintptr
//go:cgo_import_dynamic libc_fpathconf fpathconf "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fsync(fd int) (err error) {
_, _, e1 := syscall_syscall(libc_fsync_trampoline_addr, uintptr(fd), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_fsync_trampoline_addr uintptr
//go:cgo_import_dynamic libc_fsync fsync "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Ftruncate(fd int, length int64) (err error) {
_, _, e1 := syscall_syscall(libc_ftruncate_trampoline_addr, uintptr(fd), uintptr(length), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_ftruncate_trampoline_addr uintptr
//go:cgo_import_dynamic libc_ftruncate ftruncate "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getcwd(buf []byte) (n int, err error) {
var _p0 unsafe.Pointer
if len(buf) > 0 {
_p0 = unsafe.Pointer(&buf[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall(libc_getcwd_trampoline_addr, uintptr(_p0), uintptr(len(buf)), 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_getcwd_trampoline_addr uintptr
//go:cgo_import_dynamic libc_getcwd getcwd "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getdtablesize() (size int) {
r0, _, _ := syscall_syscall(libc_getdtablesize_trampoline_addr, 0, 0, 0)
size = int(r0)
return
}
var libc_getdtablesize_trampoline_addr uintptr
//go:cgo_import_dynamic libc_getdtablesize getdtablesize "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getegid() (egid int) {
r0, _, _ := syscall_rawSyscall(libc_getegid_trampoline_addr, 0, 0, 0)
egid = int(r0)
return
}
var libc_getegid_trampoline_addr uintptr
//go:cgo_import_dynamic libc_getegid getegid "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Geteuid() (uid int) {
r0, _, _ := syscall_rawSyscall(libc_geteuid_trampoline_addr, 0, 0, 0)
uid = int(r0)
return
}
var libc_geteuid_trampoline_addr uintptr
//go:cgo_import_dynamic libc_geteuid geteuid "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getgid() (gid int) {
r0, _, _ := syscall_rawSyscall(libc_getgid_trampoline_addr, 0, 0, 0)
gid = int(r0)
return
}
var libc_getgid_trampoline_addr uintptr
//go:cgo_import_dynamic libc_getgid getgid "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getpgid(pid int) (pgid int, err error) {
r0, _, e1 := syscall_rawSyscall(libc_getpgid_trampoline_addr, uintptr(pid), 0, 0)
pgid = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_getpgid_trampoline_addr uintptr
//go:cgo_import_dynamic libc_getpgid getpgid "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getpgrp() (pgrp int) {
r0, _, _ := syscall_rawSyscall(libc_getpgrp_trampoline_addr, 0, 0, 0)
pgrp = int(r0)
return
}
var libc_getpgrp_trampoline_addr uintptr
//go:cgo_import_dynamic libc_getpgrp getpgrp "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getpid() (pid int) {
r0, _, _ := syscall_rawSyscall(libc_getpid_trampoline_addr, 0, 0, 0)
pid = int(r0)
return
}
var libc_getpid_trampoline_addr uintptr
//go:cgo_import_dynamic libc_getpid getpid "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getppid() (ppid int) {
r0, _, _ := syscall_rawSyscall(libc_getppid_trampoline_addr, 0, 0, 0)
ppid = int(r0)
return
}
var libc_getppid_trampoline_addr uintptr
//go:cgo_import_dynamic libc_getppid getppid "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getpriority(which int, who int) (prio int, err error) {
r0, _, e1 := syscall_syscall(libc_getpriority_trampoline_addr, uintptr(which), uintptr(who), 0)
prio = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_getpriority_trampoline_addr uintptr
//go:cgo_import_dynamic libc_getpriority getpriority "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrlimit(which int, lim *Rlimit) (err error) {
_, _, e1 := syscall_rawSyscall(libc_getrlimit_trampoline_addr, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_getrlimit_trampoline_addr uintptr
//go:cgo_import_dynamic libc_getrlimit getrlimit "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrusage(who int, rusage *Rusage) (err error) {
_, _, e1 := syscall_rawSyscall(libc_getrusage_trampoline_addr, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_getrusage_trampoline_addr uintptr
//go:cgo_import_dynamic libc_getrusage getrusage "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getsid(pid int) (sid int, err error) {
r0, _, e1 := syscall_rawSyscall(libc_getsid_trampoline_addr, uintptr(pid), 0, 0)
sid = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_getsid_trampoline_addr uintptr
//go:cgo_import_dynamic libc_getsid getsid "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Gettimeofday(tp *Timeval) (err error) {
_, _, e1 := syscall_rawSyscall(libc_gettimeofday_trampoline_addr, uintptr(unsafe.Pointer(tp)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_gettimeofday_trampoline_addr uintptr
//go:cgo_import_dynamic libc_gettimeofday gettimeofday "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getuid() (uid int) {
r0, _, _ := syscall_rawSyscall(libc_getuid_trampoline_addr, 0, 0, 0)
uid = int(r0)
return
}
var libc_getuid_trampoline_addr uintptr
//go:cgo_import_dynamic libc_getuid getuid "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Issetugid() (tainted bool) {
r0, _, _ := syscall_rawSyscall(libc_issetugid_trampoline_addr, 0, 0, 0)
tainted = bool(r0 != 0)
return
}
var libc_issetugid_trampoline_addr uintptr
//go:cgo_import_dynamic libc_issetugid issetugid "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Kqueue() (fd int, err error) {
r0, _, e1 := syscall_syscall(libc_kqueue_trampoline_addr, 0, 0, 0)
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_kqueue_trampoline_addr uintptr
//go:cgo_import_dynamic libc_kqueue kqueue "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Lchown(path string, uid int, gid int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := syscall_syscall(libc_lchown_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_lchown_trampoline_addr uintptr
//go:cgo_import_dynamic libc_lchown lchown "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Link(path string, link string) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
var _p1 *byte
_p1, err = BytePtrFromString(link)
if err != nil {
return
}
_, _, e1 := syscall_syscall(libc_link_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_link_trampoline_addr uintptr
//go:cgo_import_dynamic libc_link link "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Linkat(pathfd int, path string, linkfd int, link string, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
var _p1 *byte
_p1, err = BytePtrFromString(link)
if err != nil {
return
}
_, _, e1 := syscall_syscall6(libc_linkat_trampoline_addr, uintptr(pathfd), uintptr(unsafe.Pointer(_p0)), uintptr(linkfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_linkat_trampoline_addr uintptr
//go:cgo_import_dynamic libc_linkat linkat "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Listen(s int, backlog int) (err error) {
_, _, e1 := syscall_syscall(libc_listen_trampoline_addr, uintptr(s), uintptr(backlog), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_listen_trampoline_addr uintptr
//go:cgo_import_dynamic libc_listen listen "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mkdir(path string, mode uint32) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := syscall_syscall(libc_mkdir_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_mkdir_trampoline_addr uintptr
//go:cgo_import_dynamic libc_mkdir mkdir "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mkdirat(dirfd int, path string, mode uint32) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := syscall_syscall(libc_mkdirat_trampoline_addr, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_mkdirat_trampoline_addr uintptr
//go:cgo_import_dynamic libc_mkdirat mkdirat "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mkfifo(path string, mode uint32) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := syscall_syscall(libc_mkfifo_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_mkfifo_trampoline_addr uintptr
//go:cgo_import_dynamic libc_mkfifo mkfifo "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mknod(path string, mode uint32, dev int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := syscall_syscall(libc_mknod_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_mknod_trampoline_addr uintptr
//go:cgo_import_dynamic libc_mknod mknod "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(fsType)
if err != nil {
return
}
var _p1 *byte
_p1, err = BytePtrFromString(dir)
if err != nil {
return
}
_, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_mount_trampoline_addr uintptr
//go:cgo_import_dynamic libc_mount mount "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Open(path string, mode int, perm uint32) (fd int, err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
r0, _, e1 := syscall_syscall(libc_open_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm))
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_open_trampoline_addr uintptr
//go:cgo_import_dynamic libc_open open "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
r0, _, e1 := syscall_syscall6(libc_openat_trampoline_addr, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm), 0, 0)
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_openat_trampoline_addr uintptr
//go:cgo_import_dynamic libc_openat openat "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pathconf(path string, name int) (val int, err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
r0, _, e1 := syscall_syscall(libc_pathconf_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0)
val = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_pathconf_trampoline_addr uintptr
//go:cgo_import_dynamic libc_pathconf pathconf "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func pread(fd int, p []byte, offset int64) (n int, err error) {
var _p0 unsafe.Pointer
if len(p) > 0 {
_p0 = unsafe.Pointer(&p[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall6(libc_pread_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_pread_trampoline_addr uintptr
//go:cgo_import_dynamic libc_pread pread "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func pwrite(fd int, p []byte, offset int64) (n int, err error) {
var _p0 unsafe.Pointer
if len(p) > 0 {
_p0 = unsafe.Pointer(&p[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall6(libc_pwrite_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_pwrite_trampoline_addr uintptr
//go:cgo_import_dynamic libc_pwrite pwrite "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func read(fd int, p []byte) (n int, err error) {
var _p0 unsafe.Pointer
if len(p) > 0 {
_p0 = unsafe.Pointer(&p[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall(libc_read_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(p)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_read_trampoline_addr uintptr
//go:cgo_import_dynamic libc_read read "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Readlink(path string, buf []byte) (n int, err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
var _p1 unsafe.Pointer
if len(buf) > 0 {
_p1 = unsafe.Pointer(&buf[0])
} else {
_p1 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall(libc_readlink_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_readlink_trampoline_addr uintptr
//go:cgo_import_dynamic libc_readlink readlink "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
var _p1 unsafe.Pointer
if len(buf) > 0 {
_p1 = unsafe.Pointer(&buf[0])
} else {
_p1 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall6(libc_readlinkat_trampoline_addr, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_readlinkat_trampoline_addr uintptr
//go:cgo_import_dynamic libc_readlinkat readlinkat "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Rename(from string, to string) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(from)
if err != nil {
return
}
var _p1 *byte
_p1, err = BytePtrFromString(to)
if err != nil {
return
}
_, _, e1 := syscall_syscall(libc_rename_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_rename_trampoline_addr uintptr
//go:cgo_import_dynamic libc_rename rename "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Renameat(fromfd int, from string, tofd int, to string) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(from)
if err != nil {
return
}
var _p1 *byte
_p1, err = BytePtrFromString(to)
if err != nil {
return
}
_, _, e1 := syscall_syscall6(libc_renameat_trampoline_addr, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_renameat_trampoline_addr uintptr
//go:cgo_import_dynamic libc_renameat renameat "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Revoke(path string) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := syscall_syscall(libc_revoke_trampoline_addr, uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_revoke_trampoline_addr uintptr
//go:cgo_import_dynamic libc_revoke revoke "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Rmdir(path string) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := syscall_syscall(libc_rmdir_trampoline_addr, uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_rmdir_trampoline_addr uintptr
//go:cgo_import_dynamic libc_rmdir rmdir "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
r0, _, e1 := syscall_syscall(libc_lseek_trampoline_addr, uintptr(fd), uintptr(offset), uintptr(whence))
newoffset = int64(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_lseek_trampoline_addr uintptr
//go:cgo_import_dynamic libc_lseek lseek "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) {
r0, _, e1 := syscall_syscall6(libc_select_trampoline_addr, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_select_trampoline_addr uintptr
//go:cgo_import_dynamic libc_select select "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setattrlist(path string, attrlist *Attrlist, attrBuf []byte, options int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
var _p1 unsafe.Pointer
if len(attrBuf) > 0 {
_p1 = unsafe.Pointer(&attrBuf[0])
} else {
_p1 = unsafe.Pointer(&_zero)
}
_, _, e1 := syscall_syscall6(libc_setattrlist_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(attrlist)), uintptr(_p1), uintptr(len(attrBuf)), uintptr(options), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_setattrlist_trampoline_addr uintptr
//go:cgo_import_dynamic libc_setattrlist setattrlist "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setegid(egid int) (err error) {
_, _, e1 := syscall_syscall(libc_setegid_trampoline_addr, uintptr(egid), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_setegid_trampoline_addr uintptr
//go:cgo_import_dynamic libc_setegid setegid "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Seteuid(euid int) (err error) {
_, _, e1 := syscall_rawSyscall(libc_seteuid_trampoline_addr, uintptr(euid), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_seteuid_trampoline_addr uintptr
//go:cgo_import_dynamic libc_seteuid seteuid "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setgid(gid int) (err error) {
_, _, e1 := syscall_rawSyscall(libc_setgid_trampoline_addr, uintptr(gid), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_setgid_trampoline_addr uintptr
//go:cgo_import_dynamic libc_setgid setgid "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setlogin(name string) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(name)
if err != nil {
return
}
_, _, e1 := syscall_syscall(libc_setlogin_trampoline_addr, uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_setlogin_trampoline_addr uintptr
//go:cgo_import_dynamic libc_setlogin setlogin "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setpgid(pid int, pgid int) (err error) {
_, _, e1 := syscall_rawSyscall(libc_setpgid_trampoline_addr, uintptr(pid), uintptr(pgid), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_setpgid_trampoline_addr uintptr
//go:cgo_import_dynamic libc_setpgid setpgid "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setpriority(which int, who int, prio int) (err error) {
_, _, e1 := syscall_syscall(libc_setpriority_trampoline_addr, uintptr(which), uintptr(who), uintptr(prio))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_setpriority_trampoline_addr uintptr
//go:cgo_import_dynamic libc_setpriority setpriority "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setprivexec(flag int) (err error) {
_, _, e1 := syscall_syscall(libc_setprivexec_trampoline_addr, uintptr(flag), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_setprivexec_trampoline_addr uintptr
//go:cgo_import_dynamic libc_setprivexec setprivexec "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setregid(rgid int, egid int) (err error) {
_, _, e1 := syscall_rawSyscall(libc_setregid_trampoline_addr, uintptr(rgid), uintptr(egid), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_setregid_trampoline_addr uintptr
//go:cgo_import_dynamic libc_setregid setregid "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setreuid(ruid int, euid int) (err error) {
_, _, e1 := syscall_rawSyscall(libc_setreuid_trampoline_addr, uintptr(ruid), uintptr(euid), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_setreuid_trampoline_addr uintptr
//go:cgo_import_dynamic libc_setreuid setreuid "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setsid() (pid int, err error) {
r0, _, e1 := syscall_rawSyscall(libc_setsid_trampoline_addr, 0, 0, 0)
pid = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_setsid_trampoline_addr uintptr
//go:cgo_import_dynamic libc_setsid setsid "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Settimeofday(tp *Timeval) (err error) {
_, _, e1 := syscall_rawSyscall(libc_settimeofday_trampoline_addr, uintptr(unsafe.Pointer(tp)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_settimeofday_trampoline_addr uintptr
//go:cgo_import_dynamic libc_settimeofday settimeofday "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setuid(uid int) (err error) {
_, _, e1 := syscall_rawSyscall(libc_setuid_trampoline_addr, uintptr(uid), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_setuid_trampoline_addr uintptr
//go:cgo_import_dynamic libc_setuid setuid "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Symlink(path string, link string) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
var _p1 *byte
_p1, err = BytePtrFromString(link)
if err != nil {
return
}
_, _, e1 := syscall_syscall(libc_symlink_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_symlink_trampoline_addr uintptr
//go:cgo_import_dynamic libc_symlink symlink "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(oldpath)
if err != nil {
return
}
var _p1 *byte
_p1, err = BytePtrFromString(newpath)
if err != nil {
return
}
_, _, e1 := syscall_syscall(libc_symlinkat_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_symlinkat_trampoline_addr uintptr
//go:cgo_import_dynamic libc_symlinkat symlinkat "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Sync() (err error) {
_, _, e1 := syscall_syscall(libc_sync_trampoline_addr, 0, 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_sync_trampoline_addr uintptr
//go:cgo_import_dynamic libc_sync sync "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Truncate(path string, length int64) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := syscall_syscall(libc_truncate_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_truncate_trampoline_addr uintptr
//go:cgo_import_dynamic libc_truncate truncate "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Umask(newmask int) (oldmask int) {
r0, _, _ := syscall_syscall(libc_umask_trampoline_addr, uintptr(newmask), 0, 0)
oldmask = int(r0)
return
}
var libc_umask_trampoline_addr uintptr
//go:cgo_import_dynamic libc_umask umask "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Undelete(path string) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := syscall_syscall(libc_undelete_trampoline_addr, uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_undelete_trampoline_addr uintptr
//go:cgo_import_dynamic libc_undelete undelete "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Unlink(path string) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := syscall_syscall(libc_unlink_trampoline_addr, uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_unlink_trampoline_addr uintptr
//go:cgo_import_dynamic libc_unlink unlink "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Unlinkat(dirfd int, path string, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := syscall_syscall(libc_unlinkat_trampoline_addr, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_unlinkat_trampoline_addr uintptr
//go:cgo_import_dynamic libc_unlinkat unlinkat "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Unmount(path string, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := syscall_syscall(libc_unmount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_unmount_trampoline_addr uintptr
//go:cgo_import_dynamic libc_unmount unmount "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func write(fd int, p []byte) (n int, err error) {
var _p0 unsafe.Pointer
if len(p) > 0 {
_p0 = unsafe.Pointer(&p[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall(libc_write_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(p)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_write_trampoline_addr uintptr
//go:cgo_import_dynamic libc_write write "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) {
r0, _, e1 := syscall_syscall6(libc_mmap_trampoline_addr, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos))
ret = uintptr(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_mmap_trampoline_addr uintptr
//go:cgo_import_dynamic libc_mmap mmap "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func munmap(addr uintptr, length uintptr) (err error) {
_, _, e1 := syscall_syscall(libc_munmap_trampoline_addr, uintptr(addr), uintptr(length), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_munmap_trampoline_addr uintptr
//go:cgo_import_dynamic libc_munmap munmap "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fstat(fd int, stat *Stat_t) (err error) {
_, _, e1 := syscall_syscall(libc_fstat64_trampoline_addr, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_fstat64_trampoline_addr uintptr
//go:cgo_import_dynamic libc_fstat64 fstat64 "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := syscall_syscall6(libc_fstatat64_trampoline_addr, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_fstatat64_trampoline_addr uintptr
//go:cgo_import_dynamic libc_fstatat64 fstatat64 "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fstatfs(fd int, stat *Statfs_t) (err error) {
_, _, e1 := syscall_syscall(libc_fstatfs64_trampoline_addr, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_fstatfs64_trampoline_addr uintptr
//go:cgo_import_dynamic libc_fstatfs64 fstatfs64 "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) {
r0, _, e1 := syscall_syscall(libc_getfsstat64_trampoline_addr, uintptr(buf), uintptr(size), uintptr(flags))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_getfsstat64_trampoline_addr uintptr
//go:cgo_import_dynamic libc_getfsstat64 getfsstat64 "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Lstat(path string, stat *Stat_t) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := syscall_syscall(libc_lstat64_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_lstat64_trampoline_addr uintptr
//go:cgo_import_dynamic libc_lstat64 lstat64 "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ptrace1(request int, pid int, addr uintptr, data uintptr) (err error) {
_, _, e1 := syscall_syscall6(libc_ptrace_trampoline_addr, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_ptrace_trampoline_addr uintptr
//go:cgo_import_dynamic libc_ptrace ptrace "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Stat(path string, stat *Stat_t) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := syscall_syscall(libc_stat64_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_stat64_trampoline_addr uintptr
//go:cgo_import_dynamic libc_stat64 stat64 "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Statfs(path string, stat *Statfs_t) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := syscall_syscall(libc_statfs64_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_statfs64_trampoline_addr uintptr
//go:cgo_import_dynamic libc_statfs64 statfs64 "/usr/lib/libSystem.B.dylib"
|
go/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go/0
|
{
"file_path": "go/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go",
"repo_id": "go",
"token_count": 29991
}
| 190 |
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Windows system calls.
package windows
import (
errorspkg "errors"
"fmt"
"runtime"
"sync"
"syscall"
"time"
"unicode/utf16"
"unsafe"
)
type (
Handle uintptr
HWND uintptr
)
const (
InvalidHandle = ^Handle(0)
InvalidHWND = ^HWND(0)
// Flags for DefineDosDevice.
DDD_EXACT_MATCH_ON_REMOVE = 0x00000004
DDD_NO_BROADCAST_SYSTEM = 0x00000008
DDD_RAW_TARGET_PATH = 0x00000001
DDD_REMOVE_DEFINITION = 0x00000002
// Return values for GetDriveType.
DRIVE_UNKNOWN = 0
DRIVE_NO_ROOT_DIR = 1
DRIVE_REMOVABLE = 2
DRIVE_FIXED = 3
DRIVE_REMOTE = 4
DRIVE_CDROM = 5
DRIVE_RAMDISK = 6
// File system flags from GetVolumeInformation and GetVolumeInformationByHandle.
FILE_CASE_SENSITIVE_SEARCH = 0x00000001
FILE_CASE_PRESERVED_NAMES = 0x00000002
FILE_FILE_COMPRESSION = 0x00000010
FILE_DAX_VOLUME = 0x20000000
FILE_NAMED_STREAMS = 0x00040000
FILE_PERSISTENT_ACLS = 0x00000008
FILE_READ_ONLY_VOLUME = 0x00080000
FILE_SEQUENTIAL_WRITE_ONCE = 0x00100000
FILE_SUPPORTS_ENCRYPTION = 0x00020000
FILE_SUPPORTS_EXTENDED_ATTRIBUTES = 0x00800000
FILE_SUPPORTS_HARD_LINKS = 0x00400000
FILE_SUPPORTS_OBJECT_IDS = 0x00010000
FILE_SUPPORTS_OPEN_BY_FILE_ID = 0x01000000
FILE_SUPPORTS_REPARSE_POINTS = 0x00000080
FILE_SUPPORTS_SPARSE_FILES = 0x00000040
FILE_SUPPORTS_TRANSACTIONS = 0x00200000
FILE_SUPPORTS_USN_JOURNAL = 0x02000000
FILE_UNICODE_ON_DISK = 0x00000004
FILE_VOLUME_IS_COMPRESSED = 0x00008000
FILE_VOLUME_QUOTAS = 0x00000020
// Flags for LockFileEx.
LOCKFILE_FAIL_IMMEDIATELY = 0x00000001
LOCKFILE_EXCLUSIVE_LOCK = 0x00000002
// Return value of SleepEx and other APC functions
WAIT_IO_COMPLETION = 0x000000C0
)
// StringToUTF16 is deprecated. Use UTF16FromString instead.
// If s contains a NUL byte this function panics instead of
// returning an error.
func StringToUTF16(s string) []uint16 {
a, err := UTF16FromString(s)
if err != nil {
panic("windows: string with NUL passed to StringToUTF16")
}
return a
}
// UTF16FromString returns the UTF-16 encoding of the UTF-8 string
// s, with a terminating NUL added. If s contains a NUL byte at any
// location, it returns (nil, syscall.EINVAL).
func UTF16FromString(s string) ([]uint16, error) {
return syscall.UTF16FromString(s)
}
// UTF16ToString returns the UTF-8 encoding of the UTF-16 sequence s,
// with a terminating NUL and any bytes after the NUL removed.
func UTF16ToString(s []uint16) string {
return syscall.UTF16ToString(s)
}
// StringToUTF16Ptr is deprecated. Use UTF16PtrFromString instead.
// If s contains a NUL byte this function panics instead of
// returning an error.
func StringToUTF16Ptr(s string) *uint16 { return &StringToUTF16(s)[0] }
// UTF16PtrFromString returns pointer to the UTF-16 encoding of
// the UTF-8 string s, with a terminating NUL added. If s
// contains a NUL byte at any location, it returns (nil, syscall.EINVAL).
func UTF16PtrFromString(s string) (*uint16, error) {
a, err := UTF16FromString(s)
if err != nil {
return nil, err
}
return &a[0], nil
}
// UTF16PtrToString takes a pointer to a UTF-16 sequence and returns the corresponding UTF-8 encoded string.
// If the pointer is nil, it returns the empty string. It assumes that the UTF-16 sequence is terminated
// at a zero word; if the zero word is not present, the program may crash.
func UTF16PtrToString(p *uint16) string {
if p == nil {
return ""
}
if *p == 0 {
return ""
}
// Find NUL terminator.
n := 0
for ptr := unsafe.Pointer(p); *(*uint16)(ptr) != 0; n++ {
ptr = unsafe.Pointer(uintptr(ptr) + unsafe.Sizeof(*p))
}
return UTF16ToString(unsafe.Slice(p, n))
}
func Getpagesize() int { return 4096 }
// NewCallback converts a Go function to a function pointer conforming to the stdcall calling convention.
// This is useful when interoperating with Windows code requiring callbacks.
// The argument is expected to be a function with one uintptr-sized result. The function must not have arguments with size larger than the size of uintptr.
func NewCallback(fn interface{}) uintptr {
return syscall.NewCallback(fn)
}
// NewCallbackCDecl converts a Go function to a function pointer conforming to the cdecl calling convention.
// This is useful when interoperating with Windows code requiring callbacks.
// The argument is expected to be a function with one uintptr-sized result. The function must not have arguments with size larger than the size of uintptr.
func NewCallbackCDecl(fn interface{}) uintptr {
return syscall.NewCallbackCDecl(fn)
}
// windows api calls
//sys GetLastError() (lasterr error)
//sys LoadLibrary(libname string) (handle Handle, err error) = LoadLibraryW
//sys LoadLibraryEx(libname string, zero Handle, flags uintptr) (handle Handle, err error) = LoadLibraryExW
//sys FreeLibrary(handle Handle) (err error)
//sys GetProcAddress(module Handle, procname string) (proc uintptr, err error)
//sys GetModuleFileName(module Handle, filename *uint16, size uint32) (n uint32, err error) = kernel32.GetModuleFileNameW
//sys GetModuleHandleEx(flags uint32, moduleName *uint16, module *Handle) (err error) = kernel32.GetModuleHandleExW
//sys SetDefaultDllDirectories(directoryFlags uint32) (err error)
//sys AddDllDirectory(path *uint16) (cookie uintptr, err error) = kernel32.AddDllDirectory
//sys RemoveDllDirectory(cookie uintptr) (err error) = kernel32.RemoveDllDirectory
//sys SetDllDirectory(path string) (err error) = kernel32.SetDllDirectoryW
//sys GetVersion() (ver uint32, err error)
//sys FormatMessage(flags uint32, msgsrc uintptr, msgid uint32, langid uint32, buf []uint16, args *byte) (n uint32, err error) = FormatMessageW
//sys ExitProcess(exitcode uint32)
//sys IsWow64Process(handle Handle, isWow64 *bool) (err error) = IsWow64Process
//sys IsWow64Process2(handle Handle, processMachine *uint16, nativeMachine *uint16) (err error) = IsWow64Process2?
//sys CreateFile(name *uint16, access uint32, mode uint32, sa *SecurityAttributes, createmode uint32, attrs uint32, templatefile Handle) (handle Handle, err error) [failretval==InvalidHandle] = CreateFileW
//sys CreateNamedPipe(name *uint16, flags uint32, pipeMode uint32, maxInstances uint32, outSize uint32, inSize uint32, defaultTimeout uint32, sa *SecurityAttributes) (handle Handle, err error) [failretval==InvalidHandle] = CreateNamedPipeW
//sys ConnectNamedPipe(pipe Handle, overlapped *Overlapped) (err error)
//sys DisconnectNamedPipe(pipe Handle) (err error)
//sys GetNamedPipeInfo(pipe Handle, flags *uint32, outSize *uint32, inSize *uint32, maxInstances *uint32) (err error)
//sys GetNamedPipeHandleState(pipe Handle, state *uint32, curInstances *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32, userName *uint16, maxUserNameSize uint32) (err error) = GetNamedPipeHandleStateW
//sys SetNamedPipeHandleState(pipe Handle, state *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32) (err error) = SetNamedPipeHandleState
//sys readFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) = ReadFile
//sys writeFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) = WriteFile
//sys GetOverlappedResult(handle Handle, overlapped *Overlapped, done *uint32, wait bool) (err error)
//sys SetFilePointer(handle Handle, lowoffset int32, highoffsetptr *int32, whence uint32) (newlowoffset uint32, err error) [failretval==0xffffffff]
//sys CloseHandle(handle Handle) (err error)
//sys GetStdHandle(stdhandle uint32) (handle Handle, err error) [failretval==InvalidHandle]
//sys SetStdHandle(stdhandle uint32, handle Handle) (err error)
//sys findFirstFile1(name *uint16, data *win32finddata1) (handle Handle, err error) [failretval==InvalidHandle] = FindFirstFileW
//sys findNextFile1(handle Handle, data *win32finddata1) (err error) = FindNextFileW
//sys FindClose(handle Handle) (err error)
//sys GetFileInformationByHandle(handle Handle, data *ByHandleFileInformation) (err error)
//sys GetFileInformationByHandleEx(handle Handle, class uint32, outBuffer *byte, outBufferLen uint32) (err error)
//sys SetFileInformationByHandle(handle Handle, class uint32, inBuffer *byte, inBufferLen uint32) (err error)
//sys GetCurrentDirectory(buflen uint32, buf *uint16) (n uint32, err error) = GetCurrentDirectoryW
//sys SetCurrentDirectory(path *uint16) (err error) = SetCurrentDirectoryW
//sys CreateDirectory(path *uint16, sa *SecurityAttributes) (err error) = CreateDirectoryW
//sys RemoveDirectory(path *uint16) (err error) = RemoveDirectoryW
//sys DeleteFile(path *uint16) (err error) = DeleteFileW
//sys MoveFile(from *uint16, to *uint16) (err error) = MoveFileW
//sys MoveFileEx(from *uint16, to *uint16, flags uint32) (err error) = MoveFileExW
//sys LockFileEx(file Handle, flags uint32, reserved uint32, bytesLow uint32, bytesHigh uint32, overlapped *Overlapped) (err error)
//sys UnlockFileEx(file Handle, reserved uint32, bytesLow uint32, bytesHigh uint32, overlapped *Overlapped) (err error)
//sys GetComputerName(buf *uint16, n *uint32) (err error) = GetComputerNameW
//sys GetComputerNameEx(nametype uint32, buf *uint16, n *uint32) (err error) = GetComputerNameExW
//sys SetEndOfFile(handle Handle) (err error)
//sys SetFileValidData(handle Handle, validDataLength int64) (err error)
//sys GetSystemTimeAsFileTime(time *Filetime)
//sys GetSystemTimePreciseAsFileTime(time *Filetime)
//sys GetTimeZoneInformation(tzi *Timezoneinformation) (rc uint32, err error) [failretval==0xffffffff]
//sys CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uintptr, threadcnt uint32) (handle Handle, err error)
//sys GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uintptr, overlapped **Overlapped, timeout uint32) (err error)
//sys PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uintptr, overlapped *Overlapped) (err error)
//sys CancelIo(s Handle) (err error)
//sys CancelIoEx(s Handle, o *Overlapped) (err error)
//sys CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error) = CreateProcessW
//sys CreateProcessAsUser(token Token, appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error) = advapi32.CreateProcessAsUserW
//sys initializeProcThreadAttributeList(attrlist *ProcThreadAttributeList, attrcount uint32, flags uint32, size *uintptr) (err error) = InitializeProcThreadAttributeList
//sys deleteProcThreadAttributeList(attrlist *ProcThreadAttributeList) = DeleteProcThreadAttributeList
//sys updateProcThreadAttribute(attrlist *ProcThreadAttributeList, flags uint32, attr uintptr, value unsafe.Pointer, size uintptr, prevvalue unsafe.Pointer, returnedsize *uintptr) (err error) = UpdateProcThreadAttribute
//sys OpenProcess(desiredAccess uint32, inheritHandle bool, processId uint32) (handle Handle, err error)
//sys ShellExecute(hwnd Handle, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int32) (err error) [failretval<=32] = shell32.ShellExecuteW
//sys GetWindowThreadProcessId(hwnd HWND, pid *uint32) (tid uint32, err error) = user32.GetWindowThreadProcessId
//sys LoadKeyboardLayout(name *uint16, flags uint32) (hkl Handle, err error) [failretval==0] = user32.LoadKeyboardLayoutW
//sys UnloadKeyboardLayout(hkl Handle) (err error) = user32.UnloadKeyboardLayout
//sys GetKeyboardLayout(tid uint32) (hkl Handle) = user32.GetKeyboardLayout
//sys ToUnicodeEx(vkey uint32, scancode uint32, keystate *byte, pwszBuff *uint16, cchBuff int32, flags uint32, hkl Handle) (ret int32) = user32.ToUnicodeEx
//sys GetShellWindow() (shellWindow HWND) = user32.GetShellWindow
//sys MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) [failretval==0] = user32.MessageBoxW
//sys ExitWindowsEx(flags uint32, reason uint32) (err error) = user32.ExitWindowsEx
//sys shGetKnownFolderPath(id *KNOWNFOLDERID, flags uint32, token Token, path **uint16) (ret error) = shell32.SHGetKnownFolderPath
//sys TerminateProcess(handle Handle, exitcode uint32) (err error)
//sys GetExitCodeProcess(handle Handle, exitcode *uint32) (err error)
//sys getStartupInfo(startupInfo *StartupInfo) = GetStartupInfoW
//sys GetProcessTimes(handle Handle, creationTime *Filetime, exitTime *Filetime, kernelTime *Filetime, userTime *Filetime) (err error)
//sys DuplicateHandle(hSourceProcessHandle Handle, hSourceHandle Handle, hTargetProcessHandle Handle, lpTargetHandle *Handle, dwDesiredAccess uint32, bInheritHandle bool, dwOptions uint32) (err error)
//sys WaitForSingleObject(handle Handle, waitMilliseconds uint32) (event uint32, err error) [failretval==0xffffffff]
//sys waitForMultipleObjects(count uint32, handles uintptr, waitAll bool, waitMilliseconds uint32) (event uint32, err error) [failretval==0xffffffff] = WaitForMultipleObjects
//sys GetTempPath(buflen uint32, buf *uint16) (n uint32, err error) = GetTempPathW
//sys CreatePipe(readhandle *Handle, writehandle *Handle, sa *SecurityAttributes, size uint32) (err error)
//sys GetFileType(filehandle Handle) (n uint32, err error)
//sys CryptAcquireContext(provhandle *Handle, container *uint16, provider *uint16, provtype uint32, flags uint32) (err error) = advapi32.CryptAcquireContextW
//sys CryptReleaseContext(provhandle Handle, flags uint32) (err error) = advapi32.CryptReleaseContext
//sys CryptGenRandom(provhandle Handle, buflen uint32, buf *byte) (err error) = advapi32.CryptGenRandom
//sys GetEnvironmentStrings() (envs *uint16, err error) [failretval==nil] = kernel32.GetEnvironmentStringsW
//sys FreeEnvironmentStrings(envs *uint16) (err error) = kernel32.FreeEnvironmentStringsW
//sys GetEnvironmentVariable(name *uint16, buffer *uint16, size uint32) (n uint32, err error) = kernel32.GetEnvironmentVariableW
//sys SetEnvironmentVariable(name *uint16, value *uint16) (err error) = kernel32.SetEnvironmentVariableW
//sys ExpandEnvironmentStrings(src *uint16, dst *uint16, size uint32) (n uint32, err error) = kernel32.ExpandEnvironmentStringsW
//sys CreateEnvironmentBlock(block **uint16, token Token, inheritExisting bool) (err error) = userenv.CreateEnvironmentBlock
//sys DestroyEnvironmentBlock(block *uint16) (err error) = userenv.DestroyEnvironmentBlock
//sys getTickCount64() (ms uint64) = kernel32.GetTickCount64
//sys GetFileTime(handle Handle, ctime *Filetime, atime *Filetime, wtime *Filetime) (err error)
//sys SetFileTime(handle Handle, ctime *Filetime, atime *Filetime, wtime *Filetime) (err error)
//sys GetFileAttributes(name *uint16) (attrs uint32, err error) [failretval==INVALID_FILE_ATTRIBUTES] = kernel32.GetFileAttributesW
//sys SetFileAttributes(name *uint16, attrs uint32) (err error) = kernel32.SetFileAttributesW
//sys GetFileAttributesEx(name *uint16, level uint32, info *byte) (err error) = kernel32.GetFileAttributesExW
//sys GetCommandLine() (cmd *uint16) = kernel32.GetCommandLineW
//sys commandLineToArgv(cmd *uint16, argc *int32) (argv **uint16, err error) [failretval==nil] = shell32.CommandLineToArgvW
//sys LocalFree(hmem Handle) (handle Handle, err error) [failretval!=0]
//sys LocalAlloc(flags uint32, length uint32) (ptr uintptr, err error)
//sys SetHandleInformation(handle Handle, mask uint32, flags uint32) (err error)
//sys FlushFileBuffers(handle Handle) (err error)
//sys GetFullPathName(path *uint16, buflen uint32, buf *uint16, fname **uint16) (n uint32, err error) = kernel32.GetFullPathNameW
//sys GetLongPathName(path *uint16, buf *uint16, buflen uint32) (n uint32, err error) = kernel32.GetLongPathNameW
//sys GetShortPathName(longpath *uint16, shortpath *uint16, buflen uint32) (n uint32, err error) = kernel32.GetShortPathNameW
//sys GetFinalPathNameByHandle(file Handle, filePath *uint16, filePathSize uint32, flags uint32) (n uint32, err error) = kernel32.GetFinalPathNameByHandleW
//sys CreateFileMapping(fhandle Handle, sa *SecurityAttributes, prot uint32, maxSizeHigh uint32, maxSizeLow uint32, name *uint16) (handle Handle, err error) [failretval == 0 || e1 == ERROR_ALREADY_EXISTS] = kernel32.CreateFileMappingW
//sys MapViewOfFile(handle Handle, access uint32, offsetHigh uint32, offsetLow uint32, length uintptr) (addr uintptr, err error)
//sys UnmapViewOfFile(addr uintptr) (err error)
//sys FlushViewOfFile(addr uintptr, length uintptr) (err error)
//sys VirtualLock(addr uintptr, length uintptr) (err error)
//sys VirtualUnlock(addr uintptr, length uintptr) (err error)
//sys VirtualAlloc(address uintptr, size uintptr, alloctype uint32, protect uint32) (value uintptr, err error) = kernel32.VirtualAlloc
//sys VirtualFree(address uintptr, size uintptr, freetype uint32) (err error) = kernel32.VirtualFree
//sys VirtualProtect(address uintptr, size uintptr, newprotect uint32, oldprotect *uint32) (err error) = kernel32.VirtualProtect
//sys VirtualProtectEx(process Handle, address uintptr, size uintptr, newProtect uint32, oldProtect *uint32) (err error) = kernel32.VirtualProtectEx
//sys VirtualQuery(address uintptr, buffer *MemoryBasicInformation, length uintptr) (err error) = kernel32.VirtualQuery
//sys VirtualQueryEx(process Handle, address uintptr, buffer *MemoryBasicInformation, length uintptr) (err error) = kernel32.VirtualQueryEx
//sys ReadProcessMemory(process Handle, baseAddress uintptr, buffer *byte, size uintptr, numberOfBytesRead *uintptr) (err error) = kernel32.ReadProcessMemory
//sys WriteProcessMemory(process Handle, baseAddress uintptr, buffer *byte, size uintptr, numberOfBytesWritten *uintptr) (err error) = kernel32.WriteProcessMemory
//sys TransmitFile(s Handle, handle Handle, bytesToWrite uint32, bytsPerSend uint32, overlapped *Overlapped, transmitFileBuf *TransmitFileBuffers, flags uint32) (err error) = mswsock.TransmitFile
//sys ReadDirectoryChanges(handle Handle, buf *byte, buflen uint32, watchSubTree bool, mask uint32, retlen *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) = kernel32.ReadDirectoryChangesW
//sys FindFirstChangeNotification(path string, watchSubtree bool, notifyFilter uint32) (handle Handle, err error) [failretval==InvalidHandle] = kernel32.FindFirstChangeNotificationW
//sys FindNextChangeNotification(handle Handle) (err error)
//sys FindCloseChangeNotification(handle Handle) (err error)
//sys CertOpenSystemStore(hprov Handle, name *uint16) (store Handle, err error) = crypt32.CertOpenSystemStoreW
//sys CertOpenStore(storeProvider uintptr, msgAndCertEncodingType uint32, cryptProv uintptr, flags uint32, para uintptr) (handle Handle, err error) = crypt32.CertOpenStore
//sys CertEnumCertificatesInStore(store Handle, prevContext *CertContext) (context *CertContext, err error) [failretval==nil] = crypt32.CertEnumCertificatesInStore
//sys CertAddCertificateContextToStore(store Handle, certContext *CertContext, addDisposition uint32, storeContext **CertContext) (err error) = crypt32.CertAddCertificateContextToStore
//sys CertCloseStore(store Handle, flags uint32) (err error) = crypt32.CertCloseStore
//sys CertDeleteCertificateFromStore(certContext *CertContext) (err error) = crypt32.CertDeleteCertificateFromStore
//sys CertDuplicateCertificateContext(certContext *CertContext) (dupContext *CertContext) = crypt32.CertDuplicateCertificateContext
//sys PFXImportCertStore(pfx *CryptDataBlob, password *uint16, flags uint32) (store Handle, err error) = crypt32.PFXImportCertStore
//sys CertGetCertificateChain(engine Handle, leaf *CertContext, time *Filetime, additionalStore Handle, para *CertChainPara, flags uint32, reserved uintptr, chainCtx **CertChainContext) (err error) = crypt32.CertGetCertificateChain
//sys CertFreeCertificateChain(ctx *CertChainContext) = crypt32.CertFreeCertificateChain
//sys CertCreateCertificateContext(certEncodingType uint32, certEncoded *byte, encodedLen uint32) (context *CertContext, err error) [failretval==nil] = crypt32.CertCreateCertificateContext
//sys CertFreeCertificateContext(ctx *CertContext) (err error) = crypt32.CertFreeCertificateContext
//sys CertVerifyCertificateChainPolicy(policyOID uintptr, chain *CertChainContext, para *CertChainPolicyPara, status *CertChainPolicyStatus) (err error) = crypt32.CertVerifyCertificateChainPolicy
//sys CertGetNameString(certContext *CertContext, nameType uint32, flags uint32, typePara unsafe.Pointer, name *uint16, size uint32) (chars uint32) = crypt32.CertGetNameStringW
//sys CertFindExtension(objId *byte, countExtensions uint32, extensions *CertExtension) (ret *CertExtension) = crypt32.CertFindExtension
//sys CertFindCertificateInStore(store Handle, certEncodingType uint32, findFlags uint32, findType uint32, findPara unsafe.Pointer, prevCertContext *CertContext) (cert *CertContext, err error) [failretval==nil] = crypt32.CertFindCertificateInStore
//sys CertFindChainInStore(store Handle, certEncodingType uint32, findFlags uint32, findType uint32, findPara unsafe.Pointer, prevChainContext *CertChainContext) (certchain *CertChainContext, err error) [failretval==nil] = crypt32.CertFindChainInStore
//sys CryptAcquireCertificatePrivateKey(cert *CertContext, flags uint32, parameters unsafe.Pointer, cryptProvOrNCryptKey *Handle, keySpec *uint32, callerFreeProvOrNCryptKey *bool) (err error) = crypt32.CryptAcquireCertificatePrivateKey
//sys CryptQueryObject(objectType uint32, object unsafe.Pointer, expectedContentTypeFlags uint32, expectedFormatTypeFlags uint32, flags uint32, msgAndCertEncodingType *uint32, contentType *uint32, formatType *uint32, certStore *Handle, msg *Handle, context *unsafe.Pointer) (err error) = crypt32.CryptQueryObject
//sys CryptDecodeObject(encodingType uint32, structType *byte, encodedBytes *byte, lenEncodedBytes uint32, flags uint32, decoded unsafe.Pointer, decodedLen *uint32) (err error) = crypt32.CryptDecodeObject
//sys CryptProtectData(dataIn *DataBlob, name *uint16, optionalEntropy *DataBlob, reserved uintptr, promptStruct *CryptProtectPromptStruct, flags uint32, dataOut *DataBlob) (err error) = crypt32.CryptProtectData
//sys CryptUnprotectData(dataIn *DataBlob, name **uint16, optionalEntropy *DataBlob, reserved uintptr, promptStruct *CryptProtectPromptStruct, flags uint32, dataOut *DataBlob) (err error) = crypt32.CryptUnprotectData
//sys WinVerifyTrustEx(hwnd HWND, actionId *GUID, data *WinTrustData) (ret error) = wintrust.WinVerifyTrustEx
//sys RegOpenKeyEx(key Handle, subkey *uint16, options uint32, desiredAccess uint32, result *Handle) (regerrno error) = advapi32.RegOpenKeyExW
//sys RegCloseKey(key Handle) (regerrno error) = advapi32.RegCloseKey
//sys RegQueryInfoKey(key Handle, class *uint16, classLen *uint32, reserved *uint32, subkeysLen *uint32, maxSubkeyLen *uint32, maxClassLen *uint32, valuesLen *uint32, maxValueNameLen *uint32, maxValueLen *uint32, saLen *uint32, lastWriteTime *Filetime) (regerrno error) = advapi32.RegQueryInfoKeyW
//sys RegEnumKeyEx(key Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, class *uint16, classLen *uint32, lastWriteTime *Filetime) (regerrno error) = advapi32.RegEnumKeyExW
//sys RegQueryValueEx(key Handle, name *uint16, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno error) = advapi32.RegQueryValueExW
//sys RegNotifyChangeKeyValue(key Handle, watchSubtree bool, notifyFilter uint32, event Handle, asynchronous bool) (regerrno error) = advapi32.RegNotifyChangeKeyValue
//sys GetCurrentProcessId() (pid uint32) = kernel32.GetCurrentProcessId
//sys ProcessIdToSessionId(pid uint32, sessionid *uint32) (err error) = kernel32.ProcessIdToSessionId
//sys ClosePseudoConsole(console Handle) = kernel32.ClosePseudoConsole
//sys createPseudoConsole(size uint32, in Handle, out Handle, flags uint32, pconsole *Handle) (hr error) = kernel32.CreatePseudoConsole
//sys GetConsoleMode(console Handle, mode *uint32) (err error) = kernel32.GetConsoleMode
//sys SetConsoleMode(console Handle, mode uint32) (err error) = kernel32.SetConsoleMode
//sys GetConsoleScreenBufferInfo(console Handle, info *ConsoleScreenBufferInfo) (err error) = kernel32.GetConsoleScreenBufferInfo
//sys setConsoleCursorPosition(console Handle, position uint32) (err error) = kernel32.SetConsoleCursorPosition
//sys WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) = kernel32.WriteConsoleW
//sys ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, inputControl *byte) (err error) = kernel32.ReadConsoleW
//sys resizePseudoConsole(pconsole Handle, size uint32) (hr error) = kernel32.ResizePseudoConsole
//sys CreateToolhelp32Snapshot(flags uint32, processId uint32) (handle Handle, err error) [failretval==InvalidHandle] = kernel32.CreateToolhelp32Snapshot
//sys Module32First(snapshot Handle, moduleEntry *ModuleEntry32) (err error) = kernel32.Module32FirstW
//sys Module32Next(snapshot Handle, moduleEntry *ModuleEntry32) (err error) = kernel32.Module32NextW
//sys Process32First(snapshot Handle, procEntry *ProcessEntry32) (err error) = kernel32.Process32FirstW
//sys Process32Next(snapshot Handle, procEntry *ProcessEntry32) (err error) = kernel32.Process32NextW
//sys Thread32First(snapshot Handle, threadEntry *ThreadEntry32) (err error)
//sys Thread32Next(snapshot Handle, threadEntry *ThreadEntry32) (err error)
//sys DeviceIoControl(handle Handle, ioControlCode uint32, inBuffer *byte, inBufferSize uint32, outBuffer *byte, outBufferSize uint32, bytesReturned *uint32, overlapped *Overlapped) (err error)
// This function returns 1 byte BOOLEAN rather than the 4 byte BOOL.
//sys CreateSymbolicLink(symlinkfilename *uint16, targetfilename *uint16, flags uint32) (err error) [failretval&0xff==0] = CreateSymbolicLinkW
//sys CreateHardLink(filename *uint16, existingfilename *uint16, reserved uintptr) (err error) [failretval&0xff==0] = CreateHardLinkW
//sys GetCurrentThreadId() (id uint32)
//sys CreateEvent(eventAttrs *SecurityAttributes, manualReset uint32, initialState uint32, name *uint16) (handle Handle, err error) [failretval == 0 || e1 == ERROR_ALREADY_EXISTS] = kernel32.CreateEventW
//sys CreateEventEx(eventAttrs *SecurityAttributes, name *uint16, flags uint32, desiredAccess uint32) (handle Handle, err error) [failretval == 0 || e1 == ERROR_ALREADY_EXISTS] = kernel32.CreateEventExW
//sys OpenEvent(desiredAccess uint32, inheritHandle bool, name *uint16) (handle Handle, err error) = kernel32.OpenEventW
//sys SetEvent(event Handle) (err error) = kernel32.SetEvent
//sys ResetEvent(event Handle) (err error) = kernel32.ResetEvent
//sys PulseEvent(event Handle) (err error) = kernel32.PulseEvent
//sys CreateMutex(mutexAttrs *SecurityAttributes, initialOwner bool, name *uint16) (handle Handle, err error) [failretval == 0 || e1 == ERROR_ALREADY_EXISTS] = kernel32.CreateMutexW
//sys CreateMutexEx(mutexAttrs *SecurityAttributes, name *uint16, flags uint32, desiredAccess uint32) (handle Handle, err error) [failretval == 0 || e1 == ERROR_ALREADY_EXISTS] = kernel32.CreateMutexExW
//sys OpenMutex(desiredAccess uint32, inheritHandle bool, name *uint16) (handle Handle, err error) = kernel32.OpenMutexW
//sys ReleaseMutex(mutex Handle) (err error) = kernel32.ReleaseMutex
//sys SleepEx(milliseconds uint32, alertable bool) (ret uint32) = kernel32.SleepEx
//sys CreateJobObject(jobAttr *SecurityAttributes, name *uint16) (handle Handle, err error) = kernel32.CreateJobObjectW
//sys AssignProcessToJobObject(job Handle, process Handle) (err error) = kernel32.AssignProcessToJobObject
//sys TerminateJobObject(job Handle, exitCode uint32) (err error) = kernel32.TerminateJobObject
//sys SetErrorMode(mode uint32) (ret uint32) = kernel32.SetErrorMode
//sys ResumeThread(thread Handle) (ret uint32, err error) [failretval==0xffffffff] = kernel32.ResumeThread
//sys SetPriorityClass(process Handle, priorityClass uint32) (err error) = kernel32.SetPriorityClass
//sys GetPriorityClass(process Handle) (ret uint32, err error) = kernel32.GetPriorityClass
//sys QueryInformationJobObject(job Handle, JobObjectInformationClass int32, JobObjectInformation uintptr, JobObjectInformationLength uint32, retlen *uint32) (err error) = kernel32.QueryInformationJobObject
//sys SetInformationJobObject(job Handle, JobObjectInformationClass uint32, JobObjectInformation uintptr, JobObjectInformationLength uint32) (ret int, err error)
//sys GenerateConsoleCtrlEvent(ctrlEvent uint32, processGroupID uint32) (err error)
//sys GetProcessId(process Handle) (id uint32, err error)
//sys QueryFullProcessImageName(proc Handle, flags uint32, exeName *uint16, size *uint32) (err error) = kernel32.QueryFullProcessImageNameW
//sys OpenThread(desiredAccess uint32, inheritHandle bool, threadId uint32) (handle Handle, err error)
//sys SetProcessPriorityBoost(process Handle, disable bool) (err error) = kernel32.SetProcessPriorityBoost
//sys GetProcessWorkingSetSizeEx(hProcess Handle, lpMinimumWorkingSetSize *uintptr, lpMaximumWorkingSetSize *uintptr, flags *uint32)
//sys SetProcessWorkingSetSizeEx(hProcess Handle, dwMinimumWorkingSetSize uintptr, dwMaximumWorkingSetSize uintptr, flags uint32) (err error)
//sys ClearCommBreak(handle Handle) (err error)
//sys ClearCommError(handle Handle, lpErrors *uint32, lpStat *ComStat) (err error)
//sys EscapeCommFunction(handle Handle, dwFunc uint32) (err error)
//sys GetCommState(handle Handle, lpDCB *DCB) (err error)
//sys GetCommModemStatus(handle Handle, lpModemStat *uint32) (err error)
//sys GetCommTimeouts(handle Handle, timeouts *CommTimeouts) (err error)
//sys PurgeComm(handle Handle, dwFlags uint32) (err error)
//sys SetCommBreak(handle Handle) (err error)
//sys SetCommMask(handle Handle, dwEvtMask uint32) (err error)
//sys SetCommState(handle Handle, lpDCB *DCB) (err error)
//sys SetCommTimeouts(handle Handle, timeouts *CommTimeouts) (err error)
//sys SetupComm(handle Handle, dwInQueue uint32, dwOutQueue uint32) (err error)
//sys WaitCommEvent(handle Handle, lpEvtMask *uint32, lpOverlapped *Overlapped) (err error)
//sys GetActiveProcessorCount(groupNumber uint16) (ret uint32)
//sys GetMaximumProcessorCount(groupNumber uint16) (ret uint32)
//sys EnumWindows(enumFunc uintptr, param unsafe.Pointer) (err error) = user32.EnumWindows
//sys EnumChildWindows(hwnd HWND, enumFunc uintptr, param unsafe.Pointer) = user32.EnumChildWindows
//sys GetClassName(hwnd HWND, className *uint16, maxCount int32) (copied int32, err error) = user32.GetClassNameW
//sys GetDesktopWindow() (hwnd HWND) = user32.GetDesktopWindow
//sys GetForegroundWindow() (hwnd HWND) = user32.GetForegroundWindow
//sys IsWindow(hwnd HWND) (isWindow bool) = user32.IsWindow
//sys IsWindowUnicode(hwnd HWND) (isUnicode bool) = user32.IsWindowUnicode
//sys IsWindowVisible(hwnd HWND) (isVisible bool) = user32.IsWindowVisible
//sys GetGUIThreadInfo(thread uint32, info *GUIThreadInfo) (err error) = user32.GetGUIThreadInfo
//sys GetLargePageMinimum() (size uintptr)
// Volume Management Functions
//sys DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err error) = DefineDosDeviceW
//sys DeleteVolumeMountPoint(volumeMountPoint *uint16) (err error) = DeleteVolumeMountPointW
//sys FindFirstVolume(volumeName *uint16, bufferLength uint32) (handle Handle, err error) [failretval==InvalidHandle] = FindFirstVolumeW
//sys FindFirstVolumeMountPoint(rootPathName *uint16, volumeMountPoint *uint16, bufferLength uint32) (handle Handle, err error) [failretval==InvalidHandle] = FindFirstVolumeMountPointW
//sys FindNextVolume(findVolume Handle, volumeName *uint16, bufferLength uint32) (err error) = FindNextVolumeW
//sys FindNextVolumeMountPoint(findVolumeMountPoint Handle, volumeMountPoint *uint16, bufferLength uint32) (err error) = FindNextVolumeMountPointW
//sys FindVolumeClose(findVolume Handle) (err error)
//sys FindVolumeMountPointClose(findVolumeMountPoint Handle) (err error)
//sys GetDiskFreeSpaceEx(directoryName *uint16, freeBytesAvailableToCaller *uint64, totalNumberOfBytes *uint64, totalNumberOfFreeBytes *uint64) (err error) = GetDiskFreeSpaceExW
//sys GetDriveType(rootPathName *uint16) (driveType uint32) = GetDriveTypeW
//sys GetLogicalDrives() (drivesBitMask uint32, err error) [failretval==0]
//sys GetLogicalDriveStrings(bufferLength uint32, buffer *uint16) (n uint32, err error) [failretval==0] = GetLogicalDriveStringsW
//sys GetVolumeInformation(rootPathName *uint16, volumeNameBuffer *uint16, volumeNameSize uint32, volumeNameSerialNumber *uint32, maximumComponentLength *uint32, fileSystemFlags *uint32, fileSystemNameBuffer *uint16, fileSystemNameSize uint32) (err error) = GetVolumeInformationW
//sys GetVolumeInformationByHandle(file Handle, volumeNameBuffer *uint16, volumeNameSize uint32, volumeNameSerialNumber *uint32, maximumComponentLength *uint32, fileSystemFlags *uint32, fileSystemNameBuffer *uint16, fileSystemNameSize uint32) (err error) = GetVolumeInformationByHandleW
//sys GetVolumeNameForVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16, bufferlength uint32) (err error) = GetVolumeNameForVolumeMountPointW
//sys GetVolumePathName(fileName *uint16, volumePathName *uint16, bufferLength uint32) (err error) = GetVolumePathNameW
//sys GetVolumePathNamesForVolumeName(volumeName *uint16, volumePathNames *uint16, bufferLength uint32, returnLength *uint32) (err error) = GetVolumePathNamesForVolumeNameW
//sys QueryDosDevice(deviceName *uint16, targetPath *uint16, max uint32) (n uint32, err error) [failretval==0] = QueryDosDeviceW
//sys SetVolumeLabel(rootPathName *uint16, volumeName *uint16) (err error) = SetVolumeLabelW
//sys SetVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16) (err error) = SetVolumeMountPointW
//sys InitiateSystemShutdownEx(machineName *uint16, message *uint16, timeout uint32, forceAppsClosed bool, rebootAfterShutdown bool, reason uint32) (err error) = advapi32.InitiateSystemShutdownExW
//sys SetProcessShutdownParameters(level uint32, flags uint32) (err error) = kernel32.SetProcessShutdownParameters
//sys GetProcessShutdownParameters(level *uint32, flags *uint32) (err error) = kernel32.GetProcessShutdownParameters
//sys clsidFromString(lpsz *uint16, pclsid *GUID) (ret error) = ole32.CLSIDFromString
//sys stringFromGUID2(rguid *GUID, lpsz *uint16, cchMax int32) (chars int32) = ole32.StringFromGUID2
//sys coCreateGuid(pguid *GUID) (ret error) = ole32.CoCreateGuid
//sys CoTaskMemFree(address unsafe.Pointer) = ole32.CoTaskMemFree
//sys CoInitializeEx(reserved uintptr, coInit uint32) (ret error) = ole32.CoInitializeEx
//sys CoUninitialize() = ole32.CoUninitialize
//sys CoGetObject(name *uint16, bindOpts *BIND_OPTS3, guid *GUID, functionTable **uintptr) (ret error) = ole32.CoGetObject
//sys getProcessPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) = kernel32.GetProcessPreferredUILanguages
//sys getThreadPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) = kernel32.GetThreadPreferredUILanguages
//sys getUserPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) = kernel32.GetUserPreferredUILanguages
//sys getSystemPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) = kernel32.GetSystemPreferredUILanguages
//sys findResource(module Handle, name uintptr, resType uintptr) (resInfo Handle, err error) = kernel32.FindResourceW
//sys SizeofResource(module Handle, resInfo Handle) (size uint32, err error) = kernel32.SizeofResource
//sys LoadResource(module Handle, resInfo Handle) (resData Handle, err error) = kernel32.LoadResource
//sys LockResource(resData Handle) (addr uintptr, err error) = kernel32.LockResource
// Version APIs
//sys GetFileVersionInfoSize(filename string, zeroHandle *Handle) (bufSize uint32, err error) = version.GetFileVersionInfoSizeW
//sys GetFileVersionInfo(filename string, handle uint32, bufSize uint32, buffer unsafe.Pointer) (err error) = version.GetFileVersionInfoW
//sys VerQueryValue(block unsafe.Pointer, subBlock string, pointerToBufferPointer unsafe.Pointer, bufSize *uint32) (err error) = version.VerQueryValueW
// Process Status API (PSAPI)
//sys enumProcesses(processIds *uint32, nSize uint32, bytesReturned *uint32) (err error) = psapi.EnumProcesses
//sys EnumProcessModules(process Handle, module *Handle, cb uint32, cbNeeded *uint32) (err error) = psapi.EnumProcessModules
//sys EnumProcessModulesEx(process Handle, module *Handle, cb uint32, cbNeeded *uint32, filterFlag uint32) (err error) = psapi.EnumProcessModulesEx
//sys GetModuleInformation(process Handle, module Handle, modinfo *ModuleInfo, cb uint32) (err error) = psapi.GetModuleInformation
//sys GetModuleFileNameEx(process Handle, module Handle, filename *uint16, size uint32) (err error) = psapi.GetModuleFileNameExW
//sys GetModuleBaseName(process Handle, module Handle, baseName *uint16, size uint32) (err error) = psapi.GetModuleBaseNameW
//sys QueryWorkingSetEx(process Handle, pv uintptr, cb uint32) (err error) = psapi.QueryWorkingSetEx
// NT Native APIs
//sys rtlNtStatusToDosErrorNoTeb(ntstatus NTStatus) (ret syscall.Errno) = ntdll.RtlNtStatusToDosErrorNoTeb
//sys rtlGetVersion(info *OsVersionInfoEx) (ntstatus error) = ntdll.RtlGetVersion
//sys rtlGetNtVersionNumbers(majorVersion *uint32, minorVersion *uint32, buildNumber *uint32) = ntdll.RtlGetNtVersionNumbers
//sys RtlGetCurrentPeb() (peb *PEB) = ntdll.RtlGetCurrentPeb
//sys RtlInitUnicodeString(destinationString *NTUnicodeString, sourceString *uint16) = ntdll.RtlInitUnicodeString
//sys RtlInitString(destinationString *NTString, sourceString *byte) = ntdll.RtlInitString
//sys NtCreateFile(handle *Handle, access uint32, oa *OBJECT_ATTRIBUTES, iosb *IO_STATUS_BLOCK, allocationSize *int64, attributes uint32, share uint32, disposition uint32, options uint32, eabuffer uintptr, ealength uint32) (ntstatus error) = ntdll.NtCreateFile
//sys NtCreateNamedPipeFile(pipe *Handle, access uint32, oa *OBJECT_ATTRIBUTES, iosb *IO_STATUS_BLOCK, share uint32, disposition uint32, options uint32, typ uint32, readMode uint32, completionMode uint32, maxInstances uint32, inboundQuota uint32, outputQuota uint32, timeout *int64) (ntstatus error) = ntdll.NtCreateNamedPipeFile
//sys NtSetInformationFile(handle Handle, iosb *IO_STATUS_BLOCK, inBuffer *byte, inBufferLen uint32, class uint32) (ntstatus error) = ntdll.NtSetInformationFile
//sys RtlDosPathNameToNtPathName(dosName *uint16, ntName *NTUnicodeString, ntFileNamePart *uint16, relativeName *RTL_RELATIVE_NAME) (ntstatus error) = ntdll.RtlDosPathNameToNtPathName_U_WithStatus
//sys RtlDosPathNameToRelativeNtPathName(dosName *uint16, ntName *NTUnicodeString, ntFileNamePart *uint16, relativeName *RTL_RELATIVE_NAME) (ntstatus error) = ntdll.RtlDosPathNameToRelativeNtPathName_U_WithStatus
//sys RtlDefaultNpAcl(acl **ACL) (ntstatus error) = ntdll.RtlDefaultNpAcl
//sys NtQueryInformationProcess(proc Handle, procInfoClass int32, procInfo unsafe.Pointer, procInfoLen uint32, retLen *uint32) (ntstatus error) = ntdll.NtQueryInformationProcess
//sys NtSetInformationProcess(proc Handle, procInfoClass int32, procInfo unsafe.Pointer, procInfoLen uint32) (ntstatus error) = ntdll.NtSetInformationProcess
//sys NtQuerySystemInformation(sysInfoClass int32, sysInfo unsafe.Pointer, sysInfoLen uint32, retLen *uint32) (ntstatus error) = ntdll.NtQuerySystemInformation
//sys NtSetSystemInformation(sysInfoClass int32, sysInfo unsafe.Pointer, sysInfoLen uint32) (ntstatus error) = ntdll.NtSetSystemInformation
//sys RtlAddFunctionTable(functionTable *RUNTIME_FUNCTION, entryCount uint32, baseAddress uintptr) (ret bool) = ntdll.RtlAddFunctionTable
//sys RtlDeleteFunctionTable(functionTable *RUNTIME_FUNCTION) (ret bool) = ntdll.RtlDeleteFunctionTable
// Desktop Window Manager API (Dwmapi)
//sys DwmGetWindowAttribute(hwnd HWND, attribute uint32, value unsafe.Pointer, size uint32) (ret error) = dwmapi.DwmGetWindowAttribute
//sys DwmSetWindowAttribute(hwnd HWND, attribute uint32, value unsafe.Pointer, size uint32) (ret error) = dwmapi.DwmSetWindowAttribute
// Windows Multimedia API
//sys TimeBeginPeriod (period uint32) (err error) [failretval != 0] = winmm.timeBeginPeriod
//sys TimeEndPeriod (period uint32) (err error) [failretval != 0] = winmm.timeEndPeriod
// syscall interface implementation for other packages
// GetCurrentProcess returns the handle for the current process.
// It is a pseudo handle that does not need to be closed.
// The returned error is always nil.
//
// Deprecated: use CurrentProcess for the same Handle without the nil
// error.
func GetCurrentProcess() (Handle, error) {
return CurrentProcess(), nil
}
// CurrentProcess returns the handle for the current process.
// It is a pseudo handle that does not need to be closed.
func CurrentProcess() Handle { return Handle(^uintptr(1 - 1)) }
// GetCurrentThread returns the handle for the current thread.
// It is a pseudo handle that does not need to be closed.
// The returned error is always nil.
//
// Deprecated: use CurrentThread for the same Handle without the nil
// error.
func GetCurrentThread() (Handle, error) {
return CurrentThread(), nil
}
// CurrentThread returns the handle for the current thread.
// It is a pseudo handle that does not need to be closed.
func CurrentThread() Handle { return Handle(^uintptr(2 - 1)) }
// GetProcAddressByOrdinal retrieves the address of the exported
// function from module by ordinal.
func GetProcAddressByOrdinal(module Handle, ordinal uintptr) (proc uintptr, err error) {
r0, _, e1 := syscall.Syscall(procGetProcAddress.Addr(), 2, uintptr(module), ordinal, 0)
proc = uintptr(r0)
if proc == 0 {
err = errnoErr(e1)
}
return
}
func Exit(code int) { ExitProcess(uint32(code)) }
func makeInheritSa() *SecurityAttributes {
var sa SecurityAttributes
sa.Length = uint32(unsafe.Sizeof(sa))
sa.InheritHandle = 1
return &sa
}
func Open(path string, mode int, perm uint32) (fd Handle, err error) {
if len(path) == 0 {
return InvalidHandle, ERROR_FILE_NOT_FOUND
}
pathp, err := UTF16PtrFromString(path)
if err != nil {
return InvalidHandle, err
}
var access uint32
switch mode & (O_RDONLY | O_WRONLY | O_RDWR) {
case O_RDONLY:
access = GENERIC_READ
case O_WRONLY:
access = GENERIC_WRITE
case O_RDWR:
access = GENERIC_READ | GENERIC_WRITE
}
if mode&O_CREAT != 0 {
access |= GENERIC_WRITE
}
if mode&O_APPEND != 0 {
access &^= GENERIC_WRITE
access |= FILE_APPEND_DATA
}
sharemode := uint32(FILE_SHARE_READ | FILE_SHARE_WRITE)
var sa *SecurityAttributes
if mode&O_CLOEXEC == 0 {
sa = makeInheritSa()
}
var createmode uint32
switch {
case mode&(O_CREAT|O_EXCL) == (O_CREAT | O_EXCL):
createmode = CREATE_NEW
case mode&(O_CREAT|O_TRUNC) == (O_CREAT | O_TRUNC):
createmode = CREATE_ALWAYS
case mode&O_CREAT == O_CREAT:
createmode = OPEN_ALWAYS
case mode&O_TRUNC == O_TRUNC:
createmode = TRUNCATE_EXISTING
default:
createmode = OPEN_EXISTING
}
var attrs uint32 = FILE_ATTRIBUTE_NORMAL
if perm&S_IWRITE == 0 {
attrs = FILE_ATTRIBUTE_READONLY
}
h, e := CreateFile(pathp, access, sharemode, sa, createmode, attrs, 0)
return h, e
}
func Read(fd Handle, p []byte) (n int, err error) {
var done uint32
e := ReadFile(fd, p, &done, nil)
if e != nil {
if e == ERROR_BROKEN_PIPE {
// NOTE(brainman): work around ERROR_BROKEN_PIPE is returned on reading EOF from stdin
return 0, nil
}
return 0, e
}
return int(done), nil
}
func Write(fd Handle, p []byte) (n int, err error) {
if raceenabled {
raceReleaseMerge(unsafe.Pointer(&ioSync))
}
var done uint32
e := WriteFile(fd, p, &done, nil)
if e != nil {
return 0, e
}
return int(done), nil
}
func ReadFile(fd Handle, p []byte, done *uint32, overlapped *Overlapped) error {
err := readFile(fd, p, done, overlapped)
if raceenabled {
if *done > 0 {
raceWriteRange(unsafe.Pointer(&p[0]), int(*done))
}
raceAcquire(unsafe.Pointer(&ioSync))
}
return err
}
func WriteFile(fd Handle, p []byte, done *uint32, overlapped *Overlapped) error {
if raceenabled {
raceReleaseMerge(unsafe.Pointer(&ioSync))
}
err := writeFile(fd, p, done, overlapped)
if raceenabled && *done > 0 {
raceReadRange(unsafe.Pointer(&p[0]), int(*done))
}
return err
}
var ioSync int64
func Seek(fd Handle, offset int64, whence int) (newoffset int64, err error) {
var w uint32
switch whence {
case 0:
w = FILE_BEGIN
case 1:
w = FILE_CURRENT
case 2:
w = FILE_END
}
hi := int32(offset >> 32)
lo := int32(offset)
// use GetFileType to check pipe, pipe can't do seek
ft, _ := GetFileType(fd)
if ft == FILE_TYPE_PIPE {
return 0, syscall.EPIPE
}
rlo, e := SetFilePointer(fd, lo, &hi, w)
if e != nil {
return 0, e
}
return int64(hi)<<32 + int64(rlo), nil
}
func Close(fd Handle) (err error) {
return CloseHandle(fd)
}
var (
Stdin = getStdHandle(STD_INPUT_HANDLE)
Stdout = getStdHandle(STD_OUTPUT_HANDLE)
Stderr = getStdHandle(STD_ERROR_HANDLE)
)
func getStdHandle(stdhandle uint32) (fd Handle) {
r, _ := GetStdHandle(stdhandle)
return r
}
const ImplementsGetwd = true
func Getwd() (wd string, err error) {
b := make([]uint16, 300)
n, e := GetCurrentDirectory(uint32(len(b)), &b[0])
if e != nil {
return "", e
}
return string(utf16.Decode(b[0:n])), nil
}
func Chdir(path string) (err error) {
pathp, err := UTF16PtrFromString(path)
if err != nil {
return err
}
return SetCurrentDirectory(pathp)
}
func Mkdir(path string, mode uint32) (err error) {
pathp, err := UTF16PtrFromString(path)
if err != nil {
return err
}
return CreateDirectory(pathp, nil)
}
func Rmdir(path string) (err error) {
pathp, err := UTF16PtrFromString(path)
if err != nil {
return err
}
return RemoveDirectory(pathp)
}
func Unlink(path string) (err error) {
pathp, err := UTF16PtrFromString(path)
if err != nil {
return err
}
return DeleteFile(pathp)
}
func Rename(oldpath, newpath string) (err error) {
from, err := UTF16PtrFromString(oldpath)
if err != nil {
return err
}
to, err := UTF16PtrFromString(newpath)
if err != nil {
return err
}
return MoveFileEx(from, to, MOVEFILE_REPLACE_EXISTING)
}
func ComputerName() (name string, err error) {
var n uint32 = MAX_COMPUTERNAME_LENGTH + 1
b := make([]uint16, n)
e := GetComputerName(&b[0], &n)
if e != nil {
return "", e
}
return string(utf16.Decode(b[0:n])), nil
}
func DurationSinceBoot() time.Duration {
return time.Duration(getTickCount64()) * time.Millisecond
}
func Ftruncate(fd Handle, length int64) (err error) {
curoffset, e := Seek(fd, 0, 1)
if e != nil {
return e
}
defer Seek(fd, curoffset, 0)
_, e = Seek(fd, length, 0)
if e != nil {
return e
}
e = SetEndOfFile(fd)
if e != nil {
return e
}
return nil
}
func Gettimeofday(tv *Timeval) (err error) {
var ft Filetime
GetSystemTimeAsFileTime(&ft)
*tv = NsecToTimeval(ft.Nanoseconds())
return nil
}
func Pipe(p []Handle) (err error) {
if len(p) != 2 {
return syscall.EINVAL
}
var r, w Handle
e := CreatePipe(&r, &w, makeInheritSa(), 0)
if e != nil {
return e
}
p[0] = r
p[1] = w
return nil
}
func Utimes(path string, tv []Timeval) (err error) {
if len(tv) != 2 {
return syscall.EINVAL
}
pathp, e := UTF16PtrFromString(path)
if e != nil {
return e
}
h, e := CreateFile(pathp,
FILE_WRITE_ATTRIBUTES, FILE_SHARE_WRITE, nil,
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0)
if e != nil {
return e
}
defer CloseHandle(h)
a := NsecToFiletime(tv[0].Nanoseconds())
w := NsecToFiletime(tv[1].Nanoseconds())
return SetFileTime(h, nil, &a, &w)
}
func UtimesNano(path string, ts []Timespec) (err error) {
if len(ts) != 2 {
return syscall.EINVAL
}
pathp, e := UTF16PtrFromString(path)
if e != nil {
return e
}
h, e := CreateFile(pathp,
FILE_WRITE_ATTRIBUTES, FILE_SHARE_WRITE, nil,
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0)
if e != nil {
return e
}
defer CloseHandle(h)
a := NsecToFiletime(TimespecToNsec(ts[0]))
w := NsecToFiletime(TimespecToNsec(ts[1]))
return SetFileTime(h, nil, &a, &w)
}
func Fsync(fd Handle) (err error) {
return FlushFileBuffers(fd)
}
func Chmod(path string, mode uint32) (err error) {
p, e := UTF16PtrFromString(path)
if e != nil {
return e
}
attrs, e := GetFileAttributes(p)
if e != nil {
return e
}
if mode&S_IWRITE != 0 {
attrs &^= FILE_ATTRIBUTE_READONLY
} else {
attrs |= FILE_ATTRIBUTE_READONLY
}
return SetFileAttributes(p, attrs)
}
func LoadGetSystemTimePreciseAsFileTime() error {
return procGetSystemTimePreciseAsFileTime.Find()
}
func LoadCancelIoEx() error {
return procCancelIoEx.Find()
}
func LoadSetFileCompletionNotificationModes() error {
return procSetFileCompletionNotificationModes.Find()
}
func WaitForMultipleObjects(handles []Handle, waitAll bool, waitMilliseconds uint32) (event uint32, err error) {
// Every other win32 array API takes arguments as "pointer, count", except for this function. So we
// can't declare it as a usual [] type, because mksyscall will use the opposite order. We therefore
// trivially stub this ourselves.
var handlePtr *Handle
if len(handles) > 0 {
handlePtr = &handles[0]
}
return waitForMultipleObjects(uint32(len(handles)), uintptr(unsafe.Pointer(handlePtr)), waitAll, waitMilliseconds)
}
// net api calls
const socket_error = uintptr(^uint32(0))
//sys WSAStartup(verreq uint32, data *WSAData) (sockerr error) = ws2_32.WSAStartup
//sys WSACleanup() (err error) [failretval==socket_error] = ws2_32.WSACleanup
//sys WSAIoctl(s Handle, iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbob uint32, cbbr *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) [failretval==socket_error] = ws2_32.WSAIoctl
//sys WSALookupServiceBegin(querySet *WSAQUERYSET, flags uint32, handle *Handle) (err error) [failretval==socket_error] = ws2_32.WSALookupServiceBeginW
//sys WSALookupServiceNext(handle Handle, flags uint32, size *int32, querySet *WSAQUERYSET) (err error) [failretval==socket_error] = ws2_32.WSALookupServiceNextW
//sys WSALookupServiceEnd(handle Handle) (err error) [failretval==socket_error] = ws2_32.WSALookupServiceEnd
//sys socket(af int32, typ int32, protocol int32) (handle Handle, err error) [failretval==InvalidHandle] = ws2_32.socket
//sys sendto(s Handle, buf []byte, flags int32, to unsafe.Pointer, tolen int32) (err error) [failretval==socket_error] = ws2_32.sendto
//sys recvfrom(s Handle, buf []byte, flags int32, from *RawSockaddrAny, fromlen *int32) (n int32, err error) [failretval==-1] = ws2_32.recvfrom
//sys Setsockopt(s Handle, level int32, optname int32, optval *byte, optlen int32) (err error) [failretval==socket_error] = ws2_32.setsockopt
//sys Getsockopt(s Handle, level int32, optname int32, optval *byte, optlen *int32) (err error) [failretval==socket_error] = ws2_32.getsockopt
//sys bind(s Handle, name unsafe.Pointer, namelen int32) (err error) [failretval==socket_error] = ws2_32.bind
//sys connect(s Handle, name unsafe.Pointer, namelen int32) (err error) [failretval==socket_error] = ws2_32.connect
//sys getsockname(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) [failretval==socket_error] = ws2_32.getsockname
//sys getpeername(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) [failretval==socket_error] = ws2_32.getpeername
//sys listen(s Handle, backlog int32) (err error) [failretval==socket_error] = ws2_32.listen
//sys shutdown(s Handle, how int32) (err error) [failretval==socket_error] = ws2_32.shutdown
//sys Closesocket(s Handle) (err error) [failretval==socket_error] = ws2_32.closesocket
//sys AcceptEx(ls Handle, as Handle, buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, recvd *uint32, overlapped *Overlapped) (err error) = mswsock.AcceptEx
//sys GetAcceptExSockaddrs(buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, lrsa **RawSockaddrAny, lrsalen *int32, rrsa **RawSockaddrAny, rrsalen *int32) = mswsock.GetAcceptExSockaddrs
//sys WSARecv(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, overlapped *Overlapped, croutine *byte) (err error) [failretval==socket_error] = ws2_32.WSARecv
//sys WSASend(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, overlapped *Overlapped, croutine *byte) (err error) [failretval==socket_error] = ws2_32.WSASend
//sys WSARecvFrom(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, from *RawSockaddrAny, fromlen *int32, overlapped *Overlapped, croutine *byte) (err error) [failretval==socket_error] = ws2_32.WSARecvFrom
//sys WSASendTo(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to *RawSockaddrAny, tolen int32, overlapped *Overlapped, croutine *byte) (err error) [failretval==socket_error] = ws2_32.WSASendTo
//sys WSASocket(af int32, typ int32, protocol int32, protoInfo *WSAProtocolInfo, group uint32, flags uint32) (handle Handle, err error) [failretval==InvalidHandle] = ws2_32.WSASocketW
//sys GetHostByName(name string) (h *Hostent, err error) [failretval==nil] = ws2_32.gethostbyname
//sys GetServByName(name string, proto string) (s *Servent, err error) [failretval==nil] = ws2_32.getservbyname
//sys Ntohs(netshort uint16) (u uint16) = ws2_32.ntohs
//sys GetProtoByName(name string) (p *Protoent, err error) [failretval==nil] = ws2_32.getprotobyname
//sys DnsQuery(name string, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status error) = dnsapi.DnsQuery_W
//sys DnsRecordListFree(rl *DNSRecord, freetype uint32) = dnsapi.DnsRecordListFree
//sys DnsNameCompare(name1 *uint16, name2 *uint16) (same bool) = dnsapi.DnsNameCompare_W
//sys GetAddrInfoW(nodename *uint16, servicename *uint16, hints *AddrinfoW, result **AddrinfoW) (sockerr error) = ws2_32.GetAddrInfoW
//sys FreeAddrInfoW(addrinfo *AddrinfoW) = ws2_32.FreeAddrInfoW
//sys GetIfEntry(pIfRow *MibIfRow) (errcode error) = iphlpapi.GetIfEntry
//sys GetAdaptersInfo(ai *IpAdapterInfo, ol *uint32) (errcode error) = iphlpapi.GetAdaptersInfo
//sys SetFileCompletionNotificationModes(handle Handle, flags uint8) (err error) = kernel32.SetFileCompletionNotificationModes
//sys WSAEnumProtocols(protocols *int32, protocolBuffer *WSAProtocolInfo, bufferLength *uint32) (n int32, err error) [failretval==-1] = ws2_32.WSAEnumProtocolsW
//sys WSAGetOverlappedResult(h Handle, o *Overlapped, bytes *uint32, wait bool, flags *uint32) (err error) = ws2_32.WSAGetOverlappedResult
//sys GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) = iphlpapi.GetAdaptersAddresses
//sys GetACP() (acp uint32) = kernel32.GetACP
//sys MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) = kernel32.MultiByteToWideChar
//sys getBestInterfaceEx(sockaddr unsafe.Pointer, pdwBestIfIndex *uint32) (errcode error) = iphlpapi.GetBestInterfaceEx
// For testing: clients can set this flag to force
// creation of IPv6 sockets to return EAFNOSUPPORT.
var SocketDisableIPv6 bool
type RawSockaddrInet4 struct {
Family uint16
Port uint16
Addr [4]byte /* in_addr */
Zero [8]uint8
}
type RawSockaddrInet6 struct {
Family uint16
Port uint16
Flowinfo uint32
Addr [16]byte /* in6_addr */
Scope_id uint32
}
type RawSockaddr struct {
Family uint16
Data [14]int8
}
type RawSockaddrAny struct {
Addr RawSockaddr
Pad [100]int8
}
type Sockaddr interface {
sockaddr() (ptr unsafe.Pointer, len int32, err error) // lowercase; only we can define Sockaddrs
}
type SockaddrInet4 struct {
Port int
Addr [4]byte
raw RawSockaddrInet4
}
func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, int32, error) {
if sa.Port < 0 || sa.Port > 0xFFFF {
return nil, 0, syscall.EINVAL
}
sa.raw.Family = AF_INET
p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
p[0] = byte(sa.Port >> 8)
p[1] = byte(sa.Port)
sa.raw.Addr = sa.Addr
return unsafe.Pointer(&sa.raw), int32(unsafe.Sizeof(sa.raw)), nil
}
type SockaddrInet6 struct {
Port int
ZoneId uint32
Addr [16]byte
raw RawSockaddrInet6
}
func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, int32, error) {
if sa.Port < 0 || sa.Port > 0xFFFF {
return nil, 0, syscall.EINVAL
}
sa.raw.Family = AF_INET6
p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
p[0] = byte(sa.Port >> 8)
p[1] = byte(sa.Port)
sa.raw.Scope_id = sa.ZoneId
sa.raw.Addr = sa.Addr
return unsafe.Pointer(&sa.raw), int32(unsafe.Sizeof(sa.raw)), nil
}
type RawSockaddrUnix struct {
Family uint16
Path [UNIX_PATH_MAX]int8
}
type SockaddrUnix struct {
Name string
raw RawSockaddrUnix
}
func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, int32, error) {
name := sa.Name
n := len(name)
if n > len(sa.raw.Path) {
return nil, 0, syscall.EINVAL
}
if n == len(sa.raw.Path) && name[0] != '@' {
return nil, 0, syscall.EINVAL
}
sa.raw.Family = AF_UNIX
for i := 0; i < n; i++ {
sa.raw.Path[i] = int8(name[i])
}
// length is family (uint16), name, NUL.
sl := int32(2)
if n > 0 {
sl += int32(n) + 1
}
if sa.raw.Path[0] == '@' || (sa.raw.Path[0] == 0 && sl > 3) {
// Check sl > 3 so we don't change unnamed socket behavior.
sa.raw.Path[0] = 0
// Don't count trailing NUL for abstract address.
sl--
}
return unsafe.Pointer(&sa.raw), sl, nil
}
type RawSockaddrBth struct {
AddressFamily [2]byte
BtAddr [8]byte
ServiceClassId [16]byte
Port [4]byte
}
type SockaddrBth struct {
BtAddr uint64
ServiceClassId GUID
Port uint32
raw RawSockaddrBth
}
func (sa *SockaddrBth) sockaddr() (unsafe.Pointer, int32, error) {
family := AF_BTH
sa.raw = RawSockaddrBth{
AddressFamily: *(*[2]byte)(unsafe.Pointer(&family)),
BtAddr: *(*[8]byte)(unsafe.Pointer(&sa.BtAddr)),
Port: *(*[4]byte)(unsafe.Pointer(&sa.Port)),
ServiceClassId: *(*[16]byte)(unsafe.Pointer(&sa.ServiceClassId)),
}
return unsafe.Pointer(&sa.raw), int32(unsafe.Sizeof(sa.raw)), nil
}
func (rsa *RawSockaddrAny) Sockaddr() (Sockaddr, error) {
switch rsa.Addr.Family {
case AF_UNIX:
pp := (*RawSockaddrUnix)(unsafe.Pointer(rsa))
sa := new(SockaddrUnix)
if pp.Path[0] == 0 {
// "Abstract" Unix domain socket.
// Rewrite leading NUL as @ for textual display.
// (This is the standard convention.)
// Not friendly to overwrite in place,
// but the callers below don't care.
pp.Path[0] = '@'
}
// Assume path ends at NUL.
// This is not technically the Linux semantics for
// abstract Unix domain sockets--they are supposed
// to be uninterpreted fixed-size binary blobs--but
// everyone uses this convention.
n := 0
for n < len(pp.Path) && pp.Path[n] != 0 {
n++
}
sa.Name = string(unsafe.Slice((*byte)(unsafe.Pointer(&pp.Path[0])), n))
return sa, nil
case AF_INET:
pp := (*RawSockaddrInet4)(unsafe.Pointer(rsa))
sa := new(SockaddrInet4)
p := (*[2]byte)(unsafe.Pointer(&pp.Port))
sa.Port = int(p[0])<<8 + int(p[1])
sa.Addr = pp.Addr
return sa, nil
case AF_INET6:
pp := (*RawSockaddrInet6)(unsafe.Pointer(rsa))
sa := new(SockaddrInet6)
p := (*[2]byte)(unsafe.Pointer(&pp.Port))
sa.Port = int(p[0])<<8 + int(p[1])
sa.ZoneId = pp.Scope_id
sa.Addr = pp.Addr
return sa, nil
}
return nil, syscall.EAFNOSUPPORT
}
func Socket(domain, typ, proto int) (fd Handle, err error) {
if domain == AF_INET6 && SocketDisableIPv6 {
return InvalidHandle, syscall.EAFNOSUPPORT
}
return socket(int32(domain), int32(typ), int32(proto))
}
func SetsockoptInt(fd Handle, level, opt int, value int) (err error) {
v := int32(value)
return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(&v)), int32(unsafe.Sizeof(v)))
}
func Bind(fd Handle, sa Sockaddr) (err error) {
ptr, n, err := sa.sockaddr()
if err != nil {
return err
}
return bind(fd, ptr, n)
}
func Connect(fd Handle, sa Sockaddr) (err error) {
ptr, n, err := sa.sockaddr()
if err != nil {
return err
}
return connect(fd, ptr, n)
}
func GetBestInterfaceEx(sa Sockaddr, pdwBestIfIndex *uint32) (err error) {
ptr, _, err := sa.sockaddr()
if err != nil {
return err
}
return getBestInterfaceEx(ptr, pdwBestIfIndex)
}
func Getsockname(fd Handle) (sa Sockaddr, err error) {
var rsa RawSockaddrAny
l := int32(unsafe.Sizeof(rsa))
if err = getsockname(fd, &rsa, &l); err != nil {
return
}
return rsa.Sockaddr()
}
func Getpeername(fd Handle) (sa Sockaddr, err error) {
var rsa RawSockaddrAny
l := int32(unsafe.Sizeof(rsa))
if err = getpeername(fd, &rsa, &l); err != nil {
return
}
return rsa.Sockaddr()
}
func Listen(s Handle, n int) (err error) {
return listen(s, int32(n))
}
func Shutdown(fd Handle, how int) (err error) {
return shutdown(fd, int32(how))
}
func WSASendto(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to Sockaddr, overlapped *Overlapped, croutine *byte) (err error) {
var rsa unsafe.Pointer
var l int32
if to != nil {
rsa, l, err = to.sockaddr()
if err != nil {
return err
}
}
return WSASendTo(s, bufs, bufcnt, sent, flags, (*RawSockaddrAny)(unsafe.Pointer(rsa)), l, overlapped, croutine)
}
func LoadGetAddrInfo() error {
return procGetAddrInfoW.Find()
}
var connectExFunc struct {
once sync.Once
addr uintptr
err error
}
func LoadConnectEx() error {
connectExFunc.once.Do(func() {
var s Handle
s, connectExFunc.err = Socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)
if connectExFunc.err != nil {
return
}
defer CloseHandle(s)
var n uint32
connectExFunc.err = WSAIoctl(s,
SIO_GET_EXTENSION_FUNCTION_POINTER,
(*byte)(unsafe.Pointer(&WSAID_CONNECTEX)),
uint32(unsafe.Sizeof(WSAID_CONNECTEX)),
(*byte)(unsafe.Pointer(&connectExFunc.addr)),
uint32(unsafe.Sizeof(connectExFunc.addr)),
&n, nil, 0)
})
return connectExFunc.err
}
func connectEx(s Handle, name unsafe.Pointer, namelen int32, sendBuf *byte, sendDataLen uint32, bytesSent *uint32, overlapped *Overlapped) (err error) {
r1, _, e1 := syscall.Syscall9(connectExFunc.addr, 7, uintptr(s), uintptr(name), uintptr(namelen), uintptr(unsafe.Pointer(sendBuf)), uintptr(sendDataLen), uintptr(unsafe.Pointer(bytesSent)), uintptr(unsafe.Pointer(overlapped)), 0, 0)
if r1 == 0 {
if e1 != 0 {
err = error(e1)
} else {
err = syscall.EINVAL
}
}
return
}
func ConnectEx(fd Handle, sa Sockaddr, sendBuf *byte, sendDataLen uint32, bytesSent *uint32, overlapped *Overlapped) error {
err := LoadConnectEx()
if err != nil {
return errorspkg.New("failed to find ConnectEx: " + err.Error())
}
ptr, n, err := sa.sockaddr()
if err != nil {
return err
}
return connectEx(fd, ptr, n, sendBuf, sendDataLen, bytesSent, overlapped)
}
var sendRecvMsgFunc struct {
once sync.Once
sendAddr uintptr
recvAddr uintptr
err error
}
func loadWSASendRecvMsg() error {
sendRecvMsgFunc.once.Do(func() {
var s Handle
s, sendRecvMsgFunc.err = Socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)
if sendRecvMsgFunc.err != nil {
return
}
defer CloseHandle(s)
var n uint32
sendRecvMsgFunc.err = WSAIoctl(s,
SIO_GET_EXTENSION_FUNCTION_POINTER,
(*byte)(unsafe.Pointer(&WSAID_WSARECVMSG)),
uint32(unsafe.Sizeof(WSAID_WSARECVMSG)),
(*byte)(unsafe.Pointer(&sendRecvMsgFunc.recvAddr)),
uint32(unsafe.Sizeof(sendRecvMsgFunc.recvAddr)),
&n, nil, 0)
if sendRecvMsgFunc.err != nil {
return
}
sendRecvMsgFunc.err = WSAIoctl(s,
SIO_GET_EXTENSION_FUNCTION_POINTER,
(*byte)(unsafe.Pointer(&WSAID_WSASENDMSG)),
uint32(unsafe.Sizeof(WSAID_WSASENDMSG)),
(*byte)(unsafe.Pointer(&sendRecvMsgFunc.sendAddr)),
uint32(unsafe.Sizeof(sendRecvMsgFunc.sendAddr)),
&n, nil, 0)
})
return sendRecvMsgFunc.err
}
func WSASendMsg(fd Handle, msg *WSAMsg, flags uint32, bytesSent *uint32, overlapped *Overlapped, croutine *byte) error {
err := loadWSASendRecvMsg()
if err != nil {
return err
}
r1, _, e1 := syscall.Syscall6(sendRecvMsgFunc.sendAddr, 6, uintptr(fd), uintptr(unsafe.Pointer(msg)), uintptr(flags), uintptr(unsafe.Pointer(bytesSent)), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)))
if r1 == socket_error {
err = errnoErr(e1)
}
return err
}
func WSARecvMsg(fd Handle, msg *WSAMsg, bytesReceived *uint32, overlapped *Overlapped, croutine *byte) error {
err := loadWSASendRecvMsg()
if err != nil {
return err
}
r1, _, e1 := syscall.Syscall6(sendRecvMsgFunc.recvAddr, 5, uintptr(fd), uintptr(unsafe.Pointer(msg)), uintptr(unsafe.Pointer(bytesReceived)), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)), 0)
if r1 == socket_error {
err = errnoErr(e1)
}
return err
}
// Invented structures to support what package os expects.
type Rusage struct {
CreationTime Filetime
ExitTime Filetime
KernelTime Filetime
UserTime Filetime
}
type WaitStatus struct {
ExitCode uint32
}
func (w WaitStatus) Exited() bool { return true }
func (w WaitStatus) ExitStatus() int { return int(w.ExitCode) }
func (w WaitStatus) Signal() Signal { return -1 }
func (w WaitStatus) CoreDump() bool { return false }
func (w WaitStatus) Stopped() bool { return false }
func (w WaitStatus) Continued() bool { return false }
func (w WaitStatus) StopSignal() Signal { return -1 }
func (w WaitStatus) Signaled() bool { return false }
func (w WaitStatus) TrapCause() int { return -1 }
// Timespec is an invented structure on Windows, but here for
// consistency with the corresponding package for other operating systems.
type Timespec struct {
Sec int64
Nsec int64
}
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
func NsecToTimespec(nsec int64) (ts Timespec) {
ts.Sec = nsec / 1e9
ts.Nsec = nsec % 1e9
return
}
// TODO(brainman): fix all needed for net
func Accept(fd Handle) (nfd Handle, sa Sockaddr, err error) { return 0, nil, syscall.EWINDOWS }
func Recvfrom(fd Handle, p []byte, flags int) (n int, from Sockaddr, err error) {
var rsa RawSockaddrAny
l := int32(unsafe.Sizeof(rsa))
n32, err := recvfrom(fd, p, int32(flags), &rsa, &l)
n = int(n32)
if err != nil {
return
}
from, err = rsa.Sockaddr()
return
}
func Sendto(fd Handle, p []byte, flags int, to Sockaddr) (err error) {
ptr, l, err := to.sockaddr()
if err != nil {
return err
}
return sendto(fd, p, int32(flags), ptr, l)
}
func SetsockoptTimeval(fd Handle, level, opt int, tv *Timeval) (err error) { return syscall.EWINDOWS }
// The Linger struct is wrong but we only noticed after Go 1.
// sysLinger is the real system call structure.
// BUG(brainman): The definition of Linger is not appropriate for direct use
// with Setsockopt and Getsockopt.
// Use SetsockoptLinger instead.
type Linger struct {
Onoff int32
Linger int32
}
type sysLinger struct {
Onoff uint16
Linger uint16
}
type IPMreq struct {
Multiaddr [4]byte /* in_addr */
Interface [4]byte /* in_addr */
}
type IPv6Mreq struct {
Multiaddr [16]byte /* in6_addr */
Interface uint32
}
func GetsockoptInt(fd Handle, level, opt int) (int, error) {
v := int32(0)
l := int32(unsafe.Sizeof(v))
err := Getsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(&v)), &l)
return int(v), err
}
func SetsockoptLinger(fd Handle, level, opt int, l *Linger) (err error) {
sys := sysLinger{Onoff: uint16(l.Onoff), Linger: uint16(l.Linger)}
return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(&sys)), int32(unsafe.Sizeof(sys)))
}
func SetsockoptInet4Addr(fd Handle, level, opt int, value [4]byte) (err error) {
return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(&value[0])), 4)
}
func SetsockoptIPMreq(fd Handle, level, opt int, mreq *IPMreq) (err error) {
return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(mreq)), int32(unsafe.Sizeof(*mreq)))
}
func SetsockoptIPv6Mreq(fd Handle, level, opt int, mreq *IPv6Mreq) (err error) {
return syscall.EWINDOWS
}
func EnumProcesses(processIds []uint32, bytesReturned *uint32) error {
// EnumProcesses syscall expects the size parameter to be in bytes, but the code generated with mksyscall uses
// the length of the processIds slice instead. Hence, this wrapper function is added to fix the discrepancy.
var p *uint32
if len(processIds) > 0 {
p = &processIds[0]
}
size := uint32(len(processIds) * 4)
return enumProcesses(p, size, bytesReturned)
}
func Getpid() (pid int) { return int(GetCurrentProcessId()) }
func FindFirstFile(name *uint16, data *Win32finddata) (handle Handle, err error) {
// NOTE(rsc): The Win32finddata struct is wrong for the system call:
// the two paths are each one uint16 short. Use the correct struct,
// a win32finddata1, and then copy the results out.
// There is no loss of expressivity here, because the final
// uint16, if it is used, is supposed to be a NUL, and Go doesn't need that.
// For Go 1.1, we might avoid the allocation of win32finddata1 here
// by adding a final Bug [2]uint16 field to the struct and then
// adjusting the fields in the result directly.
var data1 win32finddata1
handle, err = findFirstFile1(name, &data1)
if err == nil {
copyFindData(data, &data1)
}
return
}
func FindNextFile(handle Handle, data *Win32finddata) (err error) {
var data1 win32finddata1
err = findNextFile1(handle, &data1)
if err == nil {
copyFindData(data, &data1)
}
return
}
func getProcessEntry(pid int) (*ProcessEntry32, error) {
snapshot, err := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
if err != nil {
return nil, err
}
defer CloseHandle(snapshot)
var procEntry ProcessEntry32
procEntry.Size = uint32(unsafe.Sizeof(procEntry))
if err = Process32First(snapshot, &procEntry); err != nil {
return nil, err
}
for {
if procEntry.ProcessID == uint32(pid) {
return &procEntry, nil
}
err = Process32Next(snapshot, &procEntry)
if err != nil {
return nil, err
}
}
}
func Getppid() (ppid int) {
pe, err := getProcessEntry(Getpid())
if err != nil {
return -1
}
return int(pe.ParentProcessID)
}
// TODO(brainman): fix all needed for os
func Fchdir(fd Handle) (err error) { return syscall.EWINDOWS }
func Link(oldpath, newpath string) (err error) { return syscall.EWINDOWS }
func Symlink(path, link string) (err error) { return syscall.EWINDOWS }
func Fchmod(fd Handle, mode uint32) (err error) { return syscall.EWINDOWS }
func Chown(path string, uid int, gid int) (err error) { return syscall.EWINDOWS }
func Lchown(path string, uid int, gid int) (err error) { return syscall.EWINDOWS }
func Fchown(fd Handle, uid int, gid int) (err error) { return syscall.EWINDOWS }
func Getuid() (uid int) { return -1 }
func Geteuid() (euid int) { return -1 }
func Getgid() (gid int) { return -1 }
func Getegid() (egid int) { return -1 }
func Getgroups() (gids []int, err error) { return nil, syscall.EWINDOWS }
type Signal int
func (s Signal) Signal() {}
func (s Signal) String() string {
if 0 <= s && int(s) < len(signals) {
str := signals[s]
if str != "" {
return str
}
}
return "signal " + itoa(int(s))
}
func LoadCreateSymbolicLink() error {
return procCreateSymbolicLinkW.Find()
}
// Readlink returns the destination of the named symbolic link.
func Readlink(path string, buf []byte) (n int, err error) {
fd, err := CreateFile(StringToUTF16Ptr(path), GENERIC_READ, 0, nil, OPEN_EXISTING,
FILE_FLAG_OPEN_REPARSE_POINT|FILE_FLAG_BACKUP_SEMANTICS, 0)
if err != nil {
return -1, err
}
defer CloseHandle(fd)
rdbbuf := make([]byte, MAXIMUM_REPARSE_DATA_BUFFER_SIZE)
var bytesReturned uint32
err = DeviceIoControl(fd, FSCTL_GET_REPARSE_POINT, nil, 0, &rdbbuf[0], uint32(len(rdbbuf)), &bytesReturned, nil)
if err != nil {
return -1, err
}
rdb := (*reparseDataBuffer)(unsafe.Pointer(&rdbbuf[0]))
var s string
switch rdb.ReparseTag {
case IO_REPARSE_TAG_SYMLINK:
data := (*symbolicLinkReparseBuffer)(unsafe.Pointer(&rdb.reparseBuffer))
p := (*[0xffff]uint16)(unsafe.Pointer(&data.PathBuffer[0]))
s = UTF16ToString(p[data.PrintNameOffset/2 : (data.PrintNameLength-data.PrintNameOffset)/2])
case IO_REPARSE_TAG_MOUNT_POINT:
data := (*mountPointReparseBuffer)(unsafe.Pointer(&rdb.reparseBuffer))
p := (*[0xffff]uint16)(unsafe.Pointer(&data.PathBuffer[0]))
s = UTF16ToString(p[data.PrintNameOffset/2 : (data.PrintNameLength-data.PrintNameOffset)/2])
default:
// the path is not a symlink or junction but another type of reparse
// point
return -1, syscall.ENOENT
}
n = copy(buf, []byte(s))
return n, nil
}
// GUIDFromString parses a string in the form of
// "{XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}" into a GUID.
func GUIDFromString(str string) (GUID, error) {
guid := GUID{}
str16, err := syscall.UTF16PtrFromString(str)
if err != nil {
return guid, err
}
err = clsidFromString(str16, &guid)
if err != nil {
return guid, err
}
return guid, nil
}
// GenerateGUID creates a new random GUID.
func GenerateGUID() (GUID, error) {
guid := GUID{}
err := coCreateGuid(&guid)
if err != nil {
return guid, err
}
return guid, nil
}
// String returns the canonical string form of the GUID,
// in the form of "{XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}".
func (guid GUID) String() string {
var str [100]uint16
chars := stringFromGUID2(&guid, &str[0], int32(len(str)))
if chars <= 1 {
return ""
}
return string(utf16.Decode(str[:chars-1]))
}
// KnownFolderPath returns a well-known folder path for the current user, specified by one of
// the FOLDERID_ constants, and chosen and optionally created based on a KF_ flag.
func KnownFolderPath(folderID *KNOWNFOLDERID, flags uint32) (string, error) {
return Token(0).KnownFolderPath(folderID, flags)
}
// KnownFolderPath returns a well-known folder path for the user token, specified by one of
// the FOLDERID_ constants, and chosen and optionally created based on a KF_ flag.
func (t Token) KnownFolderPath(folderID *KNOWNFOLDERID, flags uint32) (string, error) {
var p *uint16
err := shGetKnownFolderPath(folderID, flags, t, &p)
if err != nil {
return "", err
}
defer CoTaskMemFree(unsafe.Pointer(p))
return UTF16PtrToString(p), nil
}
// RtlGetVersion returns the version of the underlying operating system, ignoring
// manifest semantics but is affected by the application compatibility layer.
func RtlGetVersion() *OsVersionInfoEx {
info := &OsVersionInfoEx{}
info.osVersionInfoSize = uint32(unsafe.Sizeof(*info))
// According to documentation, this function always succeeds.
// The function doesn't even check the validity of the
// osVersionInfoSize member. Disassembling ntdll.dll indicates
// that the documentation is indeed correct about that.
_ = rtlGetVersion(info)
return info
}
// RtlGetNtVersionNumbers returns the version of the underlying operating system,
// ignoring manifest semantics and the application compatibility layer.
func RtlGetNtVersionNumbers() (majorVersion, minorVersion, buildNumber uint32) {
rtlGetNtVersionNumbers(&majorVersion, &minorVersion, &buildNumber)
buildNumber &= 0xffff
return
}
// GetProcessPreferredUILanguages retrieves the process preferred UI languages.
func GetProcessPreferredUILanguages(flags uint32) ([]string, error) {
return getUILanguages(flags, getProcessPreferredUILanguages)
}
// GetThreadPreferredUILanguages retrieves the thread preferred UI languages for the current thread.
func GetThreadPreferredUILanguages(flags uint32) ([]string, error) {
return getUILanguages(flags, getThreadPreferredUILanguages)
}
// GetUserPreferredUILanguages retrieves information about the user preferred UI languages.
func GetUserPreferredUILanguages(flags uint32) ([]string, error) {
return getUILanguages(flags, getUserPreferredUILanguages)
}
// GetSystemPreferredUILanguages retrieves the system preferred UI languages.
func GetSystemPreferredUILanguages(flags uint32) ([]string, error) {
return getUILanguages(flags, getSystemPreferredUILanguages)
}
func getUILanguages(flags uint32, f func(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) error) ([]string, error) {
size := uint32(128)
for {
var numLanguages uint32
buf := make([]uint16, size)
err := f(flags, &numLanguages, &buf[0], &size)
if err == ERROR_INSUFFICIENT_BUFFER {
continue
}
if err != nil {
return nil, err
}
buf = buf[:size]
if numLanguages == 0 || len(buf) == 0 { // GetProcessPreferredUILanguages may return numLanguages==0 with "\0\0"
return []string{}, nil
}
if buf[len(buf)-1] == 0 {
buf = buf[:len(buf)-1] // remove terminating null
}
languages := make([]string, 0, numLanguages)
from := 0
for i, c := range buf {
if c == 0 {
languages = append(languages, string(utf16.Decode(buf[from:i])))
from = i + 1
}
}
return languages, nil
}
}
func SetConsoleCursorPosition(console Handle, position Coord) error {
return setConsoleCursorPosition(console, *((*uint32)(unsafe.Pointer(&position))))
}
func GetStartupInfo(startupInfo *StartupInfo) error {
getStartupInfo(startupInfo)
return nil
}
func (s NTStatus) Errno() syscall.Errno {
return rtlNtStatusToDosErrorNoTeb(s)
}
func langID(pri, sub uint16) uint32 { return uint32(sub)<<10 | uint32(pri) }
func (s NTStatus) Error() string {
b := make([]uint16, 300)
n, err := FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_FROM_HMODULE|FORMAT_MESSAGE_ARGUMENT_ARRAY, modntdll.Handle(), uint32(s), langID(LANG_ENGLISH, SUBLANG_ENGLISH_US), b, nil)
if err != nil {
return fmt.Sprintf("NTSTATUS 0x%08x", uint32(s))
}
// trim terminating \r and \n
for ; n > 0 && (b[n-1] == '\n' || b[n-1] == '\r'); n-- {
}
return string(utf16.Decode(b[:n]))
}
// NewNTUnicodeString returns a new NTUnicodeString structure for use with native
// NT APIs that work over the NTUnicodeString type. Note that most Windows APIs
// do not use NTUnicodeString, and instead UTF16PtrFromString should be used for
// the more common *uint16 string type.
func NewNTUnicodeString(s string) (*NTUnicodeString, error) {
var u NTUnicodeString
s16, err := UTF16PtrFromString(s)
if err != nil {
return nil, err
}
RtlInitUnicodeString(&u, s16)
return &u, nil
}
// Slice returns a uint16 slice that aliases the data in the NTUnicodeString.
func (s *NTUnicodeString) Slice() []uint16 {
slice := unsafe.Slice(s.Buffer, s.MaximumLength)
return slice[:s.Length]
}
func (s *NTUnicodeString) String() string {
return UTF16ToString(s.Slice())
}
// NewNTString returns a new NTString structure for use with native
// NT APIs that work over the NTString type. Note that most Windows APIs
// do not use NTString, and instead UTF16PtrFromString should be used for
// the more common *uint16 string type.
func NewNTString(s string) (*NTString, error) {
var nts NTString
s8, err := BytePtrFromString(s)
if err != nil {
return nil, err
}
RtlInitString(&nts, s8)
return &nts, nil
}
// Slice returns a byte slice that aliases the data in the NTString.
func (s *NTString) Slice() []byte {
slice := unsafe.Slice(s.Buffer, s.MaximumLength)
return slice[:s.Length]
}
func (s *NTString) String() string {
return ByteSliceToString(s.Slice())
}
// FindResource resolves a resource of the given name and resource type.
func FindResource(module Handle, name, resType ResourceIDOrString) (Handle, error) {
var namePtr, resTypePtr uintptr
var name16, resType16 *uint16
var err error
resolvePtr := func(i interface{}, keep **uint16) (uintptr, error) {
switch v := i.(type) {
case string:
*keep, err = UTF16PtrFromString(v)
if err != nil {
return 0, err
}
return uintptr(unsafe.Pointer(*keep)), nil
case ResourceID:
return uintptr(v), nil
}
return 0, errorspkg.New("parameter must be a ResourceID or a string")
}
namePtr, err = resolvePtr(name, &name16)
if err != nil {
return 0, err
}
resTypePtr, err = resolvePtr(resType, &resType16)
if err != nil {
return 0, err
}
resInfo, err := findResource(module, namePtr, resTypePtr)
runtime.KeepAlive(name16)
runtime.KeepAlive(resType16)
return resInfo, err
}
func LoadResourceData(module, resInfo Handle) (data []byte, err error) {
size, err := SizeofResource(module, resInfo)
if err != nil {
return
}
resData, err := LoadResource(module, resInfo)
if err != nil {
return
}
ptr, err := LockResource(resData)
if err != nil {
return
}
data = unsafe.Slice((*byte)(unsafe.Pointer(ptr)), size)
return
}
// PSAPI_WORKING_SET_EX_BLOCK contains extended working set information for a page.
type PSAPI_WORKING_SET_EX_BLOCK uint64
// Valid returns the validity of this page.
// If this bit is 1, the subsequent members are valid; otherwise they should be ignored.
func (b PSAPI_WORKING_SET_EX_BLOCK) Valid() bool {
return (b & 1) == 1
}
// ShareCount is the number of processes that share this page. The maximum value of this member is 7.
func (b PSAPI_WORKING_SET_EX_BLOCK) ShareCount() uint64 {
return b.intField(1, 3)
}
// Win32Protection is the memory protection attributes of the page. For a list of values, see
// https://docs.microsoft.com/en-us/windows/win32/memory/memory-protection-constants
func (b PSAPI_WORKING_SET_EX_BLOCK) Win32Protection() uint64 {
return b.intField(4, 11)
}
// Shared returns the shared status of this page.
// If this bit is 1, the page can be shared.
func (b PSAPI_WORKING_SET_EX_BLOCK) Shared() bool {
return (b & (1 << 15)) == 1
}
// Node is the NUMA node. The maximum value of this member is 63.
func (b PSAPI_WORKING_SET_EX_BLOCK) Node() uint64 {
return b.intField(16, 6)
}
// Locked returns the locked status of this page.
// If this bit is 1, the virtual page is locked in physical memory.
func (b PSAPI_WORKING_SET_EX_BLOCK) Locked() bool {
return (b & (1 << 22)) == 1
}
// LargePage returns the large page status of this page.
// If this bit is 1, the page is a large page.
func (b PSAPI_WORKING_SET_EX_BLOCK) LargePage() bool {
return (b & (1 << 23)) == 1
}
// Bad returns the bad status of this page.
// If this bit is 1, the page is has been reported as bad.
func (b PSAPI_WORKING_SET_EX_BLOCK) Bad() bool {
return (b & (1 << 31)) == 1
}
// intField extracts an integer field in the PSAPI_WORKING_SET_EX_BLOCK union.
func (b PSAPI_WORKING_SET_EX_BLOCK) intField(start, length int) uint64 {
var mask PSAPI_WORKING_SET_EX_BLOCK
for pos := start; pos < start+length; pos++ {
mask |= (1 << pos)
}
masked := b & mask
return uint64(masked >> start)
}
// PSAPI_WORKING_SET_EX_INFORMATION contains extended working set information for a process.
type PSAPI_WORKING_SET_EX_INFORMATION struct {
// The virtual address.
VirtualAddress Pointer
// A PSAPI_WORKING_SET_EX_BLOCK union that indicates the attributes of the page at VirtualAddress.
VirtualAttributes PSAPI_WORKING_SET_EX_BLOCK
}
// CreatePseudoConsole creates a windows pseudo console.
func CreatePseudoConsole(size Coord, in Handle, out Handle, flags uint32, pconsole *Handle) error {
// We need this wrapper to manually cast Coord to uint32. The autogenerated wrappers only
// accept arguments that can be casted to uintptr, and Coord can't.
return createPseudoConsole(*((*uint32)(unsafe.Pointer(&size))), in, out, flags, pconsole)
}
// ResizePseudoConsole resizes the internal buffers of the pseudo console to the width and height specified in `size`.
func ResizePseudoConsole(pconsole Handle, size Coord) error {
// We need this wrapper to manually cast Coord to uint32. The autogenerated wrappers only
// accept arguments that can be casted to uintptr, and Coord can't.
return resizePseudoConsole(pconsole, *((*uint32)(unsafe.Pointer(&size))))
}
// DCB constants. See https://learn.microsoft.com/en-us/windows/win32/api/winbase/ns-winbase-dcb.
const (
CBR_110 = 110
CBR_300 = 300
CBR_600 = 600
CBR_1200 = 1200
CBR_2400 = 2400
CBR_4800 = 4800
CBR_9600 = 9600
CBR_14400 = 14400
CBR_19200 = 19200
CBR_38400 = 38400
CBR_57600 = 57600
CBR_115200 = 115200
CBR_128000 = 128000
CBR_256000 = 256000
DTR_CONTROL_DISABLE = 0x00000000
DTR_CONTROL_ENABLE = 0x00000010
DTR_CONTROL_HANDSHAKE = 0x00000020
RTS_CONTROL_DISABLE = 0x00000000
RTS_CONTROL_ENABLE = 0x00001000
RTS_CONTROL_HANDSHAKE = 0x00002000
RTS_CONTROL_TOGGLE = 0x00003000
NOPARITY = 0
ODDPARITY = 1
EVENPARITY = 2
MARKPARITY = 3
SPACEPARITY = 4
ONESTOPBIT = 0
ONE5STOPBITS = 1
TWOSTOPBITS = 2
)
// EscapeCommFunction constants. See https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-escapecommfunction.
const (
SETXOFF = 1
SETXON = 2
SETRTS = 3
CLRRTS = 4
SETDTR = 5
CLRDTR = 6
SETBREAK = 8
CLRBREAK = 9
)
// PurgeComm constants. See https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-purgecomm.
const (
PURGE_TXABORT = 0x0001
PURGE_RXABORT = 0x0002
PURGE_TXCLEAR = 0x0004
PURGE_RXCLEAR = 0x0008
)
// SetCommMask constants. See https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setcommmask.
const (
EV_RXCHAR = 0x0001
EV_RXFLAG = 0x0002
EV_TXEMPTY = 0x0004
EV_CTS = 0x0008
EV_DSR = 0x0010
EV_RLSD = 0x0020
EV_BREAK = 0x0040
EV_ERR = 0x0080
EV_RING = 0x0100
)
|
go/src/cmd/vendor/golang.org/x/sys/windows/syscall_windows.go/0
|
{
"file_path": "go/src/cmd/vendor/golang.org/x/sys/windows/syscall_windows.go",
"repo_id": "go",
"token_count": 30432
}
| 191 |
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
package term
import (
"golang.org/x/sys/unix"
)
type state struct {
termios unix.Termios
}
func isTerminal(fd int) bool {
_, err := unix.IoctlGetTermios(fd, ioctlReadTermios)
return err == nil
}
func makeRaw(fd int) (*State, error) {
termios, err := unix.IoctlGetTermios(fd, ioctlReadTermios)
if err != nil {
return nil, err
}
oldState := State{state{termios: *termios}}
// This attempts to replicate the behaviour documented for cfmakeraw in
// the termios(3) manpage.
termios.Iflag &^= unix.IGNBRK | unix.BRKINT | unix.PARMRK | unix.ISTRIP | unix.INLCR | unix.IGNCR | unix.ICRNL | unix.IXON
termios.Oflag &^= unix.OPOST
termios.Lflag &^= unix.ECHO | unix.ECHONL | unix.ICANON | unix.ISIG | unix.IEXTEN
termios.Cflag &^= unix.CSIZE | unix.PARENB
termios.Cflag |= unix.CS8
termios.Cc[unix.VMIN] = 1
termios.Cc[unix.VTIME] = 0
if err := unix.IoctlSetTermios(fd, ioctlWriteTermios, termios); err != nil {
return nil, err
}
return &oldState, nil
}
func getState(fd int) (*State, error) {
termios, err := unix.IoctlGetTermios(fd, ioctlReadTermios)
if err != nil {
return nil, err
}
return &State{state{termios: *termios}}, nil
}
func restore(fd int, state *State) error {
return unix.IoctlSetTermios(fd, ioctlWriteTermios, &state.termios)
}
func getSize(fd int) (width, height int, err error) {
ws, err := unix.IoctlGetWinsize(fd, unix.TIOCGWINSZ)
if err != nil {
return 0, 0, err
}
return int(ws.Col), int(ws.Row), nil
}
// passwordReader is an io.Reader that reads from a specific file descriptor.
type passwordReader int
func (r passwordReader) Read(buf []byte) (int, error) {
return unix.Read(int(r), buf)
}
func readPassword(fd int) ([]byte, error) {
termios, err := unix.IoctlGetTermios(fd, ioctlReadTermios)
if err != nil {
return nil, err
}
newState := *termios
newState.Lflag &^= unix.ECHO
newState.Lflag |= unix.ICANON | unix.ISIG
newState.Iflag |= unix.ICRNL
if err := unix.IoctlSetTermios(fd, ioctlWriteTermios, &newState); err != nil {
return nil, err
}
defer unix.IoctlSetTermios(fd, ioctlWriteTermios, termios)
return readPasswordLine(passwordReader(fd))
}
|
go/src/cmd/vendor/golang.org/x/term/term_unix.go/0
|
{
"file_path": "go/src/cmd/vendor/golang.org/x/term/term_unix.go",
"repo_id": "go",
"token_count": 958
}
| 192 |
// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package language
import (
"bytes"
"fmt"
"sort"
"strconv"
"golang.org/x/text/internal/tag"
)
// findIndex tries to find the given tag in idx and returns a standardized error
// if it could not be found.
func findIndex(idx tag.Index, key []byte, form string) (index int, err error) {
if !tag.FixCase(form, key) {
return 0, ErrSyntax
}
i := idx.Index(key)
if i == -1 {
return 0, NewValueError(key)
}
return i, nil
}
func searchUint(imap []uint16, key uint16) int {
return sort.Search(len(imap), func(i int) bool {
return imap[i] >= key
})
}
type Language uint16
// getLangID returns the langID of s if s is a canonical subtag
// or langUnknown if s is not a canonical subtag.
func getLangID(s []byte) (Language, error) {
if len(s) == 2 {
return getLangISO2(s)
}
return getLangISO3(s)
}
// TODO language normalization as well as the AliasMaps could be moved to the
// higher level package, but it is a bit tricky to separate the generation.
func (id Language) Canonicalize() (Language, AliasType) {
return normLang(id)
}
// normLang returns the mapped langID of id according to mapping m.
func normLang(id Language) (Language, AliasType) {
k := sort.Search(len(AliasMap), func(i int) bool {
return AliasMap[i].From >= uint16(id)
})
if k < len(AliasMap) && AliasMap[k].From == uint16(id) {
return Language(AliasMap[k].To), AliasTypes[k]
}
return id, AliasTypeUnknown
}
// getLangISO2 returns the langID for the given 2-letter ISO language code
// or unknownLang if this does not exist.
func getLangISO2(s []byte) (Language, error) {
if !tag.FixCase("zz", s) {
return 0, ErrSyntax
}
if i := lang.Index(s); i != -1 && lang.Elem(i)[3] != 0 {
return Language(i), nil
}
return 0, NewValueError(s)
}
const base = 'z' - 'a' + 1
func strToInt(s []byte) uint {
v := uint(0)
for i := 0; i < len(s); i++ {
v *= base
v += uint(s[i] - 'a')
}
return v
}
// converts the given integer to the original ASCII string passed to strToInt.
// len(s) must match the number of characters obtained.
func intToStr(v uint, s []byte) {
for i := len(s) - 1; i >= 0; i-- {
s[i] = byte(v%base) + 'a'
v /= base
}
}
// getLangISO3 returns the langID for the given 3-letter ISO language code
// or unknownLang if this does not exist.
func getLangISO3(s []byte) (Language, error) {
if tag.FixCase("und", s) {
// first try to match canonical 3-letter entries
for i := lang.Index(s[:2]); i != -1; i = lang.Next(s[:2], i) {
if e := lang.Elem(i); e[3] == 0 && e[2] == s[2] {
// We treat "und" as special and always translate it to "unspecified".
// Note that ZZ and Zzzz are private use and are not treated as
// unspecified by default.
id := Language(i)
if id == nonCanonicalUnd {
return 0, nil
}
return id, nil
}
}
if i := altLangISO3.Index(s); i != -1 {
return Language(altLangIndex[altLangISO3.Elem(i)[3]]), nil
}
n := strToInt(s)
if langNoIndex[n/8]&(1<<(n%8)) != 0 {
return Language(n) + langNoIndexOffset, nil
}
// Check for non-canonical uses of ISO3.
for i := lang.Index(s[:1]); i != -1; i = lang.Next(s[:1], i) {
if e := lang.Elem(i); e[2] == s[1] && e[3] == s[2] {
return Language(i), nil
}
}
return 0, NewValueError(s)
}
return 0, ErrSyntax
}
// StringToBuf writes the string to b and returns the number of bytes
// written. cap(b) must be >= 3.
func (id Language) StringToBuf(b []byte) int {
if id >= langNoIndexOffset {
intToStr(uint(id)-langNoIndexOffset, b[:3])
return 3
} else if id == 0 {
return copy(b, "und")
}
l := lang[id<<2:]
if l[3] == 0 {
return copy(b, l[:3])
}
return copy(b, l[:2])
}
// String returns the BCP 47 representation of the langID.
// Use b as variable name, instead of id, to ensure the variable
// used is consistent with that of Base in which this type is embedded.
func (b Language) String() string {
if b == 0 {
return "und"
} else if b >= langNoIndexOffset {
b -= langNoIndexOffset
buf := [3]byte{}
intToStr(uint(b), buf[:])
return string(buf[:])
}
l := lang.Elem(int(b))
if l[3] == 0 {
return l[:3]
}
return l[:2]
}
// ISO3 returns the ISO 639-3 language code.
func (b Language) ISO3() string {
if b == 0 || b >= langNoIndexOffset {
return b.String()
}
l := lang.Elem(int(b))
if l[3] == 0 {
return l[:3]
} else if l[2] == 0 {
return altLangISO3.Elem(int(l[3]))[:3]
}
// This allocation will only happen for 3-letter ISO codes
// that are non-canonical BCP 47 language identifiers.
return l[0:1] + l[2:4]
}
// IsPrivateUse reports whether this language code is reserved for private use.
func (b Language) IsPrivateUse() bool {
return langPrivateStart <= b && b <= langPrivateEnd
}
// SuppressScript returns the script marked as SuppressScript in the IANA
// language tag repository, or 0 if there is no such script.
func (b Language) SuppressScript() Script {
if b < langNoIndexOffset {
return Script(suppressScript[b])
}
return 0
}
type Region uint16
// getRegionID returns the region id for s if s is a valid 2-letter region code
// or unknownRegion.
func getRegionID(s []byte) (Region, error) {
if len(s) == 3 {
if isAlpha(s[0]) {
return getRegionISO3(s)
}
if i, err := strconv.ParseUint(string(s), 10, 10); err == nil {
return getRegionM49(int(i))
}
}
return getRegionISO2(s)
}
// getRegionISO2 returns the regionID for the given 2-letter ISO country code
// or unknownRegion if this does not exist.
func getRegionISO2(s []byte) (Region, error) {
i, err := findIndex(regionISO, s, "ZZ")
if err != nil {
return 0, err
}
return Region(i) + isoRegionOffset, nil
}
// getRegionISO3 returns the regionID for the given 3-letter ISO country code
// or unknownRegion if this does not exist.
func getRegionISO3(s []byte) (Region, error) {
if tag.FixCase("ZZZ", s) {
for i := regionISO.Index(s[:1]); i != -1; i = regionISO.Next(s[:1], i) {
if e := regionISO.Elem(i); e[2] == s[1] && e[3] == s[2] {
return Region(i) + isoRegionOffset, nil
}
}
for i := 0; i < len(altRegionISO3); i += 3 {
if tag.Compare(altRegionISO3[i:i+3], s) == 0 {
return Region(altRegionIDs[i/3]), nil
}
}
return 0, NewValueError(s)
}
return 0, ErrSyntax
}
func getRegionM49(n int) (Region, error) {
if 0 < n && n <= 999 {
const (
searchBits = 7
regionBits = 9
regionMask = 1<<regionBits - 1
)
idx := n >> searchBits
buf := fromM49[m49Index[idx]:m49Index[idx+1]]
val := uint16(n) << regionBits // we rely on bits shifting out
i := sort.Search(len(buf), func(i int) bool {
return buf[i] >= val
})
if r := fromM49[int(m49Index[idx])+i]; r&^regionMask == val {
return Region(r & regionMask), nil
}
}
var e ValueError
fmt.Fprint(bytes.NewBuffer([]byte(e.v[:])), n)
return 0, e
}
// normRegion returns a region if r is deprecated or 0 otherwise.
// TODO: consider supporting BYS (-> BLR), CSK (-> 200 or CZ), PHI (-> PHL) and AFI (-> DJ).
// TODO: consider mapping split up regions to new most populous one (like CLDR).
func normRegion(r Region) Region {
m := regionOldMap
k := sort.Search(len(m), func(i int) bool {
return m[i].From >= uint16(r)
})
if k < len(m) && m[k].From == uint16(r) {
return Region(m[k].To)
}
return 0
}
const (
iso3166UserAssigned = 1 << iota
ccTLD
bcp47Region
)
func (r Region) typ() byte {
return regionTypes[r]
}
// String returns the BCP 47 representation for the region.
// It returns "ZZ" for an unspecified region.
func (r Region) String() string {
if r < isoRegionOffset {
if r == 0 {
return "ZZ"
}
return fmt.Sprintf("%03d", r.M49())
}
r -= isoRegionOffset
return regionISO.Elem(int(r))[:2]
}
// ISO3 returns the 3-letter ISO code of r.
// Note that not all regions have a 3-letter ISO code.
// In such cases this method returns "ZZZ".
func (r Region) ISO3() string {
if r < isoRegionOffset {
return "ZZZ"
}
r -= isoRegionOffset
reg := regionISO.Elem(int(r))
switch reg[2] {
case 0:
return altRegionISO3[reg[3]:][:3]
case ' ':
return "ZZZ"
}
return reg[0:1] + reg[2:4]
}
// M49 returns the UN M.49 encoding of r, or 0 if this encoding
// is not defined for r.
func (r Region) M49() int {
return int(m49[r])
}
// IsPrivateUse reports whether r has the ISO 3166 User-assigned status. This
// may include private-use tags that are assigned by CLDR and used in this
// implementation. So IsPrivateUse and IsCountry can be simultaneously true.
func (r Region) IsPrivateUse() bool {
return r.typ()&iso3166UserAssigned != 0
}
type Script uint16
// getScriptID returns the script id for string s. It assumes that s
// is of the format [A-Z][a-z]{3}.
func getScriptID(idx tag.Index, s []byte) (Script, error) {
i, err := findIndex(idx, s, "Zzzz")
return Script(i), err
}
// String returns the script code in title case.
// It returns "Zzzz" for an unspecified script.
func (s Script) String() string {
if s == 0 {
return "Zzzz"
}
return script.Elem(int(s))
}
// IsPrivateUse reports whether this script code is reserved for private use.
func (s Script) IsPrivateUse() bool {
return _Qaaa <= s && s <= _Qabx
}
const (
maxAltTaglen = len("en-US-POSIX")
maxLen = maxAltTaglen
)
var (
// grandfatheredMap holds a mapping from legacy and grandfathered tags to
// their base language or index to more elaborate tag.
grandfatheredMap = map[[maxLen]byte]int16{
[maxLen]byte{'a', 'r', 't', '-', 'l', 'o', 'j', 'b', 'a', 'n'}: _jbo, // art-lojban
[maxLen]byte{'i', '-', 'a', 'm', 'i'}: _ami, // i-ami
[maxLen]byte{'i', '-', 'b', 'n', 'n'}: _bnn, // i-bnn
[maxLen]byte{'i', '-', 'h', 'a', 'k'}: _hak, // i-hak
[maxLen]byte{'i', '-', 'k', 'l', 'i', 'n', 'g', 'o', 'n'}: _tlh, // i-klingon
[maxLen]byte{'i', '-', 'l', 'u', 'x'}: _lb, // i-lux
[maxLen]byte{'i', '-', 'n', 'a', 'v', 'a', 'j', 'o'}: _nv, // i-navajo
[maxLen]byte{'i', '-', 'p', 'w', 'n'}: _pwn, // i-pwn
[maxLen]byte{'i', '-', 't', 'a', 'o'}: _tao, // i-tao
[maxLen]byte{'i', '-', 't', 'a', 'y'}: _tay, // i-tay
[maxLen]byte{'i', '-', 't', 's', 'u'}: _tsu, // i-tsu
[maxLen]byte{'n', 'o', '-', 'b', 'o', 'k'}: _nb, // no-bok
[maxLen]byte{'n', 'o', '-', 'n', 'y', 'n'}: _nn, // no-nyn
[maxLen]byte{'s', 'g', 'n', '-', 'b', 'e', '-', 'f', 'r'}: _sfb, // sgn-BE-FR
[maxLen]byte{'s', 'g', 'n', '-', 'b', 'e', '-', 'n', 'l'}: _vgt, // sgn-BE-NL
[maxLen]byte{'s', 'g', 'n', '-', 'c', 'h', '-', 'd', 'e'}: _sgg, // sgn-CH-DE
[maxLen]byte{'z', 'h', '-', 'g', 'u', 'o', 'y', 'u'}: _cmn, // zh-guoyu
[maxLen]byte{'z', 'h', '-', 'h', 'a', 'k', 'k', 'a'}: _hak, // zh-hakka
[maxLen]byte{'z', 'h', '-', 'm', 'i', 'n', '-', 'n', 'a', 'n'}: _nan, // zh-min-nan
[maxLen]byte{'z', 'h', '-', 'x', 'i', 'a', 'n', 'g'}: _hsn, // zh-xiang
// Grandfathered tags with no modern replacement will be converted as
// follows:
[maxLen]byte{'c', 'e', 'l', '-', 'g', 'a', 'u', 'l', 'i', 's', 'h'}: -1, // cel-gaulish
[maxLen]byte{'e', 'n', '-', 'g', 'b', '-', 'o', 'e', 'd'}: -2, // en-GB-oed
[maxLen]byte{'i', '-', 'd', 'e', 'f', 'a', 'u', 'l', 't'}: -3, // i-default
[maxLen]byte{'i', '-', 'e', 'n', 'o', 'c', 'h', 'i', 'a', 'n'}: -4, // i-enochian
[maxLen]byte{'i', '-', 'm', 'i', 'n', 'g', 'o'}: -5, // i-mingo
[maxLen]byte{'z', 'h', '-', 'm', 'i', 'n'}: -6, // zh-min
// CLDR-specific tag.
[maxLen]byte{'r', 'o', 'o', 't'}: 0, // root
[maxLen]byte{'e', 'n', '-', 'u', 's', '-', 'p', 'o', 's', 'i', 'x'}: -7, // en_US_POSIX"
}
altTagIndex = [...]uint8{0, 17, 31, 45, 61, 74, 86, 102}
altTags = "xtg-x-cel-gaulishen-GB-oxendicten-x-i-defaultund-x-i-enochiansee-x-i-mingonan-x-zh-minen-US-u-va-posix"
)
func grandfathered(s [maxAltTaglen]byte) (t Tag, ok bool) {
if v, ok := grandfatheredMap[s]; ok {
if v < 0 {
return Make(altTags[altTagIndex[-v-1]:altTagIndex[-v]]), true
}
t.LangID = Language(v)
return t, true
}
return t, false
}
|
go/src/cmd/vendor/golang.org/x/text/internal/language/lookup.go/0
|
{
"file_path": "go/src/cmd/vendor/golang.org/x/text/internal/language/lookup.go",
"repo_id": "go",
"token_count": 5455
}
| 193 |
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package norm
import "encoding/binary"
// This file contains Form-specific logic and wrappers for data in tables.go.
// Rune info is stored in a separate trie per composing form. A composing form
// and its corresponding decomposing form share the same trie. Each trie maps
// a rune to a uint16. The values take two forms. For v >= 0x8000:
// bits
// 15: 1 (inverse of NFD_QC bit of qcInfo)
// 13..7: qcInfo (see below). isYesD is always true (no decomposition).
// 6..0: ccc (compressed CCC value).
// For v < 0x8000, the respective rune has a decomposition and v is an index
// into a byte array of UTF-8 decomposition sequences and additional info and
// has the form:
// <header> <decomp_byte>* [<tccc> [<lccc>]]
// The header contains the number of bytes in the decomposition (excluding this
// length byte). The two most significant bits of this length byte correspond
// to bit 5 and 4 of qcInfo (see below). The byte sequence itself starts at v+1.
// The byte sequence is followed by a trailing and leading CCC if the values
// for these are not zero. The value of v determines which ccc are appended
// to the sequences. For v < firstCCC, there are none, for v >= firstCCC,
// the sequence is followed by a trailing ccc, and for v >= firstLeadingCC
// there is an additional leading ccc. The value of tccc itself is the
// trailing CCC shifted left 2 bits. The two least-significant bits of tccc
// are the number of trailing non-starters.
const (
qcInfoMask = 0x3F // to clear all but the relevant bits in a qcInfo
headerLenMask = 0x3F // extract the length value from the header byte
headerFlagsMask = 0xC0 // extract the qcInfo bits from the header byte
)
// Properties provides access to normalization properties of a rune.
type Properties struct {
pos uint8 // start position in reorderBuffer; used in composition.go
size uint8 // length of UTF-8 encoding of this rune
ccc uint8 // leading canonical combining class (ccc if not decomposition)
tccc uint8 // trailing canonical combining class (ccc if not decomposition)
nLead uint8 // number of leading non-starters.
flags qcInfo // quick check flags
index uint16
}
// functions dispatchable per form
type lookupFunc func(b input, i int) Properties
// formInfo holds Form-specific functions and tables.
type formInfo struct {
form Form
composing, compatibility bool // form type
info lookupFunc
nextMain iterFunc
}
var formTable = []*formInfo{{
form: NFC,
composing: true,
compatibility: false,
info: lookupInfoNFC,
nextMain: nextComposed,
}, {
form: NFD,
composing: false,
compatibility: false,
info: lookupInfoNFC,
nextMain: nextDecomposed,
}, {
form: NFKC,
composing: true,
compatibility: true,
info: lookupInfoNFKC,
nextMain: nextComposed,
}, {
form: NFKD,
composing: false,
compatibility: true,
info: lookupInfoNFKC,
nextMain: nextDecomposed,
}}
// We do not distinguish between boundaries for NFC, NFD, etc. to avoid
// unexpected behavior for the user. For example, in NFD, there is a boundary
// after 'a'. However, 'a' might combine with modifiers, so from the application's
// perspective it is not a good boundary. We will therefore always use the
// boundaries for the combining variants.
// BoundaryBefore returns true if this rune starts a new segment and
// cannot combine with any rune on the left.
func (p Properties) BoundaryBefore() bool {
if p.ccc == 0 && !p.combinesBackward() {
return true
}
// We assume that the CCC of the first character in a decomposition
// is always non-zero if different from info.ccc and that we can return
// false at this point. This is verified by maketables.
return false
}
// BoundaryAfter returns true if runes cannot combine with or otherwise
// interact with this or previous runes.
func (p Properties) BoundaryAfter() bool {
// TODO: loosen these conditions.
return p.isInert()
}
// We pack quick check data in 4 bits:
//
// 5: Combines forward (0 == false, 1 == true)
// 4..3: NFC_QC Yes(00), No (10), or Maybe (11)
// 2: NFD_QC Yes (0) or No (1). No also means there is a decomposition.
// 1..0: Number of trailing non-starters.
//
// When all 4 bits are zero, the character is inert, meaning it is never
// influenced by normalization.
type qcInfo uint8
func (p Properties) isYesC() bool { return p.flags&0x10 == 0 }
func (p Properties) isYesD() bool { return p.flags&0x4 == 0 }
func (p Properties) combinesForward() bool { return p.flags&0x20 != 0 }
func (p Properties) combinesBackward() bool { return p.flags&0x8 != 0 } // == isMaybe
func (p Properties) hasDecomposition() bool { return p.flags&0x4 != 0 } // == isNoD
func (p Properties) isInert() bool {
return p.flags&qcInfoMask == 0 && p.ccc == 0
}
func (p Properties) multiSegment() bool {
return p.index >= firstMulti && p.index < endMulti
}
func (p Properties) nLeadingNonStarters() uint8 {
return p.nLead
}
func (p Properties) nTrailingNonStarters() uint8 {
return uint8(p.flags & 0x03)
}
// Decomposition returns the decomposition for the underlying rune
// or nil if there is none.
func (p Properties) Decomposition() []byte {
// TODO: create the decomposition for Hangul?
if p.index == 0 {
return nil
}
i := p.index
n := decomps[i] & headerLenMask
i++
return decomps[i : i+uint16(n)]
}
// Size returns the length of UTF-8 encoding of the rune.
func (p Properties) Size() int {
return int(p.size)
}
// CCC returns the canonical combining class of the underlying rune.
func (p Properties) CCC() uint8 {
if p.index >= firstCCCZeroExcept {
return 0
}
return ccc[p.ccc]
}
// LeadCCC returns the CCC of the first rune in the decomposition.
// If there is no decomposition, LeadCCC equals CCC.
func (p Properties) LeadCCC() uint8 {
return ccc[p.ccc]
}
// TrailCCC returns the CCC of the last rune in the decomposition.
// If there is no decomposition, TrailCCC equals CCC.
func (p Properties) TrailCCC() uint8 {
return ccc[p.tccc]
}
func buildRecompMap() {
recompMap = make(map[uint32]rune, len(recompMapPacked)/8)
var buf [8]byte
for i := 0; i < len(recompMapPacked); i += 8 {
copy(buf[:], recompMapPacked[i:i+8])
key := binary.BigEndian.Uint32(buf[:4])
val := binary.BigEndian.Uint32(buf[4:])
recompMap[key] = rune(val)
}
}
// Recomposition
// We use 32-bit keys instead of 64-bit for the two codepoint keys.
// This clips off the bits of three entries, but we know this will not
// result in a collision. In the unlikely event that changes to
// UnicodeData.txt introduce collisions, the compiler will catch it.
// Note that the recomposition map for NFC and NFKC are identical.
// combine returns the combined rune or 0 if it doesn't exist.
//
// The caller is responsible for calling
// recompMapOnce.Do(buildRecompMap) sometime before this is called.
func combine(a, b rune) rune {
key := uint32(uint16(a))<<16 + uint32(uint16(b))
if recompMap == nil {
panic("caller error") // see func comment
}
return recompMap[key]
}
func lookupInfoNFC(b input, i int) Properties {
v, sz := b.charinfoNFC(i)
return compInfo(v, sz)
}
func lookupInfoNFKC(b input, i int) Properties {
v, sz := b.charinfoNFKC(i)
return compInfo(v, sz)
}
// Properties returns properties for the first rune in s.
func (f Form) Properties(s []byte) Properties {
if f == NFC || f == NFD {
return compInfo(nfcData.lookup(s))
}
return compInfo(nfkcData.lookup(s))
}
// PropertiesString returns properties for the first rune in s.
func (f Form) PropertiesString(s string) Properties {
if f == NFC || f == NFD {
return compInfo(nfcData.lookupString(s))
}
return compInfo(nfkcData.lookupString(s))
}
// compInfo converts the information contained in v and sz
// to a Properties. See the comment at the top of the file
// for more information on the format.
func compInfo(v uint16, sz int) Properties {
if v == 0 {
return Properties{size: uint8(sz)}
} else if v >= 0x8000 {
p := Properties{
size: uint8(sz),
ccc: uint8(v),
tccc: uint8(v),
flags: qcInfo(v >> 8),
}
if p.ccc > 0 || p.combinesBackward() {
p.nLead = uint8(p.flags & 0x3)
}
return p
}
// has decomposition
h := decomps[v]
f := (qcInfo(h&headerFlagsMask) >> 2) | 0x4
p := Properties{size: uint8(sz), flags: f, index: v}
if v >= firstCCC {
v += uint16(h&headerLenMask) + 1
c := decomps[v]
p.tccc = c >> 2
p.flags |= qcInfo(c & 0x3)
if v >= firstLeadingCCC {
p.nLead = c & 0x3
if v >= firstStarterWithNLead {
// We were tricked. Remove the decomposition.
p.flags &= 0x03
p.index = 0
return p
}
p.ccc = decomps[v+1]
}
}
return p
}
|
go/src/cmd/vendor/golang.org/x/text/unicode/norm/forminfo.go/0
|
{
"file_path": "go/src/cmd/vendor/golang.org/x/text/unicode/norm/forminfo.go",
"repo_id": "go",
"token_count": 3113
}
| 194 |
// Copyright 2020 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package sigchanyzer defines an Analyzer that detects
// misuse of unbuffered signal as argument to signal.Notify.
package sigchanyzer
import (
"bytes"
_ "embed"
"go/ast"
"go/format"
"go/token"
"go/types"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/passes/inspect"
"golang.org/x/tools/go/analysis/passes/internal/analysisutil"
"golang.org/x/tools/go/ast/inspector"
)
//go:embed doc.go
var doc string
// Analyzer describes sigchanyzer analysis function detector.
var Analyzer = &analysis.Analyzer{
Name: "sigchanyzer",
Doc: analysisutil.MustExtractDoc(doc, "sigchanyzer"),
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/sigchanyzer",
Requires: []*analysis.Analyzer{inspect.Analyzer},
Run: run,
}
func run(pass *analysis.Pass) (interface{}, error) {
if !analysisutil.Imports(pass.Pkg, "os/signal") {
return nil, nil // doesn't directly import signal
}
inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
nodeFilter := []ast.Node{
(*ast.CallExpr)(nil),
}
inspect.Preorder(nodeFilter, func(n ast.Node) {
call := n.(*ast.CallExpr)
if !isSignalNotify(pass.TypesInfo, call) {
return
}
var chanDecl *ast.CallExpr
switch arg := call.Args[0].(type) {
case *ast.Ident:
if decl, ok := findDecl(arg).(*ast.CallExpr); ok {
chanDecl = decl
}
case *ast.CallExpr:
// Only signal.Notify(make(chan os.Signal), os.Interrupt) is safe,
// conservatively treat others as not safe, see golang/go#45043
if isBuiltinMake(pass.TypesInfo, arg) {
return
}
chanDecl = arg
}
if chanDecl == nil || len(chanDecl.Args) != 1 {
return
}
// Make a copy of the channel's declaration to avoid
// mutating the AST. See https://golang.org/issue/46129.
chanDeclCopy := &ast.CallExpr{}
*chanDeclCopy = *chanDecl
chanDeclCopy.Args = append([]ast.Expr(nil), chanDecl.Args...)
chanDeclCopy.Args = append(chanDeclCopy.Args, &ast.BasicLit{
Kind: token.INT,
Value: "1",
})
var buf bytes.Buffer
if err := format.Node(&buf, token.NewFileSet(), chanDeclCopy); err != nil {
return
}
pass.Report(analysis.Diagnostic{
Pos: call.Pos(),
End: call.End(),
Message: "misuse of unbuffered os.Signal channel as argument to signal.Notify",
SuggestedFixes: []analysis.SuggestedFix{{
Message: "Change to buffer channel",
TextEdits: []analysis.TextEdit{{
Pos: chanDecl.Pos(),
End: chanDecl.End(),
NewText: buf.Bytes(),
}},
}},
})
})
return nil, nil
}
func isSignalNotify(info *types.Info, call *ast.CallExpr) bool {
check := func(id *ast.Ident) bool {
obj := info.ObjectOf(id)
return obj.Name() == "Notify" && obj.Pkg().Path() == "os/signal"
}
switch fun := call.Fun.(type) {
case *ast.SelectorExpr:
return check(fun.Sel)
case *ast.Ident:
if fun, ok := findDecl(fun).(*ast.SelectorExpr); ok {
return check(fun.Sel)
}
return false
default:
return false
}
}
func findDecl(arg *ast.Ident) ast.Node {
if arg.Obj == nil {
return nil
}
switch as := arg.Obj.Decl.(type) {
case *ast.AssignStmt:
if len(as.Lhs) != len(as.Rhs) {
return nil
}
for i, lhs := range as.Lhs {
lid, ok := lhs.(*ast.Ident)
if !ok {
continue
}
if lid.Obj == arg.Obj {
return as.Rhs[i]
}
}
case *ast.ValueSpec:
if len(as.Names) != len(as.Values) {
return nil
}
for i, name := range as.Names {
if name.Obj == arg.Obj {
return as.Values[i]
}
}
}
return nil
}
func isBuiltinMake(info *types.Info, call *ast.CallExpr) bool {
typVal := info.Types[call.Fun]
if !typVal.IsBuiltin() {
return false
}
switch fun := call.Fun.(type) {
case *ast.Ident:
return info.ObjectOf(fun).Name() == "make"
default:
return false
}
}
|
go/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/sigchanyzer/sigchanyzer.go/0
|
{
"file_path": "go/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/sigchanyzer/sigchanyzer.go",
"repo_id": "go",
"token_count": 1651
}
| 195 |
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// The unmarshal package defines an Analyzer that checks for passing
// non-pointer or non-interface types to unmarshal and decode functions.
//
// # Analyzer unmarshal
//
// unmarshal: report passing non-pointer or non-interface values to unmarshal
//
// The unmarshal analysis reports calls to functions such as json.Unmarshal
// in which the argument type is not a pointer or an interface.
package unmarshal
|
go/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/unmarshal/doc.go/0
|
{
"file_path": "go/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/unmarshal/doc.go",
"repo_id": "go",
"token_count": 148
}
| 196 |
// Copyright 2024 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Code generated by generate.go. DO NOT EDIT.
package stdlib
var PackageSymbols = map[string][]Symbol{
"archive/tar": {
{"(*Header).FileInfo", Method, 1},
{"(*Reader).Next", Method, 0},
{"(*Reader).Read", Method, 0},
{"(*Writer).AddFS", Method, 22},
{"(*Writer).Close", Method, 0},
{"(*Writer).Flush", Method, 0},
{"(*Writer).Write", Method, 0},
{"(*Writer).WriteHeader", Method, 0},
{"(Format).String", Method, 10},
{"ErrFieldTooLong", Var, 0},
{"ErrHeader", Var, 0},
{"ErrInsecurePath", Var, 20},
{"ErrWriteAfterClose", Var, 0},
{"ErrWriteTooLong", Var, 0},
{"FileInfoHeader", Func, 1},
{"FileInfoNames", Type, 23},
{"Format", Type, 10},
{"FormatGNU", Const, 10},
{"FormatPAX", Const, 10},
{"FormatUSTAR", Const, 10},
{"FormatUnknown", Const, 10},
{"Header", Type, 0},
{"Header.AccessTime", Field, 0},
{"Header.ChangeTime", Field, 0},
{"Header.Devmajor", Field, 0},
{"Header.Devminor", Field, 0},
{"Header.Format", Field, 10},
{"Header.Gid", Field, 0},
{"Header.Gname", Field, 0},
{"Header.Linkname", Field, 0},
{"Header.ModTime", Field, 0},
{"Header.Mode", Field, 0},
{"Header.Name", Field, 0},
{"Header.PAXRecords", Field, 10},
{"Header.Size", Field, 0},
{"Header.Typeflag", Field, 0},
{"Header.Uid", Field, 0},
{"Header.Uname", Field, 0},
{"Header.Xattrs", Field, 3},
{"NewReader", Func, 0},
{"NewWriter", Func, 0},
{"Reader", Type, 0},
{"TypeBlock", Const, 0},
{"TypeChar", Const, 0},
{"TypeCont", Const, 0},
{"TypeDir", Const, 0},
{"TypeFifo", Const, 0},
{"TypeGNULongLink", Const, 1},
{"TypeGNULongName", Const, 1},
{"TypeGNUSparse", Const, 3},
{"TypeLink", Const, 0},
{"TypeReg", Const, 0},
{"TypeRegA", Const, 0},
{"TypeSymlink", Const, 0},
{"TypeXGlobalHeader", Const, 0},
{"TypeXHeader", Const, 0},
{"Writer", Type, 0},
},
"archive/zip": {
{"(*File).DataOffset", Method, 2},
{"(*File).FileInfo", Method, 0},
{"(*File).ModTime", Method, 0},
{"(*File).Mode", Method, 0},
{"(*File).Open", Method, 0},
{"(*File).OpenRaw", Method, 17},
{"(*File).SetModTime", Method, 0},
{"(*File).SetMode", Method, 0},
{"(*FileHeader).FileInfo", Method, 0},
{"(*FileHeader).ModTime", Method, 0},
{"(*FileHeader).Mode", Method, 0},
{"(*FileHeader).SetModTime", Method, 0},
{"(*FileHeader).SetMode", Method, 0},
{"(*ReadCloser).Close", Method, 0},
{"(*ReadCloser).Open", Method, 16},
{"(*ReadCloser).RegisterDecompressor", Method, 6},
{"(*Reader).Open", Method, 16},
{"(*Reader).RegisterDecompressor", Method, 6},
{"(*Writer).AddFS", Method, 22},
{"(*Writer).Close", Method, 0},
{"(*Writer).Copy", Method, 17},
{"(*Writer).Create", Method, 0},
{"(*Writer).CreateHeader", Method, 0},
{"(*Writer).CreateRaw", Method, 17},
{"(*Writer).Flush", Method, 4},
{"(*Writer).RegisterCompressor", Method, 6},
{"(*Writer).SetComment", Method, 10},
{"(*Writer).SetOffset", Method, 5},
{"Compressor", Type, 2},
{"Decompressor", Type, 2},
{"Deflate", Const, 0},
{"ErrAlgorithm", Var, 0},
{"ErrChecksum", Var, 0},
{"ErrFormat", Var, 0},
{"ErrInsecurePath", Var, 20},
{"File", Type, 0},
{"File.FileHeader", Field, 0},
{"FileHeader", Type, 0},
{"FileHeader.CRC32", Field, 0},
{"FileHeader.Comment", Field, 0},
{"FileHeader.CompressedSize", Field, 0},
{"FileHeader.CompressedSize64", Field, 1},
{"FileHeader.CreatorVersion", Field, 0},
{"FileHeader.ExternalAttrs", Field, 0},
{"FileHeader.Extra", Field, 0},
{"FileHeader.Flags", Field, 0},
{"FileHeader.Method", Field, 0},
{"FileHeader.Modified", Field, 10},
{"FileHeader.ModifiedDate", Field, 0},
{"FileHeader.ModifiedTime", Field, 0},
{"FileHeader.Name", Field, 0},
{"FileHeader.NonUTF8", Field, 10},
{"FileHeader.ReaderVersion", Field, 0},
{"FileHeader.UncompressedSize", Field, 0},
{"FileHeader.UncompressedSize64", Field, 1},
{"FileInfoHeader", Func, 0},
{"NewReader", Func, 0},
{"NewWriter", Func, 0},
{"OpenReader", Func, 0},
{"ReadCloser", Type, 0},
{"ReadCloser.Reader", Field, 0},
{"Reader", Type, 0},
{"Reader.Comment", Field, 0},
{"Reader.File", Field, 0},
{"RegisterCompressor", Func, 2},
{"RegisterDecompressor", Func, 2},
{"Store", Const, 0},
{"Writer", Type, 0},
},
"bufio": {
{"(*Reader).Buffered", Method, 0},
{"(*Reader).Discard", Method, 5},
{"(*Reader).Peek", Method, 0},
{"(*Reader).Read", Method, 0},
{"(*Reader).ReadByte", Method, 0},
{"(*Reader).ReadBytes", Method, 0},
{"(*Reader).ReadLine", Method, 0},
{"(*Reader).ReadRune", Method, 0},
{"(*Reader).ReadSlice", Method, 0},
{"(*Reader).ReadString", Method, 0},
{"(*Reader).Reset", Method, 2},
{"(*Reader).Size", Method, 10},
{"(*Reader).UnreadByte", Method, 0},
{"(*Reader).UnreadRune", Method, 0},
{"(*Reader).WriteTo", Method, 1},
{"(*Scanner).Buffer", Method, 6},
{"(*Scanner).Bytes", Method, 1},
{"(*Scanner).Err", Method, 1},
{"(*Scanner).Scan", Method, 1},
{"(*Scanner).Split", Method, 1},
{"(*Scanner).Text", Method, 1},
{"(*Writer).Available", Method, 0},
{"(*Writer).AvailableBuffer", Method, 18},
{"(*Writer).Buffered", Method, 0},
{"(*Writer).Flush", Method, 0},
{"(*Writer).ReadFrom", Method, 1},
{"(*Writer).Reset", Method, 2},
{"(*Writer).Size", Method, 10},
{"(*Writer).Write", Method, 0},
{"(*Writer).WriteByte", Method, 0},
{"(*Writer).WriteRune", Method, 0},
{"(*Writer).WriteString", Method, 0},
{"(ReadWriter).Available", Method, 0},
{"(ReadWriter).AvailableBuffer", Method, 18},
{"(ReadWriter).Discard", Method, 5},
{"(ReadWriter).Flush", Method, 0},
{"(ReadWriter).Peek", Method, 0},
{"(ReadWriter).Read", Method, 0},
{"(ReadWriter).ReadByte", Method, 0},
{"(ReadWriter).ReadBytes", Method, 0},
{"(ReadWriter).ReadFrom", Method, 1},
{"(ReadWriter).ReadLine", Method, 0},
{"(ReadWriter).ReadRune", Method, 0},
{"(ReadWriter).ReadSlice", Method, 0},
{"(ReadWriter).ReadString", Method, 0},
{"(ReadWriter).UnreadByte", Method, 0},
{"(ReadWriter).UnreadRune", Method, 0},
{"(ReadWriter).Write", Method, 0},
{"(ReadWriter).WriteByte", Method, 0},
{"(ReadWriter).WriteRune", Method, 0},
{"(ReadWriter).WriteString", Method, 0},
{"(ReadWriter).WriteTo", Method, 1},
{"ErrAdvanceTooFar", Var, 1},
{"ErrBadReadCount", Var, 15},
{"ErrBufferFull", Var, 0},
{"ErrFinalToken", Var, 6},
{"ErrInvalidUnreadByte", Var, 0},
{"ErrInvalidUnreadRune", Var, 0},
{"ErrNegativeAdvance", Var, 1},
{"ErrNegativeCount", Var, 0},
{"ErrTooLong", Var, 1},
{"MaxScanTokenSize", Const, 1},
{"NewReadWriter", Func, 0},
{"NewReader", Func, 0},
{"NewReaderSize", Func, 0},
{"NewScanner", Func, 1},
{"NewWriter", Func, 0},
{"NewWriterSize", Func, 0},
{"ReadWriter", Type, 0},
{"ReadWriter.Reader", Field, 0},
{"ReadWriter.Writer", Field, 0},
{"Reader", Type, 0},
{"ScanBytes", Func, 1},
{"ScanLines", Func, 1},
{"ScanRunes", Func, 1},
{"ScanWords", Func, 1},
{"Scanner", Type, 1},
{"SplitFunc", Type, 1},
{"Writer", Type, 0},
},
"bytes": {
{"(*Buffer).Available", Method, 21},
{"(*Buffer).AvailableBuffer", Method, 21},
{"(*Buffer).Bytes", Method, 0},
{"(*Buffer).Cap", Method, 5},
{"(*Buffer).Grow", Method, 1},
{"(*Buffer).Len", Method, 0},
{"(*Buffer).Next", Method, 0},
{"(*Buffer).Read", Method, 0},
{"(*Buffer).ReadByte", Method, 0},
{"(*Buffer).ReadBytes", Method, 0},
{"(*Buffer).ReadFrom", Method, 0},
{"(*Buffer).ReadRune", Method, 0},
{"(*Buffer).ReadString", Method, 0},
{"(*Buffer).Reset", Method, 0},
{"(*Buffer).String", Method, 0},
{"(*Buffer).Truncate", Method, 0},
{"(*Buffer).UnreadByte", Method, 0},
{"(*Buffer).UnreadRune", Method, 0},
{"(*Buffer).Write", Method, 0},
{"(*Buffer).WriteByte", Method, 0},
{"(*Buffer).WriteRune", Method, 0},
{"(*Buffer).WriteString", Method, 0},
{"(*Buffer).WriteTo", Method, 0},
{"(*Reader).Len", Method, 0},
{"(*Reader).Read", Method, 0},
{"(*Reader).ReadAt", Method, 0},
{"(*Reader).ReadByte", Method, 0},
{"(*Reader).ReadRune", Method, 0},
{"(*Reader).Reset", Method, 7},
{"(*Reader).Seek", Method, 0},
{"(*Reader).Size", Method, 5},
{"(*Reader).UnreadByte", Method, 0},
{"(*Reader).UnreadRune", Method, 0},
{"(*Reader).WriteTo", Method, 1},
{"Buffer", Type, 0},
{"Clone", Func, 20},
{"Compare", Func, 0},
{"Contains", Func, 0},
{"ContainsAny", Func, 7},
{"ContainsFunc", Func, 21},
{"ContainsRune", Func, 7},
{"Count", Func, 0},
{"Cut", Func, 18},
{"CutPrefix", Func, 20},
{"CutSuffix", Func, 20},
{"Equal", Func, 0},
{"EqualFold", Func, 0},
{"ErrTooLarge", Var, 0},
{"Fields", Func, 0},
{"FieldsFunc", Func, 0},
{"HasPrefix", Func, 0},
{"HasSuffix", Func, 0},
{"Index", Func, 0},
{"IndexAny", Func, 0},
{"IndexByte", Func, 0},
{"IndexFunc", Func, 0},
{"IndexRune", Func, 0},
{"Join", Func, 0},
{"LastIndex", Func, 0},
{"LastIndexAny", Func, 0},
{"LastIndexByte", Func, 5},
{"LastIndexFunc", Func, 0},
{"Map", Func, 0},
{"MinRead", Const, 0},
{"NewBuffer", Func, 0},
{"NewBufferString", Func, 0},
{"NewReader", Func, 0},
{"Reader", Type, 0},
{"Repeat", Func, 0},
{"Replace", Func, 0},
{"ReplaceAll", Func, 12},
{"Runes", Func, 0},
{"Split", Func, 0},
{"SplitAfter", Func, 0},
{"SplitAfterN", Func, 0},
{"SplitN", Func, 0},
{"Title", Func, 0},
{"ToLower", Func, 0},
{"ToLowerSpecial", Func, 0},
{"ToTitle", Func, 0},
{"ToTitleSpecial", Func, 0},
{"ToUpper", Func, 0},
{"ToUpperSpecial", Func, 0},
{"ToValidUTF8", Func, 13},
{"Trim", Func, 0},
{"TrimFunc", Func, 0},
{"TrimLeft", Func, 0},
{"TrimLeftFunc", Func, 0},
{"TrimPrefix", Func, 1},
{"TrimRight", Func, 0},
{"TrimRightFunc", Func, 0},
{"TrimSpace", Func, 0},
{"TrimSuffix", Func, 1},
},
"cmp": {
{"Compare", Func, 21},
{"Less", Func, 21},
{"Or", Func, 22},
{"Ordered", Type, 21},
},
"compress/bzip2": {
{"(StructuralError).Error", Method, 0},
{"NewReader", Func, 0},
{"StructuralError", Type, 0},
},
"compress/flate": {
{"(*ReadError).Error", Method, 0},
{"(*WriteError).Error", Method, 0},
{"(*Writer).Close", Method, 0},
{"(*Writer).Flush", Method, 0},
{"(*Writer).Reset", Method, 2},
{"(*Writer).Write", Method, 0},
{"(CorruptInputError).Error", Method, 0},
{"(InternalError).Error", Method, 0},
{"BestCompression", Const, 0},
{"BestSpeed", Const, 0},
{"CorruptInputError", Type, 0},
{"DefaultCompression", Const, 0},
{"HuffmanOnly", Const, 7},
{"InternalError", Type, 0},
{"NewReader", Func, 0},
{"NewReaderDict", Func, 0},
{"NewWriter", Func, 0},
{"NewWriterDict", Func, 0},
{"NoCompression", Const, 0},
{"ReadError", Type, 0},
{"ReadError.Err", Field, 0},
{"ReadError.Offset", Field, 0},
{"Reader", Type, 0},
{"Resetter", Type, 4},
{"WriteError", Type, 0},
{"WriteError.Err", Field, 0},
{"WriteError.Offset", Field, 0},
{"Writer", Type, 0},
},
"compress/gzip": {
{"(*Reader).Close", Method, 0},
{"(*Reader).Multistream", Method, 4},
{"(*Reader).Read", Method, 0},
{"(*Reader).Reset", Method, 3},
{"(*Writer).Close", Method, 0},
{"(*Writer).Flush", Method, 1},
{"(*Writer).Reset", Method, 2},
{"(*Writer).Write", Method, 0},
{"BestCompression", Const, 0},
{"BestSpeed", Const, 0},
{"DefaultCompression", Const, 0},
{"ErrChecksum", Var, 0},
{"ErrHeader", Var, 0},
{"Header", Type, 0},
{"Header.Comment", Field, 0},
{"Header.Extra", Field, 0},
{"Header.ModTime", Field, 0},
{"Header.Name", Field, 0},
{"Header.OS", Field, 0},
{"HuffmanOnly", Const, 8},
{"NewReader", Func, 0},
{"NewWriter", Func, 0},
{"NewWriterLevel", Func, 0},
{"NoCompression", Const, 0},
{"Reader", Type, 0},
{"Reader.Header", Field, 0},
{"Writer", Type, 0},
{"Writer.Header", Field, 0},
},
"compress/lzw": {
{"(*Reader).Close", Method, 17},
{"(*Reader).Read", Method, 17},
{"(*Reader).Reset", Method, 17},
{"(*Writer).Close", Method, 17},
{"(*Writer).Reset", Method, 17},
{"(*Writer).Write", Method, 17},
{"LSB", Const, 0},
{"MSB", Const, 0},
{"NewReader", Func, 0},
{"NewWriter", Func, 0},
{"Order", Type, 0},
{"Reader", Type, 17},
{"Writer", Type, 17},
},
"compress/zlib": {
{"(*Writer).Close", Method, 0},
{"(*Writer).Flush", Method, 0},
{"(*Writer).Reset", Method, 2},
{"(*Writer).Write", Method, 0},
{"BestCompression", Const, 0},
{"BestSpeed", Const, 0},
{"DefaultCompression", Const, 0},
{"ErrChecksum", Var, 0},
{"ErrDictionary", Var, 0},
{"ErrHeader", Var, 0},
{"HuffmanOnly", Const, 8},
{"NewReader", Func, 0},
{"NewReaderDict", Func, 0},
{"NewWriter", Func, 0},
{"NewWriterLevel", Func, 0},
{"NewWriterLevelDict", Func, 0},
{"NoCompression", Const, 0},
{"Resetter", Type, 4},
{"Writer", Type, 0},
},
"container/heap": {
{"Fix", Func, 2},
{"Init", Func, 0},
{"Interface", Type, 0},
{"Pop", Func, 0},
{"Push", Func, 0},
{"Remove", Func, 0},
},
"container/list": {
{"(*Element).Next", Method, 0},
{"(*Element).Prev", Method, 0},
{"(*List).Back", Method, 0},
{"(*List).Front", Method, 0},
{"(*List).Init", Method, 0},
{"(*List).InsertAfter", Method, 0},
{"(*List).InsertBefore", Method, 0},
{"(*List).Len", Method, 0},
{"(*List).MoveAfter", Method, 2},
{"(*List).MoveBefore", Method, 2},
{"(*List).MoveToBack", Method, 0},
{"(*List).MoveToFront", Method, 0},
{"(*List).PushBack", Method, 0},
{"(*List).PushBackList", Method, 0},
{"(*List).PushFront", Method, 0},
{"(*List).PushFrontList", Method, 0},
{"(*List).Remove", Method, 0},
{"Element", Type, 0},
{"Element.Value", Field, 0},
{"List", Type, 0},
{"New", Func, 0},
},
"container/ring": {
{"(*Ring).Do", Method, 0},
{"(*Ring).Len", Method, 0},
{"(*Ring).Link", Method, 0},
{"(*Ring).Move", Method, 0},
{"(*Ring).Next", Method, 0},
{"(*Ring).Prev", Method, 0},
{"(*Ring).Unlink", Method, 0},
{"New", Func, 0},
{"Ring", Type, 0},
{"Ring.Value", Field, 0},
},
"context": {
{"AfterFunc", Func, 21},
{"Background", Func, 7},
{"CancelCauseFunc", Type, 20},
{"CancelFunc", Type, 7},
{"Canceled", Var, 7},
{"Cause", Func, 20},
{"Context", Type, 7},
{"DeadlineExceeded", Var, 7},
{"TODO", Func, 7},
{"WithCancel", Func, 7},
{"WithCancelCause", Func, 20},
{"WithDeadline", Func, 7},
{"WithDeadlineCause", Func, 21},
{"WithTimeout", Func, 7},
{"WithTimeoutCause", Func, 21},
{"WithValue", Func, 7},
{"WithoutCancel", Func, 21},
},
"crypto": {
{"(Hash).Available", Method, 0},
{"(Hash).HashFunc", Method, 4},
{"(Hash).New", Method, 0},
{"(Hash).Size", Method, 0},
{"(Hash).String", Method, 15},
{"BLAKE2b_256", Const, 9},
{"BLAKE2b_384", Const, 9},
{"BLAKE2b_512", Const, 9},
{"BLAKE2s_256", Const, 9},
{"Decrypter", Type, 5},
{"DecrypterOpts", Type, 5},
{"Hash", Type, 0},
{"MD4", Const, 0},
{"MD5", Const, 0},
{"MD5SHA1", Const, 0},
{"PrivateKey", Type, 0},
{"PublicKey", Type, 2},
{"RIPEMD160", Const, 0},
{"RegisterHash", Func, 0},
{"SHA1", Const, 0},
{"SHA224", Const, 0},
{"SHA256", Const, 0},
{"SHA384", Const, 0},
{"SHA3_224", Const, 4},
{"SHA3_256", Const, 4},
{"SHA3_384", Const, 4},
{"SHA3_512", Const, 4},
{"SHA512", Const, 0},
{"SHA512_224", Const, 5},
{"SHA512_256", Const, 5},
{"Signer", Type, 4},
{"SignerOpts", Type, 4},
},
"crypto/aes": {
{"(KeySizeError).Error", Method, 0},
{"BlockSize", Const, 0},
{"KeySizeError", Type, 0},
{"NewCipher", Func, 0},
},
"crypto/cipher": {
{"(StreamReader).Read", Method, 0},
{"(StreamWriter).Close", Method, 0},
{"(StreamWriter).Write", Method, 0},
{"AEAD", Type, 2},
{"Block", Type, 0},
{"BlockMode", Type, 0},
{"NewCBCDecrypter", Func, 0},
{"NewCBCEncrypter", Func, 0},
{"NewCFBDecrypter", Func, 0},
{"NewCFBEncrypter", Func, 0},
{"NewCTR", Func, 0},
{"NewGCM", Func, 2},
{"NewGCMWithNonceSize", Func, 5},
{"NewGCMWithTagSize", Func, 11},
{"NewOFB", Func, 0},
{"Stream", Type, 0},
{"StreamReader", Type, 0},
{"StreamReader.R", Field, 0},
{"StreamReader.S", Field, 0},
{"StreamWriter", Type, 0},
{"StreamWriter.Err", Field, 0},
{"StreamWriter.S", Field, 0},
{"StreamWriter.W", Field, 0},
},
"crypto/des": {
{"(KeySizeError).Error", Method, 0},
{"BlockSize", Const, 0},
{"KeySizeError", Type, 0},
{"NewCipher", Func, 0},
{"NewTripleDESCipher", Func, 0},
},
"crypto/dsa": {
{"ErrInvalidPublicKey", Var, 0},
{"GenerateKey", Func, 0},
{"GenerateParameters", Func, 0},
{"L1024N160", Const, 0},
{"L2048N224", Const, 0},
{"L2048N256", Const, 0},
{"L3072N256", Const, 0},
{"ParameterSizes", Type, 0},
{"Parameters", Type, 0},
{"Parameters.G", Field, 0},
{"Parameters.P", Field, 0},
{"Parameters.Q", Field, 0},
{"PrivateKey", Type, 0},
{"PrivateKey.PublicKey", Field, 0},
{"PrivateKey.X", Field, 0},
{"PublicKey", Type, 0},
{"PublicKey.Parameters", Field, 0},
{"PublicKey.Y", Field, 0},
{"Sign", Func, 0},
{"Verify", Func, 0},
},
"crypto/ecdh": {
{"(*PrivateKey).Bytes", Method, 20},
{"(*PrivateKey).Curve", Method, 20},
{"(*PrivateKey).ECDH", Method, 20},
{"(*PrivateKey).Equal", Method, 20},
{"(*PrivateKey).Public", Method, 20},
{"(*PrivateKey).PublicKey", Method, 20},
{"(*PublicKey).Bytes", Method, 20},
{"(*PublicKey).Curve", Method, 20},
{"(*PublicKey).Equal", Method, 20},
{"Curve", Type, 20},
{"P256", Func, 20},
{"P384", Func, 20},
{"P521", Func, 20},
{"PrivateKey", Type, 20},
{"PublicKey", Type, 20},
{"X25519", Func, 20},
},
"crypto/ecdsa": {
{"(*PrivateKey).ECDH", Method, 20},
{"(*PrivateKey).Equal", Method, 15},
{"(*PrivateKey).Public", Method, 4},
{"(*PrivateKey).Sign", Method, 4},
{"(*PublicKey).ECDH", Method, 20},
{"(*PublicKey).Equal", Method, 15},
{"(PrivateKey).Add", Method, 0},
{"(PrivateKey).Double", Method, 0},
{"(PrivateKey).IsOnCurve", Method, 0},
{"(PrivateKey).Params", Method, 0},
{"(PrivateKey).ScalarBaseMult", Method, 0},
{"(PrivateKey).ScalarMult", Method, 0},
{"(PublicKey).Add", Method, 0},
{"(PublicKey).Double", Method, 0},
{"(PublicKey).IsOnCurve", Method, 0},
{"(PublicKey).Params", Method, 0},
{"(PublicKey).ScalarBaseMult", Method, 0},
{"(PublicKey).ScalarMult", Method, 0},
{"GenerateKey", Func, 0},
{"PrivateKey", Type, 0},
{"PrivateKey.D", Field, 0},
{"PrivateKey.PublicKey", Field, 0},
{"PublicKey", Type, 0},
{"PublicKey.Curve", Field, 0},
{"PublicKey.X", Field, 0},
{"PublicKey.Y", Field, 0},
{"Sign", Func, 0},
{"SignASN1", Func, 15},
{"Verify", Func, 0},
{"VerifyASN1", Func, 15},
},
"crypto/ed25519": {
{"(*Options).HashFunc", Method, 20},
{"(PrivateKey).Equal", Method, 15},
{"(PrivateKey).Public", Method, 13},
{"(PrivateKey).Seed", Method, 13},
{"(PrivateKey).Sign", Method, 13},
{"(PublicKey).Equal", Method, 15},
{"GenerateKey", Func, 13},
{"NewKeyFromSeed", Func, 13},
{"Options", Type, 20},
{"Options.Context", Field, 20},
{"Options.Hash", Field, 20},
{"PrivateKey", Type, 13},
{"PrivateKeySize", Const, 13},
{"PublicKey", Type, 13},
{"PublicKeySize", Const, 13},
{"SeedSize", Const, 13},
{"Sign", Func, 13},
{"SignatureSize", Const, 13},
{"Verify", Func, 13},
{"VerifyWithOptions", Func, 20},
},
"crypto/elliptic": {
{"(*CurveParams).Add", Method, 0},
{"(*CurveParams).Double", Method, 0},
{"(*CurveParams).IsOnCurve", Method, 0},
{"(*CurveParams).Params", Method, 0},
{"(*CurveParams).ScalarBaseMult", Method, 0},
{"(*CurveParams).ScalarMult", Method, 0},
{"Curve", Type, 0},
{"CurveParams", Type, 0},
{"CurveParams.B", Field, 0},
{"CurveParams.BitSize", Field, 0},
{"CurveParams.Gx", Field, 0},
{"CurveParams.Gy", Field, 0},
{"CurveParams.N", Field, 0},
{"CurveParams.Name", Field, 5},
{"CurveParams.P", Field, 0},
{"GenerateKey", Func, 0},
{"Marshal", Func, 0},
{"MarshalCompressed", Func, 15},
{"P224", Func, 0},
{"P256", Func, 0},
{"P384", Func, 0},
{"P521", Func, 0},
{"Unmarshal", Func, 0},
{"UnmarshalCompressed", Func, 15},
},
"crypto/hmac": {
{"Equal", Func, 1},
{"New", Func, 0},
},
"crypto/md5": {
{"BlockSize", Const, 0},
{"New", Func, 0},
{"Size", Const, 0},
{"Sum", Func, 2},
},
"crypto/rand": {
{"Int", Func, 0},
{"Prime", Func, 0},
{"Read", Func, 0},
{"Reader", Var, 0},
},
"crypto/rc4": {
{"(*Cipher).Reset", Method, 0},
{"(*Cipher).XORKeyStream", Method, 0},
{"(KeySizeError).Error", Method, 0},
{"Cipher", Type, 0},
{"KeySizeError", Type, 0},
{"NewCipher", Func, 0},
},
"crypto/rsa": {
{"(*PSSOptions).HashFunc", Method, 4},
{"(*PrivateKey).Decrypt", Method, 5},
{"(*PrivateKey).Equal", Method, 15},
{"(*PrivateKey).Precompute", Method, 0},
{"(*PrivateKey).Public", Method, 4},
{"(*PrivateKey).Sign", Method, 4},
{"(*PrivateKey).Size", Method, 11},
{"(*PrivateKey).Validate", Method, 0},
{"(*PublicKey).Equal", Method, 15},
{"(*PublicKey).Size", Method, 11},
{"CRTValue", Type, 0},
{"CRTValue.Coeff", Field, 0},
{"CRTValue.Exp", Field, 0},
{"CRTValue.R", Field, 0},
{"DecryptOAEP", Func, 0},
{"DecryptPKCS1v15", Func, 0},
{"DecryptPKCS1v15SessionKey", Func, 0},
{"EncryptOAEP", Func, 0},
{"EncryptPKCS1v15", Func, 0},
{"ErrDecryption", Var, 0},
{"ErrMessageTooLong", Var, 0},
{"ErrVerification", Var, 0},
{"GenerateKey", Func, 0},
{"GenerateMultiPrimeKey", Func, 0},
{"OAEPOptions", Type, 5},
{"OAEPOptions.Hash", Field, 5},
{"OAEPOptions.Label", Field, 5},
{"OAEPOptions.MGFHash", Field, 20},
{"PKCS1v15DecryptOptions", Type, 5},
{"PKCS1v15DecryptOptions.SessionKeyLen", Field, 5},
{"PSSOptions", Type, 2},
{"PSSOptions.Hash", Field, 4},
{"PSSOptions.SaltLength", Field, 2},
{"PSSSaltLengthAuto", Const, 2},
{"PSSSaltLengthEqualsHash", Const, 2},
{"PrecomputedValues", Type, 0},
{"PrecomputedValues.CRTValues", Field, 0},
{"PrecomputedValues.Dp", Field, 0},
{"PrecomputedValues.Dq", Field, 0},
{"PrecomputedValues.Qinv", Field, 0},
{"PrivateKey", Type, 0},
{"PrivateKey.D", Field, 0},
{"PrivateKey.Precomputed", Field, 0},
{"PrivateKey.Primes", Field, 0},
{"PrivateKey.PublicKey", Field, 0},
{"PublicKey", Type, 0},
{"PublicKey.E", Field, 0},
{"PublicKey.N", Field, 0},
{"SignPKCS1v15", Func, 0},
{"SignPSS", Func, 2},
{"VerifyPKCS1v15", Func, 0},
{"VerifyPSS", Func, 2},
},
"crypto/sha1": {
{"BlockSize", Const, 0},
{"New", Func, 0},
{"Size", Const, 0},
{"Sum", Func, 2},
},
"crypto/sha256": {
{"BlockSize", Const, 0},
{"New", Func, 0},
{"New224", Func, 0},
{"Size", Const, 0},
{"Size224", Const, 0},
{"Sum224", Func, 2},
{"Sum256", Func, 2},
},
"crypto/sha512": {
{"BlockSize", Const, 0},
{"New", Func, 0},
{"New384", Func, 0},
{"New512_224", Func, 5},
{"New512_256", Func, 5},
{"Size", Const, 0},
{"Size224", Const, 5},
{"Size256", Const, 5},
{"Size384", Const, 0},
{"Sum384", Func, 2},
{"Sum512", Func, 2},
{"Sum512_224", Func, 5},
{"Sum512_256", Func, 5},
},
"crypto/subtle": {
{"ConstantTimeByteEq", Func, 0},
{"ConstantTimeCompare", Func, 0},
{"ConstantTimeCopy", Func, 0},
{"ConstantTimeEq", Func, 0},
{"ConstantTimeLessOrEq", Func, 2},
{"ConstantTimeSelect", Func, 0},
{"XORBytes", Func, 20},
},
"crypto/tls": {
{"(*CertificateRequestInfo).Context", Method, 17},
{"(*CertificateRequestInfo).SupportsCertificate", Method, 14},
{"(*CertificateVerificationError).Error", Method, 20},
{"(*CertificateVerificationError).Unwrap", Method, 20},
{"(*ClientHelloInfo).Context", Method, 17},
{"(*ClientHelloInfo).SupportsCertificate", Method, 14},
{"(*ClientSessionState).ResumptionState", Method, 21},
{"(*Config).BuildNameToCertificate", Method, 0},
{"(*Config).Clone", Method, 8},
{"(*Config).DecryptTicket", Method, 21},
{"(*Config).EncryptTicket", Method, 21},
{"(*Config).SetSessionTicketKeys", Method, 5},
{"(*Conn).Close", Method, 0},
{"(*Conn).CloseWrite", Method, 8},
{"(*Conn).ConnectionState", Method, 0},
{"(*Conn).Handshake", Method, 0},
{"(*Conn).HandshakeContext", Method, 17},
{"(*Conn).LocalAddr", Method, 0},
{"(*Conn).NetConn", Method, 18},
{"(*Conn).OCSPResponse", Method, 0},
{"(*Conn).Read", Method, 0},
{"(*Conn).RemoteAddr", Method, 0},
{"(*Conn).SetDeadline", Method, 0},
{"(*Conn).SetReadDeadline", Method, 0},
{"(*Conn).SetWriteDeadline", Method, 0},
{"(*Conn).VerifyHostname", Method, 0},
{"(*Conn).Write", Method, 0},
{"(*ConnectionState).ExportKeyingMaterial", Method, 11},
{"(*Dialer).Dial", Method, 15},
{"(*Dialer).DialContext", Method, 15},
{"(*ECHRejectionError).Error", Method, 23},
{"(*QUICConn).Close", Method, 21},
{"(*QUICConn).ConnectionState", Method, 21},
{"(*QUICConn).HandleData", Method, 21},
{"(*QUICConn).NextEvent", Method, 21},
{"(*QUICConn).SendSessionTicket", Method, 21},
{"(*QUICConn).SetTransportParameters", Method, 21},
{"(*QUICConn).Start", Method, 21},
{"(*QUICConn).StoreSession", Method, 23},
{"(*SessionState).Bytes", Method, 21},
{"(AlertError).Error", Method, 21},
{"(ClientAuthType).String", Method, 15},
{"(CurveID).String", Method, 15},
{"(QUICEncryptionLevel).String", Method, 21},
{"(RecordHeaderError).Error", Method, 6},
{"(SignatureScheme).String", Method, 15},
{"AlertError", Type, 21},
{"Certificate", Type, 0},
{"Certificate.Certificate", Field, 0},
{"Certificate.Leaf", Field, 0},
{"Certificate.OCSPStaple", Field, 0},
{"Certificate.PrivateKey", Field, 0},
{"Certificate.SignedCertificateTimestamps", Field, 5},
{"Certificate.SupportedSignatureAlgorithms", Field, 14},
{"CertificateRequestInfo", Type, 8},
{"CertificateRequestInfo.AcceptableCAs", Field, 8},
{"CertificateRequestInfo.SignatureSchemes", Field, 8},
{"CertificateRequestInfo.Version", Field, 14},
{"CertificateVerificationError", Type, 20},
{"CertificateVerificationError.Err", Field, 20},
{"CertificateVerificationError.UnverifiedCertificates", Field, 20},
{"CipherSuite", Type, 14},
{"CipherSuite.ID", Field, 14},
{"CipherSuite.Insecure", Field, 14},
{"CipherSuite.Name", Field, 14},
{"CipherSuite.SupportedVersions", Field, 14},
{"CipherSuiteName", Func, 14},
{"CipherSuites", Func, 14},
{"Client", Func, 0},
{"ClientAuthType", Type, 0},
{"ClientHelloInfo", Type, 4},
{"ClientHelloInfo.CipherSuites", Field, 4},
{"ClientHelloInfo.Conn", Field, 8},
{"ClientHelloInfo.ServerName", Field, 4},
{"ClientHelloInfo.SignatureSchemes", Field, 8},
{"ClientHelloInfo.SupportedCurves", Field, 4},
{"ClientHelloInfo.SupportedPoints", Field, 4},
{"ClientHelloInfo.SupportedProtos", Field, 8},
{"ClientHelloInfo.SupportedVersions", Field, 8},
{"ClientSessionCache", Type, 3},
{"ClientSessionState", Type, 3},
{"Config", Type, 0},
{"Config.Certificates", Field, 0},
{"Config.CipherSuites", Field, 0},
{"Config.ClientAuth", Field, 0},
{"Config.ClientCAs", Field, 0},
{"Config.ClientSessionCache", Field, 3},
{"Config.CurvePreferences", Field, 3},
{"Config.DynamicRecordSizingDisabled", Field, 7},
{"Config.EncryptedClientHelloConfigList", Field, 23},
{"Config.EncryptedClientHelloRejectionVerify", Field, 23},
{"Config.GetCertificate", Field, 4},
{"Config.GetClientCertificate", Field, 8},
{"Config.GetConfigForClient", Field, 8},
{"Config.InsecureSkipVerify", Field, 0},
{"Config.KeyLogWriter", Field, 8},
{"Config.MaxVersion", Field, 2},
{"Config.MinVersion", Field, 2},
{"Config.NameToCertificate", Field, 0},
{"Config.NextProtos", Field, 0},
{"Config.PreferServerCipherSuites", Field, 1},
{"Config.Rand", Field, 0},
{"Config.Renegotiation", Field, 7},
{"Config.RootCAs", Field, 0},
{"Config.ServerName", Field, 0},
{"Config.SessionTicketKey", Field, 1},
{"Config.SessionTicketsDisabled", Field, 1},
{"Config.Time", Field, 0},
{"Config.UnwrapSession", Field, 21},
{"Config.VerifyConnection", Field, 15},
{"Config.VerifyPeerCertificate", Field, 8},
{"Config.WrapSession", Field, 21},
{"Conn", Type, 0},
{"ConnectionState", Type, 0},
{"ConnectionState.CipherSuite", Field, 0},
{"ConnectionState.DidResume", Field, 1},
{"ConnectionState.ECHAccepted", Field, 23},
{"ConnectionState.HandshakeComplete", Field, 0},
{"ConnectionState.NegotiatedProtocol", Field, 0},
{"ConnectionState.NegotiatedProtocolIsMutual", Field, 0},
{"ConnectionState.OCSPResponse", Field, 5},
{"ConnectionState.PeerCertificates", Field, 0},
{"ConnectionState.ServerName", Field, 0},
{"ConnectionState.SignedCertificateTimestamps", Field, 5},
{"ConnectionState.TLSUnique", Field, 4},
{"ConnectionState.VerifiedChains", Field, 0},
{"ConnectionState.Version", Field, 3},
{"CurveID", Type, 3},
{"CurveP256", Const, 3},
{"CurveP384", Const, 3},
{"CurveP521", Const, 3},
{"Dial", Func, 0},
{"DialWithDialer", Func, 3},
{"Dialer", Type, 15},
{"Dialer.Config", Field, 15},
{"Dialer.NetDialer", Field, 15},
{"ECDSAWithP256AndSHA256", Const, 8},
{"ECDSAWithP384AndSHA384", Const, 8},
{"ECDSAWithP521AndSHA512", Const, 8},
{"ECDSAWithSHA1", Const, 10},
{"ECHRejectionError", Type, 23},
{"ECHRejectionError.RetryConfigList", Field, 23},
{"Ed25519", Const, 13},
{"InsecureCipherSuites", Func, 14},
{"Listen", Func, 0},
{"LoadX509KeyPair", Func, 0},
{"NewLRUClientSessionCache", Func, 3},
{"NewListener", Func, 0},
{"NewResumptionState", Func, 21},
{"NoClientCert", Const, 0},
{"PKCS1WithSHA1", Const, 8},
{"PKCS1WithSHA256", Const, 8},
{"PKCS1WithSHA384", Const, 8},
{"PKCS1WithSHA512", Const, 8},
{"PSSWithSHA256", Const, 8},
{"PSSWithSHA384", Const, 8},
{"PSSWithSHA512", Const, 8},
{"ParseSessionState", Func, 21},
{"QUICClient", Func, 21},
{"QUICConfig", Type, 21},
{"QUICConfig.EnableStoreSessionEvent", Field, 23},
{"QUICConfig.TLSConfig", Field, 21},
{"QUICConn", Type, 21},
{"QUICEncryptionLevel", Type, 21},
{"QUICEncryptionLevelApplication", Const, 21},
{"QUICEncryptionLevelEarly", Const, 21},
{"QUICEncryptionLevelHandshake", Const, 21},
{"QUICEncryptionLevelInitial", Const, 21},
{"QUICEvent", Type, 21},
{"QUICEvent.Data", Field, 21},
{"QUICEvent.Kind", Field, 21},
{"QUICEvent.Level", Field, 21},
{"QUICEvent.SessionState", Field, 23},
{"QUICEvent.Suite", Field, 21},
{"QUICEventKind", Type, 21},
{"QUICHandshakeDone", Const, 21},
{"QUICNoEvent", Const, 21},
{"QUICRejectedEarlyData", Const, 21},
{"QUICResumeSession", Const, 23},
{"QUICServer", Func, 21},
{"QUICSessionTicketOptions", Type, 21},
{"QUICSessionTicketOptions.EarlyData", Field, 21},
{"QUICSessionTicketOptions.Extra", Field, 23},
{"QUICSetReadSecret", Const, 21},
{"QUICSetWriteSecret", Const, 21},
{"QUICStoreSession", Const, 23},
{"QUICTransportParameters", Const, 21},
{"QUICTransportParametersRequired", Const, 21},
{"QUICWriteData", Const, 21},
{"RecordHeaderError", Type, 6},
{"RecordHeaderError.Conn", Field, 12},
{"RecordHeaderError.Msg", Field, 6},
{"RecordHeaderError.RecordHeader", Field, 6},
{"RenegotiateFreelyAsClient", Const, 7},
{"RenegotiateNever", Const, 7},
{"RenegotiateOnceAsClient", Const, 7},
{"RenegotiationSupport", Type, 7},
{"RequestClientCert", Const, 0},
{"RequireAndVerifyClientCert", Const, 0},
{"RequireAnyClientCert", Const, 0},
{"Server", Func, 0},
{"SessionState", Type, 21},
{"SessionState.EarlyData", Field, 21},
{"SessionState.Extra", Field, 21},
{"SignatureScheme", Type, 8},
{"TLS_AES_128_GCM_SHA256", Const, 12},
{"TLS_AES_256_GCM_SHA384", Const, 12},
{"TLS_CHACHA20_POLY1305_SHA256", Const, 12},
{"TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA", Const, 2},
{"TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256", Const, 8},
{"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", Const, 2},
{"TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA", Const, 2},
{"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", Const, 5},
{"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305", Const, 8},
{"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", Const, 14},
{"TLS_ECDHE_ECDSA_WITH_RC4_128_SHA", Const, 2},
{"TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA", Const, 0},
{"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", Const, 0},
{"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", Const, 8},
{"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", Const, 2},
{"TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", Const, 1},
{"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", Const, 5},
{"TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305", Const, 8},
{"TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256", Const, 14},
{"TLS_ECDHE_RSA_WITH_RC4_128_SHA", Const, 0},
{"TLS_FALLBACK_SCSV", Const, 4},
{"TLS_RSA_WITH_3DES_EDE_CBC_SHA", Const, 0},
{"TLS_RSA_WITH_AES_128_CBC_SHA", Const, 0},
{"TLS_RSA_WITH_AES_128_CBC_SHA256", Const, 8},
{"TLS_RSA_WITH_AES_128_GCM_SHA256", Const, 6},
{"TLS_RSA_WITH_AES_256_CBC_SHA", Const, 1},
{"TLS_RSA_WITH_AES_256_GCM_SHA384", Const, 6},
{"TLS_RSA_WITH_RC4_128_SHA", Const, 0},
{"VerifyClientCertIfGiven", Const, 0},
{"VersionName", Func, 21},
{"VersionSSL30", Const, 2},
{"VersionTLS10", Const, 2},
{"VersionTLS11", Const, 2},
{"VersionTLS12", Const, 2},
{"VersionTLS13", Const, 12},
{"X25519", Const, 8},
{"X509KeyPair", Func, 0},
},
"crypto/x509": {
{"(*CertPool).AddCert", Method, 0},
{"(*CertPool).AddCertWithConstraint", Method, 22},
{"(*CertPool).AppendCertsFromPEM", Method, 0},
{"(*CertPool).Clone", Method, 19},
{"(*CertPool).Equal", Method, 19},
{"(*CertPool).Subjects", Method, 0},
{"(*Certificate).CheckCRLSignature", Method, 0},
{"(*Certificate).CheckSignature", Method, 0},
{"(*Certificate).CheckSignatureFrom", Method, 0},
{"(*Certificate).CreateCRL", Method, 0},
{"(*Certificate).Equal", Method, 0},
{"(*Certificate).Verify", Method, 0},
{"(*Certificate).VerifyHostname", Method, 0},
{"(*CertificateRequest).CheckSignature", Method, 5},
{"(*OID).UnmarshalBinary", Method, 23},
{"(*OID).UnmarshalText", Method, 23},
{"(*RevocationList).CheckSignatureFrom", Method, 19},
{"(CertificateInvalidError).Error", Method, 0},
{"(ConstraintViolationError).Error", Method, 0},
{"(HostnameError).Error", Method, 0},
{"(InsecureAlgorithmError).Error", Method, 6},
{"(OID).Equal", Method, 22},
{"(OID).EqualASN1OID", Method, 22},
{"(OID).MarshalBinary", Method, 23},
{"(OID).MarshalText", Method, 23},
{"(OID).String", Method, 22},
{"(PublicKeyAlgorithm).String", Method, 10},
{"(SignatureAlgorithm).String", Method, 6},
{"(SystemRootsError).Error", Method, 1},
{"(SystemRootsError).Unwrap", Method, 16},
{"(UnhandledCriticalExtension).Error", Method, 0},
{"(UnknownAuthorityError).Error", Method, 0},
{"CANotAuthorizedForExtKeyUsage", Const, 10},
{"CANotAuthorizedForThisName", Const, 0},
{"CertPool", Type, 0},
{"Certificate", Type, 0},
{"Certificate.AuthorityKeyId", Field, 0},
{"Certificate.BasicConstraintsValid", Field, 0},
{"Certificate.CRLDistributionPoints", Field, 2},
{"Certificate.DNSNames", Field, 0},
{"Certificate.EmailAddresses", Field, 0},
{"Certificate.ExcludedDNSDomains", Field, 9},
{"Certificate.ExcludedEmailAddresses", Field, 10},
{"Certificate.ExcludedIPRanges", Field, 10},
{"Certificate.ExcludedURIDomains", Field, 10},
{"Certificate.ExtKeyUsage", Field, 0},
{"Certificate.Extensions", Field, 2},
{"Certificate.ExtraExtensions", Field, 2},
{"Certificate.IPAddresses", Field, 1},
{"Certificate.IsCA", Field, 0},
{"Certificate.Issuer", Field, 0},
{"Certificate.IssuingCertificateURL", Field, 2},
{"Certificate.KeyUsage", Field, 0},
{"Certificate.MaxPathLen", Field, 0},
{"Certificate.MaxPathLenZero", Field, 4},
{"Certificate.NotAfter", Field, 0},
{"Certificate.NotBefore", Field, 0},
{"Certificate.OCSPServer", Field, 2},
{"Certificate.PermittedDNSDomains", Field, 0},
{"Certificate.PermittedDNSDomainsCritical", Field, 0},
{"Certificate.PermittedEmailAddresses", Field, 10},
{"Certificate.PermittedIPRanges", Field, 10},
{"Certificate.PermittedURIDomains", Field, 10},
{"Certificate.Policies", Field, 22},
{"Certificate.PolicyIdentifiers", Field, 0},
{"Certificate.PublicKey", Field, 0},
{"Certificate.PublicKeyAlgorithm", Field, 0},
{"Certificate.Raw", Field, 0},
{"Certificate.RawIssuer", Field, 0},
{"Certificate.RawSubject", Field, 0},
{"Certificate.RawSubjectPublicKeyInfo", Field, 0},
{"Certificate.RawTBSCertificate", Field, 0},
{"Certificate.SerialNumber", Field, 0},
{"Certificate.Signature", Field, 0},
{"Certificate.SignatureAlgorithm", Field, 0},
{"Certificate.Subject", Field, 0},
{"Certificate.SubjectKeyId", Field, 0},
{"Certificate.URIs", Field, 10},
{"Certificate.UnhandledCriticalExtensions", Field, 5},
{"Certificate.UnknownExtKeyUsage", Field, 0},
{"Certificate.Version", Field, 0},
{"CertificateInvalidError", Type, 0},
{"CertificateInvalidError.Cert", Field, 0},
{"CertificateInvalidError.Detail", Field, 10},
{"CertificateInvalidError.Reason", Field, 0},
{"CertificateRequest", Type, 3},
{"CertificateRequest.Attributes", Field, 3},
{"CertificateRequest.DNSNames", Field, 3},
{"CertificateRequest.EmailAddresses", Field, 3},
{"CertificateRequest.Extensions", Field, 3},
{"CertificateRequest.ExtraExtensions", Field, 3},
{"CertificateRequest.IPAddresses", Field, 3},
{"CertificateRequest.PublicKey", Field, 3},
{"CertificateRequest.PublicKeyAlgorithm", Field, 3},
{"CertificateRequest.Raw", Field, 3},
{"CertificateRequest.RawSubject", Field, 3},
{"CertificateRequest.RawSubjectPublicKeyInfo", Field, 3},
{"CertificateRequest.RawTBSCertificateRequest", Field, 3},
{"CertificateRequest.Signature", Field, 3},
{"CertificateRequest.SignatureAlgorithm", Field, 3},
{"CertificateRequest.Subject", Field, 3},
{"CertificateRequest.URIs", Field, 10},
{"CertificateRequest.Version", Field, 3},
{"ConstraintViolationError", Type, 0},
{"CreateCertificate", Func, 0},
{"CreateCertificateRequest", Func, 3},
{"CreateRevocationList", Func, 15},
{"DSA", Const, 0},
{"DSAWithSHA1", Const, 0},
{"DSAWithSHA256", Const, 0},
{"DecryptPEMBlock", Func, 1},
{"ECDSA", Const, 1},
{"ECDSAWithSHA1", Const, 1},
{"ECDSAWithSHA256", Const, 1},
{"ECDSAWithSHA384", Const, 1},
{"ECDSAWithSHA512", Const, 1},
{"Ed25519", Const, 13},
{"EncryptPEMBlock", Func, 1},
{"ErrUnsupportedAlgorithm", Var, 0},
{"Expired", Const, 0},
{"ExtKeyUsage", Type, 0},
{"ExtKeyUsageAny", Const, 0},
{"ExtKeyUsageClientAuth", Const, 0},
{"ExtKeyUsageCodeSigning", Const, 0},
{"ExtKeyUsageEmailProtection", Const, 0},
{"ExtKeyUsageIPSECEndSystem", Const, 1},
{"ExtKeyUsageIPSECTunnel", Const, 1},
{"ExtKeyUsageIPSECUser", Const, 1},
{"ExtKeyUsageMicrosoftCommercialCodeSigning", Const, 10},
{"ExtKeyUsageMicrosoftKernelCodeSigning", Const, 10},
{"ExtKeyUsageMicrosoftServerGatedCrypto", Const, 1},
{"ExtKeyUsageNetscapeServerGatedCrypto", Const, 1},
{"ExtKeyUsageOCSPSigning", Const, 0},
{"ExtKeyUsageServerAuth", Const, 0},
{"ExtKeyUsageTimeStamping", Const, 0},
{"HostnameError", Type, 0},
{"HostnameError.Certificate", Field, 0},
{"HostnameError.Host", Field, 0},
{"IncompatibleUsage", Const, 1},
{"IncorrectPasswordError", Var, 1},
{"InsecureAlgorithmError", Type, 6},
{"InvalidReason", Type, 0},
{"IsEncryptedPEMBlock", Func, 1},
{"KeyUsage", Type, 0},
{"KeyUsageCRLSign", Const, 0},
{"KeyUsageCertSign", Const, 0},
{"KeyUsageContentCommitment", Const, 0},
{"KeyUsageDataEncipherment", Const, 0},
{"KeyUsageDecipherOnly", Const, 0},
{"KeyUsageDigitalSignature", Const, 0},
{"KeyUsageEncipherOnly", Const, 0},
{"KeyUsageKeyAgreement", Const, 0},
{"KeyUsageKeyEncipherment", Const, 0},
{"MD2WithRSA", Const, 0},
{"MD5WithRSA", Const, 0},
{"MarshalECPrivateKey", Func, 2},
{"MarshalPKCS1PrivateKey", Func, 0},
{"MarshalPKCS1PublicKey", Func, 10},
{"MarshalPKCS8PrivateKey", Func, 10},
{"MarshalPKIXPublicKey", Func, 0},
{"NameConstraintsWithoutSANs", Const, 10},
{"NameMismatch", Const, 8},
{"NewCertPool", Func, 0},
{"NotAuthorizedToSign", Const, 0},
{"OID", Type, 22},
{"OIDFromInts", Func, 22},
{"PEMCipher", Type, 1},
{"PEMCipher3DES", Const, 1},
{"PEMCipherAES128", Const, 1},
{"PEMCipherAES192", Const, 1},
{"PEMCipherAES256", Const, 1},
{"PEMCipherDES", Const, 1},
{"ParseCRL", Func, 0},
{"ParseCertificate", Func, 0},
{"ParseCertificateRequest", Func, 3},
{"ParseCertificates", Func, 0},
{"ParseDERCRL", Func, 0},
{"ParseECPrivateKey", Func, 1},
{"ParseOID", Func, 23},
{"ParsePKCS1PrivateKey", Func, 0},
{"ParsePKCS1PublicKey", Func, 10},
{"ParsePKCS8PrivateKey", Func, 0},
{"ParsePKIXPublicKey", Func, 0},
{"ParseRevocationList", Func, 19},
{"PublicKeyAlgorithm", Type, 0},
{"PureEd25519", Const, 13},
{"RSA", Const, 0},
{"RevocationList", Type, 15},
{"RevocationList.AuthorityKeyId", Field, 19},
{"RevocationList.Extensions", Field, 19},
{"RevocationList.ExtraExtensions", Field, 15},
{"RevocationList.Issuer", Field, 19},
{"RevocationList.NextUpdate", Field, 15},
{"RevocationList.Number", Field, 15},
{"RevocationList.Raw", Field, 19},
{"RevocationList.RawIssuer", Field, 19},
{"RevocationList.RawTBSRevocationList", Field, 19},
{"RevocationList.RevokedCertificateEntries", Field, 21},
{"RevocationList.RevokedCertificates", Field, 15},
{"RevocationList.Signature", Field, 19},
{"RevocationList.SignatureAlgorithm", Field, 15},
{"RevocationList.ThisUpdate", Field, 15},
{"RevocationListEntry", Type, 21},
{"RevocationListEntry.Extensions", Field, 21},
{"RevocationListEntry.ExtraExtensions", Field, 21},
{"RevocationListEntry.Raw", Field, 21},
{"RevocationListEntry.ReasonCode", Field, 21},
{"RevocationListEntry.RevocationTime", Field, 21},
{"RevocationListEntry.SerialNumber", Field, 21},
{"SHA1WithRSA", Const, 0},
{"SHA256WithRSA", Const, 0},
{"SHA256WithRSAPSS", Const, 8},
{"SHA384WithRSA", Const, 0},
{"SHA384WithRSAPSS", Const, 8},
{"SHA512WithRSA", Const, 0},
{"SHA512WithRSAPSS", Const, 8},
{"SetFallbackRoots", Func, 20},
{"SignatureAlgorithm", Type, 0},
{"SystemCertPool", Func, 7},
{"SystemRootsError", Type, 1},
{"SystemRootsError.Err", Field, 7},
{"TooManyConstraints", Const, 10},
{"TooManyIntermediates", Const, 0},
{"UnconstrainedName", Const, 10},
{"UnhandledCriticalExtension", Type, 0},
{"UnknownAuthorityError", Type, 0},
{"UnknownAuthorityError.Cert", Field, 8},
{"UnknownPublicKeyAlgorithm", Const, 0},
{"UnknownSignatureAlgorithm", Const, 0},
{"VerifyOptions", Type, 0},
{"VerifyOptions.CurrentTime", Field, 0},
{"VerifyOptions.DNSName", Field, 0},
{"VerifyOptions.Intermediates", Field, 0},
{"VerifyOptions.KeyUsages", Field, 1},
{"VerifyOptions.MaxConstraintComparisions", Field, 10},
{"VerifyOptions.Roots", Field, 0},
},
"crypto/x509/pkix": {
{"(*CertificateList).HasExpired", Method, 0},
{"(*Name).FillFromRDNSequence", Method, 0},
{"(Name).String", Method, 10},
{"(Name).ToRDNSequence", Method, 0},
{"(RDNSequence).String", Method, 10},
{"AlgorithmIdentifier", Type, 0},
{"AlgorithmIdentifier.Algorithm", Field, 0},
{"AlgorithmIdentifier.Parameters", Field, 0},
{"AttributeTypeAndValue", Type, 0},
{"AttributeTypeAndValue.Type", Field, 0},
{"AttributeTypeAndValue.Value", Field, 0},
{"AttributeTypeAndValueSET", Type, 3},
{"AttributeTypeAndValueSET.Type", Field, 3},
{"AttributeTypeAndValueSET.Value", Field, 3},
{"CertificateList", Type, 0},
{"CertificateList.SignatureAlgorithm", Field, 0},
{"CertificateList.SignatureValue", Field, 0},
{"CertificateList.TBSCertList", Field, 0},
{"Extension", Type, 0},
{"Extension.Critical", Field, 0},
{"Extension.Id", Field, 0},
{"Extension.Value", Field, 0},
{"Name", Type, 0},
{"Name.CommonName", Field, 0},
{"Name.Country", Field, 0},
{"Name.ExtraNames", Field, 5},
{"Name.Locality", Field, 0},
{"Name.Names", Field, 0},
{"Name.Organization", Field, 0},
{"Name.OrganizationalUnit", Field, 0},
{"Name.PostalCode", Field, 0},
{"Name.Province", Field, 0},
{"Name.SerialNumber", Field, 0},
{"Name.StreetAddress", Field, 0},
{"RDNSequence", Type, 0},
{"RelativeDistinguishedNameSET", Type, 0},
{"RevokedCertificate", Type, 0},
{"RevokedCertificate.Extensions", Field, 0},
{"RevokedCertificate.RevocationTime", Field, 0},
{"RevokedCertificate.SerialNumber", Field, 0},
{"TBSCertificateList", Type, 0},
{"TBSCertificateList.Extensions", Field, 0},
{"TBSCertificateList.Issuer", Field, 0},
{"TBSCertificateList.NextUpdate", Field, 0},
{"TBSCertificateList.Raw", Field, 0},
{"TBSCertificateList.RevokedCertificates", Field, 0},
{"TBSCertificateList.Signature", Field, 0},
{"TBSCertificateList.ThisUpdate", Field, 0},
{"TBSCertificateList.Version", Field, 0},
},
"database/sql": {
{"(*ColumnType).DatabaseTypeName", Method, 8},
{"(*ColumnType).DecimalSize", Method, 8},
{"(*ColumnType).Length", Method, 8},
{"(*ColumnType).Name", Method, 8},
{"(*ColumnType).Nullable", Method, 8},
{"(*ColumnType).ScanType", Method, 8},
{"(*Conn).BeginTx", Method, 9},
{"(*Conn).Close", Method, 9},
{"(*Conn).ExecContext", Method, 9},
{"(*Conn).PingContext", Method, 9},
{"(*Conn).PrepareContext", Method, 9},
{"(*Conn).QueryContext", Method, 9},
{"(*Conn).QueryRowContext", Method, 9},
{"(*Conn).Raw", Method, 13},
{"(*DB).Begin", Method, 0},
{"(*DB).BeginTx", Method, 8},
{"(*DB).Close", Method, 0},
{"(*DB).Conn", Method, 9},
{"(*DB).Driver", Method, 0},
{"(*DB).Exec", Method, 0},
{"(*DB).ExecContext", Method, 8},
{"(*DB).Ping", Method, 1},
{"(*DB).PingContext", Method, 8},
{"(*DB).Prepare", Method, 0},
{"(*DB).PrepareContext", Method, 8},
{"(*DB).Query", Method, 0},
{"(*DB).QueryContext", Method, 8},
{"(*DB).QueryRow", Method, 0},
{"(*DB).QueryRowContext", Method, 8},
{"(*DB).SetConnMaxIdleTime", Method, 15},
{"(*DB).SetConnMaxLifetime", Method, 6},
{"(*DB).SetMaxIdleConns", Method, 1},
{"(*DB).SetMaxOpenConns", Method, 2},
{"(*DB).Stats", Method, 5},
{"(*Null).Scan", Method, 22},
{"(*NullBool).Scan", Method, 0},
{"(*NullByte).Scan", Method, 17},
{"(*NullFloat64).Scan", Method, 0},
{"(*NullInt16).Scan", Method, 17},
{"(*NullInt32).Scan", Method, 13},
{"(*NullInt64).Scan", Method, 0},
{"(*NullString).Scan", Method, 0},
{"(*NullTime).Scan", Method, 13},
{"(*Row).Err", Method, 15},
{"(*Row).Scan", Method, 0},
{"(*Rows).Close", Method, 0},
{"(*Rows).ColumnTypes", Method, 8},
{"(*Rows).Columns", Method, 0},
{"(*Rows).Err", Method, 0},
{"(*Rows).Next", Method, 0},
{"(*Rows).NextResultSet", Method, 8},
{"(*Rows).Scan", Method, 0},
{"(*Stmt).Close", Method, 0},
{"(*Stmt).Exec", Method, 0},
{"(*Stmt).ExecContext", Method, 8},
{"(*Stmt).Query", Method, 0},
{"(*Stmt).QueryContext", Method, 8},
{"(*Stmt).QueryRow", Method, 0},
{"(*Stmt).QueryRowContext", Method, 8},
{"(*Tx).Commit", Method, 0},
{"(*Tx).Exec", Method, 0},
{"(*Tx).ExecContext", Method, 8},
{"(*Tx).Prepare", Method, 0},
{"(*Tx).PrepareContext", Method, 8},
{"(*Tx).Query", Method, 0},
{"(*Tx).QueryContext", Method, 8},
{"(*Tx).QueryRow", Method, 0},
{"(*Tx).QueryRowContext", Method, 8},
{"(*Tx).Rollback", Method, 0},
{"(*Tx).Stmt", Method, 0},
{"(*Tx).StmtContext", Method, 8},
{"(IsolationLevel).String", Method, 11},
{"(Null).Value", Method, 22},
{"(NullBool).Value", Method, 0},
{"(NullByte).Value", Method, 17},
{"(NullFloat64).Value", Method, 0},
{"(NullInt16).Value", Method, 17},
{"(NullInt32).Value", Method, 13},
{"(NullInt64).Value", Method, 0},
{"(NullString).Value", Method, 0},
{"(NullTime).Value", Method, 13},
{"ColumnType", Type, 8},
{"Conn", Type, 9},
{"DB", Type, 0},
{"DBStats", Type, 5},
{"DBStats.Idle", Field, 11},
{"DBStats.InUse", Field, 11},
{"DBStats.MaxIdleClosed", Field, 11},
{"DBStats.MaxIdleTimeClosed", Field, 15},
{"DBStats.MaxLifetimeClosed", Field, 11},
{"DBStats.MaxOpenConnections", Field, 11},
{"DBStats.OpenConnections", Field, 5},
{"DBStats.WaitCount", Field, 11},
{"DBStats.WaitDuration", Field, 11},
{"Drivers", Func, 4},
{"ErrConnDone", Var, 9},
{"ErrNoRows", Var, 0},
{"ErrTxDone", Var, 0},
{"IsolationLevel", Type, 8},
{"LevelDefault", Const, 8},
{"LevelLinearizable", Const, 8},
{"LevelReadCommitted", Const, 8},
{"LevelReadUncommitted", Const, 8},
{"LevelRepeatableRead", Const, 8},
{"LevelSerializable", Const, 8},
{"LevelSnapshot", Const, 8},
{"LevelWriteCommitted", Const, 8},
{"Named", Func, 8},
{"NamedArg", Type, 8},
{"NamedArg.Name", Field, 8},
{"NamedArg.Value", Field, 8},
{"Null", Type, 22},
{"Null.V", Field, 22},
{"Null.Valid", Field, 22},
{"NullBool", Type, 0},
{"NullBool.Bool", Field, 0},
{"NullBool.Valid", Field, 0},
{"NullByte", Type, 17},
{"NullByte.Byte", Field, 17},
{"NullByte.Valid", Field, 17},
{"NullFloat64", Type, 0},
{"NullFloat64.Float64", Field, 0},
{"NullFloat64.Valid", Field, 0},
{"NullInt16", Type, 17},
{"NullInt16.Int16", Field, 17},
{"NullInt16.Valid", Field, 17},
{"NullInt32", Type, 13},
{"NullInt32.Int32", Field, 13},
{"NullInt32.Valid", Field, 13},
{"NullInt64", Type, 0},
{"NullInt64.Int64", Field, 0},
{"NullInt64.Valid", Field, 0},
{"NullString", Type, 0},
{"NullString.String", Field, 0},
{"NullString.Valid", Field, 0},
{"NullTime", Type, 13},
{"NullTime.Time", Field, 13},
{"NullTime.Valid", Field, 13},
{"Open", Func, 0},
{"OpenDB", Func, 10},
{"Out", Type, 9},
{"Out.Dest", Field, 9},
{"Out.In", Field, 9},
{"RawBytes", Type, 0},
{"Register", Func, 0},
{"Result", Type, 0},
{"Row", Type, 0},
{"Rows", Type, 0},
{"Scanner", Type, 0},
{"Stmt", Type, 0},
{"Tx", Type, 0},
{"TxOptions", Type, 8},
{"TxOptions.Isolation", Field, 8},
{"TxOptions.ReadOnly", Field, 8},
},
"database/sql/driver": {
{"(NotNull).ConvertValue", Method, 0},
{"(Null).ConvertValue", Method, 0},
{"(RowsAffected).LastInsertId", Method, 0},
{"(RowsAffected).RowsAffected", Method, 0},
{"Bool", Var, 0},
{"ColumnConverter", Type, 0},
{"Conn", Type, 0},
{"ConnBeginTx", Type, 8},
{"ConnPrepareContext", Type, 8},
{"Connector", Type, 10},
{"DefaultParameterConverter", Var, 0},
{"Driver", Type, 0},
{"DriverContext", Type, 10},
{"ErrBadConn", Var, 0},
{"ErrRemoveArgument", Var, 9},
{"ErrSkip", Var, 0},
{"Execer", Type, 0},
{"ExecerContext", Type, 8},
{"Int32", Var, 0},
{"IsScanValue", Func, 0},
{"IsValue", Func, 0},
{"IsolationLevel", Type, 8},
{"NamedValue", Type, 8},
{"NamedValue.Name", Field, 8},
{"NamedValue.Ordinal", Field, 8},
{"NamedValue.Value", Field, 8},
{"NamedValueChecker", Type, 9},
{"NotNull", Type, 0},
{"NotNull.Converter", Field, 0},
{"Null", Type, 0},
{"Null.Converter", Field, 0},
{"Pinger", Type, 8},
{"Queryer", Type, 1},
{"QueryerContext", Type, 8},
{"Result", Type, 0},
{"ResultNoRows", Var, 0},
{"Rows", Type, 0},
{"RowsAffected", Type, 0},
{"RowsColumnTypeDatabaseTypeName", Type, 8},
{"RowsColumnTypeLength", Type, 8},
{"RowsColumnTypeNullable", Type, 8},
{"RowsColumnTypePrecisionScale", Type, 8},
{"RowsColumnTypeScanType", Type, 8},
{"RowsNextResultSet", Type, 8},
{"SessionResetter", Type, 10},
{"Stmt", Type, 0},
{"StmtExecContext", Type, 8},
{"StmtQueryContext", Type, 8},
{"String", Var, 0},
{"Tx", Type, 0},
{"TxOptions", Type, 8},
{"TxOptions.Isolation", Field, 8},
{"TxOptions.ReadOnly", Field, 8},
{"Validator", Type, 15},
{"Value", Type, 0},
{"ValueConverter", Type, 0},
{"Valuer", Type, 0},
},
"debug/buildinfo": {
{"BuildInfo", Type, 18},
{"Read", Func, 18},
{"ReadFile", Func, 18},
},
"debug/dwarf": {
{"(*AddrType).Basic", Method, 0},
{"(*AddrType).Common", Method, 0},
{"(*AddrType).Size", Method, 0},
{"(*AddrType).String", Method, 0},
{"(*ArrayType).Common", Method, 0},
{"(*ArrayType).Size", Method, 0},
{"(*ArrayType).String", Method, 0},
{"(*BasicType).Basic", Method, 0},
{"(*BasicType).Common", Method, 0},
{"(*BasicType).Size", Method, 0},
{"(*BasicType).String", Method, 0},
{"(*BoolType).Basic", Method, 0},
{"(*BoolType).Common", Method, 0},
{"(*BoolType).Size", Method, 0},
{"(*BoolType).String", Method, 0},
{"(*CharType).Basic", Method, 0},
{"(*CharType).Common", Method, 0},
{"(*CharType).Size", Method, 0},
{"(*CharType).String", Method, 0},
{"(*CommonType).Common", Method, 0},
{"(*CommonType).Size", Method, 0},
{"(*ComplexType).Basic", Method, 0},
{"(*ComplexType).Common", Method, 0},
{"(*ComplexType).Size", Method, 0},
{"(*ComplexType).String", Method, 0},
{"(*Data).AddSection", Method, 14},
{"(*Data).AddTypes", Method, 3},
{"(*Data).LineReader", Method, 5},
{"(*Data).Ranges", Method, 7},
{"(*Data).Reader", Method, 0},
{"(*Data).Type", Method, 0},
{"(*DotDotDotType).Common", Method, 0},
{"(*DotDotDotType).Size", Method, 0},
{"(*DotDotDotType).String", Method, 0},
{"(*Entry).AttrField", Method, 5},
{"(*Entry).Val", Method, 0},
{"(*EnumType).Common", Method, 0},
{"(*EnumType).Size", Method, 0},
{"(*EnumType).String", Method, 0},
{"(*FloatType).Basic", Method, 0},
{"(*FloatType).Common", Method, 0},
{"(*FloatType).Size", Method, 0},
{"(*FloatType).String", Method, 0},
{"(*FuncType).Common", Method, 0},
{"(*FuncType).Size", Method, 0},
{"(*FuncType).String", Method, 0},
{"(*IntType).Basic", Method, 0},
{"(*IntType).Common", Method, 0},
{"(*IntType).Size", Method, 0},
{"(*IntType).String", Method, 0},
{"(*LineReader).Files", Method, 14},
{"(*LineReader).Next", Method, 5},
{"(*LineReader).Reset", Method, 5},
{"(*LineReader).Seek", Method, 5},
{"(*LineReader).SeekPC", Method, 5},
{"(*LineReader).Tell", Method, 5},
{"(*PtrType).Common", Method, 0},
{"(*PtrType).Size", Method, 0},
{"(*PtrType).String", Method, 0},
{"(*QualType).Common", Method, 0},
{"(*QualType).Size", Method, 0},
{"(*QualType).String", Method, 0},
{"(*Reader).AddressSize", Method, 5},
{"(*Reader).ByteOrder", Method, 14},
{"(*Reader).Next", Method, 0},
{"(*Reader).Seek", Method, 0},
{"(*Reader).SeekPC", Method, 7},
{"(*Reader).SkipChildren", Method, 0},
{"(*StructType).Common", Method, 0},
{"(*StructType).Defn", Method, 0},
{"(*StructType).Size", Method, 0},
{"(*StructType).String", Method, 0},
{"(*TypedefType).Common", Method, 0},
{"(*TypedefType).Size", Method, 0},
{"(*TypedefType).String", Method, 0},
{"(*UcharType).Basic", Method, 0},
{"(*UcharType).Common", Method, 0},
{"(*UcharType).Size", Method, 0},
{"(*UcharType).String", Method, 0},
{"(*UintType).Basic", Method, 0},
{"(*UintType).Common", Method, 0},
{"(*UintType).Size", Method, 0},
{"(*UintType).String", Method, 0},
{"(*UnspecifiedType).Basic", Method, 4},
{"(*UnspecifiedType).Common", Method, 4},
{"(*UnspecifiedType).Size", Method, 4},
{"(*UnspecifiedType).String", Method, 4},
{"(*UnsupportedType).Common", Method, 13},
{"(*UnsupportedType).Size", Method, 13},
{"(*UnsupportedType).String", Method, 13},
{"(*VoidType).Common", Method, 0},
{"(*VoidType).Size", Method, 0},
{"(*VoidType).String", Method, 0},
{"(Attr).GoString", Method, 0},
{"(Attr).String", Method, 0},
{"(Class).GoString", Method, 5},
{"(Class).String", Method, 5},
{"(DecodeError).Error", Method, 0},
{"(Tag).GoString", Method, 0},
{"(Tag).String", Method, 0},
{"AddrType", Type, 0},
{"AddrType.BasicType", Field, 0},
{"ArrayType", Type, 0},
{"ArrayType.CommonType", Field, 0},
{"ArrayType.Count", Field, 0},
{"ArrayType.StrideBitSize", Field, 0},
{"ArrayType.Type", Field, 0},
{"Attr", Type, 0},
{"AttrAbstractOrigin", Const, 0},
{"AttrAccessibility", Const, 0},
{"AttrAddrBase", Const, 14},
{"AttrAddrClass", Const, 0},
{"AttrAlignment", Const, 14},
{"AttrAllocated", Const, 0},
{"AttrArtificial", Const, 0},
{"AttrAssociated", Const, 0},
{"AttrBaseTypes", Const, 0},
{"AttrBinaryScale", Const, 14},
{"AttrBitOffset", Const, 0},
{"AttrBitSize", Const, 0},
{"AttrByteSize", Const, 0},
{"AttrCallAllCalls", Const, 14},
{"AttrCallAllSourceCalls", Const, 14},
{"AttrCallAllTailCalls", Const, 14},
{"AttrCallColumn", Const, 0},
{"AttrCallDataLocation", Const, 14},
{"AttrCallDataValue", Const, 14},
{"AttrCallFile", Const, 0},
{"AttrCallLine", Const, 0},
{"AttrCallOrigin", Const, 14},
{"AttrCallPC", Const, 14},
{"AttrCallParameter", Const, 14},
{"AttrCallReturnPC", Const, 14},
{"AttrCallTailCall", Const, 14},
{"AttrCallTarget", Const, 14},
{"AttrCallTargetClobbered", Const, 14},
{"AttrCallValue", Const, 14},
{"AttrCalling", Const, 0},
{"AttrCommonRef", Const, 0},
{"AttrCompDir", Const, 0},
{"AttrConstExpr", Const, 14},
{"AttrConstValue", Const, 0},
{"AttrContainingType", Const, 0},
{"AttrCount", Const, 0},
{"AttrDataBitOffset", Const, 14},
{"AttrDataLocation", Const, 0},
{"AttrDataMemberLoc", Const, 0},
{"AttrDecimalScale", Const, 14},
{"AttrDecimalSign", Const, 14},
{"AttrDeclColumn", Const, 0},
{"AttrDeclFile", Const, 0},
{"AttrDeclLine", Const, 0},
{"AttrDeclaration", Const, 0},
{"AttrDefaultValue", Const, 0},
{"AttrDefaulted", Const, 14},
{"AttrDeleted", Const, 14},
{"AttrDescription", Const, 0},
{"AttrDigitCount", Const, 14},
{"AttrDiscr", Const, 0},
{"AttrDiscrList", Const, 0},
{"AttrDiscrValue", Const, 0},
{"AttrDwoName", Const, 14},
{"AttrElemental", Const, 14},
{"AttrEncoding", Const, 0},
{"AttrEndianity", Const, 14},
{"AttrEntrypc", Const, 0},
{"AttrEnumClass", Const, 14},
{"AttrExplicit", Const, 14},
{"AttrExportSymbols", Const, 14},
{"AttrExtension", Const, 0},
{"AttrExternal", Const, 0},
{"AttrFrameBase", Const, 0},
{"AttrFriend", Const, 0},
{"AttrHighpc", Const, 0},
{"AttrIdentifierCase", Const, 0},
{"AttrImport", Const, 0},
{"AttrInline", Const, 0},
{"AttrIsOptional", Const, 0},
{"AttrLanguage", Const, 0},
{"AttrLinkageName", Const, 14},
{"AttrLocation", Const, 0},
{"AttrLoclistsBase", Const, 14},
{"AttrLowerBound", Const, 0},
{"AttrLowpc", Const, 0},
{"AttrMacroInfo", Const, 0},
{"AttrMacros", Const, 14},
{"AttrMainSubprogram", Const, 14},
{"AttrMutable", Const, 14},
{"AttrName", Const, 0},
{"AttrNamelistItem", Const, 0},
{"AttrNoreturn", Const, 14},
{"AttrObjectPointer", Const, 14},
{"AttrOrdering", Const, 0},
{"AttrPictureString", Const, 14},
{"AttrPriority", Const, 0},
{"AttrProducer", Const, 0},
{"AttrPrototyped", Const, 0},
{"AttrPure", Const, 14},
{"AttrRanges", Const, 0},
{"AttrRank", Const, 14},
{"AttrRecursive", Const, 14},
{"AttrReference", Const, 14},
{"AttrReturnAddr", Const, 0},
{"AttrRnglistsBase", Const, 14},
{"AttrRvalueReference", Const, 14},
{"AttrSegment", Const, 0},
{"AttrSibling", Const, 0},
{"AttrSignature", Const, 14},
{"AttrSmall", Const, 14},
{"AttrSpecification", Const, 0},
{"AttrStartScope", Const, 0},
{"AttrStaticLink", Const, 0},
{"AttrStmtList", Const, 0},
{"AttrStrOffsetsBase", Const, 14},
{"AttrStride", Const, 0},
{"AttrStrideSize", Const, 0},
{"AttrStringLength", Const, 0},
{"AttrStringLengthBitSize", Const, 14},
{"AttrStringLengthByteSize", Const, 14},
{"AttrThreadsScaled", Const, 14},
{"AttrTrampoline", Const, 0},
{"AttrType", Const, 0},
{"AttrUpperBound", Const, 0},
{"AttrUseLocation", Const, 0},
{"AttrUseUTF8", Const, 0},
{"AttrVarParam", Const, 0},
{"AttrVirtuality", Const, 0},
{"AttrVisibility", Const, 0},
{"AttrVtableElemLoc", Const, 0},
{"BasicType", Type, 0},
{"BasicType.BitOffset", Field, 0},
{"BasicType.BitSize", Field, 0},
{"BasicType.CommonType", Field, 0},
{"BasicType.DataBitOffset", Field, 18},
{"BoolType", Type, 0},
{"BoolType.BasicType", Field, 0},
{"CharType", Type, 0},
{"CharType.BasicType", Field, 0},
{"Class", Type, 5},
{"ClassAddrPtr", Const, 14},
{"ClassAddress", Const, 5},
{"ClassBlock", Const, 5},
{"ClassConstant", Const, 5},
{"ClassExprLoc", Const, 5},
{"ClassFlag", Const, 5},
{"ClassLinePtr", Const, 5},
{"ClassLocList", Const, 14},
{"ClassLocListPtr", Const, 5},
{"ClassMacPtr", Const, 5},
{"ClassRangeListPtr", Const, 5},
{"ClassReference", Const, 5},
{"ClassReferenceAlt", Const, 5},
{"ClassReferenceSig", Const, 5},
{"ClassRngList", Const, 14},
{"ClassRngListsPtr", Const, 14},
{"ClassStrOffsetsPtr", Const, 14},
{"ClassString", Const, 5},
{"ClassStringAlt", Const, 5},
{"ClassUnknown", Const, 6},
{"CommonType", Type, 0},
{"CommonType.ByteSize", Field, 0},
{"CommonType.Name", Field, 0},
{"ComplexType", Type, 0},
{"ComplexType.BasicType", Field, 0},
{"Data", Type, 0},
{"DecodeError", Type, 0},
{"DecodeError.Err", Field, 0},
{"DecodeError.Name", Field, 0},
{"DecodeError.Offset", Field, 0},
{"DotDotDotType", Type, 0},
{"DotDotDotType.CommonType", Field, 0},
{"Entry", Type, 0},
{"Entry.Children", Field, 0},
{"Entry.Field", Field, 0},
{"Entry.Offset", Field, 0},
{"Entry.Tag", Field, 0},
{"EnumType", Type, 0},
{"EnumType.CommonType", Field, 0},
{"EnumType.EnumName", Field, 0},
{"EnumType.Val", Field, 0},
{"EnumValue", Type, 0},
{"EnumValue.Name", Field, 0},
{"EnumValue.Val", Field, 0},
{"ErrUnknownPC", Var, 5},
{"Field", Type, 0},
{"Field.Attr", Field, 0},
{"Field.Class", Field, 5},
{"Field.Val", Field, 0},
{"FloatType", Type, 0},
{"FloatType.BasicType", Field, 0},
{"FuncType", Type, 0},
{"FuncType.CommonType", Field, 0},
{"FuncType.ParamType", Field, 0},
{"FuncType.ReturnType", Field, 0},
{"IntType", Type, 0},
{"IntType.BasicType", Field, 0},
{"LineEntry", Type, 5},
{"LineEntry.Address", Field, 5},
{"LineEntry.BasicBlock", Field, 5},
{"LineEntry.Column", Field, 5},
{"LineEntry.Discriminator", Field, 5},
{"LineEntry.EndSequence", Field, 5},
{"LineEntry.EpilogueBegin", Field, 5},
{"LineEntry.File", Field, 5},
{"LineEntry.ISA", Field, 5},
{"LineEntry.IsStmt", Field, 5},
{"LineEntry.Line", Field, 5},
{"LineEntry.OpIndex", Field, 5},
{"LineEntry.PrologueEnd", Field, 5},
{"LineFile", Type, 5},
{"LineFile.Length", Field, 5},
{"LineFile.Mtime", Field, 5},
{"LineFile.Name", Field, 5},
{"LineReader", Type, 5},
{"LineReaderPos", Type, 5},
{"New", Func, 0},
{"Offset", Type, 0},
{"PtrType", Type, 0},
{"PtrType.CommonType", Field, 0},
{"PtrType.Type", Field, 0},
{"QualType", Type, 0},
{"QualType.CommonType", Field, 0},
{"QualType.Qual", Field, 0},
{"QualType.Type", Field, 0},
{"Reader", Type, 0},
{"StructField", Type, 0},
{"StructField.BitOffset", Field, 0},
{"StructField.BitSize", Field, 0},
{"StructField.ByteOffset", Field, 0},
{"StructField.ByteSize", Field, 0},
{"StructField.DataBitOffset", Field, 18},
{"StructField.Name", Field, 0},
{"StructField.Type", Field, 0},
{"StructType", Type, 0},
{"StructType.CommonType", Field, 0},
{"StructType.Field", Field, 0},
{"StructType.Incomplete", Field, 0},
{"StructType.Kind", Field, 0},
{"StructType.StructName", Field, 0},
{"Tag", Type, 0},
{"TagAccessDeclaration", Const, 0},
{"TagArrayType", Const, 0},
{"TagAtomicType", Const, 14},
{"TagBaseType", Const, 0},
{"TagCallSite", Const, 14},
{"TagCallSiteParameter", Const, 14},
{"TagCatchDwarfBlock", Const, 0},
{"TagClassType", Const, 0},
{"TagCoarrayType", Const, 14},
{"TagCommonDwarfBlock", Const, 0},
{"TagCommonInclusion", Const, 0},
{"TagCompileUnit", Const, 0},
{"TagCondition", Const, 3},
{"TagConstType", Const, 0},
{"TagConstant", Const, 0},
{"TagDwarfProcedure", Const, 0},
{"TagDynamicType", Const, 14},
{"TagEntryPoint", Const, 0},
{"TagEnumerationType", Const, 0},
{"TagEnumerator", Const, 0},
{"TagFileType", Const, 0},
{"TagFormalParameter", Const, 0},
{"TagFriend", Const, 0},
{"TagGenericSubrange", Const, 14},
{"TagImmutableType", Const, 14},
{"TagImportedDeclaration", Const, 0},
{"TagImportedModule", Const, 0},
{"TagImportedUnit", Const, 0},
{"TagInheritance", Const, 0},
{"TagInlinedSubroutine", Const, 0},
{"TagInterfaceType", Const, 0},
{"TagLabel", Const, 0},
{"TagLexDwarfBlock", Const, 0},
{"TagMember", Const, 0},
{"TagModule", Const, 0},
{"TagMutableType", Const, 0},
{"TagNamelist", Const, 0},
{"TagNamelistItem", Const, 0},
{"TagNamespace", Const, 0},
{"TagPackedType", Const, 0},
{"TagPartialUnit", Const, 0},
{"TagPointerType", Const, 0},
{"TagPtrToMemberType", Const, 0},
{"TagReferenceType", Const, 0},
{"TagRestrictType", Const, 0},
{"TagRvalueReferenceType", Const, 3},
{"TagSetType", Const, 0},
{"TagSharedType", Const, 3},
{"TagSkeletonUnit", Const, 14},
{"TagStringType", Const, 0},
{"TagStructType", Const, 0},
{"TagSubprogram", Const, 0},
{"TagSubrangeType", Const, 0},
{"TagSubroutineType", Const, 0},
{"TagTemplateAlias", Const, 3},
{"TagTemplateTypeParameter", Const, 0},
{"TagTemplateValueParameter", Const, 0},
{"TagThrownType", Const, 0},
{"TagTryDwarfBlock", Const, 0},
{"TagTypeUnit", Const, 3},
{"TagTypedef", Const, 0},
{"TagUnionType", Const, 0},
{"TagUnspecifiedParameters", Const, 0},
{"TagUnspecifiedType", Const, 0},
{"TagVariable", Const, 0},
{"TagVariant", Const, 0},
{"TagVariantPart", Const, 0},
{"TagVolatileType", Const, 0},
{"TagWithStmt", Const, 0},
{"Type", Type, 0},
{"TypedefType", Type, 0},
{"TypedefType.CommonType", Field, 0},
{"TypedefType.Type", Field, 0},
{"UcharType", Type, 0},
{"UcharType.BasicType", Field, 0},
{"UintType", Type, 0},
{"UintType.BasicType", Field, 0},
{"UnspecifiedType", Type, 4},
{"UnspecifiedType.BasicType", Field, 4},
{"UnsupportedType", Type, 13},
{"UnsupportedType.CommonType", Field, 13},
{"UnsupportedType.Tag", Field, 13},
{"VoidType", Type, 0},
{"VoidType.CommonType", Field, 0},
},
"debug/elf": {
{"(*File).Close", Method, 0},
{"(*File).DWARF", Method, 0},
{"(*File).DynString", Method, 1},
{"(*File).DynValue", Method, 21},
{"(*File).DynamicSymbols", Method, 4},
{"(*File).ImportedLibraries", Method, 0},
{"(*File).ImportedSymbols", Method, 0},
{"(*File).Section", Method, 0},
{"(*File).SectionByType", Method, 0},
{"(*File).Symbols", Method, 0},
{"(*FormatError).Error", Method, 0},
{"(*Prog).Open", Method, 0},
{"(*Section).Data", Method, 0},
{"(*Section).Open", Method, 0},
{"(Class).GoString", Method, 0},
{"(Class).String", Method, 0},
{"(CompressionType).GoString", Method, 6},
{"(CompressionType).String", Method, 6},
{"(Data).GoString", Method, 0},
{"(Data).String", Method, 0},
{"(DynFlag).GoString", Method, 0},
{"(DynFlag).String", Method, 0},
{"(DynFlag1).GoString", Method, 21},
{"(DynFlag1).String", Method, 21},
{"(DynTag).GoString", Method, 0},
{"(DynTag).String", Method, 0},
{"(Machine).GoString", Method, 0},
{"(Machine).String", Method, 0},
{"(NType).GoString", Method, 0},
{"(NType).String", Method, 0},
{"(OSABI).GoString", Method, 0},
{"(OSABI).String", Method, 0},
{"(Prog).ReadAt", Method, 0},
{"(ProgFlag).GoString", Method, 0},
{"(ProgFlag).String", Method, 0},
{"(ProgType).GoString", Method, 0},
{"(ProgType).String", Method, 0},
{"(R_386).GoString", Method, 0},
{"(R_386).String", Method, 0},
{"(R_390).GoString", Method, 7},
{"(R_390).String", Method, 7},
{"(R_AARCH64).GoString", Method, 4},
{"(R_AARCH64).String", Method, 4},
{"(R_ALPHA).GoString", Method, 0},
{"(R_ALPHA).String", Method, 0},
{"(R_ARM).GoString", Method, 0},
{"(R_ARM).String", Method, 0},
{"(R_LARCH).GoString", Method, 19},
{"(R_LARCH).String", Method, 19},
{"(R_MIPS).GoString", Method, 6},
{"(R_MIPS).String", Method, 6},
{"(R_PPC).GoString", Method, 0},
{"(R_PPC).String", Method, 0},
{"(R_PPC64).GoString", Method, 5},
{"(R_PPC64).String", Method, 5},
{"(R_RISCV).GoString", Method, 11},
{"(R_RISCV).String", Method, 11},
{"(R_SPARC).GoString", Method, 0},
{"(R_SPARC).String", Method, 0},
{"(R_X86_64).GoString", Method, 0},
{"(R_X86_64).String", Method, 0},
{"(Section).ReadAt", Method, 0},
{"(SectionFlag).GoString", Method, 0},
{"(SectionFlag).String", Method, 0},
{"(SectionIndex).GoString", Method, 0},
{"(SectionIndex).String", Method, 0},
{"(SectionType).GoString", Method, 0},
{"(SectionType).String", Method, 0},
{"(SymBind).GoString", Method, 0},
{"(SymBind).String", Method, 0},
{"(SymType).GoString", Method, 0},
{"(SymType).String", Method, 0},
{"(SymVis).GoString", Method, 0},
{"(SymVis).String", Method, 0},
{"(Type).GoString", Method, 0},
{"(Type).String", Method, 0},
{"(Version).GoString", Method, 0},
{"(Version).String", Method, 0},
{"ARM_MAGIC_TRAMP_NUMBER", Const, 0},
{"COMPRESS_HIOS", Const, 6},
{"COMPRESS_HIPROC", Const, 6},
{"COMPRESS_LOOS", Const, 6},
{"COMPRESS_LOPROC", Const, 6},
{"COMPRESS_ZLIB", Const, 6},
{"COMPRESS_ZSTD", Const, 21},
{"Chdr32", Type, 6},
{"Chdr32.Addralign", Field, 6},
{"Chdr32.Size", Field, 6},
{"Chdr32.Type", Field, 6},
{"Chdr64", Type, 6},
{"Chdr64.Addralign", Field, 6},
{"Chdr64.Size", Field, 6},
{"Chdr64.Type", Field, 6},
{"Class", Type, 0},
{"CompressionType", Type, 6},
{"DF_1_CONFALT", Const, 21},
{"DF_1_DIRECT", Const, 21},
{"DF_1_DISPRELDNE", Const, 21},
{"DF_1_DISPRELPND", Const, 21},
{"DF_1_EDITED", Const, 21},
{"DF_1_ENDFILTEE", Const, 21},
{"DF_1_GLOBAL", Const, 21},
{"DF_1_GLOBAUDIT", Const, 21},
{"DF_1_GROUP", Const, 21},
{"DF_1_IGNMULDEF", Const, 21},
{"DF_1_INITFIRST", Const, 21},
{"DF_1_INTERPOSE", Const, 21},
{"DF_1_KMOD", Const, 21},
{"DF_1_LOADFLTR", Const, 21},
{"DF_1_NOCOMMON", Const, 21},
{"DF_1_NODEFLIB", Const, 21},
{"DF_1_NODELETE", Const, 21},
{"DF_1_NODIRECT", Const, 21},
{"DF_1_NODUMP", Const, 21},
{"DF_1_NOHDR", Const, 21},
{"DF_1_NOKSYMS", Const, 21},
{"DF_1_NOOPEN", Const, 21},
{"DF_1_NORELOC", Const, 21},
{"DF_1_NOW", Const, 21},
{"DF_1_ORIGIN", Const, 21},
{"DF_1_PIE", Const, 21},
{"DF_1_SINGLETON", Const, 21},
{"DF_1_STUB", Const, 21},
{"DF_1_SYMINTPOSE", Const, 21},
{"DF_1_TRANS", Const, 21},
{"DF_1_WEAKFILTER", Const, 21},
{"DF_BIND_NOW", Const, 0},
{"DF_ORIGIN", Const, 0},
{"DF_STATIC_TLS", Const, 0},
{"DF_SYMBOLIC", Const, 0},
{"DF_TEXTREL", Const, 0},
{"DT_ADDRRNGHI", Const, 16},
{"DT_ADDRRNGLO", Const, 16},
{"DT_AUDIT", Const, 16},
{"DT_AUXILIARY", Const, 16},
{"DT_BIND_NOW", Const, 0},
{"DT_CHECKSUM", Const, 16},
{"DT_CONFIG", Const, 16},
{"DT_DEBUG", Const, 0},
{"DT_DEPAUDIT", Const, 16},
{"DT_ENCODING", Const, 0},
{"DT_FEATURE", Const, 16},
{"DT_FILTER", Const, 16},
{"DT_FINI", Const, 0},
{"DT_FINI_ARRAY", Const, 0},
{"DT_FINI_ARRAYSZ", Const, 0},
{"DT_FLAGS", Const, 0},
{"DT_FLAGS_1", Const, 16},
{"DT_GNU_CONFLICT", Const, 16},
{"DT_GNU_CONFLICTSZ", Const, 16},
{"DT_GNU_HASH", Const, 16},
{"DT_GNU_LIBLIST", Const, 16},
{"DT_GNU_LIBLISTSZ", Const, 16},
{"DT_GNU_PRELINKED", Const, 16},
{"DT_HASH", Const, 0},
{"DT_HIOS", Const, 0},
{"DT_HIPROC", Const, 0},
{"DT_INIT", Const, 0},
{"DT_INIT_ARRAY", Const, 0},
{"DT_INIT_ARRAYSZ", Const, 0},
{"DT_JMPREL", Const, 0},
{"DT_LOOS", Const, 0},
{"DT_LOPROC", Const, 0},
{"DT_MIPS_AUX_DYNAMIC", Const, 16},
{"DT_MIPS_BASE_ADDRESS", Const, 16},
{"DT_MIPS_COMPACT_SIZE", Const, 16},
{"DT_MIPS_CONFLICT", Const, 16},
{"DT_MIPS_CONFLICTNO", Const, 16},
{"DT_MIPS_CXX_FLAGS", Const, 16},
{"DT_MIPS_DELTA_CLASS", Const, 16},
{"DT_MIPS_DELTA_CLASSSYM", Const, 16},
{"DT_MIPS_DELTA_CLASSSYM_NO", Const, 16},
{"DT_MIPS_DELTA_CLASS_NO", Const, 16},
{"DT_MIPS_DELTA_INSTANCE", Const, 16},
{"DT_MIPS_DELTA_INSTANCE_NO", Const, 16},
{"DT_MIPS_DELTA_RELOC", Const, 16},
{"DT_MIPS_DELTA_RELOC_NO", Const, 16},
{"DT_MIPS_DELTA_SYM", Const, 16},
{"DT_MIPS_DELTA_SYM_NO", Const, 16},
{"DT_MIPS_DYNSTR_ALIGN", Const, 16},
{"DT_MIPS_FLAGS", Const, 16},
{"DT_MIPS_GOTSYM", Const, 16},
{"DT_MIPS_GP_VALUE", Const, 16},
{"DT_MIPS_HIDDEN_GOTIDX", Const, 16},
{"DT_MIPS_HIPAGENO", Const, 16},
{"DT_MIPS_ICHECKSUM", Const, 16},
{"DT_MIPS_INTERFACE", Const, 16},
{"DT_MIPS_INTERFACE_SIZE", Const, 16},
{"DT_MIPS_IVERSION", Const, 16},
{"DT_MIPS_LIBLIST", Const, 16},
{"DT_MIPS_LIBLISTNO", Const, 16},
{"DT_MIPS_LOCALPAGE_GOTIDX", Const, 16},
{"DT_MIPS_LOCAL_GOTIDX", Const, 16},
{"DT_MIPS_LOCAL_GOTNO", Const, 16},
{"DT_MIPS_MSYM", Const, 16},
{"DT_MIPS_OPTIONS", Const, 16},
{"DT_MIPS_PERF_SUFFIX", Const, 16},
{"DT_MIPS_PIXIE_INIT", Const, 16},
{"DT_MIPS_PLTGOT", Const, 16},
{"DT_MIPS_PROTECTED_GOTIDX", Const, 16},
{"DT_MIPS_RLD_MAP", Const, 16},
{"DT_MIPS_RLD_MAP_REL", Const, 16},
{"DT_MIPS_RLD_TEXT_RESOLVE_ADDR", Const, 16},
{"DT_MIPS_RLD_VERSION", Const, 16},
{"DT_MIPS_RWPLT", Const, 16},
{"DT_MIPS_SYMBOL_LIB", Const, 16},
{"DT_MIPS_SYMTABNO", Const, 16},
{"DT_MIPS_TIME_STAMP", Const, 16},
{"DT_MIPS_UNREFEXTNO", Const, 16},
{"DT_MOVEENT", Const, 16},
{"DT_MOVESZ", Const, 16},
{"DT_MOVETAB", Const, 16},
{"DT_NEEDED", Const, 0},
{"DT_NULL", Const, 0},
{"DT_PLTGOT", Const, 0},
{"DT_PLTPAD", Const, 16},
{"DT_PLTPADSZ", Const, 16},
{"DT_PLTREL", Const, 0},
{"DT_PLTRELSZ", Const, 0},
{"DT_POSFLAG_1", Const, 16},
{"DT_PPC64_GLINK", Const, 16},
{"DT_PPC64_OPD", Const, 16},
{"DT_PPC64_OPDSZ", Const, 16},
{"DT_PPC64_OPT", Const, 16},
{"DT_PPC_GOT", Const, 16},
{"DT_PPC_OPT", Const, 16},
{"DT_PREINIT_ARRAY", Const, 0},
{"DT_PREINIT_ARRAYSZ", Const, 0},
{"DT_REL", Const, 0},
{"DT_RELA", Const, 0},
{"DT_RELACOUNT", Const, 16},
{"DT_RELAENT", Const, 0},
{"DT_RELASZ", Const, 0},
{"DT_RELCOUNT", Const, 16},
{"DT_RELENT", Const, 0},
{"DT_RELSZ", Const, 0},
{"DT_RPATH", Const, 0},
{"DT_RUNPATH", Const, 0},
{"DT_SONAME", Const, 0},
{"DT_SPARC_REGISTER", Const, 16},
{"DT_STRSZ", Const, 0},
{"DT_STRTAB", Const, 0},
{"DT_SYMBOLIC", Const, 0},
{"DT_SYMENT", Const, 0},
{"DT_SYMINENT", Const, 16},
{"DT_SYMINFO", Const, 16},
{"DT_SYMINSZ", Const, 16},
{"DT_SYMTAB", Const, 0},
{"DT_SYMTAB_SHNDX", Const, 16},
{"DT_TEXTREL", Const, 0},
{"DT_TLSDESC_GOT", Const, 16},
{"DT_TLSDESC_PLT", Const, 16},
{"DT_USED", Const, 16},
{"DT_VALRNGHI", Const, 16},
{"DT_VALRNGLO", Const, 16},
{"DT_VERDEF", Const, 16},
{"DT_VERDEFNUM", Const, 16},
{"DT_VERNEED", Const, 0},
{"DT_VERNEEDNUM", Const, 0},
{"DT_VERSYM", Const, 0},
{"Data", Type, 0},
{"Dyn32", Type, 0},
{"Dyn32.Tag", Field, 0},
{"Dyn32.Val", Field, 0},
{"Dyn64", Type, 0},
{"Dyn64.Tag", Field, 0},
{"Dyn64.Val", Field, 0},
{"DynFlag", Type, 0},
{"DynFlag1", Type, 21},
{"DynTag", Type, 0},
{"EI_ABIVERSION", Const, 0},
{"EI_CLASS", Const, 0},
{"EI_DATA", Const, 0},
{"EI_NIDENT", Const, 0},
{"EI_OSABI", Const, 0},
{"EI_PAD", Const, 0},
{"EI_VERSION", Const, 0},
{"ELFCLASS32", Const, 0},
{"ELFCLASS64", Const, 0},
{"ELFCLASSNONE", Const, 0},
{"ELFDATA2LSB", Const, 0},
{"ELFDATA2MSB", Const, 0},
{"ELFDATANONE", Const, 0},
{"ELFMAG", Const, 0},
{"ELFOSABI_86OPEN", Const, 0},
{"ELFOSABI_AIX", Const, 0},
{"ELFOSABI_ARM", Const, 0},
{"ELFOSABI_AROS", Const, 11},
{"ELFOSABI_CLOUDABI", Const, 11},
{"ELFOSABI_FENIXOS", Const, 11},
{"ELFOSABI_FREEBSD", Const, 0},
{"ELFOSABI_HPUX", Const, 0},
{"ELFOSABI_HURD", Const, 0},
{"ELFOSABI_IRIX", Const, 0},
{"ELFOSABI_LINUX", Const, 0},
{"ELFOSABI_MODESTO", Const, 0},
{"ELFOSABI_NETBSD", Const, 0},
{"ELFOSABI_NONE", Const, 0},
{"ELFOSABI_NSK", Const, 0},
{"ELFOSABI_OPENBSD", Const, 0},
{"ELFOSABI_OPENVMS", Const, 0},
{"ELFOSABI_SOLARIS", Const, 0},
{"ELFOSABI_STANDALONE", Const, 0},
{"ELFOSABI_TRU64", Const, 0},
{"EM_386", Const, 0},
{"EM_486", Const, 0},
{"EM_56800EX", Const, 11},
{"EM_68HC05", Const, 11},
{"EM_68HC08", Const, 11},
{"EM_68HC11", Const, 11},
{"EM_68HC12", Const, 0},
{"EM_68HC16", Const, 11},
{"EM_68K", Const, 0},
{"EM_78KOR", Const, 11},
{"EM_8051", Const, 11},
{"EM_860", Const, 0},
{"EM_88K", Const, 0},
{"EM_960", Const, 0},
{"EM_AARCH64", Const, 4},
{"EM_ALPHA", Const, 0},
{"EM_ALPHA_STD", Const, 0},
{"EM_ALTERA_NIOS2", Const, 11},
{"EM_AMDGPU", Const, 11},
{"EM_ARC", Const, 0},
{"EM_ARCA", Const, 11},
{"EM_ARC_COMPACT", Const, 11},
{"EM_ARC_COMPACT2", Const, 11},
{"EM_ARM", Const, 0},
{"EM_AVR", Const, 11},
{"EM_AVR32", Const, 11},
{"EM_BA1", Const, 11},
{"EM_BA2", Const, 11},
{"EM_BLACKFIN", Const, 11},
{"EM_BPF", Const, 11},
{"EM_C166", Const, 11},
{"EM_CDP", Const, 11},
{"EM_CE", Const, 11},
{"EM_CLOUDSHIELD", Const, 11},
{"EM_COGE", Const, 11},
{"EM_COLDFIRE", Const, 0},
{"EM_COOL", Const, 11},
{"EM_COREA_1ST", Const, 11},
{"EM_COREA_2ND", Const, 11},
{"EM_CR", Const, 11},
{"EM_CR16", Const, 11},
{"EM_CRAYNV2", Const, 11},
{"EM_CRIS", Const, 11},
{"EM_CRX", Const, 11},
{"EM_CSR_KALIMBA", Const, 11},
{"EM_CUDA", Const, 11},
{"EM_CYPRESS_M8C", Const, 11},
{"EM_D10V", Const, 11},
{"EM_D30V", Const, 11},
{"EM_DSP24", Const, 11},
{"EM_DSPIC30F", Const, 11},
{"EM_DXP", Const, 11},
{"EM_ECOG1", Const, 11},
{"EM_ECOG16", Const, 11},
{"EM_ECOG1X", Const, 11},
{"EM_ECOG2", Const, 11},
{"EM_ETPU", Const, 11},
{"EM_EXCESS", Const, 11},
{"EM_F2MC16", Const, 11},
{"EM_FIREPATH", Const, 11},
{"EM_FR20", Const, 0},
{"EM_FR30", Const, 11},
{"EM_FT32", Const, 11},
{"EM_FX66", Const, 11},
{"EM_H8S", Const, 0},
{"EM_H8_300", Const, 0},
{"EM_H8_300H", Const, 0},
{"EM_H8_500", Const, 0},
{"EM_HUANY", Const, 11},
{"EM_IA_64", Const, 0},
{"EM_INTEL205", Const, 11},
{"EM_INTEL206", Const, 11},
{"EM_INTEL207", Const, 11},
{"EM_INTEL208", Const, 11},
{"EM_INTEL209", Const, 11},
{"EM_IP2K", Const, 11},
{"EM_JAVELIN", Const, 11},
{"EM_K10M", Const, 11},
{"EM_KM32", Const, 11},
{"EM_KMX16", Const, 11},
{"EM_KMX32", Const, 11},
{"EM_KMX8", Const, 11},
{"EM_KVARC", Const, 11},
{"EM_L10M", Const, 11},
{"EM_LANAI", Const, 11},
{"EM_LATTICEMICO32", Const, 11},
{"EM_LOONGARCH", Const, 19},
{"EM_M16C", Const, 11},
{"EM_M32", Const, 0},
{"EM_M32C", Const, 11},
{"EM_M32R", Const, 11},
{"EM_MANIK", Const, 11},
{"EM_MAX", Const, 11},
{"EM_MAXQ30", Const, 11},
{"EM_MCHP_PIC", Const, 11},
{"EM_MCST_ELBRUS", Const, 11},
{"EM_ME16", Const, 0},
{"EM_METAG", Const, 11},
{"EM_MICROBLAZE", Const, 11},
{"EM_MIPS", Const, 0},
{"EM_MIPS_RS3_LE", Const, 0},
{"EM_MIPS_RS4_BE", Const, 0},
{"EM_MIPS_X", Const, 0},
{"EM_MMA", Const, 0},
{"EM_MMDSP_PLUS", Const, 11},
{"EM_MMIX", Const, 11},
{"EM_MN10200", Const, 11},
{"EM_MN10300", Const, 11},
{"EM_MOXIE", Const, 11},
{"EM_MSP430", Const, 11},
{"EM_NCPU", Const, 0},
{"EM_NDR1", Const, 0},
{"EM_NDS32", Const, 11},
{"EM_NONE", Const, 0},
{"EM_NORC", Const, 11},
{"EM_NS32K", Const, 11},
{"EM_OPEN8", Const, 11},
{"EM_OPENRISC", Const, 11},
{"EM_PARISC", Const, 0},
{"EM_PCP", Const, 0},
{"EM_PDP10", Const, 11},
{"EM_PDP11", Const, 11},
{"EM_PDSP", Const, 11},
{"EM_PJ", Const, 11},
{"EM_PPC", Const, 0},
{"EM_PPC64", Const, 0},
{"EM_PRISM", Const, 11},
{"EM_QDSP6", Const, 11},
{"EM_R32C", Const, 11},
{"EM_RCE", Const, 0},
{"EM_RH32", Const, 0},
{"EM_RISCV", Const, 11},
{"EM_RL78", Const, 11},
{"EM_RS08", Const, 11},
{"EM_RX", Const, 11},
{"EM_S370", Const, 0},
{"EM_S390", Const, 0},
{"EM_SCORE7", Const, 11},
{"EM_SEP", Const, 11},
{"EM_SE_C17", Const, 11},
{"EM_SE_C33", Const, 11},
{"EM_SH", Const, 0},
{"EM_SHARC", Const, 11},
{"EM_SLE9X", Const, 11},
{"EM_SNP1K", Const, 11},
{"EM_SPARC", Const, 0},
{"EM_SPARC32PLUS", Const, 0},
{"EM_SPARCV9", Const, 0},
{"EM_ST100", Const, 0},
{"EM_ST19", Const, 11},
{"EM_ST200", Const, 11},
{"EM_ST7", Const, 11},
{"EM_ST9PLUS", Const, 11},
{"EM_STARCORE", Const, 0},
{"EM_STM8", Const, 11},
{"EM_STXP7X", Const, 11},
{"EM_SVX", Const, 11},
{"EM_TILE64", Const, 11},
{"EM_TILEGX", Const, 11},
{"EM_TILEPRO", Const, 11},
{"EM_TINYJ", Const, 0},
{"EM_TI_ARP32", Const, 11},
{"EM_TI_C2000", Const, 11},
{"EM_TI_C5500", Const, 11},
{"EM_TI_C6000", Const, 11},
{"EM_TI_PRU", Const, 11},
{"EM_TMM_GPP", Const, 11},
{"EM_TPC", Const, 11},
{"EM_TRICORE", Const, 0},
{"EM_TRIMEDIA", Const, 11},
{"EM_TSK3000", Const, 11},
{"EM_UNICORE", Const, 11},
{"EM_V800", Const, 0},
{"EM_V850", Const, 11},
{"EM_VAX", Const, 11},
{"EM_VIDEOCORE", Const, 11},
{"EM_VIDEOCORE3", Const, 11},
{"EM_VIDEOCORE5", Const, 11},
{"EM_VISIUM", Const, 11},
{"EM_VPP500", Const, 0},
{"EM_X86_64", Const, 0},
{"EM_XCORE", Const, 11},
{"EM_XGATE", Const, 11},
{"EM_XIMO16", Const, 11},
{"EM_XTENSA", Const, 11},
{"EM_Z80", Const, 11},
{"EM_ZSP", Const, 11},
{"ET_CORE", Const, 0},
{"ET_DYN", Const, 0},
{"ET_EXEC", Const, 0},
{"ET_HIOS", Const, 0},
{"ET_HIPROC", Const, 0},
{"ET_LOOS", Const, 0},
{"ET_LOPROC", Const, 0},
{"ET_NONE", Const, 0},
{"ET_REL", Const, 0},
{"EV_CURRENT", Const, 0},
{"EV_NONE", Const, 0},
{"ErrNoSymbols", Var, 4},
{"File", Type, 0},
{"File.FileHeader", Field, 0},
{"File.Progs", Field, 0},
{"File.Sections", Field, 0},
{"FileHeader", Type, 0},
{"FileHeader.ABIVersion", Field, 0},
{"FileHeader.ByteOrder", Field, 0},
{"FileHeader.Class", Field, 0},
{"FileHeader.Data", Field, 0},
{"FileHeader.Entry", Field, 1},
{"FileHeader.Machine", Field, 0},
{"FileHeader.OSABI", Field, 0},
{"FileHeader.Type", Field, 0},
{"FileHeader.Version", Field, 0},
{"FormatError", Type, 0},
{"Header32", Type, 0},
{"Header32.Ehsize", Field, 0},
{"Header32.Entry", Field, 0},
{"Header32.Flags", Field, 0},
{"Header32.Ident", Field, 0},
{"Header32.Machine", Field, 0},
{"Header32.Phentsize", Field, 0},
{"Header32.Phnum", Field, 0},
{"Header32.Phoff", Field, 0},
{"Header32.Shentsize", Field, 0},
{"Header32.Shnum", Field, 0},
{"Header32.Shoff", Field, 0},
{"Header32.Shstrndx", Field, 0},
{"Header32.Type", Field, 0},
{"Header32.Version", Field, 0},
{"Header64", Type, 0},
{"Header64.Ehsize", Field, 0},
{"Header64.Entry", Field, 0},
{"Header64.Flags", Field, 0},
{"Header64.Ident", Field, 0},
{"Header64.Machine", Field, 0},
{"Header64.Phentsize", Field, 0},
{"Header64.Phnum", Field, 0},
{"Header64.Phoff", Field, 0},
{"Header64.Shentsize", Field, 0},
{"Header64.Shnum", Field, 0},
{"Header64.Shoff", Field, 0},
{"Header64.Shstrndx", Field, 0},
{"Header64.Type", Field, 0},
{"Header64.Version", Field, 0},
{"ImportedSymbol", Type, 0},
{"ImportedSymbol.Library", Field, 0},
{"ImportedSymbol.Name", Field, 0},
{"ImportedSymbol.Version", Field, 0},
{"Machine", Type, 0},
{"NT_FPREGSET", Const, 0},
{"NT_PRPSINFO", Const, 0},
{"NT_PRSTATUS", Const, 0},
{"NType", Type, 0},
{"NewFile", Func, 0},
{"OSABI", Type, 0},
{"Open", Func, 0},
{"PF_MASKOS", Const, 0},
{"PF_MASKPROC", Const, 0},
{"PF_R", Const, 0},
{"PF_W", Const, 0},
{"PF_X", Const, 0},
{"PT_AARCH64_ARCHEXT", Const, 16},
{"PT_AARCH64_UNWIND", Const, 16},
{"PT_ARM_ARCHEXT", Const, 16},
{"PT_ARM_EXIDX", Const, 16},
{"PT_DYNAMIC", Const, 0},
{"PT_GNU_EH_FRAME", Const, 16},
{"PT_GNU_MBIND_HI", Const, 16},
{"PT_GNU_MBIND_LO", Const, 16},
{"PT_GNU_PROPERTY", Const, 16},
{"PT_GNU_RELRO", Const, 16},
{"PT_GNU_STACK", Const, 16},
{"PT_HIOS", Const, 0},
{"PT_HIPROC", Const, 0},
{"PT_INTERP", Const, 0},
{"PT_LOAD", Const, 0},
{"PT_LOOS", Const, 0},
{"PT_LOPROC", Const, 0},
{"PT_MIPS_ABIFLAGS", Const, 16},
{"PT_MIPS_OPTIONS", Const, 16},
{"PT_MIPS_REGINFO", Const, 16},
{"PT_MIPS_RTPROC", Const, 16},
{"PT_NOTE", Const, 0},
{"PT_NULL", Const, 0},
{"PT_OPENBSD_BOOTDATA", Const, 16},
{"PT_OPENBSD_NOBTCFI", Const, 23},
{"PT_OPENBSD_RANDOMIZE", Const, 16},
{"PT_OPENBSD_WXNEEDED", Const, 16},
{"PT_PAX_FLAGS", Const, 16},
{"PT_PHDR", Const, 0},
{"PT_S390_PGSTE", Const, 16},
{"PT_SHLIB", Const, 0},
{"PT_SUNWSTACK", Const, 16},
{"PT_SUNW_EH_FRAME", Const, 16},
{"PT_TLS", Const, 0},
{"Prog", Type, 0},
{"Prog.ProgHeader", Field, 0},
{"Prog.ReaderAt", Field, 0},
{"Prog32", Type, 0},
{"Prog32.Align", Field, 0},
{"Prog32.Filesz", Field, 0},
{"Prog32.Flags", Field, 0},
{"Prog32.Memsz", Field, 0},
{"Prog32.Off", Field, 0},
{"Prog32.Paddr", Field, 0},
{"Prog32.Type", Field, 0},
{"Prog32.Vaddr", Field, 0},
{"Prog64", Type, 0},
{"Prog64.Align", Field, 0},
{"Prog64.Filesz", Field, 0},
{"Prog64.Flags", Field, 0},
{"Prog64.Memsz", Field, 0},
{"Prog64.Off", Field, 0},
{"Prog64.Paddr", Field, 0},
{"Prog64.Type", Field, 0},
{"Prog64.Vaddr", Field, 0},
{"ProgFlag", Type, 0},
{"ProgHeader", Type, 0},
{"ProgHeader.Align", Field, 0},
{"ProgHeader.Filesz", Field, 0},
{"ProgHeader.Flags", Field, 0},
{"ProgHeader.Memsz", Field, 0},
{"ProgHeader.Off", Field, 0},
{"ProgHeader.Paddr", Field, 0},
{"ProgHeader.Type", Field, 0},
{"ProgHeader.Vaddr", Field, 0},
{"ProgType", Type, 0},
{"R_386", Type, 0},
{"R_386_16", Const, 10},
{"R_386_32", Const, 0},
{"R_386_32PLT", Const, 10},
{"R_386_8", Const, 10},
{"R_386_COPY", Const, 0},
{"R_386_GLOB_DAT", Const, 0},
{"R_386_GOT32", Const, 0},
{"R_386_GOT32X", Const, 10},
{"R_386_GOTOFF", Const, 0},
{"R_386_GOTPC", Const, 0},
{"R_386_IRELATIVE", Const, 10},
{"R_386_JMP_SLOT", Const, 0},
{"R_386_NONE", Const, 0},
{"R_386_PC16", Const, 10},
{"R_386_PC32", Const, 0},
{"R_386_PC8", Const, 10},
{"R_386_PLT32", Const, 0},
{"R_386_RELATIVE", Const, 0},
{"R_386_SIZE32", Const, 10},
{"R_386_TLS_DESC", Const, 10},
{"R_386_TLS_DESC_CALL", Const, 10},
{"R_386_TLS_DTPMOD32", Const, 0},
{"R_386_TLS_DTPOFF32", Const, 0},
{"R_386_TLS_GD", Const, 0},
{"R_386_TLS_GD_32", Const, 0},
{"R_386_TLS_GD_CALL", Const, 0},
{"R_386_TLS_GD_POP", Const, 0},
{"R_386_TLS_GD_PUSH", Const, 0},
{"R_386_TLS_GOTDESC", Const, 10},
{"R_386_TLS_GOTIE", Const, 0},
{"R_386_TLS_IE", Const, 0},
{"R_386_TLS_IE_32", Const, 0},
{"R_386_TLS_LDM", Const, 0},
{"R_386_TLS_LDM_32", Const, 0},
{"R_386_TLS_LDM_CALL", Const, 0},
{"R_386_TLS_LDM_POP", Const, 0},
{"R_386_TLS_LDM_PUSH", Const, 0},
{"R_386_TLS_LDO_32", Const, 0},
{"R_386_TLS_LE", Const, 0},
{"R_386_TLS_LE_32", Const, 0},
{"R_386_TLS_TPOFF", Const, 0},
{"R_386_TLS_TPOFF32", Const, 0},
{"R_390", Type, 7},
{"R_390_12", Const, 7},
{"R_390_16", Const, 7},
{"R_390_20", Const, 7},
{"R_390_32", Const, 7},
{"R_390_64", Const, 7},
{"R_390_8", Const, 7},
{"R_390_COPY", Const, 7},
{"R_390_GLOB_DAT", Const, 7},
{"R_390_GOT12", Const, 7},
{"R_390_GOT16", Const, 7},
{"R_390_GOT20", Const, 7},
{"R_390_GOT32", Const, 7},
{"R_390_GOT64", Const, 7},
{"R_390_GOTENT", Const, 7},
{"R_390_GOTOFF", Const, 7},
{"R_390_GOTOFF16", Const, 7},
{"R_390_GOTOFF64", Const, 7},
{"R_390_GOTPC", Const, 7},
{"R_390_GOTPCDBL", Const, 7},
{"R_390_GOTPLT12", Const, 7},
{"R_390_GOTPLT16", Const, 7},
{"R_390_GOTPLT20", Const, 7},
{"R_390_GOTPLT32", Const, 7},
{"R_390_GOTPLT64", Const, 7},
{"R_390_GOTPLTENT", Const, 7},
{"R_390_GOTPLTOFF16", Const, 7},
{"R_390_GOTPLTOFF32", Const, 7},
{"R_390_GOTPLTOFF64", Const, 7},
{"R_390_JMP_SLOT", Const, 7},
{"R_390_NONE", Const, 7},
{"R_390_PC16", Const, 7},
{"R_390_PC16DBL", Const, 7},
{"R_390_PC32", Const, 7},
{"R_390_PC32DBL", Const, 7},
{"R_390_PC64", Const, 7},
{"R_390_PLT16DBL", Const, 7},
{"R_390_PLT32", Const, 7},
{"R_390_PLT32DBL", Const, 7},
{"R_390_PLT64", Const, 7},
{"R_390_RELATIVE", Const, 7},
{"R_390_TLS_DTPMOD", Const, 7},
{"R_390_TLS_DTPOFF", Const, 7},
{"R_390_TLS_GD32", Const, 7},
{"R_390_TLS_GD64", Const, 7},
{"R_390_TLS_GDCALL", Const, 7},
{"R_390_TLS_GOTIE12", Const, 7},
{"R_390_TLS_GOTIE20", Const, 7},
{"R_390_TLS_GOTIE32", Const, 7},
{"R_390_TLS_GOTIE64", Const, 7},
{"R_390_TLS_IE32", Const, 7},
{"R_390_TLS_IE64", Const, 7},
{"R_390_TLS_IEENT", Const, 7},
{"R_390_TLS_LDCALL", Const, 7},
{"R_390_TLS_LDM32", Const, 7},
{"R_390_TLS_LDM64", Const, 7},
{"R_390_TLS_LDO32", Const, 7},
{"R_390_TLS_LDO64", Const, 7},
{"R_390_TLS_LE32", Const, 7},
{"R_390_TLS_LE64", Const, 7},
{"R_390_TLS_LOAD", Const, 7},
{"R_390_TLS_TPOFF", Const, 7},
{"R_AARCH64", Type, 4},
{"R_AARCH64_ABS16", Const, 4},
{"R_AARCH64_ABS32", Const, 4},
{"R_AARCH64_ABS64", Const, 4},
{"R_AARCH64_ADD_ABS_LO12_NC", Const, 4},
{"R_AARCH64_ADR_GOT_PAGE", Const, 4},
{"R_AARCH64_ADR_PREL_LO21", Const, 4},
{"R_AARCH64_ADR_PREL_PG_HI21", Const, 4},
{"R_AARCH64_ADR_PREL_PG_HI21_NC", Const, 4},
{"R_AARCH64_CALL26", Const, 4},
{"R_AARCH64_CONDBR19", Const, 4},
{"R_AARCH64_COPY", Const, 4},
{"R_AARCH64_GLOB_DAT", Const, 4},
{"R_AARCH64_GOT_LD_PREL19", Const, 4},
{"R_AARCH64_IRELATIVE", Const, 4},
{"R_AARCH64_JUMP26", Const, 4},
{"R_AARCH64_JUMP_SLOT", Const, 4},
{"R_AARCH64_LD64_GOTOFF_LO15", Const, 10},
{"R_AARCH64_LD64_GOTPAGE_LO15", Const, 10},
{"R_AARCH64_LD64_GOT_LO12_NC", Const, 4},
{"R_AARCH64_LDST128_ABS_LO12_NC", Const, 4},
{"R_AARCH64_LDST16_ABS_LO12_NC", Const, 4},
{"R_AARCH64_LDST32_ABS_LO12_NC", Const, 4},
{"R_AARCH64_LDST64_ABS_LO12_NC", Const, 4},
{"R_AARCH64_LDST8_ABS_LO12_NC", Const, 4},
{"R_AARCH64_LD_PREL_LO19", Const, 4},
{"R_AARCH64_MOVW_SABS_G0", Const, 4},
{"R_AARCH64_MOVW_SABS_G1", Const, 4},
{"R_AARCH64_MOVW_SABS_G2", Const, 4},
{"R_AARCH64_MOVW_UABS_G0", Const, 4},
{"R_AARCH64_MOVW_UABS_G0_NC", Const, 4},
{"R_AARCH64_MOVW_UABS_G1", Const, 4},
{"R_AARCH64_MOVW_UABS_G1_NC", Const, 4},
{"R_AARCH64_MOVW_UABS_G2", Const, 4},
{"R_AARCH64_MOVW_UABS_G2_NC", Const, 4},
{"R_AARCH64_MOVW_UABS_G3", Const, 4},
{"R_AARCH64_NONE", Const, 4},
{"R_AARCH64_NULL", Const, 4},
{"R_AARCH64_P32_ABS16", Const, 4},
{"R_AARCH64_P32_ABS32", Const, 4},
{"R_AARCH64_P32_ADD_ABS_LO12_NC", Const, 4},
{"R_AARCH64_P32_ADR_GOT_PAGE", Const, 4},
{"R_AARCH64_P32_ADR_PREL_LO21", Const, 4},
{"R_AARCH64_P32_ADR_PREL_PG_HI21", Const, 4},
{"R_AARCH64_P32_CALL26", Const, 4},
{"R_AARCH64_P32_CONDBR19", Const, 4},
{"R_AARCH64_P32_COPY", Const, 4},
{"R_AARCH64_P32_GLOB_DAT", Const, 4},
{"R_AARCH64_P32_GOT_LD_PREL19", Const, 4},
{"R_AARCH64_P32_IRELATIVE", Const, 4},
{"R_AARCH64_P32_JUMP26", Const, 4},
{"R_AARCH64_P32_JUMP_SLOT", Const, 4},
{"R_AARCH64_P32_LD32_GOT_LO12_NC", Const, 4},
{"R_AARCH64_P32_LDST128_ABS_LO12_NC", Const, 4},
{"R_AARCH64_P32_LDST16_ABS_LO12_NC", Const, 4},
{"R_AARCH64_P32_LDST32_ABS_LO12_NC", Const, 4},
{"R_AARCH64_P32_LDST64_ABS_LO12_NC", Const, 4},
{"R_AARCH64_P32_LDST8_ABS_LO12_NC", Const, 4},
{"R_AARCH64_P32_LD_PREL_LO19", Const, 4},
{"R_AARCH64_P32_MOVW_SABS_G0", Const, 4},
{"R_AARCH64_P32_MOVW_UABS_G0", Const, 4},
{"R_AARCH64_P32_MOVW_UABS_G0_NC", Const, 4},
{"R_AARCH64_P32_MOVW_UABS_G1", Const, 4},
{"R_AARCH64_P32_PREL16", Const, 4},
{"R_AARCH64_P32_PREL32", Const, 4},
{"R_AARCH64_P32_RELATIVE", Const, 4},
{"R_AARCH64_P32_TLSDESC", Const, 4},
{"R_AARCH64_P32_TLSDESC_ADD_LO12_NC", Const, 4},
{"R_AARCH64_P32_TLSDESC_ADR_PAGE21", Const, 4},
{"R_AARCH64_P32_TLSDESC_ADR_PREL21", Const, 4},
{"R_AARCH64_P32_TLSDESC_CALL", Const, 4},
{"R_AARCH64_P32_TLSDESC_LD32_LO12_NC", Const, 4},
{"R_AARCH64_P32_TLSDESC_LD_PREL19", Const, 4},
{"R_AARCH64_P32_TLSGD_ADD_LO12_NC", Const, 4},
{"R_AARCH64_P32_TLSGD_ADR_PAGE21", Const, 4},
{"R_AARCH64_P32_TLSIE_ADR_GOTTPREL_PAGE21", Const, 4},
{"R_AARCH64_P32_TLSIE_LD32_GOTTPREL_LO12_NC", Const, 4},
{"R_AARCH64_P32_TLSIE_LD_GOTTPREL_PREL19", Const, 4},
{"R_AARCH64_P32_TLSLE_ADD_TPREL_HI12", Const, 4},
{"R_AARCH64_P32_TLSLE_ADD_TPREL_LO12", Const, 4},
{"R_AARCH64_P32_TLSLE_ADD_TPREL_LO12_NC", Const, 4},
{"R_AARCH64_P32_TLSLE_MOVW_TPREL_G0", Const, 4},
{"R_AARCH64_P32_TLSLE_MOVW_TPREL_G0_NC", Const, 4},
{"R_AARCH64_P32_TLSLE_MOVW_TPREL_G1", Const, 4},
{"R_AARCH64_P32_TLS_DTPMOD", Const, 4},
{"R_AARCH64_P32_TLS_DTPREL", Const, 4},
{"R_AARCH64_P32_TLS_TPREL", Const, 4},
{"R_AARCH64_P32_TSTBR14", Const, 4},
{"R_AARCH64_PREL16", Const, 4},
{"R_AARCH64_PREL32", Const, 4},
{"R_AARCH64_PREL64", Const, 4},
{"R_AARCH64_RELATIVE", Const, 4},
{"R_AARCH64_TLSDESC", Const, 4},
{"R_AARCH64_TLSDESC_ADD", Const, 4},
{"R_AARCH64_TLSDESC_ADD_LO12_NC", Const, 4},
{"R_AARCH64_TLSDESC_ADR_PAGE21", Const, 4},
{"R_AARCH64_TLSDESC_ADR_PREL21", Const, 4},
{"R_AARCH64_TLSDESC_CALL", Const, 4},
{"R_AARCH64_TLSDESC_LD64_LO12_NC", Const, 4},
{"R_AARCH64_TLSDESC_LDR", Const, 4},
{"R_AARCH64_TLSDESC_LD_PREL19", Const, 4},
{"R_AARCH64_TLSDESC_OFF_G0_NC", Const, 4},
{"R_AARCH64_TLSDESC_OFF_G1", Const, 4},
{"R_AARCH64_TLSGD_ADD_LO12_NC", Const, 4},
{"R_AARCH64_TLSGD_ADR_PAGE21", Const, 4},
{"R_AARCH64_TLSGD_ADR_PREL21", Const, 10},
{"R_AARCH64_TLSGD_MOVW_G0_NC", Const, 10},
{"R_AARCH64_TLSGD_MOVW_G1", Const, 10},
{"R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21", Const, 4},
{"R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC", Const, 4},
{"R_AARCH64_TLSIE_LD_GOTTPREL_PREL19", Const, 4},
{"R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC", Const, 4},
{"R_AARCH64_TLSIE_MOVW_GOTTPREL_G1", Const, 4},
{"R_AARCH64_TLSLD_ADR_PAGE21", Const, 10},
{"R_AARCH64_TLSLD_ADR_PREL21", Const, 10},
{"R_AARCH64_TLSLD_LDST128_DTPREL_LO12", Const, 10},
{"R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC", Const, 10},
{"R_AARCH64_TLSLE_ADD_TPREL_HI12", Const, 4},
{"R_AARCH64_TLSLE_ADD_TPREL_LO12", Const, 4},
{"R_AARCH64_TLSLE_ADD_TPREL_LO12_NC", Const, 4},
{"R_AARCH64_TLSLE_LDST128_TPREL_LO12", Const, 10},
{"R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC", Const, 10},
{"R_AARCH64_TLSLE_MOVW_TPREL_G0", Const, 4},
{"R_AARCH64_TLSLE_MOVW_TPREL_G0_NC", Const, 4},
{"R_AARCH64_TLSLE_MOVW_TPREL_G1", Const, 4},
{"R_AARCH64_TLSLE_MOVW_TPREL_G1_NC", Const, 4},
{"R_AARCH64_TLSLE_MOVW_TPREL_G2", Const, 4},
{"R_AARCH64_TLS_DTPMOD64", Const, 4},
{"R_AARCH64_TLS_DTPREL64", Const, 4},
{"R_AARCH64_TLS_TPREL64", Const, 4},
{"R_AARCH64_TSTBR14", Const, 4},
{"R_ALPHA", Type, 0},
{"R_ALPHA_BRADDR", Const, 0},
{"R_ALPHA_COPY", Const, 0},
{"R_ALPHA_GLOB_DAT", Const, 0},
{"R_ALPHA_GPDISP", Const, 0},
{"R_ALPHA_GPREL32", Const, 0},
{"R_ALPHA_GPRELHIGH", Const, 0},
{"R_ALPHA_GPRELLOW", Const, 0},
{"R_ALPHA_GPVALUE", Const, 0},
{"R_ALPHA_HINT", Const, 0},
{"R_ALPHA_IMMED_BR_HI32", Const, 0},
{"R_ALPHA_IMMED_GP_16", Const, 0},
{"R_ALPHA_IMMED_GP_HI32", Const, 0},
{"R_ALPHA_IMMED_LO32", Const, 0},
{"R_ALPHA_IMMED_SCN_HI32", Const, 0},
{"R_ALPHA_JMP_SLOT", Const, 0},
{"R_ALPHA_LITERAL", Const, 0},
{"R_ALPHA_LITUSE", Const, 0},
{"R_ALPHA_NONE", Const, 0},
{"R_ALPHA_OP_PRSHIFT", Const, 0},
{"R_ALPHA_OP_PSUB", Const, 0},
{"R_ALPHA_OP_PUSH", Const, 0},
{"R_ALPHA_OP_STORE", Const, 0},
{"R_ALPHA_REFLONG", Const, 0},
{"R_ALPHA_REFQUAD", Const, 0},
{"R_ALPHA_RELATIVE", Const, 0},
{"R_ALPHA_SREL16", Const, 0},
{"R_ALPHA_SREL32", Const, 0},
{"R_ALPHA_SREL64", Const, 0},
{"R_ARM", Type, 0},
{"R_ARM_ABS12", Const, 0},
{"R_ARM_ABS16", Const, 0},
{"R_ARM_ABS32", Const, 0},
{"R_ARM_ABS32_NOI", Const, 10},
{"R_ARM_ABS8", Const, 0},
{"R_ARM_ALU_PCREL_15_8", Const, 10},
{"R_ARM_ALU_PCREL_23_15", Const, 10},
{"R_ARM_ALU_PCREL_7_0", Const, 10},
{"R_ARM_ALU_PC_G0", Const, 10},
{"R_ARM_ALU_PC_G0_NC", Const, 10},
{"R_ARM_ALU_PC_G1", Const, 10},
{"R_ARM_ALU_PC_G1_NC", Const, 10},
{"R_ARM_ALU_PC_G2", Const, 10},
{"R_ARM_ALU_SBREL_19_12_NC", Const, 10},
{"R_ARM_ALU_SBREL_27_20_CK", Const, 10},
{"R_ARM_ALU_SB_G0", Const, 10},
{"R_ARM_ALU_SB_G0_NC", Const, 10},
{"R_ARM_ALU_SB_G1", Const, 10},
{"R_ARM_ALU_SB_G1_NC", Const, 10},
{"R_ARM_ALU_SB_G2", Const, 10},
{"R_ARM_AMP_VCALL9", Const, 0},
{"R_ARM_BASE_ABS", Const, 10},
{"R_ARM_CALL", Const, 10},
{"R_ARM_COPY", Const, 0},
{"R_ARM_GLOB_DAT", Const, 0},
{"R_ARM_GNU_VTENTRY", Const, 0},
{"R_ARM_GNU_VTINHERIT", Const, 0},
{"R_ARM_GOT32", Const, 0},
{"R_ARM_GOTOFF", Const, 0},
{"R_ARM_GOTOFF12", Const, 10},
{"R_ARM_GOTPC", Const, 0},
{"R_ARM_GOTRELAX", Const, 10},
{"R_ARM_GOT_ABS", Const, 10},
{"R_ARM_GOT_BREL12", Const, 10},
{"R_ARM_GOT_PREL", Const, 10},
{"R_ARM_IRELATIVE", Const, 10},
{"R_ARM_JUMP24", Const, 10},
{"R_ARM_JUMP_SLOT", Const, 0},
{"R_ARM_LDC_PC_G0", Const, 10},
{"R_ARM_LDC_PC_G1", Const, 10},
{"R_ARM_LDC_PC_G2", Const, 10},
{"R_ARM_LDC_SB_G0", Const, 10},
{"R_ARM_LDC_SB_G1", Const, 10},
{"R_ARM_LDC_SB_G2", Const, 10},
{"R_ARM_LDRS_PC_G0", Const, 10},
{"R_ARM_LDRS_PC_G1", Const, 10},
{"R_ARM_LDRS_PC_G2", Const, 10},
{"R_ARM_LDRS_SB_G0", Const, 10},
{"R_ARM_LDRS_SB_G1", Const, 10},
{"R_ARM_LDRS_SB_G2", Const, 10},
{"R_ARM_LDR_PC_G1", Const, 10},
{"R_ARM_LDR_PC_G2", Const, 10},
{"R_ARM_LDR_SBREL_11_10_NC", Const, 10},
{"R_ARM_LDR_SB_G0", Const, 10},
{"R_ARM_LDR_SB_G1", Const, 10},
{"R_ARM_LDR_SB_G2", Const, 10},
{"R_ARM_ME_TOO", Const, 10},
{"R_ARM_MOVT_ABS", Const, 10},
{"R_ARM_MOVT_BREL", Const, 10},
{"R_ARM_MOVT_PREL", Const, 10},
{"R_ARM_MOVW_ABS_NC", Const, 10},
{"R_ARM_MOVW_BREL", Const, 10},
{"R_ARM_MOVW_BREL_NC", Const, 10},
{"R_ARM_MOVW_PREL_NC", Const, 10},
{"R_ARM_NONE", Const, 0},
{"R_ARM_PC13", Const, 0},
{"R_ARM_PC24", Const, 0},
{"R_ARM_PLT32", Const, 0},
{"R_ARM_PLT32_ABS", Const, 10},
{"R_ARM_PREL31", Const, 10},
{"R_ARM_PRIVATE_0", Const, 10},
{"R_ARM_PRIVATE_1", Const, 10},
{"R_ARM_PRIVATE_10", Const, 10},
{"R_ARM_PRIVATE_11", Const, 10},
{"R_ARM_PRIVATE_12", Const, 10},
{"R_ARM_PRIVATE_13", Const, 10},
{"R_ARM_PRIVATE_14", Const, 10},
{"R_ARM_PRIVATE_15", Const, 10},
{"R_ARM_PRIVATE_2", Const, 10},
{"R_ARM_PRIVATE_3", Const, 10},
{"R_ARM_PRIVATE_4", Const, 10},
{"R_ARM_PRIVATE_5", Const, 10},
{"R_ARM_PRIVATE_6", Const, 10},
{"R_ARM_PRIVATE_7", Const, 10},
{"R_ARM_PRIVATE_8", Const, 10},
{"R_ARM_PRIVATE_9", Const, 10},
{"R_ARM_RABS32", Const, 0},
{"R_ARM_RBASE", Const, 0},
{"R_ARM_REL32", Const, 0},
{"R_ARM_REL32_NOI", Const, 10},
{"R_ARM_RELATIVE", Const, 0},
{"R_ARM_RPC24", Const, 0},
{"R_ARM_RREL32", Const, 0},
{"R_ARM_RSBREL32", Const, 0},
{"R_ARM_RXPC25", Const, 10},
{"R_ARM_SBREL31", Const, 10},
{"R_ARM_SBREL32", Const, 0},
{"R_ARM_SWI24", Const, 0},
{"R_ARM_TARGET1", Const, 10},
{"R_ARM_TARGET2", Const, 10},
{"R_ARM_THM_ABS5", Const, 0},
{"R_ARM_THM_ALU_ABS_G0_NC", Const, 10},
{"R_ARM_THM_ALU_ABS_G1_NC", Const, 10},
{"R_ARM_THM_ALU_ABS_G2_NC", Const, 10},
{"R_ARM_THM_ALU_ABS_G3", Const, 10},
{"R_ARM_THM_ALU_PREL_11_0", Const, 10},
{"R_ARM_THM_GOT_BREL12", Const, 10},
{"R_ARM_THM_JUMP11", Const, 10},
{"R_ARM_THM_JUMP19", Const, 10},
{"R_ARM_THM_JUMP24", Const, 10},
{"R_ARM_THM_JUMP6", Const, 10},
{"R_ARM_THM_JUMP8", Const, 10},
{"R_ARM_THM_MOVT_ABS", Const, 10},
{"R_ARM_THM_MOVT_BREL", Const, 10},
{"R_ARM_THM_MOVT_PREL", Const, 10},
{"R_ARM_THM_MOVW_ABS_NC", Const, 10},
{"R_ARM_THM_MOVW_BREL", Const, 10},
{"R_ARM_THM_MOVW_BREL_NC", Const, 10},
{"R_ARM_THM_MOVW_PREL_NC", Const, 10},
{"R_ARM_THM_PC12", Const, 10},
{"R_ARM_THM_PC22", Const, 0},
{"R_ARM_THM_PC8", Const, 0},
{"R_ARM_THM_RPC22", Const, 0},
{"R_ARM_THM_SWI8", Const, 0},
{"R_ARM_THM_TLS_CALL", Const, 10},
{"R_ARM_THM_TLS_DESCSEQ16", Const, 10},
{"R_ARM_THM_TLS_DESCSEQ32", Const, 10},
{"R_ARM_THM_XPC22", Const, 0},
{"R_ARM_TLS_CALL", Const, 10},
{"R_ARM_TLS_DESCSEQ", Const, 10},
{"R_ARM_TLS_DTPMOD32", Const, 10},
{"R_ARM_TLS_DTPOFF32", Const, 10},
{"R_ARM_TLS_GD32", Const, 10},
{"R_ARM_TLS_GOTDESC", Const, 10},
{"R_ARM_TLS_IE12GP", Const, 10},
{"R_ARM_TLS_IE32", Const, 10},
{"R_ARM_TLS_LDM32", Const, 10},
{"R_ARM_TLS_LDO12", Const, 10},
{"R_ARM_TLS_LDO32", Const, 10},
{"R_ARM_TLS_LE12", Const, 10},
{"R_ARM_TLS_LE32", Const, 10},
{"R_ARM_TLS_TPOFF32", Const, 10},
{"R_ARM_V4BX", Const, 10},
{"R_ARM_XPC25", Const, 0},
{"R_INFO", Func, 0},
{"R_INFO32", Func, 0},
{"R_LARCH", Type, 19},
{"R_LARCH_32", Const, 19},
{"R_LARCH_32_PCREL", Const, 20},
{"R_LARCH_64", Const, 19},
{"R_LARCH_64_PCREL", Const, 22},
{"R_LARCH_ABS64_HI12", Const, 20},
{"R_LARCH_ABS64_LO20", Const, 20},
{"R_LARCH_ABS_HI20", Const, 20},
{"R_LARCH_ABS_LO12", Const, 20},
{"R_LARCH_ADD16", Const, 19},
{"R_LARCH_ADD24", Const, 19},
{"R_LARCH_ADD32", Const, 19},
{"R_LARCH_ADD6", Const, 22},
{"R_LARCH_ADD64", Const, 19},
{"R_LARCH_ADD8", Const, 19},
{"R_LARCH_ADD_ULEB128", Const, 22},
{"R_LARCH_ALIGN", Const, 22},
{"R_LARCH_B16", Const, 20},
{"R_LARCH_B21", Const, 20},
{"R_LARCH_B26", Const, 20},
{"R_LARCH_CFA", Const, 22},
{"R_LARCH_COPY", Const, 19},
{"R_LARCH_DELETE", Const, 22},
{"R_LARCH_GNU_VTENTRY", Const, 20},
{"R_LARCH_GNU_VTINHERIT", Const, 20},
{"R_LARCH_GOT64_HI12", Const, 20},
{"R_LARCH_GOT64_LO20", Const, 20},
{"R_LARCH_GOT64_PC_HI12", Const, 20},
{"R_LARCH_GOT64_PC_LO20", Const, 20},
{"R_LARCH_GOT_HI20", Const, 20},
{"R_LARCH_GOT_LO12", Const, 20},
{"R_LARCH_GOT_PC_HI20", Const, 20},
{"R_LARCH_GOT_PC_LO12", Const, 20},
{"R_LARCH_IRELATIVE", Const, 19},
{"R_LARCH_JUMP_SLOT", Const, 19},
{"R_LARCH_MARK_LA", Const, 19},
{"R_LARCH_MARK_PCREL", Const, 19},
{"R_LARCH_NONE", Const, 19},
{"R_LARCH_PCALA64_HI12", Const, 20},
{"R_LARCH_PCALA64_LO20", Const, 20},
{"R_LARCH_PCALA_HI20", Const, 20},
{"R_LARCH_PCALA_LO12", Const, 20},
{"R_LARCH_PCREL20_S2", Const, 22},
{"R_LARCH_RELATIVE", Const, 19},
{"R_LARCH_RELAX", Const, 20},
{"R_LARCH_SOP_ADD", Const, 19},
{"R_LARCH_SOP_AND", Const, 19},
{"R_LARCH_SOP_ASSERT", Const, 19},
{"R_LARCH_SOP_IF_ELSE", Const, 19},
{"R_LARCH_SOP_NOT", Const, 19},
{"R_LARCH_SOP_POP_32_S_0_10_10_16_S2", Const, 19},
{"R_LARCH_SOP_POP_32_S_0_5_10_16_S2", Const, 19},
{"R_LARCH_SOP_POP_32_S_10_12", Const, 19},
{"R_LARCH_SOP_POP_32_S_10_16", Const, 19},
{"R_LARCH_SOP_POP_32_S_10_16_S2", Const, 19},
{"R_LARCH_SOP_POP_32_S_10_5", Const, 19},
{"R_LARCH_SOP_POP_32_S_5_20", Const, 19},
{"R_LARCH_SOP_POP_32_U", Const, 19},
{"R_LARCH_SOP_POP_32_U_10_12", Const, 19},
{"R_LARCH_SOP_PUSH_ABSOLUTE", Const, 19},
{"R_LARCH_SOP_PUSH_DUP", Const, 19},
{"R_LARCH_SOP_PUSH_GPREL", Const, 19},
{"R_LARCH_SOP_PUSH_PCREL", Const, 19},
{"R_LARCH_SOP_PUSH_PLT_PCREL", Const, 19},
{"R_LARCH_SOP_PUSH_TLS_GD", Const, 19},
{"R_LARCH_SOP_PUSH_TLS_GOT", Const, 19},
{"R_LARCH_SOP_PUSH_TLS_TPREL", Const, 19},
{"R_LARCH_SOP_SL", Const, 19},
{"R_LARCH_SOP_SR", Const, 19},
{"R_LARCH_SOP_SUB", Const, 19},
{"R_LARCH_SUB16", Const, 19},
{"R_LARCH_SUB24", Const, 19},
{"R_LARCH_SUB32", Const, 19},
{"R_LARCH_SUB6", Const, 22},
{"R_LARCH_SUB64", Const, 19},
{"R_LARCH_SUB8", Const, 19},
{"R_LARCH_SUB_ULEB128", Const, 22},
{"R_LARCH_TLS_DTPMOD32", Const, 19},
{"R_LARCH_TLS_DTPMOD64", Const, 19},
{"R_LARCH_TLS_DTPREL32", Const, 19},
{"R_LARCH_TLS_DTPREL64", Const, 19},
{"R_LARCH_TLS_GD_HI20", Const, 20},
{"R_LARCH_TLS_GD_PC_HI20", Const, 20},
{"R_LARCH_TLS_IE64_HI12", Const, 20},
{"R_LARCH_TLS_IE64_LO20", Const, 20},
{"R_LARCH_TLS_IE64_PC_HI12", Const, 20},
{"R_LARCH_TLS_IE64_PC_LO20", Const, 20},
{"R_LARCH_TLS_IE_HI20", Const, 20},
{"R_LARCH_TLS_IE_LO12", Const, 20},
{"R_LARCH_TLS_IE_PC_HI20", Const, 20},
{"R_LARCH_TLS_IE_PC_LO12", Const, 20},
{"R_LARCH_TLS_LD_HI20", Const, 20},
{"R_LARCH_TLS_LD_PC_HI20", Const, 20},
{"R_LARCH_TLS_LE64_HI12", Const, 20},
{"R_LARCH_TLS_LE64_LO20", Const, 20},
{"R_LARCH_TLS_LE_HI20", Const, 20},
{"R_LARCH_TLS_LE_LO12", Const, 20},
{"R_LARCH_TLS_TPREL32", Const, 19},
{"R_LARCH_TLS_TPREL64", Const, 19},
{"R_MIPS", Type, 6},
{"R_MIPS_16", Const, 6},
{"R_MIPS_26", Const, 6},
{"R_MIPS_32", Const, 6},
{"R_MIPS_64", Const, 6},
{"R_MIPS_ADD_IMMEDIATE", Const, 6},
{"R_MIPS_CALL16", Const, 6},
{"R_MIPS_CALL_HI16", Const, 6},
{"R_MIPS_CALL_LO16", Const, 6},
{"R_MIPS_DELETE", Const, 6},
{"R_MIPS_GOT16", Const, 6},
{"R_MIPS_GOT_DISP", Const, 6},
{"R_MIPS_GOT_HI16", Const, 6},
{"R_MIPS_GOT_LO16", Const, 6},
{"R_MIPS_GOT_OFST", Const, 6},
{"R_MIPS_GOT_PAGE", Const, 6},
{"R_MIPS_GPREL16", Const, 6},
{"R_MIPS_GPREL32", Const, 6},
{"R_MIPS_HI16", Const, 6},
{"R_MIPS_HIGHER", Const, 6},
{"R_MIPS_HIGHEST", Const, 6},
{"R_MIPS_INSERT_A", Const, 6},
{"R_MIPS_INSERT_B", Const, 6},
{"R_MIPS_JALR", Const, 6},
{"R_MIPS_LITERAL", Const, 6},
{"R_MIPS_LO16", Const, 6},
{"R_MIPS_NONE", Const, 6},
{"R_MIPS_PC16", Const, 6},
{"R_MIPS_PC32", Const, 22},
{"R_MIPS_PJUMP", Const, 6},
{"R_MIPS_REL16", Const, 6},
{"R_MIPS_REL32", Const, 6},
{"R_MIPS_RELGOT", Const, 6},
{"R_MIPS_SCN_DISP", Const, 6},
{"R_MIPS_SHIFT5", Const, 6},
{"R_MIPS_SHIFT6", Const, 6},
{"R_MIPS_SUB", Const, 6},
{"R_MIPS_TLS_DTPMOD32", Const, 6},
{"R_MIPS_TLS_DTPMOD64", Const, 6},
{"R_MIPS_TLS_DTPREL32", Const, 6},
{"R_MIPS_TLS_DTPREL64", Const, 6},
{"R_MIPS_TLS_DTPREL_HI16", Const, 6},
{"R_MIPS_TLS_DTPREL_LO16", Const, 6},
{"R_MIPS_TLS_GD", Const, 6},
{"R_MIPS_TLS_GOTTPREL", Const, 6},
{"R_MIPS_TLS_LDM", Const, 6},
{"R_MIPS_TLS_TPREL32", Const, 6},
{"R_MIPS_TLS_TPREL64", Const, 6},
{"R_MIPS_TLS_TPREL_HI16", Const, 6},
{"R_MIPS_TLS_TPREL_LO16", Const, 6},
{"R_PPC", Type, 0},
{"R_PPC64", Type, 5},
{"R_PPC64_ADDR14", Const, 5},
{"R_PPC64_ADDR14_BRNTAKEN", Const, 5},
{"R_PPC64_ADDR14_BRTAKEN", Const, 5},
{"R_PPC64_ADDR16", Const, 5},
{"R_PPC64_ADDR16_DS", Const, 5},
{"R_PPC64_ADDR16_HA", Const, 5},
{"R_PPC64_ADDR16_HI", Const, 5},
{"R_PPC64_ADDR16_HIGH", Const, 10},
{"R_PPC64_ADDR16_HIGHA", Const, 10},
{"R_PPC64_ADDR16_HIGHER", Const, 5},
{"R_PPC64_ADDR16_HIGHER34", Const, 20},
{"R_PPC64_ADDR16_HIGHERA", Const, 5},
{"R_PPC64_ADDR16_HIGHERA34", Const, 20},
{"R_PPC64_ADDR16_HIGHEST", Const, 5},
{"R_PPC64_ADDR16_HIGHEST34", Const, 20},
{"R_PPC64_ADDR16_HIGHESTA", Const, 5},
{"R_PPC64_ADDR16_HIGHESTA34", Const, 20},
{"R_PPC64_ADDR16_LO", Const, 5},
{"R_PPC64_ADDR16_LO_DS", Const, 5},
{"R_PPC64_ADDR24", Const, 5},
{"R_PPC64_ADDR32", Const, 5},
{"R_PPC64_ADDR64", Const, 5},
{"R_PPC64_ADDR64_LOCAL", Const, 10},
{"R_PPC64_COPY", Const, 20},
{"R_PPC64_D28", Const, 20},
{"R_PPC64_D34", Const, 20},
{"R_PPC64_D34_HA30", Const, 20},
{"R_PPC64_D34_HI30", Const, 20},
{"R_PPC64_D34_LO", Const, 20},
{"R_PPC64_DTPMOD64", Const, 5},
{"R_PPC64_DTPREL16", Const, 5},
{"R_PPC64_DTPREL16_DS", Const, 5},
{"R_PPC64_DTPREL16_HA", Const, 5},
{"R_PPC64_DTPREL16_HI", Const, 5},
{"R_PPC64_DTPREL16_HIGH", Const, 10},
{"R_PPC64_DTPREL16_HIGHA", Const, 10},
{"R_PPC64_DTPREL16_HIGHER", Const, 5},
{"R_PPC64_DTPREL16_HIGHERA", Const, 5},
{"R_PPC64_DTPREL16_HIGHEST", Const, 5},
{"R_PPC64_DTPREL16_HIGHESTA", Const, 5},
{"R_PPC64_DTPREL16_LO", Const, 5},
{"R_PPC64_DTPREL16_LO_DS", Const, 5},
{"R_PPC64_DTPREL34", Const, 20},
{"R_PPC64_DTPREL64", Const, 5},
{"R_PPC64_ENTRY", Const, 10},
{"R_PPC64_GLOB_DAT", Const, 20},
{"R_PPC64_GNU_VTENTRY", Const, 20},
{"R_PPC64_GNU_VTINHERIT", Const, 20},
{"R_PPC64_GOT16", Const, 5},
{"R_PPC64_GOT16_DS", Const, 5},
{"R_PPC64_GOT16_HA", Const, 5},
{"R_PPC64_GOT16_HI", Const, 5},
{"R_PPC64_GOT16_LO", Const, 5},
{"R_PPC64_GOT16_LO_DS", Const, 5},
{"R_PPC64_GOT_DTPREL16_DS", Const, 5},
{"R_PPC64_GOT_DTPREL16_HA", Const, 5},
{"R_PPC64_GOT_DTPREL16_HI", Const, 5},
{"R_PPC64_GOT_DTPREL16_LO_DS", Const, 5},
{"R_PPC64_GOT_DTPREL_PCREL34", Const, 20},
{"R_PPC64_GOT_PCREL34", Const, 20},
{"R_PPC64_GOT_TLSGD16", Const, 5},
{"R_PPC64_GOT_TLSGD16_HA", Const, 5},
{"R_PPC64_GOT_TLSGD16_HI", Const, 5},
{"R_PPC64_GOT_TLSGD16_LO", Const, 5},
{"R_PPC64_GOT_TLSGD_PCREL34", Const, 20},
{"R_PPC64_GOT_TLSLD16", Const, 5},
{"R_PPC64_GOT_TLSLD16_HA", Const, 5},
{"R_PPC64_GOT_TLSLD16_HI", Const, 5},
{"R_PPC64_GOT_TLSLD16_LO", Const, 5},
{"R_PPC64_GOT_TLSLD_PCREL34", Const, 20},
{"R_PPC64_GOT_TPREL16_DS", Const, 5},
{"R_PPC64_GOT_TPREL16_HA", Const, 5},
{"R_PPC64_GOT_TPREL16_HI", Const, 5},
{"R_PPC64_GOT_TPREL16_LO_DS", Const, 5},
{"R_PPC64_GOT_TPREL_PCREL34", Const, 20},
{"R_PPC64_IRELATIVE", Const, 10},
{"R_PPC64_JMP_IREL", Const, 10},
{"R_PPC64_JMP_SLOT", Const, 5},
{"R_PPC64_NONE", Const, 5},
{"R_PPC64_PCREL28", Const, 20},
{"R_PPC64_PCREL34", Const, 20},
{"R_PPC64_PCREL_OPT", Const, 20},
{"R_PPC64_PLT16_HA", Const, 20},
{"R_PPC64_PLT16_HI", Const, 20},
{"R_PPC64_PLT16_LO", Const, 20},
{"R_PPC64_PLT16_LO_DS", Const, 10},
{"R_PPC64_PLT32", Const, 20},
{"R_PPC64_PLT64", Const, 20},
{"R_PPC64_PLTCALL", Const, 20},
{"R_PPC64_PLTCALL_NOTOC", Const, 20},
{"R_PPC64_PLTGOT16", Const, 10},
{"R_PPC64_PLTGOT16_DS", Const, 10},
{"R_PPC64_PLTGOT16_HA", Const, 10},
{"R_PPC64_PLTGOT16_HI", Const, 10},
{"R_PPC64_PLTGOT16_LO", Const, 10},
{"R_PPC64_PLTGOT_LO_DS", Const, 10},
{"R_PPC64_PLTREL32", Const, 20},
{"R_PPC64_PLTREL64", Const, 20},
{"R_PPC64_PLTSEQ", Const, 20},
{"R_PPC64_PLTSEQ_NOTOC", Const, 20},
{"R_PPC64_PLT_PCREL34", Const, 20},
{"R_PPC64_PLT_PCREL34_NOTOC", Const, 20},
{"R_PPC64_REL14", Const, 5},
{"R_PPC64_REL14_BRNTAKEN", Const, 5},
{"R_PPC64_REL14_BRTAKEN", Const, 5},
{"R_PPC64_REL16", Const, 5},
{"R_PPC64_REL16DX_HA", Const, 10},
{"R_PPC64_REL16_HA", Const, 5},
{"R_PPC64_REL16_HI", Const, 5},
{"R_PPC64_REL16_HIGH", Const, 20},
{"R_PPC64_REL16_HIGHA", Const, 20},
{"R_PPC64_REL16_HIGHER", Const, 20},
{"R_PPC64_REL16_HIGHER34", Const, 20},
{"R_PPC64_REL16_HIGHERA", Const, 20},
{"R_PPC64_REL16_HIGHERA34", Const, 20},
{"R_PPC64_REL16_HIGHEST", Const, 20},
{"R_PPC64_REL16_HIGHEST34", Const, 20},
{"R_PPC64_REL16_HIGHESTA", Const, 20},
{"R_PPC64_REL16_HIGHESTA34", Const, 20},
{"R_PPC64_REL16_LO", Const, 5},
{"R_PPC64_REL24", Const, 5},
{"R_PPC64_REL24_NOTOC", Const, 10},
{"R_PPC64_REL24_P9NOTOC", Const, 21},
{"R_PPC64_REL30", Const, 20},
{"R_PPC64_REL32", Const, 5},
{"R_PPC64_REL64", Const, 5},
{"R_PPC64_RELATIVE", Const, 18},
{"R_PPC64_SECTOFF", Const, 20},
{"R_PPC64_SECTOFF_DS", Const, 10},
{"R_PPC64_SECTOFF_HA", Const, 20},
{"R_PPC64_SECTOFF_HI", Const, 20},
{"R_PPC64_SECTOFF_LO", Const, 20},
{"R_PPC64_SECTOFF_LO_DS", Const, 10},
{"R_PPC64_TLS", Const, 5},
{"R_PPC64_TLSGD", Const, 5},
{"R_PPC64_TLSLD", Const, 5},
{"R_PPC64_TOC", Const, 5},
{"R_PPC64_TOC16", Const, 5},
{"R_PPC64_TOC16_DS", Const, 5},
{"R_PPC64_TOC16_HA", Const, 5},
{"R_PPC64_TOC16_HI", Const, 5},
{"R_PPC64_TOC16_LO", Const, 5},
{"R_PPC64_TOC16_LO_DS", Const, 5},
{"R_PPC64_TOCSAVE", Const, 10},
{"R_PPC64_TPREL16", Const, 5},
{"R_PPC64_TPREL16_DS", Const, 5},
{"R_PPC64_TPREL16_HA", Const, 5},
{"R_PPC64_TPREL16_HI", Const, 5},
{"R_PPC64_TPREL16_HIGH", Const, 10},
{"R_PPC64_TPREL16_HIGHA", Const, 10},
{"R_PPC64_TPREL16_HIGHER", Const, 5},
{"R_PPC64_TPREL16_HIGHERA", Const, 5},
{"R_PPC64_TPREL16_HIGHEST", Const, 5},
{"R_PPC64_TPREL16_HIGHESTA", Const, 5},
{"R_PPC64_TPREL16_LO", Const, 5},
{"R_PPC64_TPREL16_LO_DS", Const, 5},
{"R_PPC64_TPREL34", Const, 20},
{"R_PPC64_TPREL64", Const, 5},
{"R_PPC64_UADDR16", Const, 20},
{"R_PPC64_UADDR32", Const, 20},
{"R_PPC64_UADDR64", Const, 20},
{"R_PPC_ADDR14", Const, 0},
{"R_PPC_ADDR14_BRNTAKEN", Const, 0},
{"R_PPC_ADDR14_BRTAKEN", Const, 0},
{"R_PPC_ADDR16", Const, 0},
{"R_PPC_ADDR16_HA", Const, 0},
{"R_PPC_ADDR16_HI", Const, 0},
{"R_PPC_ADDR16_LO", Const, 0},
{"R_PPC_ADDR24", Const, 0},
{"R_PPC_ADDR32", Const, 0},
{"R_PPC_COPY", Const, 0},
{"R_PPC_DTPMOD32", Const, 0},
{"R_PPC_DTPREL16", Const, 0},
{"R_PPC_DTPREL16_HA", Const, 0},
{"R_PPC_DTPREL16_HI", Const, 0},
{"R_PPC_DTPREL16_LO", Const, 0},
{"R_PPC_DTPREL32", Const, 0},
{"R_PPC_EMB_BIT_FLD", Const, 0},
{"R_PPC_EMB_MRKREF", Const, 0},
{"R_PPC_EMB_NADDR16", Const, 0},
{"R_PPC_EMB_NADDR16_HA", Const, 0},
{"R_PPC_EMB_NADDR16_HI", Const, 0},
{"R_PPC_EMB_NADDR16_LO", Const, 0},
{"R_PPC_EMB_NADDR32", Const, 0},
{"R_PPC_EMB_RELSDA", Const, 0},
{"R_PPC_EMB_RELSEC16", Const, 0},
{"R_PPC_EMB_RELST_HA", Const, 0},
{"R_PPC_EMB_RELST_HI", Const, 0},
{"R_PPC_EMB_RELST_LO", Const, 0},
{"R_PPC_EMB_SDA21", Const, 0},
{"R_PPC_EMB_SDA2I16", Const, 0},
{"R_PPC_EMB_SDA2REL", Const, 0},
{"R_PPC_EMB_SDAI16", Const, 0},
{"R_PPC_GLOB_DAT", Const, 0},
{"R_PPC_GOT16", Const, 0},
{"R_PPC_GOT16_HA", Const, 0},
{"R_PPC_GOT16_HI", Const, 0},
{"R_PPC_GOT16_LO", Const, 0},
{"R_PPC_GOT_TLSGD16", Const, 0},
{"R_PPC_GOT_TLSGD16_HA", Const, 0},
{"R_PPC_GOT_TLSGD16_HI", Const, 0},
{"R_PPC_GOT_TLSGD16_LO", Const, 0},
{"R_PPC_GOT_TLSLD16", Const, 0},
{"R_PPC_GOT_TLSLD16_HA", Const, 0},
{"R_PPC_GOT_TLSLD16_HI", Const, 0},
{"R_PPC_GOT_TLSLD16_LO", Const, 0},
{"R_PPC_GOT_TPREL16", Const, 0},
{"R_PPC_GOT_TPREL16_HA", Const, 0},
{"R_PPC_GOT_TPREL16_HI", Const, 0},
{"R_PPC_GOT_TPREL16_LO", Const, 0},
{"R_PPC_JMP_SLOT", Const, 0},
{"R_PPC_LOCAL24PC", Const, 0},
{"R_PPC_NONE", Const, 0},
{"R_PPC_PLT16_HA", Const, 0},
{"R_PPC_PLT16_HI", Const, 0},
{"R_PPC_PLT16_LO", Const, 0},
{"R_PPC_PLT32", Const, 0},
{"R_PPC_PLTREL24", Const, 0},
{"R_PPC_PLTREL32", Const, 0},
{"R_PPC_REL14", Const, 0},
{"R_PPC_REL14_BRNTAKEN", Const, 0},
{"R_PPC_REL14_BRTAKEN", Const, 0},
{"R_PPC_REL24", Const, 0},
{"R_PPC_REL32", Const, 0},
{"R_PPC_RELATIVE", Const, 0},
{"R_PPC_SDAREL16", Const, 0},
{"R_PPC_SECTOFF", Const, 0},
{"R_PPC_SECTOFF_HA", Const, 0},
{"R_PPC_SECTOFF_HI", Const, 0},
{"R_PPC_SECTOFF_LO", Const, 0},
{"R_PPC_TLS", Const, 0},
{"R_PPC_TPREL16", Const, 0},
{"R_PPC_TPREL16_HA", Const, 0},
{"R_PPC_TPREL16_HI", Const, 0},
{"R_PPC_TPREL16_LO", Const, 0},
{"R_PPC_TPREL32", Const, 0},
{"R_PPC_UADDR16", Const, 0},
{"R_PPC_UADDR32", Const, 0},
{"R_RISCV", Type, 11},
{"R_RISCV_32", Const, 11},
{"R_RISCV_32_PCREL", Const, 12},
{"R_RISCV_64", Const, 11},
{"R_RISCV_ADD16", Const, 11},
{"R_RISCV_ADD32", Const, 11},
{"R_RISCV_ADD64", Const, 11},
{"R_RISCV_ADD8", Const, 11},
{"R_RISCV_ALIGN", Const, 11},
{"R_RISCV_BRANCH", Const, 11},
{"R_RISCV_CALL", Const, 11},
{"R_RISCV_CALL_PLT", Const, 11},
{"R_RISCV_COPY", Const, 11},
{"R_RISCV_GNU_VTENTRY", Const, 11},
{"R_RISCV_GNU_VTINHERIT", Const, 11},
{"R_RISCV_GOT_HI20", Const, 11},
{"R_RISCV_GPREL_I", Const, 11},
{"R_RISCV_GPREL_S", Const, 11},
{"R_RISCV_HI20", Const, 11},
{"R_RISCV_JAL", Const, 11},
{"R_RISCV_JUMP_SLOT", Const, 11},
{"R_RISCV_LO12_I", Const, 11},
{"R_RISCV_LO12_S", Const, 11},
{"R_RISCV_NONE", Const, 11},
{"R_RISCV_PCREL_HI20", Const, 11},
{"R_RISCV_PCREL_LO12_I", Const, 11},
{"R_RISCV_PCREL_LO12_S", Const, 11},
{"R_RISCV_RELATIVE", Const, 11},
{"R_RISCV_RELAX", Const, 11},
{"R_RISCV_RVC_BRANCH", Const, 11},
{"R_RISCV_RVC_JUMP", Const, 11},
{"R_RISCV_RVC_LUI", Const, 11},
{"R_RISCV_SET16", Const, 11},
{"R_RISCV_SET32", Const, 11},
{"R_RISCV_SET6", Const, 11},
{"R_RISCV_SET8", Const, 11},
{"R_RISCV_SUB16", Const, 11},
{"R_RISCV_SUB32", Const, 11},
{"R_RISCV_SUB6", Const, 11},
{"R_RISCV_SUB64", Const, 11},
{"R_RISCV_SUB8", Const, 11},
{"R_RISCV_TLS_DTPMOD32", Const, 11},
{"R_RISCV_TLS_DTPMOD64", Const, 11},
{"R_RISCV_TLS_DTPREL32", Const, 11},
{"R_RISCV_TLS_DTPREL64", Const, 11},
{"R_RISCV_TLS_GD_HI20", Const, 11},
{"R_RISCV_TLS_GOT_HI20", Const, 11},
{"R_RISCV_TLS_TPREL32", Const, 11},
{"R_RISCV_TLS_TPREL64", Const, 11},
{"R_RISCV_TPREL_ADD", Const, 11},
{"R_RISCV_TPREL_HI20", Const, 11},
{"R_RISCV_TPREL_I", Const, 11},
{"R_RISCV_TPREL_LO12_I", Const, 11},
{"R_RISCV_TPREL_LO12_S", Const, 11},
{"R_RISCV_TPREL_S", Const, 11},
{"R_SPARC", Type, 0},
{"R_SPARC_10", Const, 0},
{"R_SPARC_11", Const, 0},
{"R_SPARC_13", Const, 0},
{"R_SPARC_16", Const, 0},
{"R_SPARC_22", Const, 0},
{"R_SPARC_32", Const, 0},
{"R_SPARC_5", Const, 0},
{"R_SPARC_6", Const, 0},
{"R_SPARC_64", Const, 0},
{"R_SPARC_7", Const, 0},
{"R_SPARC_8", Const, 0},
{"R_SPARC_COPY", Const, 0},
{"R_SPARC_DISP16", Const, 0},
{"R_SPARC_DISP32", Const, 0},
{"R_SPARC_DISP64", Const, 0},
{"R_SPARC_DISP8", Const, 0},
{"R_SPARC_GLOB_DAT", Const, 0},
{"R_SPARC_GLOB_JMP", Const, 0},
{"R_SPARC_GOT10", Const, 0},
{"R_SPARC_GOT13", Const, 0},
{"R_SPARC_GOT22", Const, 0},
{"R_SPARC_H44", Const, 0},
{"R_SPARC_HH22", Const, 0},
{"R_SPARC_HI22", Const, 0},
{"R_SPARC_HIPLT22", Const, 0},
{"R_SPARC_HIX22", Const, 0},
{"R_SPARC_HM10", Const, 0},
{"R_SPARC_JMP_SLOT", Const, 0},
{"R_SPARC_L44", Const, 0},
{"R_SPARC_LM22", Const, 0},
{"R_SPARC_LO10", Const, 0},
{"R_SPARC_LOPLT10", Const, 0},
{"R_SPARC_LOX10", Const, 0},
{"R_SPARC_M44", Const, 0},
{"R_SPARC_NONE", Const, 0},
{"R_SPARC_OLO10", Const, 0},
{"R_SPARC_PC10", Const, 0},
{"R_SPARC_PC22", Const, 0},
{"R_SPARC_PCPLT10", Const, 0},
{"R_SPARC_PCPLT22", Const, 0},
{"R_SPARC_PCPLT32", Const, 0},
{"R_SPARC_PC_HH22", Const, 0},
{"R_SPARC_PC_HM10", Const, 0},
{"R_SPARC_PC_LM22", Const, 0},
{"R_SPARC_PLT32", Const, 0},
{"R_SPARC_PLT64", Const, 0},
{"R_SPARC_REGISTER", Const, 0},
{"R_SPARC_RELATIVE", Const, 0},
{"R_SPARC_UA16", Const, 0},
{"R_SPARC_UA32", Const, 0},
{"R_SPARC_UA64", Const, 0},
{"R_SPARC_WDISP16", Const, 0},
{"R_SPARC_WDISP19", Const, 0},
{"R_SPARC_WDISP22", Const, 0},
{"R_SPARC_WDISP30", Const, 0},
{"R_SPARC_WPLT30", Const, 0},
{"R_SYM32", Func, 0},
{"R_SYM64", Func, 0},
{"R_TYPE32", Func, 0},
{"R_TYPE64", Func, 0},
{"R_X86_64", Type, 0},
{"R_X86_64_16", Const, 0},
{"R_X86_64_32", Const, 0},
{"R_X86_64_32S", Const, 0},
{"R_X86_64_64", Const, 0},
{"R_X86_64_8", Const, 0},
{"R_X86_64_COPY", Const, 0},
{"R_X86_64_DTPMOD64", Const, 0},
{"R_X86_64_DTPOFF32", Const, 0},
{"R_X86_64_DTPOFF64", Const, 0},
{"R_X86_64_GLOB_DAT", Const, 0},
{"R_X86_64_GOT32", Const, 0},
{"R_X86_64_GOT64", Const, 10},
{"R_X86_64_GOTOFF64", Const, 10},
{"R_X86_64_GOTPC32", Const, 10},
{"R_X86_64_GOTPC32_TLSDESC", Const, 10},
{"R_X86_64_GOTPC64", Const, 10},
{"R_X86_64_GOTPCREL", Const, 0},
{"R_X86_64_GOTPCREL64", Const, 10},
{"R_X86_64_GOTPCRELX", Const, 10},
{"R_X86_64_GOTPLT64", Const, 10},
{"R_X86_64_GOTTPOFF", Const, 0},
{"R_X86_64_IRELATIVE", Const, 10},
{"R_X86_64_JMP_SLOT", Const, 0},
{"R_X86_64_NONE", Const, 0},
{"R_X86_64_PC16", Const, 0},
{"R_X86_64_PC32", Const, 0},
{"R_X86_64_PC32_BND", Const, 10},
{"R_X86_64_PC64", Const, 10},
{"R_X86_64_PC8", Const, 0},
{"R_X86_64_PLT32", Const, 0},
{"R_X86_64_PLT32_BND", Const, 10},
{"R_X86_64_PLTOFF64", Const, 10},
{"R_X86_64_RELATIVE", Const, 0},
{"R_X86_64_RELATIVE64", Const, 10},
{"R_X86_64_REX_GOTPCRELX", Const, 10},
{"R_X86_64_SIZE32", Const, 10},
{"R_X86_64_SIZE64", Const, 10},
{"R_X86_64_TLSDESC", Const, 10},
{"R_X86_64_TLSDESC_CALL", Const, 10},
{"R_X86_64_TLSGD", Const, 0},
{"R_X86_64_TLSLD", Const, 0},
{"R_X86_64_TPOFF32", Const, 0},
{"R_X86_64_TPOFF64", Const, 0},
{"Rel32", Type, 0},
{"Rel32.Info", Field, 0},
{"Rel32.Off", Field, 0},
{"Rel64", Type, 0},
{"Rel64.Info", Field, 0},
{"Rel64.Off", Field, 0},
{"Rela32", Type, 0},
{"Rela32.Addend", Field, 0},
{"Rela32.Info", Field, 0},
{"Rela32.Off", Field, 0},
{"Rela64", Type, 0},
{"Rela64.Addend", Field, 0},
{"Rela64.Info", Field, 0},
{"Rela64.Off", Field, 0},
{"SHF_ALLOC", Const, 0},
{"SHF_COMPRESSED", Const, 6},
{"SHF_EXECINSTR", Const, 0},
{"SHF_GROUP", Const, 0},
{"SHF_INFO_LINK", Const, 0},
{"SHF_LINK_ORDER", Const, 0},
{"SHF_MASKOS", Const, 0},
{"SHF_MASKPROC", Const, 0},
{"SHF_MERGE", Const, 0},
{"SHF_OS_NONCONFORMING", Const, 0},
{"SHF_STRINGS", Const, 0},
{"SHF_TLS", Const, 0},
{"SHF_WRITE", Const, 0},
{"SHN_ABS", Const, 0},
{"SHN_COMMON", Const, 0},
{"SHN_HIOS", Const, 0},
{"SHN_HIPROC", Const, 0},
{"SHN_HIRESERVE", Const, 0},
{"SHN_LOOS", Const, 0},
{"SHN_LOPROC", Const, 0},
{"SHN_LORESERVE", Const, 0},
{"SHN_UNDEF", Const, 0},
{"SHN_XINDEX", Const, 0},
{"SHT_DYNAMIC", Const, 0},
{"SHT_DYNSYM", Const, 0},
{"SHT_FINI_ARRAY", Const, 0},
{"SHT_GNU_ATTRIBUTES", Const, 0},
{"SHT_GNU_HASH", Const, 0},
{"SHT_GNU_LIBLIST", Const, 0},
{"SHT_GNU_VERDEF", Const, 0},
{"SHT_GNU_VERNEED", Const, 0},
{"SHT_GNU_VERSYM", Const, 0},
{"SHT_GROUP", Const, 0},
{"SHT_HASH", Const, 0},
{"SHT_HIOS", Const, 0},
{"SHT_HIPROC", Const, 0},
{"SHT_HIUSER", Const, 0},
{"SHT_INIT_ARRAY", Const, 0},
{"SHT_LOOS", Const, 0},
{"SHT_LOPROC", Const, 0},
{"SHT_LOUSER", Const, 0},
{"SHT_MIPS_ABIFLAGS", Const, 17},
{"SHT_NOBITS", Const, 0},
{"SHT_NOTE", Const, 0},
{"SHT_NULL", Const, 0},
{"SHT_PREINIT_ARRAY", Const, 0},
{"SHT_PROGBITS", Const, 0},
{"SHT_REL", Const, 0},
{"SHT_RELA", Const, 0},
{"SHT_SHLIB", Const, 0},
{"SHT_STRTAB", Const, 0},
{"SHT_SYMTAB", Const, 0},
{"SHT_SYMTAB_SHNDX", Const, 0},
{"STB_GLOBAL", Const, 0},
{"STB_HIOS", Const, 0},
{"STB_HIPROC", Const, 0},
{"STB_LOCAL", Const, 0},
{"STB_LOOS", Const, 0},
{"STB_LOPROC", Const, 0},
{"STB_WEAK", Const, 0},
{"STT_COMMON", Const, 0},
{"STT_FILE", Const, 0},
{"STT_FUNC", Const, 0},
{"STT_GNU_IFUNC", Const, 23},
{"STT_HIOS", Const, 0},
{"STT_HIPROC", Const, 0},
{"STT_LOOS", Const, 0},
{"STT_LOPROC", Const, 0},
{"STT_NOTYPE", Const, 0},
{"STT_OBJECT", Const, 0},
{"STT_RELC", Const, 23},
{"STT_SECTION", Const, 0},
{"STT_SRELC", Const, 23},
{"STT_TLS", Const, 0},
{"STV_DEFAULT", Const, 0},
{"STV_HIDDEN", Const, 0},
{"STV_INTERNAL", Const, 0},
{"STV_PROTECTED", Const, 0},
{"ST_BIND", Func, 0},
{"ST_INFO", Func, 0},
{"ST_TYPE", Func, 0},
{"ST_VISIBILITY", Func, 0},
{"Section", Type, 0},
{"Section.ReaderAt", Field, 0},
{"Section.SectionHeader", Field, 0},
{"Section32", Type, 0},
{"Section32.Addr", Field, 0},
{"Section32.Addralign", Field, 0},
{"Section32.Entsize", Field, 0},
{"Section32.Flags", Field, 0},
{"Section32.Info", Field, 0},
{"Section32.Link", Field, 0},
{"Section32.Name", Field, 0},
{"Section32.Off", Field, 0},
{"Section32.Size", Field, 0},
{"Section32.Type", Field, 0},
{"Section64", Type, 0},
{"Section64.Addr", Field, 0},
{"Section64.Addralign", Field, 0},
{"Section64.Entsize", Field, 0},
{"Section64.Flags", Field, 0},
{"Section64.Info", Field, 0},
{"Section64.Link", Field, 0},
{"Section64.Name", Field, 0},
{"Section64.Off", Field, 0},
{"Section64.Size", Field, 0},
{"Section64.Type", Field, 0},
{"SectionFlag", Type, 0},
{"SectionHeader", Type, 0},
{"SectionHeader.Addr", Field, 0},
{"SectionHeader.Addralign", Field, 0},
{"SectionHeader.Entsize", Field, 0},
{"SectionHeader.FileSize", Field, 6},
{"SectionHeader.Flags", Field, 0},
{"SectionHeader.Info", Field, 0},
{"SectionHeader.Link", Field, 0},
{"SectionHeader.Name", Field, 0},
{"SectionHeader.Offset", Field, 0},
{"SectionHeader.Size", Field, 0},
{"SectionHeader.Type", Field, 0},
{"SectionIndex", Type, 0},
{"SectionType", Type, 0},
{"Sym32", Type, 0},
{"Sym32.Info", Field, 0},
{"Sym32.Name", Field, 0},
{"Sym32.Other", Field, 0},
{"Sym32.Shndx", Field, 0},
{"Sym32.Size", Field, 0},
{"Sym32.Value", Field, 0},
{"Sym32Size", Const, 0},
{"Sym64", Type, 0},
{"Sym64.Info", Field, 0},
{"Sym64.Name", Field, 0},
{"Sym64.Other", Field, 0},
{"Sym64.Shndx", Field, 0},
{"Sym64.Size", Field, 0},
{"Sym64.Value", Field, 0},
{"Sym64Size", Const, 0},
{"SymBind", Type, 0},
{"SymType", Type, 0},
{"SymVis", Type, 0},
{"Symbol", Type, 0},
{"Symbol.Info", Field, 0},
{"Symbol.Library", Field, 13},
{"Symbol.Name", Field, 0},
{"Symbol.Other", Field, 0},
{"Symbol.Section", Field, 0},
{"Symbol.Size", Field, 0},
{"Symbol.Value", Field, 0},
{"Symbol.Version", Field, 13},
{"Type", Type, 0},
{"Version", Type, 0},
},
"debug/gosym": {
{"(*DecodingError).Error", Method, 0},
{"(*LineTable).LineToPC", Method, 0},
{"(*LineTable).PCToLine", Method, 0},
{"(*Sym).BaseName", Method, 0},
{"(*Sym).PackageName", Method, 0},
{"(*Sym).ReceiverName", Method, 0},
{"(*Sym).Static", Method, 0},
{"(*Table).LineToPC", Method, 0},
{"(*Table).LookupFunc", Method, 0},
{"(*Table).LookupSym", Method, 0},
{"(*Table).PCToFunc", Method, 0},
{"(*Table).PCToLine", Method, 0},
{"(*Table).SymByAddr", Method, 0},
{"(*UnknownLineError).Error", Method, 0},
{"(Func).BaseName", Method, 0},
{"(Func).PackageName", Method, 0},
{"(Func).ReceiverName", Method, 0},
{"(Func).Static", Method, 0},
{"(UnknownFileError).Error", Method, 0},
{"DecodingError", Type, 0},
{"Func", Type, 0},
{"Func.End", Field, 0},
{"Func.Entry", Field, 0},
{"Func.FrameSize", Field, 0},
{"Func.LineTable", Field, 0},
{"Func.Locals", Field, 0},
{"Func.Obj", Field, 0},
{"Func.Params", Field, 0},
{"Func.Sym", Field, 0},
{"LineTable", Type, 0},
{"LineTable.Data", Field, 0},
{"LineTable.Line", Field, 0},
{"LineTable.PC", Field, 0},
{"NewLineTable", Func, 0},
{"NewTable", Func, 0},
{"Obj", Type, 0},
{"Obj.Funcs", Field, 0},
{"Obj.Paths", Field, 0},
{"Sym", Type, 0},
{"Sym.Func", Field, 0},
{"Sym.GoType", Field, 0},
{"Sym.Name", Field, 0},
{"Sym.Type", Field, 0},
{"Sym.Value", Field, 0},
{"Table", Type, 0},
{"Table.Files", Field, 0},
{"Table.Funcs", Field, 0},
{"Table.Objs", Field, 0},
{"Table.Syms", Field, 0},
{"UnknownFileError", Type, 0},
{"UnknownLineError", Type, 0},
{"UnknownLineError.File", Field, 0},
{"UnknownLineError.Line", Field, 0},
},
"debug/macho": {
{"(*FatFile).Close", Method, 3},
{"(*File).Close", Method, 0},
{"(*File).DWARF", Method, 0},
{"(*File).ImportedLibraries", Method, 0},
{"(*File).ImportedSymbols", Method, 0},
{"(*File).Section", Method, 0},
{"(*File).Segment", Method, 0},
{"(*FormatError).Error", Method, 0},
{"(*Section).Data", Method, 0},
{"(*Section).Open", Method, 0},
{"(*Segment).Data", Method, 0},
{"(*Segment).Open", Method, 0},
{"(Cpu).GoString", Method, 0},
{"(Cpu).String", Method, 0},
{"(Dylib).Raw", Method, 0},
{"(Dysymtab).Raw", Method, 0},
{"(FatArch).Close", Method, 3},
{"(FatArch).DWARF", Method, 3},
{"(FatArch).ImportedLibraries", Method, 3},
{"(FatArch).ImportedSymbols", Method, 3},
{"(FatArch).Section", Method, 3},
{"(FatArch).Segment", Method, 3},
{"(LoadBytes).Raw", Method, 0},
{"(LoadCmd).GoString", Method, 0},
{"(LoadCmd).String", Method, 0},
{"(RelocTypeARM).GoString", Method, 10},
{"(RelocTypeARM).String", Method, 10},
{"(RelocTypeARM64).GoString", Method, 10},
{"(RelocTypeARM64).String", Method, 10},
{"(RelocTypeGeneric).GoString", Method, 10},
{"(RelocTypeGeneric).String", Method, 10},
{"(RelocTypeX86_64).GoString", Method, 10},
{"(RelocTypeX86_64).String", Method, 10},
{"(Rpath).Raw", Method, 10},
{"(Section).ReadAt", Method, 0},
{"(Segment).Raw", Method, 0},
{"(Segment).ReadAt", Method, 0},
{"(Symtab).Raw", Method, 0},
{"(Type).GoString", Method, 10},
{"(Type).String", Method, 10},
{"ARM64_RELOC_ADDEND", Const, 10},
{"ARM64_RELOC_BRANCH26", Const, 10},
{"ARM64_RELOC_GOT_LOAD_PAGE21", Const, 10},
{"ARM64_RELOC_GOT_LOAD_PAGEOFF12", Const, 10},
{"ARM64_RELOC_PAGE21", Const, 10},
{"ARM64_RELOC_PAGEOFF12", Const, 10},
{"ARM64_RELOC_POINTER_TO_GOT", Const, 10},
{"ARM64_RELOC_SUBTRACTOR", Const, 10},
{"ARM64_RELOC_TLVP_LOAD_PAGE21", Const, 10},
{"ARM64_RELOC_TLVP_LOAD_PAGEOFF12", Const, 10},
{"ARM64_RELOC_UNSIGNED", Const, 10},
{"ARM_RELOC_BR24", Const, 10},
{"ARM_RELOC_HALF", Const, 10},
{"ARM_RELOC_HALF_SECTDIFF", Const, 10},
{"ARM_RELOC_LOCAL_SECTDIFF", Const, 10},
{"ARM_RELOC_PAIR", Const, 10},
{"ARM_RELOC_PB_LA_PTR", Const, 10},
{"ARM_RELOC_SECTDIFF", Const, 10},
{"ARM_RELOC_VANILLA", Const, 10},
{"ARM_THUMB_32BIT_BRANCH", Const, 10},
{"ARM_THUMB_RELOC_BR22", Const, 10},
{"Cpu", Type, 0},
{"Cpu386", Const, 0},
{"CpuAmd64", Const, 0},
{"CpuArm", Const, 3},
{"CpuArm64", Const, 11},
{"CpuPpc", Const, 3},
{"CpuPpc64", Const, 3},
{"Dylib", Type, 0},
{"Dylib.CompatVersion", Field, 0},
{"Dylib.CurrentVersion", Field, 0},
{"Dylib.LoadBytes", Field, 0},
{"Dylib.Name", Field, 0},
{"Dylib.Time", Field, 0},
{"DylibCmd", Type, 0},
{"DylibCmd.Cmd", Field, 0},
{"DylibCmd.CompatVersion", Field, 0},
{"DylibCmd.CurrentVersion", Field, 0},
{"DylibCmd.Len", Field, 0},
{"DylibCmd.Name", Field, 0},
{"DylibCmd.Time", Field, 0},
{"Dysymtab", Type, 0},
{"Dysymtab.DysymtabCmd", Field, 0},
{"Dysymtab.IndirectSyms", Field, 0},
{"Dysymtab.LoadBytes", Field, 0},
{"DysymtabCmd", Type, 0},
{"DysymtabCmd.Cmd", Field, 0},
{"DysymtabCmd.Extrefsymoff", Field, 0},
{"DysymtabCmd.Extreloff", Field, 0},
{"DysymtabCmd.Iextdefsym", Field, 0},
{"DysymtabCmd.Ilocalsym", Field, 0},
{"DysymtabCmd.Indirectsymoff", Field, 0},
{"DysymtabCmd.Iundefsym", Field, 0},
{"DysymtabCmd.Len", Field, 0},
{"DysymtabCmd.Locreloff", Field, 0},
{"DysymtabCmd.Modtaboff", Field, 0},
{"DysymtabCmd.Nextdefsym", Field, 0},
{"DysymtabCmd.Nextrefsyms", Field, 0},
{"DysymtabCmd.Nextrel", Field, 0},
{"DysymtabCmd.Nindirectsyms", Field, 0},
{"DysymtabCmd.Nlocalsym", Field, 0},
{"DysymtabCmd.Nlocrel", Field, 0},
{"DysymtabCmd.Nmodtab", Field, 0},
{"DysymtabCmd.Ntoc", Field, 0},
{"DysymtabCmd.Nundefsym", Field, 0},
{"DysymtabCmd.Tocoffset", Field, 0},
{"ErrNotFat", Var, 3},
{"FatArch", Type, 3},
{"FatArch.FatArchHeader", Field, 3},
{"FatArch.File", Field, 3},
{"FatArchHeader", Type, 3},
{"FatArchHeader.Align", Field, 3},
{"FatArchHeader.Cpu", Field, 3},
{"FatArchHeader.Offset", Field, 3},
{"FatArchHeader.Size", Field, 3},
{"FatArchHeader.SubCpu", Field, 3},
{"FatFile", Type, 3},
{"FatFile.Arches", Field, 3},
{"FatFile.Magic", Field, 3},
{"File", Type, 0},
{"File.ByteOrder", Field, 0},
{"File.Dysymtab", Field, 0},
{"File.FileHeader", Field, 0},
{"File.Loads", Field, 0},
{"File.Sections", Field, 0},
{"File.Symtab", Field, 0},
{"FileHeader", Type, 0},
{"FileHeader.Cmdsz", Field, 0},
{"FileHeader.Cpu", Field, 0},
{"FileHeader.Flags", Field, 0},
{"FileHeader.Magic", Field, 0},
{"FileHeader.Ncmd", Field, 0},
{"FileHeader.SubCpu", Field, 0},
{"FileHeader.Type", Field, 0},
{"FlagAllModsBound", Const, 10},
{"FlagAllowStackExecution", Const, 10},
{"FlagAppExtensionSafe", Const, 10},
{"FlagBindAtLoad", Const, 10},
{"FlagBindsToWeak", Const, 10},
{"FlagCanonical", Const, 10},
{"FlagDeadStrippableDylib", Const, 10},
{"FlagDyldLink", Const, 10},
{"FlagForceFlat", Const, 10},
{"FlagHasTLVDescriptors", Const, 10},
{"FlagIncrLink", Const, 10},
{"FlagLazyInit", Const, 10},
{"FlagNoFixPrebinding", Const, 10},
{"FlagNoHeapExecution", Const, 10},
{"FlagNoMultiDefs", Const, 10},
{"FlagNoReexportedDylibs", Const, 10},
{"FlagNoUndefs", Const, 10},
{"FlagPIE", Const, 10},
{"FlagPrebindable", Const, 10},
{"FlagPrebound", Const, 10},
{"FlagRootSafe", Const, 10},
{"FlagSetuidSafe", Const, 10},
{"FlagSplitSegs", Const, 10},
{"FlagSubsectionsViaSymbols", Const, 10},
{"FlagTwoLevel", Const, 10},
{"FlagWeakDefines", Const, 10},
{"FormatError", Type, 0},
{"GENERIC_RELOC_LOCAL_SECTDIFF", Const, 10},
{"GENERIC_RELOC_PAIR", Const, 10},
{"GENERIC_RELOC_PB_LA_PTR", Const, 10},
{"GENERIC_RELOC_SECTDIFF", Const, 10},
{"GENERIC_RELOC_TLV", Const, 10},
{"GENERIC_RELOC_VANILLA", Const, 10},
{"Load", Type, 0},
{"LoadBytes", Type, 0},
{"LoadCmd", Type, 0},
{"LoadCmdDylib", Const, 0},
{"LoadCmdDylinker", Const, 0},
{"LoadCmdDysymtab", Const, 0},
{"LoadCmdRpath", Const, 10},
{"LoadCmdSegment", Const, 0},
{"LoadCmdSegment64", Const, 0},
{"LoadCmdSymtab", Const, 0},
{"LoadCmdThread", Const, 0},
{"LoadCmdUnixThread", Const, 0},
{"Magic32", Const, 0},
{"Magic64", Const, 0},
{"MagicFat", Const, 3},
{"NewFatFile", Func, 3},
{"NewFile", Func, 0},
{"Nlist32", Type, 0},
{"Nlist32.Desc", Field, 0},
{"Nlist32.Name", Field, 0},
{"Nlist32.Sect", Field, 0},
{"Nlist32.Type", Field, 0},
{"Nlist32.Value", Field, 0},
{"Nlist64", Type, 0},
{"Nlist64.Desc", Field, 0},
{"Nlist64.Name", Field, 0},
{"Nlist64.Sect", Field, 0},
{"Nlist64.Type", Field, 0},
{"Nlist64.Value", Field, 0},
{"Open", Func, 0},
{"OpenFat", Func, 3},
{"Regs386", Type, 0},
{"Regs386.AX", Field, 0},
{"Regs386.BP", Field, 0},
{"Regs386.BX", Field, 0},
{"Regs386.CS", Field, 0},
{"Regs386.CX", Field, 0},
{"Regs386.DI", Field, 0},
{"Regs386.DS", Field, 0},
{"Regs386.DX", Field, 0},
{"Regs386.ES", Field, 0},
{"Regs386.FLAGS", Field, 0},
{"Regs386.FS", Field, 0},
{"Regs386.GS", Field, 0},
{"Regs386.IP", Field, 0},
{"Regs386.SI", Field, 0},
{"Regs386.SP", Field, 0},
{"Regs386.SS", Field, 0},
{"RegsAMD64", Type, 0},
{"RegsAMD64.AX", Field, 0},
{"RegsAMD64.BP", Field, 0},
{"RegsAMD64.BX", Field, 0},
{"RegsAMD64.CS", Field, 0},
{"RegsAMD64.CX", Field, 0},
{"RegsAMD64.DI", Field, 0},
{"RegsAMD64.DX", Field, 0},
{"RegsAMD64.FLAGS", Field, 0},
{"RegsAMD64.FS", Field, 0},
{"RegsAMD64.GS", Field, 0},
{"RegsAMD64.IP", Field, 0},
{"RegsAMD64.R10", Field, 0},
{"RegsAMD64.R11", Field, 0},
{"RegsAMD64.R12", Field, 0},
{"RegsAMD64.R13", Field, 0},
{"RegsAMD64.R14", Field, 0},
{"RegsAMD64.R15", Field, 0},
{"RegsAMD64.R8", Field, 0},
{"RegsAMD64.R9", Field, 0},
{"RegsAMD64.SI", Field, 0},
{"RegsAMD64.SP", Field, 0},
{"Reloc", Type, 10},
{"Reloc.Addr", Field, 10},
{"Reloc.Extern", Field, 10},
{"Reloc.Len", Field, 10},
{"Reloc.Pcrel", Field, 10},
{"Reloc.Scattered", Field, 10},
{"Reloc.Type", Field, 10},
{"Reloc.Value", Field, 10},
{"RelocTypeARM", Type, 10},
{"RelocTypeARM64", Type, 10},
{"RelocTypeGeneric", Type, 10},
{"RelocTypeX86_64", Type, 10},
{"Rpath", Type, 10},
{"Rpath.LoadBytes", Field, 10},
{"Rpath.Path", Field, 10},
{"RpathCmd", Type, 10},
{"RpathCmd.Cmd", Field, 10},
{"RpathCmd.Len", Field, 10},
{"RpathCmd.Path", Field, 10},
{"Section", Type, 0},
{"Section.ReaderAt", Field, 0},
{"Section.Relocs", Field, 10},
{"Section.SectionHeader", Field, 0},
{"Section32", Type, 0},
{"Section32.Addr", Field, 0},
{"Section32.Align", Field, 0},
{"Section32.Flags", Field, 0},
{"Section32.Name", Field, 0},
{"Section32.Nreloc", Field, 0},
{"Section32.Offset", Field, 0},
{"Section32.Reloff", Field, 0},
{"Section32.Reserve1", Field, 0},
{"Section32.Reserve2", Field, 0},
{"Section32.Seg", Field, 0},
{"Section32.Size", Field, 0},
{"Section64", Type, 0},
{"Section64.Addr", Field, 0},
{"Section64.Align", Field, 0},
{"Section64.Flags", Field, 0},
{"Section64.Name", Field, 0},
{"Section64.Nreloc", Field, 0},
{"Section64.Offset", Field, 0},
{"Section64.Reloff", Field, 0},
{"Section64.Reserve1", Field, 0},
{"Section64.Reserve2", Field, 0},
{"Section64.Reserve3", Field, 0},
{"Section64.Seg", Field, 0},
{"Section64.Size", Field, 0},
{"SectionHeader", Type, 0},
{"SectionHeader.Addr", Field, 0},
{"SectionHeader.Align", Field, 0},
{"SectionHeader.Flags", Field, 0},
{"SectionHeader.Name", Field, 0},
{"SectionHeader.Nreloc", Field, 0},
{"SectionHeader.Offset", Field, 0},
{"SectionHeader.Reloff", Field, 0},
{"SectionHeader.Seg", Field, 0},
{"SectionHeader.Size", Field, 0},
{"Segment", Type, 0},
{"Segment.LoadBytes", Field, 0},
{"Segment.ReaderAt", Field, 0},
{"Segment.SegmentHeader", Field, 0},
{"Segment32", Type, 0},
{"Segment32.Addr", Field, 0},
{"Segment32.Cmd", Field, 0},
{"Segment32.Filesz", Field, 0},
{"Segment32.Flag", Field, 0},
{"Segment32.Len", Field, 0},
{"Segment32.Maxprot", Field, 0},
{"Segment32.Memsz", Field, 0},
{"Segment32.Name", Field, 0},
{"Segment32.Nsect", Field, 0},
{"Segment32.Offset", Field, 0},
{"Segment32.Prot", Field, 0},
{"Segment64", Type, 0},
{"Segment64.Addr", Field, 0},
{"Segment64.Cmd", Field, 0},
{"Segment64.Filesz", Field, 0},
{"Segment64.Flag", Field, 0},
{"Segment64.Len", Field, 0},
{"Segment64.Maxprot", Field, 0},
{"Segment64.Memsz", Field, 0},
{"Segment64.Name", Field, 0},
{"Segment64.Nsect", Field, 0},
{"Segment64.Offset", Field, 0},
{"Segment64.Prot", Field, 0},
{"SegmentHeader", Type, 0},
{"SegmentHeader.Addr", Field, 0},
{"SegmentHeader.Cmd", Field, 0},
{"SegmentHeader.Filesz", Field, 0},
{"SegmentHeader.Flag", Field, 0},
{"SegmentHeader.Len", Field, 0},
{"SegmentHeader.Maxprot", Field, 0},
{"SegmentHeader.Memsz", Field, 0},
{"SegmentHeader.Name", Field, 0},
{"SegmentHeader.Nsect", Field, 0},
{"SegmentHeader.Offset", Field, 0},
{"SegmentHeader.Prot", Field, 0},
{"Symbol", Type, 0},
{"Symbol.Desc", Field, 0},
{"Symbol.Name", Field, 0},
{"Symbol.Sect", Field, 0},
{"Symbol.Type", Field, 0},
{"Symbol.Value", Field, 0},
{"Symtab", Type, 0},
{"Symtab.LoadBytes", Field, 0},
{"Symtab.Syms", Field, 0},
{"Symtab.SymtabCmd", Field, 0},
{"SymtabCmd", Type, 0},
{"SymtabCmd.Cmd", Field, 0},
{"SymtabCmd.Len", Field, 0},
{"SymtabCmd.Nsyms", Field, 0},
{"SymtabCmd.Stroff", Field, 0},
{"SymtabCmd.Strsize", Field, 0},
{"SymtabCmd.Symoff", Field, 0},
{"Thread", Type, 0},
{"Thread.Cmd", Field, 0},
{"Thread.Data", Field, 0},
{"Thread.Len", Field, 0},
{"Thread.Type", Field, 0},
{"Type", Type, 0},
{"TypeBundle", Const, 3},
{"TypeDylib", Const, 3},
{"TypeExec", Const, 0},
{"TypeObj", Const, 0},
{"X86_64_RELOC_BRANCH", Const, 10},
{"X86_64_RELOC_GOT", Const, 10},
{"X86_64_RELOC_GOT_LOAD", Const, 10},
{"X86_64_RELOC_SIGNED", Const, 10},
{"X86_64_RELOC_SIGNED_1", Const, 10},
{"X86_64_RELOC_SIGNED_2", Const, 10},
{"X86_64_RELOC_SIGNED_4", Const, 10},
{"X86_64_RELOC_SUBTRACTOR", Const, 10},
{"X86_64_RELOC_TLV", Const, 10},
{"X86_64_RELOC_UNSIGNED", Const, 10},
},
"debug/pe": {
{"(*COFFSymbol).FullName", Method, 8},
{"(*File).COFFSymbolReadSectionDefAux", Method, 19},
{"(*File).Close", Method, 0},
{"(*File).DWARF", Method, 0},
{"(*File).ImportedLibraries", Method, 0},
{"(*File).ImportedSymbols", Method, 0},
{"(*File).Section", Method, 0},
{"(*FormatError).Error", Method, 0},
{"(*Section).Data", Method, 0},
{"(*Section).Open", Method, 0},
{"(Section).ReadAt", Method, 0},
{"(StringTable).String", Method, 8},
{"COFFSymbol", Type, 1},
{"COFFSymbol.Name", Field, 1},
{"COFFSymbol.NumberOfAuxSymbols", Field, 1},
{"COFFSymbol.SectionNumber", Field, 1},
{"COFFSymbol.StorageClass", Field, 1},
{"COFFSymbol.Type", Field, 1},
{"COFFSymbol.Value", Field, 1},
{"COFFSymbolAuxFormat5", Type, 19},
{"COFFSymbolAuxFormat5.Checksum", Field, 19},
{"COFFSymbolAuxFormat5.NumLineNumbers", Field, 19},
{"COFFSymbolAuxFormat5.NumRelocs", Field, 19},
{"COFFSymbolAuxFormat5.SecNum", Field, 19},
{"COFFSymbolAuxFormat5.Selection", Field, 19},
{"COFFSymbolAuxFormat5.Size", Field, 19},
{"COFFSymbolSize", Const, 1},
{"DataDirectory", Type, 3},
{"DataDirectory.Size", Field, 3},
{"DataDirectory.VirtualAddress", Field, 3},
{"File", Type, 0},
{"File.COFFSymbols", Field, 8},
{"File.FileHeader", Field, 0},
{"File.OptionalHeader", Field, 3},
{"File.Sections", Field, 0},
{"File.StringTable", Field, 8},
{"File.Symbols", Field, 1},
{"FileHeader", Type, 0},
{"FileHeader.Characteristics", Field, 0},
{"FileHeader.Machine", Field, 0},
{"FileHeader.NumberOfSections", Field, 0},
{"FileHeader.NumberOfSymbols", Field, 0},
{"FileHeader.PointerToSymbolTable", Field, 0},
{"FileHeader.SizeOfOptionalHeader", Field, 0},
{"FileHeader.TimeDateStamp", Field, 0},
{"FormatError", Type, 0},
{"IMAGE_COMDAT_SELECT_ANY", Const, 19},
{"IMAGE_COMDAT_SELECT_ASSOCIATIVE", Const, 19},
{"IMAGE_COMDAT_SELECT_EXACT_MATCH", Const, 19},
{"IMAGE_COMDAT_SELECT_LARGEST", Const, 19},
{"IMAGE_COMDAT_SELECT_NODUPLICATES", Const, 19},
{"IMAGE_COMDAT_SELECT_SAME_SIZE", Const, 19},
{"IMAGE_DIRECTORY_ENTRY_ARCHITECTURE", Const, 11},
{"IMAGE_DIRECTORY_ENTRY_BASERELOC", Const, 11},
{"IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT", Const, 11},
{"IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR", Const, 11},
{"IMAGE_DIRECTORY_ENTRY_DEBUG", Const, 11},
{"IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT", Const, 11},
{"IMAGE_DIRECTORY_ENTRY_EXCEPTION", Const, 11},
{"IMAGE_DIRECTORY_ENTRY_EXPORT", Const, 11},
{"IMAGE_DIRECTORY_ENTRY_GLOBALPTR", Const, 11},
{"IMAGE_DIRECTORY_ENTRY_IAT", Const, 11},
{"IMAGE_DIRECTORY_ENTRY_IMPORT", Const, 11},
{"IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG", Const, 11},
{"IMAGE_DIRECTORY_ENTRY_RESOURCE", Const, 11},
{"IMAGE_DIRECTORY_ENTRY_SECURITY", Const, 11},
{"IMAGE_DIRECTORY_ENTRY_TLS", Const, 11},
{"IMAGE_DLLCHARACTERISTICS_APPCONTAINER", Const, 15},
{"IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE", Const, 15},
{"IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY", Const, 15},
{"IMAGE_DLLCHARACTERISTICS_GUARD_CF", Const, 15},
{"IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA", Const, 15},
{"IMAGE_DLLCHARACTERISTICS_NO_BIND", Const, 15},
{"IMAGE_DLLCHARACTERISTICS_NO_ISOLATION", Const, 15},
{"IMAGE_DLLCHARACTERISTICS_NO_SEH", Const, 15},
{"IMAGE_DLLCHARACTERISTICS_NX_COMPAT", Const, 15},
{"IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE", Const, 15},
{"IMAGE_DLLCHARACTERISTICS_WDM_DRIVER", Const, 15},
{"IMAGE_FILE_32BIT_MACHINE", Const, 15},
{"IMAGE_FILE_AGGRESIVE_WS_TRIM", Const, 15},
{"IMAGE_FILE_BYTES_REVERSED_HI", Const, 15},
{"IMAGE_FILE_BYTES_REVERSED_LO", Const, 15},
{"IMAGE_FILE_DEBUG_STRIPPED", Const, 15},
{"IMAGE_FILE_DLL", Const, 15},
{"IMAGE_FILE_EXECUTABLE_IMAGE", Const, 15},
{"IMAGE_FILE_LARGE_ADDRESS_AWARE", Const, 15},
{"IMAGE_FILE_LINE_NUMS_STRIPPED", Const, 15},
{"IMAGE_FILE_LOCAL_SYMS_STRIPPED", Const, 15},
{"IMAGE_FILE_MACHINE_AM33", Const, 0},
{"IMAGE_FILE_MACHINE_AMD64", Const, 0},
{"IMAGE_FILE_MACHINE_ARM", Const, 0},
{"IMAGE_FILE_MACHINE_ARM64", Const, 11},
{"IMAGE_FILE_MACHINE_ARMNT", Const, 12},
{"IMAGE_FILE_MACHINE_EBC", Const, 0},
{"IMAGE_FILE_MACHINE_I386", Const, 0},
{"IMAGE_FILE_MACHINE_IA64", Const, 0},
{"IMAGE_FILE_MACHINE_LOONGARCH32", Const, 19},
{"IMAGE_FILE_MACHINE_LOONGARCH64", Const, 19},
{"IMAGE_FILE_MACHINE_M32R", Const, 0},
{"IMAGE_FILE_MACHINE_MIPS16", Const, 0},
{"IMAGE_FILE_MACHINE_MIPSFPU", Const, 0},
{"IMAGE_FILE_MACHINE_MIPSFPU16", Const, 0},
{"IMAGE_FILE_MACHINE_POWERPC", Const, 0},
{"IMAGE_FILE_MACHINE_POWERPCFP", Const, 0},
{"IMAGE_FILE_MACHINE_R4000", Const, 0},
{"IMAGE_FILE_MACHINE_RISCV128", Const, 20},
{"IMAGE_FILE_MACHINE_RISCV32", Const, 20},
{"IMAGE_FILE_MACHINE_RISCV64", Const, 20},
{"IMAGE_FILE_MACHINE_SH3", Const, 0},
{"IMAGE_FILE_MACHINE_SH3DSP", Const, 0},
{"IMAGE_FILE_MACHINE_SH4", Const, 0},
{"IMAGE_FILE_MACHINE_SH5", Const, 0},
{"IMAGE_FILE_MACHINE_THUMB", Const, 0},
{"IMAGE_FILE_MACHINE_UNKNOWN", Const, 0},
{"IMAGE_FILE_MACHINE_WCEMIPSV2", Const, 0},
{"IMAGE_FILE_NET_RUN_FROM_SWAP", Const, 15},
{"IMAGE_FILE_RELOCS_STRIPPED", Const, 15},
{"IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP", Const, 15},
{"IMAGE_FILE_SYSTEM", Const, 15},
{"IMAGE_FILE_UP_SYSTEM_ONLY", Const, 15},
{"IMAGE_SCN_CNT_CODE", Const, 19},
{"IMAGE_SCN_CNT_INITIALIZED_DATA", Const, 19},
{"IMAGE_SCN_CNT_UNINITIALIZED_DATA", Const, 19},
{"IMAGE_SCN_LNK_COMDAT", Const, 19},
{"IMAGE_SCN_MEM_DISCARDABLE", Const, 19},
{"IMAGE_SCN_MEM_EXECUTE", Const, 19},
{"IMAGE_SCN_MEM_READ", Const, 19},
{"IMAGE_SCN_MEM_WRITE", Const, 19},
{"IMAGE_SUBSYSTEM_EFI_APPLICATION", Const, 15},
{"IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER", Const, 15},
{"IMAGE_SUBSYSTEM_EFI_ROM", Const, 15},
{"IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER", Const, 15},
{"IMAGE_SUBSYSTEM_NATIVE", Const, 15},
{"IMAGE_SUBSYSTEM_NATIVE_WINDOWS", Const, 15},
{"IMAGE_SUBSYSTEM_OS2_CUI", Const, 15},
{"IMAGE_SUBSYSTEM_POSIX_CUI", Const, 15},
{"IMAGE_SUBSYSTEM_UNKNOWN", Const, 15},
{"IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION", Const, 15},
{"IMAGE_SUBSYSTEM_WINDOWS_CE_GUI", Const, 15},
{"IMAGE_SUBSYSTEM_WINDOWS_CUI", Const, 15},
{"IMAGE_SUBSYSTEM_WINDOWS_GUI", Const, 15},
{"IMAGE_SUBSYSTEM_XBOX", Const, 15},
{"ImportDirectory", Type, 0},
{"ImportDirectory.FirstThunk", Field, 0},
{"ImportDirectory.ForwarderChain", Field, 0},
{"ImportDirectory.Name", Field, 0},
{"ImportDirectory.OriginalFirstThunk", Field, 0},
{"ImportDirectory.TimeDateStamp", Field, 0},
{"NewFile", Func, 0},
{"Open", Func, 0},
{"OptionalHeader32", Type, 3},
{"OptionalHeader32.AddressOfEntryPoint", Field, 3},
{"OptionalHeader32.BaseOfCode", Field, 3},
{"OptionalHeader32.BaseOfData", Field, 3},
{"OptionalHeader32.CheckSum", Field, 3},
{"OptionalHeader32.DataDirectory", Field, 3},
{"OptionalHeader32.DllCharacteristics", Field, 3},
{"OptionalHeader32.FileAlignment", Field, 3},
{"OptionalHeader32.ImageBase", Field, 3},
{"OptionalHeader32.LoaderFlags", Field, 3},
{"OptionalHeader32.Magic", Field, 3},
{"OptionalHeader32.MajorImageVersion", Field, 3},
{"OptionalHeader32.MajorLinkerVersion", Field, 3},
{"OptionalHeader32.MajorOperatingSystemVersion", Field, 3},
{"OptionalHeader32.MajorSubsystemVersion", Field, 3},
{"OptionalHeader32.MinorImageVersion", Field, 3},
{"OptionalHeader32.MinorLinkerVersion", Field, 3},
{"OptionalHeader32.MinorOperatingSystemVersion", Field, 3},
{"OptionalHeader32.MinorSubsystemVersion", Field, 3},
{"OptionalHeader32.NumberOfRvaAndSizes", Field, 3},
{"OptionalHeader32.SectionAlignment", Field, 3},
{"OptionalHeader32.SizeOfCode", Field, 3},
{"OptionalHeader32.SizeOfHeaders", Field, 3},
{"OptionalHeader32.SizeOfHeapCommit", Field, 3},
{"OptionalHeader32.SizeOfHeapReserve", Field, 3},
{"OptionalHeader32.SizeOfImage", Field, 3},
{"OptionalHeader32.SizeOfInitializedData", Field, 3},
{"OptionalHeader32.SizeOfStackCommit", Field, 3},
{"OptionalHeader32.SizeOfStackReserve", Field, 3},
{"OptionalHeader32.SizeOfUninitializedData", Field, 3},
{"OptionalHeader32.Subsystem", Field, 3},
{"OptionalHeader32.Win32VersionValue", Field, 3},
{"OptionalHeader64", Type, 3},
{"OptionalHeader64.AddressOfEntryPoint", Field, 3},
{"OptionalHeader64.BaseOfCode", Field, 3},
{"OptionalHeader64.CheckSum", Field, 3},
{"OptionalHeader64.DataDirectory", Field, 3},
{"OptionalHeader64.DllCharacteristics", Field, 3},
{"OptionalHeader64.FileAlignment", Field, 3},
{"OptionalHeader64.ImageBase", Field, 3},
{"OptionalHeader64.LoaderFlags", Field, 3},
{"OptionalHeader64.Magic", Field, 3},
{"OptionalHeader64.MajorImageVersion", Field, 3},
{"OptionalHeader64.MajorLinkerVersion", Field, 3},
{"OptionalHeader64.MajorOperatingSystemVersion", Field, 3},
{"OptionalHeader64.MajorSubsystemVersion", Field, 3},
{"OptionalHeader64.MinorImageVersion", Field, 3},
{"OptionalHeader64.MinorLinkerVersion", Field, 3},
{"OptionalHeader64.MinorOperatingSystemVersion", Field, 3},
{"OptionalHeader64.MinorSubsystemVersion", Field, 3},
{"OptionalHeader64.NumberOfRvaAndSizes", Field, 3},
{"OptionalHeader64.SectionAlignment", Field, 3},
{"OptionalHeader64.SizeOfCode", Field, 3},
{"OptionalHeader64.SizeOfHeaders", Field, 3},
{"OptionalHeader64.SizeOfHeapCommit", Field, 3},
{"OptionalHeader64.SizeOfHeapReserve", Field, 3},
{"OptionalHeader64.SizeOfImage", Field, 3},
{"OptionalHeader64.SizeOfInitializedData", Field, 3},
{"OptionalHeader64.SizeOfStackCommit", Field, 3},
{"OptionalHeader64.SizeOfStackReserve", Field, 3},
{"OptionalHeader64.SizeOfUninitializedData", Field, 3},
{"OptionalHeader64.Subsystem", Field, 3},
{"OptionalHeader64.Win32VersionValue", Field, 3},
{"Reloc", Type, 8},
{"Reloc.SymbolTableIndex", Field, 8},
{"Reloc.Type", Field, 8},
{"Reloc.VirtualAddress", Field, 8},
{"Section", Type, 0},
{"Section.ReaderAt", Field, 0},
{"Section.Relocs", Field, 8},
{"Section.SectionHeader", Field, 0},
{"SectionHeader", Type, 0},
{"SectionHeader.Characteristics", Field, 0},
{"SectionHeader.Name", Field, 0},
{"SectionHeader.NumberOfLineNumbers", Field, 0},
{"SectionHeader.NumberOfRelocations", Field, 0},
{"SectionHeader.Offset", Field, 0},
{"SectionHeader.PointerToLineNumbers", Field, 0},
{"SectionHeader.PointerToRelocations", Field, 0},
{"SectionHeader.Size", Field, 0},
{"SectionHeader.VirtualAddress", Field, 0},
{"SectionHeader.VirtualSize", Field, 0},
{"SectionHeader32", Type, 0},
{"SectionHeader32.Characteristics", Field, 0},
{"SectionHeader32.Name", Field, 0},
{"SectionHeader32.NumberOfLineNumbers", Field, 0},
{"SectionHeader32.NumberOfRelocations", Field, 0},
{"SectionHeader32.PointerToLineNumbers", Field, 0},
{"SectionHeader32.PointerToRawData", Field, 0},
{"SectionHeader32.PointerToRelocations", Field, 0},
{"SectionHeader32.SizeOfRawData", Field, 0},
{"SectionHeader32.VirtualAddress", Field, 0},
{"SectionHeader32.VirtualSize", Field, 0},
{"StringTable", Type, 8},
{"Symbol", Type, 1},
{"Symbol.Name", Field, 1},
{"Symbol.SectionNumber", Field, 1},
{"Symbol.StorageClass", Field, 1},
{"Symbol.Type", Field, 1},
{"Symbol.Value", Field, 1},
},
"debug/plan9obj": {
{"(*File).Close", Method, 3},
{"(*File).Section", Method, 3},
{"(*File).Symbols", Method, 3},
{"(*Section).Data", Method, 3},
{"(*Section).Open", Method, 3},
{"(Section).ReadAt", Method, 3},
{"ErrNoSymbols", Var, 18},
{"File", Type, 3},
{"File.FileHeader", Field, 3},
{"File.Sections", Field, 3},
{"FileHeader", Type, 3},
{"FileHeader.Bss", Field, 3},
{"FileHeader.Entry", Field, 3},
{"FileHeader.HdrSize", Field, 4},
{"FileHeader.LoadAddress", Field, 4},
{"FileHeader.Magic", Field, 3},
{"FileHeader.PtrSize", Field, 3},
{"Magic386", Const, 3},
{"Magic64", Const, 3},
{"MagicAMD64", Const, 3},
{"MagicARM", Const, 3},
{"NewFile", Func, 3},
{"Open", Func, 3},
{"Section", Type, 3},
{"Section.ReaderAt", Field, 3},
{"Section.SectionHeader", Field, 3},
{"SectionHeader", Type, 3},
{"SectionHeader.Name", Field, 3},
{"SectionHeader.Offset", Field, 3},
{"SectionHeader.Size", Field, 3},
{"Sym", Type, 3},
{"Sym.Name", Field, 3},
{"Sym.Type", Field, 3},
{"Sym.Value", Field, 3},
},
"embed": {
{"(FS).Open", Method, 16},
{"(FS).ReadDir", Method, 16},
{"(FS).ReadFile", Method, 16},
{"FS", Type, 16},
},
"encoding": {
{"BinaryMarshaler", Type, 2},
{"BinaryUnmarshaler", Type, 2},
{"TextMarshaler", Type, 2},
{"TextUnmarshaler", Type, 2},
},
"encoding/ascii85": {
{"(CorruptInputError).Error", Method, 0},
{"CorruptInputError", Type, 0},
{"Decode", Func, 0},
{"Encode", Func, 0},
{"MaxEncodedLen", Func, 0},
{"NewDecoder", Func, 0},
{"NewEncoder", Func, 0},
},
"encoding/asn1": {
{"(BitString).At", Method, 0},
{"(BitString).RightAlign", Method, 0},
{"(ObjectIdentifier).Equal", Method, 0},
{"(ObjectIdentifier).String", Method, 3},
{"(StructuralError).Error", Method, 0},
{"(SyntaxError).Error", Method, 0},
{"BitString", Type, 0},
{"BitString.BitLength", Field, 0},
{"BitString.Bytes", Field, 0},
{"ClassApplication", Const, 6},
{"ClassContextSpecific", Const, 6},
{"ClassPrivate", Const, 6},
{"ClassUniversal", Const, 6},
{"Enumerated", Type, 0},
{"Flag", Type, 0},
{"Marshal", Func, 0},
{"MarshalWithParams", Func, 10},
{"NullBytes", Var, 9},
{"NullRawValue", Var, 9},
{"ObjectIdentifier", Type, 0},
{"RawContent", Type, 0},
{"RawValue", Type, 0},
{"RawValue.Bytes", Field, 0},
{"RawValue.Class", Field, 0},
{"RawValue.FullBytes", Field, 0},
{"RawValue.IsCompound", Field, 0},
{"RawValue.Tag", Field, 0},
{"StructuralError", Type, 0},
{"StructuralError.Msg", Field, 0},
{"SyntaxError", Type, 0},
{"SyntaxError.Msg", Field, 0},
{"TagBMPString", Const, 14},
{"TagBitString", Const, 6},
{"TagBoolean", Const, 6},
{"TagEnum", Const, 6},
{"TagGeneralString", Const, 6},
{"TagGeneralizedTime", Const, 6},
{"TagIA5String", Const, 6},
{"TagInteger", Const, 6},
{"TagNull", Const, 9},
{"TagNumericString", Const, 10},
{"TagOID", Const, 6},
{"TagOctetString", Const, 6},
{"TagPrintableString", Const, 6},
{"TagSequence", Const, 6},
{"TagSet", Const, 6},
{"TagT61String", Const, 6},
{"TagUTCTime", Const, 6},
{"TagUTF8String", Const, 6},
{"Unmarshal", Func, 0},
{"UnmarshalWithParams", Func, 0},
},
"encoding/base32": {
{"(*Encoding).AppendDecode", Method, 22},
{"(*Encoding).AppendEncode", Method, 22},
{"(*Encoding).Decode", Method, 0},
{"(*Encoding).DecodeString", Method, 0},
{"(*Encoding).DecodedLen", Method, 0},
{"(*Encoding).Encode", Method, 0},
{"(*Encoding).EncodeToString", Method, 0},
{"(*Encoding).EncodedLen", Method, 0},
{"(CorruptInputError).Error", Method, 0},
{"(Encoding).WithPadding", Method, 9},
{"CorruptInputError", Type, 0},
{"Encoding", Type, 0},
{"HexEncoding", Var, 0},
{"NewDecoder", Func, 0},
{"NewEncoder", Func, 0},
{"NewEncoding", Func, 0},
{"NoPadding", Const, 9},
{"StdEncoding", Var, 0},
{"StdPadding", Const, 9},
},
"encoding/base64": {
{"(*Encoding).AppendDecode", Method, 22},
{"(*Encoding).AppendEncode", Method, 22},
{"(*Encoding).Decode", Method, 0},
{"(*Encoding).DecodeString", Method, 0},
{"(*Encoding).DecodedLen", Method, 0},
{"(*Encoding).Encode", Method, 0},
{"(*Encoding).EncodeToString", Method, 0},
{"(*Encoding).EncodedLen", Method, 0},
{"(CorruptInputError).Error", Method, 0},
{"(Encoding).Strict", Method, 8},
{"(Encoding).WithPadding", Method, 5},
{"CorruptInputError", Type, 0},
{"Encoding", Type, 0},
{"NewDecoder", Func, 0},
{"NewEncoder", Func, 0},
{"NewEncoding", Func, 0},
{"NoPadding", Const, 5},
{"RawStdEncoding", Var, 5},
{"RawURLEncoding", Var, 5},
{"StdEncoding", Var, 0},
{"StdPadding", Const, 5},
{"URLEncoding", Var, 0},
},
"encoding/binary": {
{"Append", Func, 23},
{"AppendByteOrder", Type, 19},
{"AppendUvarint", Func, 19},
{"AppendVarint", Func, 19},
{"BigEndian", Var, 0},
{"ByteOrder", Type, 0},
{"Decode", Func, 23},
{"Encode", Func, 23},
{"LittleEndian", Var, 0},
{"MaxVarintLen16", Const, 0},
{"MaxVarintLen32", Const, 0},
{"MaxVarintLen64", Const, 0},
{"NativeEndian", Var, 21},
{"PutUvarint", Func, 0},
{"PutVarint", Func, 0},
{"Read", Func, 0},
{"ReadUvarint", Func, 0},
{"ReadVarint", Func, 0},
{"Size", Func, 0},
{"Uvarint", Func, 0},
{"Varint", Func, 0},
{"Write", Func, 0},
},
"encoding/csv": {
{"(*ParseError).Error", Method, 0},
{"(*ParseError).Unwrap", Method, 13},
{"(*Reader).FieldPos", Method, 17},
{"(*Reader).InputOffset", Method, 19},
{"(*Reader).Read", Method, 0},
{"(*Reader).ReadAll", Method, 0},
{"(*Writer).Error", Method, 1},
{"(*Writer).Flush", Method, 0},
{"(*Writer).Write", Method, 0},
{"(*Writer).WriteAll", Method, 0},
{"ErrBareQuote", Var, 0},
{"ErrFieldCount", Var, 0},
{"ErrQuote", Var, 0},
{"ErrTrailingComma", Var, 0},
{"NewReader", Func, 0},
{"NewWriter", Func, 0},
{"ParseError", Type, 0},
{"ParseError.Column", Field, 0},
{"ParseError.Err", Field, 0},
{"ParseError.Line", Field, 0},
{"ParseError.StartLine", Field, 10},
{"Reader", Type, 0},
{"Reader.Comma", Field, 0},
{"Reader.Comment", Field, 0},
{"Reader.FieldsPerRecord", Field, 0},
{"Reader.LazyQuotes", Field, 0},
{"Reader.ReuseRecord", Field, 9},
{"Reader.TrailingComma", Field, 0},
{"Reader.TrimLeadingSpace", Field, 0},
{"Writer", Type, 0},
{"Writer.Comma", Field, 0},
{"Writer.UseCRLF", Field, 0},
},
"encoding/gob": {
{"(*Decoder).Decode", Method, 0},
{"(*Decoder).DecodeValue", Method, 0},
{"(*Encoder).Encode", Method, 0},
{"(*Encoder).EncodeValue", Method, 0},
{"CommonType", Type, 0},
{"CommonType.Id", Field, 0},
{"CommonType.Name", Field, 0},
{"Decoder", Type, 0},
{"Encoder", Type, 0},
{"GobDecoder", Type, 0},
{"GobEncoder", Type, 0},
{"NewDecoder", Func, 0},
{"NewEncoder", Func, 0},
{"Register", Func, 0},
{"RegisterName", Func, 0},
},
"encoding/hex": {
{"(InvalidByteError).Error", Method, 0},
{"AppendDecode", Func, 22},
{"AppendEncode", Func, 22},
{"Decode", Func, 0},
{"DecodeString", Func, 0},
{"DecodedLen", Func, 0},
{"Dump", Func, 0},
{"Dumper", Func, 0},
{"Encode", Func, 0},
{"EncodeToString", Func, 0},
{"EncodedLen", Func, 0},
{"ErrLength", Var, 0},
{"InvalidByteError", Type, 0},
{"NewDecoder", Func, 10},
{"NewEncoder", Func, 10},
},
"encoding/json": {
{"(*Decoder).Buffered", Method, 1},
{"(*Decoder).Decode", Method, 0},
{"(*Decoder).DisallowUnknownFields", Method, 10},
{"(*Decoder).InputOffset", Method, 14},
{"(*Decoder).More", Method, 5},
{"(*Decoder).Token", Method, 5},
{"(*Decoder).UseNumber", Method, 1},
{"(*Encoder).Encode", Method, 0},
{"(*Encoder).SetEscapeHTML", Method, 7},
{"(*Encoder).SetIndent", Method, 7},
{"(*InvalidUTF8Error).Error", Method, 0},
{"(*InvalidUnmarshalError).Error", Method, 0},
{"(*MarshalerError).Error", Method, 0},
{"(*MarshalerError).Unwrap", Method, 13},
{"(*RawMessage).MarshalJSON", Method, 0},
{"(*RawMessage).UnmarshalJSON", Method, 0},
{"(*SyntaxError).Error", Method, 0},
{"(*UnmarshalFieldError).Error", Method, 0},
{"(*UnmarshalTypeError).Error", Method, 0},
{"(*UnsupportedTypeError).Error", Method, 0},
{"(*UnsupportedValueError).Error", Method, 0},
{"(Delim).String", Method, 5},
{"(Number).Float64", Method, 1},
{"(Number).Int64", Method, 1},
{"(Number).String", Method, 1},
{"(RawMessage).MarshalJSON", Method, 8},
{"Compact", Func, 0},
{"Decoder", Type, 0},
{"Delim", Type, 5},
{"Encoder", Type, 0},
{"HTMLEscape", Func, 0},
{"Indent", Func, 0},
{"InvalidUTF8Error", Type, 0},
{"InvalidUTF8Error.S", Field, 0},
{"InvalidUnmarshalError", Type, 0},
{"InvalidUnmarshalError.Type", Field, 0},
{"Marshal", Func, 0},
{"MarshalIndent", Func, 0},
{"Marshaler", Type, 0},
{"MarshalerError", Type, 0},
{"MarshalerError.Err", Field, 0},
{"MarshalerError.Type", Field, 0},
{"NewDecoder", Func, 0},
{"NewEncoder", Func, 0},
{"Number", Type, 1},
{"RawMessage", Type, 0},
{"SyntaxError", Type, 0},
{"SyntaxError.Offset", Field, 0},
{"Token", Type, 5},
{"Unmarshal", Func, 0},
{"UnmarshalFieldError", Type, 0},
{"UnmarshalFieldError.Field", Field, 0},
{"UnmarshalFieldError.Key", Field, 0},
{"UnmarshalFieldError.Type", Field, 0},
{"UnmarshalTypeError", Type, 0},
{"UnmarshalTypeError.Field", Field, 8},
{"UnmarshalTypeError.Offset", Field, 5},
{"UnmarshalTypeError.Struct", Field, 8},
{"UnmarshalTypeError.Type", Field, 0},
{"UnmarshalTypeError.Value", Field, 0},
{"Unmarshaler", Type, 0},
{"UnsupportedTypeError", Type, 0},
{"UnsupportedTypeError.Type", Field, 0},
{"UnsupportedValueError", Type, 0},
{"UnsupportedValueError.Str", Field, 0},
{"UnsupportedValueError.Value", Field, 0},
{"Valid", Func, 9},
},
"encoding/pem": {
{"Block", Type, 0},
{"Block.Bytes", Field, 0},
{"Block.Headers", Field, 0},
{"Block.Type", Field, 0},
{"Decode", Func, 0},
{"Encode", Func, 0},
{"EncodeToMemory", Func, 0},
},
"encoding/xml": {
{"(*Decoder).Decode", Method, 0},
{"(*Decoder).DecodeElement", Method, 0},
{"(*Decoder).InputOffset", Method, 4},
{"(*Decoder).InputPos", Method, 19},
{"(*Decoder).RawToken", Method, 0},
{"(*Decoder).Skip", Method, 0},
{"(*Decoder).Token", Method, 0},
{"(*Encoder).Close", Method, 20},
{"(*Encoder).Encode", Method, 0},
{"(*Encoder).EncodeElement", Method, 2},
{"(*Encoder).EncodeToken", Method, 2},
{"(*Encoder).Flush", Method, 2},
{"(*Encoder).Indent", Method, 1},
{"(*SyntaxError).Error", Method, 0},
{"(*TagPathError).Error", Method, 0},
{"(*UnsupportedTypeError).Error", Method, 0},
{"(CharData).Copy", Method, 0},
{"(Comment).Copy", Method, 0},
{"(Directive).Copy", Method, 0},
{"(ProcInst).Copy", Method, 0},
{"(StartElement).Copy", Method, 0},
{"(StartElement).End", Method, 2},
{"(UnmarshalError).Error", Method, 0},
{"Attr", Type, 0},
{"Attr.Name", Field, 0},
{"Attr.Value", Field, 0},
{"CharData", Type, 0},
{"Comment", Type, 0},
{"CopyToken", Func, 0},
{"Decoder", Type, 0},
{"Decoder.AutoClose", Field, 0},
{"Decoder.CharsetReader", Field, 0},
{"Decoder.DefaultSpace", Field, 1},
{"Decoder.Entity", Field, 0},
{"Decoder.Strict", Field, 0},
{"Directive", Type, 0},
{"Encoder", Type, 0},
{"EndElement", Type, 0},
{"EndElement.Name", Field, 0},
{"Escape", Func, 0},
{"EscapeText", Func, 1},
{"HTMLAutoClose", Var, 0},
{"HTMLEntity", Var, 0},
{"Header", Const, 0},
{"Marshal", Func, 0},
{"MarshalIndent", Func, 0},
{"Marshaler", Type, 2},
{"MarshalerAttr", Type, 2},
{"Name", Type, 0},
{"Name.Local", Field, 0},
{"Name.Space", Field, 0},
{"NewDecoder", Func, 0},
{"NewEncoder", Func, 0},
{"NewTokenDecoder", Func, 10},
{"ProcInst", Type, 0},
{"ProcInst.Inst", Field, 0},
{"ProcInst.Target", Field, 0},
{"StartElement", Type, 0},
{"StartElement.Attr", Field, 0},
{"StartElement.Name", Field, 0},
{"SyntaxError", Type, 0},
{"SyntaxError.Line", Field, 0},
{"SyntaxError.Msg", Field, 0},
{"TagPathError", Type, 0},
{"TagPathError.Field1", Field, 0},
{"TagPathError.Field2", Field, 0},
{"TagPathError.Struct", Field, 0},
{"TagPathError.Tag1", Field, 0},
{"TagPathError.Tag2", Field, 0},
{"Token", Type, 0},
{"TokenReader", Type, 10},
{"Unmarshal", Func, 0},
{"UnmarshalError", Type, 0},
{"Unmarshaler", Type, 2},
{"UnmarshalerAttr", Type, 2},
{"UnsupportedTypeError", Type, 0},
{"UnsupportedTypeError.Type", Field, 0},
},
"errors": {
{"As", Func, 13},
{"ErrUnsupported", Var, 21},
{"Is", Func, 13},
{"Join", Func, 20},
{"New", Func, 0},
{"Unwrap", Func, 13},
},
"expvar": {
{"(*Float).Add", Method, 0},
{"(*Float).Set", Method, 0},
{"(*Float).String", Method, 0},
{"(*Float).Value", Method, 8},
{"(*Int).Add", Method, 0},
{"(*Int).Set", Method, 0},
{"(*Int).String", Method, 0},
{"(*Int).Value", Method, 8},
{"(*Map).Add", Method, 0},
{"(*Map).AddFloat", Method, 0},
{"(*Map).Delete", Method, 12},
{"(*Map).Do", Method, 0},
{"(*Map).Get", Method, 0},
{"(*Map).Init", Method, 0},
{"(*Map).Set", Method, 0},
{"(*Map).String", Method, 0},
{"(*String).Set", Method, 0},
{"(*String).String", Method, 0},
{"(*String).Value", Method, 8},
{"(Func).String", Method, 0},
{"(Func).Value", Method, 8},
{"Do", Func, 0},
{"Float", Type, 0},
{"Func", Type, 0},
{"Get", Func, 0},
{"Handler", Func, 8},
{"Int", Type, 0},
{"KeyValue", Type, 0},
{"KeyValue.Key", Field, 0},
{"KeyValue.Value", Field, 0},
{"Map", Type, 0},
{"NewFloat", Func, 0},
{"NewInt", Func, 0},
{"NewMap", Func, 0},
{"NewString", Func, 0},
{"Publish", Func, 0},
{"String", Type, 0},
{"Var", Type, 0},
},
"flag": {
{"(*FlagSet).Arg", Method, 0},
{"(*FlagSet).Args", Method, 0},
{"(*FlagSet).Bool", Method, 0},
{"(*FlagSet).BoolFunc", Method, 21},
{"(*FlagSet).BoolVar", Method, 0},
{"(*FlagSet).Duration", Method, 0},
{"(*FlagSet).DurationVar", Method, 0},
{"(*FlagSet).ErrorHandling", Method, 10},
{"(*FlagSet).Float64", Method, 0},
{"(*FlagSet).Float64Var", Method, 0},
{"(*FlagSet).Func", Method, 16},
{"(*FlagSet).Init", Method, 0},
{"(*FlagSet).Int", Method, 0},
{"(*FlagSet).Int64", Method, 0},
{"(*FlagSet).Int64Var", Method, 0},
{"(*FlagSet).IntVar", Method, 0},
{"(*FlagSet).Lookup", Method, 0},
{"(*FlagSet).NArg", Method, 0},
{"(*FlagSet).NFlag", Method, 0},
{"(*FlagSet).Name", Method, 10},
{"(*FlagSet).Output", Method, 10},
{"(*FlagSet).Parse", Method, 0},
{"(*FlagSet).Parsed", Method, 0},
{"(*FlagSet).PrintDefaults", Method, 0},
{"(*FlagSet).Set", Method, 0},
{"(*FlagSet).SetOutput", Method, 0},
{"(*FlagSet).String", Method, 0},
{"(*FlagSet).StringVar", Method, 0},
{"(*FlagSet).TextVar", Method, 19},
{"(*FlagSet).Uint", Method, 0},
{"(*FlagSet).Uint64", Method, 0},
{"(*FlagSet).Uint64Var", Method, 0},
{"(*FlagSet).UintVar", Method, 0},
{"(*FlagSet).Var", Method, 0},
{"(*FlagSet).Visit", Method, 0},
{"(*FlagSet).VisitAll", Method, 0},
{"Arg", Func, 0},
{"Args", Func, 0},
{"Bool", Func, 0},
{"BoolFunc", Func, 21},
{"BoolVar", Func, 0},
{"CommandLine", Var, 2},
{"ContinueOnError", Const, 0},
{"Duration", Func, 0},
{"DurationVar", Func, 0},
{"ErrHelp", Var, 0},
{"ErrorHandling", Type, 0},
{"ExitOnError", Const, 0},
{"Flag", Type, 0},
{"Flag.DefValue", Field, 0},
{"Flag.Name", Field, 0},
{"Flag.Usage", Field, 0},
{"Flag.Value", Field, 0},
{"FlagSet", Type, 0},
{"FlagSet.Usage", Field, 0},
{"Float64", Func, 0},
{"Float64Var", Func, 0},
{"Func", Func, 16},
{"Getter", Type, 2},
{"Int", Func, 0},
{"Int64", Func, 0},
{"Int64Var", Func, 0},
{"IntVar", Func, 0},
{"Lookup", Func, 0},
{"NArg", Func, 0},
{"NFlag", Func, 0},
{"NewFlagSet", Func, 0},
{"PanicOnError", Const, 0},
{"Parse", Func, 0},
{"Parsed", Func, 0},
{"PrintDefaults", Func, 0},
{"Set", Func, 0},
{"String", Func, 0},
{"StringVar", Func, 0},
{"TextVar", Func, 19},
{"Uint", Func, 0},
{"Uint64", Func, 0},
{"Uint64Var", Func, 0},
{"UintVar", Func, 0},
{"UnquoteUsage", Func, 5},
{"Usage", Var, 0},
{"Value", Type, 0},
{"Var", Func, 0},
{"Visit", Func, 0},
{"VisitAll", Func, 0},
},
"fmt": {
{"Append", Func, 19},
{"Appendf", Func, 19},
{"Appendln", Func, 19},
{"Errorf", Func, 0},
{"FormatString", Func, 20},
{"Formatter", Type, 0},
{"Fprint", Func, 0},
{"Fprintf", Func, 0},
{"Fprintln", Func, 0},
{"Fscan", Func, 0},
{"Fscanf", Func, 0},
{"Fscanln", Func, 0},
{"GoStringer", Type, 0},
{"Print", Func, 0},
{"Printf", Func, 0},
{"Println", Func, 0},
{"Scan", Func, 0},
{"ScanState", Type, 0},
{"Scanf", Func, 0},
{"Scanln", Func, 0},
{"Scanner", Type, 0},
{"Sprint", Func, 0},
{"Sprintf", Func, 0},
{"Sprintln", Func, 0},
{"Sscan", Func, 0},
{"Sscanf", Func, 0},
{"Sscanln", Func, 0},
{"State", Type, 0},
{"Stringer", Type, 0},
},
"go/ast": {
{"(*ArrayType).End", Method, 0},
{"(*ArrayType).Pos", Method, 0},
{"(*AssignStmt).End", Method, 0},
{"(*AssignStmt).Pos", Method, 0},
{"(*BadDecl).End", Method, 0},
{"(*BadDecl).Pos", Method, 0},
{"(*BadExpr).End", Method, 0},
{"(*BadExpr).Pos", Method, 0},
{"(*BadStmt).End", Method, 0},
{"(*BadStmt).Pos", Method, 0},
{"(*BasicLit).End", Method, 0},
{"(*BasicLit).Pos", Method, 0},
{"(*BinaryExpr).End", Method, 0},
{"(*BinaryExpr).Pos", Method, 0},
{"(*BlockStmt).End", Method, 0},
{"(*BlockStmt).Pos", Method, 0},
{"(*BranchStmt).End", Method, 0},
{"(*BranchStmt).Pos", Method, 0},
{"(*CallExpr).End", Method, 0},
{"(*CallExpr).Pos", Method, 0},
{"(*CaseClause).End", Method, 0},
{"(*CaseClause).Pos", Method, 0},
{"(*ChanType).End", Method, 0},
{"(*ChanType).Pos", Method, 0},
{"(*CommClause).End", Method, 0},
{"(*CommClause).Pos", Method, 0},
{"(*Comment).End", Method, 0},
{"(*Comment).Pos", Method, 0},
{"(*CommentGroup).End", Method, 0},
{"(*CommentGroup).Pos", Method, 0},
{"(*CommentGroup).Text", Method, 0},
{"(*CompositeLit).End", Method, 0},
{"(*CompositeLit).Pos", Method, 0},
{"(*DeclStmt).End", Method, 0},
{"(*DeclStmt).Pos", Method, 0},
{"(*DeferStmt).End", Method, 0},
{"(*DeferStmt).Pos", Method, 0},
{"(*Ellipsis).End", Method, 0},
{"(*Ellipsis).Pos", Method, 0},
{"(*EmptyStmt).End", Method, 0},
{"(*EmptyStmt).Pos", Method, 0},
{"(*ExprStmt).End", Method, 0},
{"(*ExprStmt).Pos", Method, 0},
{"(*Field).End", Method, 0},
{"(*Field).Pos", Method, 0},
{"(*FieldList).End", Method, 0},
{"(*FieldList).NumFields", Method, 0},
{"(*FieldList).Pos", Method, 0},
{"(*File).End", Method, 0},
{"(*File).Pos", Method, 0},
{"(*ForStmt).End", Method, 0},
{"(*ForStmt).Pos", Method, 0},
{"(*FuncDecl).End", Method, 0},
{"(*FuncDecl).Pos", Method, 0},
{"(*FuncLit).End", Method, 0},
{"(*FuncLit).Pos", Method, 0},
{"(*FuncType).End", Method, 0},
{"(*FuncType).Pos", Method, 0},
{"(*GenDecl).End", Method, 0},
{"(*GenDecl).Pos", Method, 0},
{"(*GoStmt).End", Method, 0},
{"(*GoStmt).Pos", Method, 0},
{"(*Ident).End", Method, 0},
{"(*Ident).IsExported", Method, 0},
{"(*Ident).Pos", Method, 0},
{"(*Ident).String", Method, 0},
{"(*IfStmt).End", Method, 0},
{"(*IfStmt).Pos", Method, 0},
{"(*ImportSpec).End", Method, 0},
{"(*ImportSpec).Pos", Method, 0},
{"(*IncDecStmt).End", Method, 0},
{"(*IncDecStmt).Pos", Method, 0},
{"(*IndexExpr).End", Method, 0},
{"(*IndexExpr).Pos", Method, 0},
{"(*IndexListExpr).End", Method, 18},
{"(*IndexListExpr).Pos", Method, 18},
{"(*InterfaceType).End", Method, 0},
{"(*InterfaceType).Pos", Method, 0},
{"(*KeyValueExpr).End", Method, 0},
{"(*KeyValueExpr).Pos", Method, 0},
{"(*LabeledStmt).End", Method, 0},
{"(*LabeledStmt).Pos", Method, 0},
{"(*MapType).End", Method, 0},
{"(*MapType).Pos", Method, 0},
{"(*Object).Pos", Method, 0},
{"(*Package).End", Method, 0},
{"(*Package).Pos", Method, 0},
{"(*ParenExpr).End", Method, 0},
{"(*ParenExpr).Pos", Method, 0},
{"(*RangeStmt).End", Method, 0},
{"(*RangeStmt).Pos", Method, 0},
{"(*ReturnStmt).End", Method, 0},
{"(*ReturnStmt).Pos", Method, 0},
{"(*Scope).Insert", Method, 0},
{"(*Scope).Lookup", Method, 0},
{"(*Scope).String", Method, 0},
{"(*SelectStmt).End", Method, 0},
{"(*SelectStmt).Pos", Method, 0},
{"(*SelectorExpr).End", Method, 0},
{"(*SelectorExpr).Pos", Method, 0},
{"(*SendStmt).End", Method, 0},
{"(*SendStmt).Pos", Method, 0},
{"(*SliceExpr).End", Method, 0},
{"(*SliceExpr).Pos", Method, 0},
{"(*StarExpr).End", Method, 0},
{"(*StarExpr).Pos", Method, 0},
{"(*StructType).End", Method, 0},
{"(*StructType).Pos", Method, 0},
{"(*SwitchStmt).End", Method, 0},
{"(*SwitchStmt).Pos", Method, 0},
{"(*TypeAssertExpr).End", Method, 0},
{"(*TypeAssertExpr).Pos", Method, 0},
{"(*TypeSpec).End", Method, 0},
{"(*TypeSpec).Pos", Method, 0},
{"(*TypeSwitchStmt).End", Method, 0},
{"(*TypeSwitchStmt).Pos", Method, 0},
{"(*UnaryExpr).End", Method, 0},
{"(*UnaryExpr).Pos", Method, 0},
{"(*ValueSpec).End", Method, 0},
{"(*ValueSpec).Pos", Method, 0},
{"(CommentMap).Comments", Method, 1},
{"(CommentMap).Filter", Method, 1},
{"(CommentMap).String", Method, 1},
{"(CommentMap).Update", Method, 1},
{"(ObjKind).String", Method, 0},
{"ArrayType", Type, 0},
{"ArrayType.Elt", Field, 0},
{"ArrayType.Lbrack", Field, 0},
{"ArrayType.Len", Field, 0},
{"AssignStmt", Type, 0},
{"AssignStmt.Lhs", Field, 0},
{"AssignStmt.Rhs", Field, 0},
{"AssignStmt.Tok", Field, 0},
{"AssignStmt.TokPos", Field, 0},
{"Bad", Const, 0},
{"BadDecl", Type, 0},
{"BadDecl.From", Field, 0},
{"BadDecl.To", Field, 0},
{"BadExpr", Type, 0},
{"BadExpr.From", Field, 0},
{"BadExpr.To", Field, 0},
{"BadStmt", Type, 0},
{"BadStmt.From", Field, 0},
{"BadStmt.To", Field, 0},
{"BasicLit", Type, 0},
{"BasicLit.Kind", Field, 0},
{"BasicLit.Value", Field, 0},
{"BasicLit.ValuePos", Field, 0},
{"BinaryExpr", Type, 0},
{"BinaryExpr.Op", Field, 0},
{"BinaryExpr.OpPos", Field, 0},
{"BinaryExpr.X", Field, 0},
{"BinaryExpr.Y", Field, 0},
{"BlockStmt", Type, 0},
{"BlockStmt.Lbrace", Field, 0},
{"BlockStmt.List", Field, 0},
{"BlockStmt.Rbrace", Field, 0},
{"BranchStmt", Type, 0},
{"BranchStmt.Label", Field, 0},
{"BranchStmt.Tok", Field, 0},
{"BranchStmt.TokPos", Field, 0},
{"CallExpr", Type, 0},
{"CallExpr.Args", Field, 0},
{"CallExpr.Ellipsis", Field, 0},
{"CallExpr.Fun", Field, 0},
{"CallExpr.Lparen", Field, 0},
{"CallExpr.Rparen", Field, 0},
{"CaseClause", Type, 0},
{"CaseClause.Body", Field, 0},
{"CaseClause.Case", Field, 0},
{"CaseClause.Colon", Field, 0},
{"CaseClause.List", Field, 0},
{"ChanDir", Type, 0},
{"ChanType", Type, 0},
{"ChanType.Arrow", Field, 1},
{"ChanType.Begin", Field, 0},
{"ChanType.Dir", Field, 0},
{"ChanType.Value", Field, 0},
{"CommClause", Type, 0},
{"CommClause.Body", Field, 0},
{"CommClause.Case", Field, 0},
{"CommClause.Colon", Field, 0},
{"CommClause.Comm", Field, 0},
{"Comment", Type, 0},
{"Comment.Slash", Field, 0},
{"Comment.Text", Field, 0},
{"CommentGroup", Type, 0},
{"CommentGroup.List", Field, 0},
{"CommentMap", Type, 1},
{"CompositeLit", Type, 0},
{"CompositeLit.Elts", Field, 0},
{"CompositeLit.Incomplete", Field, 11},
{"CompositeLit.Lbrace", Field, 0},
{"CompositeLit.Rbrace", Field, 0},
{"CompositeLit.Type", Field, 0},
{"Con", Const, 0},
{"Decl", Type, 0},
{"DeclStmt", Type, 0},
{"DeclStmt.Decl", Field, 0},
{"DeferStmt", Type, 0},
{"DeferStmt.Call", Field, 0},
{"DeferStmt.Defer", Field, 0},
{"Ellipsis", Type, 0},
{"Ellipsis.Ellipsis", Field, 0},
{"Ellipsis.Elt", Field, 0},
{"EmptyStmt", Type, 0},
{"EmptyStmt.Implicit", Field, 5},
{"EmptyStmt.Semicolon", Field, 0},
{"Expr", Type, 0},
{"ExprStmt", Type, 0},
{"ExprStmt.X", Field, 0},
{"Field", Type, 0},
{"Field.Comment", Field, 0},
{"Field.Doc", Field, 0},
{"Field.Names", Field, 0},
{"Field.Tag", Field, 0},
{"Field.Type", Field, 0},
{"FieldFilter", Type, 0},
{"FieldList", Type, 0},
{"FieldList.Closing", Field, 0},
{"FieldList.List", Field, 0},
{"FieldList.Opening", Field, 0},
{"File", Type, 0},
{"File.Comments", Field, 0},
{"File.Decls", Field, 0},
{"File.Doc", Field, 0},
{"File.FileEnd", Field, 20},
{"File.FileStart", Field, 20},
{"File.GoVersion", Field, 21},
{"File.Imports", Field, 0},
{"File.Name", Field, 0},
{"File.Package", Field, 0},
{"File.Scope", Field, 0},
{"File.Unresolved", Field, 0},
{"FileExports", Func, 0},
{"Filter", Type, 0},
{"FilterDecl", Func, 0},
{"FilterFile", Func, 0},
{"FilterFuncDuplicates", Const, 0},
{"FilterImportDuplicates", Const, 0},
{"FilterPackage", Func, 0},
{"FilterUnassociatedComments", Const, 0},
{"ForStmt", Type, 0},
{"ForStmt.Body", Field, 0},
{"ForStmt.Cond", Field, 0},
{"ForStmt.For", Field, 0},
{"ForStmt.Init", Field, 0},
{"ForStmt.Post", Field, 0},
{"Fprint", Func, 0},
{"Fun", Const, 0},
{"FuncDecl", Type, 0},
{"FuncDecl.Body", Field, 0},
{"FuncDecl.Doc", Field, 0},
{"FuncDecl.Name", Field, 0},
{"FuncDecl.Recv", Field, 0},
{"FuncDecl.Type", Field, 0},
{"FuncLit", Type, 0},
{"FuncLit.Body", Field, 0},
{"FuncLit.Type", Field, 0},
{"FuncType", Type, 0},
{"FuncType.Func", Field, 0},
{"FuncType.Params", Field, 0},
{"FuncType.Results", Field, 0},
{"FuncType.TypeParams", Field, 18},
{"GenDecl", Type, 0},
{"GenDecl.Doc", Field, 0},
{"GenDecl.Lparen", Field, 0},
{"GenDecl.Rparen", Field, 0},
{"GenDecl.Specs", Field, 0},
{"GenDecl.Tok", Field, 0},
{"GenDecl.TokPos", Field, 0},
{"GoStmt", Type, 0},
{"GoStmt.Call", Field, 0},
{"GoStmt.Go", Field, 0},
{"Ident", Type, 0},
{"Ident.Name", Field, 0},
{"Ident.NamePos", Field, 0},
{"Ident.Obj", Field, 0},
{"IfStmt", Type, 0},
{"IfStmt.Body", Field, 0},
{"IfStmt.Cond", Field, 0},
{"IfStmt.Else", Field, 0},
{"IfStmt.If", Field, 0},
{"IfStmt.Init", Field, 0},
{"ImportSpec", Type, 0},
{"ImportSpec.Comment", Field, 0},
{"ImportSpec.Doc", Field, 0},
{"ImportSpec.EndPos", Field, 0},
{"ImportSpec.Name", Field, 0},
{"ImportSpec.Path", Field, 0},
{"Importer", Type, 0},
{"IncDecStmt", Type, 0},
{"IncDecStmt.Tok", Field, 0},
{"IncDecStmt.TokPos", Field, 0},
{"IncDecStmt.X", Field, 0},
{"IndexExpr", Type, 0},
{"IndexExpr.Index", Field, 0},
{"IndexExpr.Lbrack", Field, 0},
{"IndexExpr.Rbrack", Field, 0},
{"IndexExpr.X", Field, 0},
{"IndexListExpr", Type, 18},
{"IndexListExpr.Indices", Field, 18},
{"IndexListExpr.Lbrack", Field, 18},
{"IndexListExpr.Rbrack", Field, 18},
{"IndexListExpr.X", Field, 18},
{"Inspect", Func, 0},
{"InterfaceType", Type, 0},
{"InterfaceType.Incomplete", Field, 0},
{"InterfaceType.Interface", Field, 0},
{"InterfaceType.Methods", Field, 0},
{"IsExported", Func, 0},
{"IsGenerated", Func, 21},
{"KeyValueExpr", Type, 0},
{"KeyValueExpr.Colon", Field, 0},
{"KeyValueExpr.Key", Field, 0},
{"KeyValueExpr.Value", Field, 0},
{"LabeledStmt", Type, 0},
{"LabeledStmt.Colon", Field, 0},
{"LabeledStmt.Label", Field, 0},
{"LabeledStmt.Stmt", Field, 0},
{"Lbl", Const, 0},
{"MapType", Type, 0},
{"MapType.Key", Field, 0},
{"MapType.Map", Field, 0},
{"MapType.Value", Field, 0},
{"MergeMode", Type, 0},
{"MergePackageFiles", Func, 0},
{"NewCommentMap", Func, 1},
{"NewIdent", Func, 0},
{"NewObj", Func, 0},
{"NewPackage", Func, 0},
{"NewScope", Func, 0},
{"Node", Type, 0},
{"NotNilFilter", Func, 0},
{"ObjKind", Type, 0},
{"Object", Type, 0},
{"Object.Data", Field, 0},
{"Object.Decl", Field, 0},
{"Object.Kind", Field, 0},
{"Object.Name", Field, 0},
{"Object.Type", Field, 0},
{"Package", Type, 0},
{"Package.Files", Field, 0},
{"Package.Imports", Field, 0},
{"Package.Name", Field, 0},
{"Package.Scope", Field, 0},
{"PackageExports", Func, 0},
{"ParenExpr", Type, 0},
{"ParenExpr.Lparen", Field, 0},
{"ParenExpr.Rparen", Field, 0},
{"ParenExpr.X", Field, 0},
{"Pkg", Const, 0},
{"Preorder", Func, 23},
{"Print", Func, 0},
{"RECV", Const, 0},
{"RangeStmt", Type, 0},
{"RangeStmt.Body", Field, 0},
{"RangeStmt.For", Field, 0},
{"RangeStmt.Key", Field, 0},
{"RangeStmt.Range", Field, 20},
{"RangeStmt.Tok", Field, 0},
{"RangeStmt.TokPos", Field, 0},
{"RangeStmt.Value", Field, 0},
{"RangeStmt.X", Field, 0},
{"ReturnStmt", Type, 0},
{"ReturnStmt.Results", Field, 0},
{"ReturnStmt.Return", Field, 0},
{"SEND", Const, 0},
{"Scope", Type, 0},
{"Scope.Objects", Field, 0},
{"Scope.Outer", Field, 0},
{"SelectStmt", Type, 0},
{"SelectStmt.Body", Field, 0},
{"SelectStmt.Select", Field, 0},
{"SelectorExpr", Type, 0},
{"SelectorExpr.Sel", Field, 0},
{"SelectorExpr.X", Field, 0},
{"SendStmt", Type, 0},
{"SendStmt.Arrow", Field, 0},
{"SendStmt.Chan", Field, 0},
{"SendStmt.Value", Field, 0},
{"SliceExpr", Type, 0},
{"SliceExpr.High", Field, 0},
{"SliceExpr.Lbrack", Field, 0},
{"SliceExpr.Low", Field, 0},
{"SliceExpr.Max", Field, 2},
{"SliceExpr.Rbrack", Field, 0},
{"SliceExpr.Slice3", Field, 2},
{"SliceExpr.X", Field, 0},
{"SortImports", Func, 0},
{"Spec", Type, 0},
{"StarExpr", Type, 0},
{"StarExpr.Star", Field, 0},
{"StarExpr.X", Field, 0},
{"Stmt", Type, 0},
{"StructType", Type, 0},
{"StructType.Fields", Field, 0},
{"StructType.Incomplete", Field, 0},
{"StructType.Struct", Field, 0},
{"SwitchStmt", Type, 0},
{"SwitchStmt.Body", Field, 0},
{"SwitchStmt.Init", Field, 0},
{"SwitchStmt.Switch", Field, 0},
{"SwitchStmt.Tag", Field, 0},
{"Typ", Const, 0},
{"TypeAssertExpr", Type, 0},
{"TypeAssertExpr.Lparen", Field, 2},
{"TypeAssertExpr.Rparen", Field, 2},
{"TypeAssertExpr.Type", Field, 0},
{"TypeAssertExpr.X", Field, 0},
{"TypeSpec", Type, 0},
{"TypeSpec.Assign", Field, 9},
{"TypeSpec.Comment", Field, 0},
{"TypeSpec.Doc", Field, 0},
{"TypeSpec.Name", Field, 0},
{"TypeSpec.Type", Field, 0},
{"TypeSpec.TypeParams", Field, 18},
{"TypeSwitchStmt", Type, 0},
{"TypeSwitchStmt.Assign", Field, 0},
{"TypeSwitchStmt.Body", Field, 0},
{"TypeSwitchStmt.Init", Field, 0},
{"TypeSwitchStmt.Switch", Field, 0},
{"UnaryExpr", Type, 0},
{"UnaryExpr.Op", Field, 0},
{"UnaryExpr.OpPos", Field, 0},
{"UnaryExpr.X", Field, 0},
{"Unparen", Func, 22},
{"ValueSpec", Type, 0},
{"ValueSpec.Comment", Field, 0},
{"ValueSpec.Doc", Field, 0},
{"ValueSpec.Names", Field, 0},
{"ValueSpec.Type", Field, 0},
{"ValueSpec.Values", Field, 0},
{"Var", Const, 0},
{"Visitor", Type, 0},
{"Walk", Func, 0},
},
"go/build": {
{"(*Context).Import", Method, 0},
{"(*Context).ImportDir", Method, 0},
{"(*Context).MatchFile", Method, 2},
{"(*Context).SrcDirs", Method, 0},
{"(*MultiplePackageError).Error", Method, 4},
{"(*NoGoError).Error", Method, 0},
{"(*Package).IsCommand", Method, 0},
{"AllowBinary", Const, 0},
{"ArchChar", Func, 0},
{"Context", Type, 0},
{"Context.BuildTags", Field, 0},
{"Context.CgoEnabled", Field, 0},
{"Context.Compiler", Field, 0},
{"Context.Dir", Field, 14},
{"Context.GOARCH", Field, 0},
{"Context.GOOS", Field, 0},
{"Context.GOPATH", Field, 0},
{"Context.GOROOT", Field, 0},
{"Context.HasSubdir", Field, 0},
{"Context.InstallSuffix", Field, 1},
{"Context.IsAbsPath", Field, 0},
{"Context.IsDir", Field, 0},
{"Context.JoinPath", Field, 0},
{"Context.OpenFile", Field, 0},
{"Context.ReadDir", Field, 0},
{"Context.ReleaseTags", Field, 1},
{"Context.SplitPathList", Field, 0},
{"Context.ToolTags", Field, 17},
{"Context.UseAllFiles", Field, 0},
{"Default", Var, 0},
{"Directive", Type, 21},
{"Directive.Pos", Field, 21},
{"Directive.Text", Field, 21},
{"FindOnly", Const, 0},
{"IgnoreVendor", Const, 6},
{"Import", Func, 0},
{"ImportComment", Const, 4},
{"ImportDir", Func, 0},
{"ImportMode", Type, 0},
{"IsLocalImport", Func, 0},
{"MultiplePackageError", Type, 4},
{"MultiplePackageError.Dir", Field, 4},
{"MultiplePackageError.Files", Field, 4},
{"MultiplePackageError.Packages", Field, 4},
{"NoGoError", Type, 0},
{"NoGoError.Dir", Field, 0},
{"Package", Type, 0},
{"Package.AllTags", Field, 2},
{"Package.BinDir", Field, 0},
{"Package.BinaryOnly", Field, 7},
{"Package.CFiles", Field, 0},
{"Package.CXXFiles", Field, 2},
{"Package.CgoCFLAGS", Field, 0},
{"Package.CgoCPPFLAGS", Field, 2},
{"Package.CgoCXXFLAGS", Field, 2},
{"Package.CgoFFLAGS", Field, 7},
{"Package.CgoFiles", Field, 0},
{"Package.CgoLDFLAGS", Field, 0},
{"Package.CgoPkgConfig", Field, 0},
{"Package.ConflictDir", Field, 2},
{"Package.Dir", Field, 0},
{"Package.Directives", Field, 21},
{"Package.Doc", Field, 0},
{"Package.EmbedPatternPos", Field, 16},
{"Package.EmbedPatterns", Field, 16},
{"Package.FFiles", Field, 7},
{"Package.GoFiles", Field, 0},
{"Package.Goroot", Field, 0},
{"Package.HFiles", Field, 0},
{"Package.IgnoredGoFiles", Field, 1},
{"Package.IgnoredOtherFiles", Field, 16},
{"Package.ImportComment", Field, 4},
{"Package.ImportPath", Field, 0},
{"Package.ImportPos", Field, 0},
{"Package.Imports", Field, 0},
{"Package.InvalidGoFiles", Field, 6},
{"Package.MFiles", Field, 3},
{"Package.Name", Field, 0},
{"Package.PkgObj", Field, 0},
{"Package.PkgRoot", Field, 0},
{"Package.PkgTargetRoot", Field, 5},
{"Package.Root", Field, 0},
{"Package.SFiles", Field, 0},
{"Package.SrcRoot", Field, 0},
{"Package.SwigCXXFiles", Field, 1},
{"Package.SwigFiles", Field, 1},
{"Package.SysoFiles", Field, 0},
{"Package.TestDirectives", Field, 21},
{"Package.TestEmbedPatternPos", Field, 16},
{"Package.TestEmbedPatterns", Field, 16},
{"Package.TestGoFiles", Field, 0},
{"Package.TestImportPos", Field, 0},
{"Package.TestImports", Field, 0},
{"Package.XTestDirectives", Field, 21},
{"Package.XTestEmbedPatternPos", Field, 16},
{"Package.XTestEmbedPatterns", Field, 16},
{"Package.XTestGoFiles", Field, 0},
{"Package.XTestImportPos", Field, 0},
{"Package.XTestImports", Field, 0},
{"ToolDir", Var, 0},
},
"go/build/constraint": {
{"(*AndExpr).Eval", Method, 16},
{"(*AndExpr).String", Method, 16},
{"(*NotExpr).Eval", Method, 16},
{"(*NotExpr).String", Method, 16},
{"(*OrExpr).Eval", Method, 16},
{"(*OrExpr).String", Method, 16},
{"(*SyntaxError).Error", Method, 16},
{"(*TagExpr).Eval", Method, 16},
{"(*TagExpr).String", Method, 16},
{"AndExpr", Type, 16},
{"AndExpr.X", Field, 16},
{"AndExpr.Y", Field, 16},
{"Expr", Type, 16},
{"GoVersion", Func, 21},
{"IsGoBuild", Func, 16},
{"IsPlusBuild", Func, 16},
{"NotExpr", Type, 16},
{"NotExpr.X", Field, 16},
{"OrExpr", Type, 16},
{"OrExpr.X", Field, 16},
{"OrExpr.Y", Field, 16},
{"Parse", Func, 16},
{"PlusBuildLines", Func, 16},
{"SyntaxError", Type, 16},
{"SyntaxError.Err", Field, 16},
{"SyntaxError.Offset", Field, 16},
{"TagExpr", Type, 16},
{"TagExpr.Tag", Field, 16},
},
"go/constant": {
{"(Kind).String", Method, 18},
{"BinaryOp", Func, 5},
{"BitLen", Func, 5},
{"Bool", Const, 5},
{"BoolVal", Func, 5},
{"Bytes", Func, 5},
{"Compare", Func, 5},
{"Complex", Const, 5},
{"Denom", Func, 5},
{"Float", Const, 5},
{"Float32Val", Func, 5},
{"Float64Val", Func, 5},
{"Imag", Func, 5},
{"Int", Const, 5},
{"Int64Val", Func, 5},
{"Kind", Type, 5},
{"Make", Func, 13},
{"MakeBool", Func, 5},
{"MakeFloat64", Func, 5},
{"MakeFromBytes", Func, 5},
{"MakeFromLiteral", Func, 5},
{"MakeImag", Func, 5},
{"MakeInt64", Func, 5},
{"MakeString", Func, 5},
{"MakeUint64", Func, 5},
{"MakeUnknown", Func, 5},
{"Num", Func, 5},
{"Real", Func, 5},
{"Shift", Func, 5},
{"Sign", Func, 5},
{"String", Const, 5},
{"StringVal", Func, 5},
{"ToComplex", Func, 6},
{"ToFloat", Func, 6},
{"ToInt", Func, 6},
{"Uint64Val", Func, 5},
{"UnaryOp", Func, 5},
{"Unknown", Const, 5},
{"Val", Func, 13},
{"Value", Type, 5},
},
"go/doc": {
{"(*Package).Filter", Method, 0},
{"(*Package).HTML", Method, 19},
{"(*Package).Markdown", Method, 19},
{"(*Package).Parser", Method, 19},
{"(*Package).Printer", Method, 19},
{"(*Package).Synopsis", Method, 19},
{"(*Package).Text", Method, 19},
{"AllDecls", Const, 0},
{"AllMethods", Const, 0},
{"Example", Type, 0},
{"Example.Code", Field, 0},
{"Example.Comments", Field, 0},
{"Example.Doc", Field, 0},
{"Example.EmptyOutput", Field, 1},
{"Example.Name", Field, 0},
{"Example.Order", Field, 1},
{"Example.Output", Field, 0},
{"Example.Play", Field, 1},
{"Example.Suffix", Field, 14},
{"Example.Unordered", Field, 7},
{"Examples", Func, 0},
{"Filter", Type, 0},
{"Func", Type, 0},
{"Func.Decl", Field, 0},
{"Func.Doc", Field, 0},
{"Func.Examples", Field, 14},
{"Func.Level", Field, 0},
{"Func.Name", Field, 0},
{"Func.Orig", Field, 0},
{"Func.Recv", Field, 0},
{"IllegalPrefixes", Var, 1},
{"IsPredeclared", Func, 8},
{"Mode", Type, 0},
{"New", Func, 0},
{"NewFromFiles", Func, 14},
{"Note", Type, 1},
{"Note.Body", Field, 1},
{"Note.End", Field, 1},
{"Note.Pos", Field, 1},
{"Note.UID", Field, 1},
{"Package", Type, 0},
{"Package.Bugs", Field, 0},
{"Package.Consts", Field, 0},
{"Package.Doc", Field, 0},
{"Package.Examples", Field, 14},
{"Package.Filenames", Field, 0},
{"Package.Funcs", Field, 0},
{"Package.ImportPath", Field, 0},
{"Package.Imports", Field, 0},
{"Package.Name", Field, 0},
{"Package.Notes", Field, 1},
{"Package.Types", Field, 0},
{"Package.Vars", Field, 0},
{"PreserveAST", Const, 12},
{"Synopsis", Func, 0},
{"ToHTML", Func, 0},
{"ToText", Func, 0},
{"Type", Type, 0},
{"Type.Consts", Field, 0},
{"Type.Decl", Field, 0},
{"Type.Doc", Field, 0},
{"Type.Examples", Field, 14},
{"Type.Funcs", Field, 0},
{"Type.Methods", Field, 0},
{"Type.Name", Field, 0},
{"Type.Vars", Field, 0},
{"Value", Type, 0},
{"Value.Decl", Field, 0},
{"Value.Doc", Field, 0},
{"Value.Names", Field, 0},
},
"go/doc/comment": {
{"(*DocLink).DefaultURL", Method, 19},
{"(*Heading).DefaultID", Method, 19},
{"(*List).BlankBefore", Method, 19},
{"(*List).BlankBetween", Method, 19},
{"(*Parser).Parse", Method, 19},
{"(*Printer).Comment", Method, 19},
{"(*Printer).HTML", Method, 19},
{"(*Printer).Markdown", Method, 19},
{"(*Printer).Text", Method, 19},
{"Block", Type, 19},
{"Code", Type, 19},
{"Code.Text", Field, 19},
{"DefaultLookupPackage", Func, 19},
{"Doc", Type, 19},
{"Doc.Content", Field, 19},
{"Doc.Links", Field, 19},
{"DocLink", Type, 19},
{"DocLink.ImportPath", Field, 19},
{"DocLink.Name", Field, 19},
{"DocLink.Recv", Field, 19},
{"DocLink.Text", Field, 19},
{"Heading", Type, 19},
{"Heading.Text", Field, 19},
{"Italic", Type, 19},
{"Link", Type, 19},
{"Link.Auto", Field, 19},
{"Link.Text", Field, 19},
{"Link.URL", Field, 19},
{"LinkDef", Type, 19},
{"LinkDef.Text", Field, 19},
{"LinkDef.URL", Field, 19},
{"LinkDef.Used", Field, 19},
{"List", Type, 19},
{"List.ForceBlankBefore", Field, 19},
{"List.ForceBlankBetween", Field, 19},
{"List.Items", Field, 19},
{"ListItem", Type, 19},
{"ListItem.Content", Field, 19},
{"ListItem.Number", Field, 19},
{"Paragraph", Type, 19},
{"Paragraph.Text", Field, 19},
{"Parser", Type, 19},
{"Parser.LookupPackage", Field, 19},
{"Parser.LookupSym", Field, 19},
{"Parser.Words", Field, 19},
{"Plain", Type, 19},
{"Printer", Type, 19},
{"Printer.DocLinkBaseURL", Field, 19},
{"Printer.DocLinkURL", Field, 19},
{"Printer.HeadingID", Field, 19},
{"Printer.HeadingLevel", Field, 19},
{"Printer.TextCodePrefix", Field, 19},
{"Printer.TextPrefix", Field, 19},
{"Printer.TextWidth", Field, 19},
{"Text", Type, 19},
},
"go/format": {
{"Node", Func, 1},
{"Source", Func, 1},
},
"go/importer": {
{"Default", Func, 5},
{"For", Func, 5},
{"ForCompiler", Func, 12},
{"Lookup", Type, 5},
},
"go/parser": {
{"AllErrors", Const, 1},
{"DeclarationErrors", Const, 0},
{"ImportsOnly", Const, 0},
{"Mode", Type, 0},
{"PackageClauseOnly", Const, 0},
{"ParseComments", Const, 0},
{"ParseDir", Func, 0},
{"ParseExpr", Func, 0},
{"ParseExprFrom", Func, 5},
{"ParseFile", Func, 0},
{"SkipObjectResolution", Const, 17},
{"SpuriousErrors", Const, 0},
{"Trace", Const, 0},
},
"go/printer": {
{"(*Config).Fprint", Method, 0},
{"CommentedNode", Type, 0},
{"CommentedNode.Comments", Field, 0},
{"CommentedNode.Node", Field, 0},
{"Config", Type, 0},
{"Config.Indent", Field, 1},
{"Config.Mode", Field, 0},
{"Config.Tabwidth", Field, 0},
{"Fprint", Func, 0},
{"Mode", Type, 0},
{"RawFormat", Const, 0},
{"SourcePos", Const, 0},
{"TabIndent", Const, 0},
{"UseSpaces", Const, 0},
},
"go/scanner": {
{"(*ErrorList).Add", Method, 0},
{"(*ErrorList).RemoveMultiples", Method, 0},
{"(*ErrorList).Reset", Method, 0},
{"(*Scanner).Init", Method, 0},
{"(*Scanner).Scan", Method, 0},
{"(Error).Error", Method, 0},
{"(ErrorList).Err", Method, 0},
{"(ErrorList).Error", Method, 0},
{"(ErrorList).Len", Method, 0},
{"(ErrorList).Less", Method, 0},
{"(ErrorList).Sort", Method, 0},
{"(ErrorList).Swap", Method, 0},
{"Error", Type, 0},
{"Error.Msg", Field, 0},
{"Error.Pos", Field, 0},
{"ErrorHandler", Type, 0},
{"ErrorList", Type, 0},
{"Mode", Type, 0},
{"PrintError", Func, 0},
{"ScanComments", Const, 0},
{"Scanner", Type, 0},
{"Scanner.ErrorCount", Field, 0},
},
"go/token": {
{"(*File).AddLine", Method, 0},
{"(*File).AddLineColumnInfo", Method, 11},
{"(*File).AddLineInfo", Method, 0},
{"(*File).Base", Method, 0},
{"(*File).Line", Method, 0},
{"(*File).LineCount", Method, 0},
{"(*File).LineStart", Method, 12},
{"(*File).Lines", Method, 21},
{"(*File).MergeLine", Method, 2},
{"(*File).Name", Method, 0},
{"(*File).Offset", Method, 0},
{"(*File).Pos", Method, 0},
{"(*File).Position", Method, 0},
{"(*File).PositionFor", Method, 4},
{"(*File).SetLines", Method, 0},
{"(*File).SetLinesForContent", Method, 0},
{"(*File).Size", Method, 0},
{"(*FileSet).AddFile", Method, 0},
{"(*FileSet).Base", Method, 0},
{"(*FileSet).File", Method, 0},
{"(*FileSet).Iterate", Method, 0},
{"(*FileSet).Position", Method, 0},
{"(*FileSet).PositionFor", Method, 4},
{"(*FileSet).Read", Method, 0},
{"(*FileSet).RemoveFile", Method, 20},
{"(*FileSet).Write", Method, 0},
{"(*Position).IsValid", Method, 0},
{"(Pos).IsValid", Method, 0},
{"(Position).String", Method, 0},
{"(Token).IsKeyword", Method, 0},
{"(Token).IsLiteral", Method, 0},
{"(Token).IsOperator", Method, 0},
{"(Token).Precedence", Method, 0},
{"(Token).String", Method, 0},
{"ADD", Const, 0},
{"ADD_ASSIGN", Const, 0},
{"AND", Const, 0},
{"AND_ASSIGN", Const, 0},
{"AND_NOT", Const, 0},
{"AND_NOT_ASSIGN", Const, 0},
{"ARROW", Const, 0},
{"ASSIGN", Const, 0},
{"BREAK", Const, 0},
{"CASE", Const, 0},
{"CHAN", Const, 0},
{"CHAR", Const, 0},
{"COLON", Const, 0},
{"COMMA", Const, 0},
{"COMMENT", Const, 0},
{"CONST", Const, 0},
{"CONTINUE", Const, 0},
{"DEC", Const, 0},
{"DEFAULT", Const, 0},
{"DEFER", Const, 0},
{"DEFINE", Const, 0},
{"ELLIPSIS", Const, 0},
{"ELSE", Const, 0},
{"EOF", Const, 0},
{"EQL", Const, 0},
{"FALLTHROUGH", Const, 0},
{"FLOAT", Const, 0},
{"FOR", Const, 0},
{"FUNC", Const, 0},
{"File", Type, 0},
{"FileSet", Type, 0},
{"GEQ", Const, 0},
{"GO", Const, 0},
{"GOTO", Const, 0},
{"GTR", Const, 0},
{"HighestPrec", Const, 0},
{"IDENT", Const, 0},
{"IF", Const, 0},
{"ILLEGAL", Const, 0},
{"IMAG", Const, 0},
{"IMPORT", Const, 0},
{"INC", Const, 0},
{"INT", Const, 0},
{"INTERFACE", Const, 0},
{"IsExported", Func, 13},
{"IsIdentifier", Func, 13},
{"IsKeyword", Func, 13},
{"LAND", Const, 0},
{"LBRACE", Const, 0},
{"LBRACK", Const, 0},
{"LEQ", Const, 0},
{"LOR", Const, 0},
{"LPAREN", Const, 0},
{"LSS", Const, 0},
{"Lookup", Func, 0},
{"LowestPrec", Const, 0},
{"MAP", Const, 0},
{"MUL", Const, 0},
{"MUL_ASSIGN", Const, 0},
{"NEQ", Const, 0},
{"NOT", Const, 0},
{"NewFileSet", Func, 0},
{"NoPos", Const, 0},
{"OR", Const, 0},
{"OR_ASSIGN", Const, 0},
{"PACKAGE", Const, 0},
{"PERIOD", Const, 0},
{"Pos", Type, 0},
{"Position", Type, 0},
{"Position.Column", Field, 0},
{"Position.Filename", Field, 0},
{"Position.Line", Field, 0},
{"Position.Offset", Field, 0},
{"QUO", Const, 0},
{"QUO_ASSIGN", Const, 0},
{"RANGE", Const, 0},
{"RBRACE", Const, 0},
{"RBRACK", Const, 0},
{"REM", Const, 0},
{"REM_ASSIGN", Const, 0},
{"RETURN", Const, 0},
{"RPAREN", Const, 0},
{"SELECT", Const, 0},
{"SEMICOLON", Const, 0},
{"SHL", Const, 0},
{"SHL_ASSIGN", Const, 0},
{"SHR", Const, 0},
{"SHR_ASSIGN", Const, 0},
{"STRING", Const, 0},
{"STRUCT", Const, 0},
{"SUB", Const, 0},
{"SUB_ASSIGN", Const, 0},
{"SWITCH", Const, 0},
{"TILDE", Const, 18},
{"TYPE", Const, 0},
{"Token", Type, 0},
{"UnaryPrec", Const, 0},
{"VAR", Const, 0},
{"XOR", Const, 0},
{"XOR_ASSIGN", Const, 0},
},
"go/types": {
{"(*Alias).Obj", Method, 22},
{"(*Alias).Origin", Method, 23},
{"(*Alias).Rhs", Method, 23},
{"(*Alias).SetTypeParams", Method, 23},
{"(*Alias).String", Method, 22},
{"(*Alias).TypeArgs", Method, 23},
{"(*Alias).TypeParams", Method, 23},
{"(*Alias).Underlying", Method, 22},
{"(*ArgumentError).Error", Method, 18},
{"(*ArgumentError).Unwrap", Method, 18},
{"(*Array).Elem", Method, 5},
{"(*Array).Len", Method, 5},
{"(*Array).String", Method, 5},
{"(*Array).Underlying", Method, 5},
{"(*Basic).Info", Method, 5},
{"(*Basic).Kind", Method, 5},
{"(*Basic).Name", Method, 5},
{"(*Basic).String", Method, 5},
{"(*Basic).Underlying", Method, 5},
{"(*Builtin).Exported", Method, 5},
{"(*Builtin).Id", Method, 5},
{"(*Builtin).Name", Method, 5},
{"(*Builtin).Parent", Method, 5},
{"(*Builtin).Pkg", Method, 5},
{"(*Builtin).Pos", Method, 5},
{"(*Builtin).String", Method, 5},
{"(*Builtin).Type", Method, 5},
{"(*Chan).Dir", Method, 5},
{"(*Chan).Elem", Method, 5},
{"(*Chan).String", Method, 5},
{"(*Chan).Underlying", Method, 5},
{"(*Checker).Files", Method, 5},
{"(*Config).Check", Method, 5},
{"(*Const).Exported", Method, 5},
{"(*Const).Id", Method, 5},
{"(*Const).Name", Method, 5},
{"(*Const).Parent", Method, 5},
{"(*Const).Pkg", Method, 5},
{"(*Const).Pos", Method, 5},
{"(*Const).String", Method, 5},
{"(*Const).Type", Method, 5},
{"(*Const).Val", Method, 5},
{"(*Func).Exported", Method, 5},
{"(*Func).FullName", Method, 5},
{"(*Func).Id", Method, 5},
{"(*Func).Name", Method, 5},
{"(*Func).Origin", Method, 19},
{"(*Func).Parent", Method, 5},
{"(*Func).Pkg", Method, 5},
{"(*Func).Pos", Method, 5},
{"(*Func).Scope", Method, 5},
{"(*Func).Signature", Method, 23},
{"(*Func).String", Method, 5},
{"(*Func).Type", Method, 5},
{"(*Info).ObjectOf", Method, 5},
{"(*Info).PkgNameOf", Method, 22},
{"(*Info).TypeOf", Method, 5},
{"(*Initializer).String", Method, 5},
{"(*Interface).Complete", Method, 5},
{"(*Interface).Embedded", Method, 5},
{"(*Interface).EmbeddedType", Method, 11},
{"(*Interface).Empty", Method, 5},
{"(*Interface).ExplicitMethod", Method, 5},
{"(*Interface).IsComparable", Method, 18},
{"(*Interface).IsImplicit", Method, 18},
{"(*Interface).IsMethodSet", Method, 18},
{"(*Interface).MarkImplicit", Method, 18},
{"(*Interface).Method", Method, 5},
{"(*Interface).NumEmbeddeds", Method, 5},
{"(*Interface).NumExplicitMethods", Method, 5},
{"(*Interface).NumMethods", Method, 5},
{"(*Interface).String", Method, 5},
{"(*Interface).Underlying", Method, 5},
{"(*Label).Exported", Method, 5},
{"(*Label).Id", Method, 5},
{"(*Label).Name", Method, 5},
{"(*Label).Parent", Method, 5},
{"(*Label).Pkg", Method, 5},
{"(*Label).Pos", Method, 5},
{"(*Label).String", Method, 5},
{"(*Label).Type", Method, 5},
{"(*Map).Elem", Method, 5},
{"(*Map).Key", Method, 5},
{"(*Map).String", Method, 5},
{"(*Map).Underlying", Method, 5},
{"(*MethodSet).At", Method, 5},
{"(*MethodSet).Len", Method, 5},
{"(*MethodSet).Lookup", Method, 5},
{"(*MethodSet).String", Method, 5},
{"(*Named).AddMethod", Method, 5},
{"(*Named).Method", Method, 5},
{"(*Named).NumMethods", Method, 5},
{"(*Named).Obj", Method, 5},
{"(*Named).Origin", Method, 18},
{"(*Named).SetTypeParams", Method, 18},
{"(*Named).SetUnderlying", Method, 5},
{"(*Named).String", Method, 5},
{"(*Named).TypeArgs", Method, 18},
{"(*Named).TypeParams", Method, 18},
{"(*Named).Underlying", Method, 5},
{"(*Nil).Exported", Method, 5},
{"(*Nil).Id", Method, 5},
{"(*Nil).Name", Method, 5},
{"(*Nil).Parent", Method, 5},
{"(*Nil).Pkg", Method, 5},
{"(*Nil).Pos", Method, 5},
{"(*Nil).String", Method, 5},
{"(*Nil).Type", Method, 5},
{"(*Package).Complete", Method, 5},
{"(*Package).GoVersion", Method, 21},
{"(*Package).Imports", Method, 5},
{"(*Package).MarkComplete", Method, 5},
{"(*Package).Name", Method, 5},
{"(*Package).Path", Method, 5},
{"(*Package).Scope", Method, 5},
{"(*Package).SetImports", Method, 5},
{"(*Package).SetName", Method, 6},
{"(*Package).String", Method, 5},
{"(*PkgName).Exported", Method, 5},
{"(*PkgName).Id", Method, 5},
{"(*PkgName).Imported", Method, 5},
{"(*PkgName).Name", Method, 5},
{"(*PkgName).Parent", Method, 5},
{"(*PkgName).Pkg", Method, 5},
{"(*PkgName).Pos", Method, 5},
{"(*PkgName).String", Method, 5},
{"(*PkgName).Type", Method, 5},
{"(*Pointer).Elem", Method, 5},
{"(*Pointer).String", Method, 5},
{"(*Pointer).Underlying", Method, 5},
{"(*Scope).Child", Method, 5},
{"(*Scope).Contains", Method, 5},
{"(*Scope).End", Method, 5},
{"(*Scope).Innermost", Method, 5},
{"(*Scope).Insert", Method, 5},
{"(*Scope).Len", Method, 5},
{"(*Scope).Lookup", Method, 5},
{"(*Scope).LookupParent", Method, 5},
{"(*Scope).Names", Method, 5},
{"(*Scope).NumChildren", Method, 5},
{"(*Scope).Parent", Method, 5},
{"(*Scope).Pos", Method, 5},
{"(*Scope).String", Method, 5},
{"(*Scope).WriteTo", Method, 5},
{"(*Selection).Index", Method, 5},
{"(*Selection).Indirect", Method, 5},
{"(*Selection).Kind", Method, 5},
{"(*Selection).Obj", Method, 5},
{"(*Selection).Recv", Method, 5},
{"(*Selection).String", Method, 5},
{"(*Selection).Type", Method, 5},
{"(*Signature).Params", Method, 5},
{"(*Signature).Recv", Method, 5},
{"(*Signature).RecvTypeParams", Method, 18},
{"(*Signature).Results", Method, 5},
{"(*Signature).String", Method, 5},
{"(*Signature).TypeParams", Method, 18},
{"(*Signature).Underlying", Method, 5},
{"(*Signature).Variadic", Method, 5},
{"(*Slice).Elem", Method, 5},
{"(*Slice).String", Method, 5},
{"(*Slice).Underlying", Method, 5},
{"(*StdSizes).Alignof", Method, 5},
{"(*StdSizes).Offsetsof", Method, 5},
{"(*StdSizes).Sizeof", Method, 5},
{"(*Struct).Field", Method, 5},
{"(*Struct).NumFields", Method, 5},
{"(*Struct).String", Method, 5},
{"(*Struct).Tag", Method, 5},
{"(*Struct).Underlying", Method, 5},
{"(*Term).String", Method, 18},
{"(*Term).Tilde", Method, 18},
{"(*Term).Type", Method, 18},
{"(*Tuple).At", Method, 5},
{"(*Tuple).Len", Method, 5},
{"(*Tuple).String", Method, 5},
{"(*Tuple).Underlying", Method, 5},
{"(*TypeList).At", Method, 18},
{"(*TypeList).Len", Method, 18},
{"(*TypeName).Exported", Method, 5},
{"(*TypeName).Id", Method, 5},
{"(*TypeName).IsAlias", Method, 9},
{"(*TypeName).Name", Method, 5},
{"(*TypeName).Parent", Method, 5},
{"(*TypeName).Pkg", Method, 5},
{"(*TypeName).Pos", Method, 5},
{"(*TypeName).String", Method, 5},
{"(*TypeName).Type", Method, 5},
{"(*TypeParam).Constraint", Method, 18},
{"(*TypeParam).Index", Method, 18},
{"(*TypeParam).Obj", Method, 18},
{"(*TypeParam).SetConstraint", Method, 18},
{"(*TypeParam).String", Method, 18},
{"(*TypeParam).Underlying", Method, 18},
{"(*TypeParamList).At", Method, 18},
{"(*TypeParamList).Len", Method, 18},
{"(*Union).Len", Method, 18},
{"(*Union).String", Method, 18},
{"(*Union).Term", Method, 18},
{"(*Union).Underlying", Method, 18},
{"(*Var).Anonymous", Method, 5},
{"(*Var).Embedded", Method, 11},
{"(*Var).Exported", Method, 5},
{"(*Var).Id", Method, 5},
{"(*Var).IsField", Method, 5},
{"(*Var).Name", Method, 5},
{"(*Var).Origin", Method, 19},
{"(*Var).Parent", Method, 5},
{"(*Var).Pkg", Method, 5},
{"(*Var).Pos", Method, 5},
{"(*Var).String", Method, 5},
{"(*Var).Type", Method, 5},
{"(Checker).ObjectOf", Method, 5},
{"(Checker).PkgNameOf", Method, 22},
{"(Checker).TypeOf", Method, 5},
{"(Error).Error", Method, 5},
{"(TypeAndValue).Addressable", Method, 5},
{"(TypeAndValue).Assignable", Method, 5},
{"(TypeAndValue).HasOk", Method, 5},
{"(TypeAndValue).IsBuiltin", Method, 5},
{"(TypeAndValue).IsNil", Method, 5},
{"(TypeAndValue).IsType", Method, 5},
{"(TypeAndValue).IsValue", Method, 5},
{"(TypeAndValue).IsVoid", Method, 5},
{"Alias", Type, 22},
{"ArgumentError", Type, 18},
{"ArgumentError.Err", Field, 18},
{"ArgumentError.Index", Field, 18},
{"Array", Type, 5},
{"AssertableTo", Func, 5},
{"AssignableTo", Func, 5},
{"Basic", Type, 5},
{"BasicInfo", Type, 5},
{"BasicKind", Type, 5},
{"Bool", Const, 5},
{"Builtin", Type, 5},
{"Byte", Const, 5},
{"Chan", Type, 5},
{"ChanDir", Type, 5},
{"CheckExpr", Func, 13},
{"Checker", Type, 5},
{"Checker.Info", Field, 5},
{"Comparable", Func, 5},
{"Complex128", Const, 5},
{"Complex64", Const, 5},
{"Config", Type, 5},
{"Config.Context", Field, 18},
{"Config.DisableUnusedImportCheck", Field, 5},
{"Config.Error", Field, 5},
{"Config.FakeImportC", Field, 5},
{"Config.GoVersion", Field, 18},
{"Config.IgnoreFuncBodies", Field, 5},
{"Config.Importer", Field, 5},
{"Config.Sizes", Field, 5},
{"Const", Type, 5},
{"Context", Type, 18},
{"ConvertibleTo", Func, 5},
{"DefPredeclaredTestFuncs", Func, 5},
{"Default", Func, 8},
{"Error", Type, 5},
{"Error.Fset", Field, 5},
{"Error.Msg", Field, 5},
{"Error.Pos", Field, 5},
{"Error.Soft", Field, 5},
{"Eval", Func, 5},
{"ExprString", Func, 5},
{"FieldVal", Const, 5},
{"Float32", Const, 5},
{"Float64", Const, 5},
{"Func", Type, 5},
{"Id", Func, 5},
{"Identical", Func, 5},
{"IdenticalIgnoreTags", Func, 8},
{"Implements", Func, 5},
{"ImportMode", Type, 6},
{"Importer", Type, 5},
{"ImporterFrom", Type, 6},
{"Info", Type, 5},
{"Info.Defs", Field, 5},
{"Info.FileVersions", Field, 22},
{"Info.Implicits", Field, 5},
{"Info.InitOrder", Field, 5},
{"Info.Instances", Field, 18},
{"Info.Scopes", Field, 5},
{"Info.Selections", Field, 5},
{"Info.Types", Field, 5},
{"Info.Uses", Field, 5},
{"Initializer", Type, 5},
{"Initializer.Lhs", Field, 5},
{"Initializer.Rhs", Field, 5},
{"Instance", Type, 18},
{"Instance.Type", Field, 18},
{"Instance.TypeArgs", Field, 18},
{"Instantiate", Func, 18},
{"Int", Const, 5},
{"Int16", Const, 5},
{"Int32", Const, 5},
{"Int64", Const, 5},
{"Int8", Const, 5},
{"Interface", Type, 5},
{"Invalid", Const, 5},
{"IsBoolean", Const, 5},
{"IsComplex", Const, 5},
{"IsConstType", Const, 5},
{"IsFloat", Const, 5},
{"IsInteger", Const, 5},
{"IsInterface", Func, 5},
{"IsNumeric", Const, 5},
{"IsOrdered", Const, 5},
{"IsString", Const, 5},
{"IsUnsigned", Const, 5},
{"IsUntyped", Const, 5},
{"Label", Type, 5},
{"LookupFieldOrMethod", Func, 5},
{"Map", Type, 5},
{"MethodExpr", Const, 5},
{"MethodSet", Type, 5},
{"MethodVal", Const, 5},
{"MissingMethod", Func, 5},
{"Named", Type, 5},
{"NewAlias", Func, 22},
{"NewArray", Func, 5},
{"NewChan", Func, 5},
{"NewChecker", Func, 5},
{"NewConst", Func, 5},
{"NewContext", Func, 18},
{"NewField", Func, 5},
{"NewFunc", Func, 5},
{"NewInterface", Func, 5},
{"NewInterfaceType", Func, 11},
{"NewLabel", Func, 5},
{"NewMap", Func, 5},
{"NewMethodSet", Func, 5},
{"NewNamed", Func, 5},
{"NewPackage", Func, 5},
{"NewParam", Func, 5},
{"NewPkgName", Func, 5},
{"NewPointer", Func, 5},
{"NewScope", Func, 5},
{"NewSignature", Func, 5},
{"NewSignatureType", Func, 18},
{"NewSlice", Func, 5},
{"NewStruct", Func, 5},
{"NewTerm", Func, 18},
{"NewTuple", Func, 5},
{"NewTypeName", Func, 5},
{"NewTypeParam", Func, 18},
{"NewUnion", Func, 18},
{"NewVar", Func, 5},
{"Nil", Type, 5},
{"Object", Type, 5},
{"ObjectString", Func, 5},
{"Package", Type, 5},
{"PkgName", Type, 5},
{"Pointer", Type, 5},
{"Qualifier", Type, 5},
{"RecvOnly", Const, 5},
{"RelativeTo", Func, 5},
{"Rune", Const, 5},
{"Satisfies", Func, 20},
{"Scope", Type, 5},
{"Selection", Type, 5},
{"SelectionKind", Type, 5},
{"SelectionString", Func, 5},
{"SendOnly", Const, 5},
{"SendRecv", Const, 5},
{"Signature", Type, 5},
{"Sizes", Type, 5},
{"SizesFor", Func, 9},
{"Slice", Type, 5},
{"StdSizes", Type, 5},
{"StdSizes.MaxAlign", Field, 5},
{"StdSizes.WordSize", Field, 5},
{"String", Const, 5},
{"Struct", Type, 5},
{"Term", Type, 18},
{"Tuple", Type, 5},
{"Typ", Var, 5},
{"Type", Type, 5},
{"TypeAndValue", Type, 5},
{"TypeAndValue.Type", Field, 5},
{"TypeAndValue.Value", Field, 5},
{"TypeList", Type, 18},
{"TypeName", Type, 5},
{"TypeParam", Type, 18},
{"TypeParamList", Type, 18},
{"TypeString", Func, 5},
{"Uint", Const, 5},
{"Uint16", Const, 5},
{"Uint32", Const, 5},
{"Uint64", Const, 5},
{"Uint8", Const, 5},
{"Uintptr", Const, 5},
{"Unalias", Func, 22},
{"Union", Type, 18},
{"Universe", Var, 5},
{"Unsafe", Var, 5},
{"UnsafePointer", Const, 5},
{"UntypedBool", Const, 5},
{"UntypedComplex", Const, 5},
{"UntypedFloat", Const, 5},
{"UntypedInt", Const, 5},
{"UntypedNil", Const, 5},
{"UntypedRune", Const, 5},
{"UntypedString", Const, 5},
{"Var", Type, 5},
{"WriteExpr", Func, 5},
{"WriteSignature", Func, 5},
{"WriteType", Func, 5},
},
"go/version": {
{"Compare", Func, 22},
{"IsValid", Func, 22},
{"Lang", Func, 22},
},
"hash": {
{"Hash", Type, 0},
{"Hash32", Type, 0},
{"Hash64", Type, 0},
},
"hash/adler32": {
{"Checksum", Func, 0},
{"New", Func, 0},
{"Size", Const, 0},
},
"hash/crc32": {
{"Castagnoli", Const, 0},
{"Checksum", Func, 0},
{"ChecksumIEEE", Func, 0},
{"IEEE", Const, 0},
{"IEEETable", Var, 0},
{"Koopman", Const, 0},
{"MakeTable", Func, 0},
{"New", Func, 0},
{"NewIEEE", Func, 0},
{"Size", Const, 0},
{"Table", Type, 0},
{"Update", Func, 0},
},
"hash/crc64": {
{"Checksum", Func, 0},
{"ECMA", Const, 0},
{"ISO", Const, 0},
{"MakeTable", Func, 0},
{"New", Func, 0},
{"Size", Const, 0},
{"Table", Type, 0},
{"Update", Func, 0},
},
"hash/fnv": {
{"New128", Func, 9},
{"New128a", Func, 9},
{"New32", Func, 0},
{"New32a", Func, 0},
{"New64", Func, 0},
{"New64a", Func, 0},
},
"hash/maphash": {
{"(*Hash).BlockSize", Method, 14},
{"(*Hash).Reset", Method, 14},
{"(*Hash).Seed", Method, 14},
{"(*Hash).SetSeed", Method, 14},
{"(*Hash).Size", Method, 14},
{"(*Hash).Sum", Method, 14},
{"(*Hash).Sum64", Method, 14},
{"(*Hash).Write", Method, 14},
{"(*Hash).WriteByte", Method, 14},
{"(*Hash).WriteString", Method, 14},
{"Bytes", Func, 19},
{"Hash", Type, 14},
{"MakeSeed", Func, 14},
{"Seed", Type, 14},
{"String", Func, 19},
},
"html": {
{"EscapeString", Func, 0},
{"UnescapeString", Func, 0},
},
"html/template": {
{"(*Error).Error", Method, 0},
{"(*Template).AddParseTree", Method, 0},
{"(*Template).Clone", Method, 0},
{"(*Template).DefinedTemplates", Method, 6},
{"(*Template).Delims", Method, 0},
{"(*Template).Execute", Method, 0},
{"(*Template).ExecuteTemplate", Method, 0},
{"(*Template).Funcs", Method, 0},
{"(*Template).Lookup", Method, 0},
{"(*Template).Name", Method, 0},
{"(*Template).New", Method, 0},
{"(*Template).Option", Method, 5},
{"(*Template).Parse", Method, 0},
{"(*Template).ParseFS", Method, 16},
{"(*Template).ParseFiles", Method, 0},
{"(*Template).ParseGlob", Method, 0},
{"(*Template).Templates", Method, 0},
{"CSS", Type, 0},
{"ErrAmbigContext", Const, 0},
{"ErrBadHTML", Const, 0},
{"ErrBranchEnd", Const, 0},
{"ErrEndContext", Const, 0},
{"ErrJSTemplate", Const, 21},
{"ErrNoSuchTemplate", Const, 0},
{"ErrOutputContext", Const, 0},
{"ErrPartialCharset", Const, 0},
{"ErrPartialEscape", Const, 0},
{"ErrPredefinedEscaper", Const, 9},
{"ErrRangeLoopReentry", Const, 0},
{"ErrSlashAmbig", Const, 0},
{"Error", Type, 0},
{"Error.Description", Field, 0},
{"Error.ErrorCode", Field, 0},
{"Error.Line", Field, 0},
{"Error.Name", Field, 0},
{"Error.Node", Field, 4},
{"ErrorCode", Type, 0},
{"FuncMap", Type, 0},
{"HTML", Type, 0},
{"HTMLAttr", Type, 0},
{"HTMLEscape", Func, 0},
{"HTMLEscapeString", Func, 0},
{"HTMLEscaper", Func, 0},
{"IsTrue", Func, 6},
{"JS", Type, 0},
{"JSEscape", Func, 0},
{"JSEscapeString", Func, 0},
{"JSEscaper", Func, 0},
{"JSStr", Type, 0},
{"Must", Func, 0},
{"New", Func, 0},
{"OK", Const, 0},
{"ParseFS", Func, 16},
{"ParseFiles", Func, 0},
{"ParseGlob", Func, 0},
{"Srcset", Type, 10},
{"Template", Type, 0},
{"Template.Tree", Field, 2},
{"URL", Type, 0},
{"URLQueryEscaper", Func, 0},
},
"image": {
{"(*Alpha).AlphaAt", Method, 4},
{"(*Alpha).At", Method, 0},
{"(*Alpha).Bounds", Method, 0},
{"(*Alpha).ColorModel", Method, 0},
{"(*Alpha).Opaque", Method, 0},
{"(*Alpha).PixOffset", Method, 0},
{"(*Alpha).RGBA64At", Method, 17},
{"(*Alpha).Set", Method, 0},
{"(*Alpha).SetAlpha", Method, 0},
{"(*Alpha).SetRGBA64", Method, 17},
{"(*Alpha).SubImage", Method, 0},
{"(*Alpha16).Alpha16At", Method, 4},
{"(*Alpha16).At", Method, 0},
{"(*Alpha16).Bounds", Method, 0},
{"(*Alpha16).ColorModel", Method, 0},
{"(*Alpha16).Opaque", Method, 0},
{"(*Alpha16).PixOffset", Method, 0},
{"(*Alpha16).RGBA64At", Method, 17},
{"(*Alpha16).Set", Method, 0},
{"(*Alpha16).SetAlpha16", Method, 0},
{"(*Alpha16).SetRGBA64", Method, 17},
{"(*Alpha16).SubImage", Method, 0},
{"(*CMYK).At", Method, 5},
{"(*CMYK).Bounds", Method, 5},
{"(*CMYK).CMYKAt", Method, 5},
{"(*CMYK).ColorModel", Method, 5},
{"(*CMYK).Opaque", Method, 5},
{"(*CMYK).PixOffset", Method, 5},
{"(*CMYK).RGBA64At", Method, 17},
{"(*CMYK).Set", Method, 5},
{"(*CMYK).SetCMYK", Method, 5},
{"(*CMYK).SetRGBA64", Method, 17},
{"(*CMYK).SubImage", Method, 5},
{"(*Gray).At", Method, 0},
{"(*Gray).Bounds", Method, 0},
{"(*Gray).ColorModel", Method, 0},
{"(*Gray).GrayAt", Method, 4},
{"(*Gray).Opaque", Method, 0},
{"(*Gray).PixOffset", Method, 0},
{"(*Gray).RGBA64At", Method, 17},
{"(*Gray).Set", Method, 0},
{"(*Gray).SetGray", Method, 0},
{"(*Gray).SetRGBA64", Method, 17},
{"(*Gray).SubImage", Method, 0},
{"(*Gray16).At", Method, 0},
{"(*Gray16).Bounds", Method, 0},
{"(*Gray16).ColorModel", Method, 0},
{"(*Gray16).Gray16At", Method, 4},
{"(*Gray16).Opaque", Method, 0},
{"(*Gray16).PixOffset", Method, 0},
{"(*Gray16).RGBA64At", Method, 17},
{"(*Gray16).Set", Method, 0},
{"(*Gray16).SetGray16", Method, 0},
{"(*Gray16).SetRGBA64", Method, 17},
{"(*Gray16).SubImage", Method, 0},
{"(*NRGBA).At", Method, 0},
{"(*NRGBA).Bounds", Method, 0},
{"(*NRGBA).ColorModel", Method, 0},
{"(*NRGBA).NRGBAAt", Method, 4},
{"(*NRGBA).Opaque", Method, 0},
{"(*NRGBA).PixOffset", Method, 0},
{"(*NRGBA).RGBA64At", Method, 17},
{"(*NRGBA).Set", Method, 0},
{"(*NRGBA).SetNRGBA", Method, 0},
{"(*NRGBA).SetRGBA64", Method, 17},
{"(*NRGBA).SubImage", Method, 0},
{"(*NRGBA64).At", Method, 0},
{"(*NRGBA64).Bounds", Method, 0},
{"(*NRGBA64).ColorModel", Method, 0},
{"(*NRGBA64).NRGBA64At", Method, 4},
{"(*NRGBA64).Opaque", Method, 0},
{"(*NRGBA64).PixOffset", Method, 0},
{"(*NRGBA64).RGBA64At", Method, 17},
{"(*NRGBA64).Set", Method, 0},
{"(*NRGBA64).SetNRGBA64", Method, 0},
{"(*NRGBA64).SetRGBA64", Method, 17},
{"(*NRGBA64).SubImage", Method, 0},
{"(*NYCbCrA).AOffset", Method, 6},
{"(*NYCbCrA).At", Method, 6},
{"(*NYCbCrA).Bounds", Method, 6},
{"(*NYCbCrA).COffset", Method, 6},
{"(*NYCbCrA).ColorModel", Method, 6},
{"(*NYCbCrA).NYCbCrAAt", Method, 6},
{"(*NYCbCrA).Opaque", Method, 6},
{"(*NYCbCrA).RGBA64At", Method, 17},
{"(*NYCbCrA).SubImage", Method, 6},
{"(*NYCbCrA).YCbCrAt", Method, 6},
{"(*NYCbCrA).YOffset", Method, 6},
{"(*Paletted).At", Method, 0},
{"(*Paletted).Bounds", Method, 0},
{"(*Paletted).ColorIndexAt", Method, 0},
{"(*Paletted).ColorModel", Method, 0},
{"(*Paletted).Opaque", Method, 0},
{"(*Paletted).PixOffset", Method, 0},
{"(*Paletted).RGBA64At", Method, 17},
{"(*Paletted).Set", Method, 0},
{"(*Paletted).SetColorIndex", Method, 0},
{"(*Paletted).SetRGBA64", Method, 17},
{"(*Paletted).SubImage", Method, 0},
{"(*RGBA).At", Method, 0},
{"(*RGBA).Bounds", Method, 0},
{"(*RGBA).ColorModel", Method, 0},
{"(*RGBA).Opaque", Method, 0},
{"(*RGBA).PixOffset", Method, 0},
{"(*RGBA).RGBA64At", Method, 17},
{"(*RGBA).RGBAAt", Method, 4},
{"(*RGBA).Set", Method, 0},
{"(*RGBA).SetRGBA", Method, 0},
{"(*RGBA).SetRGBA64", Method, 17},
{"(*RGBA).SubImage", Method, 0},
{"(*RGBA64).At", Method, 0},
{"(*RGBA64).Bounds", Method, 0},
{"(*RGBA64).ColorModel", Method, 0},
{"(*RGBA64).Opaque", Method, 0},
{"(*RGBA64).PixOffset", Method, 0},
{"(*RGBA64).RGBA64At", Method, 4},
{"(*RGBA64).Set", Method, 0},
{"(*RGBA64).SetRGBA64", Method, 0},
{"(*RGBA64).SubImage", Method, 0},
{"(*Uniform).At", Method, 0},
{"(*Uniform).Bounds", Method, 0},
{"(*Uniform).ColorModel", Method, 0},
{"(*Uniform).Convert", Method, 0},
{"(*Uniform).Opaque", Method, 0},
{"(*Uniform).RGBA", Method, 0},
{"(*Uniform).RGBA64At", Method, 17},
{"(*YCbCr).At", Method, 0},
{"(*YCbCr).Bounds", Method, 0},
{"(*YCbCr).COffset", Method, 0},
{"(*YCbCr).ColorModel", Method, 0},
{"(*YCbCr).Opaque", Method, 0},
{"(*YCbCr).RGBA64At", Method, 17},
{"(*YCbCr).SubImage", Method, 0},
{"(*YCbCr).YCbCrAt", Method, 4},
{"(*YCbCr).YOffset", Method, 0},
{"(Point).Add", Method, 0},
{"(Point).Div", Method, 0},
{"(Point).Eq", Method, 0},
{"(Point).In", Method, 0},
{"(Point).Mod", Method, 0},
{"(Point).Mul", Method, 0},
{"(Point).String", Method, 0},
{"(Point).Sub", Method, 0},
{"(Rectangle).Add", Method, 0},
{"(Rectangle).At", Method, 5},
{"(Rectangle).Bounds", Method, 5},
{"(Rectangle).Canon", Method, 0},
{"(Rectangle).ColorModel", Method, 5},
{"(Rectangle).Dx", Method, 0},
{"(Rectangle).Dy", Method, 0},
{"(Rectangle).Empty", Method, 0},
{"(Rectangle).Eq", Method, 0},
{"(Rectangle).In", Method, 0},
{"(Rectangle).Inset", Method, 0},
{"(Rectangle).Intersect", Method, 0},
{"(Rectangle).Overlaps", Method, 0},
{"(Rectangle).RGBA64At", Method, 17},
{"(Rectangle).Size", Method, 0},
{"(Rectangle).String", Method, 0},
{"(Rectangle).Sub", Method, 0},
{"(Rectangle).Union", Method, 0},
{"(YCbCrSubsampleRatio).String", Method, 0},
{"Alpha", Type, 0},
{"Alpha.Pix", Field, 0},
{"Alpha.Rect", Field, 0},
{"Alpha.Stride", Field, 0},
{"Alpha16", Type, 0},
{"Alpha16.Pix", Field, 0},
{"Alpha16.Rect", Field, 0},
{"Alpha16.Stride", Field, 0},
{"Black", Var, 0},
{"CMYK", Type, 5},
{"CMYK.Pix", Field, 5},
{"CMYK.Rect", Field, 5},
{"CMYK.Stride", Field, 5},
{"Config", Type, 0},
{"Config.ColorModel", Field, 0},
{"Config.Height", Field, 0},
{"Config.Width", Field, 0},
{"Decode", Func, 0},
{"DecodeConfig", Func, 0},
{"ErrFormat", Var, 0},
{"Gray", Type, 0},
{"Gray.Pix", Field, 0},
{"Gray.Rect", Field, 0},
{"Gray.Stride", Field, 0},
{"Gray16", Type, 0},
{"Gray16.Pix", Field, 0},
{"Gray16.Rect", Field, 0},
{"Gray16.Stride", Field, 0},
{"Image", Type, 0},
{"NRGBA", Type, 0},
{"NRGBA.Pix", Field, 0},
{"NRGBA.Rect", Field, 0},
{"NRGBA.Stride", Field, 0},
{"NRGBA64", Type, 0},
{"NRGBA64.Pix", Field, 0},
{"NRGBA64.Rect", Field, 0},
{"NRGBA64.Stride", Field, 0},
{"NYCbCrA", Type, 6},
{"NYCbCrA.A", Field, 6},
{"NYCbCrA.AStride", Field, 6},
{"NYCbCrA.YCbCr", Field, 6},
{"NewAlpha", Func, 0},
{"NewAlpha16", Func, 0},
{"NewCMYK", Func, 5},
{"NewGray", Func, 0},
{"NewGray16", Func, 0},
{"NewNRGBA", Func, 0},
{"NewNRGBA64", Func, 0},
{"NewNYCbCrA", Func, 6},
{"NewPaletted", Func, 0},
{"NewRGBA", Func, 0},
{"NewRGBA64", Func, 0},
{"NewUniform", Func, 0},
{"NewYCbCr", Func, 0},
{"Opaque", Var, 0},
{"Paletted", Type, 0},
{"Paletted.Palette", Field, 0},
{"Paletted.Pix", Field, 0},
{"Paletted.Rect", Field, 0},
{"Paletted.Stride", Field, 0},
{"PalettedImage", Type, 0},
{"Point", Type, 0},
{"Point.X", Field, 0},
{"Point.Y", Field, 0},
{"Pt", Func, 0},
{"RGBA", Type, 0},
{"RGBA.Pix", Field, 0},
{"RGBA.Rect", Field, 0},
{"RGBA.Stride", Field, 0},
{"RGBA64", Type, 0},
{"RGBA64.Pix", Field, 0},
{"RGBA64.Rect", Field, 0},
{"RGBA64.Stride", Field, 0},
{"RGBA64Image", Type, 17},
{"Rect", Func, 0},
{"Rectangle", Type, 0},
{"Rectangle.Max", Field, 0},
{"Rectangle.Min", Field, 0},
{"RegisterFormat", Func, 0},
{"Transparent", Var, 0},
{"Uniform", Type, 0},
{"Uniform.C", Field, 0},
{"White", Var, 0},
{"YCbCr", Type, 0},
{"YCbCr.CStride", Field, 0},
{"YCbCr.Cb", Field, 0},
{"YCbCr.Cr", Field, 0},
{"YCbCr.Rect", Field, 0},
{"YCbCr.SubsampleRatio", Field, 0},
{"YCbCr.Y", Field, 0},
{"YCbCr.YStride", Field, 0},
{"YCbCrSubsampleRatio", Type, 0},
{"YCbCrSubsampleRatio410", Const, 5},
{"YCbCrSubsampleRatio411", Const, 5},
{"YCbCrSubsampleRatio420", Const, 0},
{"YCbCrSubsampleRatio422", Const, 0},
{"YCbCrSubsampleRatio440", Const, 1},
{"YCbCrSubsampleRatio444", Const, 0},
{"ZP", Var, 0},
{"ZR", Var, 0},
},
"image/color": {
{"(Alpha).RGBA", Method, 0},
{"(Alpha16).RGBA", Method, 0},
{"(CMYK).RGBA", Method, 5},
{"(Gray).RGBA", Method, 0},
{"(Gray16).RGBA", Method, 0},
{"(NRGBA).RGBA", Method, 0},
{"(NRGBA64).RGBA", Method, 0},
{"(NYCbCrA).RGBA", Method, 6},
{"(Palette).Convert", Method, 0},
{"(Palette).Index", Method, 0},
{"(RGBA).RGBA", Method, 0},
{"(RGBA64).RGBA", Method, 0},
{"(YCbCr).RGBA", Method, 0},
{"Alpha", Type, 0},
{"Alpha.A", Field, 0},
{"Alpha16", Type, 0},
{"Alpha16.A", Field, 0},
{"Alpha16Model", Var, 0},
{"AlphaModel", Var, 0},
{"Black", Var, 0},
{"CMYK", Type, 5},
{"CMYK.C", Field, 5},
{"CMYK.K", Field, 5},
{"CMYK.M", Field, 5},
{"CMYK.Y", Field, 5},
{"CMYKModel", Var, 5},
{"CMYKToRGB", Func, 5},
{"Color", Type, 0},
{"Gray", Type, 0},
{"Gray.Y", Field, 0},
{"Gray16", Type, 0},
{"Gray16.Y", Field, 0},
{"Gray16Model", Var, 0},
{"GrayModel", Var, 0},
{"Model", Type, 0},
{"ModelFunc", Func, 0},
{"NRGBA", Type, 0},
{"NRGBA.A", Field, 0},
{"NRGBA.B", Field, 0},
{"NRGBA.G", Field, 0},
{"NRGBA.R", Field, 0},
{"NRGBA64", Type, 0},
{"NRGBA64.A", Field, 0},
{"NRGBA64.B", Field, 0},
{"NRGBA64.G", Field, 0},
{"NRGBA64.R", Field, 0},
{"NRGBA64Model", Var, 0},
{"NRGBAModel", Var, 0},
{"NYCbCrA", Type, 6},
{"NYCbCrA.A", Field, 6},
{"NYCbCrA.YCbCr", Field, 6},
{"NYCbCrAModel", Var, 6},
{"Opaque", Var, 0},
{"Palette", Type, 0},
{"RGBA", Type, 0},
{"RGBA.A", Field, 0},
{"RGBA.B", Field, 0},
{"RGBA.G", Field, 0},
{"RGBA.R", Field, 0},
{"RGBA64", Type, 0},
{"RGBA64.A", Field, 0},
{"RGBA64.B", Field, 0},
{"RGBA64.G", Field, 0},
{"RGBA64.R", Field, 0},
{"RGBA64Model", Var, 0},
{"RGBAModel", Var, 0},
{"RGBToCMYK", Func, 5},
{"RGBToYCbCr", Func, 0},
{"Transparent", Var, 0},
{"White", Var, 0},
{"YCbCr", Type, 0},
{"YCbCr.Cb", Field, 0},
{"YCbCr.Cr", Field, 0},
{"YCbCr.Y", Field, 0},
{"YCbCrModel", Var, 0},
{"YCbCrToRGB", Func, 0},
},
"image/color/palette": {
{"Plan9", Var, 2},
{"WebSafe", Var, 2},
},
"image/draw": {
{"(Op).Draw", Method, 2},
{"Draw", Func, 0},
{"DrawMask", Func, 0},
{"Drawer", Type, 2},
{"FloydSteinberg", Var, 2},
{"Image", Type, 0},
{"Op", Type, 0},
{"Over", Const, 0},
{"Quantizer", Type, 2},
{"RGBA64Image", Type, 17},
{"Src", Const, 0},
},
"image/gif": {
{"Decode", Func, 0},
{"DecodeAll", Func, 0},
{"DecodeConfig", Func, 0},
{"DisposalBackground", Const, 5},
{"DisposalNone", Const, 5},
{"DisposalPrevious", Const, 5},
{"Encode", Func, 2},
{"EncodeAll", Func, 2},
{"GIF", Type, 0},
{"GIF.BackgroundIndex", Field, 5},
{"GIF.Config", Field, 5},
{"GIF.Delay", Field, 0},
{"GIF.Disposal", Field, 5},
{"GIF.Image", Field, 0},
{"GIF.LoopCount", Field, 0},
{"Options", Type, 2},
{"Options.Drawer", Field, 2},
{"Options.NumColors", Field, 2},
{"Options.Quantizer", Field, 2},
},
"image/jpeg": {
{"(FormatError).Error", Method, 0},
{"(UnsupportedError).Error", Method, 0},
{"Decode", Func, 0},
{"DecodeConfig", Func, 0},
{"DefaultQuality", Const, 0},
{"Encode", Func, 0},
{"FormatError", Type, 0},
{"Options", Type, 0},
{"Options.Quality", Field, 0},
{"Reader", Type, 0},
{"UnsupportedError", Type, 0},
},
"image/png": {
{"(*Encoder).Encode", Method, 4},
{"(FormatError).Error", Method, 0},
{"(UnsupportedError).Error", Method, 0},
{"BestCompression", Const, 4},
{"BestSpeed", Const, 4},
{"CompressionLevel", Type, 4},
{"Decode", Func, 0},
{"DecodeConfig", Func, 0},
{"DefaultCompression", Const, 4},
{"Encode", Func, 0},
{"Encoder", Type, 4},
{"Encoder.BufferPool", Field, 9},
{"Encoder.CompressionLevel", Field, 4},
{"EncoderBuffer", Type, 9},
{"EncoderBufferPool", Type, 9},
{"FormatError", Type, 0},
{"NoCompression", Const, 4},
{"UnsupportedError", Type, 0},
},
"index/suffixarray": {
{"(*Index).Bytes", Method, 0},
{"(*Index).FindAllIndex", Method, 0},
{"(*Index).Lookup", Method, 0},
{"(*Index).Read", Method, 0},
{"(*Index).Write", Method, 0},
{"Index", Type, 0},
{"New", Func, 0},
},
"io": {
{"(*LimitedReader).Read", Method, 0},
{"(*OffsetWriter).Seek", Method, 20},
{"(*OffsetWriter).Write", Method, 20},
{"(*OffsetWriter).WriteAt", Method, 20},
{"(*PipeReader).Close", Method, 0},
{"(*PipeReader).CloseWithError", Method, 0},
{"(*PipeReader).Read", Method, 0},
{"(*PipeWriter).Close", Method, 0},
{"(*PipeWriter).CloseWithError", Method, 0},
{"(*PipeWriter).Write", Method, 0},
{"(*SectionReader).Outer", Method, 22},
{"(*SectionReader).Read", Method, 0},
{"(*SectionReader).ReadAt", Method, 0},
{"(*SectionReader).Seek", Method, 0},
{"(*SectionReader).Size", Method, 0},
{"ByteReader", Type, 0},
{"ByteScanner", Type, 0},
{"ByteWriter", Type, 1},
{"Closer", Type, 0},
{"Copy", Func, 0},
{"CopyBuffer", Func, 5},
{"CopyN", Func, 0},
{"Discard", Var, 16},
{"EOF", Var, 0},
{"ErrClosedPipe", Var, 0},
{"ErrNoProgress", Var, 1},
{"ErrShortBuffer", Var, 0},
{"ErrShortWrite", Var, 0},
{"ErrUnexpectedEOF", Var, 0},
{"LimitReader", Func, 0},
{"LimitedReader", Type, 0},
{"LimitedReader.N", Field, 0},
{"LimitedReader.R", Field, 0},
{"MultiReader", Func, 0},
{"MultiWriter", Func, 0},
{"NewOffsetWriter", Func, 20},
{"NewSectionReader", Func, 0},
{"NopCloser", Func, 16},
{"OffsetWriter", Type, 20},
{"Pipe", Func, 0},
{"PipeReader", Type, 0},
{"PipeWriter", Type, 0},
{"ReadAll", Func, 16},
{"ReadAtLeast", Func, 0},
{"ReadCloser", Type, 0},
{"ReadFull", Func, 0},
{"ReadSeekCloser", Type, 16},
{"ReadSeeker", Type, 0},
{"ReadWriteCloser", Type, 0},
{"ReadWriteSeeker", Type, 0},
{"ReadWriter", Type, 0},
{"Reader", Type, 0},
{"ReaderAt", Type, 0},
{"ReaderFrom", Type, 0},
{"RuneReader", Type, 0},
{"RuneScanner", Type, 0},
{"SectionReader", Type, 0},
{"SeekCurrent", Const, 7},
{"SeekEnd", Const, 7},
{"SeekStart", Const, 7},
{"Seeker", Type, 0},
{"StringWriter", Type, 12},
{"TeeReader", Func, 0},
{"WriteCloser", Type, 0},
{"WriteSeeker", Type, 0},
{"WriteString", Func, 0},
{"Writer", Type, 0},
{"WriterAt", Type, 0},
{"WriterTo", Type, 0},
},
"io/fs": {
{"(*PathError).Error", Method, 16},
{"(*PathError).Timeout", Method, 16},
{"(*PathError).Unwrap", Method, 16},
{"(FileMode).IsDir", Method, 16},
{"(FileMode).IsRegular", Method, 16},
{"(FileMode).Perm", Method, 16},
{"(FileMode).String", Method, 16},
{"(FileMode).Type", Method, 16},
{"DirEntry", Type, 16},
{"ErrClosed", Var, 16},
{"ErrExist", Var, 16},
{"ErrInvalid", Var, 16},
{"ErrNotExist", Var, 16},
{"ErrPermission", Var, 16},
{"FS", Type, 16},
{"File", Type, 16},
{"FileInfo", Type, 16},
{"FileInfoToDirEntry", Func, 17},
{"FileMode", Type, 16},
{"FormatDirEntry", Func, 21},
{"FormatFileInfo", Func, 21},
{"Glob", Func, 16},
{"GlobFS", Type, 16},
{"ModeAppend", Const, 16},
{"ModeCharDevice", Const, 16},
{"ModeDevice", Const, 16},
{"ModeDir", Const, 16},
{"ModeExclusive", Const, 16},
{"ModeIrregular", Const, 16},
{"ModeNamedPipe", Const, 16},
{"ModePerm", Const, 16},
{"ModeSetgid", Const, 16},
{"ModeSetuid", Const, 16},
{"ModeSocket", Const, 16},
{"ModeSticky", Const, 16},
{"ModeSymlink", Const, 16},
{"ModeTemporary", Const, 16},
{"ModeType", Const, 16},
{"PathError", Type, 16},
{"PathError.Err", Field, 16},
{"PathError.Op", Field, 16},
{"PathError.Path", Field, 16},
{"ReadDir", Func, 16},
{"ReadDirFS", Type, 16},
{"ReadDirFile", Type, 16},
{"ReadFile", Func, 16},
{"ReadFileFS", Type, 16},
{"SkipAll", Var, 20},
{"SkipDir", Var, 16},
{"Stat", Func, 16},
{"StatFS", Type, 16},
{"Sub", Func, 16},
{"SubFS", Type, 16},
{"ValidPath", Func, 16},
{"WalkDir", Func, 16},
{"WalkDirFunc", Type, 16},
},
"io/ioutil": {
{"Discard", Var, 0},
{"NopCloser", Func, 0},
{"ReadAll", Func, 0},
{"ReadDir", Func, 0},
{"ReadFile", Func, 0},
{"TempDir", Func, 0},
{"TempFile", Func, 0},
{"WriteFile", Func, 0},
},
"iter": {
{"Pull", Func, 23},
{"Pull2", Func, 23},
{"Seq", Type, 23},
{"Seq2", Type, 23},
},
"log": {
{"(*Logger).Fatal", Method, 0},
{"(*Logger).Fatalf", Method, 0},
{"(*Logger).Fatalln", Method, 0},
{"(*Logger).Flags", Method, 0},
{"(*Logger).Output", Method, 0},
{"(*Logger).Panic", Method, 0},
{"(*Logger).Panicf", Method, 0},
{"(*Logger).Panicln", Method, 0},
{"(*Logger).Prefix", Method, 0},
{"(*Logger).Print", Method, 0},
{"(*Logger).Printf", Method, 0},
{"(*Logger).Println", Method, 0},
{"(*Logger).SetFlags", Method, 0},
{"(*Logger).SetOutput", Method, 5},
{"(*Logger).SetPrefix", Method, 0},
{"(*Logger).Writer", Method, 12},
{"Default", Func, 16},
{"Fatal", Func, 0},
{"Fatalf", Func, 0},
{"Fatalln", Func, 0},
{"Flags", Func, 0},
{"LUTC", Const, 5},
{"Ldate", Const, 0},
{"Llongfile", Const, 0},
{"Lmicroseconds", Const, 0},
{"Lmsgprefix", Const, 14},
{"Logger", Type, 0},
{"Lshortfile", Const, 0},
{"LstdFlags", Const, 0},
{"Ltime", Const, 0},
{"New", Func, 0},
{"Output", Func, 5},
{"Panic", Func, 0},
{"Panicf", Func, 0},
{"Panicln", Func, 0},
{"Prefix", Func, 0},
{"Print", Func, 0},
{"Printf", Func, 0},
{"Println", Func, 0},
{"SetFlags", Func, 0},
{"SetOutput", Func, 0},
{"SetPrefix", Func, 0},
{"Writer", Func, 13},
},
"log/slog": {
{"(*JSONHandler).Enabled", Method, 21},
{"(*JSONHandler).Handle", Method, 21},
{"(*JSONHandler).WithAttrs", Method, 21},
{"(*JSONHandler).WithGroup", Method, 21},
{"(*Level).UnmarshalJSON", Method, 21},
{"(*Level).UnmarshalText", Method, 21},
{"(*LevelVar).Level", Method, 21},
{"(*LevelVar).MarshalText", Method, 21},
{"(*LevelVar).Set", Method, 21},
{"(*LevelVar).String", Method, 21},
{"(*LevelVar).UnmarshalText", Method, 21},
{"(*Logger).Debug", Method, 21},
{"(*Logger).DebugContext", Method, 21},
{"(*Logger).Enabled", Method, 21},
{"(*Logger).Error", Method, 21},
{"(*Logger).ErrorContext", Method, 21},
{"(*Logger).Handler", Method, 21},
{"(*Logger).Info", Method, 21},
{"(*Logger).InfoContext", Method, 21},
{"(*Logger).Log", Method, 21},
{"(*Logger).LogAttrs", Method, 21},
{"(*Logger).Warn", Method, 21},
{"(*Logger).WarnContext", Method, 21},
{"(*Logger).With", Method, 21},
{"(*Logger).WithGroup", Method, 21},
{"(*Record).Add", Method, 21},
{"(*Record).AddAttrs", Method, 21},
{"(*TextHandler).Enabled", Method, 21},
{"(*TextHandler).Handle", Method, 21},
{"(*TextHandler).WithAttrs", Method, 21},
{"(*TextHandler).WithGroup", Method, 21},
{"(Attr).Equal", Method, 21},
{"(Attr).String", Method, 21},
{"(Kind).String", Method, 21},
{"(Level).Level", Method, 21},
{"(Level).MarshalJSON", Method, 21},
{"(Level).MarshalText", Method, 21},
{"(Level).String", Method, 21},
{"(Record).Attrs", Method, 21},
{"(Record).Clone", Method, 21},
{"(Record).NumAttrs", Method, 21},
{"(Value).Any", Method, 21},
{"(Value).Bool", Method, 21},
{"(Value).Duration", Method, 21},
{"(Value).Equal", Method, 21},
{"(Value).Float64", Method, 21},
{"(Value).Group", Method, 21},
{"(Value).Int64", Method, 21},
{"(Value).Kind", Method, 21},
{"(Value).LogValuer", Method, 21},
{"(Value).Resolve", Method, 21},
{"(Value).String", Method, 21},
{"(Value).Time", Method, 21},
{"(Value).Uint64", Method, 21},
{"Any", Func, 21},
{"AnyValue", Func, 21},
{"Attr", Type, 21},
{"Attr.Key", Field, 21},
{"Attr.Value", Field, 21},
{"Bool", Func, 21},
{"BoolValue", Func, 21},
{"Debug", Func, 21},
{"DebugContext", Func, 21},
{"Default", Func, 21},
{"Duration", Func, 21},
{"DurationValue", Func, 21},
{"Error", Func, 21},
{"ErrorContext", Func, 21},
{"Float64", Func, 21},
{"Float64Value", Func, 21},
{"Group", Func, 21},
{"GroupValue", Func, 21},
{"Handler", Type, 21},
{"HandlerOptions", Type, 21},
{"HandlerOptions.AddSource", Field, 21},
{"HandlerOptions.Level", Field, 21},
{"HandlerOptions.ReplaceAttr", Field, 21},
{"Info", Func, 21},
{"InfoContext", Func, 21},
{"Int", Func, 21},
{"Int64", Func, 21},
{"Int64Value", Func, 21},
{"IntValue", Func, 21},
{"JSONHandler", Type, 21},
{"Kind", Type, 21},
{"KindAny", Const, 21},
{"KindBool", Const, 21},
{"KindDuration", Const, 21},
{"KindFloat64", Const, 21},
{"KindGroup", Const, 21},
{"KindInt64", Const, 21},
{"KindLogValuer", Const, 21},
{"KindString", Const, 21},
{"KindTime", Const, 21},
{"KindUint64", Const, 21},
{"Level", Type, 21},
{"LevelDebug", Const, 21},
{"LevelError", Const, 21},
{"LevelInfo", Const, 21},
{"LevelKey", Const, 21},
{"LevelVar", Type, 21},
{"LevelWarn", Const, 21},
{"Leveler", Type, 21},
{"Log", Func, 21},
{"LogAttrs", Func, 21},
{"LogValuer", Type, 21},
{"Logger", Type, 21},
{"MessageKey", Const, 21},
{"New", Func, 21},
{"NewJSONHandler", Func, 21},
{"NewLogLogger", Func, 21},
{"NewRecord", Func, 21},
{"NewTextHandler", Func, 21},
{"Record", Type, 21},
{"Record.Level", Field, 21},
{"Record.Message", Field, 21},
{"Record.PC", Field, 21},
{"Record.Time", Field, 21},
{"SetDefault", Func, 21},
{"SetLogLoggerLevel", Func, 22},
{"Source", Type, 21},
{"Source.File", Field, 21},
{"Source.Function", Field, 21},
{"Source.Line", Field, 21},
{"SourceKey", Const, 21},
{"String", Func, 21},
{"StringValue", Func, 21},
{"TextHandler", Type, 21},
{"Time", Func, 21},
{"TimeKey", Const, 21},
{"TimeValue", Func, 21},
{"Uint64", Func, 21},
{"Uint64Value", Func, 21},
{"Value", Type, 21},
{"Warn", Func, 21},
{"WarnContext", Func, 21},
{"With", Func, 21},
},
"log/syslog": {
{"(*Writer).Alert", Method, 0},
{"(*Writer).Close", Method, 0},
{"(*Writer).Crit", Method, 0},
{"(*Writer).Debug", Method, 0},
{"(*Writer).Emerg", Method, 0},
{"(*Writer).Err", Method, 0},
{"(*Writer).Info", Method, 0},
{"(*Writer).Notice", Method, 0},
{"(*Writer).Warning", Method, 0},
{"(*Writer).Write", Method, 0},
{"Dial", Func, 0},
{"LOG_ALERT", Const, 0},
{"LOG_AUTH", Const, 1},
{"LOG_AUTHPRIV", Const, 1},
{"LOG_CRIT", Const, 0},
{"LOG_CRON", Const, 1},
{"LOG_DAEMON", Const, 1},
{"LOG_DEBUG", Const, 0},
{"LOG_EMERG", Const, 0},
{"LOG_ERR", Const, 0},
{"LOG_FTP", Const, 1},
{"LOG_INFO", Const, 0},
{"LOG_KERN", Const, 1},
{"LOG_LOCAL0", Const, 1},
{"LOG_LOCAL1", Const, 1},
{"LOG_LOCAL2", Const, 1},
{"LOG_LOCAL3", Const, 1},
{"LOG_LOCAL4", Const, 1},
{"LOG_LOCAL5", Const, 1},
{"LOG_LOCAL6", Const, 1},
{"LOG_LOCAL7", Const, 1},
{"LOG_LPR", Const, 1},
{"LOG_MAIL", Const, 1},
{"LOG_NEWS", Const, 1},
{"LOG_NOTICE", Const, 0},
{"LOG_SYSLOG", Const, 1},
{"LOG_USER", Const, 1},
{"LOG_UUCP", Const, 1},
{"LOG_WARNING", Const, 0},
{"New", Func, 0},
{"NewLogger", Func, 0},
{"Priority", Type, 0},
{"Writer", Type, 0},
},
"maps": {
{"All", Func, 23},
{"Clone", Func, 21},
{"Collect", Func, 23},
{"Copy", Func, 21},
{"DeleteFunc", Func, 21},
{"Equal", Func, 21},
{"EqualFunc", Func, 21},
{"Insert", Func, 23},
{"Keys", Func, 23},
{"Values", Func, 23},
},
"math": {
{"Abs", Func, 0},
{"Acos", Func, 0},
{"Acosh", Func, 0},
{"Asin", Func, 0},
{"Asinh", Func, 0},
{"Atan", Func, 0},
{"Atan2", Func, 0},
{"Atanh", Func, 0},
{"Cbrt", Func, 0},
{"Ceil", Func, 0},
{"Copysign", Func, 0},
{"Cos", Func, 0},
{"Cosh", Func, 0},
{"Dim", Func, 0},
{"E", Const, 0},
{"Erf", Func, 0},
{"Erfc", Func, 0},
{"Erfcinv", Func, 10},
{"Erfinv", Func, 10},
{"Exp", Func, 0},
{"Exp2", Func, 0},
{"Expm1", Func, 0},
{"FMA", Func, 14},
{"Float32bits", Func, 0},
{"Float32frombits", Func, 0},
{"Float64bits", Func, 0},
{"Float64frombits", Func, 0},
{"Floor", Func, 0},
{"Frexp", Func, 0},
{"Gamma", Func, 0},
{"Hypot", Func, 0},
{"Ilogb", Func, 0},
{"Inf", Func, 0},
{"IsInf", Func, 0},
{"IsNaN", Func, 0},
{"J0", Func, 0},
{"J1", Func, 0},
{"Jn", Func, 0},
{"Ldexp", Func, 0},
{"Lgamma", Func, 0},
{"Ln10", Const, 0},
{"Ln2", Const, 0},
{"Log", Func, 0},
{"Log10", Func, 0},
{"Log10E", Const, 0},
{"Log1p", Func, 0},
{"Log2", Func, 0},
{"Log2E", Const, 0},
{"Logb", Func, 0},
{"Max", Func, 0},
{"MaxFloat32", Const, 0},
{"MaxFloat64", Const, 0},
{"MaxInt", Const, 17},
{"MaxInt16", Const, 0},
{"MaxInt32", Const, 0},
{"MaxInt64", Const, 0},
{"MaxInt8", Const, 0},
{"MaxUint", Const, 17},
{"MaxUint16", Const, 0},
{"MaxUint32", Const, 0},
{"MaxUint64", Const, 0},
{"MaxUint8", Const, 0},
{"Min", Func, 0},
{"MinInt", Const, 17},
{"MinInt16", Const, 0},
{"MinInt32", Const, 0},
{"MinInt64", Const, 0},
{"MinInt8", Const, 0},
{"Mod", Func, 0},
{"Modf", Func, 0},
{"NaN", Func, 0},
{"Nextafter", Func, 0},
{"Nextafter32", Func, 4},
{"Phi", Const, 0},
{"Pi", Const, 0},
{"Pow", Func, 0},
{"Pow10", Func, 0},
{"Remainder", Func, 0},
{"Round", Func, 10},
{"RoundToEven", Func, 10},
{"Signbit", Func, 0},
{"Sin", Func, 0},
{"Sincos", Func, 0},
{"Sinh", Func, 0},
{"SmallestNonzeroFloat32", Const, 0},
{"SmallestNonzeroFloat64", Const, 0},
{"Sqrt", Func, 0},
{"Sqrt2", Const, 0},
{"SqrtE", Const, 0},
{"SqrtPhi", Const, 0},
{"SqrtPi", Const, 0},
{"Tan", Func, 0},
{"Tanh", Func, 0},
{"Trunc", Func, 0},
{"Y0", Func, 0},
{"Y1", Func, 0},
{"Yn", Func, 0},
},
"math/big": {
{"(*Float).Abs", Method, 5},
{"(*Float).Acc", Method, 5},
{"(*Float).Add", Method, 5},
{"(*Float).Append", Method, 5},
{"(*Float).Cmp", Method, 5},
{"(*Float).Copy", Method, 5},
{"(*Float).Float32", Method, 5},
{"(*Float).Float64", Method, 5},
{"(*Float).Format", Method, 5},
{"(*Float).GobDecode", Method, 7},
{"(*Float).GobEncode", Method, 7},
{"(*Float).Int", Method, 5},
{"(*Float).Int64", Method, 5},
{"(*Float).IsInf", Method, 5},
{"(*Float).IsInt", Method, 5},
{"(*Float).MantExp", Method, 5},
{"(*Float).MarshalText", Method, 6},
{"(*Float).MinPrec", Method, 5},
{"(*Float).Mode", Method, 5},
{"(*Float).Mul", Method, 5},
{"(*Float).Neg", Method, 5},
{"(*Float).Parse", Method, 5},
{"(*Float).Prec", Method, 5},
{"(*Float).Quo", Method, 5},
{"(*Float).Rat", Method, 5},
{"(*Float).Scan", Method, 8},
{"(*Float).Set", Method, 5},
{"(*Float).SetFloat64", Method, 5},
{"(*Float).SetInf", Method, 5},
{"(*Float).SetInt", Method, 5},
{"(*Float).SetInt64", Method, 5},
{"(*Float).SetMantExp", Method, 5},
{"(*Float).SetMode", Method, 5},
{"(*Float).SetPrec", Method, 5},
{"(*Float).SetRat", Method, 5},
{"(*Float).SetString", Method, 5},
{"(*Float).SetUint64", Method, 5},
{"(*Float).Sign", Method, 5},
{"(*Float).Signbit", Method, 5},
{"(*Float).Sqrt", Method, 10},
{"(*Float).String", Method, 5},
{"(*Float).Sub", Method, 5},
{"(*Float).Text", Method, 5},
{"(*Float).Uint64", Method, 5},
{"(*Float).UnmarshalText", Method, 6},
{"(*Int).Abs", Method, 0},
{"(*Int).Add", Method, 0},
{"(*Int).And", Method, 0},
{"(*Int).AndNot", Method, 0},
{"(*Int).Append", Method, 6},
{"(*Int).Binomial", Method, 0},
{"(*Int).Bit", Method, 0},
{"(*Int).BitLen", Method, 0},
{"(*Int).Bits", Method, 0},
{"(*Int).Bytes", Method, 0},
{"(*Int).Cmp", Method, 0},
{"(*Int).CmpAbs", Method, 10},
{"(*Int).Div", Method, 0},
{"(*Int).DivMod", Method, 0},
{"(*Int).Exp", Method, 0},
{"(*Int).FillBytes", Method, 15},
{"(*Int).Float64", Method, 21},
{"(*Int).Format", Method, 0},
{"(*Int).GCD", Method, 0},
{"(*Int).GobDecode", Method, 0},
{"(*Int).GobEncode", Method, 0},
{"(*Int).Int64", Method, 0},
{"(*Int).IsInt64", Method, 9},
{"(*Int).IsUint64", Method, 9},
{"(*Int).Lsh", Method, 0},
{"(*Int).MarshalJSON", Method, 1},
{"(*Int).MarshalText", Method, 3},
{"(*Int).Mod", Method, 0},
{"(*Int).ModInverse", Method, 0},
{"(*Int).ModSqrt", Method, 5},
{"(*Int).Mul", Method, 0},
{"(*Int).MulRange", Method, 0},
{"(*Int).Neg", Method, 0},
{"(*Int).Not", Method, 0},
{"(*Int).Or", Method, 0},
{"(*Int).ProbablyPrime", Method, 0},
{"(*Int).Quo", Method, 0},
{"(*Int).QuoRem", Method, 0},
{"(*Int).Rand", Method, 0},
{"(*Int).Rem", Method, 0},
{"(*Int).Rsh", Method, 0},
{"(*Int).Scan", Method, 0},
{"(*Int).Set", Method, 0},
{"(*Int).SetBit", Method, 0},
{"(*Int).SetBits", Method, 0},
{"(*Int).SetBytes", Method, 0},
{"(*Int).SetInt64", Method, 0},
{"(*Int).SetString", Method, 0},
{"(*Int).SetUint64", Method, 1},
{"(*Int).Sign", Method, 0},
{"(*Int).Sqrt", Method, 8},
{"(*Int).String", Method, 0},
{"(*Int).Sub", Method, 0},
{"(*Int).Text", Method, 6},
{"(*Int).TrailingZeroBits", Method, 13},
{"(*Int).Uint64", Method, 1},
{"(*Int).UnmarshalJSON", Method, 1},
{"(*Int).UnmarshalText", Method, 3},
{"(*Int).Xor", Method, 0},
{"(*Rat).Abs", Method, 0},
{"(*Rat).Add", Method, 0},
{"(*Rat).Cmp", Method, 0},
{"(*Rat).Denom", Method, 0},
{"(*Rat).Float32", Method, 4},
{"(*Rat).Float64", Method, 1},
{"(*Rat).FloatPrec", Method, 22},
{"(*Rat).FloatString", Method, 0},
{"(*Rat).GobDecode", Method, 0},
{"(*Rat).GobEncode", Method, 0},
{"(*Rat).Inv", Method, 0},
{"(*Rat).IsInt", Method, 0},
{"(*Rat).MarshalText", Method, 3},
{"(*Rat).Mul", Method, 0},
{"(*Rat).Neg", Method, 0},
{"(*Rat).Num", Method, 0},
{"(*Rat).Quo", Method, 0},
{"(*Rat).RatString", Method, 0},
{"(*Rat).Scan", Method, 0},
{"(*Rat).Set", Method, 0},
{"(*Rat).SetFloat64", Method, 1},
{"(*Rat).SetFrac", Method, 0},
{"(*Rat).SetFrac64", Method, 0},
{"(*Rat).SetInt", Method, 0},
{"(*Rat).SetInt64", Method, 0},
{"(*Rat).SetString", Method, 0},
{"(*Rat).SetUint64", Method, 13},
{"(*Rat).Sign", Method, 0},
{"(*Rat).String", Method, 0},
{"(*Rat).Sub", Method, 0},
{"(*Rat).UnmarshalText", Method, 3},
{"(Accuracy).String", Method, 5},
{"(ErrNaN).Error", Method, 5},
{"(RoundingMode).String", Method, 5},
{"Above", Const, 5},
{"Accuracy", Type, 5},
{"AwayFromZero", Const, 5},
{"Below", Const, 5},
{"ErrNaN", Type, 5},
{"Exact", Const, 5},
{"Float", Type, 5},
{"Int", Type, 0},
{"Jacobi", Func, 5},
{"MaxBase", Const, 0},
{"MaxExp", Const, 5},
{"MaxPrec", Const, 5},
{"MinExp", Const, 5},
{"NewFloat", Func, 5},
{"NewInt", Func, 0},
{"NewRat", Func, 0},
{"ParseFloat", Func, 5},
{"Rat", Type, 0},
{"RoundingMode", Type, 5},
{"ToNearestAway", Const, 5},
{"ToNearestEven", Const, 5},
{"ToNegativeInf", Const, 5},
{"ToPositiveInf", Const, 5},
{"ToZero", Const, 5},
{"Word", Type, 0},
},
"math/bits": {
{"Add", Func, 12},
{"Add32", Func, 12},
{"Add64", Func, 12},
{"Div", Func, 12},
{"Div32", Func, 12},
{"Div64", Func, 12},
{"LeadingZeros", Func, 9},
{"LeadingZeros16", Func, 9},
{"LeadingZeros32", Func, 9},
{"LeadingZeros64", Func, 9},
{"LeadingZeros8", Func, 9},
{"Len", Func, 9},
{"Len16", Func, 9},
{"Len32", Func, 9},
{"Len64", Func, 9},
{"Len8", Func, 9},
{"Mul", Func, 12},
{"Mul32", Func, 12},
{"Mul64", Func, 12},
{"OnesCount", Func, 9},
{"OnesCount16", Func, 9},
{"OnesCount32", Func, 9},
{"OnesCount64", Func, 9},
{"OnesCount8", Func, 9},
{"Rem", Func, 14},
{"Rem32", Func, 14},
{"Rem64", Func, 14},
{"Reverse", Func, 9},
{"Reverse16", Func, 9},
{"Reverse32", Func, 9},
{"Reverse64", Func, 9},
{"Reverse8", Func, 9},
{"ReverseBytes", Func, 9},
{"ReverseBytes16", Func, 9},
{"ReverseBytes32", Func, 9},
{"ReverseBytes64", Func, 9},
{"RotateLeft", Func, 9},
{"RotateLeft16", Func, 9},
{"RotateLeft32", Func, 9},
{"RotateLeft64", Func, 9},
{"RotateLeft8", Func, 9},
{"Sub", Func, 12},
{"Sub32", Func, 12},
{"Sub64", Func, 12},
{"TrailingZeros", Func, 9},
{"TrailingZeros16", Func, 9},
{"TrailingZeros32", Func, 9},
{"TrailingZeros64", Func, 9},
{"TrailingZeros8", Func, 9},
{"UintSize", Const, 9},
},
"math/cmplx": {
{"Abs", Func, 0},
{"Acos", Func, 0},
{"Acosh", Func, 0},
{"Asin", Func, 0},
{"Asinh", Func, 0},
{"Atan", Func, 0},
{"Atanh", Func, 0},
{"Conj", Func, 0},
{"Cos", Func, 0},
{"Cosh", Func, 0},
{"Cot", Func, 0},
{"Exp", Func, 0},
{"Inf", Func, 0},
{"IsInf", Func, 0},
{"IsNaN", Func, 0},
{"Log", Func, 0},
{"Log10", Func, 0},
{"NaN", Func, 0},
{"Phase", Func, 0},
{"Polar", Func, 0},
{"Pow", Func, 0},
{"Rect", Func, 0},
{"Sin", Func, 0},
{"Sinh", Func, 0},
{"Sqrt", Func, 0},
{"Tan", Func, 0},
{"Tanh", Func, 0},
},
"math/rand": {
{"(*Rand).ExpFloat64", Method, 0},
{"(*Rand).Float32", Method, 0},
{"(*Rand).Float64", Method, 0},
{"(*Rand).Int", Method, 0},
{"(*Rand).Int31", Method, 0},
{"(*Rand).Int31n", Method, 0},
{"(*Rand).Int63", Method, 0},
{"(*Rand).Int63n", Method, 0},
{"(*Rand).Intn", Method, 0},
{"(*Rand).NormFloat64", Method, 0},
{"(*Rand).Perm", Method, 0},
{"(*Rand).Read", Method, 6},
{"(*Rand).Seed", Method, 0},
{"(*Rand).Shuffle", Method, 10},
{"(*Rand).Uint32", Method, 0},
{"(*Rand).Uint64", Method, 8},
{"(*Zipf).Uint64", Method, 0},
{"ExpFloat64", Func, 0},
{"Float32", Func, 0},
{"Float64", Func, 0},
{"Int", Func, 0},
{"Int31", Func, 0},
{"Int31n", Func, 0},
{"Int63", Func, 0},
{"Int63n", Func, 0},
{"Intn", Func, 0},
{"New", Func, 0},
{"NewSource", Func, 0},
{"NewZipf", Func, 0},
{"NormFloat64", Func, 0},
{"Perm", Func, 0},
{"Rand", Type, 0},
{"Read", Func, 6},
{"Seed", Func, 0},
{"Shuffle", Func, 10},
{"Source", Type, 0},
{"Source64", Type, 8},
{"Uint32", Func, 0},
{"Uint64", Func, 8},
{"Zipf", Type, 0},
},
"math/rand/v2": {
{"(*ChaCha8).MarshalBinary", Method, 22},
{"(*ChaCha8).Read", Method, 23},
{"(*ChaCha8).Seed", Method, 22},
{"(*ChaCha8).Uint64", Method, 22},
{"(*ChaCha8).UnmarshalBinary", Method, 22},
{"(*PCG).MarshalBinary", Method, 22},
{"(*PCG).Seed", Method, 22},
{"(*PCG).Uint64", Method, 22},
{"(*PCG).UnmarshalBinary", Method, 22},
{"(*Rand).ExpFloat64", Method, 22},
{"(*Rand).Float32", Method, 22},
{"(*Rand).Float64", Method, 22},
{"(*Rand).Int", Method, 22},
{"(*Rand).Int32", Method, 22},
{"(*Rand).Int32N", Method, 22},
{"(*Rand).Int64", Method, 22},
{"(*Rand).Int64N", Method, 22},
{"(*Rand).IntN", Method, 22},
{"(*Rand).NormFloat64", Method, 22},
{"(*Rand).Perm", Method, 22},
{"(*Rand).Shuffle", Method, 22},
{"(*Rand).Uint", Method, 23},
{"(*Rand).Uint32", Method, 22},
{"(*Rand).Uint32N", Method, 22},
{"(*Rand).Uint64", Method, 22},
{"(*Rand).Uint64N", Method, 22},
{"(*Rand).UintN", Method, 22},
{"(*Zipf).Uint64", Method, 22},
{"ChaCha8", Type, 22},
{"ExpFloat64", Func, 22},
{"Float32", Func, 22},
{"Float64", Func, 22},
{"Int", Func, 22},
{"Int32", Func, 22},
{"Int32N", Func, 22},
{"Int64", Func, 22},
{"Int64N", Func, 22},
{"IntN", Func, 22},
{"N", Func, 22},
{"New", Func, 22},
{"NewChaCha8", Func, 22},
{"NewPCG", Func, 22},
{"NewZipf", Func, 22},
{"NormFloat64", Func, 22},
{"PCG", Type, 22},
{"Perm", Func, 22},
{"Rand", Type, 22},
{"Shuffle", Func, 22},
{"Source", Type, 22},
{"Uint", Func, 23},
{"Uint32", Func, 22},
{"Uint32N", Func, 22},
{"Uint64", Func, 22},
{"Uint64N", Func, 22},
{"UintN", Func, 22},
{"Zipf", Type, 22},
},
"mime": {
{"(*WordDecoder).Decode", Method, 5},
{"(*WordDecoder).DecodeHeader", Method, 5},
{"(WordEncoder).Encode", Method, 5},
{"AddExtensionType", Func, 0},
{"BEncoding", Const, 5},
{"ErrInvalidMediaParameter", Var, 9},
{"ExtensionsByType", Func, 5},
{"FormatMediaType", Func, 0},
{"ParseMediaType", Func, 0},
{"QEncoding", Const, 5},
{"TypeByExtension", Func, 0},
{"WordDecoder", Type, 5},
{"WordDecoder.CharsetReader", Field, 5},
{"WordEncoder", Type, 5},
},
"mime/multipart": {
{"(*FileHeader).Open", Method, 0},
{"(*Form).RemoveAll", Method, 0},
{"(*Part).Close", Method, 0},
{"(*Part).FileName", Method, 0},
{"(*Part).FormName", Method, 0},
{"(*Part).Read", Method, 0},
{"(*Reader).NextPart", Method, 0},
{"(*Reader).NextRawPart", Method, 14},
{"(*Reader).ReadForm", Method, 0},
{"(*Writer).Boundary", Method, 0},
{"(*Writer).Close", Method, 0},
{"(*Writer).CreateFormField", Method, 0},
{"(*Writer).CreateFormFile", Method, 0},
{"(*Writer).CreatePart", Method, 0},
{"(*Writer).FormDataContentType", Method, 0},
{"(*Writer).SetBoundary", Method, 1},
{"(*Writer).WriteField", Method, 0},
{"ErrMessageTooLarge", Var, 9},
{"File", Type, 0},
{"FileHeader", Type, 0},
{"FileHeader.Filename", Field, 0},
{"FileHeader.Header", Field, 0},
{"FileHeader.Size", Field, 9},
{"Form", Type, 0},
{"Form.File", Field, 0},
{"Form.Value", Field, 0},
{"NewReader", Func, 0},
{"NewWriter", Func, 0},
{"Part", Type, 0},
{"Part.Header", Field, 0},
{"Reader", Type, 0},
{"Writer", Type, 0},
},
"mime/quotedprintable": {
{"(*Reader).Read", Method, 5},
{"(*Writer).Close", Method, 5},
{"(*Writer).Write", Method, 5},
{"NewReader", Func, 5},
{"NewWriter", Func, 5},
{"Reader", Type, 5},
{"Writer", Type, 5},
{"Writer.Binary", Field, 5},
},
"net": {
{"(*AddrError).Error", Method, 0},
{"(*AddrError).Temporary", Method, 0},
{"(*AddrError).Timeout", Method, 0},
{"(*Buffers).Read", Method, 8},
{"(*Buffers).WriteTo", Method, 8},
{"(*DNSConfigError).Error", Method, 0},
{"(*DNSConfigError).Temporary", Method, 0},
{"(*DNSConfigError).Timeout", Method, 0},
{"(*DNSConfigError).Unwrap", Method, 13},
{"(*DNSError).Error", Method, 0},
{"(*DNSError).Temporary", Method, 0},
{"(*DNSError).Timeout", Method, 0},
{"(*DNSError).Unwrap", Method, 23},
{"(*Dialer).Dial", Method, 1},
{"(*Dialer).DialContext", Method, 7},
{"(*Dialer).MultipathTCP", Method, 21},
{"(*Dialer).SetMultipathTCP", Method, 21},
{"(*IP).UnmarshalText", Method, 2},
{"(*IPAddr).Network", Method, 0},
{"(*IPAddr).String", Method, 0},
{"(*IPConn).Close", Method, 0},
{"(*IPConn).File", Method, 0},
{"(*IPConn).LocalAddr", Method, 0},
{"(*IPConn).Read", Method, 0},
{"(*IPConn).ReadFrom", Method, 0},
{"(*IPConn).ReadFromIP", Method, 0},
{"(*IPConn).ReadMsgIP", Method, 1},
{"(*IPConn).RemoteAddr", Method, 0},
{"(*IPConn).SetDeadline", Method, 0},
{"(*IPConn).SetReadBuffer", Method, 0},
{"(*IPConn).SetReadDeadline", Method, 0},
{"(*IPConn).SetWriteBuffer", Method, 0},
{"(*IPConn).SetWriteDeadline", Method, 0},
{"(*IPConn).SyscallConn", Method, 9},
{"(*IPConn).Write", Method, 0},
{"(*IPConn).WriteMsgIP", Method, 1},
{"(*IPConn).WriteTo", Method, 0},
{"(*IPConn).WriteToIP", Method, 0},
{"(*IPNet).Contains", Method, 0},
{"(*IPNet).Network", Method, 0},
{"(*IPNet).String", Method, 0},
{"(*Interface).Addrs", Method, 0},
{"(*Interface).MulticastAddrs", Method, 0},
{"(*ListenConfig).Listen", Method, 11},
{"(*ListenConfig).ListenPacket", Method, 11},
{"(*ListenConfig).MultipathTCP", Method, 21},
{"(*ListenConfig).SetMultipathTCP", Method, 21},
{"(*OpError).Error", Method, 0},
{"(*OpError).Temporary", Method, 0},
{"(*OpError).Timeout", Method, 0},
{"(*OpError).Unwrap", Method, 13},
{"(*ParseError).Error", Method, 0},
{"(*ParseError).Temporary", Method, 17},
{"(*ParseError).Timeout", Method, 17},
{"(*Resolver).LookupAddr", Method, 8},
{"(*Resolver).LookupCNAME", Method, 8},
{"(*Resolver).LookupHost", Method, 8},
{"(*Resolver).LookupIP", Method, 15},
{"(*Resolver).LookupIPAddr", Method, 8},
{"(*Resolver).LookupMX", Method, 8},
{"(*Resolver).LookupNS", Method, 8},
{"(*Resolver).LookupNetIP", Method, 18},
{"(*Resolver).LookupPort", Method, 8},
{"(*Resolver).LookupSRV", Method, 8},
{"(*Resolver).LookupTXT", Method, 8},
{"(*TCPAddr).AddrPort", Method, 18},
{"(*TCPAddr).Network", Method, 0},
{"(*TCPAddr).String", Method, 0},
{"(*TCPConn).Close", Method, 0},
{"(*TCPConn).CloseRead", Method, 0},
{"(*TCPConn).CloseWrite", Method, 0},
{"(*TCPConn).File", Method, 0},
{"(*TCPConn).LocalAddr", Method, 0},
{"(*TCPConn).MultipathTCP", Method, 21},
{"(*TCPConn).Read", Method, 0},
{"(*TCPConn).ReadFrom", Method, 0},
{"(*TCPConn).RemoteAddr", Method, 0},
{"(*TCPConn).SetDeadline", Method, 0},
{"(*TCPConn).SetKeepAlive", Method, 0},
{"(*TCPConn).SetKeepAliveConfig", Method, 23},
{"(*TCPConn).SetKeepAlivePeriod", Method, 2},
{"(*TCPConn).SetLinger", Method, 0},
{"(*TCPConn).SetNoDelay", Method, 0},
{"(*TCPConn).SetReadBuffer", Method, 0},
{"(*TCPConn).SetReadDeadline", Method, 0},
{"(*TCPConn).SetWriteBuffer", Method, 0},
{"(*TCPConn).SetWriteDeadline", Method, 0},
{"(*TCPConn).SyscallConn", Method, 9},
{"(*TCPConn).Write", Method, 0},
{"(*TCPConn).WriteTo", Method, 22},
{"(*TCPListener).Accept", Method, 0},
{"(*TCPListener).AcceptTCP", Method, 0},
{"(*TCPListener).Addr", Method, 0},
{"(*TCPListener).Close", Method, 0},
{"(*TCPListener).File", Method, 0},
{"(*TCPListener).SetDeadline", Method, 0},
{"(*TCPListener).SyscallConn", Method, 10},
{"(*UDPAddr).AddrPort", Method, 18},
{"(*UDPAddr).Network", Method, 0},
{"(*UDPAddr).String", Method, 0},
{"(*UDPConn).Close", Method, 0},
{"(*UDPConn).File", Method, 0},
{"(*UDPConn).LocalAddr", Method, 0},
{"(*UDPConn).Read", Method, 0},
{"(*UDPConn).ReadFrom", Method, 0},
{"(*UDPConn).ReadFromUDP", Method, 0},
{"(*UDPConn).ReadFromUDPAddrPort", Method, 18},
{"(*UDPConn).ReadMsgUDP", Method, 1},
{"(*UDPConn).ReadMsgUDPAddrPort", Method, 18},
{"(*UDPConn).RemoteAddr", Method, 0},
{"(*UDPConn).SetDeadline", Method, 0},
{"(*UDPConn).SetReadBuffer", Method, 0},
{"(*UDPConn).SetReadDeadline", Method, 0},
{"(*UDPConn).SetWriteBuffer", Method, 0},
{"(*UDPConn).SetWriteDeadline", Method, 0},
{"(*UDPConn).SyscallConn", Method, 9},
{"(*UDPConn).Write", Method, 0},
{"(*UDPConn).WriteMsgUDP", Method, 1},
{"(*UDPConn).WriteMsgUDPAddrPort", Method, 18},
{"(*UDPConn).WriteTo", Method, 0},
{"(*UDPConn).WriteToUDP", Method, 0},
{"(*UDPConn).WriteToUDPAddrPort", Method, 18},
{"(*UnixAddr).Network", Method, 0},
{"(*UnixAddr).String", Method, 0},
{"(*UnixConn).Close", Method, 0},
{"(*UnixConn).CloseRead", Method, 1},
{"(*UnixConn).CloseWrite", Method, 1},
{"(*UnixConn).File", Method, 0},
{"(*UnixConn).LocalAddr", Method, 0},
{"(*UnixConn).Read", Method, 0},
{"(*UnixConn).ReadFrom", Method, 0},
{"(*UnixConn).ReadFromUnix", Method, 0},
{"(*UnixConn).ReadMsgUnix", Method, 0},
{"(*UnixConn).RemoteAddr", Method, 0},
{"(*UnixConn).SetDeadline", Method, 0},
{"(*UnixConn).SetReadBuffer", Method, 0},
{"(*UnixConn).SetReadDeadline", Method, 0},
{"(*UnixConn).SetWriteBuffer", Method, 0},
{"(*UnixConn).SetWriteDeadline", Method, 0},
{"(*UnixConn).SyscallConn", Method, 9},
{"(*UnixConn).Write", Method, 0},
{"(*UnixConn).WriteMsgUnix", Method, 0},
{"(*UnixConn).WriteTo", Method, 0},
{"(*UnixConn).WriteToUnix", Method, 0},
{"(*UnixListener).Accept", Method, 0},
{"(*UnixListener).AcceptUnix", Method, 0},
{"(*UnixListener).Addr", Method, 0},
{"(*UnixListener).Close", Method, 0},
{"(*UnixListener).File", Method, 0},
{"(*UnixListener).SetDeadline", Method, 0},
{"(*UnixListener).SetUnlinkOnClose", Method, 8},
{"(*UnixListener).SyscallConn", Method, 10},
{"(Flags).String", Method, 0},
{"(HardwareAddr).String", Method, 0},
{"(IP).DefaultMask", Method, 0},
{"(IP).Equal", Method, 0},
{"(IP).IsGlobalUnicast", Method, 0},
{"(IP).IsInterfaceLocalMulticast", Method, 0},
{"(IP).IsLinkLocalMulticast", Method, 0},
{"(IP).IsLinkLocalUnicast", Method, 0},
{"(IP).IsLoopback", Method, 0},
{"(IP).IsMulticast", Method, 0},
{"(IP).IsPrivate", Method, 17},
{"(IP).IsUnspecified", Method, 0},
{"(IP).MarshalText", Method, 2},
{"(IP).Mask", Method, 0},
{"(IP).String", Method, 0},
{"(IP).To16", Method, 0},
{"(IP).To4", Method, 0},
{"(IPMask).Size", Method, 0},
{"(IPMask).String", Method, 0},
{"(InvalidAddrError).Error", Method, 0},
{"(InvalidAddrError).Temporary", Method, 0},
{"(InvalidAddrError).Timeout", Method, 0},
{"(UnknownNetworkError).Error", Method, 0},
{"(UnknownNetworkError).Temporary", Method, 0},
{"(UnknownNetworkError).Timeout", Method, 0},
{"Addr", Type, 0},
{"AddrError", Type, 0},
{"AddrError.Addr", Field, 0},
{"AddrError.Err", Field, 0},
{"Buffers", Type, 8},
{"CIDRMask", Func, 0},
{"Conn", Type, 0},
{"DNSConfigError", Type, 0},
{"DNSConfigError.Err", Field, 0},
{"DNSError", Type, 0},
{"DNSError.Err", Field, 0},
{"DNSError.IsNotFound", Field, 13},
{"DNSError.IsTemporary", Field, 6},
{"DNSError.IsTimeout", Field, 0},
{"DNSError.Name", Field, 0},
{"DNSError.Server", Field, 0},
{"DNSError.UnwrapErr", Field, 23},
{"DefaultResolver", Var, 8},
{"Dial", Func, 0},
{"DialIP", Func, 0},
{"DialTCP", Func, 0},
{"DialTimeout", Func, 0},
{"DialUDP", Func, 0},
{"DialUnix", Func, 0},
{"Dialer", Type, 1},
{"Dialer.Cancel", Field, 6},
{"Dialer.Control", Field, 11},
{"Dialer.ControlContext", Field, 20},
{"Dialer.Deadline", Field, 1},
{"Dialer.DualStack", Field, 2},
{"Dialer.FallbackDelay", Field, 5},
{"Dialer.KeepAlive", Field, 3},
{"Dialer.KeepAliveConfig", Field, 23},
{"Dialer.LocalAddr", Field, 1},
{"Dialer.Resolver", Field, 8},
{"Dialer.Timeout", Field, 1},
{"ErrClosed", Var, 16},
{"ErrWriteToConnected", Var, 0},
{"Error", Type, 0},
{"FileConn", Func, 0},
{"FileListener", Func, 0},
{"FilePacketConn", Func, 0},
{"FlagBroadcast", Const, 0},
{"FlagLoopback", Const, 0},
{"FlagMulticast", Const, 0},
{"FlagPointToPoint", Const, 0},
{"FlagRunning", Const, 20},
{"FlagUp", Const, 0},
{"Flags", Type, 0},
{"HardwareAddr", Type, 0},
{"IP", Type, 0},
{"IPAddr", Type, 0},
{"IPAddr.IP", Field, 0},
{"IPAddr.Zone", Field, 1},
{"IPConn", Type, 0},
{"IPMask", Type, 0},
{"IPNet", Type, 0},
{"IPNet.IP", Field, 0},
{"IPNet.Mask", Field, 0},
{"IPv4", Func, 0},
{"IPv4Mask", Func, 0},
{"IPv4allrouter", Var, 0},
{"IPv4allsys", Var, 0},
{"IPv4bcast", Var, 0},
{"IPv4len", Const, 0},
{"IPv4zero", Var, 0},
{"IPv6interfacelocalallnodes", Var, 0},
{"IPv6len", Const, 0},
{"IPv6linklocalallnodes", Var, 0},
{"IPv6linklocalallrouters", Var, 0},
{"IPv6loopback", Var, 0},
{"IPv6unspecified", Var, 0},
{"IPv6zero", Var, 0},
{"Interface", Type, 0},
{"Interface.Flags", Field, 0},
{"Interface.HardwareAddr", Field, 0},
{"Interface.Index", Field, 0},
{"Interface.MTU", Field, 0},
{"Interface.Name", Field, 0},
{"InterfaceAddrs", Func, 0},
{"InterfaceByIndex", Func, 0},
{"InterfaceByName", Func, 0},
{"Interfaces", Func, 0},
{"InvalidAddrError", Type, 0},
{"JoinHostPort", Func, 0},
{"KeepAliveConfig", Type, 23},
{"KeepAliveConfig.Count", Field, 23},
{"KeepAliveConfig.Enable", Field, 23},
{"KeepAliveConfig.Idle", Field, 23},
{"KeepAliveConfig.Interval", Field, 23},
{"Listen", Func, 0},
{"ListenConfig", Type, 11},
{"ListenConfig.Control", Field, 11},
{"ListenConfig.KeepAlive", Field, 13},
{"ListenConfig.KeepAliveConfig", Field, 23},
{"ListenIP", Func, 0},
{"ListenMulticastUDP", Func, 0},
{"ListenPacket", Func, 0},
{"ListenTCP", Func, 0},
{"ListenUDP", Func, 0},
{"ListenUnix", Func, 0},
{"ListenUnixgram", Func, 0},
{"Listener", Type, 0},
{"LookupAddr", Func, 0},
{"LookupCNAME", Func, 0},
{"LookupHost", Func, 0},
{"LookupIP", Func, 0},
{"LookupMX", Func, 0},
{"LookupNS", Func, 1},
{"LookupPort", Func, 0},
{"LookupSRV", Func, 0},
{"LookupTXT", Func, 0},
{"MX", Type, 0},
{"MX.Host", Field, 0},
{"MX.Pref", Field, 0},
{"NS", Type, 1},
{"NS.Host", Field, 1},
{"OpError", Type, 0},
{"OpError.Addr", Field, 0},
{"OpError.Err", Field, 0},
{"OpError.Net", Field, 0},
{"OpError.Op", Field, 0},
{"OpError.Source", Field, 5},
{"PacketConn", Type, 0},
{"ParseCIDR", Func, 0},
{"ParseError", Type, 0},
{"ParseError.Text", Field, 0},
{"ParseError.Type", Field, 0},
{"ParseIP", Func, 0},
{"ParseMAC", Func, 0},
{"Pipe", Func, 0},
{"ResolveIPAddr", Func, 0},
{"ResolveTCPAddr", Func, 0},
{"ResolveUDPAddr", Func, 0},
{"ResolveUnixAddr", Func, 0},
{"Resolver", Type, 8},
{"Resolver.Dial", Field, 9},
{"Resolver.PreferGo", Field, 8},
{"Resolver.StrictErrors", Field, 9},
{"SRV", Type, 0},
{"SRV.Port", Field, 0},
{"SRV.Priority", Field, 0},
{"SRV.Target", Field, 0},
{"SRV.Weight", Field, 0},
{"SplitHostPort", Func, 0},
{"TCPAddr", Type, 0},
{"TCPAddr.IP", Field, 0},
{"TCPAddr.Port", Field, 0},
{"TCPAddr.Zone", Field, 1},
{"TCPAddrFromAddrPort", Func, 18},
{"TCPConn", Type, 0},
{"TCPListener", Type, 0},
{"UDPAddr", Type, 0},
{"UDPAddr.IP", Field, 0},
{"UDPAddr.Port", Field, 0},
{"UDPAddr.Zone", Field, 1},
{"UDPAddrFromAddrPort", Func, 18},
{"UDPConn", Type, 0},
{"UnixAddr", Type, 0},
{"UnixAddr.Name", Field, 0},
{"UnixAddr.Net", Field, 0},
{"UnixConn", Type, 0},
{"UnixListener", Type, 0},
{"UnknownNetworkError", Type, 0},
},
"net/http": {
{"(*Client).CloseIdleConnections", Method, 12},
{"(*Client).Do", Method, 0},
{"(*Client).Get", Method, 0},
{"(*Client).Head", Method, 0},
{"(*Client).Post", Method, 0},
{"(*Client).PostForm", Method, 0},
{"(*Cookie).String", Method, 0},
{"(*Cookie).Valid", Method, 18},
{"(*MaxBytesError).Error", Method, 19},
{"(*ProtocolError).Error", Method, 0},
{"(*ProtocolError).Is", Method, 21},
{"(*Request).AddCookie", Method, 0},
{"(*Request).BasicAuth", Method, 4},
{"(*Request).Clone", Method, 13},
{"(*Request).Context", Method, 7},
{"(*Request).Cookie", Method, 0},
{"(*Request).Cookies", Method, 0},
{"(*Request).CookiesNamed", Method, 23},
{"(*Request).FormFile", Method, 0},
{"(*Request).FormValue", Method, 0},
{"(*Request).MultipartReader", Method, 0},
{"(*Request).ParseForm", Method, 0},
{"(*Request).ParseMultipartForm", Method, 0},
{"(*Request).PathValue", Method, 22},
{"(*Request).PostFormValue", Method, 1},
{"(*Request).ProtoAtLeast", Method, 0},
{"(*Request).Referer", Method, 0},
{"(*Request).SetBasicAuth", Method, 0},
{"(*Request).SetPathValue", Method, 22},
{"(*Request).UserAgent", Method, 0},
{"(*Request).WithContext", Method, 7},
{"(*Request).Write", Method, 0},
{"(*Request).WriteProxy", Method, 0},
{"(*Response).Cookies", Method, 0},
{"(*Response).Location", Method, 0},
{"(*Response).ProtoAtLeast", Method, 0},
{"(*Response).Write", Method, 0},
{"(*ResponseController).EnableFullDuplex", Method, 21},
{"(*ResponseController).Flush", Method, 20},
{"(*ResponseController).Hijack", Method, 20},
{"(*ResponseController).SetReadDeadline", Method, 20},
{"(*ResponseController).SetWriteDeadline", Method, 20},
{"(*ServeMux).Handle", Method, 0},
{"(*ServeMux).HandleFunc", Method, 0},
{"(*ServeMux).Handler", Method, 1},
{"(*ServeMux).ServeHTTP", Method, 0},
{"(*Server).Close", Method, 8},
{"(*Server).ListenAndServe", Method, 0},
{"(*Server).ListenAndServeTLS", Method, 0},
{"(*Server).RegisterOnShutdown", Method, 9},
{"(*Server).Serve", Method, 0},
{"(*Server).ServeTLS", Method, 9},
{"(*Server).SetKeepAlivesEnabled", Method, 3},
{"(*Server).Shutdown", Method, 8},
{"(*Transport).CancelRequest", Method, 1},
{"(*Transport).Clone", Method, 13},
{"(*Transport).CloseIdleConnections", Method, 0},
{"(*Transport).RegisterProtocol", Method, 0},
{"(*Transport).RoundTrip", Method, 0},
{"(ConnState).String", Method, 3},
{"(Dir).Open", Method, 0},
{"(HandlerFunc).ServeHTTP", Method, 0},
{"(Header).Add", Method, 0},
{"(Header).Clone", Method, 13},
{"(Header).Del", Method, 0},
{"(Header).Get", Method, 0},
{"(Header).Set", Method, 0},
{"(Header).Values", Method, 14},
{"(Header).Write", Method, 0},
{"(Header).WriteSubset", Method, 0},
{"AllowQuerySemicolons", Func, 17},
{"CanonicalHeaderKey", Func, 0},
{"Client", Type, 0},
{"Client.CheckRedirect", Field, 0},
{"Client.Jar", Field, 0},
{"Client.Timeout", Field, 3},
{"Client.Transport", Field, 0},
{"CloseNotifier", Type, 1},
{"ConnState", Type, 3},
{"Cookie", Type, 0},
{"Cookie.Domain", Field, 0},
{"Cookie.Expires", Field, 0},
{"Cookie.HttpOnly", Field, 0},
{"Cookie.MaxAge", Field, 0},
{"Cookie.Name", Field, 0},
{"Cookie.Partitioned", Field, 23},
{"Cookie.Path", Field, 0},
{"Cookie.Quoted", Field, 23},
{"Cookie.Raw", Field, 0},
{"Cookie.RawExpires", Field, 0},
{"Cookie.SameSite", Field, 11},
{"Cookie.Secure", Field, 0},
{"Cookie.Unparsed", Field, 0},
{"Cookie.Value", Field, 0},
{"CookieJar", Type, 0},
{"DefaultClient", Var, 0},
{"DefaultMaxHeaderBytes", Const, 0},
{"DefaultMaxIdleConnsPerHost", Const, 0},
{"DefaultServeMux", Var, 0},
{"DefaultTransport", Var, 0},
{"DetectContentType", Func, 0},
{"Dir", Type, 0},
{"ErrAbortHandler", Var, 8},
{"ErrBodyNotAllowed", Var, 0},
{"ErrBodyReadAfterClose", Var, 0},
{"ErrContentLength", Var, 0},
{"ErrHandlerTimeout", Var, 0},
{"ErrHeaderTooLong", Var, 0},
{"ErrHijacked", Var, 0},
{"ErrLineTooLong", Var, 0},
{"ErrMissingBoundary", Var, 0},
{"ErrMissingContentLength", Var, 0},
{"ErrMissingFile", Var, 0},
{"ErrNoCookie", Var, 0},
{"ErrNoLocation", Var, 0},
{"ErrNotMultipart", Var, 0},
{"ErrNotSupported", Var, 0},
{"ErrSchemeMismatch", Var, 21},
{"ErrServerClosed", Var, 8},
{"ErrShortBody", Var, 0},
{"ErrSkipAltProtocol", Var, 6},
{"ErrUnexpectedTrailer", Var, 0},
{"ErrUseLastResponse", Var, 7},
{"ErrWriteAfterFlush", Var, 0},
{"Error", Func, 0},
{"FS", Func, 16},
{"File", Type, 0},
{"FileServer", Func, 0},
{"FileServerFS", Func, 22},
{"FileSystem", Type, 0},
{"Flusher", Type, 0},
{"Get", Func, 0},
{"Handle", Func, 0},
{"HandleFunc", Func, 0},
{"Handler", Type, 0},
{"HandlerFunc", Type, 0},
{"Head", Func, 0},
{"Header", Type, 0},
{"Hijacker", Type, 0},
{"ListenAndServe", Func, 0},
{"ListenAndServeTLS", Func, 0},
{"LocalAddrContextKey", Var, 7},
{"MaxBytesError", Type, 19},
{"MaxBytesError.Limit", Field, 19},
{"MaxBytesHandler", Func, 18},
{"MaxBytesReader", Func, 0},
{"MethodConnect", Const, 6},
{"MethodDelete", Const, 6},
{"MethodGet", Const, 6},
{"MethodHead", Const, 6},
{"MethodOptions", Const, 6},
{"MethodPatch", Const, 6},
{"MethodPost", Const, 6},
{"MethodPut", Const, 6},
{"MethodTrace", Const, 6},
{"NewFileTransport", Func, 0},
{"NewFileTransportFS", Func, 22},
{"NewRequest", Func, 0},
{"NewRequestWithContext", Func, 13},
{"NewResponseController", Func, 20},
{"NewServeMux", Func, 0},
{"NoBody", Var, 8},
{"NotFound", Func, 0},
{"NotFoundHandler", Func, 0},
{"ParseCookie", Func, 23},
{"ParseHTTPVersion", Func, 0},
{"ParseSetCookie", Func, 23},
{"ParseTime", Func, 1},
{"Post", Func, 0},
{"PostForm", Func, 0},
{"ProtocolError", Type, 0},
{"ProtocolError.ErrorString", Field, 0},
{"ProxyFromEnvironment", Func, 0},
{"ProxyURL", Func, 0},
{"PushOptions", Type, 8},
{"PushOptions.Header", Field, 8},
{"PushOptions.Method", Field, 8},
{"Pusher", Type, 8},
{"ReadRequest", Func, 0},
{"ReadResponse", Func, 0},
{"Redirect", Func, 0},
{"RedirectHandler", Func, 0},
{"Request", Type, 0},
{"Request.Body", Field, 0},
{"Request.Cancel", Field, 5},
{"Request.Close", Field, 0},
{"Request.ContentLength", Field, 0},
{"Request.Form", Field, 0},
{"Request.GetBody", Field, 8},
{"Request.Header", Field, 0},
{"Request.Host", Field, 0},
{"Request.Method", Field, 0},
{"Request.MultipartForm", Field, 0},
{"Request.Pattern", Field, 23},
{"Request.PostForm", Field, 1},
{"Request.Proto", Field, 0},
{"Request.ProtoMajor", Field, 0},
{"Request.ProtoMinor", Field, 0},
{"Request.RemoteAddr", Field, 0},
{"Request.RequestURI", Field, 0},
{"Request.Response", Field, 7},
{"Request.TLS", Field, 0},
{"Request.Trailer", Field, 0},
{"Request.TransferEncoding", Field, 0},
{"Request.URL", Field, 0},
{"Response", Type, 0},
{"Response.Body", Field, 0},
{"Response.Close", Field, 0},
{"Response.ContentLength", Field, 0},
{"Response.Header", Field, 0},
{"Response.Proto", Field, 0},
{"Response.ProtoMajor", Field, 0},
{"Response.ProtoMinor", Field, 0},
{"Response.Request", Field, 0},
{"Response.Status", Field, 0},
{"Response.StatusCode", Field, 0},
{"Response.TLS", Field, 3},
{"Response.Trailer", Field, 0},
{"Response.TransferEncoding", Field, 0},
{"Response.Uncompressed", Field, 7},
{"ResponseController", Type, 20},
{"ResponseWriter", Type, 0},
{"RoundTripper", Type, 0},
{"SameSite", Type, 11},
{"SameSiteDefaultMode", Const, 11},
{"SameSiteLaxMode", Const, 11},
{"SameSiteNoneMode", Const, 13},
{"SameSiteStrictMode", Const, 11},
{"Serve", Func, 0},
{"ServeContent", Func, 0},
{"ServeFile", Func, 0},
{"ServeFileFS", Func, 22},
{"ServeMux", Type, 0},
{"ServeTLS", Func, 9},
{"Server", Type, 0},
{"Server.Addr", Field, 0},
{"Server.BaseContext", Field, 13},
{"Server.ConnContext", Field, 13},
{"Server.ConnState", Field, 3},
{"Server.DisableGeneralOptionsHandler", Field, 20},
{"Server.ErrorLog", Field, 3},
{"Server.Handler", Field, 0},
{"Server.IdleTimeout", Field, 8},
{"Server.MaxHeaderBytes", Field, 0},
{"Server.ReadHeaderTimeout", Field, 8},
{"Server.ReadTimeout", Field, 0},
{"Server.TLSConfig", Field, 0},
{"Server.TLSNextProto", Field, 1},
{"Server.WriteTimeout", Field, 0},
{"ServerContextKey", Var, 7},
{"SetCookie", Func, 0},
{"StateActive", Const, 3},
{"StateClosed", Const, 3},
{"StateHijacked", Const, 3},
{"StateIdle", Const, 3},
{"StateNew", Const, 3},
{"StatusAccepted", Const, 0},
{"StatusAlreadyReported", Const, 7},
{"StatusBadGateway", Const, 0},
{"StatusBadRequest", Const, 0},
{"StatusConflict", Const, 0},
{"StatusContinue", Const, 0},
{"StatusCreated", Const, 0},
{"StatusEarlyHints", Const, 13},
{"StatusExpectationFailed", Const, 0},
{"StatusFailedDependency", Const, 7},
{"StatusForbidden", Const, 0},
{"StatusFound", Const, 0},
{"StatusGatewayTimeout", Const, 0},
{"StatusGone", Const, 0},
{"StatusHTTPVersionNotSupported", Const, 0},
{"StatusIMUsed", Const, 7},
{"StatusInsufficientStorage", Const, 7},
{"StatusInternalServerError", Const, 0},
{"StatusLengthRequired", Const, 0},
{"StatusLocked", Const, 7},
{"StatusLoopDetected", Const, 7},
{"StatusMethodNotAllowed", Const, 0},
{"StatusMisdirectedRequest", Const, 11},
{"StatusMovedPermanently", Const, 0},
{"StatusMultiStatus", Const, 7},
{"StatusMultipleChoices", Const, 0},
{"StatusNetworkAuthenticationRequired", Const, 6},
{"StatusNoContent", Const, 0},
{"StatusNonAuthoritativeInfo", Const, 0},
{"StatusNotAcceptable", Const, 0},
{"StatusNotExtended", Const, 7},
{"StatusNotFound", Const, 0},
{"StatusNotImplemented", Const, 0},
{"StatusNotModified", Const, 0},
{"StatusOK", Const, 0},
{"StatusPartialContent", Const, 0},
{"StatusPaymentRequired", Const, 0},
{"StatusPermanentRedirect", Const, 7},
{"StatusPreconditionFailed", Const, 0},
{"StatusPreconditionRequired", Const, 6},
{"StatusProcessing", Const, 7},
{"StatusProxyAuthRequired", Const, 0},
{"StatusRequestEntityTooLarge", Const, 0},
{"StatusRequestHeaderFieldsTooLarge", Const, 6},
{"StatusRequestTimeout", Const, 0},
{"StatusRequestURITooLong", Const, 0},
{"StatusRequestedRangeNotSatisfiable", Const, 0},
{"StatusResetContent", Const, 0},
{"StatusSeeOther", Const, 0},
{"StatusServiceUnavailable", Const, 0},
{"StatusSwitchingProtocols", Const, 0},
{"StatusTeapot", Const, 0},
{"StatusTemporaryRedirect", Const, 0},
{"StatusText", Func, 0},
{"StatusTooEarly", Const, 12},
{"StatusTooManyRequests", Const, 6},
{"StatusUnauthorized", Const, 0},
{"StatusUnavailableForLegalReasons", Const, 6},
{"StatusUnprocessableEntity", Const, 7},
{"StatusUnsupportedMediaType", Const, 0},
{"StatusUpgradeRequired", Const, 7},
{"StatusUseProxy", Const, 0},
{"StatusVariantAlsoNegotiates", Const, 7},
{"StripPrefix", Func, 0},
{"TimeFormat", Const, 0},
{"TimeoutHandler", Func, 0},
{"TrailerPrefix", Const, 8},
{"Transport", Type, 0},
{"Transport.Dial", Field, 0},
{"Transport.DialContext", Field, 7},
{"Transport.DialTLS", Field, 4},
{"Transport.DialTLSContext", Field, 14},
{"Transport.DisableCompression", Field, 0},
{"Transport.DisableKeepAlives", Field, 0},
{"Transport.ExpectContinueTimeout", Field, 6},
{"Transport.ForceAttemptHTTP2", Field, 13},
{"Transport.GetProxyConnectHeader", Field, 16},
{"Transport.IdleConnTimeout", Field, 7},
{"Transport.MaxConnsPerHost", Field, 11},
{"Transport.MaxIdleConns", Field, 7},
{"Transport.MaxIdleConnsPerHost", Field, 0},
{"Transport.MaxResponseHeaderBytes", Field, 7},
{"Transport.OnProxyConnectResponse", Field, 20},
{"Transport.Proxy", Field, 0},
{"Transport.ProxyConnectHeader", Field, 8},
{"Transport.ReadBufferSize", Field, 13},
{"Transport.ResponseHeaderTimeout", Field, 1},
{"Transport.TLSClientConfig", Field, 0},
{"Transport.TLSHandshakeTimeout", Field, 3},
{"Transport.TLSNextProto", Field, 6},
{"Transport.WriteBufferSize", Field, 13},
},
"net/http/cgi": {
{"(*Handler).ServeHTTP", Method, 0},
{"Handler", Type, 0},
{"Handler.Args", Field, 0},
{"Handler.Dir", Field, 0},
{"Handler.Env", Field, 0},
{"Handler.InheritEnv", Field, 0},
{"Handler.Logger", Field, 0},
{"Handler.Path", Field, 0},
{"Handler.PathLocationHandler", Field, 0},
{"Handler.Root", Field, 0},
{"Handler.Stderr", Field, 7},
{"Request", Func, 0},
{"RequestFromMap", Func, 0},
{"Serve", Func, 0},
},
"net/http/cookiejar": {
{"(*Jar).Cookies", Method, 1},
{"(*Jar).SetCookies", Method, 1},
{"Jar", Type, 1},
{"New", Func, 1},
{"Options", Type, 1},
{"Options.PublicSuffixList", Field, 1},
{"PublicSuffixList", Type, 1},
},
"net/http/fcgi": {
{"ErrConnClosed", Var, 5},
{"ErrRequestAborted", Var, 5},
{"ProcessEnv", Func, 9},
{"Serve", Func, 0},
},
"net/http/httptest": {
{"(*ResponseRecorder).Flush", Method, 0},
{"(*ResponseRecorder).Header", Method, 0},
{"(*ResponseRecorder).Result", Method, 7},
{"(*ResponseRecorder).Write", Method, 0},
{"(*ResponseRecorder).WriteHeader", Method, 0},
{"(*ResponseRecorder).WriteString", Method, 6},
{"(*Server).Certificate", Method, 9},
{"(*Server).Client", Method, 9},
{"(*Server).Close", Method, 0},
{"(*Server).CloseClientConnections", Method, 0},
{"(*Server).Start", Method, 0},
{"(*Server).StartTLS", Method, 0},
{"DefaultRemoteAddr", Const, 0},
{"NewRecorder", Func, 0},
{"NewRequest", Func, 7},
{"NewRequestWithContext", Func, 23},
{"NewServer", Func, 0},
{"NewTLSServer", Func, 0},
{"NewUnstartedServer", Func, 0},
{"ResponseRecorder", Type, 0},
{"ResponseRecorder.Body", Field, 0},
{"ResponseRecorder.Code", Field, 0},
{"ResponseRecorder.Flushed", Field, 0},
{"ResponseRecorder.HeaderMap", Field, 0},
{"Server", Type, 0},
{"Server.Config", Field, 0},
{"Server.EnableHTTP2", Field, 14},
{"Server.Listener", Field, 0},
{"Server.TLS", Field, 0},
{"Server.URL", Field, 0},
},
"net/http/httptrace": {
{"ClientTrace", Type, 7},
{"ClientTrace.ConnectDone", Field, 7},
{"ClientTrace.ConnectStart", Field, 7},
{"ClientTrace.DNSDone", Field, 7},
{"ClientTrace.DNSStart", Field, 7},
{"ClientTrace.GetConn", Field, 7},
{"ClientTrace.Got100Continue", Field, 7},
{"ClientTrace.Got1xxResponse", Field, 11},
{"ClientTrace.GotConn", Field, 7},
{"ClientTrace.GotFirstResponseByte", Field, 7},
{"ClientTrace.PutIdleConn", Field, 7},
{"ClientTrace.TLSHandshakeDone", Field, 8},
{"ClientTrace.TLSHandshakeStart", Field, 8},
{"ClientTrace.Wait100Continue", Field, 7},
{"ClientTrace.WroteHeaderField", Field, 11},
{"ClientTrace.WroteHeaders", Field, 7},
{"ClientTrace.WroteRequest", Field, 7},
{"ContextClientTrace", Func, 7},
{"DNSDoneInfo", Type, 7},
{"DNSDoneInfo.Addrs", Field, 7},
{"DNSDoneInfo.Coalesced", Field, 7},
{"DNSDoneInfo.Err", Field, 7},
{"DNSStartInfo", Type, 7},
{"DNSStartInfo.Host", Field, 7},
{"GotConnInfo", Type, 7},
{"GotConnInfo.Conn", Field, 7},
{"GotConnInfo.IdleTime", Field, 7},
{"GotConnInfo.Reused", Field, 7},
{"GotConnInfo.WasIdle", Field, 7},
{"WithClientTrace", Func, 7},
{"WroteRequestInfo", Type, 7},
{"WroteRequestInfo.Err", Field, 7},
},
"net/http/httputil": {
{"(*ClientConn).Close", Method, 0},
{"(*ClientConn).Do", Method, 0},
{"(*ClientConn).Hijack", Method, 0},
{"(*ClientConn).Pending", Method, 0},
{"(*ClientConn).Read", Method, 0},
{"(*ClientConn).Write", Method, 0},
{"(*ProxyRequest).SetURL", Method, 20},
{"(*ProxyRequest).SetXForwarded", Method, 20},
{"(*ReverseProxy).ServeHTTP", Method, 0},
{"(*ServerConn).Close", Method, 0},
{"(*ServerConn).Hijack", Method, 0},
{"(*ServerConn).Pending", Method, 0},
{"(*ServerConn).Read", Method, 0},
{"(*ServerConn).Write", Method, 0},
{"BufferPool", Type, 6},
{"ClientConn", Type, 0},
{"DumpRequest", Func, 0},
{"DumpRequestOut", Func, 0},
{"DumpResponse", Func, 0},
{"ErrClosed", Var, 0},
{"ErrLineTooLong", Var, 0},
{"ErrPersistEOF", Var, 0},
{"ErrPipeline", Var, 0},
{"NewChunkedReader", Func, 0},
{"NewChunkedWriter", Func, 0},
{"NewClientConn", Func, 0},
{"NewProxyClientConn", Func, 0},
{"NewServerConn", Func, 0},
{"NewSingleHostReverseProxy", Func, 0},
{"ProxyRequest", Type, 20},
{"ProxyRequest.In", Field, 20},
{"ProxyRequest.Out", Field, 20},
{"ReverseProxy", Type, 0},
{"ReverseProxy.BufferPool", Field, 6},
{"ReverseProxy.Director", Field, 0},
{"ReverseProxy.ErrorHandler", Field, 11},
{"ReverseProxy.ErrorLog", Field, 4},
{"ReverseProxy.FlushInterval", Field, 0},
{"ReverseProxy.ModifyResponse", Field, 8},
{"ReverseProxy.Rewrite", Field, 20},
{"ReverseProxy.Transport", Field, 0},
{"ServerConn", Type, 0},
},
"net/http/pprof": {
{"Cmdline", Func, 0},
{"Handler", Func, 0},
{"Index", Func, 0},
{"Profile", Func, 0},
{"Symbol", Func, 0},
{"Trace", Func, 5},
},
"net/mail": {
{"(*Address).String", Method, 0},
{"(*AddressParser).Parse", Method, 5},
{"(*AddressParser).ParseList", Method, 5},
{"(Header).AddressList", Method, 0},
{"(Header).Date", Method, 0},
{"(Header).Get", Method, 0},
{"Address", Type, 0},
{"Address.Address", Field, 0},
{"Address.Name", Field, 0},
{"AddressParser", Type, 5},
{"AddressParser.WordDecoder", Field, 5},
{"ErrHeaderNotPresent", Var, 0},
{"Header", Type, 0},
{"Message", Type, 0},
{"Message.Body", Field, 0},
{"Message.Header", Field, 0},
{"ParseAddress", Func, 1},
{"ParseAddressList", Func, 1},
{"ParseDate", Func, 8},
{"ReadMessage", Func, 0},
},
"net/netip": {
{"(*Addr).UnmarshalBinary", Method, 18},
{"(*Addr).UnmarshalText", Method, 18},
{"(*AddrPort).UnmarshalBinary", Method, 18},
{"(*AddrPort).UnmarshalText", Method, 18},
{"(*Prefix).UnmarshalBinary", Method, 18},
{"(*Prefix).UnmarshalText", Method, 18},
{"(Addr).AppendTo", Method, 18},
{"(Addr).As16", Method, 18},
{"(Addr).As4", Method, 18},
{"(Addr).AsSlice", Method, 18},
{"(Addr).BitLen", Method, 18},
{"(Addr).Compare", Method, 18},
{"(Addr).Is4", Method, 18},
{"(Addr).Is4In6", Method, 18},
{"(Addr).Is6", Method, 18},
{"(Addr).IsGlobalUnicast", Method, 18},
{"(Addr).IsInterfaceLocalMulticast", Method, 18},
{"(Addr).IsLinkLocalMulticast", Method, 18},
{"(Addr).IsLinkLocalUnicast", Method, 18},
{"(Addr).IsLoopback", Method, 18},
{"(Addr).IsMulticast", Method, 18},
{"(Addr).IsPrivate", Method, 18},
{"(Addr).IsUnspecified", Method, 18},
{"(Addr).IsValid", Method, 18},
{"(Addr).Less", Method, 18},
{"(Addr).MarshalBinary", Method, 18},
{"(Addr).MarshalText", Method, 18},
{"(Addr).Next", Method, 18},
{"(Addr).Prefix", Method, 18},
{"(Addr).Prev", Method, 18},
{"(Addr).String", Method, 18},
{"(Addr).StringExpanded", Method, 18},
{"(Addr).Unmap", Method, 18},
{"(Addr).WithZone", Method, 18},
{"(Addr).Zone", Method, 18},
{"(AddrPort).Addr", Method, 18},
{"(AddrPort).AppendTo", Method, 18},
{"(AddrPort).Compare", Method, 22},
{"(AddrPort).IsValid", Method, 18},
{"(AddrPort).MarshalBinary", Method, 18},
{"(AddrPort).MarshalText", Method, 18},
{"(AddrPort).Port", Method, 18},
{"(AddrPort).String", Method, 18},
{"(Prefix).Addr", Method, 18},
{"(Prefix).AppendTo", Method, 18},
{"(Prefix).Bits", Method, 18},
{"(Prefix).Contains", Method, 18},
{"(Prefix).IsSingleIP", Method, 18},
{"(Prefix).IsValid", Method, 18},
{"(Prefix).MarshalBinary", Method, 18},
{"(Prefix).MarshalText", Method, 18},
{"(Prefix).Masked", Method, 18},
{"(Prefix).Overlaps", Method, 18},
{"(Prefix).String", Method, 18},
{"Addr", Type, 18},
{"AddrFrom16", Func, 18},
{"AddrFrom4", Func, 18},
{"AddrFromSlice", Func, 18},
{"AddrPort", Type, 18},
{"AddrPortFrom", Func, 18},
{"IPv4Unspecified", Func, 18},
{"IPv6LinkLocalAllNodes", Func, 18},
{"IPv6LinkLocalAllRouters", Func, 20},
{"IPv6Loopback", Func, 20},
{"IPv6Unspecified", Func, 18},
{"MustParseAddr", Func, 18},
{"MustParseAddrPort", Func, 18},
{"MustParsePrefix", Func, 18},
{"ParseAddr", Func, 18},
{"ParseAddrPort", Func, 18},
{"ParsePrefix", Func, 18},
{"Prefix", Type, 18},
{"PrefixFrom", Func, 18},
},
"net/rpc": {
{"(*Client).Call", Method, 0},
{"(*Client).Close", Method, 0},
{"(*Client).Go", Method, 0},
{"(*Server).Accept", Method, 0},
{"(*Server).HandleHTTP", Method, 0},
{"(*Server).Register", Method, 0},
{"(*Server).RegisterName", Method, 0},
{"(*Server).ServeCodec", Method, 0},
{"(*Server).ServeConn", Method, 0},
{"(*Server).ServeHTTP", Method, 0},
{"(*Server).ServeRequest", Method, 0},
{"(ServerError).Error", Method, 0},
{"Accept", Func, 0},
{"Call", Type, 0},
{"Call.Args", Field, 0},
{"Call.Done", Field, 0},
{"Call.Error", Field, 0},
{"Call.Reply", Field, 0},
{"Call.ServiceMethod", Field, 0},
{"Client", Type, 0},
{"ClientCodec", Type, 0},
{"DefaultDebugPath", Const, 0},
{"DefaultRPCPath", Const, 0},
{"DefaultServer", Var, 0},
{"Dial", Func, 0},
{"DialHTTP", Func, 0},
{"DialHTTPPath", Func, 0},
{"ErrShutdown", Var, 0},
{"HandleHTTP", Func, 0},
{"NewClient", Func, 0},
{"NewClientWithCodec", Func, 0},
{"NewServer", Func, 0},
{"Register", Func, 0},
{"RegisterName", Func, 0},
{"Request", Type, 0},
{"Request.Seq", Field, 0},
{"Request.ServiceMethod", Field, 0},
{"Response", Type, 0},
{"Response.Error", Field, 0},
{"Response.Seq", Field, 0},
{"Response.ServiceMethod", Field, 0},
{"ServeCodec", Func, 0},
{"ServeConn", Func, 0},
{"ServeRequest", Func, 0},
{"Server", Type, 0},
{"ServerCodec", Type, 0},
{"ServerError", Type, 0},
},
"net/rpc/jsonrpc": {
{"Dial", Func, 0},
{"NewClient", Func, 0},
{"NewClientCodec", Func, 0},
{"NewServerCodec", Func, 0},
{"ServeConn", Func, 0},
},
"net/smtp": {
{"(*Client).Auth", Method, 0},
{"(*Client).Close", Method, 2},
{"(*Client).Data", Method, 0},
{"(*Client).Extension", Method, 0},
{"(*Client).Hello", Method, 1},
{"(*Client).Mail", Method, 0},
{"(*Client).Noop", Method, 10},
{"(*Client).Quit", Method, 0},
{"(*Client).Rcpt", Method, 0},
{"(*Client).Reset", Method, 0},
{"(*Client).StartTLS", Method, 0},
{"(*Client).TLSConnectionState", Method, 5},
{"(*Client).Verify", Method, 0},
{"Auth", Type, 0},
{"CRAMMD5Auth", Func, 0},
{"Client", Type, 0},
{"Client.Text", Field, 0},
{"Dial", Func, 0},
{"NewClient", Func, 0},
{"PlainAuth", Func, 0},
{"SendMail", Func, 0},
{"ServerInfo", Type, 0},
{"ServerInfo.Auth", Field, 0},
{"ServerInfo.Name", Field, 0},
{"ServerInfo.TLS", Field, 0},
},
"net/textproto": {
{"(*Conn).Close", Method, 0},
{"(*Conn).Cmd", Method, 0},
{"(*Conn).DotReader", Method, 0},
{"(*Conn).DotWriter", Method, 0},
{"(*Conn).EndRequest", Method, 0},
{"(*Conn).EndResponse", Method, 0},
{"(*Conn).Next", Method, 0},
{"(*Conn).PrintfLine", Method, 0},
{"(*Conn).ReadCodeLine", Method, 0},
{"(*Conn).ReadContinuedLine", Method, 0},
{"(*Conn).ReadContinuedLineBytes", Method, 0},
{"(*Conn).ReadDotBytes", Method, 0},
{"(*Conn).ReadDotLines", Method, 0},
{"(*Conn).ReadLine", Method, 0},
{"(*Conn).ReadLineBytes", Method, 0},
{"(*Conn).ReadMIMEHeader", Method, 0},
{"(*Conn).ReadResponse", Method, 0},
{"(*Conn).StartRequest", Method, 0},
{"(*Conn).StartResponse", Method, 0},
{"(*Error).Error", Method, 0},
{"(*Pipeline).EndRequest", Method, 0},
{"(*Pipeline).EndResponse", Method, 0},
{"(*Pipeline).Next", Method, 0},
{"(*Pipeline).StartRequest", Method, 0},
{"(*Pipeline).StartResponse", Method, 0},
{"(*Reader).DotReader", Method, 0},
{"(*Reader).ReadCodeLine", Method, 0},
{"(*Reader).ReadContinuedLine", Method, 0},
{"(*Reader).ReadContinuedLineBytes", Method, 0},
{"(*Reader).ReadDotBytes", Method, 0},
{"(*Reader).ReadDotLines", Method, 0},
{"(*Reader).ReadLine", Method, 0},
{"(*Reader).ReadLineBytes", Method, 0},
{"(*Reader).ReadMIMEHeader", Method, 0},
{"(*Reader).ReadResponse", Method, 0},
{"(*Writer).DotWriter", Method, 0},
{"(*Writer).PrintfLine", Method, 0},
{"(MIMEHeader).Add", Method, 0},
{"(MIMEHeader).Del", Method, 0},
{"(MIMEHeader).Get", Method, 0},
{"(MIMEHeader).Set", Method, 0},
{"(MIMEHeader).Values", Method, 14},
{"(ProtocolError).Error", Method, 0},
{"CanonicalMIMEHeaderKey", Func, 0},
{"Conn", Type, 0},
{"Conn.Pipeline", Field, 0},
{"Conn.Reader", Field, 0},
{"Conn.Writer", Field, 0},
{"Dial", Func, 0},
{"Error", Type, 0},
{"Error.Code", Field, 0},
{"Error.Msg", Field, 0},
{"MIMEHeader", Type, 0},
{"NewConn", Func, 0},
{"NewReader", Func, 0},
{"NewWriter", Func, 0},
{"Pipeline", Type, 0},
{"ProtocolError", Type, 0},
{"Reader", Type, 0},
{"Reader.R", Field, 0},
{"TrimBytes", Func, 1},
{"TrimString", Func, 1},
{"Writer", Type, 0},
{"Writer.W", Field, 0},
},
"net/url": {
{"(*Error).Error", Method, 0},
{"(*Error).Temporary", Method, 6},
{"(*Error).Timeout", Method, 6},
{"(*Error).Unwrap", Method, 13},
{"(*URL).EscapedFragment", Method, 15},
{"(*URL).EscapedPath", Method, 5},
{"(*URL).Hostname", Method, 8},
{"(*URL).IsAbs", Method, 0},
{"(*URL).JoinPath", Method, 19},
{"(*URL).MarshalBinary", Method, 8},
{"(*URL).Parse", Method, 0},
{"(*URL).Port", Method, 8},
{"(*URL).Query", Method, 0},
{"(*URL).Redacted", Method, 15},
{"(*URL).RequestURI", Method, 0},
{"(*URL).ResolveReference", Method, 0},
{"(*URL).String", Method, 0},
{"(*URL).UnmarshalBinary", Method, 8},
{"(*Userinfo).Password", Method, 0},
{"(*Userinfo).String", Method, 0},
{"(*Userinfo).Username", Method, 0},
{"(EscapeError).Error", Method, 0},
{"(InvalidHostError).Error", Method, 6},
{"(Values).Add", Method, 0},
{"(Values).Del", Method, 0},
{"(Values).Encode", Method, 0},
{"(Values).Get", Method, 0},
{"(Values).Has", Method, 17},
{"(Values).Set", Method, 0},
{"Error", Type, 0},
{"Error.Err", Field, 0},
{"Error.Op", Field, 0},
{"Error.URL", Field, 0},
{"EscapeError", Type, 0},
{"InvalidHostError", Type, 6},
{"JoinPath", Func, 19},
{"Parse", Func, 0},
{"ParseQuery", Func, 0},
{"ParseRequestURI", Func, 0},
{"PathEscape", Func, 8},
{"PathUnescape", Func, 8},
{"QueryEscape", Func, 0},
{"QueryUnescape", Func, 0},
{"URL", Type, 0},
{"URL.ForceQuery", Field, 7},
{"URL.Fragment", Field, 0},
{"URL.Host", Field, 0},
{"URL.OmitHost", Field, 19},
{"URL.Opaque", Field, 0},
{"URL.Path", Field, 0},
{"URL.RawFragment", Field, 15},
{"URL.RawPath", Field, 5},
{"URL.RawQuery", Field, 0},
{"URL.Scheme", Field, 0},
{"URL.User", Field, 0},
{"User", Func, 0},
{"UserPassword", Func, 0},
{"Userinfo", Type, 0},
{"Values", Type, 0},
},
"os": {
{"(*File).Chdir", Method, 0},
{"(*File).Chmod", Method, 0},
{"(*File).Chown", Method, 0},
{"(*File).Close", Method, 0},
{"(*File).Fd", Method, 0},
{"(*File).Name", Method, 0},
{"(*File).Read", Method, 0},
{"(*File).ReadAt", Method, 0},
{"(*File).ReadDir", Method, 16},
{"(*File).ReadFrom", Method, 15},
{"(*File).Readdir", Method, 0},
{"(*File).Readdirnames", Method, 0},
{"(*File).Seek", Method, 0},
{"(*File).SetDeadline", Method, 10},
{"(*File).SetReadDeadline", Method, 10},
{"(*File).SetWriteDeadline", Method, 10},
{"(*File).Stat", Method, 0},
{"(*File).Sync", Method, 0},
{"(*File).SyscallConn", Method, 12},
{"(*File).Truncate", Method, 0},
{"(*File).Write", Method, 0},
{"(*File).WriteAt", Method, 0},
{"(*File).WriteString", Method, 0},
{"(*File).WriteTo", Method, 22},
{"(*LinkError).Error", Method, 0},
{"(*LinkError).Unwrap", Method, 13},
{"(*PathError).Error", Method, 0},
{"(*PathError).Timeout", Method, 10},
{"(*PathError).Unwrap", Method, 13},
{"(*Process).Kill", Method, 0},
{"(*Process).Release", Method, 0},
{"(*Process).Signal", Method, 0},
{"(*Process).Wait", Method, 0},
{"(*ProcessState).ExitCode", Method, 12},
{"(*ProcessState).Exited", Method, 0},
{"(*ProcessState).Pid", Method, 0},
{"(*ProcessState).String", Method, 0},
{"(*ProcessState).Success", Method, 0},
{"(*ProcessState).Sys", Method, 0},
{"(*ProcessState).SysUsage", Method, 0},
{"(*ProcessState).SystemTime", Method, 0},
{"(*ProcessState).UserTime", Method, 0},
{"(*SyscallError).Error", Method, 0},
{"(*SyscallError).Timeout", Method, 10},
{"(*SyscallError).Unwrap", Method, 13},
{"(FileMode).IsDir", Method, 0},
{"(FileMode).IsRegular", Method, 1},
{"(FileMode).Perm", Method, 0},
{"(FileMode).String", Method, 0},
{"Args", Var, 0},
{"Chdir", Func, 0},
{"Chmod", Func, 0},
{"Chown", Func, 0},
{"Chtimes", Func, 0},
{"Clearenv", Func, 0},
{"CopyFS", Func, 23},
{"Create", Func, 0},
{"CreateTemp", Func, 16},
{"DevNull", Const, 0},
{"DirEntry", Type, 16},
{"DirFS", Func, 16},
{"Environ", Func, 0},
{"ErrClosed", Var, 8},
{"ErrDeadlineExceeded", Var, 15},
{"ErrExist", Var, 0},
{"ErrInvalid", Var, 0},
{"ErrNoDeadline", Var, 10},
{"ErrNotExist", Var, 0},
{"ErrPermission", Var, 0},
{"ErrProcessDone", Var, 16},
{"Executable", Func, 8},
{"Exit", Func, 0},
{"Expand", Func, 0},
{"ExpandEnv", Func, 0},
{"File", Type, 0},
{"FileInfo", Type, 0},
{"FileMode", Type, 0},
{"FindProcess", Func, 0},
{"Getegid", Func, 0},
{"Getenv", Func, 0},
{"Geteuid", Func, 0},
{"Getgid", Func, 0},
{"Getgroups", Func, 0},
{"Getpagesize", Func, 0},
{"Getpid", Func, 0},
{"Getppid", Func, 0},
{"Getuid", Func, 0},
{"Getwd", Func, 0},
{"Hostname", Func, 0},
{"Interrupt", Var, 0},
{"IsExist", Func, 0},
{"IsNotExist", Func, 0},
{"IsPathSeparator", Func, 0},
{"IsPermission", Func, 0},
{"IsTimeout", Func, 10},
{"Kill", Var, 0},
{"Lchown", Func, 0},
{"Link", Func, 0},
{"LinkError", Type, 0},
{"LinkError.Err", Field, 0},
{"LinkError.New", Field, 0},
{"LinkError.Old", Field, 0},
{"LinkError.Op", Field, 0},
{"LookupEnv", Func, 5},
{"Lstat", Func, 0},
{"Mkdir", Func, 0},
{"MkdirAll", Func, 0},
{"MkdirTemp", Func, 16},
{"ModeAppend", Const, 0},
{"ModeCharDevice", Const, 0},
{"ModeDevice", Const, 0},
{"ModeDir", Const, 0},
{"ModeExclusive", Const, 0},
{"ModeIrregular", Const, 11},
{"ModeNamedPipe", Const, 0},
{"ModePerm", Const, 0},
{"ModeSetgid", Const, 0},
{"ModeSetuid", Const, 0},
{"ModeSocket", Const, 0},
{"ModeSticky", Const, 0},
{"ModeSymlink", Const, 0},
{"ModeTemporary", Const, 0},
{"ModeType", Const, 0},
{"NewFile", Func, 0},
{"NewSyscallError", Func, 0},
{"O_APPEND", Const, 0},
{"O_CREATE", Const, 0},
{"O_EXCL", Const, 0},
{"O_RDONLY", Const, 0},
{"O_RDWR", Const, 0},
{"O_SYNC", Const, 0},
{"O_TRUNC", Const, 0},
{"O_WRONLY", Const, 0},
{"Open", Func, 0},
{"OpenFile", Func, 0},
{"PathError", Type, 0},
{"PathError.Err", Field, 0},
{"PathError.Op", Field, 0},
{"PathError.Path", Field, 0},
{"PathListSeparator", Const, 0},
{"PathSeparator", Const, 0},
{"Pipe", Func, 0},
{"ProcAttr", Type, 0},
{"ProcAttr.Dir", Field, 0},
{"ProcAttr.Env", Field, 0},
{"ProcAttr.Files", Field, 0},
{"ProcAttr.Sys", Field, 0},
{"Process", Type, 0},
{"Process.Pid", Field, 0},
{"ProcessState", Type, 0},
{"ReadDir", Func, 16},
{"ReadFile", Func, 16},
{"Readlink", Func, 0},
{"Remove", Func, 0},
{"RemoveAll", Func, 0},
{"Rename", Func, 0},
{"SEEK_CUR", Const, 0},
{"SEEK_END", Const, 0},
{"SEEK_SET", Const, 0},
{"SameFile", Func, 0},
{"Setenv", Func, 0},
{"Signal", Type, 0},
{"StartProcess", Func, 0},
{"Stat", Func, 0},
{"Stderr", Var, 0},
{"Stdin", Var, 0},
{"Stdout", Var, 0},
{"Symlink", Func, 0},
{"SyscallError", Type, 0},
{"SyscallError.Err", Field, 0},
{"SyscallError.Syscall", Field, 0},
{"TempDir", Func, 0},
{"Truncate", Func, 0},
{"Unsetenv", Func, 4},
{"UserCacheDir", Func, 11},
{"UserConfigDir", Func, 13},
{"UserHomeDir", Func, 12},
{"WriteFile", Func, 16},
},
"os/exec": {
{"(*Cmd).CombinedOutput", Method, 0},
{"(*Cmd).Environ", Method, 19},
{"(*Cmd).Output", Method, 0},
{"(*Cmd).Run", Method, 0},
{"(*Cmd).Start", Method, 0},
{"(*Cmd).StderrPipe", Method, 0},
{"(*Cmd).StdinPipe", Method, 0},
{"(*Cmd).StdoutPipe", Method, 0},
{"(*Cmd).String", Method, 13},
{"(*Cmd).Wait", Method, 0},
{"(*Error).Error", Method, 0},
{"(*Error).Unwrap", Method, 13},
{"(*ExitError).Error", Method, 0},
{"(ExitError).ExitCode", Method, 12},
{"(ExitError).Exited", Method, 0},
{"(ExitError).Pid", Method, 0},
{"(ExitError).String", Method, 0},
{"(ExitError).Success", Method, 0},
{"(ExitError).Sys", Method, 0},
{"(ExitError).SysUsage", Method, 0},
{"(ExitError).SystemTime", Method, 0},
{"(ExitError).UserTime", Method, 0},
{"Cmd", Type, 0},
{"Cmd.Args", Field, 0},
{"Cmd.Cancel", Field, 20},
{"Cmd.Dir", Field, 0},
{"Cmd.Env", Field, 0},
{"Cmd.Err", Field, 19},
{"Cmd.ExtraFiles", Field, 0},
{"Cmd.Path", Field, 0},
{"Cmd.Process", Field, 0},
{"Cmd.ProcessState", Field, 0},
{"Cmd.Stderr", Field, 0},
{"Cmd.Stdin", Field, 0},
{"Cmd.Stdout", Field, 0},
{"Cmd.SysProcAttr", Field, 0},
{"Cmd.WaitDelay", Field, 20},
{"Command", Func, 0},
{"CommandContext", Func, 7},
{"ErrDot", Var, 19},
{"ErrNotFound", Var, 0},
{"ErrWaitDelay", Var, 20},
{"Error", Type, 0},
{"Error.Err", Field, 0},
{"Error.Name", Field, 0},
{"ExitError", Type, 0},
{"ExitError.ProcessState", Field, 0},
{"ExitError.Stderr", Field, 6},
{"LookPath", Func, 0},
},
"os/signal": {
{"Ignore", Func, 5},
{"Ignored", Func, 11},
{"Notify", Func, 0},
{"NotifyContext", Func, 16},
{"Reset", Func, 5},
{"Stop", Func, 1},
},
"os/user": {
{"(*User).GroupIds", Method, 7},
{"(UnknownGroupError).Error", Method, 7},
{"(UnknownGroupIdError).Error", Method, 7},
{"(UnknownUserError).Error", Method, 0},
{"(UnknownUserIdError).Error", Method, 0},
{"Current", Func, 0},
{"Group", Type, 7},
{"Group.Gid", Field, 7},
{"Group.Name", Field, 7},
{"Lookup", Func, 0},
{"LookupGroup", Func, 7},
{"LookupGroupId", Func, 7},
{"LookupId", Func, 0},
{"UnknownGroupError", Type, 7},
{"UnknownGroupIdError", Type, 7},
{"UnknownUserError", Type, 0},
{"UnknownUserIdError", Type, 0},
{"User", Type, 0},
{"User.Gid", Field, 0},
{"User.HomeDir", Field, 0},
{"User.Name", Field, 0},
{"User.Uid", Field, 0},
{"User.Username", Field, 0},
},
"path": {
{"Base", Func, 0},
{"Clean", Func, 0},
{"Dir", Func, 0},
{"ErrBadPattern", Var, 0},
{"Ext", Func, 0},
{"IsAbs", Func, 0},
{"Join", Func, 0},
{"Match", Func, 0},
{"Split", Func, 0},
},
"path/filepath": {
{"Abs", Func, 0},
{"Base", Func, 0},
{"Clean", Func, 0},
{"Dir", Func, 0},
{"ErrBadPattern", Var, 0},
{"EvalSymlinks", Func, 0},
{"Ext", Func, 0},
{"FromSlash", Func, 0},
{"Glob", Func, 0},
{"HasPrefix", Func, 0},
{"IsAbs", Func, 0},
{"IsLocal", Func, 20},
{"Join", Func, 0},
{"ListSeparator", Const, 0},
{"Localize", Func, 23},
{"Match", Func, 0},
{"Rel", Func, 0},
{"Separator", Const, 0},
{"SkipAll", Var, 20},
{"SkipDir", Var, 0},
{"Split", Func, 0},
{"SplitList", Func, 0},
{"ToSlash", Func, 0},
{"VolumeName", Func, 0},
{"Walk", Func, 0},
{"WalkDir", Func, 16},
{"WalkFunc", Type, 0},
},
"plugin": {
{"(*Plugin).Lookup", Method, 8},
{"Open", Func, 8},
{"Plugin", Type, 8},
{"Symbol", Type, 8},
},
"reflect": {
{"(*MapIter).Key", Method, 12},
{"(*MapIter).Next", Method, 12},
{"(*MapIter).Reset", Method, 18},
{"(*MapIter).Value", Method, 12},
{"(*ValueError).Error", Method, 0},
{"(ChanDir).String", Method, 0},
{"(Kind).String", Method, 0},
{"(Method).IsExported", Method, 17},
{"(StructField).IsExported", Method, 17},
{"(StructTag).Get", Method, 0},
{"(StructTag).Lookup", Method, 7},
{"(Value).Addr", Method, 0},
{"(Value).Bool", Method, 0},
{"(Value).Bytes", Method, 0},
{"(Value).Call", Method, 0},
{"(Value).CallSlice", Method, 0},
{"(Value).CanAddr", Method, 0},
{"(Value).CanComplex", Method, 18},
{"(Value).CanConvert", Method, 17},
{"(Value).CanFloat", Method, 18},
{"(Value).CanInt", Method, 18},
{"(Value).CanInterface", Method, 0},
{"(Value).CanSet", Method, 0},
{"(Value).CanUint", Method, 18},
{"(Value).Cap", Method, 0},
{"(Value).Clear", Method, 21},
{"(Value).Close", Method, 0},
{"(Value).Comparable", Method, 20},
{"(Value).Complex", Method, 0},
{"(Value).Convert", Method, 1},
{"(Value).Elem", Method, 0},
{"(Value).Equal", Method, 20},
{"(Value).Field", Method, 0},
{"(Value).FieldByIndex", Method, 0},
{"(Value).FieldByIndexErr", Method, 18},
{"(Value).FieldByName", Method, 0},
{"(Value).FieldByNameFunc", Method, 0},
{"(Value).Float", Method, 0},
{"(Value).Grow", Method, 20},
{"(Value).Index", Method, 0},
{"(Value).Int", Method, 0},
{"(Value).Interface", Method, 0},
{"(Value).InterfaceData", Method, 0},
{"(Value).IsNil", Method, 0},
{"(Value).IsValid", Method, 0},
{"(Value).IsZero", Method, 13},
{"(Value).Kind", Method, 0},
{"(Value).Len", Method, 0},
{"(Value).MapIndex", Method, 0},
{"(Value).MapKeys", Method, 0},
{"(Value).MapRange", Method, 12},
{"(Value).Method", Method, 0},
{"(Value).MethodByName", Method, 0},
{"(Value).NumField", Method, 0},
{"(Value).NumMethod", Method, 0},
{"(Value).OverflowComplex", Method, 0},
{"(Value).OverflowFloat", Method, 0},
{"(Value).OverflowInt", Method, 0},
{"(Value).OverflowUint", Method, 0},
{"(Value).Pointer", Method, 0},
{"(Value).Recv", Method, 0},
{"(Value).Send", Method, 0},
{"(Value).Seq", Method, 23},
{"(Value).Seq2", Method, 23},
{"(Value).Set", Method, 0},
{"(Value).SetBool", Method, 0},
{"(Value).SetBytes", Method, 0},
{"(Value).SetCap", Method, 2},
{"(Value).SetComplex", Method, 0},
{"(Value).SetFloat", Method, 0},
{"(Value).SetInt", Method, 0},
{"(Value).SetIterKey", Method, 18},
{"(Value).SetIterValue", Method, 18},
{"(Value).SetLen", Method, 0},
{"(Value).SetMapIndex", Method, 0},
{"(Value).SetPointer", Method, 0},
{"(Value).SetString", Method, 0},
{"(Value).SetUint", Method, 0},
{"(Value).SetZero", Method, 20},
{"(Value).Slice", Method, 0},
{"(Value).Slice3", Method, 2},
{"(Value).String", Method, 0},
{"(Value).TryRecv", Method, 0},
{"(Value).TrySend", Method, 0},
{"(Value).Type", Method, 0},
{"(Value).Uint", Method, 0},
{"(Value).UnsafeAddr", Method, 0},
{"(Value).UnsafePointer", Method, 18},
{"Append", Func, 0},
{"AppendSlice", Func, 0},
{"Array", Const, 0},
{"ArrayOf", Func, 5},
{"Bool", Const, 0},
{"BothDir", Const, 0},
{"Chan", Const, 0},
{"ChanDir", Type, 0},
{"ChanOf", Func, 1},
{"Complex128", Const, 0},
{"Complex64", Const, 0},
{"Copy", Func, 0},
{"DeepEqual", Func, 0},
{"Float32", Const, 0},
{"Float64", Const, 0},
{"Func", Const, 0},
{"FuncOf", Func, 5},
{"Indirect", Func, 0},
{"Int", Const, 0},
{"Int16", Const, 0},
{"Int32", Const, 0},
{"Int64", Const, 0},
{"Int8", Const, 0},
{"Interface", Const, 0},
{"Invalid", Const, 0},
{"Kind", Type, 0},
{"MakeChan", Func, 0},
{"MakeFunc", Func, 1},
{"MakeMap", Func, 0},
{"MakeMapWithSize", Func, 9},
{"MakeSlice", Func, 0},
{"Map", Const, 0},
{"MapIter", Type, 12},
{"MapOf", Func, 1},
{"Method", Type, 0},
{"Method.Func", Field, 0},
{"Method.Index", Field, 0},
{"Method.Name", Field, 0},
{"Method.PkgPath", Field, 0},
{"Method.Type", Field, 0},
{"New", Func, 0},
{"NewAt", Func, 0},
{"Pointer", Const, 18},
{"PointerTo", Func, 18},
{"Ptr", Const, 0},
{"PtrTo", Func, 0},
{"RecvDir", Const, 0},
{"Select", Func, 1},
{"SelectCase", Type, 1},
{"SelectCase.Chan", Field, 1},
{"SelectCase.Dir", Field, 1},
{"SelectCase.Send", Field, 1},
{"SelectDefault", Const, 1},
{"SelectDir", Type, 1},
{"SelectRecv", Const, 1},
{"SelectSend", Const, 1},
{"SendDir", Const, 0},
{"Slice", Const, 0},
{"SliceAt", Func, 23},
{"SliceHeader", Type, 0},
{"SliceHeader.Cap", Field, 0},
{"SliceHeader.Data", Field, 0},
{"SliceHeader.Len", Field, 0},
{"SliceOf", Func, 1},
{"String", Const, 0},
{"StringHeader", Type, 0},
{"StringHeader.Data", Field, 0},
{"StringHeader.Len", Field, 0},
{"Struct", Const, 0},
{"StructField", Type, 0},
{"StructField.Anonymous", Field, 0},
{"StructField.Index", Field, 0},
{"StructField.Name", Field, 0},
{"StructField.Offset", Field, 0},
{"StructField.PkgPath", Field, 0},
{"StructField.Tag", Field, 0},
{"StructField.Type", Field, 0},
{"StructOf", Func, 7},
{"StructTag", Type, 0},
{"Swapper", Func, 8},
{"Type", Type, 0},
{"TypeFor", Func, 22},
{"TypeOf", Func, 0},
{"Uint", Const, 0},
{"Uint16", Const, 0},
{"Uint32", Const, 0},
{"Uint64", Const, 0},
{"Uint8", Const, 0},
{"Uintptr", Const, 0},
{"UnsafePointer", Const, 0},
{"Value", Type, 0},
{"ValueError", Type, 0},
{"ValueError.Kind", Field, 0},
{"ValueError.Method", Field, 0},
{"ValueOf", Func, 0},
{"VisibleFields", Func, 17},
{"Zero", Func, 0},
},
"regexp": {
{"(*Regexp).Copy", Method, 6},
{"(*Regexp).Expand", Method, 0},
{"(*Regexp).ExpandString", Method, 0},
{"(*Regexp).Find", Method, 0},
{"(*Regexp).FindAll", Method, 0},
{"(*Regexp).FindAllIndex", Method, 0},
{"(*Regexp).FindAllString", Method, 0},
{"(*Regexp).FindAllStringIndex", Method, 0},
{"(*Regexp).FindAllStringSubmatch", Method, 0},
{"(*Regexp).FindAllStringSubmatchIndex", Method, 0},
{"(*Regexp).FindAllSubmatch", Method, 0},
{"(*Regexp).FindAllSubmatchIndex", Method, 0},
{"(*Regexp).FindIndex", Method, 0},
{"(*Regexp).FindReaderIndex", Method, 0},
{"(*Regexp).FindReaderSubmatchIndex", Method, 0},
{"(*Regexp).FindString", Method, 0},
{"(*Regexp).FindStringIndex", Method, 0},
{"(*Regexp).FindStringSubmatch", Method, 0},
{"(*Regexp).FindStringSubmatchIndex", Method, 0},
{"(*Regexp).FindSubmatch", Method, 0},
{"(*Regexp).FindSubmatchIndex", Method, 0},
{"(*Regexp).LiteralPrefix", Method, 0},
{"(*Regexp).Longest", Method, 1},
{"(*Regexp).MarshalText", Method, 21},
{"(*Regexp).Match", Method, 0},
{"(*Regexp).MatchReader", Method, 0},
{"(*Regexp).MatchString", Method, 0},
{"(*Regexp).NumSubexp", Method, 0},
{"(*Regexp).ReplaceAll", Method, 0},
{"(*Regexp).ReplaceAllFunc", Method, 0},
{"(*Regexp).ReplaceAllLiteral", Method, 0},
{"(*Regexp).ReplaceAllLiteralString", Method, 0},
{"(*Regexp).ReplaceAllString", Method, 0},
{"(*Regexp).ReplaceAllStringFunc", Method, 0},
{"(*Regexp).Split", Method, 1},
{"(*Regexp).String", Method, 0},
{"(*Regexp).SubexpIndex", Method, 15},
{"(*Regexp).SubexpNames", Method, 0},
{"(*Regexp).UnmarshalText", Method, 21},
{"Compile", Func, 0},
{"CompilePOSIX", Func, 0},
{"Match", Func, 0},
{"MatchReader", Func, 0},
{"MatchString", Func, 0},
{"MustCompile", Func, 0},
{"MustCompilePOSIX", Func, 0},
{"QuoteMeta", Func, 0},
{"Regexp", Type, 0},
},
"regexp/syntax": {
{"(*Error).Error", Method, 0},
{"(*Inst).MatchEmptyWidth", Method, 0},
{"(*Inst).MatchRune", Method, 0},
{"(*Inst).MatchRunePos", Method, 3},
{"(*Inst).String", Method, 0},
{"(*Prog).Prefix", Method, 0},
{"(*Prog).StartCond", Method, 0},
{"(*Prog).String", Method, 0},
{"(*Regexp).CapNames", Method, 0},
{"(*Regexp).Equal", Method, 0},
{"(*Regexp).MaxCap", Method, 0},
{"(*Regexp).Simplify", Method, 0},
{"(*Regexp).String", Method, 0},
{"(ErrorCode).String", Method, 0},
{"(InstOp).String", Method, 3},
{"(Op).String", Method, 11},
{"ClassNL", Const, 0},
{"Compile", Func, 0},
{"DotNL", Const, 0},
{"EmptyBeginLine", Const, 0},
{"EmptyBeginText", Const, 0},
{"EmptyEndLine", Const, 0},
{"EmptyEndText", Const, 0},
{"EmptyNoWordBoundary", Const, 0},
{"EmptyOp", Type, 0},
{"EmptyOpContext", Func, 0},
{"EmptyWordBoundary", Const, 0},
{"ErrInternalError", Const, 0},
{"ErrInvalidCharClass", Const, 0},
{"ErrInvalidCharRange", Const, 0},
{"ErrInvalidEscape", Const, 0},
{"ErrInvalidNamedCapture", Const, 0},
{"ErrInvalidPerlOp", Const, 0},
{"ErrInvalidRepeatOp", Const, 0},
{"ErrInvalidRepeatSize", Const, 0},
{"ErrInvalidUTF8", Const, 0},
{"ErrLarge", Const, 20},
{"ErrMissingBracket", Const, 0},
{"ErrMissingParen", Const, 0},
{"ErrMissingRepeatArgument", Const, 0},
{"ErrNestingDepth", Const, 19},
{"ErrTrailingBackslash", Const, 0},
{"ErrUnexpectedParen", Const, 1},
{"Error", Type, 0},
{"Error.Code", Field, 0},
{"Error.Expr", Field, 0},
{"ErrorCode", Type, 0},
{"Flags", Type, 0},
{"FoldCase", Const, 0},
{"Inst", Type, 0},
{"Inst.Arg", Field, 0},
{"Inst.Op", Field, 0},
{"Inst.Out", Field, 0},
{"Inst.Rune", Field, 0},
{"InstAlt", Const, 0},
{"InstAltMatch", Const, 0},
{"InstCapture", Const, 0},
{"InstEmptyWidth", Const, 0},
{"InstFail", Const, 0},
{"InstMatch", Const, 0},
{"InstNop", Const, 0},
{"InstOp", Type, 0},
{"InstRune", Const, 0},
{"InstRune1", Const, 0},
{"InstRuneAny", Const, 0},
{"InstRuneAnyNotNL", Const, 0},
{"IsWordChar", Func, 0},
{"Literal", Const, 0},
{"MatchNL", Const, 0},
{"NonGreedy", Const, 0},
{"OneLine", Const, 0},
{"Op", Type, 0},
{"OpAlternate", Const, 0},
{"OpAnyChar", Const, 0},
{"OpAnyCharNotNL", Const, 0},
{"OpBeginLine", Const, 0},
{"OpBeginText", Const, 0},
{"OpCapture", Const, 0},
{"OpCharClass", Const, 0},
{"OpConcat", Const, 0},
{"OpEmptyMatch", Const, 0},
{"OpEndLine", Const, 0},
{"OpEndText", Const, 0},
{"OpLiteral", Const, 0},
{"OpNoMatch", Const, 0},
{"OpNoWordBoundary", Const, 0},
{"OpPlus", Const, 0},
{"OpQuest", Const, 0},
{"OpRepeat", Const, 0},
{"OpStar", Const, 0},
{"OpWordBoundary", Const, 0},
{"POSIX", Const, 0},
{"Parse", Func, 0},
{"Perl", Const, 0},
{"PerlX", Const, 0},
{"Prog", Type, 0},
{"Prog.Inst", Field, 0},
{"Prog.NumCap", Field, 0},
{"Prog.Start", Field, 0},
{"Regexp", Type, 0},
{"Regexp.Cap", Field, 0},
{"Regexp.Flags", Field, 0},
{"Regexp.Max", Field, 0},
{"Regexp.Min", Field, 0},
{"Regexp.Name", Field, 0},
{"Regexp.Op", Field, 0},
{"Regexp.Rune", Field, 0},
{"Regexp.Rune0", Field, 0},
{"Regexp.Sub", Field, 0},
{"Regexp.Sub0", Field, 0},
{"Simple", Const, 0},
{"UnicodeGroups", Const, 0},
{"WasDollar", Const, 0},
},
"runtime": {
{"(*BlockProfileRecord).Stack", Method, 1},
{"(*Frames).Next", Method, 7},
{"(*Func).Entry", Method, 0},
{"(*Func).FileLine", Method, 0},
{"(*Func).Name", Method, 0},
{"(*MemProfileRecord).InUseBytes", Method, 0},
{"(*MemProfileRecord).InUseObjects", Method, 0},
{"(*MemProfileRecord).Stack", Method, 0},
{"(*PanicNilError).Error", Method, 21},
{"(*PanicNilError).RuntimeError", Method, 21},
{"(*Pinner).Pin", Method, 21},
{"(*Pinner).Unpin", Method, 21},
{"(*StackRecord).Stack", Method, 0},
{"(*TypeAssertionError).Error", Method, 0},
{"(*TypeAssertionError).RuntimeError", Method, 0},
{"BlockProfile", Func, 1},
{"BlockProfileRecord", Type, 1},
{"BlockProfileRecord.Count", Field, 1},
{"BlockProfileRecord.Cycles", Field, 1},
{"BlockProfileRecord.StackRecord", Field, 1},
{"Breakpoint", Func, 0},
{"CPUProfile", Func, 0},
{"Caller", Func, 0},
{"Callers", Func, 0},
{"CallersFrames", Func, 7},
{"Compiler", Const, 0},
{"Error", Type, 0},
{"Frame", Type, 7},
{"Frame.Entry", Field, 7},
{"Frame.File", Field, 7},
{"Frame.Func", Field, 7},
{"Frame.Function", Field, 7},
{"Frame.Line", Field, 7},
{"Frame.PC", Field, 7},
{"Frames", Type, 7},
{"Func", Type, 0},
{"FuncForPC", Func, 0},
{"GC", Func, 0},
{"GOARCH", Const, 0},
{"GOMAXPROCS", Func, 0},
{"GOOS", Const, 0},
{"GOROOT", Func, 0},
{"Goexit", Func, 0},
{"GoroutineProfile", Func, 0},
{"Gosched", Func, 0},
{"KeepAlive", Func, 7},
{"LockOSThread", Func, 0},
{"MemProfile", Func, 0},
{"MemProfileRate", Var, 0},
{"MemProfileRecord", Type, 0},
{"MemProfileRecord.AllocBytes", Field, 0},
{"MemProfileRecord.AllocObjects", Field, 0},
{"MemProfileRecord.FreeBytes", Field, 0},
{"MemProfileRecord.FreeObjects", Field, 0},
{"MemProfileRecord.Stack0", Field, 0},
{"MemStats", Type, 0},
{"MemStats.Alloc", Field, 0},
{"MemStats.BuckHashSys", Field, 0},
{"MemStats.BySize", Field, 0},
{"MemStats.DebugGC", Field, 0},
{"MemStats.EnableGC", Field, 0},
{"MemStats.Frees", Field, 0},
{"MemStats.GCCPUFraction", Field, 5},
{"MemStats.GCSys", Field, 2},
{"MemStats.HeapAlloc", Field, 0},
{"MemStats.HeapIdle", Field, 0},
{"MemStats.HeapInuse", Field, 0},
{"MemStats.HeapObjects", Field, 0},
{"MemStats.HeapReleased", Field, 0},
{"MemStats.HeapSys", Field, 0},
{"MemStats.LastGC", Field, 0},
{"MemStats.Lookups", Field, 0},
{"MemStats.MCacheInuse", Field, 0},
{"MemStats.MCacheSys", Field, 0},
{"MemStats.MSpanInuse", Field, 0},
{"MemStats.MSpanSys", Field, 0},
{"MemStats.Mallocs", Field, 0},
{"MemStats.NextGC", Field, 0},
{"MemStats.NumForcedGC", Field, 8},
{"MemStats.NumGC", Field, 0},
{"MemStats.OtherSys", Field, 2},
{"MemStats.PauseEnd", Field, 4},
{"MemStats.PauseNs", Field, 0},
{"MemStats.PauseTotalNs", Field, 0},
{"MemStats.StackInuse", Field, 0},
{"MemStats.StackSys", Field, 0},
{"MemStats.Sys", Field, 0},
{"MemStats.TotalAlloc", Field, 0},
{"MutexProfile", Func, 8},
{"NumCPU", Func, 0},
{"NumCgoCall", Func, 0},
{"NumGoroutine", Func, 0},
{"PanicNilError", Type, 21},
{"Pinner", Type, 21},
{"ReadMemStats", Func, 0},
{"ReadTrace", Func, 5},
{"SetBlockProfileRate", Func, 1},
{"SetCPUProfileRate", Func, 0},
{"SetCgoTraceback", Func, 7},
{"SetFinalizer", Func, 0},
{"SetMutexProfileFraction", Func, 8},
{"Stack", Func, 0},
{"StackRecord", Type, 0},
{"StackRecord.Stack0", Field, 0},
{"StartTrace", Func, 5},
{"StopTrace", Func, 5},
{"ThreadCreateProfile", Func, 0},
{"TypeAssertionError", Type, 0},
{"UnlockOSThread", Func, 0},
{"Version", Func, 0},
},
"runtime/cgo": {
{"(Handle).Delete", Method, 17},
{"(Handle).Value", Method, 17},
{"Handle", Type, 17},
{"Incomplete", Type, 20},
{"NewHandle", Func, 17},
},
"runtime/coverage": {
{"ClearCounters", Func, 20},
{"WriteCounters", Func, 20},
{"WriteCountersDir", Func, 20},
{"WriteMeta", Func, 20},
{"WriteMetaDir", Func, 20},
},
"runtime/debug": {
{"(*BuildInfo).String", Method, 18},
{"BuildInfo", Type, 12},
{"BuildInfo.Deps", Field, 12},
{"BuildInfo.GoVersion", Field, 18},
{"BuildInfo.Main", Field, 12},
{"BuildInfo.Path", Field, 12},
{"BuildInfo.Settings", Field, 18},
{"BuildSetting", Type, 18},
{"BuildSetting.Key", Field, 18},
{"BuildSetting.Value", Field, 18},
{"CrashOptions", Type, 23},
{"FreeOSMemory", Func, 1},
{"GCStats", Type, 1},
{"GCStats.LastGC", Field, 1},
{"GCStats.NumGC", Field, 1},
{"GCStats.Pause", Field, 1},
{"GCStats.PauseEnd", Field, 4},
{"GCStats.PauseQuantiles", Field, 1},
{"GCStats.PauseTotal", Field, 1},
{"Module", Type, 12},
{"Module.Path", Field, 12},
{"Module.Replace", Field, 12},
{"Module.Sum", Field, 12},
{"Module.Version", Field, 12},
{"ParseBuildInfo", Func, 18},
{"PrintStack", Func, 0},
{"ReadBuildInfo", Func, 12},
{"ReadGCStats", Func, 1},
{"SetCrashOutput", Func, 23},
{"SetGCPercent", Func, 1},
{"SetMaxStack", Func, 2},
{"SetMaxThreads", Func, 2},
{"SetMemoryLimit", Func, 19},
{"SetPanicOnFault", Func, 3},
{"SetTraceback", Func, 6},
{"Stack", Func, 0},
{"WriteHeapDump", Func, 3},
},
"runtime/metrics": {
{"(Value).Float64", Method, 16},
{"(Value).Float64Histogram", Method, 16},
{"(Value).Kind", Method, 16},
{"(Value).Uint64", Method, 16},
{"All", Func, 16},
{"Description", Type, 16},
{"Description.Cumulative", Field, 16},
{"Description.Description", Field, 16},
{"Description.Kind", Field, 16},
{"Description.Name", Field, 16},
{"Float64Histogram", Type, 16},
{"Float64Histogram.Buckets", Field, 16},
{"Float64Histogram.Counts", Field, 16},
{"KindBad", Const, 16},
{"KindFloat64", Const, 16},
{"KindFloat64Histogram", Const, 16},
{"KindUint64", Const, 16},
{"Read", Func, 16},
{"Sample", Type, 16},
{"Sample.Name", Field, 16},
{"Sample.Value", Field, 16},
{"Value", Type, 16},
{"ValueKind", Type, 16},
},
"runtime/pprof": {
{"(*Profile).Add", Method, 0},
{"(*Profile).Count", Method, 0},
{"(*Profile).Name", Method, 0},
{"(*Profile).Remove", Method, 0},
{"(*Profile).WriteTo", Method, 0},
{"Do", Func, 9},
{"ForLabels", Func, 9},
{"Label", Func, 9},
{"LabelSet", Type, 9},
{"Labels", Func, 9},
{"Lookup", Func, 0},
{"NewProfile", Func, 0},
{"Profile", Type, 0},
{"Profiles", Func, 0},
{"SetGoroutineLabels", Func, 9},
{"StartCPUProfile", Func, 0},
{"StopCPUProfile", Func, 0},
{"WithLabels", Func, 9},
{"WriteHeapProfile", Func, 0},
},
"runtime/trace": {
{"(*Region).End", Method, 11},
{"(*Task).End", Method, 11},
{"IsEnabled", Func, 11},
{"Log", Func, 11},
{"Logf", Func, 11},
{"NewTask", Func, 11},
{"Region", Type, 11},
{"Start", Func, 5},
{"StartRegion", Func, 11},
{"Stop", Func, 5},
{"Task", Type, 11},
{"WithRegion", Func, 11},
},
"slices": {
{"All", Func, 23},
{"AppendSeq", Func, 23},
{"Backward", Func, 23},
{"BinarySearch", Func, 21},
{"BinarySearchFunc", Func, 21},
{"Chunk", Func, 23},
{"Clip", Func, 21},
{"Clone", Func, 21},
{"Collect", Func, 23},
{"Compact", Func, 21},
{"CompactFunc", Func, 21},
{"Compare", Func, 21},
{"CompareFunc", Func, 21},
{"Concat", Func, 22},
{"Contains", Func, 21},
{"ContainsFunc", Func, 21},
{"Delete", Func, 21},
{"DeleteFunc", Func, 21},
{"Equal", Func, 21},
{"EqualFunc", Func, 21},
{"Grow", Func, 21},
{"Index", Func, 21},
{"IndexFunc", Func, 21},
{"Insert", Func, 21},
{"IsSorted", Func, 21},
{"IsSortedFunc", Func, 21},
{"Max", Func, 21},
{"MaxFunc", Func, 21},
{"Min", Func, 21},
{"MinFunc", Func, 21},
{"Repeat", Func, 23},
{"Replace", Func, 21},
{"Reverse", Func, 21},
{"Sort", Func, 21},
{"SortFunc", Func, 21},
{"SortStableFunc", Func, 21},
{"Sorted", Func, 23},
{"SortedFunc", Func, 23},
{"SortedStableFunc", Func, 23},
{"Values", Func, 23},
},
"sort": {
{"(Float64Slice).Len", Method, 0},
{"(Float64Slice).Less", Method, 0},
{"(Float64Slice).Search", Method, 0},
{"(Float64Slice).Sort", Method, 0},
{"(Float64Slice).Swap", Method, 0},
{"(IntSlice).Len", Method, 0},
{"(IntSlice).Less", Method, 0},
{"(IntSlice).Search", Method, 0},
{"(IntSlice).Sort", Method, 0},
{"(IntSlice).Swap", Method, 0},
{"(StringSlice).Len", Method, 0},
{"(StringSlice).Less", Method, 0},
{"(StringSlice).Search", Method, 0},
{"(StringSlice).Sort", Method, 0},
{"(StringSlice).Swap", Method, 0},
{"Find", Func, 19},
{"Float64Slice", Type, 0},
{"Float64s", Func, 0},
{"Float64sAreSorted", Func, 0},
{"IntSlice", Type, 0},
{"Interface", Type, 0},
{"Ints", Func, 0},
{"IntsAreSorted", Func, 0},
{"IsSorted", Func, 0},
{"Reverse", Func, 1},
{"Search", Func, 0},
{"SearchFloat64s", Func, 0},
{"SearchInts", Func, 0},
{"SearchStrings", Func, 0},
{"Slice", Func, 8},
{"SliceIsSorted", Func, 8},
{"SliceStable", Func, 8},
{"Sort", Func, 0},
{"Stable", Func, 2},
{"StringSlice", Type, 0},
{"Strings", Func, 0},
{"StringsAreSorted", Func, 0},
},
"strconv": {
{"(*NumError).Error", Method, 0},
{"(*NumError).Unwrap", Method, 14},
{"AppendBool", Func, 0},
{"AppendFloat", Func, 0},
{"AppendInt", Func, 0},
{"AppendQuote", Func, 0},
{"AppendQuoteRune", Func, 0},
{"AppendQuoteRuneToASCII", Func, 0},
{"AppendQuoteRuneToGraphic", Func, 6},
{"AppendQuoteToASCII", Func, 0},
{"AppendQuoteToGraphic", Func, 6},
{"AppendUint", Func, 0},
{"Atoi", Func, 0},
{"CanBackquote", Func, 0},
{"ErrRange", Var, 0},
{"ErrSyntax", Var, 0},
{"FormatBool", Func, 0},
{"FormatComplex", Func, 15},
{"FormatFloat", Func, 0},
{"FormatInt", Func, 0},
{"FormatUint", Func, 0},
{"IntSize", Const, 0},
{"IsGraphic", Func, 6},
{"IsPrint", Func, 0},
{"Itoa", Func, 0},
{"NumError", Type, 0},
{"NumError.Err", Field, 0},
{"NumError.Func", Field, 0},
{"NumError.Num", Field, 0},
{"ParseBool", Func, 0},
{"ParseComplex", Func, 15},
{"ParseFloat", Func, 0},
{"ParseInt", Func, 0},
{"ParseUint", Func, 0},
{"Quote", Func, 0},
{"QuoteRune", Func, 0},
{"QuoteRuneToASCII", Func, 0},
{"QuoteRuneToGraphic", Func, 6},
{"QuoteToASCII", Func, 0},
{"QuoteToGraphic", Func, 6},
{"QuotedPrefix", Func, 17},
{"Unquote", Func, 0},
{"UnquoteChar", Func, 0},
},
"strings": {
{"(*Builder).Cap", Method, 12},
{"(*Builder).Grow", Method, 10},
{"(*Builder).Len", Method, 10},
{"(*Builder).Reset", Method, 10},
{"(*Builder).String", Method, 10},
{"(*Builder).Write", Method, 10},
{"(*Builder).WriteByte", Method, 10},
{"(*Builder).WriteRune", Method, 10},
{"(*Builder).WriteString", Method, 10},
{"(*Reader).Len", Method, 0},
{"(*Reader).Read", Method, 0},
{"(*Reader).ReadAt", Method, 0},
{"(*Reader).ReadByte", Method, 0},
{"(*Reader).ReadRune", Method, 0},
{"(*Reader).Reset", Method, 7},
{"(*Reader).Seek", Method, 0},
{"(*Reader).Size", Method, 5},
{"(*Reader).UnreadByte", Method, 0},
{"(*Reader).UnreadRune", Method, 0},
{"(*Reader).WriteTo", Method, 1},
{"(*Replacer).Replace", Method, 0},
{"(*Replacer).WriteString", Method, 0},
{"Builder", Type, 10},
{"Clone", Func, 18},
{"Compare", Func, 5},
{"Contains", Func, 0},
{"ContainsAny", Func, 0},
{"ContainsFunc", Func, 21},
{"ContainsRune", Func, 0},
{"Count", Func, 0},
{"Cut", Func, 18},
{"CutPrefix", Func, 20},
{"CutSuffix", Func, 20},
{"EqualFold", Func, 0},
{"Fields", Func, 0},
{"FieldsFunc", Func, 0},
{"HasPrefix", Func, 0},
{"HasSuffix", Func, 0},
{"Index", Func, 0},
{"IndexAny", Func, 0},
{"IndexByte", Func, 2},
{"IndexFunc", Func, 0},
{"IndexRune", Func, 0},
{"Join", Func, 0},
{"LastIndex", Func, 0},
{"LastIndexAny", Func, 0},
{"LastIndexByte", Func, 5},
{"LastIndexFunc", Func, 0},
{"Map", Func, 0},
{"NewReader", Func, 0},
{"NewReplacer", Func, 0},
{"Reader", Type, 0},
{"Repeat", Func, 0},
{"Replace", Func, 0},
{"ReplaceAll", Func, 12},
{"Replacer", Type, 0},
{"Split", Func, 0},
{"SplitAfter", Func, 0},
{"SplitAfterN", Func, 0},
{"SplitN", Func, 0},
{"Title", Func, 0},
{"ToLower", Func, 0},
{"ToLowerSpecial", Func, 0},
{"ToTitle", Func, 0},
{"ToTitleSpecial", Func, 0},
{"ToUpper", Func, 0},
{"ToUpperSpecial", Func, 0},
{"ToValidUTF8", Func, 13},
{"Trim", Func, 0},
{"TrimFunc", Func, 0},
{"TrimLeft", Func, 0},
{"TrimLeftFunc", Func, 0},
{"TrimPrefix", Func, 1},
{"TrimRight", Func, 0},
{"TrimRightFunc", Func, 0},
{"TrimSpace", Func, 0},
{"TrimSuffix", Func, 1},
},
"structs": {
{"HostLayout", Type, 23},
},
"sync": {
{"(*Cond).Broadcast", Method, 0},
{"(*Cond).Signal", Method, 0},
{"(*Cond).Wait", Method, 0},
{"(*Map).Clear", Method, 23},
{"(*Map).CompareAndDelete", Method, 20},
{"(*Map).CompareAndSwap", Method, 20},
{"(*Map).Delete", Method, 9},
{"(*Map).Load", Method, 9},
{"(*Map).LoadAndDelete", Method, 15},
{"(*Map).LoadOrStore", Method, 9},
{"(*Map).Range", Method, 9},
{"(*Map).Store", Method, 9},
{"(*Map).Swap", Method, 20},
{"(*Mutex).Lock", Method, 0},
{"(*Mutex).TryLock", Method, 18},
{"(*Mutex).Unlock", Method, 0},
{"(*Once).Do", Method, 0},
{"(*Pool).Get", Method, 3},
{"(*Pool).Put", Method, 3},
{"(*RWMutex).Lock", Method, 0},
{"(*RWMutex).RLock", Method, 0},
{"(*RWMutex).RLocker", Method, 0},
{"(*RWMutex).RUnlock", Method, 0},
{"(*RWMutex).TryLock", Method, 18},
{"(*RWMutex).TryRLock", Method, 18},
{"(*RWMutex).Unlock", Method, 0},
{"(*WaitGroup).Add", Method, 0},
{"(*WaitGroup).Done", Method, 0},
{"(*WaitGroup).Wait", Method, 0},
{"Cond", Type, 0},
{"Cond.L", Field, 0},
{"Locker", Type, 0},
{"Map", Type, 9},
{"Mutex", Type, 0},
{"NewCond", Func, 0},
{"Once", Type, 0},
{"OnceFunc", Func, 21},
{"OnceValue", Func, 21},
{"OnceValues", Func, 21},
{"Pool", Type, 3},
{"Pool.New", Field, 3},
{"RWMutex", Type, 0},
{"WaitGroup", Type, 0},
},
"sync/atomic": {
{"(*Bool).CompareAndSwap", Method, 19},
{"(*Bool).Load", Method, 19},
{"(*Bool).Store", Method, 19},
{"(*Bool).Swap", Method, 19},
{"(*Int32).Add", Method, 19},
{"(*Int32).And", Method, 23},
{"(*Int32).CompareAndSwap", Method, 19},
{"(*Int32).Load", Method, 19},
{"(*Int32).Or", Method, 23},
{"(*Int32).Store", Method, 19},
{"(*Int32).Swap", Method, 19},
{"(*Int64).Add", Method, 19},
{"(*Int64).And", Method, 23},
{"(*Int64).CompareAndSwap", Method, 19},
{"(*Int64).Load", Method, 19},
{"(*Int64).Or", Method, 23},
{"(*Int64).Store", Method, 19},
{"(*Int64).Swap", Method, 19},
{"(*Pointer).CompareAndSwap", Method, 19},
{"(*Pointer).Load", Method, 19},
{"(*Pointer).Store", Method, 19},
{"(*Pointer).Swap", Method, 19},
{"(*Uint32).Add", Method, 19},
{"(*Uint32).And", Method, 23},
{"(*Uint32).CompareAndSwap", Method, 19},
{"(*Uint32).Load", Method, 19},
{"(*Uint32).Or", Method, 23},
{"(*Uint32).Store", Method, 19},
{"(*Uint32).Swap", Method, 19},
{"(*Uint64).Add", Method, 19},
{"(*Uint64).And", Method, 23},
{"(*Uint64).CompareAndSwap", Method, 19},
{"(*Uint64).Load", Method, 19},
{"(*Uint64).Or", Method, 23},
{"(*Uint64).Store", Method, 19},
{"(*Uint64).Swap", Method, 19},
{"(*Uintptr).Add", Method, 19},
{"(*Uintptr).And", Method, 23},
{"(*Uintptr).CompareAndSwap", Method, 19},
{"(*Uintptr).Load", Method, 19},
{"(*Uintptr).Or", Method, 23},
{"(*Uintptr).Store", Method, 19},
{"(*Uintptr).Swap", Method, 19},
{"(*Value).CompareAndSwap", Method, 17},
{"(*Value).Load", Method, 4},
{"(*Value).Store", Method, 4},
{"(*Value).Swap", Method, 17},
{"AddInt32", Func, 0},
{"AddInt64", Func, 0},
{"AddUint32", Func, 0},
{"AddUint64", Func, 0},
{"AddUintptr", Func, 0},
{"AndInt32", Func, 23},
{"AndInt64", Func, 23},
{"AndUint32", Func, 23},
{"AndUint64", Func, 23},
{"AndUintptr", Func, 23},
{"Bool", Type, 19},
{"CompareAndSwapInt32", Func, 0},
{"CompareAndSwapInt64", Func, 0},
{"CompareAndSwapPointer", Func, 0},
{"CompareAndSwapUint32", Func, 0},
{"CompareAndSwapUint64", Func, 0},
{"CompareAndSwapUintptr", Func, 0},
{"Int32", Type, 19},
{"Int64", Type, 19},
{"LoadInt32", Func, 0},
{"LoadInt64", Func, 0},
{"LoadPointer", Func, 0},
{"LoadUint32", Func, 0},
{"LoadUint64", Func, 0},
{"LoadUintptr", Func, 0},
{"OrInt32", Func, 23},
{"OrInt64", Func, 23},
{"OrUint32", Func, 23},
{"OrUint64", Func, 23},
{"OrUintptr", Func, 23},
{"Pointer", Type, 19},
{"StoreInt32", Func, 0},
{"StoreInt64", Func, 0},
{"StorePointer", Func, 0},
{"StoreUint32", Func, 0},
{"StoreUint64", Func, 0},
{"StoreUintptr", Func, 0},
{"SwapInt32", Func, 2},
{"SwapInt64", Func, 2},
{"SwapPointer", Func, 2},
{"SwapUint32", Func, 2},
{"SwapUint64", Func, 2},
{"SwapUintptr", Func, 2},
{"Uint32", Type, 19},
{"Uint64", Type, 19},
{"Uintptr", Type, 19},
{"Value", Type, 4},
},
"syscall": {
{"(*Cmsghdr).SetLen", Method, 0},
{"(*DLL).FindProc", Method, 0},
{"(*DLL).MustFindProc", Method, 0},
{"(*DLL).Release", Method, 0},
{"(*DLLError).Error", Method, 0},
{"(*DLLError).Unwrap", Method, 16},
{"(*Filetime).Nanoseconds", Method, 0},
{"(*Iovec).SetLen", Method, 0},
{"(*LazyDLL).Handle", Method, 0},
{"(*LazyDLL).Load", Method, 0},
{"(*LazyDLL).NewProc", Method, 0},
{"(*LazyProc).Addr", Method, 0},
{"(*LazyProc).Call", Method, 0},
{"(*LazyProc).Find", Method, 0},
{"(*Msghdr).SetControllen", Method, 0},
{"(*Proc).Addr", Method, 0},
{"(*Proc).Call", Method, 0},
{"(*PtraceRegs).PC", Method, 0},
{"(*PtraceRegs).SetPC", Method, 0},
{"(*RawSockaddrAny).Sockaddr", Method, 0},
{"(*SID).Copy", Method, 0},
{"(*SID).Len", Method, 0},
{"(*SID).LookupAccount", Method, 0},
{"(*SID).String", Method, 0},
{"(*Timespec).Nano", Method, 0},
{"(*Timespec).Unix", Method, 0},
{"(*Timeval).Nano", Method, 0},
{"(*Timeval).Nanoseconds", Method, 0},
{"(*Timeval).Unix", Method, 0},
{"(Errno).Error", Method, 0},
{"(Errno).Is", Method, 13},
{"(Errno).Temporary", Method, 0},
{"(Errno).Timeout", Method, 0},
{"(Signal).Signal", Method, 0},
{"(Signal).String", Method, 0},
{"(Token).Close", Method, 0},
{"(Token).GetTokenPrimaryGroup", Method, 0},
{"(Token).GetTokenUser", Method, 0},
{"(Token).GetUserProfileDirectory", Method, 0},
{"(WaitStatus).Continued", Method, 0},
{"(WaitStatus).CoreDump", Method, 0},
{"(WaitStatus).ExitStatus", Method, 0},
{"(WaitStatus).Exited", Method, 0},
{"(WaitStatus).Signal", Method, 0},
{"(WaitStatus).Signaled", Method, 0},
{"(WaitStatus).StopSignal", Method, 0},
{"(WaitStatus).Stopped", Method, 0},
{"(WaitStatus).TrapCause", Method, 0},
{"AF_ALG", Const, 0},
{"AF_APPLETALK", Const, 0},
{"AF_ARP", Const, 0},
{"AF_ASH", Const, 0},
{"AF_ATM", Const, 0},
{"AF_ATMPVC", Const, 0},
{"AF_ATMSVC", Const, 0},
{"AF_AX25", Const, 0},
{"AF_BLUETOOTH", Const, 0},
{"AF_BRIDGE", Const, 0},
{"AF_CAIF", Const, 0},
{"AF_CAN", Const, 0},
{"AF_CCITT", Const, 0},
{"AF_CHAOS", Const, 0},
{"AF_CNT", Const, 0},
{"AF_COIP", Const, 0},
{"AF_DATAKIT", Const, 0},
{"AF_DECnet", Const, 0},
{"AF_DLI", Const, 0},
{"AF_E164", Const, 0},
{"AF_ECMA", Const, 0},
{"AF_ECONET", Const, 0},
{"AF_ENCAP", Const, 1},
{"AF_FILE", Const, 0},
{"AF_HYLINK", Const, 0},
{"AF_IEEE80211", Const, 0},
{"AF_IEEE802154", Const, 0},
{"AF_IMPLINK", Const, 0},
{"AF_INET", Const, 0},
{"AF_INET6", Const, 0},
{"AF_INET6_SDP", Const, 3},
{"AF_INET_SDP", Const, 3},
{"AF_IPX", Const, 0},
{"AF_IRDA", Const, 0},
{"AF_ISDN", Const, 0},
{"AF_ISO", Const, 0},
{"AF_IUCV", Const, 0},
{"AF_KEY", Const, 0},
{"AF_LAT", Const, 0},
{"AF_LINK", Const, 0},
{"AF_LLC", Const, 0},
{"AF_LOCAL", Const, 0},
{"AF_MAX", Const, 0},
{"AF_MPLS", Const, 1},
{"AF_NATM", Const, 0},
{"AF_NDRV", Const, 0},
{"AF_NETBEUI", Const, 0},
{"AF_NETBIOS", Const, 0},
{"AF_NETGRAPH", Const, 0},
{"AF_NETLINK", Const, 0},
{"AF_NETROM", Const, 0},
{"AF_NS", Const, 0},
{"AF_OROUTE", Const, 1},
{"AF_OSI", Const, 0},
{"AF_PACKET", Const, 0},
{"AF_PHONET", Const, 0},
{"AF_PPP", Const, 0},
{"AF_PPPOX", Const, 0},
{"AF_PUP", Const, 0},
{"AF_RDS", Const, 0},
{"AF_RESERVED_36", Const, 0},
{"AF_ROSE", Const, 0},
{"AF_ROUTE", Const, 0},
{"AF_RXRPC", Const, 0},
{"AF_SCLUSTER", Const, 0},
{"AF_SECURITY", Const, 0},
{"AF_SIP", Const, 0},
{"AF_SLOW", Const, 0},
{"AF_SNA", Const, 0},
{"AF_SYSTEM", Const, 0},
{"AF_TIPC", Const, 0},
{"AF_UNIX", Const, 0},
{"AF_UNSPEC", Const, 0},
{"AF_UTUN", Const, 16},
{"AF_VENDOR00", Const, 0},
{"AF_VENDOR01", Const, 0},
{"AF_VENDOR02", Const, 0},
{"AF_VENDOR03", Const, 0},
{"AF_VENDOR04", Const, 0},
{"AF_VENDOR05", Const, 0},
{"AF_VENDOR06", Const, 0},
{"AF_VENDOR07", Const, 0},
{"AF_VENDOR08", Const, 0},
{"AF_VENDOR09", Const, 0},
{"AF_VENDOR10", Const, 0},
{"AF_VENDOR11", Const, 0},
{"AF_VENDOR12", Const, 0},
{"AF_VENDOR13", Const, 0},
{"AF_VENDOR14", Const, 0},
{"AF_VENDOR15", Const, 0},
{"AF_VENDOR16", Const, 0},
{"AF_VENDOR17", Const, 0},
{"AF_VENDOR18", Const, 0},
{"AF_VENDOR19", Const, 0},
{"AF_VENDOR20", Const, 0},
{"AF_VENDOR21", Const, 0},
{"AF_VENDOR22", Const, 0},
{"AF_VENDOR23", Const, 0},
{"AF_VENDOR24", Const, 0},
{"AF_VENDOR25", Const, 0},
{"AF_VENDOR26", Const, 0},
{"AF_VENDOR27", Const, 0},
{"AF_VENDOR28", Const, 0},
{"AF_VENDOR29", Const, 0},
{"AF_VENDOR30", Const, 0},
{"AF_VENDOR31", Const, 0},
{"AF_VENDOR32", Const, 0},
{"AF_VENDOR33", Const, 0},
{"AF_VENDOR34", Const, 0},
{"AF_VENDOR35", Const, 0},
{"AF_VENDOR36", Const, 0},
{"AF_VENDOR37", Const, 0},
{"AF_VENDOR38", Const, 0},
{"AF_VENDOR39", Const, 0},
{"AF_VENDOR40", Const, 0},
{"AF_VENDOR41", Const, 0},
{"AF_VENDOR42", Const, 0},
{"AF_VENDOR43", Const, 0},
{"AF_VENDOR44", Const, 0},
{"AF_VENDOR45", Const, 0},
{"AF_VENDOR46", Const, 0},
{"AF_VENDOR47", Const, 0},
{"AF_WANPIPE", Const, 0},
{"AF_X25", Const, 0},
{"AI_CANONNAME", Const, 1},
{"AI_NUMERICHOST", Const, 1},
{"AI_PASSIVE", Const, 1},
{"APPLICATION_ERROR", Const, 0},
{"ARPHRD_ADAPT", Const, 0},
{"ARPHRD_APPLETLK", Const, 0},
{"ARPHRD_ARCNET", Const, 0},
{"ARPHRD_ASH", Const, 0},
{"ARPHRD_ATM", Const, 0},
{"ARPHRD_AX25", Const, 0},
{"ARPHRD_BIF", Const, 0},
{"ARPHRD_CHAOS", Const, 0},
{"ARPHRD_CISCO", Const, 0},
{"ARPHRD_CSLIP", Const, 0},
{"ARPHRD_CSLIP6", Const, 0},
{"ARPHRD_DDCMP", Const, 0},
{"ARPHRD_DLCI", Const, 0},
{"ARPHRD_ECONET", Const, 0},
{"ARPHRD_EETHER", Const, 0},
{"ARPHRD_ETHER", Const, 0},
{"ARPHRD_EUI64", Const, 0},
{"ARPHRD_FCAL", Const, 0},
{"ARPHRD_FCFABRIC", Const, 0},
{"ARPHRD_FCPL", Const, 0},
{"ARPHRD_FCPP", Const, 0},
{"ARPHRD_FDDI", Const, 0},
{"ARPHRD_FRAD", Const, 0},
{"ARPHRD_FRELAY", Const, 1},
{"ARPHRD_HDLC", Const, 0},
{"ARPHRD_HIPPI", Const, 0},
{"ARPHRD_HWX25", Const, 0},
{"ARPHRD_IEEE1394", Const, 0},
{"ARPHRD_IEEE802", Const, 0},
{"ARPHRD_IEEE80211", Const, 0},
{"ARPHRD_IEEE80211_PRISM", Const, 0},
{"ARPHRD_IEEE80211_RADIOTAP", Const, 0},
{"ARPHRD_IEEE802154", Const, 0},
{"ARPHRD_IEEE802154_PHY", Const, 0},
{"ARPHRD_IEEE802_TR", Const, 0},
{"ARPHRD_INFINIBAND", Const, 0},
{"ARPHRD_IPDDP", Const, 0},
{"ARPHRD_IPGRE", Const, 0},
{"ARPHRD_IRDA", Const, 0},
{"ARPHRD_LAPB", Const, 0},
{"ARPHRD_LOCALTLK", Const, 0},
{"ARPHRD_LOOPBACK", Const, 0},
{"ARPHRD_METRICOM", Const, 0},
{"ARPHRD_NETROM", Const, 0},
{"ARPHRD_NONE", Const, 0},
{"ARPHRD_PIMREG", Const, 0},
{"ARPHRD_PPP", Const, 0},
{"ARPHRD_PRONET", Const, 0},
{"ARPHRD_RAWHDLC", Const, 0},
{"ARPHRD_ROSE", Const, 0},
{"ARPHRD_RSRVD", Const, 0},
{"ARPHRD_SIT", Const, 0},
{"ARPHRD_SKIP", Const, 0},
{"ARPHRD_SLIP", Const, 0},
{"ARPHRD_SLIP6", Const, 0},
{"ARPHRD_STRIP", Const, 1},
{"ARPHRD_TUNNEL", Const, 0},
{"ARPHRD_TUNNEL6", Const, 0},
{"ARPHRD_VOID", Const, 0},
{"ARPHRD_X25", Const, 0},
{"AUTHTYPE_CLIENT", Const, 0},
{"AUTHTYPE_SERVER", Const, 0},
{"Accept", Func, 0},
{"Accept4", Func, 1},
{"AcceptEx", Func, 0},
{"Access", Func, 0},
{"Acct", Func, 0},
{"AddrinfoW", Type, 1},
{"AddrinfoW.Addr", Field, 1},
{"AddrinfoW.Addrlen", Field, 1},
{"AddrinfoW.Canonname", Field, 1},
{"AddrinfoW.Family", Field, 1},
{"AddrinfoW.Flags", Field, 1},
{"AddrinfoW.Next", Field, 1},
{"AddrinfoW.Protocol", Field, 1},
{"AddrinfoW.Socktype", Field, 1},
{"Adjtime", Func, 0},
{"Adjtimex", Func, 0},
{"AllThreadsSyscall", Func, 16},
{"AllThreadsSyscall6", Func, 16},
{"AttachLsf", Func, 0},
{"B0", Const, 0},
{"B1000000", Const, 0},
{"B110", Const, 0},
{"B115200", Const, 0},
{"B1152000", Const, 0},
{"B1200", Const, 0},
{"B134", Const, 0},
{"B14400", Const, 1},
{"B150", Const, 0},
{"B1500000", Const, 0},
{"B1800", Const, 0},
{"B19200", Const, 0},
{"B200", Const, 0},
{"B2000000", Const, 0},
{"B230400", Const, 0},
{"B2400", Const, 0},
{"B2500000", Const, 0},
{"B28800", Const, 1},
{"B300", Const, 0},
{"B3000000", Const, 0},
{"B3500000", Const, 0},
{"B38400", Const, 0},
{"B4000000", Const, 0},
{"B460800", Const, 0},
{"B4800", Const, 0},
{"B50", Const, 0},
{"B500000", Const, 0},
{"B57600", Const, 0},
{"B576000", Const, 0},
{"B600", Const, 0},
{"B7200", Const, 1},
{"B75", Const, 0},
{"B76800", Const, 1},
{"B921600", Const, 0},
{"B9600", Const, 0},
{"BASE_PROTOCOL", Const, 2},
{"BIOCFEEDBACK", Const, 0},
{"BIOCFLUSH", Const, 0},
{"BIOCGBLEN", Const, 0},
{"BIOCGDIRECTION", Const, 0},
{"BIOCGDIRFILT", Const, 1},
{"BIOCGDLT", Const, 0},
{"BIOCGDLTLIST", Const, 0},
{"BIOCGETBUFMODE", Const, 0},
{"BIOCGETIF", Const, 0},
{"BIOCGETZMAX", Const, 0},
{"BIOCGFEEDBACK", Const, 1},
{"BIOCGFILDROP", Const, 1},
{"BIOCGHDRCMPLT", Const, 0},
{"BIOCGRSIG", Const, 0},
{"BIOCGRTIMEOUT", Const, 0},
{"BIOCGSEESENT", Const, 0},
{"BIOCGSTATS", Const, 0},
{"BIOCGSTATSOLD", Const, 1},
{"BIOCGTSTAMP", Const, 1},
{"BIOCIMMEDIATE", Const, 0},
{"BIOCLOCK", Const, 0},
{"BIOCPROMISC", Const, 0},
{"BIOCROTZBUF", Const, 0},
{"BIOCSBLEN", Const, 0},
{"BIOCSDIRECTION", Const, 0},
{"BIOCSDIRFILT", Const, 1},
{"BIOCSDLT", Const, 0},
{"BIOCSETBUFMODE", Const, 0},
{"BIOCSETF", Const, 0},
{"BIOCSETFNR", Const, 0},
{"BIOCSETIF", Const, 0},
{"BIOCSETWF", Const, 0},
{"BIOCSETZBUF", Const, 0},
{"BIOCSFEEDBACK", Const, 1},
{"BIOCSFILDROP", Const, 1},
{"BIOCSHDRCMPLT", Const, 0},
{"BIOCSRSIG", Const, 0},
{"BIOCSRTIMEOUT", Const, 0},
{"BIOCSSEESENT", Const, 0},
{"BIOCSTCPF", Const, 1},
{"BIOCSTSTAMP", Const, 1},
{"BIOCSUDPF", Const, 1},
{"BIOCVERSION", Const, 0},
{"BPF_A", Const, 0},
{"BPF_ABS", Const, 0},
{"BPF_ADD", Const, 0},
{"BPF_ALIGNMENT", Const, 0},
{"BPF_ALIGNMENT32", Const, 1},
{"BPF_ALU", Const, 0},
{"BPF_AND", Const, 0},
{"BPF_B", Const, 0},
{"BPF_BUFMODE_BUFFER", Const, 0},
{"BPF_BUFMODE_ZBUF", Const, 0},
{"BPF_DFLTBUFSIZE", Const, 1},
{"BPF_DIRECTION_IN", Const, 1},
{"BPF_DIRECTION_OUT", Const, 1},
{"BPF_DIV", Const, 0},
{"BPF_H", Const, 0},
{"BPF_IMM", Const, 0},
{"BPF_IND", Const, 0},
{"BPF_JA", Const, 0},
{"BPF_JEQ", Const, 0},
{"BPF_JGE", Const, 0},
{"BPF_JGT", Const, 0},
{"BPF_JMP", Const, 0},
{"BPF_JSET", Const, 0},
{"BPF_K", Const, 0},
{"BPF_LD", Const, 0},
{"BPF_LDX", Const, 0},
{"BPF_LEN", Const, 0},
{"BPF_LSH", Const, 0},
{"BPF_MAJOR_VERSION", Const, 0},
{"BPF_MAXBUFSIZE", Const, 0},
{"BPF_MAXINSNS", Const, 0},
{"BPF_MEM", Const, 0},
{"BPF_MEMWORDS", Const, 0},
{"BPF_MINBUFSIZE", Const, 0},
{"BPF_MINOR_VERSION", Const, 0},
{"BPF_MISC", Const, 0},
{"BPF_MSH", Const, 0},
{"BPF_MUL", Const, 0},
{"BPF_NEG", Const, 0},
{"BPF_OR", Const, 0},
{"BPF_RELEASE", Const, 0},
{"BPF_RET", Const, 0},
{"BPF_RSH", Const, 0},
{"BPF_ST", Const, 0},
{"BPF_STX", Const, 0},
{"BPF_SUB", Const, 0},
{"BPF_TAX", Const, 0},
{"BPF_TXA", Const, 0},
{"BPF_T_BINTIME", Const, 1},
{"BPF_T_BINTIME_FAST", Const, 1},
{"BPF_T_BINTIME_MONOTONIC", Const, 1},
{"BPF_T_BINTIME_MONOTONIC_FAST", Const, 1},
{"BPF_T_FAST", Const, 1},
{"BPF_T_FLAG_MASK", Const, 1},
{"BPF_T_FORMAT_MASK", Const, 1},
{"BPF_T_MICROTIME", Const, 1},
{"BPF_T_MICROTIME_FAST", Const, 1},
{"BPF_T_MICROTIME_MONOTONIC", Const, 1},
{"BPF_T_MICROTIME_MONOTONIC_FAST", Const, 1},
{"BPF_T_MONOTONIC", Const, 1},
{"BPF_T_MONOTONIC_FAST", Const, 1},
{"BPF_T_NANOTIME", Const, 1},
{"BPF_T_NANOTIME_FAST", Const, 1},
{"BPF_T_NANOTIME_MONOTONIC", Const, 1},
{"BPF_T_NANOTIME_MONOTONIC_FAST", Const, 1},
{"BPF_T_NONE", Const, 1},
{"BPF_T_NORMAL", Const, 1},
{"BPF_W", Const, 0},
{"BPF_X", Const, 0},
{"BRKINT", Const, 0},
{"Bind", Func, 0},
{"BindToDevice", Func, 0},
{"BpfBuflen", Func, 0},
{"BpfDatalink", Func, 0},
{"BpfHdr", Type, 0},
{"BpfHdr.Caplen", Field, 0},
{"BpfHdr.Datalen", Field, 0},
{"BpfHdr.Hdrlen", Field, 0},
{"BpfHdr.Pad_cgo_0", Field, 0},
{"BpfHdr.Tstamp", Field, 0},
{"BpfHeadercmpl", Func, 0},
{"BpfInsn", Type, 0},
{"BpfInsn.Code", Field, 0},
{"BpfInsn.Jf", Field, 0},
{"BpfInsn.Jt", Field, 0},
{"BpfInsn.K", Field, 0},
{"BpfInterface", Func, 0},
{"BpfJump", Func, 0},
{"BpfProgram", Type, 0},
{"BpfProgram.Insns", Field, 0},
{"BpfProgram.Len", Field, 0},
{"BpfProgram.Pad_cgo_0", Field, 0},
{"BpfStat", Type, 0},
{"BpfStat.Capt", Field, 2},
{"BpfStat.Drop", Field, 0},
{"BpfStat.Padding", Field, 2},
{"BpfStat.Recv", Field, 0},
{"BpfStats", Func, 0},
{"BpfStmt", Func, 0},
{"BpfTimeout", Func, 0},
{"BpfTimeval", Type, 2},
{"BpfTimeval.Sec", Field, 2},
{"BpfTimeval.Usec", Field, 2},
{"BpfVersion", Type, 0},
{"BpfVersion.Major", Field, 0},
{"BpfVersion.Minor", Field, 0},
{"BpfZbuf", Type, 0},
{"BpfZbuf.Bufa", Field, 0},
{"BpfZbuf.Bufb", Field, 0},
{"BpfZbuf.Buflen", Field, 0},
{"BpfZbufHeader", Type, 0},
{"BpfZbufHeader.Kernel_gen", Field, 0},
{"BpfZbufHeader.Kernel_len", Field, 0},
{"BpfZbufHeader.User_gen", Field, 0},
{"BpfZbufHeader.X_bzh_pad", Field, 0},
{"ByHandleFileInformation", Type, 0},
{"ByHandleFileInformation.CreationTime", Field, 0},
{"ByHandleFileInformation.FileAttributes", Field, 0},
{"ByHandleFileInformation.FileIndexHigh", Field, 0},
{"ByHandleFileInformation.FileIndexLow", Field, 0},
{"ByHandleFileInformation.FileSizeHigh", Field, 0},
{"ByHandleFileInformation.FileSizeLow", Field, 0},
{"ByHandleFileInformation.LastAccessTime", Field, 0},
{"ByHandleFileInformation.LastWriteTime", Field, 0},
{"ByHandleFileInformation.NumberOfLinks", Field, 0},
{"ByHandleFileInformation.VolumeSerialNumber", Field, 0},
{"BytePtrFromString", Func, 1},
{"ByteSliceFromString", Func, 1},
{"CCR0_FLUSH", Const, 1},
{"CERT_CHAIN_POLICY_AUTHENTICODE", Const, 0},
{"CERT_CHAIN_POLICY_AUTHENTICODE_TS", Const, 0},
{"CERT_CHAIN_POLICY_BASE", Const, 0},
{"CERT_CHAIN_POLICY_BASIC_CONSTRAINTS", Const, 0},
{"CERT_CHAIN_POLICY_EV", Const, 0},
{"CERT_CHAIN_POLICY_MICROSOFT_ROOT", Const, 0},
{"CERT_CHAIN_POLICY_NT_AUTH", Const, 0},
{"CERT_CHAIN_POLICY_SSL", Const, 0},
{"CERT_E_CN_NO_MATCH", Const, 0},
{"CERT_E_EXPIRED", Const, 0},
{"CERT_E_PURPOSE", Const, 0},
{"CERT_E_ROLE", Const, 0},
{"CERT_E_UNTRUSTEDROOT", Const, 0},
{"CERT_STORE_ADD_ALWAYS", Const, 0},
{"CERT_STORE_DEFER_CLOSE_UNTIL_LAST_FREE_FLAG", Const, 0},
{"CERT_STORE_PROV_MEMORY", Const, 0},
{"CERT_TRUST_HAS_EXCLUDED_NAME_CONSTRAINT", Const, 0},
{"CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT", Const, 0},
{"CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT", Const, 0},
{"CERT_TRUST_HAS_NOT_SUPPORTED_CRITICAL_EXT", Const, 0},
{"CERT_TRUST_HAS_NOT_SUPPORTED_NAME_CONSTRAINT", Const, 0},
{"CERT_TRUST_INVALID_BASIC_CONSTRAINTS", Const, 0},
{"CERT_TRUST_INVALID_EXTENSION", Const, 0},
{"CERT_TRUST_INVALID_NAME_CONSTRAINTS", Const, 0},
{"CERT_TRUST_INVALID_POLICY_CONSTRAINTS", Const, 0},
{"CERT_TRUST_IS_CYCLIC", Const, 0},
{"CERT_TRUST_IS_EXPLICIT_DISTRUST", Const, 0},
{"CERT_TRUST_IS_NOT_SIGNATURE_VALID", Const, 0},
{"CERT_TRUST_IS_NOT_TIME_VALID", Const, 0},
{"CERT_TRUST_IS_NOT_VALID_FOR_USAGE", Const, 0},
{"CERT_TRUST_IS_OFFLINE_REVOCATION", Const, 0},
{"CERT_TRUST_IS_REVOKED", Const, 0},
{"CERT_TRUST_IS_UNTRUSTED_ROOT", Const, 0},
{"CERT_TRUST_NO_ERROR", Const, 0},
{"CERT_TRUST_NO_ISSUANCE_CHAIN_POLICY", Const, 0},
{"CERT_TRUST_REVOCATION_STATUS_UNKNOWN", Const, 0},
{"CFLUSH", Const, 1},
{"CLOCAL", Const, 0},
{"CLONE_CHILD_CLEARTID", Const, 2},
{"CLONE_CHILD_SETTID", Const, 2},
{"CLONE_CLEAR_SIGHAND", Const, 20},
{"CLONE_CSIGNAL", Const, 3},
{"CLONE_DETACHED", Const, 2},
{"CLONE_FILES", Const, 2},
{"CLONE_FS", Const, 2},
{"CLONE_INTO_CGROUP", Const, 20},
{"CLONE_IO", Const, 2},
{"CLONE_NEWCGROUP", Const, 20},
{"CLONE_NEWIPC", Const, 2},
{"CLONE_NEWNET", Const, 2},
{"CLONE_NEWNS", Const, 2},
{"CLONE_NEWPID", Const, 2},
{"CLONE_NEWTIME", Const, 20},
{"CLONE_NEWUSER", Const, 2},
{"CLONE_NEWUTS", Const, 2},
{"CLONE_PARENT", Const, 2},
{"CLONE_PARENT_SETTID", Const, 2},
{"CLONE_PID", Const, 3},
{"CLONE_PIDFD", Const, 20},
{"CLONE_PTRACE", Const, 2},
{"CLONE_SETTLS", Const, 2},
{"CLONE_SIGHAND", Const, 2},
{"CLONE_SYSVSEM", Const, 2},
{"CLONE_THREAD", Const, 2},
{"CLONE_UNTRACED", Const, 2},
{"CLONE_VFORK", Const, 2},
{"CLONE_VM", Const, 2},
{"CPUID_CFLUSH", Const, 1},
{"CREAD", Const, 0},
{"CREATE_ALWAYS", Const, 0},
{"CREATE_NEW", Const, 0},
{"CREATE_NEW_PROCESS_GROUP", Const, 1},
{"CREATE_UNICODE_ENVIRONMENT", Const, 0},
{"CRYPT_DEFAULT_CONTAINER_OPTIONAL", Const, 0},
{"CRYPT_DELETEKEYSET", Const, 0},
{"CRYPT_MACHINE_KEYSET", Const, 0},
{"CRYPT_NEWKEYSET", Const, 0},
{"CRYPT_SILENT", Const, 0},
{"CRYPT_VERIFYCONTEXT", Const, 0},
{"CS5", Const, 0},
{"CS6", Const, 0},
{"CS7", Const, 0},
{"CS8", Const, 0},
{"CSIZE", Const, 0},
{"CSTART", Const, 1},
{"CSTATUS", Const, 1},
{"CSTOP", Const, 1},
{"CSTOPB", Const, 0},
{"CSUSP", Const, 1},
{"CTL_MAXNAME", Const, 0},
{"CTL_NET", Const, 0},
{"CTL_QUERY", Const, 1},
{"CTRL_BREAK_EVENT", Const, 1},
{"CTRL_CLOSE_EVENT", Const, 14},
{"CTRL_C_EVENT", Const, 1},
{"CTRL_LOGOFF_EVENT", Const, 14},
{"CTRL_SHUTDOWN_EVENT", Const, 14},
{"CancelIo", Func, 0},
{"CancelIoEx", Func, 1},
{"CertAddCertificateContextToStore", Func, 0},
{"CertChainContext", Type, 0},
{"CertChainContext.ChainCount", Field, 0},
{"CertChainContext.Chains", Field, 0},
{"CertChainContext.HasRevocationFreshnessTime", Field, 0},
{"CertChainContext.LowerQualityChainCount", Field, 0},
{"CertChainContext.LowerQualityChains", Field, 0},
{"CertChainContext.RevocationFreshnessTime", Field, 0},
{"CertChainContext.Size", Field, 0},
{"CertChainContext.TrustStatus", Field, 0},
{"CertChainElement", Type, 0},
{"CertChainElement.ApplicationUsage", Field, 0},
{"CertChainElement.CertContext", Field, 0},
{"CertChainElement.ExtendedErrorInfo", Field, 0},
{"CertChainElement.IssuanceUsage", Field, 0},
{"CertChainElement.RevocationInfo", Field, 0},
{"CertChainElement.Size", Field, 0},
{"CertChainElement.TrustStatus", Field, 0},
{"CertChainPara", Type, 0},
{"CertChainPara.CacheResync", Field, 0},
{"CertChainPara.CheckRevocationFreshnessTime", Field, 0},
{"CertChainPara.RequestedUsage", Field, 0},
{"CertChainPara.RequstedIssuancePolicy", Field, 0},
{"CertChainPara.RevocationFreshnessTime", Field, 0},
{"CertChainPara.Size", Field, 0},
{"CertChainPara.URLRetrievalTimeout", Field, 0},
{"CertChainPolicyPara", Type, 0},
{"CertChainPolicyPara.ExtraPolicyPara", Field, 0},
{"CertChainPolicyPara.Flags", Field, 0},
{"CertChainPolicyPara.Size", Field, 0},
{"CertChainPolicyStatus", Type, 0},
{"CertChainPolicyStatus.ChainIndex", Field, 0},
{"CertChainPolicyStatus.ElementIndex", Field, 0},
{"CertChainPolicyStatus.Error", Field, 0},
{"CertChainPolicyStatus.ExtraPolicyStatus", Field, 0},
{"CertChainPolicyStatus.Size", Field, 0},
{"CertCloseStore", Func, 0},
{"CertContext", Type, 0},
{"CertContext.CertInfo", Field, 0},
{"CertContext.EncodedCert", Field, 0},
{"CertContext.EncodingType", Field, 0},
{"CertContext.Length", Field, 0},
{"CertContext.Store", Field, 0},
{"CertCreateCertificateContext", Func, 0},
{"CertEnhKeyUsage", Type, 0},
{"CertEnhKeyUsage.Length", Field, 0},
{"CertEnhKeyUsage.UsageIdentifiers", Field, 0},
{"CertEnumCertificatesInStore", Func, 0},
{"CertFreeCertificateChain", Func, 0},
{"CertFreeCertificateContext", Func, 0},
{"CertGetCertificateChain", Func, 0},
{"CertInfo", Type, 11},
{"CertOpenStore", Func, 0},
{"CertOpenSystemStore", Func, 0},
{"CertRevocationCrlInfo", Type, 11},
{"CertRevocationInfo", Type, 0},
{"CertRevocationInfo.CrlInfo", Field, 0},
{"CertRevocationInfo.FreshnessTime", Field, 0},
{"CertRevocationInfo.HasFreshnessTime", Field, 0},
{"CertRevocationInfo.OidSpecificInfo", Field, 0},
{"CertRevocationInfo.RevocationOid", Field, 0},
{"CertRevocationInfo.RevocationResult", Field, 0},
{"CertRevocationInfo.Size", Field, 0},
{"CertSimpleChain", Type, 0},
{"CertSimpleChain.Elements", Field, 0},
{"CertSimpleChain.HasRevocationFreshnessTime", Field, 0},
{"CertSimpleChain.NumElements", Field, 0},
{"CertSimpleChain.RevocationFreshnessTime", Field, 0},
{"CertSimpleChain.Size", Field, 0},
{"CertSimpleChain.TrustListInfo", Field, 0},
{"CertSimpleChain.TrustStatus", Field, 0},
{"CertTrustListInfo", Type, 11},
{"CertTrustStatus", Type, 0},
{"CertTrustStatus.ErrorStatus", Field, 0},
{"CertTrustStatus.InfoStatus", Field, 0},
{"CertUsageMatch", Type, 0},
{"CertUsageMatch.Type", Field, 0},
{"CertUsageMatch.Usage", Field, 0},
{"CertVerifyCertificateChainPolicy", Func, 0},
{"Chdir", Func, 0},
{"CheckBpfVersion", Func, 0},
{"Chflags", Func, 0},
{"Chmod", Func, 0},
{"Chown", Func, 0},
{"Chroot", Func, 0},
{"Clearenv", Func, 0},
{"Close", Func, 0},
{"CloseHandle", Func, 0},
{"CloseOnExec", Func, 0},
{"Closesocket", Func, 0},
{"CmsgLen", Func, 0},
{"CmsgSpace", Func, 0},
{"Cmsghdr", Type, 0},
{"Cmsghdr.Len", Field, 0},
{"Cmsghdr.Level", Field, 0},
{"Cmsghdr.Type", Field, 0},
{"Cmsghdr.X__cmsg_data", Field, 0},
{"CommandLineToArgv", Func, 0},
{"ComputerName", Func, 0},
{"Conn", Type, 9},
{"Connect", Func, 0},
{"ConnectEx", Func, 1},
{"ConvertSidToStringSid", Func, 0},
{"ConvertStringSidToSid", Func, 0},
{"CopySid", Func, 0},
{"Creat", Func, 0},
{"CreateDirectory", Func, 0},
{"CreateFile", Func, 0},
{"CreateFileMapping", Func, 0},
{"CreateHardLink", Func, 4},
{"CreateIoCompletionPort", Func, 0},
{"CreatePipe", Func, 0},
{"CreateProcess", Func, 0},
{"CreateProcessAsUser", Func, 10},
{"CreateSymbolicLink", Func, 4},
{"CreateToolhelp32Snapshot", Func, 4},
{"Credential", Type, 0},
{"Credential.Gid", Field, 0},
{"Credential.Groups", Field, 0},
{"Credential.NoSetGroups", Field, 9},
{"Credential.Uid", Field, 0},
{"CryptAcquireContext", Func, 0},
{"CryptGenRandom", Func, 0},
{"CryptReleaseContext", Func, 0},
{"DIOCBSFLUSH", Const, 1},
{"DIOCOSFPFLUSH", Const, 1},
{"DLL", Type, 0},
{"DLL.Handle", Field, 0},
{"DLL.Name", Field, 0},
{"DLLError", Type, 0},
{"DLLError.Err", Field, 0},
{"DLLError.Msg", Field, 0},
{"DLLError.ObjName", Field, 0},
{"DLT_A429", Const, 0},
{"DLT_A653_ICM", Const, 0},
{"DLT_AIRONET_HEADER", Const, 0},
{"DLT_AOS", Const, 1},
{"DLT_APPLE_IP_OVER_IEEE1394", Const, 0},
{"DLT_ARCNET", Const, 0},
{"DLT_ARCNET_LINUX", Const, 0},
{"DLT_ATM_CLIP", Const, 0},
{"DLT_ATM_RFC1483", Const, 0},
{"DLT_AURORA", Const, 0},
{"DLT_AX25", Const, 0},
{"DLT_AX25_KISS", Const, 0},
{"DLT_BACNET_MS_TP", Const, 0},
{"DLT_BLUETOOTH_HCI_H4", Const, 0},
{"DLT_BLUETOOTH_HCI_H4_WITH_PHDR", Const, 0},
{"DLT_CAN20B", Const, 0},
{"DLT_CAN_SOCKETCAN", Const, 1},
{"DLT_CHAOS", Const, 0},
{"DLT_CHDLC", Const, 0},
{"DLT_CISCO_IOS", Const, 0},
{"DLT_C_HDLC", Const, 0},
{"DLT_C_HDLC_WITH_DIR", Const, 0},
{"DLT_DBUS", Const, 1},
{"DLT_DECT", Const, 1},
{"DLT_DOCSIS", Const, 0},
{"DLT_DVB_CI", Const, 1},
{"DLT_ECONET", Const, 0},
{"DLT_EN10MB", Const, 0},
{"DLT_EN3MB", Const, 0},
{"DLT_ENC", Const, 0},
{"DLT_ERF", Const, 0},
{"DLT_ERF_ETH", Const, 0},
{"DLT_ERF_POS", Const, 0},
{"DLT_FC_2", Const, 1},
{"DLT_FC_2_WITH_FRAME_DELIMS", Const, 1},
{"DLT_FDDI", Const, 0},
{"DLT_FLEXRAY", Const, 0},
{"DLT_FRELAY", Const, 0},
{"DLT_FRELAY_WITH_DIR", Const, 0},
{"DLT_GCOM_SERIAL", Const, 0},
{"DLT_GCOM_T1E1", Const, 0},
{"DLT_GPF_F", Const, 0},
{"DLT_GPF_T", Const, 0},
{"DLT_GPRS_LLC", Const, 0},
{"DLT_GSMTAP_ABIS", Const, 1},
{"DLT_GSMTAP_UM", Const, 1},
{"DLT_HDLC", Const, 1},
{"DLT_HHDLC", Const, 0},
{"DLT_HIPPI", Const, 1},
{"DLT_IBM_SN", Const, 0},
{"DLT_IBM_SP", Const, 0},
{"DLT_IEEE802", Const, 0},
{"DLT_IEEE802_11", Const, 0},
{"DLT_IEEE802_11_RADIO", Const, 0},
{"DLT_IEEE802_11_RADIO_AVS", Const, 0},
{"DLT_IEEE802_15_4", Const, 0},
{"DLT_IEEE802_15_4_LINUX", Const, 0},
{"DLT_IEEE802_15_4_NOFCS", Const, 1},
{"DLT_IEEE802_15_4_NONASK_PHY", Const, 0},
{"DLT_IEEE802_16_MAC_CPS", Const, 0},
{"DLT_IEEE802_16_MAC_CPS_RADIO", Const, 0},
{"DLT_IPFILTER", Const, 0},
{"DLT_IPMB", Const, 0},
{"DLT_IPMB_LINUX", Const, 0},
{"DLT_IPNET", Const, 1},
{"DLT_IPOIB", Const, 1},
{"DLT_IPV4", Const, 1},
{"DLT_IPV6", Const, 1},
{"DLT_IP_OVER_FC", Const, 0},
{"DLT_JUNIPER_ATM1", Const, 0},
{"DLT_JUNIPER_ATM2", Const, 0},
{"DLT_JUNIPER_ATM_CEMIC", Const, 1},
{"DLT_JUNIPER_CHDLC", Const, 0},
{"DLT_JUNIPER_ES", Const, 0},
{"DLT_JUNIPER_ETHER", Const, 0},
{"DLT_JUNIPER_FIBRECHANNEL", Const, 1},
{"DLT_JUNIPER_FRELAY", Const, 0},
{"DLT_JUNIPER_GGSN", Const, 0},
{"DLT_JUNIPER_ISM", Const, 0},
{"DLT_JUNIPER_MFR", Const, 0},
{"DLT_JUNIPER_MLFR", Const, 0},
{"DLT_JUNIPER_MLPPP", Const, 0},
{"DLT_JUNIPER_MONITOR", Const, 0},
{"DLT_JUNIPER_PIC_PEER", Const, 0},
{"DLT_JUNIPER_PPP", Const, 0},
{"DLT_JUNIPER_PPPOE", Const, 0},
{"DLT_JUNIPER_PPPOE_ATM", Const, 0},
{"DLT_JUNIPER_SERVICES", Const, 0},
{"DLT_JUNIPER_SRX_E2E", Const, 1},
{"DLT_JUNIPER_ST", Const, 0},
{"DLT_JUNIPER_VP", Const, 0},
{"DLT_JUNIPER_VS", Const, 1},
{"DLT_LAPB_WITH_DIR", Const, 0},
{"DLT_LAPD", Const, 0},
{"DLT_LIN", Const, 0},
{"DLT_LINUX_EVDEV", Const, 1},
{"DLT_LINUX_IRDA", Const, 0},
{"DLT_LINUX_LAPD", Const, 0},
{"DLT_LINUX_PPP_WITHDIRECTION", Const, 0},
{"DLT_LINUX_SLL", Const, 0},
{"DLT_LOOP", Const, 0},
{"DLT_LTALK", Const, 0},
{"DLT_MATCHING_MAX", Const, 1},
{"DLT_MATCHING_MIN", Const, 1},
{"DLT_MFR", Const, 0},
{"DLT_MOST", Const, 0},
{"DLT_MPEG_2_TS", Const, 1},
{"DLT_MPLS", Const, 1},
{"DLT_MTP2", Const, 0},
{"DLT_MTP2_WITH_PHDR", Const, 0},
{"DLT_MTP3", Const, 0},
{"DLT_MUX27010", Const, 1},
{"DLT_NETANALYZER", Const, 1},
{"DLT_NETANALYZER_TRANSPARENT", Const, 1},
{"DLT_NFC_LLCP", Const, 1},
{"DLT_NFLOG", Const, 1},
{"DLT_NG40", Const, 1},
{"DLT_NULL", Const, 0},
{"DLT_PCI_EXP", Const, 0},
{"DLT_PFLOG", Const, 0},
{"DLT_PFSYNC", Const, 0},
{"DLT_PPI", Const, 0},
{"DLT_PPP", Const, 0},
{"DLT_PPP_BSDOS", Const, 0},
{"DLT_PPP_ETHER", Const, 0},
{"DLT_PPP_PPPD", Const, 0},
{"DLT_PPP_SERIAL", Const, 0},
{"DLT_PPP_WITH_DIR", Const, 0},
{"DLT_PPP_WITH_DIRECTION", Const, 0},
{"DLT_PRISM_HEADER", Const, 0},
{"DLT_PRONET", Const, 0},
{"DLT_RAIF1", Const, 0},
{"DLT_RAW", Const, 0},
{"DLT_RAWAF_MASK", Const, 1},
{"DLT_RIO", Const, 0},
{"DLT_SCCP", Const, 0},
{"DLT_SITA", Const, 0},
{"DLT_SLIP", Const, 0},
{"DLT_SLIP_BSDOS", Const, 0},
{"DLT_STANAG_5066_D_PDU", Const, 1},
{"DLT_SUNATM", Const, 0},
{"DLT_SYMANTEC_FIREWALL", Const, 0},
{"DLT_TZSP", Const, 0},
{"DLT_USB", Const, 0},
{"DLT_USB_LINUX", Const, 0},
{"DLT_USB_LINUX_MMAPPED", Const, 1},
{"DLT_USER0", Const, 0},
{"DLT_USER1", Const, 0},
{"DLT_USER10", Const, 0},
{"DLT_USER11", Const, 0},
{"DLT_USER12", Const, 0},
{"DLT_USER13", Const, 0},
{"DLT_USER14", Const, 0},
{"DLT_USER15", Const, 0},
{"DLT_USER2", Const, 0},
{"DLT_USER3", Const, 0},
{"DLT_USER4", Const, 0},
{"DLT_USER5", Const, 0},
{"DLT_USER6", Const, 0},
{"DLT_USER7", Const, 0},
{"DLT_USER8", Const, 0},
{"DLT_USER9", Const, 0},
{"DLT_WIHART", Const, 1},
{"DLT_X2E_SERIAL", Const, 0},
{"DLT_X2E_XORAYA", Const, 0},
{"DNSMXData", Type, 0},
{"DNSMXData.NameExchange", Field, 0},
{"DNSMXData.Pad", Field, 0},
{"DNSMXData.Preference", Field, 0},
{"DNSPTRData", Type, 0},
{"DNSPTRData.Host", Field, 0},
{"DNSRecord", Type, 0},
{"DNSRecord.Data", Field, 0},
{"DNSRecord.Dw", Field, 0},
{"DNSRecord.Length", Field, 0},
{"DNSRecord.Name", Field, 0},
{"DNSRecord.Next", Field, 0},
{"DNSRecord.Reserved", Field, 0},
{"DNSRecord.Ttl", Field, 0},
{"DNSRecord.Type", Field, 0},
{"DNSSRVData", Type, 0},
{"DNSSRVData.Pad", Field, 0},
{"DNSSRVData.Port", Field, 0},
{"DNSSRVData.Priority", Field, 0},
{"DNSSRVData.Target", Field, 0},
{"DNSSRVData.Weight", Field, 0},
{"DNSTXTData", Type, 0},
{"DNSTXTData.StringArray", Field, 0},
{"DNSTXTData.StringCount", Field, 0},
{"DNS_INFO_NO_RECORDS", Const, 4},
{"DNS_TYPE_A", Const, 0},
{"DNS_TYPE_A6", Const, 0},
{"DNS_TYPE_AAAA", Const, 0},
{"DNS_TYPE_ADDRS", Const, 0},
{"DNS_TYPE_AFSDB", Const, 0},
{"DNS_TYPE_ALL", Const, 0},
{"DNS_TYPE_ANY", Const, 0},
{"DNS_TYPE_ATMA", Const, 0},
{"DNS_TYPE_AXFR", Const, 0},
{"DNS_TYPE_CERT", Const, 0},
{"DNS_TYPE_CNAME", Const, 0},
{"DNS_TYPE_DHCID", Const, 0},
{"DNS_TYPE_DNAME", Const, 0},
{"DNS_TYPE_DNSKEY", Const, 0},
{"DNS_TYPE_DS", Const, 0},
{"DNS_TYPE_EID", Const, 0},
{"DNS_TYPE_GID", Const, 0},
{"DNS_TYPE_GPOS", Const, 0},
{"DNS_TYPE_HINFO", Const, 0},
{"DNS_TYPE_ISDN", Const, 0},
{"DNS_TYPE_IXFR", Const, 0},
{"DNS_TYPE_KEY", Const, 0},
{"DNS_TYPE_KX", Const, 0},
{"DNS_TYPE_LOC", Const, 0},
{"DNS_TYPE_MAILA", Const, 0},
{"DNS_TYPE_MAILB", Const, 0},
{"DNS_TYPE_MB", Const, 0},
{"DNS_TYPE_MD", Const, 0},
{"DNS_TYPE_MF", Const, 0},
{"DNS_TYPE_MG", Const, 0},
{"DNS_TYPE_MINFO", Const, 0},
{"DNS_TYPE_MR", Const, 0},
{"DNS_TYPE_MX", Const, 0},
{"DNS_TYPE_NAPTR", Const, 0},
{"DNS_TYPE_NBSTAT", Const, 0},
{"DNS_TYPE_NIMLOC", Const, 0},
{"DNS_TYPE_NS", Const, 0},
{"DNS_TYPE_NSAP", Const, 0},
{"DNS_TYPE_NSAPPTR", Const, 0},
{"DNS_TYPE_NSEC", Const, 0},
{"DNS_TYPE_NULL", Const, 0},
{"DNS_TYPE_NXT", Const, 0},
{"DNS_TYPE_OPT", Const, 0},
{"DNS_TYPE_PTR", Const, 0},
{"DNS_TYPE_PX", Const, 0},
{"DNS_TYPE_RP", Const, 0},
{"DNS_TYPE_RRSIG", Const, 0},
{"DNS_TYPE_RT", Const, 0},
{"DNS_TYPE_SIG", Const, 0},
{"DNS_TYPE_SINK", Const, 0},
{"DNS_TYPE_SOA", Const, 0},
{"DNS_TYPE_SRV", Const, 0},
{"DNS_TYPE_TEXT", Const, 0},
{"DNS_TYPE_TKEY", Const, 0},
{"DNS_TYPE_TSIG", Const, 0},
{"DNS_TYPE_UID", Const, 0},
{"DNS_TYPE_UINFO", Const, 0},
{"DNS_TYPE_UNSPEC", Const, 0},
{"DNS_TYPE_WINS", Const, 0},
{"DNS_TYPE_WINSR", Const, 0},
{"DNS_TYPE_WKS", Const, 0},
{"DNS_TYPE_X25", Const, 0},
{"DT_BLK", Const, 0},
{"DT_CHR", Const, 0},
{"DT_DIR", Const, 0},
{"DT_FIFO", Const, 0},
{"DT_LNK", Const, 0},
{"DT_REG", Const, 0},
{"DT_SOCK", Const, 0},
{"DT_UNKNOWN", Const, 0},
{"DT_WHT", Const, 0},
{"DUPLICATE_CLOSE_SOURCE", Const, 0},
{"DUPLICATE_SAME_ACCESS", Const, 0},
{"DeleteFile", Func, 0},
{"DetachLsf", Func, 0},
{"DeviceIoControl", Func, 4},
{"Dirent", Type, 0},
{"Dirent.Fileno", Field, 0},
{"Dirent.Ino", Field, 0},
{"Dirent.Name", Field, 0},
{"Dirent.Namlen", Field, 0},
{"Dirent.Off", Field, 0},
{"Dirent.Pad0", Field, 12},
{"Dirent.Pad1", Field, 12},
{"Dirent.Pad_cgo_0", Field, 0},
{"Dirent.Reclen", Field, 0},
{"Dirent.Seekoff", Field, 0},
{"Dirent.Type", Field, 0},
{"Dirent.X__d_padding", Field, 3},
{"DnsNameCompare", Func, 4},
{"DnsQuery", Func, 0},
{"DnsRecordListFree", Func, 0},
{"DnsSectionAdditional", Const, 4},
{"DnsSectionAnswer", Const, 4},
{"DnsSectionAuthority", Const, 4},
{"DnsSectionQuestion", Const, 4},
{"Dup", Func, 0},
{"Dup2", Func, 0},
{"Dup3", Func, 2},
{"DuplicateHandle", Func, 0},
{"E2BIG", Const, 0},
{"EACCES", Const, 0},
{"EADDRINUSE", Const, 0},
{"EADDRNOTAVAIL", Const, 0},
{"EADV", Const, 0},
{"EAFNOSUPPORT", Const, 0},
{"EAGAIN", Const, 0},
{"EALREADY", Const, 0},
{"EAUTH", Const, 0},
{"EBADARCH", Const, 0},
{"EBADE", Const, 0},
{"EBADEXEC", Const, 0},
{"EBADF", Const, 0},
{"EBADFD", Const, 0},
{"EBADMACHO", Const, 0},
{"EBADMSG", Const, 0},
{"EBADR", Const, 0},
{"EBADRPC", Const, 0},
{"EBADRQC", Const, 0},
{"EBADSLT", Const, 0},
{"EBFONT", Const, 0},
{"EBUSY", Const, 0},
{"ECANCELED", Const, 0},
{"ECAPMODE", Const, 1},
{"ECHILD", Const, 0},
{"ECHO", Const, 0},
{"ECHOCTL", Const, 0},
{"ECHOE", Const, 0},
{"ECHOK", Const, 0},
{"ECHOKE", Const, 0},
{"ECHONL", Const, 0},
{"ECHOPRT", Const, 0},
{"ECHRNG", Const, 0},
{"ECOMM", Const, 0},
{"ECONNABORTED", Const, 0},
{"ECONNREFUSED", Const, 0},
{"ECONNRESET", Const, 0},
{"EDEADLK", Const, 0},
{"EDEADLOCK", Const, 0},
{"EDESTADDRREQ", Const, 0},
{"EDEVERR", Const, 0},
{"EDOM", Const, 0},
{"EDOOFUS", Const, 0},
{"EDOTDOT", Const, 0},
{"EDQUOT", Const, 0},
{"EEXIST", Const, 0},
{"EFAULT", Const, 0},
{"EFBIG", Const, 0},
{"EFER_LMA", Const, 1},
{"EFER_LME", Const, 1},
{"EFER_NXE", Const, 1},
{"EFER_SCE", Const, 1},
{"EFTYPE", Const, 0},
{"EHOSTDOWN", Const, 0},
{"EHOSTUNREACH", Const, 0},
{"EHWPOISON", Const, 0},
{"EIDRM", Const, 0},
{"EILSEQ", Const, 0},
{"EINPROGRESS", Const, 0},
{"EINTR", Const, 0},
{"EINVAL", Const, 0},
{"EIO", Const, 0},
{"EIPSEC", Const, 1},
{"EISCONN", Const, 0},
{"EISDIR", Const, 0},
{"EISNAM", Const, 0},
{"EKEYEXPIRED", Const, 0},
{"EKEYREJECTED", Const, 0},
{"EKEYREVOKED", Const, 0},
{"EL2HLT", Const, 0},
{"EL2NSYNC", Const, 0},
{"EL3HLT", Const, 0},
{"EL3RST", Const, 0},
{"ELAST", Const, 0},
{"ELF_NGREG", Const, 0},
{"ELF_PRARGSZ", Const, 0},
{"ELIBACC", Const, 0},
{"ELIBBAD", Const, 0},
{"ELIBEXEC", Const, 0},
{"ELIBMAX", Const, 0},
{"ELIBSCN", Const, 0},
{"ELNRNG", Const, 0},
{"ELOOP", Const, 0},
{"EMEDIUMTYPE", Const, 0},
{"EMFILE", Const, 0},
{"EMLINK", Const, 0},
{"EMSGSIZE", Const, 0},
{"EMT_TAGOVF", Const, 1},
{"EMULTIHOP", Const, 0},
{"EMUL_ENABLED", Const, 1},
{"EMUL_LINUX", Const, 1},
{"EMUL_LINUX32", Const, 1},
{"EMUL_MAXID", Const, 1},
{"EMUL_NATIVE", Const, 1},
{"ENAMETOOLONG", Const, 0},
{"ENAVAIL", Const, 0},
{"ENDRUNDISC", Const, 1},
{"ENEEDAUTH", Const, 0},
{"ENETDOWN", Const, 0},
{"ENETRESET", Const, 0},
{"ENETUNREACH", Const, 0},
{"ENFILE", Const, 0},
{"ENOANO", Const, 0},
{"ENOATTR", Const, 0},
{"ENOBUFS", Const, 0},
{"ENOCSI", Const, 0},
{"ENODATA", Const, 0},
{"ENODEV", Const, 0},
{"ENOENT", Const, 0},
{"ENOEXEC", Const, 0},
{"ENOKEY", Const, 0},
{"ENOLCK", Const, 0},
{"ENOLINK", Const, 0},
{"ENOMEDIUM", Const, 0},
{"ENOMEM", Const, 0},
{"ENOMSG", Const, 0},
{"ENONET", Const, 0},
{"ENOPKG", Const, 0},
{"ENOPOLICY", Const, 0},
{"ENOPROTOOPT", Const, 0},
{"ENOSPC", Const, 0},
{"ENOSR", Const, 0},
{"ENOSTR", Const, 0},
{"ENOSYS", Const, 0},
{"ENOTBLK", Const, 0},
{"ENOTCAPABLE", Const, 0},
{"ENOTCONN", Const, 0},
{"ENOTDIR", Const, 0},
{"ENOTEMPTY", Const, 0},
{"ENOTNAM", Const, 0},
{"ENOTRECOVERABLE", Const, 0},
{"ENOTSOCK", Const, 0},
{"ENOTSUP", Const, 0},
{"ENOTTY", Const, 0},
{"ENOTUNIQ", Const, 0},
{"ENXIO", Const, 0},
{"EN_SW_CTL_INF", Const, 1},
{"EN_SW_CTL_PREC", Const, 1},
{"EN_SW_CTL_ROUND", Const, 1},
{"EN_SW_DATACHAIN", Const, 1},
{"EN_SW_DENORM", Const, 1},
{"EN_SW_INVOP", Const, 1},
{"EN_SW_OVERFLOW", Const, 1},
{"EN_SW_PRECLOSS", Const, 1},
{"EN_SW_UNDERFLOW", Const, 1},
{"EN_SW_ZERODIV", Const, 1},
{"EOPNOTSUPP", Const, 0},
{"EOVERFLOW", Const, 0},
{"EOWNERDEAD", Const, 0},
{"EPERM", Const, 0},
{"EPFNOSUPPORT", Const, 0},
{"EPIPE", Const, 0},
{"EPOLLERR", Const, 0},
{"EPOLLET", Const, 0},
{"EPOLLHUP", Const, 0},
{"EPOLLIN", Const, 0},
{"EPOLLMSG", Const, 0},
{"EPOLLONESHOT", Const, 0},
{"EPOLLOUT", Const, 0},
{"EPOLLPRI", Const, 0},
{"EPOLLRDBAND", Const, 0},
{"EPOLLRDHUP", Const, 0},
{"EPOLLRDNORM", Const, 0},
{"EPOLLWRBAND", Const, 0},
{"EPOLLWRNORM", Const, 0},
{"EPOLL_CLOEXEC", Const, 0},
{"EPOLL_CTL_ADD", Const, 0},
{"EPOLL_CTL_DEL", Const, 0},
{"EPOLL_CTL_MOD", Const, 0},
{"EPOLL_NONBLOCK", Const, 0},
{"EPROCLIM", Const, 0},
{"EPROCUNAVAIL", Const, 0},
{"EPROGMISMATCH", Const, 0},
{"EPROGUNAVAIL", Const, 0},
{"EPROTO", Const, 0},
{"EPROTONOSUPPORT", Const, 0},
{"EPROTOTYPE", Const, 0},
{"EPWROFF", Const, 0},
{"EQFULL", Const, 16},
{"ERANGE", Const, 0},
{"EREMCHG", Const, 0},
{"EREMOTE", Const, 0},
{"EREMOTEIO", Const, 0},
{"ERESTART", Const, 0},
{"ERFKILL", Const, 0},
{"EROFS", Const, 0},
{"ERPCMISMATCH", Const, 0},
{"ERROR_ACCESS_DENIED", Const, 0},
{"ERROR_ALREADY_EXISTS", Const, 0},
{"ERROR_BROKEN_PIPE", Const, 0},
{"ERROR_BUFFER_OVERFLOW", Const, 0},
{"ERROR_DIR_NOT_EMPTY", Const, 8},
{"ERROR_ENVVAR_NOT_FOUND", Const, 0},
{"ERROR_FILE_EXISTS", Const, 0},
{"ERROR_FILE_NOT_FOUND", Const, 0},
{"ERROR_HANDLE_EOF", Const, 2},
{"ERROR_INSUFFICIENT_BUFFER", Const, 0},
{"ERROR_IO_PENDING", Const, 0},
{"ERROR_MOD_NOT_FOUND", Const, 0},
{"ERROR_MORE_DATA", Const, 3},
{"ERROR_NETNAME_DELETED", Const, 3},
{"ERROR_NOT_FOUND", Const, 1},
{"ERROR_NO_MORE_FILES", Const, 0},
{"ERROR_OPERATION_ABORTED", Const, 0},
{"ERROR_PATH_NOT_FOUND", Const, 0},
{"ERROR_PRIVILEGE_NOT_HELD", Const, 4},
{"ERROR_PROC_NOT_FOUND", Const, 0},
{"ESHLIBVERS", Const, 0},
{"ESHUTDOWN", Const, 0},
{"ESOCKTNOSUPPORT", Const, 0},
{"ESPIPE", Const, 0},
{"ESRCH", Const, 0},
{"ESRMNT", Const, 0},
{"ESTALE", Const, 0},
{"ESTRPIPE", Const, 0},
{"ETHERCAP_JUMBO_MTU", Const, 1},
{"ETHERCAP_VLAN_HWTAGGING", Const, 1},
{"ETHERCAP_VLAN_MTU", Const, 1},
{"ETHERMIN", Const, 1},
{"ETHERMTU", Const, 1},
{"ETHERMTU_JUMBO", Const, 1},
{"ETHERTYPE_8023", Const, 1},
{"ETHERTYPE_AARP", Const, 1},
{"ETHERTYPE_ACCTON", Const, 1},
{"ETHERTYPE_AEONIC", Const, 1},
{"ETHERTYPE_ALPHA", Const, 1},
{"ETHERTYPE_AMBER", Const, 1},
{"ETHERTYPE_AMOEBA", Const, 1},
{"ETHERTYPE_AOE", Const, 1},
{"ETHERTYPE_APOLLO", Const, 1},
{"ETHERTYPE_APOLLODOMAIN", Const, 1},
{"ETHERTYPE_APPLETALK", Const, 1},
{"ETHERTYPE_APPLITEK", Const, 1},
{"ETHERTYPE_ARGONAUT", Const, 1},
{"ETHERTYPE_ARP", Const, 1},
{"ETHERTYPE_AT", Const, 1},
{"ETHERTYPE_ATALK", Const, 1},
{"ETHERTYPE_ATOMIC", Const, 1},
{"ETHERTYPE_ATT", Const, 1},
{"ETHERTYPE_ATTSTANFORD", Const, 1},
{"ETHERTYPE_AUTOPHON", Const, 1},
{"ETHERTYPE_AXIS", Const, 1},
{"ETHERTYPE_BCLOOP", Const, 1},
{"ETHERTYPE_BOFL", Const, 1},
{"ETHERTYPE_CABLETRON", Const, 1},
{"ETHERTYPE_CHAOS", Const, 1},
{"ETHERTYPE_COMDESIGN", Const, 1},
{"ETHERTYPE_COMPUGRAPHIC", Const, 1},
{"ETHERTYPE_COUNTERPOINT", Const, 1},
{"ETHERTYPE_CRONUS", Const, 1},
{"ETHERTYPE_CRONUSVLN", Const, 1},
{"ETHERTYPE_DCA", Const, 1},
{"ETHERTYPE_DDE", Const, 1},
{"ETHERTYPE_DEBNI", Const, 1},
{"ETHERTYPE_DECAM", Const, 1},
{"ETHERTYPE_DECCUST", Const, 1},
{"ETHERTYPE_DECDIAG", Const, 1},
{"ETHERTYPE_DECDNS", Const, 1},
{"ETHERTYPE_DECDTS", Const, 1},
{"ETHERTYPE_DECEXPER", Const, 1},
{"ETHERTYPE_DECLAST", Const, 1},
{"ETHERTYPE_DECLTM", Const, 1},
{"ETHERTYPE_DECMUMPS", Const, 1},
{"ETHERTYPE_DECNETBIOS", Const, 1},
{"ETHERTYPE_DELTACON", Const, 1},
{"ETHERTYPE_DIDDLE", Const, 1},
{"ETHERTYPE_DLOG1", Const, 1},
{"ETHERTYPE_DLOG2", Const, 1},
{"ETHERTYPE_DN", Const, 1},
{"ETHERTYPE_DOGFIGHT", Const, 1},
{"ETHERTYPE_DSMD", Const, 1},
{"ETHERTYPE_ECMA", Const, 1},
{"ETHERTYPE_ENCRYPT", Const, 1},
{"ETHERTYPE_ES", Const, 1},
{"ETHERTYPE_EXCELAN", Const, 1},
{"ETHERTYPE_EXPERDATA", Const, 1},
{"ETHERTYPE_FLIP", Const, 1},
{"ETHERTYPE_FLOWCONTROL", Const, 1},
{"ETHERTYPE_FRARP", Const, 1},
{"ETHERTYPE_GENDYN", Const, 1},
{"ETHERTYPE_HAYES", Const, 1},
{"ETHERTYPE_HIPPI_FP", Const, 1},
{"ETHERTYPE_HITACHI", Const, 1},
{"ETHERTYPE_HP", Const, 1},
{"ETHERTYPE_IEEEPUP", Const, 1},
{"ETHERTYPE_IEEEPUPAT", Const, 1},
{"ETHERTYPE_IMLBL", Const, 1},
{"ETHERTYPE_IMLBLDIAG", Const, 1},
{"ETHERTYPE_IP", Const, 1},
{"ETHERTYPE_IPAS", Const, 1},
{"ETHERTYPE_IPV6", Const, 1},
{"ETHERTYPE_IPX", Const, 1},
{"ETHERTYPE_IPXNEW", Const, 1},
{"ETHERTYPE_KALPANA", Const, 1},
{"ETHERTYPE_LANBRIDGE", Const, 1},
{"ETHERTYPE_LANPROBE", Const, 1},
{"ETHERTYPE_LAT", Const, 1},
{"ETHERTYPE_LBACK", Const, 1},
{"ETHERTYPE_LITTLE", Const, 1},
{"ETHERTYPE_LLDP", Const, 1},
{"ETHERTYPE_LOGICRAFT", Const, 1},
{"ETHERTYPE_LOOPBACK", Const, 1},
{"ETHERTYPE_MATRA", Const, 1},
{"ETHERTYPE_MAX", Const, 1},
{"ETHERTYPE_MERIT", Const, 1},
{"ETHERTYPE_MICP", Const, 1},
{"ETHERTYPE_MOPDL", Const, 1},
{"ETHERTYPE_MOPRC", Const, 1},
{"ETHERTYPE_MOTOROLA", Const, 1},
{"ETHERTYPE_MPLS", Const, 1},
{"ETHERTYPE_MPLS_MCAST", Const, 1},
{"ETHERTYPE_MUMPS", Const, 1},
{"ETHERTYPE_NBPCC", Const, 1},
{"ETHERTYPE_NBPCLAIM", Const, 1},
{"ETHERTYPE_NBPCLREQ", Const, 1},
{"ETHERTYPE_NBPCLRSP", Const, 1},
{"ETHERTYPE_NBPCREQ", Const, 1},
{"ETHERTYPE_NBPCRSP", Const, 1},
{"ETHERTYPE_NBPDG", Const, 1},
{"ETHERTYPE_NBPDGB", Const, 1},
{"ETHERTYPE_NBPDLTE", Const, 1},
{"ETHERTYPE_NBPRAR", Const, 1},
{"ETHERTYPE_NBPRAS", Const, 1},
{"ETHERTYPE_NBPRST", Const, 1},
{"ETHERTYPE_NBPSCD", Const, 1},
{"ETHERTYPE_NBPVCD", Const, 1},
{"ETHERTYPE_NBS", Const, 1},
{"ETHERTYPE_NCD", Const, 1},
{"ETHERTYPE_NESTAR", Const, 1},
{"ETHERTYPE_NETBEUI", Const, 1},
{"ETHERTYPE_NOVELL", Const, 1},
{"ETHERTYPE_NS", Const, 1},
{"ETHERTYPE_NSAT", Const, 1},
{"ETHERTYPE_NSCOMPAT", Const, 1},
{"ETHERTYPE_NTRAILER", Const, 1},
{"ETHERTYPE_OS9", Const, 1},
{"ETHERTYPE_OS9NET", Const, 1},
{"ETHERTYPE_PACER", Const, 1},
{"ETHERTYPE_PAE", Const, 1},
{"ETHERTYPE_PCS", Const, 1},
{"ETHERTYPE_PLANNING", Const, 1},
{"ETHERTYPE_PPP", Const, 1},
{"ETHERTYPE_PPPOE", Const, 1},
{"ETHERTYPE_PPPOEDISC", Const, 1},
{"ETHERTYPE_PRIMENTS", Const, 1},
{"ETHERTYPE_PUP", Const, 1},
{"ETHERTYPE_PUPAT", Const, 1},
{"ETHERTYPE_QINQ", Const, 1},
{"ETHERTYPE_RACAL", Const, 1},
{"ETHERTYPE_RATIONAL", Const, 1},
{"ETHERTYPE_RAWFR", Const, 1},
{"ETHERTYPE_RCL", Const, 1},
{"ETHERTYPE_RDP", Const, 1},
{"ETHERTYPE_RETIX", Const, 1},
{"ETHERTYPE_REVARP", Const, 1},
{"ETHERTYPE_SCA", Const, 1},
{"ETHERTYPE_SECTRA", Const, 1},
{"ETHERTYPE_SECUREDATA", Const, 1},
{"ETHERTYPE_SGITW", Const, 1},
{"ETHERTYPE_SG_BOUNCE", Const, 1},
{"ETHERTYPE_SG_DIAG", Const, 1},
{"ETHERTYPE_SG_NETGAMES", Const, 1},
{"ETHERTYPE_SG_RESV", Const, 1},
{"ETHERTYPE_SIMNET", Const, 1},
{"ETHERTYPE_SLOW", Const, 1},
{"ETHERTYPE_SLOWPROTOCOLS", Const, 1},
{"ETHERTYPE_SNA", Const, 1},
{"ETHERTYPE_SNMP", Const, 1},
{"ETHERTYPE_SONIX", Const, 1},
{"ETHERTYPE_SPIDER", Const, 1},
{"ETHERTYPE_SPRITE", Const, 1},
{"ETHERTYPE_STP", Const, 1},
{"ETHERTYPE_TALARIS", Const, 1},
{"ETHERTYPE_TALARISMC", Const, 1},
{"ETHERTYPE_TCPCOMP", Const, 1},
{"ETHERTYPE_TCPSM", Const, 1},
{"ETHERTYPE_TEC", Const, 1},
{"ETHERTYPE_TIGAN", Const, 1},
{"ETHERTYPE_TRAIL", Const, 1},
{"ETHERTYPE_TRANSETHER", Const, 1},
{"ETHERTYPE_TYMSHARE", Const, 1},
{"ETHERTYPE_UBBST", Const, 1},
{"ETHERTYPE_UBDEBUG", Const, 1},
{"ETHERTYPE_UBDIAGLOOP", Const, 1},
{"ETHERTYPE_UBDL", Const, 1},
{"ETHERTYPE_UBNIU", Const, 1},
{"ETHERTYPE_UBNMC", Const, 1},
{"ETHERTYPE_VALID", Const, 1},
{"ETHERTYPE_VARIAN", Const, 1},
{"ETHERTYPE_VAXELN", Const, 1},
{"ETHERTYPE_VEECO", Const, 1},
{"ETHERTYPE_VEXP", Const, 1},
{"ETHERTYPE_VGLAB", Const, 1},
{"ETHERTYPE_VINES", Const, 1},
{"ETHERTYPE_VINESECHO", Const, 1},
{"ETHERTYPE_VINESLOOP", Const, 1},
{"ETHERTYPE_VITAL", Const, 1},
{"ETHERTYPE_VLAN", Const, 1},
{"ETHERTYPE_VLTLMAN", Const, 1},
{"ETHERTYPE_VPROD", Const, 1},
{"ETHERTYPE_VURESERVED", Const, 1},
{"ETHERTYPE_WATERLOO", Const, 1},
{"ETHERTYPE_WELLFLEET", Const, 1},
{"ETHERTYPE_X25", Const, 1},
{"ETHERTYPE_X75", Const, 1},
{"ETHERTYPE_XNSSM", Const, 1},
{"ETHERTYPE_XTP", Const, 1},
{"ETHER_ADDR_LEN", Const, 1},
{"ETHER_ALIGN", Const, 1},
{"ETHER_CRC_LEN", Const, 1},
{"ETHER_CRC_POLY_BE", Const, 1},
{"ETHER_CRC_POLY_LE", Const, 1},
{"ETHER_HDR_LEN", Const, 1},
{"ETHER_MAX_DIX_LEN", Const, 1},
{"ETHER_MAX_LEN", Const, 1},
{"ETHER_MAX_LEN_JUMBO", Const, 1},
{"ETHER_MIN_LEN", Const, 1},
{"ETHER_PPPOE_ENCAP_LEN", Const, 1},
{"ETHER_TYPE_LEN", Const, 1},
{"ETHER_VLAN_ENCAP_LEN", Const, 1},
{"ETH_P_1588", Const, 0},
{"ETH_P_8021Q", Const, 0},
{"ETH_P_802_2", Const, 0},
{"ETH_P_802_3", Const, 0},
{"ETH_P_AARP", Const, 0},
{"ETH_P_ALL", Const, 0},
{"ETH_P_AOE", Const, 0},
{"ETH_P_ARCNET", Const, 0},
{"ETH_P_ARP", Const, 0},
{"ETH_P_ATALK", Const, 0},
{"ETH_P_ATMFATE", Const, 0},
{"ETH_P_ATMMPOA", Const, 0},
{"ETH_P_AX25", Const, 0},
{"ETH_P_BPQ", Const, 0},
{"ETH_P_CAIF", Const, 0},
{"ETH_P_CAN", Const, 0},
{"ETH_P_CONTROL", Const, 0},
{"ETH_P_CUST", Const, 0},
{"ETH_P_DDCMP", Const, 0},
{"ETH_P_DEC", Const, 0},
{"ETH_P_DIAG", Const, 0},
{"ETH_P_DNA_DL", Const, 0},
{"ETH_P_DNA_RC", Const, 0},
{"ETH_P_DNA_RT", Const, 0},
{"ETH_P_DSA", Const, 0},
{"ETH_P_ECONET", Const, 0},
{"ETH_P_EDSA", Const, 0},
{"ETH_P_FCOE", Const, 0},
{"ETH_P_FIP", Const, 0},
{"ETH_P_HDLC", Const, 0},
{"ETH_P_IEEE802154", Const, 0},
{"ETH_P_IEEEPUP", Const, 0},
{"ETH_P_IEEEPUPAT", Const, 0},
{"ETH_P_IP", Const, 0},
{"ETH_P_IPV6", Const, 0},
{"ETH_P_IPX", Const, 0},
{"ETH_P_IRDA", Const, 0},
{"ETH_P_LAT", Const, 0},
{"ETH_P_LINK_CTL", Const, 0},
{"ETH_P_LOCALTALK", Const, 0},
{"ETH_P_LOOP", Const, 0},
{"ETH_P_MOBITEX", Const, 0},
{"ETH_P_MPLS_MC", Const, 0},
{"ETH_P_MPLS_UC", Const, 0},
{"ETH_P_PAE", Const, 0},
{"ETH_P_PAUSE", Const, 0},
{"ETH_P_PHONET", Const, 0},
{"ETH_P_PPPTALK", Const, 0},
{"ETH_P_PPP_DISC", Const, 0},
{"ETH_P_PPP_MP", Const, 0},
{"ETH_P_PPP_SES", Const, 0},
{"ETH_P_PUP", Const, 0},
{"ETH_P_PUPAT", Const, 0},
{"ETH_P_RARP", Const, 0},
{"ETH_P_SCA", Const, 0},
{"ETH_P_SLOW", Const, 0},
{"ETH_P_SNAP", Const, 0},
{"ETH_P_TEB", Const, 0},
{"ETH_P_TIPC", Const, 0},
{"ETH_P_TRAILER", Const, 0},
{"ETH_P_TR_802_2", Const, 0},
{"ETH_P_WAN_PPP", Const, 0},
{"ETH_P_WCCP", Const, 0},
{"ETH_P_X25", Const, 0},
{"ETIME", Const, 0},
{"ETIMEDOUT", Const, 0},
{"ETOOMANYREFS", Const, 0},
{"ETXTBSY", Const, 0},
{"EUCLEAN", Const, 0},
{"EUNATCH", Const, 0},
{"EUSERS", Const, 0},
{"EVFILT_AIO", Const, 0},
{"EVFILT_FS", Const, 0},
{"EVFILT_LIO", Const, 0},
{"EVFILT_MACHPORT", Const, 0},
{"EVFILT_PROC", Const, 0},
{"EVFILT_READ", Const, 0},
{"EVFILT_SIGNAL", Const, 0},
{"EVFILT_SYSCOUNT", Const, 0},
{"EVFILT_THREADMARKER", Const, 0},
{"EVFILT_TIMER", Const, 0},
{"EVFILT_USER", Const, 0},
{"EVFILT_VM", Const, 0},
{"EVFILT_VNODE", Const, 0},
{"EVFILT_WRITE", Const, 0},
{"EV_ADD", Const, 0},
{"EV_CLEAR", Const, 0},
{"EV_DELETE", Const, 0},
{"EV_DISABLE", Const, 0},
{"EV_DISPATCH", Const, 0},
{"EV_DROP", Const, 3},
{"EV_ENABLE", Const, 0},
{"EV_EOF", Const, 0},
{"EV_ERROR", Const, 0},
{"EV_FLAG0", Const, 0},
{"EV_FLAG1", Const, 0},
{"EV_ONESHOT", Const, 0},
{"EV_OOBAND", Const, 0},
{"EV_POLL", Const, 0},
{"EV_RECEIPT", Const, 0},
{"EV_SYSFLAGS", Const, 0},
{"EWINDOWS", Const, 0},
{"EWOULDBLOCK", Const, 0},
{"EXDEV", Const, 0},
{"EXFULL", Const, 0},
{"EXTA", Const, 0},
{"EXTB", Const, 0},
{"EXTPROC", Const, 0},
{"Environ", Func, 0},
{"EpollCreate", Func, 0},
{"EpollCreate1", Func, 0},
{"EpollCtl", Func, 0},
{"EpollEvent", Type, 0},
{"EpollEvent.Events", Field, 0},
{"EpollEvent.Fd", Field, 0},
{"EpollEvent.Pad", Field, 0},
{"EpollEvent.PadFd", Field, 0},
{"EpollWait", Func, 0},
{"Errno", Type, 0},
{"EscapeArg", Func, 0},
{"Exchangedata", Func, 0},
{"Exec", Func, 0},
{"Exit", Func, 0},
{"ExitProcess", Func, 0},
{"FD_CLOEXEC", Const, 0},
{"FD_SETSIZE", Const, 0},
{"FILE_ACTION_ADDED", Const, 0},
{"FILE_ACTION_MODIFIED", Const, 0},
{"FILE_ACTION_REMOVED", Const, 0},
{"FILE_ACTION_RENAMED_NEW_NAME", Const, 0},
{"FILE_ACTION_RENAMED_OLD_NAME", Const, 0},
{"FILE_APPEND_DATA", Const, 0},
{"FILE_ATTRIBUTE_ARCHIVE", Const, 0},
{"FILE_ATTRIBUTE_DIRECTORY", Const, 0},
{"FILE_ATTRIBUTE_HIDDEN", Const, 0},
{"FILE_ATTRIBUTE_NORMAL", Const, 0},
{"FILE_ATTRIBUTE_READONLY", Const, 0},
{"FILE_ATTRIBUTE_REPARSE_POINT", Const, 4},
{"FILE_ATTRIBUTE_SYSTEM", Const, 0},
{"FILE_BEGIN", Const, 0},
{"FILE_CURRENT", Const, 0},
{"FILE_END", Const, 0},
{"FILE_FLAG_BACKUP_SEMANTICS", Const, 0},
{"FILE_FLAG_OPEN_REPARSE_POINT", Const, 4},
{"FILE_FLAG_OVERLAPPED", Const, 0},
{"FILE_LIST_DIRECTORY", Const, 0},
{"FILE_MAP_COPY", Const, 0},
{"FILE_MAP_EXECUTE", Const, 0},
{"FILE_MAP_READ", Const, 0},
{"FILE_MAP_WRITE", Const, 0},
{"FILE_NOTIFY_CHANGE_ATTRIBUTES", Const, 0},
{"FILE_NOTIFY_CHANGE_CREATION", Const, 0},
{"FILE_NOTIFY_CHANGE_DIR_NAME", Const, 0},
{"FILE_NOTIFY_CHANGE_FILE_NAME", Const, 0},
{"FILE_NOTIFY_CHANGE_LAST_ACCESS", Const, 0},
{"FILE_NOTIFY_CHANGE_LAST_WRITE", Const, 0},
{"FILE_NOTIFY_CHANGE_SIZE", Const, 0},
{"FILE_SHARE_DELETE", Const, 0},
{"FILE_SHARE_READ", Const, 0},
{"FILE_SHARE_WRITE", Const, 0},
{"FILE_SKIP_COMPLETION_PORT_ON_SUCCESS", Const, 2},
{"FILE_SKIP_SET_EVENT_ON_HANDLE", Const, 2},
{"FILE_TYPE_CHAR", Const, 0},
{"FILE_TYPE_DISK", Const, 0},
{"FILE_TYPE_PIPE", Const, 0},
{"FILE_TYPE_REMOTE", Const, 0},
{"FILE_TYPE_UNKNOWN", Const, 0},
{"FILE_WRITE_ATTRIBUTES", Const, 0},
{"FLUSHO", Const, 0},
{"FORMAT_MESSAGE_ALLOCATE_BUFFER", Const, 0},
{"FORMAT_MESSAGE_ARGUMENT_ARRAY", Const, 0},
{"FORMAT_MESSAGE_FROM_HMODULE", Const, 0},
{"FORMAT_MESSAGE_FROM_STRING", Const, 0},
{"FORMAT_MESSAGE_FROM_SYSTEM", Const, 0},
{"FORMAT_MESSAGE_IGNORE_INSERTS", Const, 0},
{"FORMAT_MESSAGE_MAX_WIDTH_MASK", Const, 0},
{"FSCTL_GET_REPARSE_POINT", Const, 4},
{"F_ADDFILESIGS", Const, 0},
{"F_ADDSIGS", Const, 0},
{"F_ALLOCATEALL", Const, 0},
{"F_ALLOCATECONTIG", Const, 0},
{"F_CANCEL", Const, 0},
{"F_CHKCLEAN", Const, 0},
{"F_CLOSEM", Const, 1},
{"F_DUP2FD", Const, 0},
{"F_DUP2FD_CLOEXEC", Const, 1},
{"F_DUPFD", Const, 0},
{"F_DUPFD_CLOEXEC", Const, 0},
{"F_EXLCK", Const, 0},
{"F_FINDSIGS", Const, 16},
{"F_FLUSH_DATA", Const, 0},
{"F_FREEZE_FS", Const, 0},
{"F_FSCTL", Const, 1},
{"F_FSDIRMASK", Const, 1},
{"F_FSIN", Const, 1},
{"F_FSINOUT", Const, 1},
{"F_FSOUT", Const, 1},
{"F_FSPRIV", Const, 1},
{"F_FSVOID", Const, 1},
{"F_FULLFSYNC", Const, 0},
{"F_GETCODEDIR", Const, 16},
{"F_GETFD", Const, 0},
{"F_GETFL", Const, 0},
{"F_GETLEASE", Const, 0},
{"F_GETLK", Const, 0},
{"F_GETLK64", Const, 0},
{"F_GETLKPID", Const, 0},
{"F_GETNOSIGPIPE", Const, 0},
{"F_GETOWN", Const, 0},
{"F_GETOWN_EX", Const, 0},
{"F_GETPATH", Const, 0},
{"F_GETPATH_MTMINFO", Const, 0},
{"F_GETPIPE_SZ", Const, 0},
{"F_GETPROTECTIONCLASS", Const, 0},
{"F_GETPROTECTIONLEVEL", Const, 16},
{"F_GETSIG", Const, 0},
{"F_GLOBAL_NOCACHE", Const, 0},
{"F_LOCK", Const, 0},
{"F_LOG2PHYS", Const, 0},
{"F_LOG2PHYS_EXT", Const, 0},
{"F_MARKDEPENDENCY", Const, 0},
{"F_MAXFD", Const, 1},
{"F_NOCACHE", Const, 0},
{"F_NODIRECT", Const, 0},
{"F_NOTIFY", Const, 0},
{"F_OGETLK", Const, 0},
{"F_OK", Const, 0},
{"F_OSETLK", Const, 0},
{"F_OSETLKW", Const, 0},
{"F_PARAM_MASK", Const, 1},
{"F_PARAM_MAX", Const, 1},
{"F_PATHPKG_CHECK", Const, 0},
{"F_PEOFPOSMODE", Const, 0},
{"F_PREALLOCATE", Const, 0},
{"F_RDADVISE", Const, 0},
{"F_RDAHEAD", Const, 0},
{"F_RDLCK", Const, 0},
{"F_READAHEAD", Const, 0},
{"F_READBOOTSTRAP", Const, 0},
{"F_SETBACKINGSTORE", Const, 0},
{"F_SETFD", Const, 0},
{"F_SETFL", Const, 0},
{"F_SETLEASE", Const, 0},
{"F_SETLK", Const, 0},
{"F_SETLK64", Const, 0},
{"F_SETLKW", Const, 0},
{"F_SETLKW64", Const, 0},
{"F_SETLKWTIMEOUT", Const, 16},
{"F_SETLK_REMOTE", Const, 0},
{"F_SETNOSIGPIPE", Const, 0},
{"F_SETOWN", Const, 0},
{"F_SETOWN_EX", Const, 0},
{"F_SETPIPE_SZ", Const, 0},
{"F_SETPROTECTIONCLASS", Const, 0},
{"F_SETSIG", Const, 0},
{"F_SETSIZE", Const, 0},
{"F_SHLCK", Const, 0},
{"F_SINGLE_WRITER", Const, 16},
{"F_TEST", Const, 0},
{"F_THAW_FS", Const, 0},
{"F_TLOCK", Const, 0},
{"F_TRANSCODEKEY", Const, 16},
{"F_ULOCK", Const, 0},
{"F_UNLCK", Const, 0},
{"F_UNLCKSYS", Const, 0},
{"F_VOLPOSMODE", Const, 0},
{"F_WRITEBOOTSTRAP", Const, 0},
{"F_WRLCK", Const, 0},
{"Faccessat", Func, 0},
{"Fallocate", Func, 0},
{"Fbootstraptransfer_t", Type, 0},
{"Fbootstraptransfer_t.Buffer", Field, 0},
{"Fbootstraptransfer_t.Length", Field, 0},
{"Fbootstraptransfer_t.Offset", Field, 0},
{"Fchdir", Func, 0},
{"Fchflags", Func, 0},
{"Fchmod", Func, 0},
{"Fchmodat", Func, 0},
{"Fchown", Func, 0},
{"Fchownat", Func, 0},
{"FcntlFlock", Func, 3},
{"FdSet", Type, 0},
{"FdSet.Bits", Field, 0},
{"FdSet.X__fds_bits", Field, 0},
{"Fdatasync", Func, 0},
{"FileNotifyInformation", Type, 0},
{"FileNotifyInformation.Action", Field, 0},
{"FileNotifyInformation.FileName", Field, 0},
{"FileNotifyInformation.FileNameLength", Field, 0},
{"FileNotifyInformation.NextEntryOffset", Field, 0},
{"Filetime", Type, 0},
{"Filetime.HighDateTime", Field, 0},
{"Filetime.LowDateTime", Field, 0},
{"FindClose", Func, 0},
{"FindFirstFile", Func, 0},
{"FindNextFile", Func, 0},
{"Flock", Func, 0},
{"Flock_t", Type, 0},
{"Flock_t.Len", Field, 0},
{"Flock_t.Pad_cgo_0", Field, 0},
{"Flock_t.Pad_cgo_1", Field, 3},
{"Flock_t.Pid", Field, 0},
{"Flock_t.Start", Field, 0},
{"Flock_t.Sysid", Field, 0},
{"Flock_t.Type", Field, 0},
{"Flock_t.Whence", Field, 0},
{"FlushBpf", Func, 0},
{"FlushFileBuffers", Func, 0},
{"FlushViewOfFile", Func, 0},
{"ForkExec", Func, 0},
{"ForkLock", Var, 0},
{"FormatMessage", Func, 0},
{"Fpathconf", Func, 0},
{"FreeAddrInfoW", Func, 1},
{"FreeEnvironmentStrings", Func, 0},
{"FreeLibrary", Func, 0},
{"Fsid", Type, 0},
{"Fsid.Val", Field, 0},
{"Fsid.X__fsid_val", Field, 2},
{"Fsid.X__val", Field, 0},
{"Fstat", Func, 0},
{"Fstatat", Func, 12},
{"Fstatfs", Func, 0},
{"Fstore_t", Type, 0},
{"Fstore_t.Bytesalloc", Field, 0},
{"Fstore_t.Flags", Field, 0},
{"Fstore_t.Length", Field, 0},
{"Fstore_t.Offset", Field, 0},
{"Fstore_t.Posmode", Field, 0},
{"Fsync", Func, 0},
{"Ftruncate", Func, 0},
{"FullPath", Func, 4},
{"Futimes", Func, 0},
{"Futimesat", Func, 0},
{"GENERIC_ALL", Const, 0},
{"GENERIC_EXECUTE", Const, 0},
{"GENERIC_READ", Const, 0},
{"GENERIC_WRITE", Const, 0},
{"GUID", Type, 1},
{"GUID.Data1", Field, 1},
{"GUID.Data2", Field, 1},
{"GUID.Data3", Field, 1},
{"GUID.Data4", Field, 1},
{"GetAcceptExSockaddrs", Func, 0},
{"GetAdaptersInfo", Func, 0},
{"GetAddrInfoW", Func, 1},
{"GetCommandLine", Func, 0},
{"GetComputerName", Func, 0},
{"GetConsoleMode", Func, 1},
{"GetCurrentDirectory", Func, 0},
{"GetCurrentProcess", Func, 0},
{"GetEnvironmentStrings", Func, 0},
{"GetEnvironmentVariable", Func, 0},
{"GetExitCodeProcess", Func, 0},
{"GetFileAttributes", Func, 0},
{"GetFileAttributesEx", Func, 0},
{"GetFileExInfoStandard", Const, 0},
{"GetFileExMaxInfoLevel", Const, 0},
{"GetFileInformationByHandle", Func, 0},
{"GetFileType", Func, 0},
{"GetFullPathName", Func, 0},
{"GetHostByName", Func, 0},
{"GetIfEntry", Func, 0},
{"GetLastError", Func, 0},
{"GetLengthSid", Func, 0},
{"GetLongPathName", Func, 0},
{"GetProcAddress", Func, 0},
{"GetProcessTimes", Func, 0},
{"GetProtoByName", Func, 0},
{"GetQueuedCompletionStatus", Func, 0},
{"GetServByName", Func, 0},
{"GetShortPathName", Func, 0},
{"GetStartupInfo", Func, 0},
{"GetStdHandle", Func, 0},
{"GetSystemTimeAsFileTime", Func, 0},
{"GetTempPath", Func, 0},
{"GetTimeZoneInformation", Func, 0},
{"GetTokenInformation", Func, 0},
{"GetUserNameEx", Func, 0},
{"GetUserProfileDirectory", Func, 0},
{"GetVersion", Func, 0},
{"Getcwd", Func, 0},
{"Getdents", Func, 0},
{"Getdirentries", Func, 0},
{"Getdtablesize", Func, 0},
{"Getegid", Func, 0},
{"Getenv", Func, 0},
{"Geteuid", Func, 0},
{"Getfsstat", Func, 0},
{"Getgid", Func, 0},
{"Getgroups", Func, 0},
{"Getpagesize", Func, 0},
{"Getpeername", Func, 0},
{"Getpgid", Func, 0},
{"Getpgrp", Func, 0},
{"Getpid", Func, 0},
{"Getppid", Func, 0},
{"Getpriority", Func, 0},
{"Getrlimit", Func, 0},
{"Getrusage", Func, 0},
{"Getsid", Func, 0},
{"Getsockname", Func, 0},
{"Getsockopt", Func, 1},
{"GetsockoptByte", Func, 0},
{"GetsockoptICMPv6Filter", Func, 2},
{"GetsockoptIPMreq", Func, 0},
{"GetsockoptIPMreqn", Func, 0},
{"GetsockoptIPv6MTUInfo", Func, 2},
{"GetsockoptIPv6Mreq", Func, 0},
{"GetsockoptInet4Addr", Func, 0},
{"GetsockoptInt", Func, 0},
{"GetsockoptUcred", Func, 1},
{"Gettid", Func, 0},
{"Gettimeofday", Func, 0},
{"Getuid", Func, 0},
{"Getwd", Func, 0},
{"Getxattr", Func, 1},
{"HANDLE_FLAG_INHERIT", Const, 0},
{"HKEY_CLASSES_ROOT", Const, 0},
{"HKEY_CURRENT_CONFIG", Const, 0},
{"HKEY_CURRENT_USER", Const, 0},
{"HKEY_DYN_DATA", Const, 0},
{"HKEY_LOCAL_MACHINE", Const, 0},
{"HKEY_PERFORMANCE_DATA", Const, 0},
{"HKEY_USERS", Const, 0},
{"HUPCL", Const, 0},
{"Handle", Type, 0},
{"Hostent", Type, 0},
{"Hostent.AddrList", Field, 0},
{"Hostent.AddrType", Field, 0},
{"Hostent.Aliases", Field, 0},
{"Hostent.Length", Field, 0},
{"Hostent.Name", Field, 0},
{"ICANON", Const, 0},
{"ICMP6_FILTER", Const, 2},
{"ICMPV6_FILTER", Const, 2},
{"ICMPv6Filter", Type, 2},
{"ICMPv6Filter.Data", Field, 2},
{"ICMPv6Filter.Filt", Field, 2},
{"ICRNL", Const, 0},
{"IEXTEN", Const, 0},
{"IFAN_ARRIVAL", Const, 1},
{"IFAN_DEPARTURE", Const, 1},
{"IFA_ADDRESS", Const, 0},
{"IFA_ANYCAST", Const, 0},
{"IFA_BROADCAST", Const, 0},
{"IFA_CACHEINFO", Const, 0},
{"IFA_F_DADFAILED", Const, 0},
{"IFA_F_DEPRECATED", Const, 0},
{"IFA_F_HOMEADDRESS", Const, 0},
{"IFA_F_NODAD", Const, 0},
{"IFA_F_OPTIMISTIC", Const, 0},
{"IFA_F_PERMANENT", Const, 0},
{"IFA_F_SECONDARY", Const, 0},
{"IFA_F_TEMPORARY", Const, 0},
{"IFA_F_TENTATIVE", Const, 0},
{"IFA_LABEL", Const, 0},
{"IFA_LOCAL", Const, 0},
{"IFA_MAX", Const, 0},
{"IFA_MULTICAST", Const, 0},
{"IFA_ROUTE", Const, 1},
{"IFA_UNSPEC", Const, 0},
{"IFF_ALLMULTI", Const, 0},
{"IFF_ALTPHYS", Const, 0},
{"IFF_AUTOMEDIA", Const, 0},
{"IFF_BROADCAST", Const, 0},
{"IFF_CANTCHANGE", Const, 0},
{"IFF_CANTCONFIG", Const, 1},
{"IFF_DEBUG", Const, 0},
{"IFF_DRV_OACTIVE", Const, 0},
{"IFF_DRV_RUNNING", Const, 0},
{"IFF_DYING", Const, 0},
{"IFF_DYNAMIC", Const, 0},
{"IFF_LINK0", Const, 0},
{"IFF_LINK1", Const, 0},
{"IFF_LINK2", Const, 0},
{"IFF_LOOPBACK", Const, 0},
{"IFF_MASTER", Const, 0},
{"IFF_MONITOR", Const, 0},
{"IFF_MULTICAST", Const, 0},
{"IFF_NOARP", Const, 0},
{"IFF_NOTRAILERS", Const, 0},
{"IFF_NO_PI", Const, 0},
{"IFF_OACTIVE", Const, 0},
{"IFF_ONE_QUEUE", Const, 0},
{"IFF_POINTOPOINT", Const, 0},
{"IFF_POINTTOPOINT", Const, 0},
{"IFF_PORTSEL", Const, 0},
{"IFF_PPROMISC", Const, 0},
{"IFF_PROMISC", Const, 0},
{"IFF_RENAMING", Const, 0},
{"IFF_RUNNING", Const, 0},
{"IFF_SIMPLEX", Const, 0},
{"IFF_SLAVE", Const, 0},
{"IFF_SMART", Const, 0},
{"IFF_STATICARP", Const, 0},
{"IFF_TAP", Const, 0},
{"IFF_TUN", Const, 0},
{"IFF_TUN_EXCL", Const, 0},
{"IFF_UP", Const, 0},
{"IFF_VNET_HDR", Const, 0},
{"IFLA_ADDRESS", Const, 0},
{"IFLA_BROADCAST", Const, 0},
{"IFLA_COST", Const, 0},
{"IFLA_IFALIAS", Const, 0},
{"IFLA_IFNAME", Const, 0},
{"IFLA_LINK", Const, 0},
{"IFLA_LINKINFO", Const, 0},
{"IFLA_LINKMODE", Const, 0},
{"IFLA_MAP", Const, 0},
{"IFLA_MASTER", Const, 0},
{"IFLA_MAX", Const, 0},
{"IFLA_MTU", Const, 0},
{"IFLA_NET_NS_PID", Const, 0},
{"IFLA_OPERSTATE", Const, 0},
{"IFLA_PRIORITY", Const, 0},
{"IFLA_PROTINFO", Const, 0},
{"IFLA_QDISC", Const, 0},
{"IFLA_STATS", Const, 0},
{"IFLA_TXQLEN", Const, 0},
{"IFLA_UNSPEC", Const, 0},
{"IFLA_WEIGHT", Const, 0},
{"IFLA_WIRELESS", Const, 0},
{"IFNAMSIZ", Const, 0},
{"IFT_1822", Const, 0},
{"IFT_A12MPPSWITCH", Const, 0},
{"IFT_AAL2", Const, 0},
{"IFT_AAL5", Const, 0},
{"IFT_ADSL", Const, 0},
{"IFT_AFLANE8023", Const, 0},
{"IFT_AFLANE8025", Const, 0},
{"IFT_ARAP", Const, 0},
{"IFT_ARCNET", Const, 0},
{"IFT_ARCNETPLUS", Const, 0},
{"IFT_ASYNC", Const, 0},
{"IFT_ATM", Const, 0},
{"IFT_ATMDXI", Const, 0},
{"IFT_ATMFUNI", Const, 0},
{"IFT_ATMIMA", Const, 0},
{"IFT_ATMLOGICAL", Const, 0},
{"IFT_ATMRADIO", Const, 0},
{"IFT_ATMSUBINTERFACE", Const, 0},
{"IFT_ATMVCIENDPT", Const, 0},
{"IFT_ATMVIRTUAL", Const, 0},
{"IFT_BGPPOLICYACCOUNTING", Const, 0},
{"IFT_BLUETOOTH", Const, 1},
{"IFT_BRIDGE", Const, 0},
{"IFT_BSC", Const, 0},
{"IFT_CARP", Const, 0},
{"IFT_CCTEMUL", Const, 0},
{"IFT_CELLULAR", Const, 0},
{"IFT_CEPT", Const, 0},
{"IFT_CES", Const, 0},
{"IFT_CHANNEL", Const, 0},
{"IFT_CNR", Const, 0},
{"IFT_COFFEE", Const, 0},
{"IFT_COMPOSITELINK", Const, 0},
{"IFT_DCN", Const, 0},
{"IFT_DIGITALPOWERLINE", Const, 0},
{"IFT_DIGITALWRAPPEROVERHEADCHANNEL", Const, 0},
{"IFT_DLSW", Const, 0},
{"IFT_DOCSCABLEDOWNSTREAM", Const, 0},
{"IFT_DOCSCABLEMACLAYER", Const, 0},
{"IFT_DOCSCABLEUPSTREAM", Const, 0},
{"IFT_DOCSCABLEUPSTREAMCHANNEL", Const, 1},
{"IFT_DS0", Const, 0},
{"IFT_DS0BUNDLE", Const, 0},
{"IFT_DS1FDL", Const, 0},
{"IFT_DS3", Const, 0},
{"IFT_DTM", Const, 0},
{"IFT_DUMMY", Const, 1},
{"IFT_DVBASILN", Const, 0},
{"IFT_DVBASIOUT", Const, 0},
{"IFT_DVBRCCDOWNSTREAM", Const, 0},
{"IFT_DVBRCCMACLAYER", Const, 0},
{"IFT_DVBRCCUPSTREAM", Const, 0},
{"IFT_ECONET", Const, 1},
{"IFT_ENC", Const, 0},
{"IFT_EON", Const, 0},
{"IFT_EPLRS", Const, 0},
{"IFT_ESCON", Const, 0},
{"IFT_ETHER", Const, 0},
{"IFT_FAITH", Const, 0},
{"IFT_FAST", Const, 0},
{"IFT_FASTETHER", Const, 0},
{"IFT_FASTETHERFX", Const, 0},
{"IFT_FDDI", Const, 0},
{"IFT_FIBRECHANNEL", Const, 0},
{"IFT_FRAMERELAYINTERCONNECT", Const, 0},
{"IFT_FRAMERELAYMPI", Const, 0},
{"IFT_FRDLCIENDPT", Const, 0},
{"IFT_FRELAY", Const, 0},
{"IFT_FRELAYDCE", Const, 0},
{"IFT_FRF16MFRBUNDLE", Const, 0},
{"IFT_FRFORWARD", Const, 0},
{"IFT_G703AT2MB", Const, 0},
{"IFT_G703AT64K", Const, 0},
{"IFT_GIF", Const, 0},
{"IFT_GIGABITETHERNET", Const, 0},
{"IFT_GR303IDT", Const, 0},
{"IFT_GR303RDT", Const, 0},
{"IFT_H323GATEKEEPER", Const, 0},
{"IFT_H323PROXY", Const, 0},
{"IFT_HDH1822", Const, 0},
{"IFT_HDLC", Const, 0},
{"IFT_HDSL2", Const, 0},
{"IFT_HIPERLAN2", Const, 0},
{"IFT_HIPPI", Const, 0},
{"IFT_HIPPIINTERFACE", Const, 0},
{"IFT_HOSTPAD", Const, 0},
{"IFT_HSSI", Const, 0},
{"IFT_HY", Const, 0},
{"IFT_IBM370PARCHAN", Const, 0},
{"IFT_IDSL", Const, 0},
{"IFT_IEEE1394", Const, 0},
{"IFT_IEEE80211", Const, 0},
{"IFT_IEEE80212", Const, 0},
{"IFT_IEEE8023ADLAG", Const, 0},
{"IFT_IFGSN", Const, 0},
{"IFT_IMT", Const, 0},
{"IFT_INFINIBAND", Const, 1},
{"IFT_INTERLEAVE", Const, 0},
{"IFT_IP", Const, 0},
{"IFT_IPFORWARD", Const, 0},
{"IFT_IPOVERATM", Const, 0},
{"IFT_IPOVERCDLC", Const, 0},
{"IFT_IPOVERCLAW", Const, 0},
{"IFT_IPSWITCH", Const, 0},
{"IFT_IPXIP", Const, 0},
{"IFT_ISDN", Const, 0},
{"IFT_ISDNBASIC", Const, 0},
{"IFT_ISDNPRIMARY", Const, 0},
{"IFT_ISDNS", Const, 0},
{"IFT_ISDNU", Const, 0},
{"IFT_ISO88022LLC", Const, 0},
{"IFT_ISO88023", Const, 0},
{"IFT_ISO88024", Const, 0},
{"IFT_ISO88025", Const, 0},
{"IFT_ISO88025CRFPINT", Const, 0},
{"IFT_ISO88025DTR", Const, 0},
{"IFT_ISO88025FIBER", Const, 0},
{"IFT_ISO88026", Const, 0},
{"IFT_ISUP", Const, 0},
{"IFT_L2VLAN", Const, 0},
{"IFT_L3IPVLAN", Const, 0},
{"IFT_L3IPXVLAN", Const, 0},
{"IFT_LAPB", Const, 0},
{"IFT_LAPD", Const, 0},
{"IFT_LAPF", Const, 0},
{"IFT_LINEGROUP", Const, 1},
{"IFT_LOCALTALK", Const, 0},
{"IFT_LOOP", Const, 0},
{"IFT_MEDIAMAILOVERIP", Const, 0},
{"IFT_MFSIGLINK", Const, 0},
{"IFT_MIOX25", Const, 0},
{"IFT_MODEM", Const, 0},
{"IFT_MPC", Const, 0},
{"IFT_MPLS", Const, 0},
{"IFT_MPLSTUNNEL", Const, 0},
{"IFT_MSDSL", Const, 0},
{"IFT_MVL", Const, 0},
{"IFT_MYRINET", Const, 0},
{"IFT_NFAS", Const, 0},
{"IFT_NSIP", Const, 0},
{"IFT_OPTICALCHANNEL", Const, 0},
{"IFT_OPTICALTRANSPORT", Const, 0},
{"IFT_OTHER", Const, 0},
{"IFT_P10", Const, 0},
{"IFT_P80", Const, 0},
{"IFT_PARA", Const, 0},
{"IFT_PDP", Const, 0},
{"IFT_PFLOG", Const, 0},
{"IFT_PFLOW", Const, 1},
{"IFT_PFSYNC", Const, 0},
{"IFT_PLC", Const, 0},
{"IFT_PON155", Const, 1},
{"IFT_PON622", Const, 1},
{"IFT_POS", Const, 0},
{"IFT_PPP", Const, 0},
{"IFT_PPPMULTILINKBUNDLE", Const, 0},
{"IFT_PROPATM", Const, 1},
{"IFT_PROPBWAP2MP", Const, 0},
{"IFT_PROPCNLS", Const, 0},
{"IFT_PROPDOCSWIRELESSDOWNSTREAM", Const, 0},
{"IFT_PROPDOCSWIRELESSMACLAYER", Const, 0},
{"IFT_PROPDOCSWIRELESSUPSTREAM", Const, 0},
{"IFT_PROPMUX", Const, 0},
{"IFT_PROPVIRTUAL", Const, 0},
{"IFT_PROPWIRELESSP2P", Const, 0},
{"IFT_PTPSERIAL", Const, 0},
{"IFT_PVC", Const, 0},
{"IFT_Q2931", Const, 1},
{"IFT_QLLC", Const, 0},
{"IFT_RADIOMAC", Const, 0},
{"IFT_RADSL", Const, 0},
{"IFT_REACHDSL", Const, 0},
{"IFT_RFC1483", Const, 0},
{"IFT_RS232", Const, 0},
{"IFT_RSRB", Const, 0},
{"IFT_SDLC", Const, 0},
{"IFT_SDSL", Const, 0},
{"IFT_SHDSL", Const, 0},
{"IFT_SIP", Const, 0},
{"IFT_SIPSIG", Const, 1},
{"IFT_SIPTG", Const, 1},
{"IFT_SLIP", Const, 0},
{"IFT_SMDSDXI", Const, 0},
{"IFT_SMDSICIP", Const, 0},
{"IFT_SONET", Const, 0},
{"IFT_SONETOVERHEADCHANNEL", Const, 0},
{"IFT_SONETPATH", Const, 0},
{"IFT_SONETVT", Const, 0},
{"IFT_SRP", Const, 0},
{"IFT_SS7SIGLINK", Const, 0},
{"IFT_STACKTOSTACK", Const, 0},
{"IFT_STARLAN", Const, 0},
{"IFT_STF", Const, 0},
{"IFT_T1", Const, 0},
{"IFT_TDLC", Const, 0},
{"IFT_TELINK", Const, 1},
{"IFT_TERMPAD", Const, 0},
{"IFT_TR008", Const, 0},
{"IFT_TRANSPHDLC", Const, 0},
{"IFT_TUNNEL", Const, 0},
{"IFT_ULTRA", Const, 0},
{"IFT_USB", Const, 0},
{"IFT_V11", Const, 0},
{"IFT_V35", Const, 0},
{"IFT_V36", Const, 0},
{"IFT_V37", Const, 0},
{"IFT_VDSL", Const, 0},
{"IFT_VIRTUALIPADDRESS", Const, 0},
{"IFT_VIRTUALTG", Const, 1},
{"IFT_VOICEDID", Const, 1},
{"IFT_VOICEEM", Const, 0},
{"IFT_VOICEEMFGD", Const, 1},
{"IFT_VOICEENCAP", Const, 0},
{"IFT_VOICEFGDEANA", Const, 1},
{"IFT_VOICEFXO", Const, 0},
{"IFT_VOICEFXS", Const, 0},
{"IFT_VOICEOVERATM", Const, 0},
{"IFT_VOICEOVERCABLE", Const, 1},
{"IFT_VOICEOVERFRAMERELAY", Const, 0},
{"IFT_VOICEOVERIP", Const, 0},
{"IFT_X213", Const, 0},
{"IFT_X25", Const, 0},
{"IFT_X25DDN", Const, 0},
{"IFT_X25HUNTGROUP", Const, 0},
{"IFT_X25MLP", Const, 0},
{"IFT_X25PLE", Const, 0},
{"IFT_XETHER", Const, 0},
{"IGNBRK", Const, 0},
{"IGNCR", Const, 0},
{"IGNORE", Const, 0},
{"IGNPAR", Const, 0},
{"IMAXBEL", Const, 0},
{"INFINITE", Const, 0},
{"INLCR", Const, 0},
{"INPCK", Const, 0},
{"INVALID_FILE_ATTRIBUTES", Const, 0},
{"IN_ACCESS", Const, 0},
{"IN_ALL_EVENTS", Const, 0},
{"IN_ATTRIB", Const, 0},
{"IN_CLASSA_HOST", Const, 0},
{"IN_CLASSA_MAX", Const, 0},
{"IN_CLASSA_NET", Const, 0},
{"IN_CLASSA_NSHIFT", Const, 0},
{"IN_CLASSB_HOST", Const, 0},
{"IN_CLASSB_MAX", Const, 0},
{"IN_CLASSB_NET", Const, 0},
{"IN_CLASSB_NSHIFT", Const, 0},
{"IN_CLASSC_HOST", Const, 0},
{"IN_CLASSC_NET", Const, 0},
{"IN_CLASSC_NSHIFT", Const, 0},
{"IN_CLASSD_HOST", Const, 0},
{"IN_CLASSD_NET", Const, 0},
{"IN_CLASSD_NSHIFT", Const, 0},
{"IN_CLOEXEC", Const, 0},
{"IN_CLOSE", Const, 0},
{"IN_CLOSE_NOWRITE", Const, 0},
{"IN_CLOSE_WRITE", Const, 0},
{"IN_CREATE", Const, 0},
{"IN_DELETE", Const, 0},
{"IN_DELETE_SELF", Const, 0},
{"IN_DONT_FOLLOW", Const, 0},
{"IN_EXCL_UNLINK", Const, 0},
{"IN_IGNORED", Const, 0},
{"IN_ISDIR", Const, 0},
{"IN_LINKLOCALNETNUM", Const, 0},
{"IN_LOOPBACKNET", Const, 0},
{"IN_MASK_ADD", Const, 0},
{"IN_MODIFY", Const, 0},
{"IN_MOVE", Const, 0},
{"IN_MOVED_FROM", Const, 0},
{"IN_MOVED_TO", Const, 0},
{"IN_MOVE_SELF", Const, 0},
{"IN_NONBLOCK", Const, 0},
{"IN_ONESHOT", Const, 0},
{"IN_ONLYDIR", Const, 0},
{"IN_OPEN", Const, 0},
{"IN_Q_OVERFLOW", Const, 0},
{"IN_RFC3021_HOST", Const, 1},
{"IN_RFC3021_MASK", Const, 1},
{"IN_RFC3021_NET", Const, 1},
{"IN_RFC3021_NSHIFT", Const, 1},
{"IN_UNMOUNT", Const, 0},
{"IOC_IN", Const, 1},
{"IOC_INOUT", Const, 1},
{"IOC_OUT", Const, 1},
{"IOC_VENDOR", Const, 3},
{"IOC_WS2", Const, 1},
{"IO_REPARSE_TAG_SYMLINK", Const, 4},
{"IPMreq", Type, 0},
{"IPMreq.Interface", Field, 0},
{"IPMreq.Multiaddr", Field, 0},
{"IPMreqn", Type, 0},
{"IPMreqn.Address", Field, 0},
{"IPMreqn.Ifindex", Field, 0},
{"IPMreqn.Multiaddr", Field, 0},
{"IPPROTO_3PC", Const, 0},
{"IPPROTO_ADFS", Const, 0},
{"IPPROTO_AH", Const, 0},
{"IPPROTO_AHIP", Const, 0},
{"IPPROTO_APES", Const, 0},
{"IPPROTO_ARGUS", Const, 0},
{"IPPROTO_AX25", Const, 0},
{"IPPROTO_BHA", Const, 0},
{"IPPROTO_BLT", Const, 0},
{"IPPROTO_BRSATMON", Const, 0},
{"IPPROTO_CARP", Const, 0},
{"IPPROTO_CFTP", Const, 0},
{"IPPROTO_CHAOS", Const, 0},
{"IPPROTO_CMTP", Const, 0},
{"IPPROTO_COMP", Const, 0},
{"IPPROTO_CPHB", Const, 0},
{"IPPROTO_CPNX", Const, 0},
{"IPPROTO_DCCP", Const, 0},
{"IPPROTO_DDP", Const, 0},
{"IPPROTO_DGP", Const, 0},
{"IPPROTO_DIVERT", Const, 0},
{"IPPROTO_DIVERT_INIT", Const, 3},
{"IPPROTO_DIVERT_RESP", Const, 3},
{"IPPROTO_DONE", Const, 0},
{"IPPROTO_DSTOPTS", Const, 0},
{"IPPROTO_EGP", Const, 0},
{"IPPROTO_EMCON", Const, 0},
{"IPPROTO_ENCAP", Const, 0},
{"IPPROTO_EON", Const, 0},
{"IPPROTO_ESP", Const, 0},
{"IPPROTO_ETHERIP", Const, 0},
{"IPPROTO_FRAGMENT", Const, 0},
{"IPPROTO_GGP", Const, 0},
{"IPPROTO_GMTP", Const, 0},
{"IPPROTO_GRE", Const, 0},
{"IPPROTO_HELLO", Const, 0},
{"IPPROTO_HMP", Const, 0},
{"IPPROTO_HOPOPTS", Const, 0},
{"IPPROTO_ICMP", Const, 0},
{"IPPROTO_ICMPV6", Const, 0},
{"IPPROTO_IDP", Const, 0},
{"IPPROTO_IDPR", Const, 0},
{"IPPROTO_IDRP", Const, 0},
{"IPPROTO_IGMP", Const, 0},
{"IPPROTO_IGP", Const, 0},
{"IPPROTO_IGRP", Const, 0},
{"IPPROTO_IL", Const, 0},
{"IPPROTO_INLSP", Const, 0},
{"IPPROTO_INP", Const, 0},
{"IPPROTO_IP", Const, 0},
{"IPPROTO_IPCOMP", Const, 0},
{"IPPROTO_IPCV", Const, 0},
{"IPPROTO_IPEIP", Const, 0},
{"IPPROTO_IPIP", Const, 0},
{"IPPROTO_IPPC", Const, 0},
{"IPPROTO_IPV4", Const, 0},
{"IPPROTO_IPV6", Const, 0},
{"IPPROTO_IPV6_ICMP", Const, 1},
{"IPPROTO_IRTP", Const, 0},
{"IPPROTO_KRYPTOLAN", Const, 0},
{"IPPROTO_LARP", Const, 0},
{"IPPROTO_LEAF1", Const, 0},
{"IPPROTO_LEAF2", Const, 0},
{"IPPROTO_MAX", Const, 0},
{"IPPROTO_MAXID", Const, 0},
{"IPPROTO_MEAS", Const, 0},
{"IPPROTO_MH", Const, 1},
{"IPPROTO_MHRP", Const, 0},
{"IPPROTO_MICP", Const, 0},
{"IPPROTO_MOBILE", Const, 0},
{"IPPROTO_MPLS", Const, 1},
{"IPPROTO_MTP", Const, 0},
{"IPPROTO_MUX", Const, 0},
{"IPPROTO_ND", Const, 0},
{"IPPROTO_NHRP", Const, 0},
{"IPPROTO_NONE", Const, 0},
{"IPPROTO_NSP", Const, 0},
{"IPPROTO_NVPII", Const, 0},
{"IPPROTO_OLD_DIVERT", Const, 0},
{"IPPROTO_OSPFIGP", Const, 0},
{"IPPROTO_PFSYNC", Const, 0},
{"IPPROTO_PGM", Const, 0},
{"IPPROTO_PIGP", Const, 0},
{"IPPROTO_PIM", Const, 0},
{"IPPROTO_PRM", Const, 0},
{"IPPROTO_PUP", Const, 0},
{"IPPROTO_PVP", Const, 0},
{"IPPROTO_RAW", Const, 0},
{"IPPROTO_RCCMON", Const, 0},
{"IPPROTO_RDP", Const, 0},
{"IPPROTO_ROUTING", Const, 0},
{"IPPROTO_RSVP", Const, 0},
{"IPPROTO_RVD", Const, 0},
{"IPPROTO_SATEXPAK", Const, 0},
{"IPPROTO_SATMON", Const, 0},
{"IPPROTO_SCCSP", Const, 0},
{"IPPROTO_SCTP", Const, 0},
{"IPPROTO_SDRP", Const, 0},
{"IPPROTO_SEND", Const, 1},
{"IPPROTO_SEP", Const, 0},
{"IPPROTO_SKIP", Const, 0},
{"IPPROTO_SPACER", Const, 0},
{"IPPROTO_SRPC", Const, 0},
{"IPPROTO_ST", Const, 0},
{"IPPROTO_SVMTP", Const, 0},
{"IPPROTO_SWIPE", Const, 0},
{"IPPROTO_TCF", Const, 0},
{"IPPROTO_TCP", Const, 0},
{"IPPROTO_TLSP", Const, 0},
{"IPPROTO_TP", Const, 0},
{"IPPROTO_TPXX", Const, 0},
{"IPPROTO_TRUNK1", Const, 0},
{"IPPROTO_TRUNK2", Const, 0},
{"IPPROTO_TTP", Const, 0},
{"IPPROTO_UDP", Const, 0},
{"IPPROTO_UDPLITE", Const, 0},
{"IPPROTO_VINES", Const, 0},
{"IPPROTO_VISA", Const, 0},
{"IPPROTO_VMTP", Const, 0},
{"IPPROTO_VRRP", Const, 1},
{"IPPROTO_WBEXPAK", Const, 0},
{"IPPROTO_WBMON", Const, 0},
{"IPPROTO_WSN", Const, 0},
{"IPPROTO_XNET", Const, 0},
{"IPPROTO_XTP", Const, 0},
{"IPV6_2292DSTOPTS", Const, 0},
{"IPV6_2292HOPLIMIT", Const, 0},
{"IPV6_2292HOPOPTS", Const, 0},
{"IPV6_2292NEXTHOP", Const, 0},
{"IPV6_2292PKTINFO", Const, 0},
{"IPV6_2292PKTOPTIONS", Const, 0},
{"IPV6_2292RTHDR", Const, 0},
{"IPV6_ADDRFORM", Const, 0},
{"IPV6_ADD_MEMBERSHIP", Const, 0},
{"IPV6_AUTHHDR", Const, 0},
{"IPV6_AUTH_LEVEL", Const, 1},
{"IPV6_AUTOFLOWLABEL", Const, 0},
{"IPV6_BINDANY", Const, 0},
{"IPV6_BINDV6ONLY", Const, 0},
{"IPV6_BOUND_IF", Const, 0},
{"IPV6_CHECKSUM", Const, 0},
{"IPV6_DEFAULT_MULTICAST_HOPS", Const, 0},
{"IPV6_DEFAULT_MULTICAST_LOOP", Const, 0},
{"IPV6_DEFHLIM", Const, 0},
{"IPV6_DONTFRAG", Const, 0},
{"IPV6_DROP_MEMBERSHIP", Const, 0},
{"IPV6_DSTOPTS", Const, 0},
{"IPV6_ESP_NETWORK_LEVEL", Const, 1},
{"IPV6_ESP_TRANS_LEVEL", Const, 1},
{"IPV6_FAITH", Const, 0},
{"IPV6_FLOWINFO_MASK", Const, 0},
{"IPV6_FLOWLABEL_MASK", Const, 0},
{"IPV6_FRAGTTL", Const, 0},
{"IPV6_FW_ADD", Const, 0},
{"IPV6_FW_DEL", Const, 0},
{"IPV6_FW_FLUSH", Const, 0},
{"IPV6_FW_GET", Const, 0},
{"IPV6_FW_ZERO", Const, 0},
{"IPV6_HLIMDEC", Const, 0},
{"IPV6_HOPLIMIT", Const, 0},
{"IPV6_HOPOPTS", Const, 0},
{"IPV6_IPCOMP_LEVEL", Const, 1},
{"IPV6_IPSEC_POLICY", Const, 0},
{"IPV6_JOIN_ANYCAST", Const, 0},
{"IPV6_JOIN_GROUP", Const, 0},
{"IPV6_LEAVE_ANYCAST", Const, 0},
{"IPV6_LEAVE_GROUP", Const, 0},
{"IPV6_MAXHLIM", Const, 0},
{"IPV6_MAXOPTHDR", Const, 0},
{"IPV6_MAXPACKET", Const, 0},
{"IPV6_MAX_GROUP_SRC_FILTER", Const, 0},
{"IPV6_MAX_MEMBERSHIPS", Const, 0},
{"IPV6_MAX_SOCK_SRC_FILTER", Const, 0},
{"IPV6_MIN_MEMBERSHIPS", Const, 0},
{"IPV6_MMTU", Const, 0},
{"IPV6_MSFILTER", Const, 0},
{"IPV6_MTU", Const, 0},
{"IPV6_MTU_DISCOVER", Const, 0},
{"IPV6_MULTICAST_HOPS", Const, 0},
{"IPV6_MULTICAST_IF", Const, 0},
{"IPV6_MULTICAST_LOOP", Const, 0},
{"IPV6_NEXTHOP", Const, 0},
{"IPV6_OPTIONS", Const, 1},
{"IPV6_PATHMTU", Const, 0},
{"IPV6_PIPEX", Const, 1},
{"IPV6_PKTINFO", Const, 0},
{"IPV6_PMTUDISC_DO", Const, 0},
{"IPV6_PMTUDISC_DONT", Const, 0},
{"IPV6_PMTUDISC_PROBE", Const, 0},
{"IPV6_PMTUDISC_WANT", Const, 0},
{"IPV6_PORTRANGE", Const, 0},
{"IPV6_PORTRANGE_DEFAULT", Const, 0},
{"IPV6_PORTRANGE_HIGH", Const, 0},
{"IPV6_PORTRANGE_LOW", Const, 0},
{"IPV6_PREFER_TEMPADDR", Const, 0},
{"IPV6_RECVDSTOPTS", Const, 0},
{"IPV6_RECVDSTPORT", Const, 3},
{"IPV6_RECVERR", Const, 0},
{"IPV6_RECVHOPLIMIT", Const, 0},
{"IPV6_RECVHOPOPTS", Const, 0},
{"IPV6_RECVPATHMTU", Const, 0},
{"IPV6_RECVPKTINFO", Const, 0},
{"IPV6_RECVRTHDR", Const, 0},
{"IPV6_RECVTCLASS", Const, 0},
{"IPV6_ROUTER_ALERT", Const, 0},
{"IPV6_RTABLE", Const, 1},
{"IPV6_RTHDR", Const, 0},
{"IPV6_RTHDRDSTOPTS", Const, 0},
{"IPV6_RTHDR_LOOSE", Const, 0},
{"IPV6_RTHDR_STRICT", Const, 0},
{"IPV6_RTHDR_TYPE_0", Const, 0},
{"IPV6_RXDSTOPTS", Const, 0},
{"IPV6_RXHOPOPTS", Const, 0},
{"IPV6_SOCKOPT_RESERVED1", Const, 0},
{"IPV6_TCLASS", Const, 0},
{"IPV6_UNICAST_HOPS", Const, 0},
{"IPV6_USE_MIN_MTU", Const, 0},
{"IPV6_V6ONLY", Const, 0},
{"IPV6_VERSION", Const, 0},
{"IPV6_VERSION_MASK", Const, 0},
{"IPV6_XFRM_POLICY", Const, 0},
{"IP_ADD_MEMBERSHIP", Const, 0},
{"IP_ADD_SOURCE_MEMBERSHIP", Const, 0},
{"IP_AUTH_LEVEL", Const, 1},
{"IP_BINDANY", Const, 0},
{"IP_BLOCK_SOURCE", Const, 0},
{"IP_BOUND_IF", Const, 0},
{"IP_DEFAULT_MULTICAST_LOOP", Const, 0},
{"IP_DEFAULT_MULTICAST_TTL", Const, 0},
{"IP_DF", Const, 0},
{"IP_DIVERTFL", Const, 3},
{"IP_DONTFRAG", Const, 0},
{"IP_DROP_MEMBERSHIP", Const, 0},
{"IP_DROP_SOURCE_MEMBERSHIP", Const, 0},
{"IP_DUMMYNET3", Const, 0},
{"IP_DUMMYNET_CONFIGURE", Const, 0},
{"IP_DUMMYNET_DEL", Const, 0},
{"IP_DUMMYNET_FLUSH", Const, 0},
{"IP_DUMMYNET_GET", Const, 0},
{"IP_EF", Const, 1},
{"IP_ERRORMTU", Const, 1},
{"IP_ESP_NETWORK_LEVEL", Const, 1},
{"IP_ESP_TRANS_LEVEL", Const, 1},
{"IP_FAITH", Const, 0},
{"IP_FREEBIND", Const, 0},
{"IP_FW3", Const, 0},
{"IP_FW_ADD", Const, 0},
{"IP_FW_DEL", Const, 0},
{"IP_FW_FLUSH", Const, 0},
{"IP_FW_GET", Const, 0},
{"IP_FW_NAT_CFG", Const, 0},
{"IP_FW_NAT_DEL", Const, 0},
{"IP_FW_NAT_GET_CONFIG", Const, 0},
{"IP_FW_NAT_GET_LOG", Const, 0},
{"IP_FW_RESETLOG", Const, 0},
{"IP_FW_TABLE_ADD", Const, 0},
{"IP_FW_TABLE_DEL", Const, 0},
{"IP_FW_TABLE_FLUSH", Const, 0},
{"IP_FW_TABLE_GETSIZE", Const, 0},
{"IP_FW_TABLE_LIST", Const, 0},
{"IP_FW_ZERO", Const, 0},
{"IP_HDRINCL", Const, 0},
{"IP_IPCOMP_LEVEL", Const, 1},
{"IP_IPSECFLOWINFO", Const, 1},
{"IP_IPSEC_LOCAL_AUTH", Const, 1},
{"IP_IPSEC_LOCAL_CRED", Const, 1},
{"IP_IPSEC_LOCAL_ID", Const, 1},
{"IP_IPSEC_POLICY", Const, 0},
{"IP_IPSEC_REMOTE_AUTH", Const, 1},
{"IP_IPSEC_REMOTE_CRED", Const, 1},
{"IP_IPSEC_REMOTE_ID", Const, 1},
{"IP_MAXPACKET", Const, 0},
{"IP_MAX_GROUP_SRC_FILTER", Const, 0},
{"IP_MAX_MEMBERSHIPS", Const, 0},
{"IP_MAX_SOCK_MUTE_FILTER", Const, 0},
{"IP_MAX_SOCK_SRC_FILTER", Const, 0},
{"IP_MAX_SOURCE_FILTER", Const, 0},
{"IP_MF", Const, 0},
{"IP_MINFRAGSIZE", Const, 1},
{"IP_MINTTL", Const, 0},
{"IP_MIN_MEMBERSHIPS", Const, 0},
{"IP_MSFILTER", Const, 0},
{"IP_MSS", Const, 0},
{"IP_MTU", Const, 0},
{"IP_MTU_DISCOVER", Const, 0},
{"IP_MULTICAST_IF", Const, 0},
{"IP_MULTICAST_IFINDEX", Const, 0},
{"IP_MULTICAST_LOOP", Const, 0},
{"IP_MULTICAST_TTL", Const, 0},
{"IP_MULTICAST_VIF", Const, 0},
{"IP_NAT__XXX", Const, 0},
{"IP_OFFMASK", Const, 0},
{"IP_OLD_FW_ADD", Const, 0},
{"IP_OLD_FW_DEL", Const, 0},
{"IP_OLD_FW_FLUSH", Const, 0},
{"IP_OLD_FW_GET", Const, 0},
{"IP_OLD_FW_RESETLOG", Const, 0},
{"IP_OLD_FW_ZERO", Const, 0},
{"IP_ONESBCAST", Const, 0},
{"IP_OPTIONS", Const, 0},
{"IP_ORIGDSTADDR", Const, 0},
{"IP_PASSSEC", Const, 0},
{"IP_PIPEX", Const, 1},
{"IP_PKTINFO", Const, 0},
{"IP_PKTOPTIONS", Const, 0},
{"IP_PMTUDISC", Const, 0},
{"IP_PMTUDISC_DO", Const, 0},
{"IP_PMTUDISC_DONT", Const, 0},
{"IP_PMTUDISC_PROBE", Const, 0},
{"IP_PMTUDISC_WANT", Const, 0},
{"IP_PORTRANGE", Const, 0},
{"IP_PORTRANGE_DEFAULT", Const, 0},
{"IP_PORTRANGE_HIGH", Const, 0},
{"IP_PORTRANGE_LOW", Const, 0},
{"IP_RECVDSTADDR", Const, 0},
{"IP_RECVDSTPORT", Const, 1},
{"IP_RECVERR", Const, 0},
{"IP_RECVIF", Const, 0},
{"IP_RECVOPTS", Const, 0},
{"IP_RECVORIGDSTADDR", Const, 0},
{"IP_RECVPKTINFO", Const, 0},
{"IP_RECVRETOPTS", Const, 0},
{"IP_RECVRTABLE", Const, 1},
{"IP_RECVTOS", Const, 0},
{"IP_RECVTTL", Const, 0},
{"IP_RETOPTS", Const, 0},
{"IP_RF", Const, 0},
{"IP_ROUTER_ALERT", Const, 0},
{"IP_RSVP_OFF", Const, 0},
{"IP_RSVP_ON", Const, 0},
{"IP_RSVP_VIF_OFF", Const, 0},
{"IP_RSVP_VIF_ON", Const, 0},
{"IP_RTABLE", Const, 1},
{"IP_SENDSRCADDR", Const, 0},
{"IP_STRIPHDR", Const, 0},
{"IP_TOS", Const, 0},
{"IP_TRAFFIC_MGT_BACKGROUND", Const, 0},
{"IP_TRANSPARENT", Const, 0},
{"IP_TTL", Const, 0},
{"IP_UNBLOCK_SOURCE", Const, 0},
{"IP_XFRM_POLICY", Const, 0},
{"IPv6MTUInfo", Type, 2},
{"IPv6MTUInfo.Addr", Field, 2},
{"IPv6MTUInfo.Mtu", Field, 2},
{"IPv6Mreq", Type, 0},
{"IPv6Mreq.Interface", Field, 0},
{"IPv6Mreq.Multiaddr", Field, 0},
{"ISIG", Const, 0},
{"ISTRIP", Const, 0},
{"IUCLC", Const, 0},
{"IUTF8", Const, 0},
{"IXANY", Const, 0},
{"IXOFF", Const, 0},
{"IXON", Const, 0},
{"IfAddrmsg", Type, 0},
{"IfAddrmsg.Family", Field, 0},
{"IfAddrmsg.Flags", Field, 0},
{"IfAddrmsg.Index", Field, 0},
{"IfAddrmsg.Prefixlen", Field, 0},
{"IfAddrmsg.Scope", Field, 0},
{"IfAnnounceMsghdr", Type, 1},
{"IfAnnounceMsghdr.Hdrlen", Field, 2},
{"IfAnnounceMsghdr.Index", Field, 1},
{"IfAnnounceMsghdr.Msglen", Field, 1},
{"IfAnnounceMsghdr.Name", Field, 1},
{"IfAnnounceMsghdr.Type", Field, 1},
{"IfAnnounceMsghdr.Version", Field, 1},
{"IfAnnounceMsghdr.What", Field, 1},
{"IfData", Type, 0},
{"IfData.Addrlen", Field, 0},
{"IfData.Baudrate", Field, 0},
{"IfData.Capabilities", Field, 2},
{"IfData.Collisions", Field, 0},
{"IfData.Datalen", Field, 0},
{"IfData.Epoch", Field, 0},
{"IfData.Hdrlen", Field, 0},
{"IfData.Hwassist", Field, 0},
{"IfData.Ibytes", Field, 0},
{"IfData.Ierrors", Field, 0},
{"IfData.Imcasts", Field, 0},
{"IfData.Ipackets", Field, 0},
{"IfData.Iqdrops", Field, 0},
{"IfData.Lastchange", Field, 0},
{"IfData.Link_state", Field, 0},
{"IfData.Mclpool", Field, 2},
{"IfData.Metric", Field, 0},
{"IfData.Mtu", Field, 0},
{"IfData.Noproto", Field, 0},
{"IfData.Obytes", Field, 0},
{"IfData.Oerrors", Field, 0},
{"IfData.Omcasts", Field, 0},
{"IfData.Opackets", Field, 0},
{"IfData.Pad", Field, 2},
{"IfData.Pad_cgo_0", Field, 2},
{"IfData.Pad_cgo_1", Field, 2},
{"IfData.Physical", Field, 0},
{"IfData.Recvquota", Field, 0},
{"IfData.Recvtiming", Field, 0},
{"IfData.Reserved1", Field, 0},
{"IfData.Reserved2", Field, 0},
{"IfData.Spare_char1", Field, 0},
{"IfData.Spare_char2", Field, 0},
{"IfData.Type", Field, 0},
{"IfData.Typelen", Field, 0},
{"IfData.Unused1", Field, 0},
{"IfData.Unused2", Field, 0},
{"IfData.Xmitquota", Field, 0},
{"IfData.Xmittiming", Field, 0},
{"IfInfomsg", Type, 0},
{"IfInfomsg.Change", Field, 0},
{"IfInfomsg.Family", Field, 0},
{"IfInfomsg.Flags", Field, 0},
{"IfInfomsg.Index", Field, 0},
{"IfInfomsg.Type", Field, 0},
{"IfInfomsg.X__ifi_pad", Field, 0},
{"IfMsghdr", Type, 0},
{"IfMsghdr.Addrs", Field, 0},
{"IfMsghdr.Data", Field, 0},
{"IfMsghdr.Flags", Field, 0},
{"IfMsghdr.Hdrlen", Field, 2},
{"IfMsghdr.Index", Field, 0},
{"IfMsghdr.Msglen", Field, 0},
{"IfMsghdr.Pad1", Field, 2},
{"IfMsghdr.Pad2", Field, 2},
{"IfMsghdr.Pad_cgo_0", Field, 0},
{"IfMsghdr.Pad_cgo_1", Field, 2},
{"IfMsghdr.Tableid", Field, 2},
{"IfMsghdr.Type", Field, 0},
{"IfMsghdr.Version", Field, 0},
{"IfMsghdr.Xflags", Field, 2},
{"IfaMsghdr", Type, 0},
{"IfaMsghdr.Addrs", Field, 0},
{"IfaMsghdr.Flags", Field, 0},
{"IfaMsghdr.Hdrlen", Field, 2},
{"IfaMsghdr.Index", Field, 0},
{"IfaMsghdr.Metric", Field, 0},
{"IfaMsghdr.Msglen", Field, 0},
{"IfaMsghdr.Pad1", Field, 2},
{"IfaMsghdr.Pad2", Field, 2},
{"IfaMsghdr.Pad_cgo_0", Field, 0},
{"IfaMsghdr.Tableid", Field, 2},
{"IfaMsghdr.Type", Field, 0},
{"IfaMsghdr.Version", Field, 0},
{"IfmaMsghdr", Type, 0},
{"IfmaMsghdr.Addrs", Field, 0},
{"IfmaMsghdr.Flags", Field, 0},
{"IfmaMsghdr.Index", Field, 0},
{"IfmaMsghdr.Msglen", Field, 0},
{"IfmaMsghdr.Pad_cgo_0", Field, 0},
{"IfmaMsghdr.Type", Field, 0},
{"IfmaMsghdr.Version", Field, 0},
{"IfmaMsghdr2", Type, 0},
{"IfmaMsghdr2.Addrs", Field, 0},
{"IfmaMsghdr2.Flags", Field, 0},
{"IfmaMsghdr2.Index", Field, 0},
{"IfmaMsghdr2.Msglen", Field, 0},
{"IfmaMsghdr2.Pad_cgo_0", Field, 0},
{"IfmaMsghdr2.Refcount", Field, 0},
{"IfmaMsghdr2.Type", Field, 0},
{"IfmaMsghdr2.Version", Field, 0},
{"ImplementsGetwd", Const, 0},
{"Inet4Pktinfo", Type, 0},
{"Inet4Pktinfo.Addr", Field, 0},
{"Inet4Pktinfo.Ifindex", Field, 0},
{"Inet4Pktinfo.Spec_dst", Field, 0},
{"Inet6Pktinfo", Type, 0},
{"Inet6Pktinfo.Addr", Field, 0},
{"Inet6Pktinfo.Ifindex", Field, 0},
{"InotifyAddWatch", Func, 0},
{"InotifyEvent", Type, 0},
{"InotifyEvent.Cookie", Field, 0},
{"InotifyEvent.Len", Field, 0},
{"InotifyEvent.Mask", Field, 0},
{"InotifyEvent.Name", Field, 0},
{"InotifyEvent.Wd", Field, 0},
{"InotifyInit", Func, 0},
{"InotifyInit1", Func, 0},
{"InotifyRmWatch", Func, 0},
{"InterfaceAddrMessage", Type, 0},
{"InterfaceAddrMessage.Data", Field, 0},
{"InterfaceAddrMessage.Header", Field, 0},
{"InterfaceAnnounceMessage", Type, 1},
{"InterfaceAnnounceMessage.Header", Field, 1},
{"InterfaceInfo", Type, 0},
{"InterfaceInfo.Address", Field, 0},
{"InterfaceInfo.BroadcastAddress", Field, 0},
{"InterfaceInfo.Flags", Field, 0},
{"InterfaceInfo.Netmask", Field, 0},
{"InterfaceMessage", Type, 0},
{"InterfaceMessage.Data", Field, 0},
{"InterfaceMessage.Header", Field, 0},
{"InterfaceMulticastAddrMessage", Type, 0},
{"InterfaceMulticastAddrMessage.Data", Field, 0},
{"InterfaceMulticastAddrMessage.Header", Field, 0},
{"InvalidHandle", Const, 0},
{"Ioperm", Func, 0},
{"Iopl", Func, 0},
{"Iovec", Type, 0},
{"Iovec.Base", Field, 0},
{"Iovec.Len", Field, 0},
{"IpAdapterInfo", Type, 0},
{"IpAdapterInfo.AdapterName", Field, 0},
{"IpAdapterInfo.Address", Field, 0},
{"IpAdapterInfo.AddressLength", Field, 0},
{"IpAdapterInfo.ComboIndex", Field, 0},
{"IpAdapterInfo.CurrentIpAddress", Field, 0},
{"IpAdapterInfo.Description", Field, 0},
{"IpAdapterInfo.DhcpEnabled", Field, 0},
{"IpAdapterInfo.DhcpServer", Field, 0},
{"IpAdapterInfo.GatewayList", Field, 0},
{"IpAdapterInfo.HaveWins", Field, 0},
{"IpAdapterInfo.Index", Field, 0},
{"IpAdapterInfo.IpAddressList", Field, 0},
{"IpAdapterInfo.LeaseExpires", Field, 0},
{"IpAdapterInfo.LeaseObtained", Field, 0},
{"IpAdapterInfo.Next", Field, 0},
{"IpAdapterInfo.PrimaryWinsServer", Field, 0},
{"IpAdapterInfo.SecondaryWinsServer", Field, 0},
{"IpAdapterInfo.Type", Field, 0},
{"IpAddrString", Type, 0},
{"IpAddrString.Context", Field, 0},
{"IpAddrString.IpAddress", Field, 0},
{"IpAddrString.IpMask", Field, 0},
{"IpAddrString.Next", Field, 0},
{"IpAddressString", Type, 0},
{"IpAddressString.String", Field, 0},
{"IpMaskString", Type, 0},
{"IpMaskString.String", Field, 2},
{"Issetugid", Func, 0},
{"KEY_ALL_ACCESS", Const, 0},
{"KEY_CREATE_LINK", Const, 0},
{"KEY_CREATE_SUB_KEY", Const, 0},
{"KEY_ENUMERATE_SUB_KEYS", Const, 0},
{"KEY_EXECUTE", Const, 0},
{"KEY_NOTIFY", Const, 0},
{"KEY_QUERY_VALUE", Const, 0},
{"KEY_READ", Const, 0},
{"KEY_SET_VALUE", Const, 0},
{"KEY_WOW64_32KEY", Const, 0},
{"KEY_WOW64_64KEY", Const, 0},
{"KEY_WRITE", Const, 0},
{"Kevent", Func, 0},
{"Kevent_t", Type, 0},
{"Kevent_t.Data", Field, 0},
{"Kevent_t.Fflags", Field, 0},
{"Kevent_t.Filter", Field, 0},
{"Kevent_t.Flags", Field, 0},
{"Kevent_t.Ident", Field, 0},
{"Kevent_t.Pad_cgo_0", Field, 2},
{"Kevent_t.Udata", Field, 0},
{"Kill", Func, 0},
{"Klogctl", Func, 0},
{"Kqueue", Func, 0},
{"LANG_ENGLISH", Const, 0},
{"LAYERED_PROTOCOL", Const, 2},
{"LCNT_OVERLOAD_FLUSH", Const, 1},
{"LINUX_REBOOT_CMD_CAD_OFF", Const, 0},
{"LINUX_REBOOT_CMD_CAD_ON", Const, 0},
{"LINUX_REBOOT_CMD_HALT", Const, 0},
{"LINUX_REBOOT_CMD_KEXEC", Const, 0},
{"LINUX_REBOOT_CMD_POWER_OFF", Const, 0},
{"LINUX_REBOOT_CMD_RESTART", Const, 0},
{"LINUX_REBOOT_CMD_RESTART2", Const, 0},
{"LINUX_REBOOT_CMD_SW_SUSPEND", Const, 0},
{"LINUX_REBOOT_MAGIC1", Const, 0},
{"LINUX_REBOOT_MAGIC2", Const, 0},
{"LOCK_EX", Const, 0},
{"LOCK_NB", Const, 0},
{"LOCK_SH", Const, 0},
{"LOCK_UN", Const, 0},
{"LazyDLL", Type, 0},
{"LazyDLL.Name", Field, 0},
{"LazyProc", Type, 0},
{"LazyProc.Name", Field, 0},
{"Lchown", Func, 0},
{"Linger", Type, 0},
{"Linger.Linger", Field, 0},
{"Linger.Onoff", Field, 0},
{"Link", Func, 0},
{"Listen", Func, 0},
{"Listxattr", Func, 1},
{"LoadCancelIoEx", Func, 1},
{"LoadConnectEx", Func, 1},
{"LoadCreateSymbolicLink", Func, 4},
{"LoadDLL", Func, 0},
{"LoadGetAddrInfo", Func, 1},
{"LoadLibrary", Func, 0},
{"LoadSetFileCompletionNotificationModes", Func, 2},
{"LocalFree", Func, 0},
{"Log2phys_t", Type, 0},
{"Log2phys_t.Contigbytes", Field, 0},
{"Log2phys_t.Devoffset", Field, 0},
{"Log2phys_t.Flags", Field, 0},
{"LookupAccountName", Func, 0},
{"LookupAccountSid", Func, 0},
{"LookupSID", Func, 0},
{"LsfJump", Func, 0},
{"LsfSocket", Func, 0},
{"LsfStmt", Func, 0},
{"Lstat", Func, 0},
{"MADV_AUTOSYNC", Const, 1},
{"MADV_CAN_REUSE", Const, 0},
{"MADV_CORE", Const, 1},
{"MADV_DOFORK", Const, 0},
{"MADV_DONTFORK", Const, 0},
{"MADV_DONTNEED", Const, 0},
{"MADV_FREE", Const, 0},
{"MADV_FREE_REUSABLE", Const, 0},
{"MADV_FREE_REUSE", Const, 0},
{"MADV_HUGEPAGE", Const, 0},
{"MADV_HWPOISON", Const, 0},
{"MADV_MERGEABLE", Const, 0},
{"MADV_NOCORE", Const, 1},
{"MADV_NOHUGEPAGE", Const, 0},
{"MADV_NORMAL", Const, 0},
{"MADV_NOSYNC", Const, 1},
{"MADV_PROTECT", Const, 1},
{"MADV_RANDOM", Const, 0},
{"MADV_REMOVE", Const, 0},
{"MADV_SEQUENTIAL", Const, 0},
{"MADV_SPACEAVAIL", Const, 3},
{"MADV_UNMERGEABLE", Const, 0},
{"MADV_WILLNEED", Const, 0},
{"MADV_ZERO_WIRED_PAGES", Const, 0},
{"MAP_32BIT", Const, 0},
{"MAP_ALIGNED_SUPER", Const, 3},
{"MAP_ALIGNMENT_16MB", Const, 3},
{"MAP_ALIGNMENT_1TB", Const, 3},
{"MAP_ALIGNMENT_256TB", Const, 3},
{"MAP_ALIGNMENT_4GB", Const, 3},
{"MAP_ALIGNMENT_64KB", Const, 3},
{"MAP_ALIGNMENT_64PB", Const, 3},
{"MAP_ALIGNMENT_MASK", Const, 3},
{"MAP_ALIGNMENT_SHIFT", Const, 3},
{"MAP_ANON", Const, 0},
{"MAP_ANONYMOUS", Const, 0},
{"MAP_COPY", Const, 0},
{"MAP_DENYWRITE", Const, 0},
{"MAP_EXECUTABLE", Const, 0},
{"MAP_FILE", Const, 0},
{"MAP_FIXED", Const, 0},
{"MAP_FLAGMASK", Const, 3},
{"MAP_GROWSDOWN", Const, 0},
{"MAP_HASSEMAPHORE", Const, 0},
{"MAP_HUGETLB", Const, 0},
{"MAP_INHERIT", Const, 3},
{"MAP_INHERIT_COPY", Const, 3},
{"MAP_INHERIT_DEFAULT", Const, 3},
{"MAP_INHERIT_DONATE_COPY", Const, 3},
{"MAP_INHERIT_NONE", Const, 3},
{"MAP_INHERIT_SHARE", Const, 3},
{"MAP_JIT", Const, 0},
{"MAP_LOCKED", Const, 0},
{"MAP_NOCACHE", Const, 0},
{"MAP_NOCORE", Const, 1},
{"MAP_NOEXTEND", Const, 0},
{"MAP_NONBLOCK", Const, 0},
{"MAP_NORESERVE", Const, 0},
{"MAP_NOSYNC", Const, 1},
{"MAP_POPULATE", Const, 0},
{"MAP_PREFAULT_READ", Const, 1},
{"MAP_PRIVATE", Const, 0},
{"MAP_RENAME", Const, 0},
{"MAP_RESERVED0080", Const, 0},
{"MAP_RESERVED0100", Const, 1},
{"MAP_SHARED", Const, 0},
{"MAP_STACK", Const, 0},
{"MAP_TRYFIXED", Const, 3},
{"MAP_TYPE", Const, 0},
{"MAP_WIRED", Const, 3},
{"MAXIMUM_REPARSE_DATA_BUFFER_SIZE", Const, 4},
{"MAXLEN_IFDESCR", Const, 0},
{"MAXLEN_PHYSADDR", Const, 0},
{"MAX_ADAPTER_ADDRESS_LENGTH", Const, 0},
{"MAX_ADAPTER_DESCRIPTION_LENGTH", Const, 0},
{"MAX_ADAPTER_NAME_LENGTH", Const, 0},
{"MAX_COMPUTERNAME_LENGTH", Const, 0},
{"MAX_INTERFACE_NAME_LEN", Const, 0},
{"MAX_LONG_PATH", Const, 0},
{"MAX_PATH", Const, 0},
{"MAX_PROTOCOL_CHAIN", Const, 2},
{"MCL_CURRENT", Const, 0},
{"MCL_FUTURE", Const, 0},
{"MNT_DETACH", Const, 0},
{"MNT_EXPIRE", Const, 0},
{"MNT_FORCE", Const, 0},
{"MSG_BCAST", Const, 1},
{"MSG_CMSG_CLOEXEC", Const, 0},
{"MSG_COMPAT", Const, 0},
{"MSG_CONFIRM", Const, 0},
{"MSG_CONTROLMBUF", Const, 1},
{"MSG_CTRUNC", Const, 0},
{"MSG_DONTROUTE", Const, 0},
{"MSG_DONTWAIT", Const, 0},
{"MSG_EOF", Const, 0},
{"MSG_EOR", Const, 0},
{"MSG_ERRQUEUE", Const, 0},
{"MSG_FASTOPEN", Const, 1},
{"MSG_FIN", Const, 0},
{"MSG_FLUSH", Const, 0},
{"MSG_HAVEMORE", Const, 0},
{"MSG_HOLD", Const, 0},
{"MSG_IOVUSRSPACE", Const, 1},
{"MSG_LENUSRSPACE", Const, 1},
{"MSG_MCAST", Const, 1},
{"MSG_MORE", Const, 0},
{"MSG_NAMEMBUF", Const, 1},
{"MSG_NBIO", Const, 0},
{"MSG_NEEDSA", Const, 0},
{"MSG_NOSIGNAL", Const, 0},
{"MSG_NOTIFICATION", Const, 0},
{"MSG_OOB", Const, 0},
{"MSG_PEEK", Const, 0},
{"MSG_PROXY", Const, 0},
{"MSG_RCVMORE", Const, 0},
{"MSG_RST", Const, 0},
{"MSG_SEND", Const, 0},
{"MSG_SYN", Const, 0},
{"MSG_TRUNC", Const, 0},
{"MSG_TRYHARD", Const, 0},
{"MSG_USERFLAGS", Const, 1},
{"MSG_WAITALL", Const, 0},
{"MSG_WAITFORONE", Const, 0},
{"MSG_WAITSTREAM", Const, 0},
{"MS_ACTIVE", Const, 0},
{"MS_ASYNC", Const, 0},
{"MS_BIND", Const, 0},
{"MS_DEACTIVATE", Const, 0},
{"MS_DIRSYNC", Const, 0},
{"MS_INVALIDATE", Const, 0},
{"MS_I_VERSION", Const, 0},
{"MS_KERNMOUNT", Const, 0},
{"MS_KILLPAGES", Const, 0},
{"MS_MANDLOCK", Const, 0},
{"MS_MGC_MSK", Const, 0},
{"MS_MGC_VAL", Const, 0},
{"MS_MOVE", Const, 0},
{"MS_NOATIME", Const, 0},
{"MS_NODEV", Const, 0},
{"MS_NODIRATIME", Const, 0},
{"MS_NOEXEC", Const, 0},
{"MS_NOSUID", Const, 0},
{"MS_NOUSER", Const, 0},
{"MS_POSIXACL", Const, 0},
{"MS_PRIVATE", Const, 0},
{"MS_RDONLY", Const, 0},
{"MS_REC", Const, 0},
{"MS_RELATIME", Const, 0},
{"MS_REMOUNT", Const, 0},
{"MS_RMT_MASK", Const, 0},
{"MS_SHARED", Const, 0},
{"MS_SILENT", Const, 0},
{"MS_SLAVE", Const, 0},
{"MS_STRICTATIME", Const, 0},
{"MS_SYNC", Const, 0},
{"MS_SYNCHRONOUS", Const, 0},
{"MS_UNBINDABLE", Const, 0},
{"Madvise", Func, 0},
{"MapViewOfFile", Func, 0},
{"MaxTokenInfoClass", Const, 0},
{"Mclpool", Type, 2},
{"Mclpool.Alive", Field, 2},
{"Mclpool.Cwm", Field, 2},
{"Mclpool.Grown", Field, 2},
{"Mclpool.Hwm", Field, 2},
{"Mclpool.Lwm", Field, 2},
{"MibIfRow", Type, 0},
{"MibIfRow.AdminStatus", Field, 0},
{"MibIfRow.Descr", Field, 0},
{"MibIfRow.DescrLen", Field, 0},
{"MibIfRow.InDiscards", Field, 0},
{"MibIfRow.InErrors", Field, 0},
{"MibIfRow.InNUcastPkts", Field, 0},
{"MibIfRow.InOctets", Field, 0},
{"MibIfRow.InUcastPkts", Field, 0},
{"MibIfRow.InUnknownProtos", Field, 0},
{"MibIfRow.Index", Field, 0},
{"MibIfRow.LastChange", Field, 0},
{"MibIfRow.Mtu", Field, 0},
{"MibIfRow.Name", Field, 0},
{"MibIfRow.OperStatus", Field, 0},
{"MibIfRow.OutDiscards", Field, 0},
{"MibIfRow.OutErrors", Field, 0},
{"MibIfRow.OutNUcastPkts", Field, 0},
{"MibIfRow.OutOctets", Field, 0},
{"MibIfRow.OutQLen", Field, 0},
{"MibIfRow.OutUcastPkts", Field, 0},
{"MibIfRow.PhysAddr", Field, 0},
{"MibIfRow.PhysAddrLen", Field, 0},
{"MibIfRow.Speed", Field, 0},
{"MibIfRow.Type", Field, 0},
{"Mkdir", Func, 0},
{"Mkdirat", Func, 0},
{"Mkfifo", Func, 0},
{"Mknod", Func, 0},
{"Mknodat", Func, 0},
{"Mlock", Func, 0},
{"Mlockall", Func, 0},
{"Mmap", Func, 0},
{"Mount", Func, 0},
{"MoveFile", Func, 0},
{"Mprotect", Func, 0},
{"Msghdr", Type, 0},
{"Msghdr.Control", Field, 0},
{"Msghdr.Controllen", Field, 0},
{"Msghdr.Flags", Field, 0},
{"Msghdr.Iov", Field, 0},
{"Msghdr.Iovlen", Field, 0},
{"Msghdr.Name", Field, 0},
{"Msghdr.Namelen", Field, 0},
{"Msghdr.Pad_cgo_0", Field, 0},
{"Msghdr.Pad_cgo_1", Field, 0},
{"Munlock", Func, 0},
{"Munlockall", Func, 0},
{"Munmap", Func, 0},
{"MustLoadDLL", Func, 0},
{"NAME_MAX", Const, 0},
{"NETLINK_ADD_MEMBERSHIP", Const, 0},
{"NETLINK_AUDIT", Const, 0},
{"NETLINK_BROADCAST_ERROR", Const, 0},
{"NETLINK_CONNECTOR", Const, 0},
{"NETLINK_DNRTMSG", Const, 0},
{"NETLINK_DROP_MEMBERSHIP", Const, 0},
{"NETLINK_ECRYPTFS", Const, 0},
{"NETLINK_FIB_LOOKUP", Const, 0},
{"NETLINK_FIREWALL", Const, 0},
{"NETLINK_GENERIC", Const, 0},
{"NETLINK_INET_DIAG", Const, 0},
{"NETLINK_IP6_FW", Const, 0},
{"NETLINK_ISCSI", Const, 0},
{"NETLINK_KOBJECT_UEVENT", Const, 0},
{"NETLINK_NETFILTER", Const, 0},
{"NETLINK_NFLOG", Const, 0},
{"NETLINK_NO_ENOBUFS", Const, 0},
{"NETLINK_PKTINFO", Const, 0},
{"NETLINK_RDMA", Const, 0},
{"NETLINK_ROUTE", Const, 0},
{"NETLINK_SCSITRANSPORT", Const, 0},
{"NETLINK_SELINUX", Const, 0},
{"NETLINK_UNUSED", Const, 0},
{"NETLINK_USERSOCK", Const, 0},
{"NETLINK_XFRM", Const, 0},
{"NET_RT_DUMP", Const, 0},
{"NET_RT_DUMP2", Const, 0},
{"NET_RT_FLAGS", Const, 0},
{"NET_RT_IFLIST", Const, 0},
{"NET_RT_IFLIST2", Const, 0},
{"NET_RT_IFLISTL", Const, 1},
{"NET_RT_IFMALIST", Const, 0},
{"NET_RT_MAXID", Const, 0},
{"NET_RT_OIFLIST", Const, 1},
{"NET_RT_OOIFLIST", Const, 1},
{"NET_RT_STAT", Const, 0},
{"NET_RT_STATS", Const, 1},
{"NET_RT_TABLE", Const, 1},
{"NET_RT_TRASH", Const, 0},
{"NLA_ALIGNTO", Const, 0},
{"NLA_F_NESTED", Const, 0},
{"NLA_F_NET_BYTEORDER", Const, 0},
{"NLA_HDRLEN", Const, 0},
{"NLMSG_ALIGNTO", Const, 0},
{"NLMSG_DONE", Const, 0},
{"NLMSG_ERROR", Const, 0},
{"NLMSG_HDRLEN", Const, 0},
{"NLMSG_MIN_TYPE", Const, 0},
{"NLMSG_NOOP", Const, 0},
{"NLMSG_OVERRUN", Const, 0},
{"NLM_F_ACK", Const, 0},
{"NLM_F_APPEND", Const, 0},
{"NLM_F_ATOMIC", Const, 0},
{"NLM_F_CREATE", Const, 0},
{"NLM_F_DUMP", Const, 0},
{"NLM_F_ECHO", Const, 0},
{"NLM_F_EXCL", Const, 0},
{"NLM_F_MATCH", Const, 0},
{"NLM_F_MULTI", Const, 0},
{"NLM_F_REPLACE", Const, 0},
{"NLM_F_REQUEST", Const, 0},
{"NLM_F_ROOT", Const, 0},
{"NOFLSH", Const, 0},
{"NOTE_ABSOLUTE", Const, 0},
{"NOTE_ATTRIB", Const, 0},
{"NOTE_BACKGROUND", Const, 16},
{"NOTE_CHILD", Const, 0},
{"NOTE_CRITICAL", Const, 16},
{"NOTE_DELETE", Const, 0},
{"NOTE_EOF", Const, 1},
{"NOTE_EXEC", Const, 0},
{"NOTE_EXIT", Const, 0},
{"NOTE_EXITSTATUS", Const, 0},
{"NOTE_EXIT_CSERROR", Const, 16},
{"NOTE_EXIT_DECRYPTFAIL", Const, 16},
{"NOTE_EXIT_DETAIL", Const, 16},
{"NOTE_EXIT_DETAIL_MASK", Const, 16},
{"NOTE_EXIT_MEMORY", Const, 16},
{"NOTE_EXIT_REPARENTED", Const, 16},
{"NOTE_EXTEND", Const, 0},
{"NOTE_FFAND", Const, 0},
{"NOTE_FFCOPY", Const, 0},
{"NOTE_FFCTRLMASK", Const, 0},
{"NOTE_FFLAGSMASK", Const, 0},
{"NOTE_FFNOP", Const, 0},
{"NOTE_FFOR", Const, 0},
{"NOTE_FORK", Const, 0},
{"NOTE_LEEWAY", Const, 16},
{"NOTE_LINK", Const, 0},
{"NOTE_LOWAT", Const, 0},
{"NOTE_NONE", Const, 0},
{"NOTE_NSECONDS", Const, 0},
{"NOTE_PCTRLMASK", Const, 0},
{"NOTE_PDATAMASK", Const, 0},
{"NOTE_REAP", Const, 0},
{"NOTE_RENAME", Const, 0},
{"NOTE_RESOURCEEND", Const, 0},
{"NOTE_REVOKE", Const, 0},
{"NOTE_SECONDS", Const, 0},
{"NOTE_SIGNAL", Const, 0},
{"NOTE_TRACK", Const, 0},
{"NOTE_TRACKERR", Const, 0},
{"NOTE_TRIGGER", Const, 0},
{"NOTE_TRUNCATE", Const, 1},
{"NOTE_USECONDS", Const, 0},
{"NOTE_VM_ERROR", Const, 0},
{"NOTE_VM_PRESSURE", Const, 0},
{"NOTE_VM_PRESSURE_SUDDEN_TERMINATE", Const, 0},
{"NOTE_VM_PRESSURE_TERMINATE", Const, 0},
{"NOTE_WRITE", Const, 0},
{"NameCanonical", Const, 0},
{"NameCanonicalEx", Const, 0},
{"NameDisplay", Const, 0},
{"NameDnsDomain", Const, 0},
{"NameFullyQualifiedDN", Const, 0},
{"NameSamCompatible", Const, 0},
{"NameServicePrincipal", Const, 0},
{"NameUniqueId", Const, 0},
{"NameUnknown", Const, 0},
{"NameUserPrincipal", Const, 0},
{"Nanosleep", Func, 0},
{"NetApiBufferFree", Func, 0},
{"NetGetJoinInformation", Func, 2},
{"NetSetupDomainName", Const, 2},
{"NetSetupUnjoined", Const, 2},
{"NetSetupUnknownStatus", Const, 2},
{"NetSetupWorkgroupName", Const, 2},
{"NetUserGetInfo", Func, 0},
{"NetlinkMessage", Type, 0},
{"NetlinkMessage.Data", Field, 0},
{"NetlinkMessage.Header", Field, 0},
{"NetlinkRIB", Func, 0},
{"NetlinkRouteAttr", Type, 0},
{"NetlinkRouteAttr.Attr", Field, 0},
{"NetlinkRouteAttr.Value", Field, 0},
{"NetlinkRouteRequest", Type, 0},
{"NetlinkRouteRequest.Data", Field, 0},
{"NetlinkRouteRequest.Header", Field, 0},
{"NewCallback", Func, 0},
{"NewCallbackCDecl", Func, 3},
{"NewLazyDLL", Func, 0},
{"NlAttr", Type, 0},
{"NlAttr.Len", Field, 0},
{"NlAttr.Type", Field, 0},
{"NlMsgerr", Type, 0},
{"NlMsgerr.Error", Field, 0},
{"NlMsgerr.Msg", Field, 0},
{"NlMsghdr", Type, 0},
{"NlMsghdr.Flags", Field, 0},
{"NlMsghdr.Len", Field, 0},
{"NlMsghdr.Pid", Field, 0},
{"NlMsghdr.Seq", Field, 0},
{"NlMsghdr.Type", Field, 0},
{"NsecToFiletime", Func, 0},
{"NsecToTimespec", Func, 0},
{"NsecToTimeval", Func, 0},
{"Ntohs", Func, 0},
{"OCRNL", Const, 0},
{"OFDEL", Const, 0},
{"OFILL", Const, 0},
{"OFIOGETBMAP", Const, 1},
{"OID_PKIX_KP_SERVER_AUTH", Var, 0},
{"OID_SERVER_GATED_CRYPTO", Var, 0},
{"OID_SGC_NETSCAPE", Var, 0},
{"OLCUC", Const, 0},
{"ONLCR", Const, 0},
{"ONLRET", Const, 0},
{"ONOCR", Const, 0},
{"ONOEOT", Const, 1},
{"OPEN_ALWAYS", Const, 0},
{"OPEN_EXISTING", Const, 0},
{"OPOST", Const, 0},
{"O_ACCMODE", Const, 0},
{"O_ALERT", Const, 0},
{"O_ALT_IO", Const, 1},
{"O_APPEND", Const, 0},
{"O_ASYNC", Const, 0},
{"O_CLOEXEC", Const, 0},
{"O_CREAT", Const, 0},
{"O_DIRECT", Const, 0},
{"O_DIRECTORY", Const, 0},
{"O_DP_GETRAWENCRYPTED", Const, 16},
{"O_DSYNC", Const, 0},
{"O_EVTONLY", Const, 0},
{"O_EXCL", Const, 0},
{"O_EXEC", Const, 0},
{"O_EXLOCK", Const, 0},
{"O_FSYNC", Const, 0},
{"O_LARGEFILE", Const, 0},
{"O_NDELAY", Const, 0},
{"O_NOATIME", Const, 0},
{"O_NOCTTY", Const, 0},
{"O_NOFOLLOW", Const, 0},
{"O_NONBLOCK", Const, 0},
{"O_NOSIGPIPE", Const, 1},
{"O_POPUP", Const, 0},
{"O_RDONLY", Const, 0},
{"O_RDWR", Const, 0},
{"O_RSYNC", Const, 0},
{"O_SHLOCK", Const, 0},
{"O_SYMLINK", Const, 0},
{"O_SYNC", Const, 0},
{"O_TRUNC", Const, 0},
{"O_TTY_INIT", Const, 0},
{"O_WRONLY", Const, 0},
{"Open", Func, 0},
{"OpenCurrentProcessToken", Func, 0},
{"OpenProcess", Func, 0},
{"OpenProcessToken", Func, 0},
{"Openat", Func, 0},
{"Overlapped", Type, 0},
{"Overlapped.HEvent", Field, 0},
{"Overlapped.Internal", Field, 0},
{"Overlapped.InternalHigh", Field, 0},
{"Overlapped.Offset", Field, 0},
{"Overlapped.OffsetHigh", Field, 0},
{"PACKET_ADD_MEMBERSHIP", Const, 0},
{"PACKET_BROADCAST", Const, 0},
{"PACKET_DROP_MEMBERSHIP", Const, 0},
{"PACKET_FASTROUTE", Const, 0},
{"PACKET_HOST", Const, 0},
{"PACKET_LOOPBACK", Const, 0},
{"PACKET_MR_ALLMULTI", Const, 0},
{"PACKET_MR_MULTICAST", Const, 0},
{"PACKET_MR_PROMISC", Const, 0},
{"PACKET_MULTICAST", Const, 0},
{"PACKET_OTHERHOST", Const, 0},
{"PACKET_OUTGOING", Const, 0},
{"PACKET_RECV_OUTPUT", Const, 0},
{"PACKET_RX_RING", Const, 0},
{"PACKET_STATISTICS", Const, 0},
{"PAGE_EXECUTE_READ", Const, 0},
{"PAGE_EXECUTE_READWRITE", Const, 0},
{"PAGE_EXECUTE_WRITECOPY", Const, 0},
{"PAGE_READONLY", Const, 0},
{"PAGE_READWRITE", Const, 0},
{"PAGE_WRITECOPY", Const, 0},
{"PARENB", Const, 0},
{"PARMRK", Const, 0},
{"PARODD", Const, 0},
{"PENDIN", Const, 0},
{"PFL_HIDDEN", Const, 2},
{"PFL_MATCHES_PROTOCOL_ZERO", Const, 2},
{"PFL_MULTIPLE_PROTO_ENTRIES", Const, 2},
{"PFL_NETWORKDIRECT_PROVIDER", Const, 2},
{"PFL_RECOMMENDED_PROTO_ENTRY", Const, 2},
{"PF_FLUSH", Const, 1},
{"PKCS_7_ASN_ENCODING", Const, 0},
{"PMC5_PIPELINE_FLUSH", Const, 1},
{"PRIO_PGRP", Const, 2},
{"PRIO_PROCESS", Const, 2},
{"PRIO_USER", Const, 2},
{"PRI_IOFLUSH", Const, 1},
{"PROCESS_QUERY_INFORMATION", Const, 0},
{"PROCESS_TERMINATE", Const, 2},
{"PROT_EXEC", Const, 0},
{"PROT_GROWSDOWN", Const, 0},
{"PROT_GROWSUP", Const, 0},
{"PROT_NONE", Const, 0},
{"PROT_READ", Const, 0},
{"PROT_WRITE", Const, 0},
{"PROV_DH_SCHANNEL", Const, 0},
{"PROV_DSS", Const, 0},
{"PROV_DSS_DH", Const, 0},
{"PROV_EC_ECDSA_FULL", Const, 0},
{"PROV_EC_ECDSA_SIG", Const, 0},
{"PROV_EC_ECNRA_FULL", Const, 0},
{"PROV_EC_ECNRA_SIG", Const, 0},
{"PROV_FORTEZZA", Const, 0},
{"PROV_INTEL_SEC", Const, 0},
{"PROV_MS_EXCHANGE", Const, 0},
{"PROV_REPLACE_OWF", Const, 0},
{"PROV_RNG", Const, 0},
{"PROV_RSA_AES", Const, 0},
{"PROV_RSA_FULL", Const, 0},
{"PROV_RSA_SCHANNEL", Const, 0},
{"PROV_RSA_SIG", Const, 0},
{"PROV_SPYRUS_LYNKS", Const, 0},
{"PROV_SSL", Const, 0},
{"PR_CAPBSET_DROP", Const, 0},
{"PR_CAPBSET_READ", Const, 0},
{"PR_CLEAR_SECCOMP_FILTER", Const, 0},
{"PR_ENDIAN_BIG", Const, 0},
{"PR_ENDIAN_LITTLE", Const, 0},
{"PR_ENDIAN_PPC_LITTLE", Const, 0},
{"PR_FPEMU_NOPRINT", Const, 0},
{"PR_FPEMU_SIGFPE", Const, 0},
{"PR_FP_EXC_ASYNC", Const, 0},
{"PR_FP_EXC_DISABLED", Const, 0},
{"PR_FP_EXC_DIV", Const, 0},
{"PR_FP_EXC_INV", Const, 0},
{"PR_FP_EXC_NONRECOV", Const, 0},
{"PR_FP_EXC_OVF", Const, 0},
{"PR_FP_EXC_PRECISE", Const, 0},
{"PR_FP_EXC_RES", Const, 0},
{"PR_FP_EXC_SW_ENABLE", Const, 0},
{"PR_FP_EXC_UND", Const, 0},
{"PR_GET_DUMPABLE", Const, 0},
{"PR_GET_ENDIAN", Const, 0},
{"PR_GET_FPEMU", Const, 0},
{"PR_GET_FPEXC", Const, 0},
{"PR_GET_KEEPCAPS", Const, 0},
{"PR_GET_NAME", Const, 0},
{"PR_GET_PDEATHSIG", Const, 0},
{"PR_GET_SECCOMP", Const, 0},
{"PR_GET_SECCOMP_FILTER", Const, 0},
{"PR_GET_SECUREBITS", Const, 0},
{"PR_GET_TIMERSLACK", Const, 0},
{"PR_GET_TIMING", Const, 0},
{"PR_GET_TSC", Const, 0},
{"PR_GET_UNALIGN", Const, 0},
{"PR_MCE_KILL", Const, 0},
{"PR_MCE_KILL_CLEAR", Const, 0},
{"PR_MCE_KILL_DEFAULT", Const, 0},
{"PR_MCE_KILL_EARLY", Const, 0},
{"PR_MCE_KILL_GET", Const, 0},
{"PR_MCE_KILL_LATE", Const, 0},
{"PR_MCE_KILL_SET", Const, 0},
{"PR_SECCOMP_FILTER_EVENT", Const, 0},
{"PR_SECCOMP_FILTER_SYSCALL", Const, 0},
{"PR_SET_DUMPABLE", Const, 0},
{"PR_SET_ENDIAN", Const, 0},
{"PR_SET_FPEMU", Const, 0},
{"PR_SET_FPEXC", Const, 0},
{"PR_SET_KEEPCAPS", Const, 0},
{"PR_SET_NAME", Const, 0},
{"PR_SET_PDEATHSIG", Const, 0},
{"PR_SET_PTRACER", Const, 0},
{"PR_SET_SECCOMP", Const, 0},
{"PR_SET_SECCOMP_FILTER", Const, 0},
{"PR_SET_SECUREBITS", Const, 0},
{"PR_SET_TIMERSLACK", Const, 0},
{"PR_SET_TIMING", Const, 0},
{"PR_SET_TSC", Const, 0},
{"PR_SET_UNALIGN", Const, 0},
{"PR_TASK_PERF_EVENTS_DISABLE", Const, 0},
{"PR_TASK_PERF_EVENTS_ENABLE", Const, 0},
{"PR_TIMING_STATISTICAL", Const, 0},
{"PR_TIMING_TIMESTAMP", Const, 0},
{"PR_TSC_ENABLE", Const, 0},
{"PR_TSC_SIGSEGV", Const, 0},
{"PR_UNALIGN_NOPRINT", Const, 0},
{"PR_UNALIGN_SIGBUS", Const, 0},
{"PTRACE_ARCH_PRCTL", Const, 0},
{"PTRACE_ATTACH", Const, 0},
{"PTRACE_CONT", Const, 0},
{"PTRACE_DETACH", Const, 0},
{"PTRACE_EVENT_CLONE", Const, 0},
{"PTRACE_EVENT_EXEC", Const, 0},
{"PTRACE_EVENT_EXIT", Const, 0},
{"PTRACE_EVENT_FORK", Const, 0},
{"PTRACE_EVENT_VFORK", Const, 0},
{"PTRACE_EVENT_VFORK_DONE", Const, 0},
{"PTRACE_GETCRUNCHREGS", Const, 0},
{"PTRACE_GETEVENTMSG", Const, 0},
{"PTRACE_GETFPREGS", Const, 0},
{"PTRACE_GETFPXREGS", Const, 0},
{"PTRACE_GETHBPREGS", Const, 0},
{"PTRACE_GETREGS", Const, 0},
{"PTRACE_GETREGSET", Const, 0},
{"PTRACE_GETSIGINFO", Const, 0},
{"PTRACE_GETVFPREGS", Const, 0},
{"PTRACE_GETWMMXREGS", Const, 0},
{"PTRACE_GET_THREAD_AREA", Const, 0},
{"PTRACE_KILL", Const, 0},
{"PTRACE_OLDSETOPTIONS", Const, 0},
{"PTRACE_O_MASK", Const, 0},
{"PTRACE_O_TRACECLONE", Const, 0},
{"PTRACE_O_TRACEEXEC", Const, 0},
{"PTRACE_O_TRACEEXIT", Const, 0},
{"PTRACE_O_TRACEFORK", Const, 0},
{"PTRACE_O_TRACESYSGOOD", Const, 0},
{"PTRACE_O_TRACEVFORK", Const, 0},
{"PTRACE_O_TRACEVFORKDONE", Const, 0},
{"PTRACE_PEEKDATA", Const, 0},
{"PTRACE_PEEKTEXT", Const, 0},
{"PTRACE_PEEKUSR", Const, 0},
{"PTRACE_POKEDATA", Const, 0},
{"PTRACE_POKETEXT", Const, 0},
{"PTRACE_POKEUSR", Const, 0},
{"PTRACE_SETCRUNCHREGS", Const, 0},
{"PTRACE_SETFPREGS", Const, 0},
{"PTRACE_SETFPXREGS", Const, 0},
{"PTRACE_SETHBPREGS", Const, 0},
{"PTRACE_SETOPTIONS", Const, 0},
{"PTRACE_SETREGS", Const, 0},
{"PTRACE_SETREGSET", Const, 0},
{"PTRACE_SETSIGINFO", Const, 0},
{"PTRACE_SETVFPREGS", Const, 0},
{"PTRACE_SETWMMXREGS", Const, 0},
{"PTRACE_SET_SYSCALL", Const, 0},
{"PTRACE_SET_THREAD_AREA", Const, 0},
{"PTRACE_SINGLEBLOCK", Const, 0},
{"PTRACE_SINGLESTEP", Const, 0},
{"PTRACE_SYSCALL", Const, 0},
{"PTRACE_SYSEMU", Const, 0},
{"PTRACE_SYSEMU_SINGLESTEP", Const, 0},
{"PTRACE_TRACEME", Const, 0},
{"PT_ATTACH", Const, 0},
{"PT_ATTACHEXC", Const, 0},
{"PT_CONTINUE", Const, 0},
{"PT_DATA_ADDR", Const, 0},
{"PT_DENY_ATTACH", Const, 0},
{"PT_DETACH", Const, 0},
{"PT_FIRSTMACH", Const, 0},
{"PT_FORCEQUOTA", Const, 0},
{"PT_KILL", Const, 0},
{"PT_MASK", Const, 1},
{"PT_READ_D", Const, 0},
{"PT_READ_I", Const, 0},
{"PT_READ_U", Const, 0},
{"PT_SIGEXC", Const, 0},
{"PT_STEP", Const, 0},
{"PT_TEXT_ADDR", Const, 0},
{"PT_TEXT_END_ADDR", Const, 0},
{"PT_THUPDATE", Const, 0},
{"PT_TRACE_ME", Const, 0},
{"PT_WRITE_D", Const, 0},
{"PT_WRITE_I", Const, 0},
{"PT_WRITE_U", Const, 0},
{"ParseDirent", Func, 0},
{"ParseNetlinkMessage", Func, 0},
{"ParseNetlinkRouteAttr", Func, 0},
{"ParseRoutingMessage", Func, 0},
{"ParseRoutingSockaddr", Func, 0},
{"ParseSocketControlMessage", Func, 0},
{"ParseUnixCredentials", Func, 0},
{"ParseUnixRights", Func, 0},
{"PathMax", Const, 0},
{"Pathconf", Func, 0},
{"Pause", Func, 0},
{"Pipe", Func, 0},
{"Pipe2", Func, 1},
{"PivotRoot", Func, 0},
{"Pointer", Type, 11},
{"PostQueuedCompletionStatus", Func, 0},
{"Pread", Func, 0},
{"Proc", Type, 0},
{"Proc.Dll", Field, 0},
{"Proc.Name", Field, 0},
{"ProcAttr", Type, 0},
{"ProcAttr.Dir", Field, 0},
{"ProcAttr.Env", Field, 0},
{"ProcAttr.Files", Field, 0},
{"ProcAttr.Sys", Field, 0},
{"Process32First", Func, 4},
{"Process32Next", Func, 4},
{"ProcessEntry32", Type, 4},
{"ProcessEntry32.DefaultHeapID", Field, 4},
{"ProcessEntry32.ExeFile", Field, 4},
{"ProcessEntry32.Flags", Field, 4},
{"ProcessEntry32.ModuleID", Field, 4},
{"ProcessEntry32.ParentProcessID", Field, 4},
{"ProcessEntry32.PriClassBase", Field, 4},
{"ProcessEntry32.ProcessID", Field, 4},
{"ProcessEntry32.Size", Field, 4},
{"ProcessEntry32.Threads", Field, 4},
{"ProcessEntry32.Usage", Field, 4},
{"ProcessInformation", Type, 0},
{"ProcessInformation.Process", Field, 0},
{"ProcessInformation.ProcessId", Field, 0},
{"ProcessInformation.Thread", Field, 0},
{"ProcessInformation.ThreadId", Field, 0},
{"Protoent", Type, 0},
{"Protoent.Aliases", Field, 0},
{"Protoent.Name", Field, 0},
{"Protoent.Proto", Field, 0},
{"PtraceAttach", Func, 0},
{"PtraceCont", Func, 0},
{"PtraceDetach", Func, 0},
{"PtraceGetEventMsg", Func, 0},
{"PtraceGetRegs", Func, 0},
{"PtracePeekData", Func, 0},
{"PtracePeekText", Func, 0},
{"PtracePokeData", Func, 0},
{"PtracePokeText", Func, 0},
{"PtraceRegs", Type, 0},
{"PtraceRegs.Cs", Field, 0},
{"PtraceRegs.Ds", Field, 0},
{"PtraceRegs.Eax", Field, 0},
{"PtraceRegs.Ebp", Field, 0},
{"PtraceRegs.Ebx", Field, 0},
{"PtraceRegs.Ecx", Field, 0},
{"PtraceRegs.Edi", Field, 0},
{"PtraceRegs.Edx", Field, 0},
{"PtraceRegs.Eflags", Field, 0},
{"PtraceRegs.Eip", Field, 0},
{"PtraceRegs.Es", Field, 0},
{"PtraceRegs.Esi", Field, 0},
{"PtraceRegs.Esp", Field, 0},
{"PtraceRegs.Fs", Field, 0},
{"PtraceRegs.Fs_base", Field, 0},
{"PtraceRegs.Gs", Field, 0},
{"PtraceRegs.Gs_base", Field, 0},
{"PtraceRegs.Orig_eax", Field, 0},
{"PtraceRegs.Orig_rax", Field, 0},
{"PtraceRegs.R10", Field, 0},
{"PtraceRegs.R11", Field, 0},
{"PtraceRegs.R12", Field, 0},
{"PtraceRegs.R13", Field, 0},
{"PtraceRegs.R14", Field, 0},
{"PtraceRegs.R15", Field, 0},
{"PtraceRegs.R8", Field, 0},
{"PtraceRegs.R9", Field, 0},
{"PtraceRegs.Rax", Field, 0},
{"PtraceRegs.Rbp", Field, 0},
{"PtraceRegs.Rbx", Field, 0},
{"PtraceRegs.Rcx", Field, 0},
{"PtraceRegs.Rdi", Field, 0},
{"PtraceRegs.Rdx", Field, 0},
{"PtraceRegs.Rip", Field, 0},
{"PtraceRegs.Rsi", Field, 0},
{"PtraceRegs.Rsp", Field, 0},
{"PtraceRegs.Ss", Field, 0},
{"PtraceRegs.Uregs", Field, 0},
{"PtraceRegs.Xcs", Field, 0},
{"PtraceRegs.Xds", Field, 0},
{"PtraceRegs.Xes", Field, 0},
{"PtraceRegs.Xfs", Field, 0},
{"PtraceRegs.Xgs", Field, 0},
{"PtraceRegs.Xss", Field, 0},
{"PtraceSetOptions", Func, 0},
{"PtraceSetRegs", Func, 0},
{"PtraceSingleStep", Func, 0},
{"PtraceSyscall", Func, 1},
{"Pwrite", Func, 0},
{"REG_BINARY", Const, 0},
{"REG_DWORD", Const, 0},
{"REG_DWORD_BIG_ENDIAN", Const, 0},
{"REG_DWORD_LITTLE_ENDIAN", Const, 0},
{"REG_EXPAND_SZ", Const, 0},
{"REG_FULL_RESOURCE_DESCRIPTOR", Const, 0},
{"REG_LINK", Const, 0},
{"REG_MULTI_SZ", Const, 0},
{"REG_NONE", Const, 0},
{"REG_QWORD", Const, 0},
{"REG_QWORD_LITTLE_ENDIAN", Const, 0},
{"REG_RESOURCE_LIST", Const, 0},
{"REG_RESOURCE_REQUIREMENTS_LIST", Const, 0},
{"REG_SZ", Const, 0},
{"RLIMIT_AS", Const, 0},
{"RLIMIT_CORE", Const, 0},
{"RLIMIT_CPU", Const, 0},
{"RLIMIT_CPU_USAGE_MONITOR", Const, 16},
{"RLIMIT_DATA", Const, 0},
{"RLIMIT_FSIZE", Const, 0},
{"RLIMIT_NOFILE", Const, 0},
{"RLIMIT_STACK", Const, 0},
{"RLIM_INFINITY", Const, 0},
{"RTAX_ADVMSS", Const, 0},
{"RTAX_AUTHOR", Const, 0},
{"RTAX_BRD", Const, 0},
{"RTAX_CWND", Const, 0},
{"RTAX_DST", Const, 0},
{"RTAX_FEATURES", Const, 0},
{"RTAX_FEATURE_ALLFRAG", Const, 0},
{"RTAX_FEATURE_ECN", Const, 0},
{"RTAX_FEATURE_SACK", Const, 0},
{"RTAX_FEATURE_TIMESTAMP", Const, 0},
{"RTAX_GATEWAY", Const, 0},
{"RTAX_GENMASK", Const, 0},
{"RTAX_HOPLIMIT", Const, 0},
{"RTAX_IFA", Const, 0},
{"RTAX_IFP", Const, 0},
{"RTAX_INITCWND", Const, 0},
{"RTAX_INITRWND", Const, 0},
{"RTAX_LABEL", Const, 1},
{"RTAX_LOCK", Const, 0},
{"RTAX_MAX", Const, 0},
{"RTAX_MTU", Const, 0},
{"RTAX_NETMASK", Const, 0},
{"RTAX_REORDERING", Const, 0},
{"RTAX_RTO_MIN", Const, 0},
{"RTAX_RTT", Const, 0},
{"RTAX_RTTVAR", Const, 0},
{"RTAX_SRC", Const, 1},
{"RTAX_SRCMASK", Const, 1},
{"RTAX_SSTHRESH", Const, 0},
{"RTAX_TAG", Const, 1},
{"RTAX_UNSPEC", Const, 0},
{"RTAX_WINDOW", Const, 0},
{"RTA_ALIGNTO", Const, 0},
{"RTA_AUTHOR", Const, 0},
{"RTA_BRD", Const, 0},
{"RTA_CACHEINFO", Const, 0},
{"RTA_DST", Const, 0},
{"RTA_FLOW", Const, 0},
{"RTA_GATEWAY", Const, 0},
{"RTA_GENMASK", Const, 0},
{"RTA_IFA", Const, 0},
{"RTA_IFP", Const, 0},
{"RTA_IIF", Const, 0},
{"RTA_LABEL", Const, 1},
{"RTA_MAX", Const, 0},
{"RTA_METRICS", Const, 0},
{"RTA_MULTIPATH", Const, 0},
{"RTA_NETMASK", Const, 0},
{"RTA_OIF", Const, 0},
{"RTA_PREFSRC", Const, 0},
{"RTA_PRIORITY", Const, 0},
{"RTA_SRC", Const, 0},
{"RTA_SRCMASK", Const, 1},
{"RTA_TABLE", Const, 0},
{"RTA_TAG", Const, 1},
{"RTA_UNSPEC", Const, 0},
{"RTCF_DIRECTSRC", Const, 0},
{"RTCF_DOREDIRECT", Const, 0},
{"RTCF_LOG", Const, 0},
{"RTCF_MASQ", Const, 0},
{"RTCF_NAT", Const, 0},
{"RTCF_VALVE", Const, 0},
{"RTF_ADDRCLASSMASK", Const, 0},
{"RTF_ADDRCONF", Const, 0},
{"RTF_ALLONLINK", Const, 0},
{"RTF_ANNOUNCE", Const, 1},
{"RTF_BLACKHOLE", Const, 0},
{"RTF_BROADCAST", Const, 0},
{"RTF_CACHE", Const, 0},
{"RTF_CLONED", Const, 1},
{"RTF_CLONING", Const, 0},
{"RTF_CONDEMNED", Const, 0},
{"RTF_DEFAULT", Const, 0},
{"RTF_DELCLONE", Const, 0},
{"RTF_DONE", Const, 0},
{"RTF_DYNAMIC", Const, 0},
{"RTF_FLOW", Const, 0},
{"RTF_FMASK", Const, 0},
{"RTF_GATEWAY", Const, 0},
{"RTF_GWFLAG_COMPAT", Const, 3},
{"RTF_HOST", Const, 0},
{"RTF_IFREF", Const, 0},
{"RTF_IFSCOPE", Const, 0},
{"RTF_INTERFACE", Const, 0},
{"RTF_IRTT", Const, 0},
{"RTF_LINKRT", Const, 0},
{"RTF_LLDATA", Const, 0},
{"RTF_LLINFO", Const, 0},
{"RTF_LOCAL", Const, 0},
{"RTF_MASK", Const, 1},
{"RTF_MODIFIED", Const, 0},
{"RTF_MPATH", Const, 1},
{"RTF_MPLS", Const, 1},
{"RTF_MSS", Const, 0},
{"RTF_MTU", Const, 0},
{"RTF_MULTICAST", Const, 0},
{"RTF_NAT", Const, 0},
{"RTF_NOFORWARD", Const, 0},
{"RTF_NONEXTHOP", Const, 0},
{"RTF_NOPMTUDISC", Const, 0},
{"RTF_PERMANENT_ARP", Const, 1},
{"RTF_PINNED", Const, 0},
{"RTF_POLICY", Const, 0},
{"RTF_PRCLONING", Const, 0},
{"RTF_PROTO1", Const, 0},
{"RTF_PROTO2", Const, 0},
{"RTF_PROTO3", Const, 0},
{"RTF_PROXY", Const, 16},
{"RTF_REINSTATE", Const, 0},
{"RTF_REJECT", Const, 0},
{"RTF_RNH_LOCKED", Const, 0},
{"RTF_ROUTER", Const, 16},
{"RTF_SOURCE", Const, 1},
{"RTF_SRC", Const, 1},
{"RTF_STATIC", Const, 0},
{"RTF_STICKY", Const, 0},
{"RTF_THROW", Const, 0},
{"RTF_TUNNEL", Const, 1},
{"RTF_UP", Const, 0},
{"RTF_USETRAILERS", Const, 1},
{"RTF_WASCLONED", Const, 0},
{"RTF_WINDOW", Const, 0},
{"RTF_XRESOLVE", Const, 0},
{"RTM_ADD", Const, 0},
{"RTM_BASE", Const, 0},
{"RTM_CHANGE", Const, 0},
{"RTM_CHGADDR", Const, 1},
{"RTM_DELACTION", Const, 0},
{"RTM_DELADDR", Const, 0},
{"RTM_DELADDRLABEL", Const, 0},
{"RTM_DELETE", Const, 0},
{"RTM_DELLINK", Const, 0},
{"RTM_DELMADDR", Const, 0},
{"RTM_DELNEIGH", Const, 0},
{"RTM_DELQDISC", Const, 0},
{"RTM_DELROUTE", Const, 0},
{"RTM_DELRULE", Const, 0},
{"RTM_DELTCLASS", Const, 0},
{"RTM_DELTFILTER", Const, 0},
{"RTM_DESYNC", Const, 1},
{"RTM_F_CLONED", Const, 0},
{"RTM_F_EQUALIZE", Const, 0},
{"RTM_F_NOTIFY", Const, 0},
{"RTM_F_PREFIX", Const, 0},
{"RTM_GET", Const, 0},
{"RTM_GET2", Const, 0},
{"RTM_GETACTION", Const, 0},
{"RTM_GETADDR", Const, 0},
{"RTM_GETADDRLABEL", Const, 0},
{"RTM_GETANYCAST", Const, 0},
{"RTM_GETDCB", Const, 0},
{"RTM_GETLINK", Const, 0},
{"RTM_GETMULTICAST", Const, 0},
{"RTM_GETNEIGH", Const, 0},
{"RTM_GETNEIGHTBL", Const, 0},
{"RTM_GETQDISC", Const, 0},
{"RTM_GETROUTE", Const, 0},
{"RTM_GETRULE", Const, 0},
{"RTM_GETTCLASS", Const, 0},
{"RTM_GETTFILTER", Const, 0},
{"RTM_IEEE80211", Const, 0},
{"RTM_IFANNOUNCE", Const, 0},
{"RTM_IFINFO", Const, 0},
{"RTM_IFINFO2", Const, 0},
{"RTM_LLINFO_UPD", Const, 1},
{"RTM_LOCK", Const, 0},
{"RTM_LOSING", Const, 0},
{"RTM_MAX", Const, 0},
{"RTM_MAXSIZE", Const, 1},
{"RTM_MISS", Const, 0},
{"RTM_NEWACTION", Const, 0},
{"RTM_NEWADDR", Const, 0},
{"RTM_NEWADDRLABEL", Const, 0},
{"RTM_NEWLINK", Const, 0},
{"RTM_NEWMADDR", Const, 0},
{"RTM_NEWMADDR2", Const, 0},
{"RTM_NEWNDUSEROPT", Const, 0},
{"RTM_NEWNEIGH", Const, 0},
{"RTM_NEWNEIGHTBL", Const, 0},
{"RTM_NEWPREFIX", Const, 0},
{"RTM_NEWQDISC", Const, 0},
{"RTM_NEWROUTE", Const, 0},
{"RTM_NEWRULE", Const, 0},
{"RTM_NEWTCLASS", Const, 0},
{"RTM_NEWTFILTER", Const, 0},
{"RTM_NR_FAMILIES", Const, 0},
{"RTM_NR_MSGTYPES", Const, 0},
{"RTM_OIFINFO", Const, 1},
{"RTM_OLDADD", Const, 0},
{"RTM_OLDDEL", Const, 0},
{"RTM_OOIFINFO", Const, 1},
{"RTM_REDIRECT", Const, 0},
{"RTM_RESOLVE", Const, 0},
{"RTM_RTTUNIT", Const, 0},
{"RTM_SETDCB", Const, 0},
{"RTM_SETGATE", Const, 1},
{"RTM_SETLINK", Const, 0},
{"RTM_SETNEIGHTBL", Const, 0},
{"RTM_VERSION", Const, 0},
{"RTNH_ALIGNTO", Const, 0},
{"RTNH_F_DEAD", Const, 0},
{"RTNH_F_ONLINK", Const, 0},
{"RTNH_F_PERVASIVE", Const, 0},
{"RTNLGRP_IPV4_IFADDR", Const, 1},
{"RTNLGRP_IPV4_MROUTE", Const, 1},
{"RTNLGRP_IPV4_ROUTE", Const, 1},
{"RTNLGRP_IPV4_RULE", Const, 1},
{"RTNLGRP_IPV6_IFADDR", Const, 1},
{"RTNLGRP_IPV6_IFINFO", Const, 1},
{"RTNLGRP_IPV6_MROUTE", Const, 1},
{"RTNLGRP_IPV6_PREFIX", Const, 1},
{"RTNLGRP_IPV6_ROUTE", Const, 1},
{"RTNLGRP_IPV6_RULE", Const, 1},
{"RTNLGRP_LINK", Const, 1},
{"RTNLGRP_ND_USEROPT", Const, 1},
{"RTNLGRP_NEIGH", Const, 1},
{"RTNLGRP_NONE", Const, 1},
{"RTNLGRP_NOTIFY", Const, 1},
{"RTNLGRP_TC", Const, 1},
{"RTN_ANYCAST", Const, 0},
{"RTN_BLACKHOLE", Const, 0},
{"RTN_BROADCAST", Const, 0},
{"RTN_LOCAL", Const, 0},
{"RTN_MAX", Const, 0},
{"RTN_MULTICAST", Const, 0},
{"RTN_NAT", Const, 0},
{"RTN_PROHIBIT", Const, 0},
{"RTN_THROW", Const, 0},
{"RTN_UNICAST", Const, 0},
{"RTN_UNREACHABLE", Const, 0},
{"RTN_UNSPEC", Const, 0},
{"RTN_XRESOLVE", Const, 0},
{"RTPROT_BIRD", Const, 0},
{"RTPROT_BOOT", Const, 0},
{"RTPROT_DHCP", Const, 0},
{"RTPROT_DNROUTED", Const, 0},
{"RTPROT_GATED", Const, 0},
{"RTPROT_KERNEL", Const, 0},
{"RTPROT_MRT", Const, 0},
{"RTPROT_NTK", Const, 0},
{"RTPROT_RA", Const, 0},
{"RTPROT_REDIRECT", Const, 0},
{"RTPROT_STATIC", Const, 0},
{"RTPROT_UNSPEC", Const, 0},
{"RTPROT_XORP", Const, 0},
{"RTPROT_ZEBRA", Const, 0},
{"RTV_EXPIRE", Const, 0},
{"RTV_HOPCOUNT", Const, 0},
{"RTV_MTU", Const, 0},
{"RTV_RPIPE", Const, 0},
{"RTV_RTT", Const, 0},
{"RTV_RTTVAR", Const, 0},
{"RTV_SPIPE", Const, 0},
{"RTV_SSTHRESH", Const, 0},
{"RTV_WEIGHT", Const, 0},
{"RT_CACHING_CONTEXT", Const, 1},
{"RT_CLASS_DEFAULT", Const, 0},
{"RT_CLASS_LOCAL", Const, 0},
{"RT_CLASS_MAIN", Const, 0},
{"RT_CLASS_MAX", Const, 0},
{"RT_CLASS_UNSPEC", Const, 0},
{"RT_DEFAULT_FIB", Const, 1},
{"RT_NORTREF", Const, 1},
{"RT_SCOPE_HOST", Const, 0},
{"RT_SCOPE_LINK", Const, 0},
{"RT_SCOPE_NOWHERE", Const, 0},
{"RT_SCOPE_SITE", Const, 0},
{"RT_SCOPE_UNIVERSE", Const, 0},
{"RT_TABLEID_MAX", Const, 1},
{"RT_TABLE_COMPAT", Const, 0},
{"RT_TABLE_DEFAULT", Const, 0},
{"RT_TABLE_LOCAL", Const, 0},
{"RT_TABLE_MAIN", Const, 0},
{"RT_TABLE_MAX", Const, 0},
{"RT_TABLE_UNSPEC", Const, 0},
{"RUSAGE_CHILDREN", Const, 0},
{"RUSAGE_SELF", Const, 0},
{"RUSAGE_THREAD", Const, 0},
{"Radvisory_t", Type, 0},
{"Radvisory_t.Count", Field, 0},
{"Radvisory_t.Offset", Field, 0},
{"Radvisory_t.Pad_cgo_0", Field, 0},
{"RawConn", Type, 9},
{"RawSockaddr", Type, 0},
{"RawSockaddr.Data", Field, 0},
{"RawSockaddr.Family", Field, 0},
{"RawSockaddr.Len", Field, 0},
{"RawSockaddrAny", Type, 0},
{"RawSockaddrAny.Addr", Field, 0},
{"RawSockaddrAny.Pad", Field, 0},
{"RawSockaddrDatalink", Type, 0},
{"RawSockaddrDatalink.Alen", Field, 0},
{"RawSockaddrDatalink.Data", Field, 0},
{"RawSockaddrDatalink.Family", Field, 0},
{"RawSockaddrDatalink.Index", Field, 0},
{"RawSockaddrDatalink.Len", Field, 0},
{"RawSockaddrDatalink.Nlen", Field, 0},
{"RawSockaddrDatalink.Pad_cgo_0", Field, 2},
{"RawSockaddrDatalink.Slen", Field, 0},
{"RawSockaddrDatalink.Type", Field, 0},
{"RawSockaddrInet4", Type, 0},
{"RawSockaddrInet4.Addr", Field, 0},
{"RawSockaddrInet4.Family", Field, 0},
{"RawSockaddrInet4.Len", Field, 0},
{"RawSockaddrInet4.Port", Field, 0},
{"RawSockaddrInet4.Zero", Field, 0},
{"RawSockaddrInet6", Type, 0},
{"RawSockaddrInet6.Addr", Field, 0},
{"RawSockaddrInet6.Family", Field, 0},
{"RawSockaddrInet6.Flowinfo", Field, 0},
{"RawSockaddrInet6.Len", Field, 0},
{"RawSockaddrInet6.Port", Field, 0},
{"RawSockaddrInet6.Scope_id", Field, 0},
{"RawSockaddrLinklayer", Type, 0},
{"RawSockaddrLinklayer.Addr", Field, 0},
{"RawSockaddrLinklayer.Family", Field, 0},
{"RawSockaddrLinklayer.Halen", Field, 0},
{"RawSockaddrLinklayer.Hatype", Field, 0},
{"RawSockaddrLinklayer.Ifindex", Field, 0},
{"RawSockaddrLinklayer.Pkttype", Field, 0},
{"RawSockaddrLinklayer.Protocol", Field, 0},
{"RawSockaddrNetlink", Type, 0},
{"RawSockaddrNetlink.Family", Field, 0},
{"RawSockaddrNetlink.Groups", Field, 0},
{"RawSockaddrNetlink.Pad", Field, 0},
{"RawSockaddrNetlink.Pid", Field, 0},
{"RawSockaddrUnix", Type, 0},
{"RawSockaddrUnix.Family", Field, 0},
{"RawSockaddrUnix.Len", Field, 0},
{"RawSockaddrUnix.Pad_cgo_0", Field, 2},
{"RawSockaddrUnix.Path", Field, 0},
{"RawSyscall", Func, 0},
{"RawSyscall6", Func, 0},
{"Read", Func, 0},
{"ReadConsole", Func, 1},
{"ReadDirectoryChanges", Func, 0},
{"ReadDirent", Func, 0},
{"ReadFile", Func, 0},
{"Readlink", Func, 0},
{"Reboot", Func, 0},
{"Recvfrom", Func, 0},
{"Recvmsg", Func, 0},
{"RegCloseKey", Func, 0},
{"RegEnumKeyEx", Func, 0},
{"RegOpenKeyEx", Func, 0},
{"RegQueryInfoKey", Func, 0},
{"RegQueryValueEx", Func, 0},
{"RemoveDirectory", Func, 0},
{"Removexattr", Func, 1},
{"Rename", Func, 0},
{"Renameat", Func, 0},
{"Revoke", Func, 0},
{"Rlimit", Type, 0},
{"Rlimit.Cur", Field, 0},
{"Rlimit.Max", Field, 0},
{"Rmdir", Func, 0},
{"RouteMessage", Type, 0},
{"RouteMessage.Data", Field, 0},
{"RouteMessage.Header", Field, 0},
{"RouteRIB", Func, 0},
{"RoutingMessage", Type, 0},
{"RtAttr", Type, 0},
{"RtAttr.Len", Field, 0},
{"RtAttr.Type", Field, 0},
{"RtGenmsg", Type, 0},
{"RtGenmsg.Family", Field, 0},
{"RtMetrics", Type, 0},
{"RtMetrics.Expire", Field, 0},
{"RtMetrics.Filler", Field, 0},
{"RtMetrics.Hopcount", Field, 0},
{"RtMetrics.Locks", Field, 0},
{"RtMetrics.Mtu", Field, 0},
{"RtMetrics.Pad", Field, 3},
{"RtMetrics.Pksent", Field, 0},
{"RtMetrics.Recvpipe", Field, 0},
{"RtMetrics.Refcnt", Field, 2},
{"RtMetrics.Rtt", Field, 0},
{"RtMetrics.Rttvar", Field, 0},
{"RtMetrics.Sendpipe", Field, 0},
{"RtMetrics.Ssthresh", Field, 0},
{"RtMetrics.Weight", Field, 0},
{"RtMsg", Type, 0},
{"RtMsg.Dst_len", Field, 0},
{"RtMsg.Family", Field, 0},
{"RtMsg.Flags", Field, 0},
{"RtMsg.Protocol", Field, 0},
{"RtMsg.Scope", Field, 0},
{"RtMsg.Src_len", Field, 0},
{"RtMsg.Table", Field, 0},
{"RtMsg.Tos", Field, 0},
{"RtMsg.Type", Field, 0},
{"RtMsghdr", Type, 0},
{"RtMsghdr.Addrs", Field, 0},
{"RtMsghdr.Errno", Field, 0},
{"RtMsghdr.Flags", Field, 0},
{"RtMsghdr.Fmask", Field, 0},
{"RtMsghdr.Hdrlen", Field, 2},
{"RtMsghdr.Index", Field, 0},
{"RtMsghdr.Inits", Field, 0},
{"RtMsghdr.Mpls", Field, 2},
{"RtMsghdr.Msglen", Field, 0},
{"RtMsghdr.Pad_cgo_0", Field, 0},
{"RtMsghdr.Pad_cgo_1", Field, 2},
{"RtMsghdr.Pid", Field, 0},
{"RtMsghdr.Priority", Field, 2},
{"RtMsghdr.Rmx", Field, 0},
{"RtMsghdr.Seq", Field, 0},
{"RtMsghdr.Tableid", Field, 2},
{"RtMsghdr.Type", Field, 0},
{"RtMsghdr.Use", Field, 0},
{"RtMsghdr.Version", Field, 0},
{"RtNexthop", Type, 0},
{"RtNexthop.Flags", Field, 0},
{"RtNexthop.Hops", Field, 0},
{"RtNexthop.Ifindex", Field, 0},
{"RtNexthop.Len", Field, 0},
{"Rusage", Type, 0},
{"Rusage.CreationTime", Field, 0},
{"Rusage.ExitTime", Field, 0},
{"Rusage.Idrss", Field, 0},
{"Rusage.Inblock", Field, 0},
{"Rusage.Isrss", Field, 0},
{"Rusage.Ixrss", Field, 0},
{"Rusage.KernelTime", Field, 0},
{"Rusage.Majflt", Field, 0},
{"Rusage.Maxrss", Field, 0},
{"Rusage.Minflt", Field, 0},
{"Rusage.Msgrcv", Field, 0},
{"Rusage.Msgsnd", Field, 0},
{"Rusage.Nivcsw", Field, 0},
{"Rusage.Nsignals", Field, 0},
{"Rusage.Nswap", Field, 0},
{"Rusage.Nvcsw", Field, 0},
{"Rusage.Oublock", Field, 0},
{"Rusage.Stime", Field, 0},
{"Rusage.UserTime", Field, 0},
{"Rusage.Utime", Field, 0},
{"SCM_BINTIME", Const, 0},
{"SCM_CREDENTIALS", Const, 0},
{"SCM_CREDS", Const, 0},
{"SCM_RIGHTS", Const, 0},
{"SCM_TIMESTAMP", Const, 0},
{"SCM_TIMESTAMPING", Const, 0},
{"SCM_TIMESTAMPNS", Const, 0},
{"SCM_TIMESTAMP_MONOTONIC", Const, 0},
{"SHUT_RD", Const, 0},
{"SHUT_RDWR", Const, 0},
{"SHUT_WR", Const, 0},
{"SID", Type, 0},
{"SIDAndAttributes", Type, 0},
{"SIDAndAttributes.Attributes", Field, 0},
{"SIDAndAttributes.Sid", Field, 0},
{"SIGABRT", Const, 0},
{"SIGALRM", Const, 0},
{"SIGBUS", Const, 0},
{"SIGCHLD", Const, 0},
{"SIGCLD", Const, 0},
{"SIGCONT", Const, 0},
{"SIGEMT", Const, 0},
{"SIGFPE", Const, 0},
{"SIGHUP", Const, 0},
{"SIGILL", Const, 0},
{"SIGINFO", Const, 0},
{"SIGINT", Const, 0},
{"SIGIO", Const, 0},
{"SIGIOT", Const, 0},
{"SIGKILL", Const, 0},
{"SIGLIBRT", Const, 1},
{"SIGLWP", Const, 0},
{"SIGPIPE", Const, 0},
{"SIGPOLL", Const, 0},
{"SIGPROF", Const, 0},
{"SIGPWR", Const, 0},
{"SIGQUIT", Const, 0},
{"SIGSEGV", Const, 0},
{"SIGSTKFLT", Const, 0},
{"SIGSTOP", Const, 0},
{"SIGSYS", Const, 0},
{"SIGTERM", Const, 0},
{"SIGTHR", Const, 0},
{"SIGTRAP", Const, 0},
{"SIGTSTP", Const, 0},
{"SIGTTIN", Const, 0},
{"SIGTTOU", Const, 0},
{"SIGUNUSED", Const, 0},
{"SIGURG", Const, 0},
{"SIGUSR1", Const, 0},
{"SIGUSR2", Const, 0},
{"SIGVTALRM", Const, 0},
{"SIGWINCH", Const, 0},
{"SIGXCPU", Const, 0},
{"SIGXFSZ", Const, 0},
{"SIOCADDDLCI", Const, 0},
{"SIOCADDMULTI", Const, 0},
{"SIOCADDRT", Const, 0},
{"SIOCAIFADDR", Const, 0},
{"SIOCAIFGROUP", Const, 0},
{"SIOCALIFADDR", Const, 0},
{"SIOCARPIPLL", Const, 0},
{"SIOCATMARK", Const, 0},
{"SIOCAUTOADDR", Const, 0},
{"SIOCAUTONETMASK", Const, 0},
{"SIOCBRDGADD", Const, 1},
{"SIOCBRDGADDS", Const, 1},
{"SIOCBRDGARL", Const, 1},
{"SIOCBRDGDADDR", Const, 1},
{"SIOCBRDGDEL", Const, 1},
{"SIOCBRDGDELS", Const, 1},
{"SIOCBRDGFLUSH", Const, 1},
{"SIOCBRDGFRL", Const, 1},
{"SIOCBRDGGCACHE", Const, 1},
{"SIOCBRDGGFD", Const, 1},
{"SIOCBRDGGHT", Const, 1},
{"SIOCBRDGGIFFLGS", Const, 1},
{"SIOCBRDGGMA", Const, 1},
{"SIOCBRDGGPARAM", Const, 1},
{"SIOCBRDGGPRI", Const, 1},
{"SIOCBRDGGRL", Const, 1},
{"SIOCBRDGGSIFS", Const, 1},
{"SIOCBRDGGTO", Const, 1},
{"SIOCBRDGIFS", Const, 1},
{"SIOCBRDGRTS", Const, 1},
{"SIOCBRDGSADDR", Const, 1},
{"SIOCBRDGSCACHE", Const, 1},
{"SIOCBRDGSFD", Const, 1},
{"SIOCBRDGSHT", Const, 1},
{"SIOCBRDGSIFCOST", Const, 1},
{"SIOCBRDGSIFFLGS", Const, 1},
{"SIOCBRDGSIFPRIO", Const, 1},
{"SIOCBRDGSMA", Const, 1},
{"SIOCBRDGSPRI", Const, 1},
{"SIOCBRDGSPROTO", Const, 1},
{"SIOCBRDGSTO", Const, 1},
{"SIOCBRDGSTXHC", Const, 1},
{"SIOCDARP", Const, 0},
{"SIOCDELDLCI", Const, 0},
{"SIOCDELMULTI", Const, 0},
{"SIOCDELRT", Const, 0},
{"SIOCDEVPRIVATE", Const, 0},
{"SIOCDIFADDR", Const, 0},
{"SIOCDIFGROUP", Const, 0},
{"SIOCDIFPHYADDR", Const, 0},
{"SIOCDLIFADDR", Const, 0},
{"SIOCDRARP", Const, 0},
{"SIOCGARP", Const, 0},
{"SIOCGDRVSPEC", Const, 0},
{"SIOCGETKALIVE", Const, 1},
{"SIOCGETLABEL", Const, 1},
{"SIOCGETPFLOW", Const, 1},
{"SIOCGETPFSYNC", Const, 1},
{"SIOCGETSGCNT", Const, 0},
{"SIOCGETVIFCNT", Const, 0},
{"SIOCGETVLAN", Const, 0},
{"SIOCGHIWAT", Const, 0},
{"SIOCGIFADDR", Const, 0},
{"SIOCGIFADDRPREF", Const, 1},
{"SIOCGIFALIAS", Const, 1},
{"SIOCGIFALTMTU", Const, 0},
{"SIOCGIFASYNCMAP", Const, 0},
{"SIOCGIFBOND", Const, 0},
{"SIOCGIFBR", Const, 0},
{"SIOCGIFBRDADDR", Const, 0},
{"SIOCGIFCAP", Const, 0},
{"SIOCGIFCONF", Const, 0},
{"SIOCGIFCOUNT", Const, 0},
{"SIOCGIFDATA", Const, 1},
{"SIOCGIFDESCR", Const, 0},
{"SIOCGIFDEVMTU", Const, 0},
{"SIOCGIFDLT", Const, 1},
{"SIOCGIFDSTADDR", Const, 0},
{"SIOCGIFENCAP", Const, 0},
{"SIOCGIFFIB", Const, 1},
{"SIOCGIFFLAGS", Const, 0},
{"SIOCGIFGATTR", Const, 1},
{"SIOCGIFGENERIC", Const, 0},
{"SIOCGIFGMEMB", Const, 0},
{"SIOCGIFGROUP", Const, 0},
{"SIOCGIFHARDMTU", Const, 3},
{"SIOCGIFHWADDR", Const, 0},
{"SIOCGIFINDEX", Const, 0},
{"SIOCGIFKPI", Const, 0},
{"SIOCGIFMAC", Const, 0},
{"SIOCGIFMAP", Const, 0},
{"SIOCGIFMEDIA", Const, 0},
{"SIOCGIFMEM", Const, 0},
{"SIOCGIFMETRIC", Const, 0},
{"SIOCGIFMTU", Const, 0},
{"SIOCGIFNAME", Const, 0},
{"SIOCGIFNETMASK", Const, 0},
{"SIOCGIFPDSTADDR", Const, 0},
{"SIOCGIFPFLAGS", Const, 0},
{"SIOCGIFPHYS", Const, 0},
{"SIOCGIFPRIORITY", Const, 1},
{"SIOCGIFPSRCADDR", Const, 0},
{"SIOCGIFRDOMAIN", Const, 1},
{"SIOCGIFRTLABEL", Const, 1},
{"SIOCGIFSLAVE", Const, 0},
{"SIOCGIFSTATUS", Const, 0},
{"SIOCGIFTIMESLOT", Const, 1},
{"SIOCGIFTXQLEN", Const, 0},
{"SIOCGIFVLAN", Const, 0},
{"SIOCGIFWAKEFLAGS", Const, 0},
{"SIOCGIFXFLAGS", Const, 1},
{"SIOCGLIFADDR", Const, 0},
{"SIOCGLIFPHYADDR", Const, 0},
{"SIOCGLIFPHYRTABLE", Const, 1},
{"SIOCGLIFPHYTTL", Const, 3},
{"SIOCGLINKSTR", Const, 1},
{"SIOCGLOWAT", Const, 0},
{"SIOCGPGRP", Const, 0},
{"SIOCGPRIVATE_0", Const, 0},
{"SIOCGPRIVATE_1", Const, 0},
{"SIOCGRARP", Const, 0},
{"SIOCGSPPPPARAMS", Const, 3},
{"SIOCGSTAMP", Const, 0},
{"SIOCGSTAMPNS", Const, 0},
{"SIOCGVH", Const, 1},
{"SIOCGVNETID", Const, 3},
{"SIOCIFCREATE", Const, 0},
{"SIOCIFCREATE2", Const, 0},
{"SIOCIFDESTROY", Const, 0},
{"SIOCIFGCLONERS", Const, 0},
{"SIOCINITIFADDR", Const, 1},
{"SIOCPROTOPRIVATE", Const, 0},
{"SIOCRSLVMULTI", Const, 0},
{"SIOCRTMSG", Const, 0},
{"SIOCSARP", Const, 0},
{"SIOCSDRVSPEC", Const, 0},
{"SIOCSETKALIVE", Const, 1},
{"SIOCSETLABEL", Const, 1},
{"SIOCSETPFLOW", Const, 1},
{"SIOCSETPFSYNC", Const, 1},
{"SIOCSETVLAN", Const, 0},
{"SIOCSHIWAT", Const, 0},
{"SIOCSIFADDR", Const, 0},
{"SIOCSIFADDRPREF", Const, 1},
{"SIOCSIFALTMTU", Const, 0},
{"SIOCSIFASYNCMAP", Const, 0},
{"SIOCSIFBOND", Const, 0},
{"SIOCSIFBR", Const, 0},
{"SIOCSIFBRDADDR", Const, 0},
{"SIOCSIFCAP", Const, 0},
{"SIOCSIFDESCR", Const, 0},
{"SIOCSIFDSTADDR", Const, 0},
{"SIOCSIFENCAP", Const, 0},
{"SIOCSIFFIB", Const, 1},
{"SIOCSIFFLAGS", Const, 0},
{"SIOCSIFGATTR", Const, 1},
{"SIOCSIFGENERIC", Const, 0},
{"SIOCSIFHWADDR", Const, 0},
{"SIOCSIFHWBROADCAST", Const, 0},
{"SIOCSIFKPI", Const, 0},
{"SIOCSIFLINK", Const, 0},
{"SIOCSIFLLADDR", Const, 0},
{"SIOCSIFMAC", Const, 0},
{"SIOCSIFMAP", Const, 0},
{"SIOCSIFMEDIA", Const, 0},
{"SIOCSIFMEM", Const, 0},
{"SIOCSIFMETRIC", Const, 0},
{"SIOCSIFMTU", Const, 0},
{"SIOCSIFNAME", Const, 0},
{"SIOCSIFNETMASK", Const, 0},
{"SIOCSIFPFLAGS", Const, 0},
{"SIOCSIFPHYADDR", Const, 0},
{"SIOCSIFPHYS", Const, 0},
{"SIOCSIFPRIORITY", Const, 1},
{"SIOCSIFRDOMAIN", Const, 1},
{"SIOCSIFRTLABEL", Const, 1},
{"SIOCSIFRVNET", Const, 0},
{"SIOCSIFSLAVE", Const, 0},
{"SIOCSIFTIMESLOT", Const, 1},
{"SIOCSIFTXQLEN", Const, 0},
{"SIOCSIFVLAN", Const, 0},
{"SIOCSIFVNET", Const, 0},
{"SIOCSIFXFLAGS", Const, 1},
{"SIOCSLIFPHYADDR", Const, 0},
{"SIOCSLIFPHYRTABLE", Const, 1},
{"SIOCSLIFPHYTTL", Const, 3},
{"SIOCSLINKSTR", Const, 1},
{"SIOCSLOWAT", Const, 0},
{"SIOCSPGRP", Const, 0},
{"SIOCSRARP", Const, 0},
{"SIOCSSPPPPARAMS", Const, 3},
{"SIOCSVH", Const, 1},
{"SIOCSVNETID", Const, 3},
{"SIOCZIFDATA", Const, 1},
{"SIO_GET_EXTENSION_FUNCTION_POINTER", Const, 1},
{"SIO_GET_INTERFACE_LIST", Const, 0},
{"SIO_KEEPALIVE_VALS", Const, 3},
{"SIO_UDP_CONNRESET", Const, 4},
{"SOCK_CLOEXEC", Const, 0},
{"SOCK_DCCP", Const, 0},
{"SOCK_DGRAM", Const, 0},
{"SOCK_FLAGS_MASK", Const, 1},
{"SOCK_MAXADDRLEN", Const, 0},
{"SOCK_NONBLOCK", Const, 0},
{"SOCK_NOSIGPIPE", Const, 1},
{"SOCK_PACKET", Const, 0},
{"SOCK_RAW", Const, 0},
{"SOCK_RDM", Const, 0},
{"SOCK_SEQPACKET", Const, 0},
{"SOCK_STREAM", Const, 0},
{"SOL_AAL", Const, 0},
{"SOL_ATM", Const, 0},
{"SOL_DECNET", Const, 0},
{"SOL_ICMPV6", Const, 0},
{"SOL_IP", Const, 0},
{"SOL_IPV6", Const, 0},
{"SOL_IRDA", Const, 0},
{"SOL_PACKET", Const, 0},
{"SOL_RAW", Const, 0},
{"SOL_SOCKET", Const, 0},
{"SOL_TCP", Const, 0},
{"SOL_X25", Const, 0},
{"SOMAXCONN", Const, 0},
{"SO_ACCEPTCONN", Const, 0},
{"SO_ACCEPTFILTER", Const, 0},
{"SO_ATTACH_FILTER", Const, 0},
{"SO_BINDANY", Const, 1},
{"SO_BINDTODEVICE", Const, 0},
{"SO_BINTIME", Const, 0},
{"SO_BROADCAST", Const, 0},
{"SO_BSDCOMPAT", Const, 0},
{"SO_DEBUG", Const, 0},
{"SO_DETACH_FILTER", Const, 0},
{"SO_DOMAIN", Const, 0},
{"SO_DONTROUTE", Const, 0},
{"SO_DONTTRUNC", Const, 0},
{"SO_ERROR", Const, 0},
{"SO_KEEPALIVE", Const, 0},
{"SO_LABEL", Const, 0},
{"SO_LINGER", Const, 0},
{"SO_LINGER_SEC", Const, 0},
{"SO_LISTENINCQLEN", Const, 0},
{"SO_LISTENQLEN", Const, 0},
{"SO_LISTENQLIMIT", Const, 0},
{"SO_MARK", Const, 0},
{"SO_NETPROC", Const, 1},
{"SO_NKE", Const, 0},
{"SO_NOADDRERR", Const, 0},
{"SO_NOHEADER", Const, 1},
{"SO_NOSIGPIPE", Const, 0},
{"SO_NOTIFYCONFLICT", Const, 0},
{"SO_NO_CHECK", Const, 0},
{"SO_NO_DDP", Const, 0},
{"SO_NO_OFFLOAD", Const, 0},
{"SO_NP_EXTENSIONS", Const, 0},
{"SO_NREAD", Const, 0},
{"SO_NUMRCVPKT", Const, 16},
{"SO_NWRITE", Const, 0},
{"SO_OOBINLINE", Const, 0},
{"SO_OVERFLOWED", Const, 1},
{"SO_PASSCRED", Const, 0},
{"SO_PASSSEC", Const, 0},
{"SO_PEERCRED", Const, 0},
{"SO_PEERLABEL", Const, 0},
{"SO_PEERNAME", Const, 0},
{"SO_PEERSEC", Const, 0},
{"SO_PRIORITY", Const, 0},
{"SO_PROTOCOL", Const, 0},
{"SO_PROTOTYPE", Const, 1},
{"SO_RANDOMPORT", Const, 0},
{"SO_RCVBUF", Const, 0},
{"SO_RCVBUFFORCE", Const, 0},
{"SO_RCVLOWAT", Const, 0},
{"SO_RCVTIMEO", Const, 0},
{"SO_RESTRICTIONS", Const, 0},
{"SO_RESTRICT_DENYIN", Const, 0},
{"SO_RESTRICT_DENYOUT", Const, 0},
{"SO_RESTRICT_DENYSET", Const, 0},
{"SO_REUSEADDR", Const, 0},
{"SO_REUSEPORT", Const, 0},
{"SO_REUSESHAREUID", Const, 0},
{"SO_RTABLE", Const, 1},
{"SO_RXQ_OVFL", Const, 0},
{"SO_SECURITY_AUTHENTICATION", Const, 0},
{"SO_SECURITY_ENCRYPTION_NETWORK", Const, 0},
{"SO_SECURITY_ENCRYPTION_TRANSPORT", Const, 0},
{"SO_SETFIB", Const, 0},
{"SO_SNDBUF", Const, 0},
{"SO_SNDBUFFORCE", Const, 0},
{"SO_SNDLOWAT", Const, 0},
{"SO_SNDTIMEO", Const, 0},
{"SO_SPLICE", Const, 1},
{"SO_TIMESTAMP", Const, 0},
{"SO_TIMESTAMPING", Const, 0},
{"SO_TIMESTAMPNS", Const, 0},
{"SO_TIMESTAMP_MONOTONIC", Const, 0},
{"SO_TYPE", Const, 0},
{"SO_UPCALLCLOSEWAIT", Const, 0},
{"SO_UPDATE_ACCEPT_CONTEXT", Const, 0},
{"SO_UPDATE_CONNECT_CONTEXT", Const, 1},
{"SO_USELOOPBACK", Const, 0},
{"SO_USER_COOKIE", Const, 1},
{"SO_VENDOR", Const, 3},
{"SO_WANTMORE", Const, 0},
{"SO_WANTOOBFLAG", Const, 0},
{"SSLExtraCertChainPolicyPara", Type, 0},
{"SSLExtraCertChainPolicyPara.AuthType", Field, 0},
{"SSLExtraCertChainPolicyPara.Checks", Field, 0},
{"SSLExtraCertChainPolicyPara.ServerName", Field, 0},
{"SSLExtraCertChainPolicyPara.Size", Field, 0},
{"STANDARD_RIGHTS_ALL", Const, 0},
{"STANDARD_RIGHTS_EXECUTE", Const, 0},
{"STANDARD_RIGHTS_READ", Const, 0},
{"STANDARD_RIGHTS_REQUIRED", Const, 0},
{"STANDARD_RIGHTS_WRITE", Const, 0},
{"STARTF_USESHOWWINDOW", Const, 0},
{"STARTF_USESTDHANDLES", Const, 0},
{"STD_ERROR_HANDLE", Const, 0},
{"STD_INPUT_HANDLE", Const, 0},
{"STD_OUTPUT_HANDLE", Const, 0},
{"SUBLANG_ENGLISH_US", Const, 0},
{"SW_FORCEMINIMIZE", Const, 0},
{"SW_HIDE", Const, 0},
{"SW_MAXIMIZE", Const, 0},
{"SW_MINIMIZE", Const, 0},
{"SW_NORMAL", Const, 0},
{"SW_RESTORE", Const, 0},
{"SW_SHOW", Const, 0},
{"SW_SHOWDEFAULT", Const, 0},
{"SW_SHOWMAXIMIZED", Const, 0},
{"SW_SHOWMINIMIZED", Const, 0},
{"SW_SHOWMINNOACTIVE", Const, 0},
{"SW_SHOWNA", Const, 0},
{"SW_SHOWNOACTIVATE", Const, 0},
{"SW_SHOWNORMAL", Const, 0},
{"SYMBOLIC_LINK_FLAG_DIRECTORY", Const, 4},
{"SYNCHRONIZE", Const, 0},
{"SYSCTL_VERSION", Const, 1},
{"SYSCTL_VERS_0", Const, 1},
{"SYSCTL_VERS_1", Const, 1},
{"SYSCTL_VERS_MASK", Const, 1},
{"SYS_ABORT2", Const, 0},
{"SYS_ACCEPT", Const, 0},
{"SYS_ACCEPT4", Const, 0},
{"SYS_ACCEPT_NOCANCEL", Const, 0},
{"SYS_ACCESS", Const, 0},
{"SYS_ACCESS_EXTENDED", Const, 0},
{"SYS_ACCT", Const, 0},
{"SYS_ADD_KEY", Const, 0},
{"SYS_ADD_PROFIL", Const, 0},
{"SYS_ADJFREQ", Const, 1},
{"SYS_ADJTIME", Const, 0},
{"SYS_ADJTIMEX", Const, 0},
{"SYS_AFS_SYSCALL", Const, 0},
{"SYS_AIO_CANCEL", Const, 0},
{"SYS_AIO_ERROR", Const, 0},
{"SYS_AIO_FSYNC", Const, 0},
{"SYS_AIO_MLOCK", Const, 14},
{"SYS_AIO_READ", Const, 0},
{"SYS_AIO_RETURN", Const, 0},
{"SYS_AIO_SUSPEND", Const, 0},
{"SYS_AIO_SUSPEND_NOCANCEL", Const, 0},
{"SYS_AIO_WAITCOMPLETE", Const, 14},
{"SYS_AIO_WRITE", Const, 0},
{"SYS_ALARM", Const, 0},
{"SYS_ARCH_PRCTL", Const, 0},
{"SYS_ARM_FADVISE64_64", Const, 0},
{"SYS_ARM_SYNC_FILE_RANGE", Const, 0},
{"SYS_ATGETMSG", Const, 0},
{"SYS_ATPGETREQ", Const, 0},
{"SYS_ATPGETRSP", Const, 0},
{"SYS_ATPSNDREQ", Const, 0},
{"SYS_ATPSNDRSP", Const, 0},
{"SYS_ATPUTMSG", Const, 0},
{"SYS_ATSOCKET", Const, 0},
{"SYS_AUDIT", Const, 0},
{"SYS_AUDITCTL", Const, 0},
{"SYS_AUDITON", Const, 0},
{"SYS_AUDIT_SESSION_JOIN", Const, 0},
{"SYS_AUDIT_SESSION_PORT", Const, 0},
{"SYS_AUDIT_SESSION_SELF", Const, 0},
{"SYS_BDFLUSH", Const, 0},
{"SYS_BIND", Const, 0},
{"SYS_BINDAT", Const, 3},
{"SYS_BREAK", Const, 0},
{"SYS_BRK", Const, 0},
{"SYS_BSDTHREAD_CREATE", Const, 0},
{"SYS_BSDTHREAD_REGISTER", Const, 0},
{"SYS_BSDTHREAD_TERMINATE", Const, 0},
{"SYS_CAPGET", Const, 0},
{"SYS_CAPSET", Const, 0},
{"SYS_CAP_ENTER", Const, 0},
{"SYS_CAP_FCNTLS_GET", Const, 1},
{"SYS_CAP_FCNTLS_LIMIT", Const, 1},
{"SYS_CAP_GETMODE", Const, 0},
{"SYS_CAP_GETRIGHTS", Const, 0},
{"SYS_CAP_IOCTLS_GET", Const, 1},
{"SYS_CAP_IOCTLS_LIMIT", Const, 1},
{"SYS_CAP_NEW", Const, 0},
{"SYS_CAP_RIGHTS_GET", Const, 1},
{"SYS_CAP_RIGHTS_LIMIT", Const, 1},
{"SYS_CHDIR", Const, 0},
{"SYS_CHFLAGS", Const, 0},
{"SYS_CHFLAGSAT", Const, 3},
{"SYS_CHMOD", Const, 0},
{"SYS_CHMOD_EXTENDED", Const, 0},
{"SYS_CHOWN", Const, 0},
{"SYS_CHOWN32", Const, 0},
{"SYS_CHROOT", Const, 0},
{"SYS_CHUD", Const, 0},
{"SYS_CLOCK_ADJTIME", Const, 0},
{"SYS_CLOCK_GETCPUCLOCKID2", Const, 1},
{"SYS_CLOCK_GETRES", Const, 0},
{"SYS_CLOCK_GETTIME", Const, 0},
{"SYS_CLOCK_NANOSLEEP", Const, 0},
{"SYS_CLOCK_SETTIME", Const, 0},
{"SYS_CLONE", Const, 0},
{"SYS_CLOSE", Const, 0},
{"SYS_CLOSEFROM", Const, 0},
{"SYS_CLOSE_NOCANCEL", Const, 0},
{"SYS_CONNECT", Const, 0},
{"SYS_CONNECTAT", Const, 3},
{"SYS_CONNECT_NOCANCEL", Const, 0},
{"SYS_COPYFILE", Const, 0},
{"SYS_CPUSET", Const, 0},
{"SYS_CPUSET_GETAFFINITY", Const, 0},
{"SYS_CPUSET_GETID", Const, 0},
{"SYS_CPUSET_SETAFFINITY", Const, 0},
{"SYS_CPUSET_SETID", Const, 0},
{"SYS_CREAT", Const, 0},
{"SYS_CREATE_MODULE", Const, 0},
{"SYS_CSOPS", Const, 0},
{"SYS_CSOPS_AUDITTOKEN", Const, 16},
{"SYS_DELETE", Const, 0},
{"SYS_DELETE_MODULE", Const, 0},
{"SYS_DUP", Const, 0},
{"SYS_DUP2", Const, 0},
{"SYS_DUP3", Const, 0},
{"SYS_EACCESS", Const, 0},
{"SYS_EPOLL_CREATE", Const, 0},
{"SYS_EPOLL_CREATE1", Const, 0},
{"SYS_EPOLL_CTL", Const, 0},
{"SYS_EPOLL_CTL_OLD", Const, 0},
{"SYS_EPOLL_PWAIT", Const, 0},
{"SYS_EPOLL_WAIT", Const, 0},
{"SYS_EPOLL_WAIT_OLD", Const, 0},
{"SYS_EVENTFD", Const, 0},
{"SYS_EVENTFD2", Const, 0},
{"SYS_EXCHANGEDATA", Const, 0},
{"SYS_EXECVE", Const, 0},
{"SYS_EXIT", Const, 0},
{"SYS_EXIT_GROUP", Const, 0},
{"SYS_EXTATTRCTL", Const, 0},
{"SYS_EXTATTR_DELETE_FD", Const, 0},
{"SYS_EXTATTR_DELETE_FILE", Const, 0},
{"SYS_EXTATTR_DELETE_LINK", Const, 0},
{"SYS_EXTATTR_GET_FD", Const, 0},
{"SYS_EXTATTR_GET_FILE", Const, 0},
{"SYS_EXTATTR_GET_LINK", Const, 0},
{"SYS_EXTATTR_LIST_FD", Const, 0},
{"SYS_EXTATTR_LIST_FILE", Const, 0},
{"SYS_EXTATTR_LIST_LINK", Const, 0},
{"SYS_EXTATTR_SET_FD", Const, 0},
{"SYS_EXTATTR_SET_FILE", Const, 0},
{"SYS_EXTATTR_SET_LINK", Const, 0},
{"SYS_FACCESSAT", Const, 0},
{"SYS_FADVISE64", Const, 0},
{"SYS_FADVISE64_64", Const, 0},
{"SYS_FALLOCATE", Const, 0},
{"SYS_FANOTIFY_INIT", Const, 0},
{"SYS_FANOTIFY_MARK", Const, 0},
{"SYS_FCHDIR", Const, 0},
{"SYS_FCHFLAGS", Const, 0},
{"SYS_FCHMOD", Const, 0},
{"SYS_FCHMODAT", Const, 0},
{"SYS_FCHMOD_EXTENDED", Const, 0},
{"SYS_FCHOWN", Const, 0},
{"SYS_FCHOWN32", Const, 0},
{"SYS_FCHOWNAT", Const, 0},
{"SYS_FCHROOT", Const, 1},
{"SYS_FCNTL", Const, 0},
{"SYS_FCNTL64", Const, 0},
{"SYS_FCNTL_NOCANCEL", Const, 0},
{"SYS_FDATASYNC", Const, 0},
{"SYS_FEXECVE", Const, 0},
{"SYS_FFCLOCK_GETCOUNTER", Const, 0},
{"SYS_FFCLOCK_GETESTIMATE", Const, 0},
{"SYS_FFCLOCK_SETESTIMATE", Const, 0},
{"SYS_FFSCTL", Const, 0},
{"SYS_FGETATTRLIST", Const, 0},
{"SYS_FGETXATTR", Const, 0},
{"SYS_FHOPEN", Const, 0},
{"SYS_FHSTAT", Const, 0},
{"SYS_FHSTATFS", Const, 0},
{"SYS_FILEPORT_MAKEFD", Const, 0},
{"SYS_FILEPORT_MAKEPORT", Const, 0},
{"SYS_FKTRACE", Const, 1},
{"SYS_FLISTXATTR", Const, 0},
{"SYS_FLOCK", Const, 0},
{"SYS_FORK", Const, 0},
{"SYS_FPATHCONF", Const, 0},
{"SYS_FREEBSD6_FTRUNCATE", Const, 0},
{"SYS_FREEBSD6_LSEEK", Const, 0},
{"SYS_FREEBSD6_MMAP", Const, 0},
{"SYS_FREEBSD6_PREAD", Const, 0},
{"SYS_FREEBSD6_PWRITE", Const, 0},
{"SYS_FREEBSD6_TRUNCATE", Const, 0},
{"SYS_FREMOVEXATTR", Const, 0},
{"SYS_FSCTL", Const, 0},
{"SYS_FSETATTRLIST", Const, 0},
{"SYS_FSETXATTR", Const, 0},
{"SYS_FSGETPATH", Const, 0},
{"SYS_FSTAT", Const, 0},
{"SYS_FSTAT64", Const, 0},
{"SYS_FSTAT64_EXTENDED", Const, 0},
{"SYS_FSTATAT", Const, 0},
{"SYS_FSTATAT64", Const, 0},
{"SYS_FSTATFS", Const, 0},
{"SYS_FSTATFS64", Const, 0},
{"SYS_FSTATV", Const, 0},
{"SYS_FSTATVFS1", Const, 1},
{"SYS_FSTAT_EXTENDED", Const, 0},
{"SYS_FSYNC", Const, 0},
{"SYS_FSYNC_NOCANCEL", Const, 0},
{"SYS_FSYNC_RANGE", Const, 1},
{"SYS_FTIME", Const, 0},
{"SYS_FTRUNCATE", Const, 0},
{"SYS_FTRUNCATE64", Const, 0},
{"SYS_FUTEX", Const, 0},
{"SYS_FUTIMENS", Const, 1},
{"SYS_FUTIMES", Const, 0},
{"SYS_FUTIMESAT", Const, 0},
{"SYS_GETATTRLIST", Const, 0},
{"SYS_GETAUDIT", Const, 0},
{"SYS_GETAUDIT_ADDR", Const, 0},
{"SYS_GETAUID", Const, 0},
{"SYS_GETCONTEXT", Const, 0},
{"SYS_GETCPU", Const, 0},
{"SYS_GETCWD", Const, 0},
{"SYS_GETDENTS", Const, 0},
{"SYS_GETDENTS64", Const, 0},
{"SYS_GETDIRENTRIES", Const, 0},
{"SYS_GETDIRENTRIES64", Const, 0},
{"SYS_GETDIRENTRIESATTR", Const, 0},
{"SYS_GETDTABLECOUNT", Const, 1},
{"SYS_GETDTABLESIZE", Const, 0},
{"SYS_GETEGID", Const, 0},
{"SYS_GETEGID32", Const, 0},
{"SYS_GETEUID", Const, 0},
{"SYS_GETEUID32", Const, 0},
{"SYS_GETFH", Const, 0},
{"SYS_GETFSSTAT", Const, 0},
{"SYS_GETFSSTAT64", Const, 0},
{"SYS_GETGID", Const, 0},
{"SYS_GETGID32", Const, 0},
{"SYS_GETGROUPS", Const, 0},
{"SYS_GETGROUPS32", Const, 0},
{"SYS_GETHOSTUUID", Const, 0},
{"SYS_GETITIMER", Const, 0},
{"SYS_GETLCID", Const, 0},
{"SYS_GETLOGIN", Const, 0},
{"SYS_GETLOGINCLASS", Const, 0},
{"SYS_GETPEERNAME", Const, 0},
{"SYS_GETPGID", Const, 0},
{"SYS_GETPGRP", Const, 0},
{"SYS_GETPID", Const, 0},
{"SYS_GETPMSG", Const, 0},
{"SYS_GETPPID", Const, 0},
{"SYS_GETPRIORITY", Const, 0},
{"SYS_GETRESGID", Const, 0},
{"SYS_GETRESGID32", Const, 0},
{"SYS_GETRESUID", Const, 0},
{"SYS_GETRESUID32", Const, 0},
{"SYS_GETRLIMIT", Const, 0},
{"SYS_GETRTABLE", Const, 1},
{"SYS_GETRUSAGE", Const, 0},
{"SYS_GETSGROUPS", Const, 0},
{"SYS_GETSID", Const, 0},
{"SYS_GETSOCKNAME", Const, 0},
{"SYS_GETSOCKOPT", Const, 0},
{"SYS_GETTHRID", Const, 1},
{"SYS_GETTID", Const, 0},
{"SYS_GETTIMEOFDAY", Const, 0},
{"SYS_GETUID", Const, 0},
{"SYS_GETUID32", Const, 0},
{"SYS_GETVFSSTAT", Const, 1},
{"SYS_GETWGROUPS", Const, 0},
{"SYS_GETXATTR", Const, 0},
{"SYS_GET_KERNEL_SYMS", Const, 0},
{"SYS_GET_MEMPOLICY", Const, 0},
{"SYS_GET_ROBUST_LIST", Const, 0},
{"SYS_GET_THREAD_AREA", Const, 0},
{"SYS_GSSD_SYSCALL", Const, 14},
{"SYS_GTTY", Const, 0},
{"SYS_IDENTITYSVC", Const, 0},
{"SYS_IDLE", Const, 0},
{"SYS_INITGROUPS", Const, 0},
{"SYS_INIT_MODULE", Const, 0},
{"SYS_INOTIFY_ADD_WATCH", Const, 0},
{"SYS_INOTIFY_INIT", Const, 0},
{"SYS_INOTIFY_INIT1", Const, 0},
{"SYS_INOTIFY_RM_WATCH", Const, 0},
{"SYS_IOCTL", Const, 0},
{"SYS_IOPERM", Const, 0},
{"SYS_IOPL", Const, 0},
{"SYS_IOPOLICYSYS", Const, 0},
{"SYS_IOPRIO_GET", Const, 0},
{"SYS_IOPRIO_SET", Const, 0},
{"SYS_IO_CANCEL", Const, 0},
{"SYS_IO_DESTROY", Const, 0},
{"SYS_IO_GETEVENTS", Const, 0},
{"SYS_IO_SETUP", Const, 0},
{"SYS_IO_SUBMIT", Const, 0},
{"SYS_IPC", Const, 0},
{"SYS_ISSETUGID", Const, 0},
{"SYS_JAIL", Const, 0},
{"SYS_JAIL_ATTACH", Const, 0},
{"SYS_JAIL_GET", Const, 0},
{"SYS_JAIL_REMOVE", Const, 0},
{"SYS_JAIL_SET", Const, 0},
{"SYS_KAS_INFO", Const, 16},
{"SYS_KDEBUG_TRACE", Const, 0},
{"SYS_KENV", Const, 0},
{"SYS_KEVENT", Const, 0},
{"SYS_KEVENT64", Const, 0},
{"SYS_KEXEC_LOAD", Const, 0},
{"SYS_KEYCTL", Const, 0},
{"SYS_KILL", Const, 0},
{"SYS_KLDFIND", Const, 0},
{"SYS_KLDFIRSTMOD", Const, 0},
{"SYS_KLDLOAD", Const, 0},
{"SYS_KLDNEXT", Const, 0},
{"SYS_KLDSTAT", Const, 0},
{"SYS_KLDSYM", Const, 0},
{"SYS_KLDUNLOAD", Const, 0},
{"SYS_KLDUNLOADF", Const, 0},
{"SYS_KMQ_NOTIFY", Const, 14},
{"SYS_KMQ_OPEN", Const, 14},
{"SYS_KMQ_SETATTR", Const, 14},
{"SYS_KMQ_TIMEDRECEIVE", Const, 14},
{"SYS_KMQ_TIMEDSEND", Const, 14},
{"SYS_KMQ_UNLINK", Const, 14},
{"SYS_KQUEUE", Const, 0},
{"SYS_KQUEUE1", Const, 1},
{"SYS_KSEM_CLOSE", Const, 14},
{"SYS_KSEM_DESTROY", Const, 14},
{"SYS_KSEM_GETVALUE", Const, 14},
{"SYS_KSEM_INIT", Const, 14},
{"SYS_KSEM_OPEN", Const, 14},
{"SYS_KSEM_POST", Const, 14},
{"SYS_KSEM_TIMEDWAIT", Const, 14},
{"SYS_KSEM_TRYWAIT", Const, 14},
{"SYS_KSEM_UNLINK", Const, 14},
{"SYS_KSEM_WAIT", Const, 14},
{"SYS_KTIMER_CREATE", Const, 0},
{"SYS_KTIMER_DELETE", Const, 0},
{"SYS_KTIMER_GETOVERRUN", Const, 0},
{"SYS_KTIMER_GETTIME", Const, 0},
{"SYS_KTIMER_SETTIME", Const, 0},
{"SYS_KTRACE", Const, 0},
{"SYS_LCHFLAGS", Const, 0},
{"SYS_LCHMOD", Const, 0},
{"SYS_LCHOWN", Const, 0},
{"SYS_LCHOWN32", Const, 0},
{"SYS_LEDGER", Const, 16},
{"SYS_LGETFH", Const, 0},
{"SYS_LGETXATTR", Const, 0},
{"SYS_LINK", Const, 0},
{"SYS_LINKAT", Const, 0},
{"SYS_LIO_LISTIO", Const, 0},
{"SYS_LISTEN", Const, 0},
{"SYS_LISTXATTR", Const, 0},
{"SYS_LLISTXATTR", Const, 0},
{"SYS_LOCK", Const, 0},
{"SYS_LOOKUP_DCOOKIE", Const, 0},
{"SYS_LPATHCONF", Const, 0},
{"SYS_LREMOVEXATTR", Const, 0},
{"SYS_LSEEK", Const, 0},
{"SYS_LSETXATTR", Const, 0},
{"SYS_LSTAT", Const, 0},
{"SYS_LSTAT64", Const, 0},
{"SYS_LSTAT64_EXTENDED", Const, 0},
{"SYS_LSTATV", Const, 0},
{"SYS_LSTAT_EXTENDED", Const, 0},
{"SYS_LUTIMES", Const, 0},
{"SYS_MAC_SYSCALL", Const, 0},
{"SYS_MADVISE", Const, 0},
{"SYS_MADVISE1", Const, 0},
{"SYS_MAXSYSCALL", Const, 0},
{"SYS_MBIND", Const, 0},
{"SYS_MIGRATE_PAGES", Const, 0},
{"SYS_MINCORE", Const, 0},
{"SYS_MINHERIT", Const, 0},
{"SYS_MKCOMPLEX", Const, 0},
{"SYS_MKDIR", Const, 0},
{"SYS_MKDIRAT", Const, 0},
{"SYS_MKDIR_EXTENDED", Const, 0},
{"SYS_MKFIFO", Const, 0},
{"SYS_MKFIFOAT", Const, 0},
{"SYS_MKFIFO_EXTENDED", Const, 0},
{"SYS_MKNOD", Const, 0},
{"SYS_MKNODAT", Const, 0},
{"SYS_MLOCK", Const, 0},
{"SYS_MLOCKALL", Const, 0},
{"SYS_MMAP", Const, 0},
{"SYS_MMAP2", Const, 0},
{"SYS_MODCTL", Const, 1},
{"SYS_MODFIND", Const, 0},
{"SYS_MODFNEXT", Const, 0},
{"SYS_MODIFY_LDT", Const, 0},
{"SYS_MODNEXT", Const, 0},
{"SYS_MODSTAT", Const, 0},
{"SYS_MODWATCH", Const, 0},
{"SYS_MOUNT", Const, 0},
{"SYS_MOVE_PAGES", Const, 0},
{"SYS_MPROTECT", Const, 0},
{"SYS_MPX", Const, 0},
{"SYS_MQUERY", Const, 1},
{"SYS_MQ_GETSETATTR", Const, 0},
{"SYS_MQ_NOTIFY", Const, 0},
{"SYS_MQ_OPEN", Const, 0},
{"SYS_MQ_TIMEDRECEIVE", Const, 0},
{"SYS_MQ_TIMEDSEND", Const, 0},
{"SYS_MQ_UNLINK", Const, 0},
{"SYS_MREMAP", Const, 0},
{"SYS_MSGCTL", Const, 0},
{"SYS_MSGGET", Const, 0},
{"SYS_MSGRCV", Const, 0},
{"SYS_MSGRCV_NOCANCEL", Const, 0},
{"SYS_MSGSND", Const, 0},
{"SYS_MSGSND_NOCANCEL", Const, 0},
{"SYS_MSGSYS", Const, 0},
{"SYS_MSYNC", Const, 0},
{"SYS_MSYNC_NOCANCEL", Const, 0},
{"SYS_MUNLOCK", Const, 0},
{"SYS_MUNLOCKALL", Const, 0},
{"SYS_MUNMAP", Const, 0},
{"SYS_NAME_TO_HANDLE_AT", Const, 0},
{"SYS_NANOSLEEP", Const, 0},
{"SYS_NEWFSTATAT", Const, 0},
{"SYS_NFSCLNT", Const, 0},
{"SYS_NFSSERVCTL", Const, 0},
{"SYS_NFSSVC", Const, 0},
{"SYS_NFSTAT", Const, 0},
{"SYS_NICE", Const, 0},
{"SYS_NLM_SYSCALL", Const, 14},
{"SYS_NLSTAT", Const, 0},
{"SYS_NMOUNT", Const, 0},
{"SYS_NSTAT", Const, 0},
{"SYS_NTP_ADJTIME", Const, 0},
{"SYS_NTP_GETTIME", Const, 0},
{"SYS_NUMA_GETAFFINITY", Const, 14},
{"SYS_NUMA_SETAFFINITY", Const, 14},
{"SYS_OABI_SYSCALL_BASE", Const, 0},
{"SYS_OBREAK", Const, 0},
{"SYS_OLDFSTAT", Const, 0},
{"SYS_OLDLSTAT", Const, 0},
{"SYS_OLDOLDUNAME", Const, 0},
{"SYS_OLDSTAT", Const, 0},
{"SYS_OLDUNAME", Const, 0},
{"SYS_OPEN", Const, 0},
{"SYS_OPENAT", Const, 0},
{"SYS_OPENBSD_POLL", Const, 0},
{"SYS_OPEN_BY_HANDLE_AT", Const, 0},
{"SYS_OPEN_DPROTECTED_NP", Const, 16},
{"SYS_OPEN_EXTENDED", Const, 0},
{"SYS_OPEN_NOCANCEL", Const, 0},
{"SYS_OVADVISE", Const, 0},
{"SYS_PACCEPT", Const, 1},
{"SYS_PATHCONF", Const, 0},
{"SYS_PAUSE", Const, 0},
{"SYS_PCICONFIG_IOBASE", Const, 0},
{"SYS_PCICONFIG_READ", Const, 0},
{"SYS_PCICONFIG_WRITE", Const, 0},
{"SYS_PDFORK", Const, 0},
{"SYS_PDGETPID", Const, 0},
{"SYS_PDKILL", Const, 0},
{"SYS_PERF_EVENT_OPEN", Const, 0},
{"SYS_PERSONALITY", Const, 0},
{"SYS_PID_HIBERNATE", Const, 0},
{"SYS_PID_RESUME", Const, 0},
{"SYS_PID_SHUTDOWN_SOCKETS", Const, 0},
{"SYS_PID_SUSPEND", Const, 0},
{"SYS_PIPE", Const, 0},
{"SYS_PIPE2", Const, 0},
{"SYS_PIVOT_ROOT", Const, 0},
{"SYS_PMC_CONTROL", Const, 1},
{"SYS_PMC_GET_INFO", Const, 1},
{"SYS_POLL", Const, 0},
{"SYS_POLLTS", Const, 1},
{"SYS_POLL_NOCANCEL", Const, 0},
{"SYS_POSIX_FADVISE", Const, 0},
{"SYS_POSIX_FALLOCATE", Const, 0},
{"SYS_POSIX_OPENPT", Const, 0},
{"SYS_POSIX_SPAWN", Const, 0},
{"SYS_PPOLL", Const, 0},
{"SYS_PRCTL", Const, 0},
{"SYS_PREAD", Const, 0},
{"SYS_PREAD64", Const, 0},
{"SYS_PREADV", Const, 0},
{"SYS_PREAD_NOCANCEL", Const, 0},
{"SYS_PRLIMIT64", Const, 0},
{"SYS_PROCCTL", Const, 3},
{"SYS_PROCESS_POLICY", Const, 0},
{"SYS_PROCESS_VM_READV", Const, 0},
{"SYS_PROCESS_VM_WRITEV", Const, 0},
{"SYS_PROC_INFO", Const, 0},
{"SYS_PROF", Const, 0},
{"SYS_PROFIL", Const, 0},
{"SYS_PSELECT", Const, 0},
{"SYS_PSELECT6", Const, 0},
{"SYS_PSET_ASSIGN", Const, 1},
{"SYS_PSET_CREATE", Const, 1},
{"SYS_PSET_DESTROY", Const, 1},
{"SYS_PSYNCH_CVBROAD", Const, 0},
{"SYS_PSYNCH_CVCLRPREPOST", Const, 0},
{"SYS_PSYNCH_CVSIGNAL", Const, 0},
{"SYS_PSYNCH_CVWAIT", Const, 0},
{"SYS_PSYNCH_MUTEXDROP", Const, 0},
{"SYS_PSYNCH_MUTEXWAIT", Const, 0},
{"SYS_PSYNCH_RW_DOWNGRADE", Const, 0},
{"SYS_PSYNCH_RW_LONGRDLOCK", Const, 0},
{"SYS_PSYNCH_RW_RDLOCK", Const, 0},
{"SYS_PSYNCH_RW_UNLOCK", Const, 0},
{"SYS_PSYNCH_RW_UNLOCK2", Const, 0},
{"SYS_PSYNCH_RW_UPGRADE", Const, 0},
{"SYS_PSYNCH_RW_WRLOCK", Const, 0},
{"SYS_PSYNCH_RW_YIELDWRLOCK", Const, 0},
{"SYS_PTRACE", Const, 0},
{"SYS_PUTPMSG", Const, 0},
{"SYS_PWRITE", Const, 0},
{"SYS_PWRITE64", Const, 0},
{"SYS_PWRITEV", Const, 0},
{"SYS_PWRITE_NOCANCEL", Const, 0},
{"SYS_QUERY_MODULE", Const, 0},
{"SYS_QUOTACTL", Const, 0},
{"SYS_RASCTL", Const, 1},
{"SYS_RCTL_ADD_RULE", Const, 0},
{"SYS_RCTL_GET_LIMITS", Const, 0},
{"SYS_RCTL_GET_RACCT", Const, 0},
{"SYS_RCTL_GET_RULES", Const, 0},
{"SYS_RCTL_REMOVE_RULE", Const, 0},
{"SYS_READ", Const, 0},
{"SYS_READAHEAD", Const, 0},
{"SYS_READDIR", Const, 0},
{"SYS_READLINK", Const, 0},
{"SYS_READLINKAT", Const, 0},
{"SYS_READV", Const, 0},
{"SYS_READV_NOCANCEL", Const, 0},
{"SYS_READ_NOCANCEL", Const, 0},
{"SYS_REBOOT", Const, 0},
{"SYS_RECV", Const, 0},
{"SYS_RECVFROM", Const, 0},
{"SYS_RECVFROM_NOCANCEL", Const, 0},
{"SYS_RECVMMSG", Const, 0},
{"SYS_RECVMSG", Const, 0},
{"SYS_RECVMSG_NOCANCEL", Const, 0},
{"SYS_REMAP_FILE_PAGES", Const, 0},
{"SYS_REMOVEXATTR", Const, 0},
{"SYS_RENAME", Const, 0},
{"SYS_RENAMEAT", Const, 0},
{"SYS_REQUEST_KEY", Const, 0},
{"SYS_RESTART_SYSCALL", Const, 0},
{"SYS_REVOKE", Const, 0},
{"SYS_RFORK", Const, 0},
{"SYS_RMDIR", Const, 0},
{"SYS_RTPRIO", Const, 0},
{"SYS_RTPRIO_THREAD", Const, 0},
{"SYS_RT_SIGACTION", Const, 0},
{"SYS_RT_SIGPENDING", Const, 0},
{"SYS_RT_SIGPROCMASK", Const, 0},
{"SYS_RT_SIGQUEUEINFO", Const, 0},
{"SYS_RT_SIGRETURN", Const, 0},
{"SYS_RT_SIGSUSPEND", Const, 0},
{"SYS_RT_SIGTIMEDWAIT", Const, 0},
{"SYS_RT_TGSIGQUEUEINFO", Const, 0},
{"SYS_SBRK", Const, 0},
{"SYS_SCHED_GETAFFINITY", Const, 0},
{"SYS_SCHED_GETPARAM", Const, 0},
{"SYS_SCHED_GETSCHEDULER", Const, 0},
{"SYS_SCHED_GET_PRIORITY_MAX", Const, 0},
{"SYS_SCHED_GET_PRIORITY_MIN", Const, 0},
{"SYS_SCHED_RR_GET_INTERVAL", Const, 0},
{"SYS_SCHED_SETAFFINITY", Const, 0},
{"SYS_SCHED_SETPARAM", Const, 0},
{"SYS_SCHED_SETSCHEDULER", Const, 0},
{"SYS_SCHED_YIELD", Const, 0},
{"SYS_SCTP_GENERIC_RECVMSG", Const, 0},
{"SYS_SCTP_GENERIC_SENDMSG", Const, 0},
{"SYS_SCTP_GENERIC_SENDMSG_IOV", Const, 0},
{"SYS_SCTP_PEELOFF", Const, 0},
{"SYS_SEARCHFS", Const, 0},
{"SYS_SECURITY", Const, 0},
{"SYS_SELECT", Const, 0},
{"SYS_SELECT_NOCANCEL", Const, 0},
{"SYS_SEMCONFIG", Const, 1},
{"SYS_SEMCTL", Const, 0},
{"SYS_SEMGET", Const, 0},
{"SYS_SEMOP", Const, 0},
{"SYS_SEMSYS", Const, 0},
{"SYS_SEMTIMEDOP", Const, 0},
{"SYS_SEM_CLOSE", Const, 0},
{"SYS_SEM_DESTROY", Const, 0},
{"SYS_SEM_GETVALUE", Const, 0},
{"SYS_SEM_INIT", Const, 0},
{"SYS_SEM_OPEN", Const, 0},
{"SYS_SEM_POST", Const, 0},
{"SYS_SEM_TRYWAIT", Const, 0},
{"SYS_SEM_UNLINK", Const, 0},
{"SYS_SEM_WAIT", Const, 0},
{"SYS_SEM_WAIT_NOCANCEL", Const, 0},
{"SYS_SEND", Const, 0},
{"SYS_SENDFILE", Const, 0},
{"SYS_SENDFILE64", Const, 0},
{"SYS_SENDMMSG", Const, 0},
{"SYS_SENDMSG", Const, 0},
{"SYS_SENDMSG_NOCANCEL", Const, 0},
{"SYS_SENDTO", Const, 0},
{"SYS_SENDTO_NOCANCEL", Const, 0},
{"SYS_SETATTRLIST", Const, 0},
{"SYS_SETAUDIT", Const, 0},
{"SYS_SETAUDIT_ADDR", Const, 0},
{"SYS_SETAUID", Const, 0},
{"SYS_SETCONTEXT", Const, 0},
{"SYS_SETDOMAINNAME", Const, 0},
{"SYS_SETEGID", Const, 0},
{"SYS_SETEUID", Const, 0},
{"SYS_SETFIB", Const, 0},
{"SYS_SETFSGID", Const, 0},
{"SYS_SETFSGID32", Const, 0},
{"SYS_SETFSUID", Const, 0},
{"SYS_SETFSUID32", Const, 0},
{"SYS_SETGID", Const, 0},
{"SYS_SETGID32", Const, 0},
{"SYS_SETGROUPS", Const, 0},
{"SYS_SETGROUPS32", Const, 0},
{"SYS_SETHOSTNAME", Const, 0},
{"SYS_SETITIMER", Const, 0},
{"SYS_SETLCID", Const, 0},
{"SYS_SETLOGIN", Const, 0},
{"SYS_SETLOGINCLASS", Const, 0},
{"SYS_SETNS", Const, 0},
{"SYS_SETPGID", Const, 0},
{"SYS_SETPRIORITY", Const, 0},
{"SYS_SETPRIVEXEC", Const, 0},
{"SYS_SETREGID", Const, 0},
{"SYS_SETREGID32", Const, 0},
{"SYS_SETRESGID", Const, 0},
{"SYS_SETRESGID32", Const, 0},
{"SYS_SETRESUID", Const, 0},
{"SYS_SETRESUID32", Const, 0},
{"SYS_SETREUID", Const, 0},
{"SYS_SETREUID32", Const, 0},
{"SYS_SETRLIMIT", Const, 0},
{"SYS_SETRTABLE", Const, 1},
{"SYS_SETSGROUPS", Const, 0},
{"SYS_SETSID", Const, 0},
{"SYS_SETSOCKOPT", Const, 0},
{"SYS_SETTID", Const, 0},
{"SYS_SETTID_WITH_PID", Const, 0},
{"SYS_SETTIMEOFDAY", Const, 0},
{"SYS_SETUID", Const, 0},
{"SYS_SETUID32", Const, 0},
{"SYS_SETWGROUPS", Const, 0},
{"SYS_SETXATTR", Const, 0},
{"SYS_SET_MEMPOLICY", Const, 0},
{"SYS_SET_ROBUST_LIST", Const, 0},
{"SYS_SET_THREAD_AREA", Const, 0},
{"SYS_SET_TID_ADDRESS", Const, 0},
{"SYS_SGETMASK", Const, 0},
{"SYS_SHARED_REGION_CHECK_NP", Const, 0},
{"SYS_SHARED_REGION_MAP_AND_SLIDE_NP", Const, 0},
{"SYS_SHMAT", Const, 0},
{"SYS_SHMCTL", Const, 0},
{"SYS_SHMDT", Const, 0},
{"SYS_SHMGET", Const, 0},
{"SYS_SHMSYS", Const, 0},
{"SYS_SHM_OPEN", Const, 0},
{"SYS_SHM_UNLINK", Const, 0},
{"SYS_SHUTDOWN", Const, 0},
{"SYS_SIGACTION", Const, 0},
{"SYS_SIGALTSTACK", Const, 0},
{"SYS_SIGNAL", Const, 0},
{"SYS_SIGNALFD", Const, 0},
{"SYS_SIGNALFD4", Const, 0},
{"SYS_SIGPENDING", Const, 0},
{"SYS_SIGPROCMASK", Const, 0},
{"SYS_SIGQUEUE", Const, 0},
{"SYS_SIGQUEUEINFO", Const, 1},
{"SYS_SIGRETURN", Const, 0},
{"SYS_SIGSUSPEND", Const, 0},
{"SYS_SIGSUSPEND_NOCANCEL", Const, 0},
{"SYS_SIGTIMEDWAIT", Const, 0},
{"SYS_SIGWAIT", Const, 0},
{"SYS_SIGWAITINFO", Const, 0},
{"SYS_SOCKET", Const, 0},
{"SYS_SOCKETCALL", Const, 0},
{"SYS_SOCKETPAIR", Const, 0},
{"SYS_SPLICE", Const, 0},
{"SYS_SSETMASK", Const, 0},
{"SYS_SSTK", Const, 0},
{"SYS_STACK_SNAPSHOT", Const, 0},
{"SYS_STAT", Const, 0},
{"SYS_STAT64", Const, 0},
{"SYS_STAT64_EXTENDED", Const, 0},
{"SYS_STATFS", Const, 0},
{"SYS_STATFS64", Const, 0},
{"SYS_STATV", Const, 0},
{"SYS_STATVFS1", Const, 1},
{"SYS_STAT_EXTENDED", Const, 0},
{"SYS_STIME", Const, 0},
{"SYS_STTY", Const, 0},
{"SYS_SWAPCONTEXT", Const, 0},
{"SYS_SWAPCTL", Const, 1},
{"SYS_SWAPOFF", Const, 0},
{"SYS_SWAPON", Const, 0},
{"SYS_SYMLINK", Const, 0},
{"SYS_SYMLINKAT", Const, 0},
{"SYS_SYNC", Const, 0},
{"SYS_SYNCFS", Const, 0},
{"SYS_SYNC_FILE_RANGE", Const, 0},
{"SYS_SYSARCH", Const, 0},
{"SYS_SYSCALL", Const, 0},
{"SYS_SYSCALL_BASE", Const, 0},
{"SYS_SYSFS", Const, 0},
{"SYS_SYSINFO", Const, 0},
{"SYS_SYSLOG", Const, 0},
{"SYS_TEE", Const, 0},
{"SYS_TGKILL", Const, 0},
{"SYS_THREAD_SELFID", Const, 0},
{"SYS_THR_CREATE", Const, 0},
{"SYS_THR_EXIT", Const, 0},
{"SYS_THR_KILL", Const, 0},
{"SYS_THR_KILL2", Const, 0},
{"SYS_THR_NEW", Const, 0},
{"SYS_THR_SELF", Const, 0},
{"SYS_THR_SET_NAME", Const, 0},
{"SYS_THR_SUSPEND", Const, 0},
{"SYS_THR_WAKE", Const, 0},
{"SYS_TIME", Const, 0},
{"SYS_TIMERFD_CREATE", Const, 0},
{"SYS_TIMERFD_GETTIME", Const, 0},
{"SYS_TIMERFD_SETTIME", Const, 0},
{"SYS_TIMER_CREATE", Const, 0},
{"SYS_TIMER_DELETE", Const, 0},
{"SYS_TIMER_GETOVERRUN", Const, 0},
{"SYS_TIMER_GETTIME", Const, 0},
{"SYS_TIMER_SETTIME", Const, 0},
{"SYS_TIMES", Const, 0},
{"SYS_TKILL", Const, 0},
{"SYS_TRUNCATE", Const, 0},
{"SYS_TRUNCATE64", Const, 0},
{"SYS_TUXCALL", Const, 0},
{"SYS_UGETRLIMIT", Const, 0},
{"SYS_ULIMIT", Const, 0},
{"SYS_UMASK", Const, 0},
{"SYS_UMASK_EXTENDED", Const, 0},
{"SYS_UMOUNT", Const, 0},
{"SYS_UMOUNT2", Const, 0},
{"SYS_UNAME", Const, 0},
{"SYS_UNDELETE", Const, 0},
{"SYS_UNLINK", Const, 0},
{"SYS_UNLINKAT", Const, 0},
{"SYS_UNMOUNT", Const, 0},
{"SYS_UNSHARE", Const, 0},
{"SYS_USELIB", Const, 0},
{"SYS_USTAT", Const, 0},
{"SYS_UTIME", Const, 0},
{"SYS_UTIMENSAT", Const, 0},
{"SYS_UTIMES", Const, 0},
{"SYS_UTRACE", Const, 0},
{"SYS_UUIDGEN", Const, 0},
{"SYS_VADVISE", Const, 1},
{"SYS_VFORK", Const, 0},
{"SYS_VHANGUP", Const, 0},
{"SYS_VM86", Const, 0},
{"SYS_VM86OLD", Const, 0},
{"SYS_VMSPLICE", Const, 0},
{"SYS_VM_PRESSURE_MONITOR", Const, 0},
{"SYS_VSERVER", Const, 0},
{"SYS_WAIT4", Const, 0},
{"SYS_WAIT4_NOCANCEL", Const, 0},
{"SYS_WAIT6", Const, 1},
{"SYS_WAITEVENT", Const, 0},
{"SYS_WAITID", Const, 0},
{"SYS_WAITID_NOCANCEL", Const, 0},
{"SYS_WAITPID", Const, 0},
{"SYS_WATCHEVENT", Const, 0},
{"SYS_WORKQ_KERNRETURN", Const, 0},
{"SYS_WORKQ_OPEN", Const, 0},
{"SYS_WRITE", Const, 0},
{"SYS_WRITEV", Const, 0},
{"SYS_WRITEV_NOCANCEL", Const, 0},
{"SYS_WRITE_NOCANCEL", Const, 0},
{"SYS_YIELD", Const, 0},
{"SYS__LLSEEK", Const, 0},
{"SYS__LWP_CONTINUE", Const, 1},
{"SYS__LWP_CREATE", Const, 1},
{"SYS__LWP_CTL", Const, 1},
{"SYS__LWP_DETACH", Const, 1},
{"SYS__LWP_EXIT", Const, 1},
{"SYS__LWP_GETNAME", Const, 1},
{"SYS__LWP_GETPRIVATE", Const, 1},
{"SYS__LWP_KILL", Const, 1},
{"SYS__LWP_PARK", Const, 1},
{"SYS__LWP_SELF", Const, 1},
{"SYS__LWP_SETNAME", Const, 1},
{"SYS__LWP_SETPRIVATE", Const, 1},
{"SYS__LWP_SUSPEND", Const, 1},
{"SYS__LWP_UNPARK", Const, 1},
{"SYS__LWP_UNPARK_ALL", Const, 1},
{"SYS__LWP_WAIT", Const, 1},
{"SYS__LWP_WAKEUP", Const, 1},
{"SYS__NEWSELECT", Const, 0},
{"SYS__PSET_BIND", Const, 1},
{"SYS__SCHED_GETAFFINITY", Const, 1},
{"SYS__SCHED_GETPARAM", Const, 1},
{"SYS__SCHED_SETAFFINITY", Const, 1},
{"SYS__SCHED_SETPARAM", Const, 1},
{"SYS__SYSCTL", Const, 0},
{"SYS__UMTX_LOCK", Const, 0},
{"SYS__UMTX_OP", Const, 0},
{"SYS__UMTX_UNLOCK", Const, 0},
{"SYS___ACL_ACLCHECK_FD", Const, 0},
{"SYS___ACL_ACLCHECK_FILE", Const, 0},
{"SYS___ACL_ACLCHECK_LINK", Const, 0},
{"SYS___ACL_DELETE_FD", Const, 0},
{"SYS___ACL_DELETE_FILE", Const, 0},
{"SYS___ACL_DELETE_LINK", Const, 0},
{"SYS___ACL_GET_FD", Const, 0},
{"SYS___ACL_GET_FILE", Const, 0},
{"SYS___ACL_GET_LINK", Const, 0},
{"SYS___ACL_SET_FD", Const, 0},
{"SYS___ACL_SET_FILE", Const, 0},
{"SYS___ACL_SET_LINK", Const, 0},
{"SYS___CAP_RIGHTS_GET", Const, 14},
{"SYS___CLONE", Const, 1},
{"SYS___DISABLE_THREADSIGNAL", Const, 0},
{"SYS___GETCWD", Const, 0},
{"SYS___GETLOGIN", Const, 1},
{"SYS___GET_TCB", Const, 1},
{"SYS___MAC_EXECVE", Const, 0},
{"SYS___MAC_GETFSSTAT", Const, 0},
{"SYS___MAC_GET_FD", Const, 0},
{"SYS___MAC_GET_FILE", Const, 0},
{"SYS___MAC_GET_LCID", Const, 0},
{"SYS___MAC_GET_LCTX", Const, 0},
{"SYS___MAC_GET_LINK", Const, 0},
{"SYS___MAC_GET_MOUNT", Const, 0},
{"SYS___MAC_GET_PID", Const, 0},
{"SYS___MAC_GET_PROC", Const, 0},
{"SYS___MAC_MOUNT", Const, 0},
{"SYS___MAC_SET_FD", Const, 0},
{"SYS___MAC_SET_FILE", Const, 0},
{"SYS___MAC_SET_LCTX", Const, 0},
{"SYS___MAC_SET_LINK", Const, 0},
{"SYS___MAC_SET_PROC", Const, 0},
{"SYS___MAC_SYSCALL", Const, 0},
{"SYS___OLD_SEMWAIT_SIGNAL", Const, 0},
{"SYS___OLD_SEMWAIT_SIGNAL_NOCANCEL", Const, 0},
{"SYS___POSIX_CHOWN", Const, 1},
{"SYS___POSIX_FCHOWN", Const, 1},
{"SYS___POSIX_LCHOWN", Const, 1},
{"SYS___POSIX_RENAME", Const, 1},
{"SYS___PTHREAD_CANCELED", Const, 0},
{"SYS___PTHREAD_CHDIR", Const, 0},
{"SYS___PTHREAD_FCHDIR", Const, 0},
{"SYS___PTHREAD_KILL", Const, 0},
{"SYS___PTHREAD_MARKCANCEL", Const, 0},
{"SYS___PTHREAD_SIGMASK", Const, 0},
{"SYS___QUOTACTL", Const, 1},
{"SYS___SEMCTL", Const, 1},
{"SYS___SEMWAIT_SIGNAL", Const, 0},
{"SYS___SEMWAIT_SIGNAL_NOCANCEL", Const, 0},
{"SYS___SETLOGIN", Const, 1},
{"SYS___SETUGID", Const, 0},
{"SYS___SET_TCB", Const, 1},
{"SYS___SIGACTION_SIGTRAMP", Const, 1},
{"SYS___SIGTIMEDWAIT", Const, 1},
{"SYS___SIGWAIT", Const, 0},
{"SYS___SIGWAIT_NOCANCEL", Const, 0},
{"SYS___SYSCTL", Const, 0},
{"SYS___TFORK", Const, 1},
{"SYS___THREXIT", Const, 1},
{"SYS___THRSIGDIVERT", Const, 1},
{"SYS___THRSLEEP", Const, 1},
{"SYS___THRWAKEUP", Const, 1},
{"S_ARCH1", Const, 1},
{"S_ARCH2", Const, 1},
{"S_BLKSIZE", Const, 0},
{"S_IEXEC", Const, 0},
{"S_IFBLK", Const, 0},
{"S_IFCHR", Const, 0},
{"S_IFDIR", Const, 0},
{"S_IFIFO", Const, 0},
{"S_IFLNK", Const, 0},
{"S_IFMT", Const, 0},
{"S_IFREG", Const, 0},
{"S_IFSOCK", Const, 0},
{"S_IFWHT", Const, 0},
{"S_IREAD", Const, 0},
{"S_IRGRP", Const, 0},
{"S_IROTH", Const, 0},
{"S_IRUSR", Const, 0},
{"S_IRWXG", Const, 0},
{"S_IRWXO", Const, 0},
{"S_IRWXU", Const, 0},
{"S_ISGID", Const, 0},
{"S_ISTXT", Const, 0},
{"S_ISUID", Const, 0},
{"S_ISVTX", Const, 0},
{"S_IWGRP", Const, 0},
{"S_IWOTH", Const, 0},
{"S_IWRITE", Const, 0},
{"S_IWUSR", Const, 0},
{"S_IXGRP", Const, 0},
{"S_IXOTH", Const, 0},
{"S_IXUSR", Const, 0},
{"S_LOGIN_SET", Const, 1},
{"SecurityAttributes", Type, 0},
{"SecurityAttributes.InheritHandle", Field, 0},
{"SecurityAttributes.Length", Field, 0},
{"SecurityAttributes.SecurityDescriptor", Field, 0},
{"Seek", Func, 0},
{"Select", Func, 0},
{"Sendfile", Func, 0},
{"Sendmsg", Func, 0},
{"SendmsgN", Func, 3},
{"Sendto", Func, 0},
{"Servent", Type, 0},
{"Servent.Aliases", Field, 0},
{"Servent.Name", Field, 0},
{"Servent.Port", Field, 0},
{"Servent.Proto", Field, 0},
{"SetBpf", Func, 0},
{"SetBpfBuflen", Func, 0},
{"SetBpfDatalink", Func, 0},
{"SetBpfHeadercmpl", Func, 0},
{"SetBpfImmediate", Func, 0},
{"SetBpfInterface", Func, 0},
{"SetBpfPromisc", Func, 0},
{"SetBpfTimeout", Func, 0},
{"SetCurrentDirectory", Func, 0},
{"SetEndOfFile", Func, 0},
{"SetEnvironmentVariable", Func, 0},
{"SetFileAttributes", Func, 0},
{"SetFileCompletionNotificationModes", Func, 2},
{"SetFilePointer", Func, 0},
{"SetFileTime", Func, 0},
{"SetHandleInformation", Func, 0},
{"SetKevent", Func, 0},
{"SetLsfPromisc", Func, 0},
{"SetNonblock", Func, 0},
{"Setdomainname", Func, 0},
{"Setegid", Func, 0},
{"Setenv", Func, 0},
{"Seteuid", Func, 0},
{"Setfsgid", Func, 0},
{"Setfsuid", Func, 0},
{"Setgid", Func, 0},
{"Setgroups", Func, 0},
{"Sethostname", Func, 0},
{"Setlogin", Func, 0},
{"Setpgid", Func, 0},
{"Setpriority", Func, 0},
{"Setprivexec", Func, 0},
{"Setregid", Func, 0},
{"Setresgid", Func, 0},
{"Setresuid", Func, 0},
{"Setreuid", Func, 0},
{"Setrlimit", Func, 0},
{"Setsid", Func, 0},
{"Setsockopt", Func, 0},
{"SetsockoptByte", Func, 0},
{"SetsockoptICMPv6Filter", Func, 2},
{"SetsockoptIPMreq", Func, 0},
{"SetsockoptIPMreqn", Func, 0},
{"SetsockoptIPv6Mreq", Func, 0},
{"SetsockoptInet4Addr", Func, 0},
{"SetsockoptInt", Func, 0},
{"SetsockoptLinger", Func, 0},
{"SetsockoptString", Func, 0},
{"SetsockoptTimeval", Func, 0},
{"Settimeofday", Func, 0},
{"Setuid", Func, 0},
{"Setxattr", Func, 1},
{"Shutdown", Func, 0},
{"SidTypeAlias", Const, 0},
{"SidTypeComputer", Const, 0},
{"SidTypeDeletedAccount", Const, 0},
{"SidTypeDomain", Const, 0},
{"SidTypeGroup", Const, 0},
{"SidTypeInvalid", Const, 0},
{"SidTypeLabel", Const, 0},
{"SidTypeUnknown", Const, 0},
{"SidTypeUser", Const, 0},
{"SidTypeWellKnownGroup", Const, 0},
{"Signal", Type, 0},
{"SizeofBpfHdr", Const, 0},
{"SizeofBpfInsn", Const, 0},
{"SizeofBpfProgram", Const, 0},
{"SizeofBpfStat", Const, 0},
{"SizeofBpfVersion", Const, 0},
{"SizeofBpfZbuf", Const, 0},
{"SizeofBpfZbufHeader", Const, 0},
{"SizeofCmsghdr", Const, 0},
{"SizeofICMPv6Filter", Const, 2},
{"SizeofIPMreq", Const, 0},
{"SizeofIPMreqn", Const, 0},
{"SizeofIPv6MTUInfo", Const, 2},
{"SizeofIPv6Mreq", Const, 0},
{"SizeofIfAddrmsg", Const, 0},
{"SizeofIfAnnounceMsghdr", Const, 1},
{"SizeofIfData", Const, 0},
{"SizeofIfInfomsg", Const, 0},
{"SizeofIfMsghdr", Const, 0},
{"SizeofIfaMsghdr", Const, 0},
{"SizeofIfmaMsghdr", Const, 0},
{"SizeofIfmaMsghdr2", Const, 0},
{"SizeofInet4Pktinfo", Const, 0},
{"SizeofInet6Pktinfo", Const, 0},
{"SizeofInotifyEvent", Const, 0},
{"SizeofLinger", Const, 0},
{"SizeofMsghdr", Const, 0},
{"SizeofNlAttr", Const, 0},
{"SizeofNlMsgerr", Const, 0},
{"SizeofNlMsghdr", Const, 0},
{"SizeofRtAttr", Const, 0},
{"SizeofRtGenmsg", Const, 0},
{"SizeofRtMetrics", Const, 0},
{"SizeofRtMsg", Const, 0},
{"SizeofRtMsghdr", Const, 0},
{"SizeofRtNexthop", Const, 0},
{"SizeofSockFilter", Const, 0},
{"SizeofSockFprog", Const, 0},
{"SizeofSockaddrAny", Const, 0},
{"SizeofSockaddrDatalink", Const, 0},
{"SizeofSockaddrInet4", Const, 0},
{"SizeofSockaddrInet6", Const, 0},
{"SizeofSockaddrLinklayer", Const, 0},
{"SizeofSockaddrNetlink", Const, 0},
{"SizeofSockaddrUnix", Const, 0},
{"SizeofTCPInfo", Const, 1},
{"SizeofUcred", Const, 0},
{"SlicePtrFromStrings", Func, 1},
{"SockFilter", Type, 0},
{"SockFilter.Code", Field, 0},
{"SockFilter.Jf", Field, 0},
{"SockFilter.Jt", Field, 0},
{"SockFilter.K", Field, 0},
{"SockFprog", Type, 0},
{"SockFprog.Filter", Field, 0},
{"SockFprog.Len", Field, 0},
{"SockFprog.Pad_cgo_0", Field, 0},
{"Sockaddr", Type, 0},
{"SockaddrDatalink", Type, 0},
{"SockaddrDatalink.Alen", Field, 0},
{"SockaddrDatalink.Data", Field, 0},
{"SockaddrDatalink.Family", Field, 0},
{"SockaddrDatalink.Index", Field, 0},
{"SockaddrDatalink.Len", Field, 0},
{"SockaddrDatalink.Nlen", Field, 0},
{"SockaddrDatalink.Slen", Field, 0},
{"SockaddrDatalink.Type", Field, 0},
{"SockaddrGen", Type, 0},
{"SockaddrInet4", Type, 0},
{"SockaddrInet4.Addr", Field, 0},
{"SockaddrInet4.Port", Field, 0},
{"SockaddrInet6", Type, 0},
{"SockaddrInet6.Addr", Field, 0},
{"SockaddrInet6.Port", Field, 0},
{"SockaddrInet6.ZoneId", Field, 0},
{"SockaddrLinklayer", Type, 0},
{"SockaddrLinklayer.Addr", Field, 0},
{"SockaddrLinklayer.Halen", Field, 0},
{"SockaddrLinklayer.Hatype", Field, 0},
{"SockaddrLinklayer.Ifindex", Field, 0},
{"SockaddrLinklayer.Pkttype", Field, 0},
{"SockaddrLinklayer.Protocol", Field, 0},
{"SockaddrNetlink", Type, 0},
{"SockaddrNetlink.Family", Field, 0},
{"SockaddrNetlink.Groups", Field, 0},
{"SockaddrNetlink.Pad", Field, 0},
{"SockaddrNetlink.Pid", Field, 0},
{"SockaddrUnix", Type, 0},
{"SockaddrUnix.Name", Field, 0},
{"Socket", Func, 0},
{"SocketControlMessage", Type, 0},
{"SocketControlMessage.Data", Field, 0},
{"SocketControlMessage.Header", Field, 0},
{"SocketDisableIPv6", Var, 0},
{"Socketpair", Func, 0},
{"Splice", Func, 0},
{"StartProcess", Func, 0},
{"StartupInfo", Type, 0},
{"StartupInfo.Cb", Field, 0},
{"StartupInfo.Desktop", Field, 0},
{"StartupInfo.FillAttribute", Field, 0},
{"StartupInfo.Flags", Field, 0},
{"StartupInfo.ShowWindow", Field, 0},
{"StartupInfo.StdErr", Field, 0},
{"StartupInfo.StdInput", Field, 0},
{"StartupInfo.StdOutput", Field, 0},
{"StartupInfo.Title", Field, 0},
{"StartupInfo.X", Field, 0},
{"StartupInfo.XCountChars", Field, 0},
{"StartupInfo.XSize", Field, 0},
{"StartupInfo.Y", Field, 0},
{"StartupInfo.YCountChars", Field, 0},
{"StartupInfo.YSize", Field, 0},
{"Stat", Func, 0},
{"Stat_t", Type, 0},
{"Stat_t.Atim", Field, 0},
{"Stat_t.Atim_ext", Field, 12},
{"Stat_t.Atimespec", Field, 0},
{"Stat_t.Birthtimespec", Field, 0},
{"Stat_t.Blksize", Field, 0},
{"Stat_t.Blocks", Field, 0},
{"Stat_t.Btim_ext", Field, 12},
{"Stat_t.Ctim", Field, 0},
{"Stat_t.Ctim_ext", Field, 12},
{"Stat_t.Ctimespec", Field, 0},
{"Stat_t.Dev", Field, 0},
{"Stat_t.Flags", Field, 0},
{"Stat_t.Gen", Field, 0},
{"Stat_t.Gid", Field, 0},
{"Stat_t.Ino", Field, 0},
{"Stat_t.Lspare", Field, 0},
{"Stat_t.Lspare0", Field, 2},
{"Stat_t.Lspare1", Field, 2},
{"Stat_t.Mode", Field, 0},
{"Stat_t.Mtim", Field, 0},
{"Stat_t.Mtim_ext", Field, 12},
{"Stat_t.Mtimespec", Field, 0},
{"Stat_t.Nlink", Field, 0},
{"Stat_t.Pad_cgo_0", Field, 0},
{"Stat_t.Pad_cgo_1", Field, 0},
{"Stat_t.Pad_cgo_2", Field, 0},
{"Stat_t.Padding0", Field, 12},
{"Stat_t.Padding1", Field, 12},
{"Stat_t.Qspare", Field, 0},
{"Stat_t.Rdev", Field, 0},
{"Stat_t.Size", Field, 0},
{"Stat_t.Spare", Field, 2},
{"Stat_t.Uid", Field, 0},
{"Stat_t.X__pad0", Field, 0},
{"Stat_t.X__pad1", Field, 0},
{"Stat_t.X__pad2", Field, 0},
{"Stat_t.X__st_birthtim", Field, 2},
{"Stat_t.X__st_ino", Field, 0},
{"Stat_t.X__unused", Field, 0},
{"Statfs", Func, 0},
{"Statfs_t", Type, 0},
{"Statfs_t.Asyncreads", Field, 0},
{"Statfs_t.Asyncwrites", Field, 0},
{"Statfs_t.Bavail", Field, 0},
{"Statfs_t.Bfree", Field, 0},
{"Statfs_t.Blocks", Field, 0},
{"Statfs_t.Bsize", Field, 0},
{"Statfs_t.Charspare", Field, 0},
{"Statfs_t.F_asyncreads", Field, 2},
{"Statfs_t.F_asyncwrites", Field, 2},
{"Statfs_t.F_bavail", Field, 2},
{"Statfs_t.F_bfree", Field, 2},
{"Statfs_t.F_blocks", Field, 2},
{"Statfs_t.F_bsize", Field, 2},
{"Statfs_t.F_ctime", Field, 2},
{"Statfs_t.F_favail", Field, 2},
{"Statfs_t.F_ffree", Field, 2},
{"Statfs_t.F_files", Field, 2},
{"Statfs_t.F_flags", Field, 2},
{"Statfs_t.F_fsid", Field, 2},
{"Statfs_t.F_fstypename", Field, 2},
{"Statfs_t.F_iosize", Field, 2},
{"Statfs_t.F_mntfromname", Field, 2},
{"Statfs_t.F_mntfromspec", Field, 3},
{"Statfs_t.F_mntonname", Field, 2},
{"Statfs_t.F_namemax", Field, 2},
{"Statfs_t.F_owner", Field, 2},
{"Statfs_t.F_spare", Field, 2},
{"Statfs_t.F_syncreads", Field, 2},
{"Statfs_t.F_syncwrites", Field, 2},
{"Statfs_t.Ffree", Field, 0},
{"Statfs_t.Files", Field, 0},
{"Statfs_t.Flags", Field, 0},
{"Statfs_t.Frsize", Field, 0},
{"Statfs_t.Fsid", Field, 0},
{"Statfs_t.Fssubtype", Field, 0},
{"Statfs_t.Fstypename", Field, 0},
{"Statfs_t.Iosize", Field, 0},
{"Statfs_t.Mntfromname", Field, 0},
{"Statfs_t.Mntonname", Field, 0},
{"Statfs_t.Mount_info", Field, 2},
{"Statfs_t.Namelen", Field, 0},
{"Statfs_t.Namemax", Field, 0},
{"Statfs_t.Owner", Field, 0},
{"Statfs_t.Pad_cgo_0", Field, 0},
{"Statfs_t.Pad_cgo_1", Field, 2},
{"Statfs_t.Reserved", Field, 0},
{"Statfs_t.Spare", Field, 0},
{"Statfs_t.Syncreads", Field, 0},
{"Statfs_t.Syncwrites", Field, 0},
{"Statfs_t.Type", Field, 0},
{"Statfs_t.Version", Field, 0},
{"Stderr", Var, 0},
{"Stdin", Var, 0},
{"Stdout", Var, 0},
{"StringBytePtr", Func, 0},
{"StringByteSlice", Func, 0},
{"StringSlicePtr", Func, 0},
{"StringToSid", Func, 0},
{"StringToUTF16", Func, 0},
{"StringToUTF16Ptr", Func, 0},
{"Symlink", Func, 0},
{"Sync", Func, 0},
{"SyncFileRange", Func, 0},
{"SysProcAttr", Type, 0},
{"SysProcAttr.AdditionalInheritedHandles", Field, 17},
{"SysProcAttr.AmbientCaps", Field, 9},
{"SysProcAttr.CgroupFD", Field, 20},
{"SysProcAttr.Chroot", Field, 0},
{"SysProcAttr.Cloneflags", Field, 2},
{"SysProcAttr.CmdLine", Field, 0},
{"SysProcAttr.CreationFlags", Field, 1},
{"SysProcAttr.Credential", Field, 0},
{"SysProcAttr.Ctty", Field, 1},
{"SysProcAttr.Foreground", Field, 5},
{"SysProcAttr.GidMappings", Field, 4},
{"SysProcAttr.GidMappingsEnableSetgroups", Field, 5},
{"SysProcAttr.HideWindow", Field, 0},
{"SysProcAttr.Jail", Field, 21},
{"SysProcAttr.NoInheritHandles", Field, 16},
{"SysProcAttr.Noctty", Field, 0},
{"SysProcAttr.ParentProcess", Field, 17},
{"SysProcAttr.Pdeathsig", Field, 0},
{"SysProcAttr.Pgid", Field, 5},
{"SysProcAttr.PidFD", Field, 22},
{"SysProcAttr.ProcessAttributes", Field, 13},
{"SysProcAttr.Ptrace", Field, 0},
{"SysProcAttr.Setctty", Field, 0},
{"SysProcAttr.Setpgid", Field, 0},
{"SysProcAttr.Setsid", Field, 0},
{"SysProcAttr.ThreadAttributes", Field, 13},
{"SysProcAttr.Token", Field, 10},
{"SysProcAttr.UidMappings", Field, 4},
{"SysProcAttr.Unshareflags", Field, 7},
{"SysProcAttr.UseCgroupFD", Field, 20},
{"SysProcIDMap", Type, 4},
{"SysProcIDMap.ContainerID", Field, 4},
{"SysProcIDMap.HostID", Field, 4},
{"SysProcIDMap.Size", Field, 4},
{"Syscall", Func, 0},
{"Syscall12", Func, 0},
{"Syscall15", Func, 0},
{"Syscall18", Func, 12},
{"Syscall6", Func, 0},
{"Syscall9", Func, 0},
{"SyscallN", Func, 18},
{"Sysctl", Func, 0},
{"SysctlUint32", Func, 0},
{"Sysctlnode", Type, 2},
{"Sysctlnode.Flags", Field, 2},
{"Sysctlnode.Name", Field, 2},
{"Sysctlnode.Num", Field, 2},
{"Sysctlnode.Un", Field, 2},
{"Sysctlnode.Ver", Field, 2},
{"Sysctlnode.X__rsvd", Field, 2},
{"Sysctlnode.X_sysctl_desc", Field, 2},
{"Sysctlnode.X_sysctl_func", Field, 2},
{"Sysctlnode.X_sysctl_parent", Field, 2},
{"Sysctlnode.X_sysctl_size", Field, 2},
{"Sysinfo", Func, 0},
{"Sysinfo_t", Type, 0},
{"Sysinfo_t.Bufferram", Field, 0},
{"Sysinfo_t.Freehigh", Field, 0},
{"Sysinfo_t.Freeram", Field, 0},
{"Sysinfo_t.Freeswap", Field, 0},
{"Sysinfo_t.Loads", Field, 0},
{"Sysinfo_t.Pad", Field, 0},
{"Sysinfo_t.Pad_cgo_0", Field, 0},
{"Sysinfo_t.Pad_cgo_1", Field, 0},
{"Sysinfo_t.Procs", Field, 0},
{"Sysinfo_t.Sharedram", Field, 0},
{"Sysinfo_t.Totalhigh", Field, 0},
{"Sysinfo_t.Totalram", Field, 0},
{"Sysinfo_t.Totalswap", Field, 0},
{"Sysinfo_t.Unit", Field, 0},
{"Sysinfo_t.Uptime", Field, 0},
{"Sysinfo_t.X_f", Field, 0},
{"Systemtime", Type, 0},
{"Systemtime.Day", Field, 0},
{"Systemtime.DayOfWeek", Field, 0},
{"Systemtime.Hour", Field, 0},
{"Systemtime.Milliseconds", Field, 0},
{"Systemtime.Minute", Field, 0},
{"Systemtime.Month", Field, 0},
{"Systemtime.Second", Field, 0},
{"Systemtime.Year", Field, 0},
{"TCGETS", Const, 0},
{"TCIFLUSH", Const, 1},
{"TCIOFLUSH", Const, 1},
{"TCOFLUSH", Const, 1},
{"TCPInfo", Type, 1},
{"TCPInfo.Advmss", Field, 1},
{"TCPInfo.Ato", Field, 1},
{"TCPInfo.Backoff", Field, 1},
{"TCPInfo.Ca_state", Field, 1},
{"TCPInfo.Fackets", Field, 1},
{"TCPInfo.Last_ack_recv", Field, 1},
{"TCPInfo.Last_ack_sent", Field, 1},
{"TCPInfo.Last_data_recv", Field, 1},
{"TCPInfo.Last_data_sent", Field, 1},
{"TCPInfo.Lost", Field, 1},
{"TCPInfo.Options", Field, 1},
{"TCPInfo.Pad_cgo_0", Field, 1},
{"TCPInfo.Pmtu", Field, 1},
{"TCPInfo.Probes", Field, 1},
{"TCPInfo.Rcv_mss", Field, 1},
{"TCPInfo.Rcv_rtt", Field, 1},
{"TCPInfo.Rcv_space", Field, 1},
{"TCPInfo.Rcv_ssthresh", Field, 1},
{"TCPInfo.Reordering", Field, 1},
{"TCPInfo.Retrans", Field, 1},
{"TCPInfo.Retransmits", Field, 1},
{"TCPInfo.Rto", Field, 1},
{"TCPInfo.Rtt", Field, 1},
{"TCPInfo.Rttvar", Field, 1},
{"TCPInfo.Sacked", Field, 1},
{"TCPInfo.Snd_cwnd", Field, 1},
{"TCPInfo.Snd_mss", Field, 1},
{"TCPInfo.Snd_ssthresh", Field, 1},
{"TCPInfo.State", Field, 1},
{"TCPInfo.Total_retrans", Field, 1},
{"TCPInfo.Unacked", Field, 1},
{"TCPKeepalive", Type, 3},
{"TCPKeepalive.Interval", Field, 3},
{"TCPKeepalive.OnOff", Field, 3},
{"TCPKeepalive.Time", Field, 3},
{"TCP_CA_NAME_MAX", Const, 0},
{"TCP_CONGCTL", Const, 1},
{"TCP_CONGESTION", Const, 0},
{"TCP_CONNECTIONTIMEOUT", Const, 0},
{"TCP_CORK", Const, 0},
{"TCP_DEFER_ACCEPT", Const, 0},
{"TCP_ENABLE_ECN", Const, 16},
{"TCP_INFO", Const, 0},
{"TCP_KEEPALIVE", Const, 0},
{"TCP_KEEPCNT", Const, 0},
{"TCP_KEEPIDLE", Const, 0},
{"TCP_KEEPINIT", Const, 1},
{"TCP_KEEPINTVL", Const, 0},
{"TCP_LINGER2", Const, 0},
{"TCP_MAXBURST", Const, 0},
{"TCP_MAXHLEN", Const, 0},
{"TCP_MAXOLEN", Const, 0},
{"TCP_MAXSEG", Const, 0},
{"TCP_MAXWIN", Const, 0},
{"TCP_MAX_SACK", Const, 0},
{"TCP_MAX_WINSHIFT", Const, 0},
{"TCP_MD5SIG", Const, 0},
{"TCP_MD5SIG_MAXKEYLEN", Const, 0},
{"TCP_MINMSS", Const, 0},
{"TCP_MINMSSOVERLOAD", Const, 0},
{"TCP_MSS", Const, 0},
{"TCP_NODELAY", Const, 0},
{"TCP_NOOPT", Const, 0},
{"TCP_NOPUSH", Const, 0},
{"TCP_NOTSENT_LOWAT", Const, 16},
{"TCP_NSTATES", Const, 1},
{"TCP_QUICKACK", Const, 0},
{"TCP_RXT_CONNDROPTIME", Const, 0},
{"TCP_RXT_FINDROP", Const, 0},
{"TCP_SACK_ENABLE", Const, 1},
{"TCP_SENDMOREACKS", Const, 16},
{"TCP_SYNCNT", Const, 0},
{"TCP_VENDOR", Const, 3},
{"TCP_WINDOW_CLAMP", Const, 0},
{"TCSAFLUSH", Const, 1},
{"TCSETS", Const, 0},
{"TF_DISCONNECT", Const, 0},
{"TF_REUSE_SOCKET", Const, 0},
{"TF_USE_DEFAULT_WORKER", Const, 0},
{"TF_USE_KERNEL_APC", Const, 0},
{"TF_USE_SYSTEM_THREAD", Const, 0},
{"TF_WRITE_BEHIND", Const, 0},
{"TH32CS_INHERIT", Const, 4},
{"TH32CS_SNAPALL", Const, 4},
{"TH32CS_SNAPHEAPLIST", Const, 4},
{"TH32CS_SNAPMODULE", Const, 4},
{"TH32CS_SNAPMODULE32", Const, 4},
{"TH32CS_SNAPPROCESS", Const, 4},
{"TH32CS_SNAPTHREAD", Const, 4},
{"TIME_ZONE_ID_DAYLIGHT", Const, 0},
{"TIME_ZONE_ID_STANDARD", Const, 0},
{"TIME_ZONE_ID_UNKNOWN", Const, 0},
{"TIOCCBRK", Const, 0},
{"TIOCCDTR", Const, 0},
{"TIOCCONS", Const, 0},
{"TIOCDCDTIMESTAMP", Const, 0},
{"TIOCDRAIN", Const, 0},
{"TIOCDSIMICROCODE", Const, 0},
{"TIOCEXCL", Const, 0},
{"TIOCEXT", Const, 0},
{"TIOCFLAG_CDTRCTS", Const, 1},
{"TIOCFLAG_CLOCAL", Const, 1},
{"TIOCFLAG_CRTSCTS", Const, 1},
{"TIOCFLAG_MDMBUF", Const, 1},
{"TIOCFLAG_PPS", Const, 1},
{"TIOCFLAG_SOFTCAR", Const, 1},
{"TIOCFLUSH", Const, 0},
{"TIOCGDEV", Const, 0},
{"TIOCGDRAINWAIT", Const, 0},
{"TIOCGETA", Const, 0},
{"TIOCGETD", Const, 0},
{"TIOCGFLAGS", Const, 1},
{"TIOCGICOUNT", Const, 0},
{"TIOCGLCKTRMIOS", Const, 0},
{"TIOCGLINED", Const, 1},
{"TIOCGPGRP", Const, 0},
{"TIOCGPTN", Const, 0},
{"TIOCGQSIZE", Const, 1},
{"TIOCGRANTPT", Const, 1},
{"TIOCGRS485", Const, 0},
{"TIOCGSERIAL", Const, 0},
{"TIOCGSID", Const, 0},
{"TIOCGSIZE", Const, 1},
{"TIOCGSOFTCAR", Const, 0},
{"TIOCGTSTAMP", Const, 1},
{"TIOCGWINSZ", Const, 0},
{"TIOCINQ", Const, 0},
{"TIOCIXOFF", Const, 0},
{"TIOCIXON", Const, 0},
{"TIOCLINUX", Const, 0},
{"TIOCMBIC", Const, 0},
{"TIOCMBIS", Const, 0},
{"TIOCMGDTRWAIT", Const, 0},
{"TIOCMGET", Const, 0},
{"TIOCMIWAIT", Const, 0},
{"TIOCMODG", Const, 0},
{"TIOCMODS", Const, 0},
{"TIOCMSDTRWAIT", Const, 0},
{"TIOCMSET", Const, 0},
{"TIOCM_CAR", Const, 0},
{"TIOCM_CD", Const, 0},
{"TIOCM_CTS", Const, 0},
{"TIOCM_DCD", Const, 0},
{"TIOCM_DSR", Const, 0},
{"TIOCM_DTR", Const, 0},
{"TIOCM_LE", Const, 0},
{"TIOCM_RI", Const, 0},
{"TIOCM_RNG", Const, 0},
{"TIOCM_RTS", Const, 0},
{"TIOCM_SR", Const, 0},
{"TIOCM_ST", Const, 0},
{"TIOCNOTTY", Const, 0},
{"TIOCNXCL", Const, 0},
{"TIOCOUTQ", Const, 0},
{"TIOCPKT", Const, 0},
{"TIOCPKT_DATA", Const, 0},
{"TIOCPKT_DOSTOP", Const, 0},
{"TIOCPKT_FLUSHREAD", Const, 0},
{"TIOCPKT_FLUSHWRITE", Const, 0},
{"TIOCPKT_IOCTL", Const, 0},
{"TIOCPKT_NOSTOP", Const, 0},
{"TIOCPKT_START", Const, 0},
{"TIOCPKT_STOP", Const, 0},
{"TIOCPTMASTER", Const, 0},
{"TIOCPTMGET", Const, 1},
{"TIOCPTSNAME", Const, 1},
{"TIOCPTYGNAME", Const, 0},
{"TIOCPTYGRANT", Const, 0},
{"TIOCPTYUNLK", Const, 0},
{"TIOCRCVFRAME", Const, 1},
{"TIOCREMOTE", Const, 0},
{"TIOCSBRK", Const, 0},
{"TIOCSCONS", Const, 0},
{"TIOCSCTTY", Const, 0},
{"TIOCSDRAINWAIT", Const, 0},
{"TIOCSDTR", Const, 0},
{"TIOCSERCONFIG", Const, 0},
{"TIOCSERGETLSR", Const, 0},
{"TIOCSERGETMULTI", Const, 0},
{"TIOCSERGSTRUCT", Const, 0},
{"TIOCSERGWILD", Const, 0},
{"TIOCSERSETMULTI", Const, 0},
{"TIOCSERSWILD", Const, 0},
{"TIOCSER_TEMT", Const, 0},
{"TIOCSETA", Const, 0},
{"TIOCSETAF", Const, 0},
{"TIOCSETAW", Const, 0},
{"TIOCSETD", Const, 0},
{"TIOCSFLAGS", Const, 1},
{"TIOCSIG", Const, 0},
{"TIOCSLCKTRMIOS", Const, 0},
{"TIOCSLINED", Const, 1},
{"TIOCSPGRP", Const, 0},
{"TIOCSPTLCK", Const, 0},
{"TIOCSQSIZE", Const, 1},
{"TIOCSRS485", Const, 0},
{"TIOCSSERIAL", Const, 0},
{"TIOCSSIZE", Const, 1},
{"TIOCSSOFTCAR", Const, 0},
{"TIOCSTART", Const, 0},
{"TIOCSTAT", Const, 0},
{"TIOCSTI", Const, 0},
{"TIOCSTOP", Const, 0},
{"TIOCSTSTAMP", Const, 1},
{"TIOCSWINSZ", Const, 0},
{"TIOCTIMESTAMP", Const, 0},
{"TIOCUCNTL", Const, 0},
{"TIOCVHANGUP", Const, 0},
{"TIOCXMTFRAME", Const, 1},
{"TOKEN_ADJUST_DEFAULT", Const, 0},
{"TOKEN_ADJUST_GROUPS", Const, 0},
{"TOKEN_ADJUST_PRIVILEGES", Const, 0},
{"TOKEN_ADJUST_SESSIONID", Const, 11},
{"TOKEN_ALL_ACCESS", Const, 0},
{"TOKEN_ASSIGN_PRIMARY", Const, 0},
{"TOKEN_DUPLICATE", Const, 0},
{"TOKEN_EXECUTE", Const, 0},
{"TOKEN_IMPERSONATE", Const, 0},
{"TOKEN_QUERY", Const, 0},
{"TOKEN_QUERY_SOURCE", Const, 0},
{"TOKEN_READ", Const, 0},
{"TOKEN_WRITE", Const, 0},
{"TOSTOP", Const, 0},
{"TRUNCATE_EXISTING", Const, 0},
{"TUNATTACHFILTER", Const, 0},
{"TUNDETACHFILTER", Const, 0},
{"TUNGETFEATURES", Const, 0},
{"TUNGETIFF", Const, 0},
{"TUNGETSNDBUF", Const, 0},
{"TUNGETVNETHDRSZ", Const, 0},
{"TUNSETDEBUG", Const, 0},
{"TUNSETGROUP", Const, 0},
{"TUNSETIFF", Const, 0},
{"TUNSETLINK", Const, 0},
{"TUNSETNOCSUM", Const, 0},
{"TUNSETOFFLOAD", Const, 0},
{"TUNSETOWNER", Const, 0},
{"TUNSETPERSIST", Const, 0},
{"TUNSETSNDBUF", Const, 0},
{"TUNSETTXFILTER", Const, 0},
{"TUNSETVNETHDRSZ", Const, 0},
{"Tee", Func, 0},
{"TerminateProcess", Func, 0},
{"Termios", Type, 0},
{"Termios.Cc", Field, 0},
{"Termios.Cflag", Field, 0},
{"Termios.Iflag", Field, 0},
{"Termios.Ispeed", Field, 0},
{"Termios.Lflag", Field, 0},
{"Termios.Line", Field, 0},
{"Termios.Oflag", Field, 0},
{"Termios.Ospeed", Field, 0},
{"Termios.Pad_cgo_0", Field, 0},
{"Tgkill", Func, 0},
{"Time", Func, 0},
{"Time_t", Type, 0},
{"Times", Func, 0},
{"Timespec", Type, 0},
{"Timespec.Nsec", Field, 0},
{"Timespec.Pad_cgo_0", Field, 2},
{"Timespec.Sec", Field, 0},
{"TimespecToNsec", Func, 0},
{"Timeval", Type, 0},
{"Timeval.Pad_cgo_0", Field, 0},
{"Timeval.Sec", Field, 0},
{"Timeval.Usec", Field, 0},
{"Timeval32", Type, 0},
{"Timeval32.Sec", Field, 0},
{"Timeval32.Usec", Field, 0},
{"TimevalToNsec", Func, 0},
{"Timex", Type, 0},
{"Timex.Calcnt", Field, 0},
{"Timex.Constant", Field, 0},
{"Timex.Errcnt", Field, 0},
{"Timex.Esterror", Field, 0},
{"Timex.Freq", Field, 0},
{"Timex.Jitcnt", Field, 0},
{"Timex.Jitter", Field, 0},
{"Timex.Maxerror", Field, 0},
{"Timex.Modes", Field, 0},
{"Timex.Offset", Field, 0},
{"Timex.Pad_cgo_0", Field, 0},
{"Timex.Pad_cgo_1", Field, 0},
{"Timex.Pad_cgo_2", Field, 0},
{"Timex.Pad_cgo_3", Field, 0},
{"Timex.Ppsfreq", Field, 0},
{"Timex.Precision", Field, 0},
{"Timex.Shift", Field, 0},
{"Timex.Stabil", Field, 0},
{"Timex.Status", Field, 0},
{"Timex.Stbcnt", Field, 0},
{"Timex.Tai", Field, 0},
{"Timex.Tick", Field, 0},
{"Timex.Time", Field, 0},
{"Timex.Tolerance", Field, 0},
{"Timezoneinformation", Type, 0},
{"Timezoneinformation.Bias", Field, 0},
{"Timezoneinformation.DaylightBias", Field, 0},
{"Timezoneinformation.DaylightDate", Field, 0},
{"Timezoneinformation.DaylightName", Field, 0},
{"Timezoneinformation.StandardBias", Field, 0},
{"Timezoneinformation.StandardDate", Field, 0},
{"Timezoneinformation.StandardName", Field, 0},
{"Tms", Type, 0},
{"Tms.Cstime", Field, 0},
{"Tms.Cutime", Field, 0},
{"Tms.Stime", Field, 0},
{"Tms.Utime", Field, 0},
{"Token", Type, 0},
{"TokenAccessInformation", Const, 0},
{"TokenAuditPolicy", Const, 0},
{"TokenDefaultDacl", Const, 0},
{"TokenElevation", Const, 0},
{"TokenElevationType", Const, 0},
{"TokenGroups", Const, 0},
{"TokenGroupsAndPrivileges", Const, 0},
{"TokenHasRestrictions", Const, 0},
{"TokenImpersonationLevel", Const, 0},
{"TokenIntegrityLevel", Const, 0},
{"TokenLinkedToken", Const, 0},
{"TokenLogonSid", Const, 0},
{"TokenMandatoryPolicy", Const, 0},
{"TokenOrigin", Const, 0},
{"TokenOwner", Const, 0},
{"TokenPrimaryGroup", Const, 0},
{"TokenPrivileges", Const, 0},
{"TokenRestrictedSids", Const, 0},
{"TokenSandBoxInert", Const, 0},
{"TokenSessionId", Const, 0},
{"TokenSessionReference", Const, 0},
{"TokenSource", Const, 0},
{"TokenStatistics", Const, 0},
{"TokenType", Const, 0},
{"TokenUIAccess", Const, 0},
{"TokenUser", Const, 0},
{"TokenVirtualizationAllowed", Const, 0},
{"TokenVirtualizationEnabled", Const, 0},
{"Tokenprimarygroup", Type, 0},
{"Tokenprimarygroup.PrimaryGroup", Field, 0},
{"Tokenuser", Type, 0},
{"Tokenuser.User", Field, 0},
{"TranslateAccountName", Func, 0},
{"TranslateName", Func, 0},
{"TransmitFile", Func, 0},
{"TransmitFileBuffers", Type, 0},
{"TransmitFileBuffers.Head", Field, 0},
{"TransmitFileBuffers.HeadLength", Field, 0},
{"TransmitFileBuffers.Tail", Field, 0},
{"TransmitFileBuffers.TailLength", Field, 0},
{"Truncate", Func, 0},
{"UNIX_PATH_MAX", Const, 12},
{"USAGE_MATCH_TYPE_AND", Const, 0},
{"USAGE_MATCH_TYPE_OR", Const, 0},
{"UTF16FromString", Func, 1},
{"UTF16PtrFromString", Func, 1},
{"UTF16ToString", Func, 0},
{"Ucred", Type, 0},
{"Ucred.Gid", Field, 0},
{"Ucred.Pid", Field, 0},
{"Ucred.Uid", Field, 0},
{"Umask", Func, 0},
{"Uname", Func, 0},
{"Undelete", Func, 0},
{"UnixCredentials", Func, 0},
{"UnixRights", Func, 0},
{"Unlink", Func, 0},
{"Unlinkat", Func, 0},
{"UnmapViewOfFile", Func, 0},
{"Unmount", Func, 0},
{"Unsetenv", Func, 4},
{"Unshare", Func, 0},
{"UserInfo10", Type, 0},
{"UserInfo10.Comment", Field, 0},
{"UserInfo10.FullName", Field, 0},
{"UserInfo10.Name", Field, 0},
{"UserInfo10.UsrComment", Field, 0},
{"Ustat", Func, 0},
{"Ustat_t", Type, 0},
{"Ustat_t.Fname", Field, 0},
{"Ustat_t.Fpack", Field, 0},
{"Ustat_t.Pad_cgo_0", Field, 0},
{"Ustat_t.Pad_cgo_1", Field, 0},
{"Ustat_t.Tfree", Field, 0},
{"Ustat_t.Tinode", Field, 0},
{"Utimbuf", Type, 0},
{"Utimbuf.Actime", Field, 0},
{"Utimbuf.Modtime", Field, 0},
{"Utime", Func, 0},
{"Utimes", Func, 0},
{"UtimesNano", Func, 1},
{"Utsname", Type, 0},
{"Utsname.Domainname", Field, 0},
{"Utsname.Machine", Field, 0},
{"Utsname.Nodename", Field, 0},
{"Utsname.Release", Field, 0},
{"Utsname.Sysname", Field, 0},
{"Utsname.Version", Field, 0},
{"VDISCARD", Const, 0},
{"VDSUSP", Const, 1},
{"VEOF", Const, 0},
{"VEOL", Const, 0},
{"VEOL2", Const, 0},
{"VERASE", Const, 0},
{"VERASE2", Const, 1},
{"VINTR", Const, 0},
{"VKILL", Const, 0},
{"VLNEXT", Const, 0},
{"VMIN", Const, 0},
{"VQUIT", Const, 0},
{"VREPRINT", Const, 0},
{"VSTART", Const, 0},
{"VSTATUS", Const, 1},
{"VSTOP", Const, 0},
{"VSUSP", Const, 0},
{"VSWTC", Const, 0},
{"VT0", Const, 1},
{"VT1", Const, 1},
{"VTDLY", Const, 1},
{"VTIME", Const, 0},
{"VWERASE", Const, 0},
{"VirtualLock", Func, 0},
{"VirtualUnlock", Func, 0},
{"WAIT_ABANDONED", Const, 0},
{"WAIT_FAILED", Const, 0},
{"WAIT_OBJECT_0", Const, 0},
{"WAIT_TIMEOUT", Const, 0},
{"WALL", Const, 0},
{"WALLSIG", Const, 1},
{"WALTSIG", Const, 1},
{"WCLONE", Const, 0},
{"WCONTINUED", Const, 0},
{"WCOREFLAG", Const, 0},
{"WEXITED", Const, 0},
{"WLINUXCLONE", Const, 0},
{"WNOHANG", Const, 0},
{"WNOTHREAD", Const, 0},
{"WNOWAIT", Const, 0},
{"WNOZOMBIE", Const, 1},
{"WOPTSCHECKED", Const, 1},
{"WORDSIZE", Const, 0},
{"WSABuf", Type, 0},
{"WSABuf.Buf", Field, 0},
{"WSABuf.Len", Field, 0},
{"WSACleanup", Func, 0},
{"WSADESCRIPTION_LEN", Const, 0},
{"WSAData", Type, 0},
{"WSAData.Description", Field, 0},
{"WSAData.HighVersion", Field, 0},
{"WSAData.MaxSockets", Field, 0},
{"WSAData.MaxUdpDg", Field, 0},
{"WSAData.SystemStatus", Field, 0},
{"WSAData.VendorInfo", Field, 0},
{"WSAData.Version", Field, 0},
{"WSAEACCES", Const, 2},
{"WSAECONNABORTED", Const, 9},
{"WSAECONNRESET", Const, 3},
{"WSAENOPROTOOPT", Const, 23},
{"WSAEnumProtocols", Func, 2},
{"WSAID_CONNECTEX", Var, 1},
{"WSAIoctl", Func, 0},
{"WSAPROTOCOL_LEN", Const, 2},
{"WSAProtocolChain", Type, 2},
{"WSAProtocolChain.ChainEntries", Field, 2},
{"WSAProtocolChain.ChainLen", Field, 2},
{"WSAProtocolInfo", Type, 2},
{"WSAProtocolInfo.AddressFamily", Field, 2},
{"WSAProtocolInfo.CatalogEntryId", Field, 2},
{"WSAProtocolInfo.MaxSockAddr", Field, 2},
{"WSAProtocolInfo.MessageSize", Field, 2},
{"WSAProtocolInfo.MinSockAddr", Field, 2},
{"WSAProtocolInfo.NetworkByteOrder", Field, 2},
{"WSAProtocolInfo.Protocol", Field, 2},
{"WSAProtocolInfo.ProtocolChain", Field, 2},
{"WSAProtocolInfo.ProtocolMaxOffset", Field, 2},
{"WSAProtocolInfo.ProtocolName", Field, 2},
{"WSAProtocolInfo.ProviderFlags", Field, 2},
{"WSAProtocolInfo.ProviderId", Field, 2},
{"WSAProtocolInfo.ProviderReserved", Field, 2},
{"WSAProtocolInfo.SecurityScheme", Field, 2},
{"WSAProtocolInfo.ServiceFlags1", Field, 2},
{"WSAProtocolInfo.ServiceFlags2", Field, 2},
{"WSAProtocolInfo.ServiceFlags3", Field, 2},
{"WSAProtocolInfo.ServiceFlags4", Field, 2},
{"WSAProtocolInfo.SocketType", Field, 2},
{"WSAProtocolInfo.Version", Field, 2},
{"WSARecv", Func, 0},
{"WSARecvFrom", Func, 0},
{"WSASYS_STATUS_LEN", Const, 0},
{"WSASend", Func, 0},
{"WSASendTo", Func, 0},
{"WSASendto", Func, 0},
{"WSAStartup", Func, 0},
{"WSTOPPED", Const, 0},
{"WTRAPPED", Const, 1},
{"WUNTRACED", Const, 0},
{"Wait4", Func, 0},
{"WaitForSingleObject", Func, 0},
{"WaitStatus", Type, 0},
{"WaitStatus.ExitCode", Field, 0},
{"Win32FileAttributeData", Type, 0},
{"Win32FileAttributeData.CreationTime", Field, 0},
{"Win32FileAttributeData.FileAttributes", Field, 0},
{"Win32FileAttributeData.FileSizeHigh", Field, 0},
{"Win32FileAttributeData.FileSizeLow", Field, 0},
{"Win32FileAttributeData.LastAccessTime", Field, 0},
{"Win32FileAttributeData.LastWriteTime", Field, 0},
{"Win32finddata", Type, 0},
{"Win32finddata.AlternateFileName", Field, 0},
{"Win32finddata.CreationTime", Field, 0},
{"Win32finddata.FileAttributes", Field, 0},
{"Win32finddata.FileName", Field, 0},
{"Win32finddata.FileSizeHigh", Field, 0},
{"Win32finddata.FileSizeLow", Field, 0},
{"Win32finddata.LastAccessTime", Field, 0},
{"Win32finddata.LastWriteTime", Field, 0},
{"Win32finddata.Reserved0", Field, 0},
{"Win32finddata.Reserved1", Field, 0},
{"Write", Func, 0},
{"WriteConsole", Func, 1},
{"WriteFile", Func, 0},
{"X509_ASN_ENCODING", Const, 0},
{"XCASE", Const, 0},
{"XP1_CONNECTIONLESS", Const, 2},
{"XP1_CONNECT_DATA", Const, 2},
{"XP1_DISCONNECT_DATA", Const, 2},
{"XP1_EXPEDITED_DATA", Const, 2},
{"XP1_GRACEFUL_CLOSE", Const, 2},
{"XP1_GUARANTEED_DELIVERY", Const, 2},
{"XP1_GUARANTEED_ORDER", Const, 2},
{"XP1_IFS_HANDLES", Const, 2},
{"XP1_MESSAGE_ORIENTED", Const, 2},
{"XP1_MULTIPOINT_CONTROL_PLANE", Const, 2},
{"XP1_MULTIPOINT_DATA_PLANE", Const, 2},
{"XP1_PARTIAL_MESSAGE", Const, 2},
{"XP1_PSEUDO_STREAM", Const, 2},
{"XP1_QOS_SUPPORTED", Const, 2},
{"XP1_SAN_SUPPORT_SDP", Const, 2},
{"XP1_SUPPORT_BROADCAST", Const, 2},
{"XP1_SUPPORT_MULTIPOINT", Const, 2},
{"XP1_UNI_RECV", Const, 2},
{"XP1_UNI_SEND", Const, 2},
},
"syscall/js": {
{"CopyBytesToGo", Func, 0},
{"CopyBytesToJS", Func, 0},
{"Error", Type, 0},
{"Func", Type, 0},
{"FuncOf", Func, 0},
{"Global", Func, 0},
{"Null", Func, 0},
{"Type", Type, 0},
{"TypeBoolean", Const, 0},
{"TypeFunction", Const, 0},
{"TypeNull", Const, 0},
{"TypeNumber", Const, 0},
{"TypeObject", Const, 0},
{"TypeString", Const, 0},
{"TypeSymbol", Const, 0},
{"TypeUndefined", Const, 0},
{"Undefined", Func, 0},
{"Value", Type, 0},
{"ValueError", Type, 0},
{"ValueOf", Func, 0},
},
"testing": {
{"(*B).Cleanup", Method, 14},
{"(*B).Elapsed", Method, 20},
{"(*B).Error", Method, 0},
{"(*B).Errorf", Method, 0},
{"(*B).Fail", Method, 0},
{"(*B).FailNow", Method, 0},
{"(*B).Failed", Method, 0},
{"(*B).Fatal", Method, 0},
{"(*B).Fatalf", Method, 0},
{"(*B).Helper", Method, 9},
{"(*B).Log", Method, 0},
{"(*B).Logf", Method, 0},
{"(*B).Name", Method, 8},
{"(*B).ReportAllocs", Method, 1},
{"(*B).ReportMetric", Method, 13},
{"(*B).ResetTimer", Method, 0},
{"(*B).Run", Method, 7},
{"(*B).RunParallel", Method, 3},
{"(*B).SetBytes", Method, 0},
{"(*B).SetParallelism", Method, 3},
{"(*B).Setenv", Method, 17},
{"(*B).Skip", Method, 1},
{"(*B).SkipNow", Method, 1},
{"(*B).Skipf", Method, 1},
{"(*B).Skipped", Method, 1},
{"(*B).StartTimer", Method, 0},
{"(*B).StopTimer", Method, 0},
{"(*B).TempDir", Method, 15},
{"(*F).Add", Method, 18},
{"(*F).Cleanup", Method, 18},
{"(*F).Error", Method, 18},
{"(*F).Errorf", Method, 18},
{"(*F).Fail", Method, 18},
{"(*F).FailNow", Method, 18},
{"(*F).Failed", Method, 18},
{"(*F).Fatal", Method, 18},
{"(*F).Fatalf", Method, 18},
{"(*F).Fuzz", Method, 18},
{"(*F).Helper", Method, 18},
{"(*F).Log", Method, 18},
{"(*F).Logf", Method, 18},
{"(*F).Name", Method, 18},
{"(*F).Setenv", Method, 18},
{"(*F).Skip", Method, 18},
{"(*F).SkipNow", Method, 18},
{"(*F).Skipf", Method, 18},
{"(*F).Skipped", Method, 18},
{"(*F).TempDir", Method, 18},
{"(*M).Run", Method, 4},
{"(*PB).Next", Method, 3},
{"(*T).Cleanup", Method, 14},
{"(*T).Deadline", Method, 15},
{"(*T).Error", Method, 0},
{"(*T).Errorf", Method, 0},
{"(*T).Fail", Method, 0},
{"(*T).FailNow", Method, 0},
{"(*T).Failed", Method, 0},
{"(*T).Fatal", Method, 0},
{"(*T).Fatalf", Method, 0},
{"(*T).Helper", Method, 9},
{"(*T).Log", Method, 0},
{"(*T).Logf", Method, 0},
{"(*T).Name", Method, 8},
{"(*T).Parallel", Method, 0},
{"(*T).Run", Method, 7},
{"(*T).Setenv", Method, 17},
{"(*T).Skip", Method, 1},
{"(*T).SkipNow", Method, 1},
{"(*T).Skipf", Method, 1},
{"(*T).Skipped", Method, 1},
{"(*T).TempDir", Method, 15},
{"(BenchmarkResult).AllocedBytesPerOp", Method, 1},
{"(BenchmarkResult).AllocsPerOp", Method, 1},
{"(BenchmarkResult).MemString", Method, 1},
{"(BenchmarkResult).NsPerOp", Method, 0},
{"(BenchmarkResult).String", Method, 0},
{"AllocsPerRun", Func, 1},
{"B", Type, 0},
{"B.N", Field, 0},
{"Benchmark", Func, 0},
{"BenchmarkResult", Type, 0},
{"BenchmarkResult.Bytes", Field, 0},
{"BenchmarkResult.Extra", Field, 13},
{"BenchmarkResult.MemAllocs", Field, 1},
{"BenchmarkResult.MemBytes", Field, 1},
{"BenchmarkResult.N", Field, 0},
{"BenchmarkResult.T", Field, 0},
{"Cover", Type, 2},
{"Cover.Blocks", Field, 2},
{"Cover.Counters", Field, 2},
{"Cover.CoveredPackages", Field, 2},
{"Cover.Mode", Field, 2},
{"CoverBlock", Type, 2},
{"CoverBlock.Col0", Field, 2},
{"CoverBlock.Col1", Field, 2},
{"CoverBlock.Line0", Field, 2},
{"CoverBlock.Line1", Field, 2},
{"CoverBlock.Stmts", Field, 2},
{"CoverMode", Func, 8},
{"Coverage", Func, 4},
{"F", Type, 18},
{"Init", Func, 13},
{"InternalBenchmark", Type, 0},
{"InternalBenchmark.F", Field, 0},
{"InternalBenchmark.Name", Field, 0},
{"InternalExample", Type, 0},
{"InternalExample.F", Field, 0},
{"InternalExample.Name", Field, 0},
{"InternalExample.Output", Field, 0},
{"InternalExample.Unordered", Field, 7},
{"InternalFuzzTarget", Type, 18},
{"InternalFuzzTarget.Fn", Field, 18},
{"InternalFuzzTarget.Name", Field, 18},
{"InternalTest", Type, 0},
{"InternalTest.F", Field, 0},
{"InternalTest.Name", Field, 0},
{"M", Type, 4},
{"Main", Func, 0},
{"MainStart", Func, 4},
{"PB", Type, 3},
{"RegisterCover", Func, 2},
{"RunBenchmarks", Func, 0},
{"RunExamples", Func, 0},
{"RunTests", Func, 0},
{"Short", Func, 0},
{"T", Type, 0},
{"TB", Type, 2},
{"Testing", Func, 21},
{"Verbose", Func, 1},
},
"testing/fstest": {
{"(MapFS).Glob", Method, 16},
{"(MapFS).Open", Method, 16},
{"(MapFS).ReadDir", Method, 16},
{"(MapFS).ReadFile", Method, 16},
{"(MapFS).Stat", Method, 16},
{"(MapFS).Sub", Method, 16},
{"MapFS", Type, 16},
{"MapFile", Type, 16},
{"MapFile.Data", Field, 16},
{"MapFile.ModTime", Field, 16},
{"MapFile.Mode", Field, 16},
{"MapFile.Sys", Field, 16},
{"TestFS", Func, 16},
},
"testing/iotest": {
{"DataErrReader", Func, 0},
{"ErrReader", Func, 16},
{"ErrTimeout", Var, 0},
{"HalfReader", Func, 0},
{"NewReadLogger", Func, 0},
{"NewWriteLogger", Func, 0},
{"OneByteReader", Func, 0},
{"TestReader", Func, 16},
{"TimeoutReader", Func, 0},
{"TruncateWriter", Func, 0},
},
"testing/quick": {
{"(*CheckEqualError).Error", Method, 0},
{"(*CheckError).Error", Method, 0},
{"(SetupError).Error", Method, 0},
{"Check", Func, 0},
{"CheckEqual", Func, 0},
{"CheckEqualError", Type, 0},
{"CheckEqualError.CheckError", Field, 0},
{"CheckEqualError.Out1", Field, 0},
{"CheckEqualError.Out2", Field, 0},
{"CheckError", Type, 0},
{"CheckError.Count", Field, 0},
{"CheckError.In", Field, 0},
{"Config", Type, 0},
{"Config.MaxCount", Field, 0},
{"Config.MaxCountScale", Field, 0},
{"Config.Rand", Field, 0},
{"Config.Values", Field, 0},
{"Generator", Type, 0},
{"SetupError", Type, 0},
{"Value", Func, 0},
},
"testing/slogtest": {
{"Run", Func, 22},
{"TestHandler", Func, 21},
},
"text/scanner": {
{"(*Position).IsValid", Method, 0},
{"(*Scanner).Init", Method, 0},
{"(*Scanner).IsValid", Method, 0},
{"(*Scanner).Next", Method, 0},
{"(*Scanner).Peek", Method, 0},
{"(*Scanner).Pos", Method, 0},
{"(*Scanner).Scan", Method, 0},
{"(*Scanner).TokenText", Method, 0},
{"(Position).String", Method, 0},
{"(Scanner).String", Method, 0},
{"Char", Const, 0},
{"Comment", Const, 0},
{"EOF", Const, 0},
{"Float", Const, 0},
{"GoTokens", Const, 0},
{"GoWhitespace", Const, 0},
{"Ident", Const, 0},
{"Int", Const, 0},
{"Position", Type, 0},
{"Position.Column", Field, 0},
{"Position.Filename", Field, 0},
{"Position.Line", Field, 0},
{"Position.Offset", Field, 0},
{"RawString", Const, 0},
{"ScanChars", Const, 0},
{"ScanComments", Const, 0},
{"ScanFloats", Const, 0},
{"ScanIdents", Const, 0},
{"ScanInts", Const, 0},
{"ScanRawStrings", Const, 0},
{"ScanStrings", Const, 0},
{"Scanner", Type, 0},
{"Scanner.Error", Field, 0},
{"Scanner.ErrorCount", Field, 0},
{"Scanner.IsIdentRune", Field, 4},
{"Scanner.Mode", Field, 0},
{"Scanner.Position", Field, 0},
{"Scanner.Whitespace", Field, 0},
{"SkipComments", Const, 0},
{"String", Const, 0},
{"TokenString", Func, 0},
},
"text/tabwriter": {
{"(*Writer).Flush", Method, 0},
{"(*Writer).Init", Method, 0},
{"(*Writer).Write", Method, 0},
{"AlignRight", Const, 0},
{"Debug", Const, 0},
{"DiscardEmptyColumns", Const, 0},
{"Escape", Const, 0},
{"FilterHTML", Const, 0},
{"NewWriter", Func, 0},
{"StripEscape", Const, 0},
{"TabIndent", Const, 0},
{"Writer", Type, 0},
},
"text/template": {
{"(*Template).AddParseTree", Method, 0},
{"(*Template).Clone", Method, 0},
{"(*Template).DefinedTemplates", Method, 5},
{"(*Template).Delims", Method, 0},
{"(*Template).Execute", Method, 0},
{"(*Template).ExecuteTemplate", Method, 0},
{"(*Template).Funcs", Method, 0},
{"(*Template).Lookup", Method, 0},
{"(*Template).Name", Method, 0},
{"(*Template).New", Method, 0},
{"(*Template).Option", Method, 5},
{"(*Template).Parse", Method, 0},
{"(*Template).ParseFS", Method, 16},
{"(*Template).ParseFiles", Method, 0},
{"(*Template).ParseGlob", Method, 0},
{"(*Template).Templates", Method, 0},
{"(ExecError).Error", Method, 6},
{"(ExecError).Unwrap", Method, 13},
{"(Template).Copy", Method, 2},
{"(Template).ErrorContext", Method, 1},
{"ExecError", Type, 6},
{"ExecError.Err", Field, 6},
{"ExecError.Name", Field, 6},
{"FuncMap", Type, 0},
{"HTMLEscape", Func, 0},
{"HTMLEscapeString", Func, 0},
{"HTMLEscaper", Func, 0},
{"IsTrue", Func, 6},
{"JSEscape", Func, 0},
{"JSEscapeString", Func, 0},
{"JSEscaper", Func, 0},
{"Must", Func, 0},
{"New", Func, 0},
{"ParseFS", Func, 16},
{"ParseFiles", Func, 0},
{"ParseGlob", Func, 0},
{"Template", Type, 0},
{"Template.Tree", Field, 0},
{"URLQueryEscaper", Func, 0},
},
"text/template/parse": {
{"(*ActionNode).Copy", Method, 0},
{"(*ActionNode).String", Method, 0},
{"(*BoolNode).Copy", Method, 0},
{"(*BoolNode).String", Method, 0},
{"(*BranchNode).Copy", Method, 4},
{"(*BranchNode).String", Method, 0},
{"(*BreakNode).Copy", Method, 18},
{"(*BreakNode).String", Method, 18},
{"(*ChainNode).Add", Method, 1},
{"(*ChainNode).Copy", Method, 1},
{"(*ChainNode).String", Method, 1},
{"(*CommandNode).Copy", Method, 0},
{"(*CommandNode).String", Method, 0},
{"(*CommentNode).Copy", Method, 16},
{"(*CommentNode).String", Method, 16},
{"(*ContinueNode).Copy", Method, 18},
{"(*ContinueNode).String", Method, 18},
{"(*DotNode).Copy", Method, 0},
{"(*DotNode).String", Method, 0},
{"(*DotNode).Type", Method, 0},
{"(*FieldNode).Copy", Method, 0},
{"(*FieldNode).String", Method, 0},
{"(*IdentifierNode).Copy", Method, 0},
{"(*IdentifierNode).SetPos", Method, 1},
{"(*IdentifierNode).SetTree", Method, 4},
{"(*IdentifierNode).String", Method, 0},
{"(*IfNode).Copy", Method, 0},
{"(*IfNode).String", Method, 0},
{"(*ListNode).Copy", Method, 0},
{"(*ListNode).CopyList", Method, 0},
{"(*ListNode).String", Method, 0},
{"(*NilNode).Copy", Method, 1},
{"(*NilNode).String", Method, 1},
{"(*NilNode).Type", Method, 1},
{"(*NumberNode).Copy", Method, 0},
{"(*NumberNode).String", Method, 0},
{"(*PipeNode).Copy", Method, 0},
{"(*PipeNode).CopyPipe", Method, 0},
{"(*PipeNode).String", Method, 0},
{"(*RangeNode).Copy", Method, 0},
{"(*RangeNode).String", Method, 0},
{"(*StringNode).Copy", Method, 0},
{"(*StringNode).String", Method, 0},
{"(*TemplateNode).Copy", Method, 0},
{"(*TemplateNode).String", Method, 0},
{"(*TextNode).Copy", Method, 0},
{"(*TextNode).String", Method, 0},
{"(*Tree).Copy", Method, 2},
{"(*Tree).ErrorContext", Method, 1},
{"(*Tree).Parse", Method, 0},
{"(*VariableNode).Copy", Method, 0},
{"(*VariableNode).String", Method, 0},
{"(*WithNode).Copy", Method, 0},
{"(*WithNode).String", Method, 0},
{"(ActionNode).Position", Method, 1},
{"(ActionNode).Type", Method, 0},
{"(BoolNode).Position", Method, 1},
{"(BoolNode).Type", Method, 0},
{"(BranchNode).Position", Method, 1},
{"(BranchNode).Type", Method, 0},
{"(BreakNode).Position", Method, 18},
{"(BreakNode).Type", Method, 18},
{"(ChainNode).Position", Method, 1},
{"(ChainNode).Type", Method, 1},
{"(CommandNode).Position", Method, 1},
{"(CommandNode).Type", Method, 0},
{"(CommentNode).Position", Method, 16},
{"(CommentNode).Type", Method, 16},
{"(ContinueNode).Position", Method, 18},
{"(ContinueNode).Type", Method, 18},
{"(DotNode).Position", Method, 1},
{"(FieldNode).Position", Method, 1},
{"(FieldNode).Type", Method, 0},
{"(IdentifierNode).Position", Method, 1},
{"(IdentifierNode).Type", Method, 0},
{"(IfNode).Position", Method, 1},
{"(IfNode).Type", Method, 0},
{"(ListNode).Position", Method, 1},
{"(ListNode).Type", Method, 0},
{"(NilNode).Position", Method, 1},
{"(NodeType).Type", Method, 0},
{"(NumberNode).Position", Method, 1},
{"(NumberNode).Type", Method, 0},
{"(PipeNode).Position", Method, 1},
{"(PipeNode).Type", Method, 0},
{"(Pos).Position", Method, 1},
{"(RangeNode).Position", Method, 1},
{"(RangeNode).Type", Method, 0},
{"(StringNode).Position", Method, 1},
{"(StringNode).Type", Method, 0},
{"(TemplateNode).Position", Method, 1},
{"(TemplateNode).Type", Method, 0},
{"(TextNode).Position", Method, 1},
{"(TextNode).Type", Method, 0},
{"(VariableNode).Position", Method, 1},
{"(VariableNode).Type", Method, 0},
{"(WithNode).Position", Method, 1},
{"(WithNode).Type", Method, 0},
{"ActionNode", Type, 0},
{"ActionNode.Line", Field, 0},
{"ActionNode.NodeType", Field, 0},
{"ActionNode.Pipe", Field, 0},
{"ActionNode.Pos", Field, 1},
{"BoolNode", Type, 0},
{"BoolNode.NodeType", Field, 0},
{"BoolNode.Pos", Field, 1},
{"BoolNode.True", Field, 0},
{"BranchNode", Type, 0},
{"BranchNode.ElseList", Field, 0},
{"BranchNode.Line", Field, 0},
{"BranchNode.List", Field, 0},
{"BranchNode.NodeType", Field, 0},
{"BranchNode.Pipe", Field, 0},
{"BranchNode.Pos", Field, 1},
{"BreakNode", Type, 18},
{"BreakNode.Line", Field, 18},
{"BreakNode.NodeType", Field, 18},
{"BreakNode.Pos", Field, 18},
{"ChainNode", Type, 1},
{"ChainNode.Field", Field, 1},
{"ChainNode.Node", Field, 1},
{"ChainNode.NodeType", Field, 1},
{"ChainNode.Pos", Field, 1},
{"CommandNode", Type, 0},
{"CommandNode.Args", Field, 0},
{"CommandNode.NodeType", Field, 0},
{"CommandNode.Pos", Field, 1},
{"CommentNode", Type, 16},
{"CommentNode.NodeType", Field, 16},
{"CommentNode.Pos", Field, 16},
{"CommentNode.Text", Field, 16},
{"ContinueNode", Type, 18},
{"ContinueNode.Line", Field, 18},
{"ContinueNode.NodeType", Field, 18},
{"ContinueNode.Pos", Field, 18},
{"DotNode", Type, 0},
{"DotNode.NodeType", Field, 4},
{"DotNode.Pos", Field, 1},
{"FieldNode", Type, 0},
{"FieldNode.Ident", Field, 0},
{"FieldNode.NodeType", Field, 0},
{"FieldNode.Pos", Field, 1},
{"IdentifierNode", Type, 0},
{"IdentifierNode.Ident", Field, 0},
{"IdentifierNode.NodeType", Field, 0},
{"IdentifierNode.Pos", Field, 1},
{"IfNode", Type, 0},
{"IfNode.BranchNode", Field, 0},
{"IsEmptyTree", Func, 0},
{"ListNode", Type, 0},
{"ListNode.NodeType", Field, 0},
{"ListNode.Nodes", Field, 0},
{"ListNode.Pos", Field, 1},
{"Mode", Type, 16},
{"New", Func, 0},
{"NewIdentifier", Func, 0},
{"NilNode", Type, 1},
{"NilNode.NodeType", Field, 4},
{"NilNode.Pos", Field, 1},
{"Node", Type, 0},
{"NodeAction", Const, 0},
{"NodeBool", Const, 0},
{"NodeBreak", Const, 18},
{"NodeChain", Const, 1},
{"NodeCommand", Const, 0},
{"NodeComment", Const, 16},
{"NodeContinue", Const, 18},
{"NodeDot", Const, 0},
{"NodeField", Const, 0},
{"NodeIdentifier", Const, 0},
{"NodeIf", Const, 0},
{"NodeList", Const, 0},
{"NodeNil", Const, 1},
{"NodeNumber", Const, 0},
{"NodePipe", Const, 0},
{"NodeRange", Const, 0},
{"NodeString", Const, 0},
{"NodeTemplate", Const, 0},
{"NodeText", Const, 0},
{"NodeType", Type, 0},
{"NodeVariable", Const, 0},
{"NodeWith", Const, 0},
{"NumberNode", Type, 0},
{"NumberNode.Complex128", Field, 0},
{"NumberNode.Float64", Field, 0},
{"NumberNode.Int64", Field, 0},
{"NumberNode.IsComplex", Field, 0},
{"NumberNode.IsFloat", Field, 0},
{"NumberNode.IsInt", Field, 0},
{"NumberNode.IsUint", Field, 0},
{"NumberNode.NodeType", Field, 0},
{"NumberNode.Pos", Field, 1},
{"NumberNode.Text", Field, 0},
{"NumberNode.Uint64", Field, 0},
{"Parse", Func, 0},
{"ParseComments", Const, 16},
{"PipeNode", Type, 0},
{"PipeNode.Cmds", Field, 0},
{"PipeNode.Decl", Field, 0},
{"PipeNode.IsAssign", Field, 11},
{"PipeNode.Line", Field, 0},
{"PipeNode.NodeType", Field, 0},
{"PipeNode.Pos", Field, 1},
{"Pos", Type, 1},
{"RangeNode", Type, 0},
{"RangeNode.BranchNode", Field, 0},
{"SkipFuncCheck", Const, 17},
{"StringNode", Type, 0},
{"StringNode.NodeType", Field, 0},
{"StringNode.Pos", Field, 1},
{"StringNode.Quoted", Field, 0},
{"StringNode.Text", Field, 0},
{"TemplateNode", Type, 0},
{"TemplateNode.Line", Field, 0},
{"TemplateNode.Name", Field, 0},
{"TemplateNode.NodeType", Field, 0},
{"TemplateNode.Pipe", Field, 0},
{"TemplateNode.Pos", Field, 1},
{"TextNode", Type, 0},
{"TextNode.NodeType", Field, 0},
{"TextNode.Pos", Field, 1},
{"TextNode.Text", Field, 0},
{"Tree", Type, 0},
{"Tree.Mode", Field, 16},
{"Tree.Name", Field, 0},
{"Tree.ParseName", Field, 1},
{"Tree.Root", Field, 0},
{"VariableNode", Type, 0},
{"VariableNode.Ident", Field, 0},
{"VariableNode.NodeType", Field, 0},
{"VariableNode.Pos", Field, 1},
{"WithNode", Type, 0},
{"WithNode.BranchNode", Field, 0},
},
"time": {
{"(*Location).String", Method, 0},
{"(*ParseError).Error", Method, 0},
{"(*Ticker).Reset", Method, 15},
{"(*Ticker).Stop", Method, 0},
{"(*Time).GobDecode", Method, 0},
{"(*Time).UnmarshalBinary", Method, 2},
{"(*Time).UnmarshalJSON", Method, 0},
{"(*Time).UnmarshalText", Method, 2},
{"(*Timer).Reset", Method, 1},
{"(*Timer).Stop", Method, 0},
{"(Duration).Abs", Method, 19},
{"(Duration).Hours", Method, 0},
{"(Duration).Microseconds", Method, 13},
{"(Duration).Milliseconds", Method, 13},
{"(Duration).Minutes", Method, 0},
{"(Duration).Nanoseconds", Method, 0},
{"(Duration).Round", Method, 9},
{"(Duration).Seconds", Method, 0},
{"(Duration).String", Method, 0},
{"(Duration).Truncate", Method, 9},
{"(Month).String", Method, 0},
{"(Time).Add", Method, 0},
{"(Time).AddDate", Method, 0},
{"(Time).After", Method, 0},
{"(Time).AppendFormat", Method, 5},
{"(Time).Before", Method, 0},
{"(Time).Clock", Method, 0},
{"(Time).Compare", Method, 20},
{"(Time).Date", Method, 0},
{"(Time).Day", Method, 0},
{"(Time).Equal", Method, 0},
{"(Time).Format", Method, 0},
{"(Time).GoString", Method, 17},
{"(Time).GobEncode", Method, 0},
{"(Time).Hour", Method, 0},
{"(Time).ISOWeek", Method, 0},
{"(Time).In", Method, 0},
{"(Time).IsDST", Method, 17},
{"(Time).IsZero", Method, 0},
{"(Time).Local", Method, 0},
{"(Time).Location", Method, 0},
{"(Time).MarshalBinary", Method, 2},
{"(Time).MarshalJSON", Method, 0},
{"(Time).MarshalText", Method, 2},
{"(Time).Minute", Method, 0},
{"(Time).Month", Method, 0},
{"(Time).Nanosecond", Method, 0},
{"(Time).Round", Method, 1},
{"(Time).Second", Method, 0},
{"(Time).String", Method, 0},
{"(Time).Sub", Method, 0},
{"(Time).Truncate", Method, 1},
{"(Time).UTC", Method, 0},
{"(Time).Unix", Method, 0},
{"(Time).UnixMicro", Method, 17},
{"(Time).UnixMilli", Method, 17},
{"(Time).UnixNano", Method, 0},
{"(Time).Weekday", Method, 0},
{"(Time).Year", Method, 0},
{"(Time).YearDay", Method, 1},
{"(Time).Zone", Method, 0},
{"(Time).ZoneBounds", Method, 19},
{"(Weekday).String", Method, 0},
{"ANSIC", Const, 0},
{"After", Func, 0},
{"AfterFunc", Func, 0},
{"April", Const, 0},
{"August", Const, 0},
{"Date", Func, 0},
{"DateOnly", Const, 20},
{"DateTime", Const, 20},
{"December", Const, 0},
{"Duration", Type, 0},
{"February", Const, 0},
{"FixedZone", Func, 0},
{"Friday", Const, 0},
{"Hour", Const, 0},
{"January", Const, 0},
{"July", Const, 0},
{"June", Const, 0},
{"Kitchen", Const, 0},
{"Layout", Const, 17},
{"LoadLocation", Func, 0},
{"LoadLocationFromTZData", Func, 10},
{"Local", Var, 0},
{"Location", Type, 0},
{"March", Const, 0},
{"May", Const, 0},
{"Microsecond", Const, 0},
{"Millisecond", Const, 0},
{"Minute", Const, 0},
{"Monday", Const, 0},
{"Month", Type, 0},
{"Nanosecond", Const, 0},
{"NewTicker", Func, 0},
{"NewTimer", Func, 0},
{"November", Const, 0},
{"Now", Func, 0},
{"October", Const, 0},
{"Parse", Func, 0},
{"ParseDuration", Func, 0},
{"ParseError", Type, 0},
{"ParseError.Layout", Field, 0},
{"ParseError.LayoutElem", Field, 0},
{"ParseError.Message", Field, 0},
{"ParseError.Value", Field, 0},
{"ParseError.ValueElem", Field, 0},
{"ParseInLocation", Func, 1},
{"RFC1123", Const, 0},
{"RFC1123Z", Const, 0},
{"RFC3339", Const, 0},
{"RFC3339Nano", Const, 0},
{"RFC822", Const, 0},
{"RFC822Z", Const, 0},
{"RFC850", Const, 0},
{"RubyDate", Const, 0},
{"Saturday", Const, 0},
{"Second", Const, 0},
{"September", Const, 0},
{"Since", Func, 0},
{"Sleep", Func, 0},
{"Stamp", Const, 0},
{"StampMicro", Const, 0},
{"StampMilli", Const, 0},
{"StampNano", Const, 0},
{"Sunday", Const, 0},
{"Thursday", Const, 0},
{"Tick", Func, 0},
{"Ticker", Type, 0},
{"Ticker.C", Field, 0},
{"Time", Type, 0},
{"TimeOnly", Const, 20},
{"Timer", Type, 0},
{"Timer.C", Field, 0},
{"Tuesday", Const, 0},
{"UTC", Var, 0},
{"Unix", Func, 0},
{"UnixDate", Const, 0},
{"UnixMicro", Func, 17},
{"UnixMilli", Func, 17},
{"Until", Func, 8},
{"Wednesday", Const, 0},
{"Weekday", Type, 0},
},
"unicode": {
{"(SpecialCase).ToLower", Method, 0},
{"(SpecialCase).ToTitle", Method, 0},
{"(SpecialCase).ToUpper", Method, 0},
{"ASCII_Hex_Digit", Var, 0},
{"Adlam", Var, 7},
{"Ahom", Var, 5},
{"Anatolian_Hieroglyphs", Var, 5},
{"Arabic", Var, 0},
{"Armenian", Var, 0},
{"Avestan", Var, 0},
{"AzeriCase", Var, 0},
{"Balinese", Var, 0},
{"Bamum", Var, 0},
{"Bassa_Vah", Var, 4},
{"Batak", Var, 0},
{"Bengali", Var, 0},
{"Bhaiksuki", Var, 7},
{"Bidi_Control", Var, 0},
{"Bopomofo", Var, 0},
{"Brahmi", Var, 0},
{"Braille", Var, 0},
{"Buginese", Var, 0},
{"Buhid", Var, 0},
{"C", Var, 0},
{"Canadian_Aboriginal", Var, 0},
{"Carian", Var, 0},
{"CaseRange", Type, 0},
{"CaseRange.Delta", Field, 0},
{"CaseRange.Hi", Field, 0},
{"CaseRange.Lo", Field, 0},
{"CaseRanges", Var, 0},
{"Categories", Var, 0},
{"Caucasian_Albanian", Var, 4},
{"Cc", Var, 0},
{"Cf", Var, 0},
{"Chakma", Var, 1},
{"Cham", Var, 0},
{"Cherokee", Var, 0},
{"Chorasmian", Var, 16},
{"Co", Var, 0},
{"Common", Var, 0},
{"Coptic", Var, 0},
{"Cs", Var, 0},
{"Cuneiform", Var, 0},
{"Cypriot", Var, 0},
{"Cypro_Minoan", Var, 21},
{"Cyrillic", Var, 0},
{"Dash", Var, 0},
{"Deprecated", Var, 0},
{"Deseret", Var, 0},
{"Devanagari", Var, 0},
{"Diacritic", Var, 0},
{"Digit", Var, 0},
{"Dives_Akuru", Var, 16},
{"Dogra", Var, 13},
{"Duployan", Var, 4},
{"Egyptian_Hieroglyphs", Var, 0},
{"Elbasan", Var, 4},
{"Elymaic", Var, 14},
{"Ethiopic", Var, 0},
{"Extender", Var, 0},
{"FoldCategory", Var, 0},
{"FoldScript", Var, 0},
{"Georgian", Var, 0},
{"Glagolitic", Var, 0},
{"Gothic", Var, 0},
{"Grantha", Var, 4},
{"GraphicRanges", Var, 0},
{"Greek", Var, 0},
{"Gujarati", Var, 0},
{"Gunjala_Gondi", Var, 13},
{"Gurmukhi", Var, 0},
{"Han", Var, 0},
{"Hangul", Var, 0},
{"Hanifi_Rohingya", Var, 13},
{"Hanunoo", Var, 0},
{"Hatran", Var, 5},
{"Hebrew", Var, 0},
{"Hex_Digit", Var, 0},
{"Hiragana", Var, 0},
{"Hyphen", Var, 0},
{"IDS_Binary_Operator", Var, 0},
{"IDS_Trinary_Operator", Var, 0},
{"Ideographic", Var, 0},
{"Imperial_Aramaic", Var, 0},
{"In", Func, 2},
{"Inherited", Var, 0},
{"Inscriptional_Pahlavi", Var, 0},
{"Inscriptional_Parthian", Var, 0},
{"Is", Func, 0},
{"IsControl", Func, 0},
{"IsDigit", Func, 0},
{"IsGraphic", Func, 0},
{"IsLetter", Func, 0},
{"IsLower", Func, 0},
{"IsMark", Func, 0},
{"IsNumber", Func, 0},
{"IsOneOf", Func, 0},
{"IsPrint", Func, 0},
{"IsPunct", Func, 0},
{"IsSpace", Func, 0},
{"IsSymbol", Func, 0},
{"IsTitle", Func, 0},
{"IsUpper", Func, 0},
{"Javanese", Var, 0},
{"Join_Control", Var, 0},
{"Kaithi", Var, 0},
{"Kannada", Var, 0},
{"Katakana", Var, 0},
{"Kawi", Var, 21},
{"Kayah_Li", Var, 0},
{"Kharoshthi", Var, 0},
{"Khitan_Small_Script", Var, 16},
{"Khmer", Var, 0},
{"Khojki", Var, 4},
{"Khudawadi", Var, 4},
{"L", Var, 0},
{"Lao", Var, 0},
{"Latin", Var, 0},
{"Lepcha", Var, 0},
{"Letter", Var, 0},
{"Limbu", Var, 0},
{"Linear_A", Var, 4},
{"Linear_B", Var, 0},
{"Lisu", Var, 0},
{"Ll", Var, 0},
{"Lm", Var, 0},
{"Lo", Var, 0},
{"Logical_Order_Exception", Var, 0},
{"Lower", Var, 0},
{"LowerCase", Const, 0},
{"Lt", Var, 0},
{"Lu", Var, 0},
{"Lycian", Var, 0},
{"Lydian", Var, 0},
{"M", Var, 0},
{"Mahajani", Var, 4},
{"Makasar", Var, 13},
{"Malayalam", Var, 0},
{"Mandaic", Var, 0},
{"Manichaean", Var, 4},
{"Marchen", Var, 7},
{"Mark", Var, 0},
{"Masaram_Gondi", Var, 10},
{"MaxASCII", Const, 0},
{"MaxCase", Const, 0},
{"MaxLatin1", Const, 0},
{"MaxRune", Const, 0},
{"Mc", Var, 0},
{"Me", Var, 0},
{"Medefaidrin", Var, 13},
{"Meetei_Mayek", Var, 0},
{"Mende_Kikakui", Var, 4},
{"Meroitic_Cursive", Var, 1},
{"Meroitic_Hieroglyphs", Var, 1},
{"Miao", Var, 1},
{"Mn", Var, 0},
{"Modi", Var, 4},
{"Mongolian", Var, 0},
{"Mro", Var, 4},
{"Multani", Var, 5},
{"Myanmar", Var, 0},
{"N", Var, 0},
{"Nabataean", Var, 4},
{"Nag_Mundari", Var, 21},
{"Nandinagari", Var, 14},
{"Nd", Var, 0},
{"New_Tai_Lue", Var, 0},
{"Newa", Var, 7},
{"Nko", Var, 0},
{"Nl", Var, 0},
{"No", Var, 0},
{"Noncharacter_Code_Point", Var, 0},
{"Number", Var, 0},
{"Nushu", Var, 10},
{"Nyiakeng_Puachue_Hmong", Var, 14},
{"Ogham", Var, 0},
{"Ol_Chiki", Var, 0},
{"Old_Hungarian", Var, 5},
{"Old_Italic", Var, 0},
{"Old_North_Arabian", Var, 4},
{"Old_Permic", Var, 4},
{"Old_Persian", Var, 0},
{"Old_Sogdian", Var, 13},
{"Old_South_Arabian", Var, 0},
{"Old_Turkic", Var, 0},
{"Old_Uyghur", Var, 21},
{"Oriya", Var, 0},
{"Osage", Var, 7},
{"Osmanya", Var, 0},
{"Other", Var, 0},
{"Other_Alphabetic", Var, 0},
{"Other_Default_Ignorable_Code_Point", Var, 0},
{"Other_Grapheme_Extend", Var, 0},
{"Other_ID_Continue", Var, 0},
{"Other_ID_Start", Var, 0},
{"Other_Lowercase", Var, 0},
{"Other_Math", Var, 0},
{"Other_Uppercase", Var, 0},
{"P", Var, 0},
{"Pahawh_Hmong", Var, 4},
{"Palmyrene", Var, 4},
{"Pattern_Syntax", Var, 0},
{"Pattern_White_Space", Var, 0},
{"Pau_Cin_Hau", Var, 4},
{"Pc", Var, 0},
{"Pd", Var, 0},
{"Pe", Var, 0},
{"Pf", Var, 0},
{"Phags_Pa", Var, 0},
{"Phoenician", Var, 0},
{"Pi", Var, 0},
{"Po", Var, 0},
{"Prepended_Concatenation_Mark", Var, 7},
{"PrintRanges", Var, 0},
{"Properties", Var, 0},
{"Ps", Var, 0},
{"Psalter_Pahlavi", Var, 4},
{"Punct", Var, 0},
{"Quotation_Mark", Var, 0},
{"Radical", Var, 0},
{"Range16", Type, 0},
{"Range16.Hi", Field, 0},
{"Range16.Lo", Field, 0},
{"Range16.Stride", Field, 0},
{"Range32", Type, 0},
{"Range32.Hi", Field, 0},
{"Range32.Lo", Field, 0},
{"Range32.Stride", Field, 0},
{"RangeTable", Type, 0},
{"RangeTable.LatinOffset", Field, 1},
{"RangeTable.R16", Field, 0},
{"RangeTable.R32", Field, 0},
{"Regional_Indicator", Var, 10},
{"Rejang", Var, 0},
{"ReplacementChar", Const, 0},
{"Runic", Var, 0},
{"S", Var, 0},
{"STerm", Var, 0},
{"Samaritan", Var, 0},
{"Saurashtra", Var, 0},
{"Sc", Var, 0},
{"Scripts", Var, 0},
{"Sentence_Terminal", Var, 7},
{"Sharada", Var, 1},
{"Shavian", Var, 0},
{"Siddham", Var, 4},
{"SignWriting", Var, 5},
{"SimpleFold", Func, 0},
{"Sinhala", Var, 0},
{"Sk", Var, 0},
{"Sm", Var, 0},
{"So", Var, 0},
{"Soft_Dotted", Var, 0},
{"Sogdian", Var, 13},
{"Sora_Sompeng", Var, 1},
{"Soyombo", Var, 10},
{"Space", Var, 0},
{"SpecialCase", Type, 0},
{"Sundanese", Var, 0},
{"Syloti_Nagri", Var, 0},
{"Symbol", Var, 0},
{"Syriac", Var, 0},
{"Tagalog", Var, 0},
{"Tagbanwa", Var, 0},
{"Tai_Le", Var, 0},
{"Tai_Tham", Var, 0},
{"Tai_Viet", Var, 0},
{"Takri", Var, 1},
{"Tamil", Var, 0},
{"Tangsa", Var, 21},
{"Tangut", Var, 7},
{"Telugu", Var, 0},
{"Terminal_Punctuation", Var, 0},
{"Thaana", Var, 0},
{"Thai", Var, 0},
{"Tibetan", Var, 0},
{"Tifinagh", Var, 0},
{"Tirhuta", Var, 4},
{"Title", Var, 0},
{"TitleCase", Const, 0},
{"To", Func, 0},
{"ToLower", Func, 0},
{"ToTitle", Func, 0},
{"ToUpper", Func, 0},
{"Toto", Var, 21},
{"TurkishCase", Var, 0},
{"Ugaritic", Var, 0},
{"Unified_Ideograph", Var, 0},
{"Upper", Var, 0},
{"UpperCase", Const, 0},
{"UpperLower", Const, 0},
{"Vai", Var, 0},
{"Variation_Selector", Var, 0},
{"Version", Const, 0},
{"Vithkuqi", Var, 21},
{"Wancho", Var, 14},
{"Warang_Citi", Var, 4},
{"White_Space", Var, 0},
{"Yezidi", Var, 16},
{"Yi", Var, 0},
{"Z", Var, 0},
{"Zanabazar_Square", Var, 10},
{"Zl", Var, 0},
{"Zp", Var, 0},
{"Zs", Var, 0},
},
"unicode/utf16": {
{"AppendRune", Func, 20},
{"Decode", Func, 0},
{"DecodeRune", Func, 0},
{"Encode", Func, 0},
{"EncodeRune", Func, 0},
{"IsSurrogate", Func, 0},
{"RuneLen", Func, 23},
},
"unicode/utf8": {
{"AppendRune", Func, 18},
{"DecodeLastRune", Func, 0},
{"DecodeLastRuneInString", Func, 0},
{"DecodeRune", Func, 0},
{"DecodeRuneInString", Func, 0},
{"EncodeRune", Func, 0},
{"FullRune", Func, 0},
{"FullRuneInString", Func, 0},
{"MaxRune", Const, 0},
{"RuneCount", Func, 0},
{"RuneCountInString", Func, 0},
{"RuneError", Const, 0},
{"RuneLen", Func, 0},
{"RuneSelf", Const, 0},
{"RuneStart", Func, 0},
{"UTFMax", Const, 0},
{"Valid", Func, 0},
{"ValidRune", Func, 1},
{"ValidString", Func, 0},
},
"unique": {
{"(Handle).Value", Method, 23},
{"Handle", Type, 23},
{"Make", Func, 23},
},
"unsafe": {
{"Add", Func, 0},
{"Alignof", Func, 0},
{"Offsetof", Func, 0},
{"Pointer", Type, 0},
{"Sizeof", Func, 0},
{"Slice", Func, 0},
{"SliceData", Func, 0},
{"String", Func, 0},
{"StringData", Func, 0},
},
}
|
go/src/cmd/vendor/golang.org/x/tools/internal/stdlib/manifest.go/0
|
{
"file_path": "go/src/cmd/vendor/golang.org/x/tools/internal/stdlib/manifest.go",
"repo_id": "go",
"token_count": 254358
}
| 197 |
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package markdown
import (
"bytes"
"fmt"
"strings"
"unicode"
"unicode/utf8"
)
/*
text node can be
- other literal text
- run of * or _ characters
- [
- ![
keep delimiter stack pointing at non-other literal text
each node contains
- type of delimiter [ ![ _ *
- number of delimiters
- active or not
- potential opener, potential closer, or obth
when a ] is hit, call look for link or image
when end is hit, call process emphasis
look for link or image:
find topmost [ or ![
if none, emit literal ]
if its inactive, remove and emit literal ]
parse ahead to look for rest of link; if none, remove and emit literal ]
run process emphasis on the interior,
remove opener
if this was a link (not an image), set all [ before opener to inactive, to avoid links inside links
process emphasis
walk forward in list to find a closer.
walk back to find first potential matching opener.
if found:
strong for length >= 2
insert node
drop delimiters between opener and closer
remove 1 or 2 from open/close count, removing if now empty
if closing has some left, go around again on this node
if not:
set openers bottom for this kind of element to before current_position
if the closer at current pos is not an opener, remove it
seems needlessly complex. two passes
scan and find ` ` first.
pass 1. scan and find [ and ]() and leave the rest alone.
each completed one invokes emphasis on inner text and then on the overall list.
*/
type Inline interface {
PrintHTML(*bytes.Buffer)
PrintText(*bytes.Buffer)
printMarkdown(*bytes.Buffer)
}
type Plain struct {
Text string
}
func (*Plain) Inline() {}
func (x *Plain) PrintHTML(buf *bytes.Buffer) {
htmlEscaper.WriteString(buf, x.Text)
}
func (x *Plain) printMarkdown(buf *bytes.Buffer) {
buf.WriteString(x.Text)
}
func (x *Plain) PrintText(buf *bytes.Buffer) {
htmlEscaper.WriteString(buf, x.Text)
}
type openPlain struct {
Plain
i int // position in input where bracket is
}
type emphPlain struct {
Plain
canOpen bool
canClose bool
i int // position in output where emph is
n int // length of original span
}
type Escaped struct {
Plain
}
func (x *Escaped) printMarkdown(buf *bytes.Buffer) {
buf.WriteByte('\\')
x.Plain.printMarkdown(buf)
}
type Code struct {
Text string
}
func (*Code) Inline() {}
func (x *Code) PrintHTML(buf *bytes.Buffer) {
fmt.Fprintf(buf, "<code>%s</code>", htmlEscaper.Replace(x.Text))
}
func (x *Code) printMarkdown(buf *bytes.Buffer) {
if len(x.Text) == 0 {
return
}
// Use the fewest backticks we can, and add spaces as needed.
ticks := strings.Repeat("`", longestSequence(x.Text, '`')+1)
buf.WriteString(ticks)
if x.Text[0] == '`' {
buf.WriteByte(' ')
}
buf.WriteString(x.Text)
if x.Text[len(x.Text)-1] == '`' {
buf.WriteByte(' ')
}
buf.WriteString(ticks)
}
// longestSequence returns the length of the longest sequence of consecutive bytes b in s.
func longestSequence(s string, b byte) int {
max := 0
cur := 0
for i := range s {
if s[i] == b {
cur++
} else {
if cur > max {
max = cur
}
cur = 0
}
}
if cur > max {
max = cur
}
return max
}
func (x *Code) PrintText(buf *bytes.Buffer) {
htmlEscaper.WriteString(buf, x.Text)
}
type Strong struct {
Marker string
Inner []Inline
}
func (x *Strong) Inline() {
}
func (x *Strong) PrintHTML(buf *bytes.Buffer) {
buf.WriteString("<strong>")
for _, c := range x.Inner {
c.PrintHTML(buf)
}
buf.WriteString("</strong>")
}
func (x *Strong) printMarkdown(buf *bytes.Buffer) {
buf.WriteString(x.Marker)
for _, c := range x.Inner {
c.printMarkdown(buf)
}
buf.WriteString(x.Marker)
}
func (x *Strong) PrintText(buf *bytes.Buffer) {
for _, c := range x.Inner {
c.PrintText(buf)
}
}
type Del struct {
Marker string
Inner []Inline
}
func (x *Del) Inline() {
}
func (x *Del) PrintHTML(buf *bytes.Buffer) {
buf.WriteString("<del>")
for _, c := range x.Inner {
c.PrintHTML(buf)
}
buf.WriteString("</del>")
}
func (x *Del) printMarkdown(buf *bytes.Buffer) {
buf.WriteString(x.Marker)
for _, c := range x.Inner {
c.printMarkdown(buf)
}
buf.WriteString(x.Marker)
}
func (x *Del) PrintText(buf *bytes.Buffer) {
for _, c := range x.Inner {
c.PrintText(buf)
}
}
type Emph struct {
Marker string
Inner []Inline
}
func (*Emph) Inline() {}
func (x *Emph) PrintHTML(buf *bytes.Buffer) {
buf.WriteString("<em>")
for _, c := range x.Inner {
c.PrintHTML(buf)
}
buf.WriteString("</em>")
}
func (x *Emph) printMarkdown(buf *bytes.Buffer) {
buf.WriteString(x.Marker)
for _, c := range x.Inner {
c.printMarkdown(buf)
}
buf.WriteString(x.Marker)
}
func (x *Emph) PrintText(buf *bytes.Buffer) {
for _, c := range x.Inner {
c.PrintText(buf)
}
}
func (p *parseState) emit(i int) {
if p.emitted < i {
p.list = append(p.list, &Plain{p.s[p.emitted:i]})
p.emitted = i
}
}
func (p *parseState) skip(i int) {
p.emitted = i
}
func (p *parseState) inline(s string) []Inline {
s = trimSpaceTab(s)
// Scan text looking for inlines.
// Leaf inlines are converted immediately.
// Non-leaf inlines have potential starts pushed on a stack while we await completion.
// Links take priority over other emphasis, so the emphasis must be delayed.
p.s = s
p.list = nil
p.emitted = 0
var opens []int // indexes of open ![ and [ Plains in p.list
var lastLinkOpen int
backticks := false
i := 0
for i < len(s) {
var parser func(*parseState, string, int) (Inline, int, int, bool)
switch s[i] {
case '\\':
parser = parseEscape
case '`':
if !backticks {
backticks = true
p.backticks.reset()
}
parser = p.backticks.parseCodeSpan
case '<':
parser = parseAutoLinkOrHTML
case '[':
parser = parseLinkOpen
case '!':
parser = parseImageOpen
case '_', '*':
parser = parseEmph
case '.':
if p.SmartDot {
parser = parseDot
}
case '-':
if p.SmartDash {
parser = parseDash
}
case '"', '\'':
if p.SmartQuote {
parser = parseEmph
}
case '~':
if p.Strikethrough {
parser = parseEmph
}
case '\n': // TODO what about eof
parser = parseBreak
case '&':
parser = parseHTMLEntity
case ':':
if p.Emoji {
parser = parseEmoji
}
}
if parser != nil {
if x, start, end, ok := parser(p, s, i); ok {
p.emit(start)
if _, ok := x.(*openPlain); ok {
opens = append(opens, len(p.list))
}
p.list = append(p.list, x)
i = end
p.skip(i)
continue
}
}
if s[i] == ']' && len(opens) > 0 {
oi := opens[len(opens)-1]
open := p.list[oi].(*openPlain)
opens = opens[:len(opens)-1]
if open.Text[0] == '!' || lastLinkOpen <= open.i {
if x, end, ok := p.parseLinkClose(s, i, open); ok {
p.corner = p.corner || x.corner || linkCorner(x.URL)
p.emit(i)
x.Inner = p.emph(nil, p.list[oi+1:])
if open.Text[0] == '!' {
p.list[oi] = (*Image)(x)
} else {
p.list[oi] = x
}
p.list = p.list[:oi+1]
p.skip(end)
i = end
if open.Text[0] == '[' {
// No links around links.
lastLinkOpen = open.i
}
continue
}
}
}
i++
}
p.emit(len(s))
p.list = p.emph(p.list[:0], p.list)
p.list = p.mergePlain(p.list)
p.list = p.autoLinkText(p.list)
return p.list
}
func (ps *parseState) emph(dst, src []Inline) []Inline {
const chars = "_*~\"'"
var stack [len(chars)][]*emphPlain
stackOf := func(c byte) int {
return strings.IndexByte(chars, c)
}
trimStack := func() {
for i := range stack {
stk := &stack[i]
for len(*stk) > 0 && (*stk)[len(*stk)-1].i >= len(dst) {
*stk = (*stk)[:len(*stk)-1]
}
}
}
Src:
for i := 0; i < len(src); i++ {
if open, ok := src[i].(*openPlain); ok {
// Convert unused link/image open marker to plain text.
dst = append(dst, &open.Plain)
continue
}
p, ok := src[i].(*emphPlain)
if !ok {
dst = append(dst, src[i])
continue
}
if p.canClose {
stk := &stack[stackOf(p.Text[0])]
Loop:
for p.Text != "" {
// Looking for same symbol and compatible with p.Text.
for i := len(*stk) - 1; i >= 0; i-- {
start := (*stk)[i]
if (p.Text[0] == '*' || p.Text[0] == '_') && (p.canOpen && p.canClose || start.canOpen && start.canClose) && (p.n+start.n)%3 == 0 && (p.n%3 != 0 || start.n%3 != 0) {
continue
}
if p.Text[0] == '~' && len(p.Text) != len(start.Text) { // ~ matches ~, ~~ matches ~~
continue
}
if p.Text[0] == '"' {
dst[start.i].(*emphPlain).Text = "β"
p.Text = "β"
dst = append(dst, p)
*stk = (*stk)[:i]
// no trimStack
continue Src
}
if p.Text[0] == '\'' {
dst[start.i].(*emphPlain).Text = "β"
p.Text = "β"
dst = append(dst, p)
*stk = (*stk)[:i]
// no trimStack
continue Src
}
var d int
if len(p.Text) >= 2 && len(start.Text) >= 2 {
// strong
d = 2
} else {
// emph
d = 1
}
del := p.Text[0] == '~'
x := &Emph{Marker: p.Text[:d], Inner: append([]Inline(nil), dst[start.i+1:]...)}
start.Text = start.Text[:len(start.Text)-d]
p.Text = p.Text[d:]
if start.Text == "" {
dst = dst[:start.i]
} else {
dst = dst[:start.i+1]
}
trimStack()
if del {
dst = append(dst, (*Del)(x))
} else if d == 2 {
dst = append(dst, (*Strong)(x))
} else {
dst = append(dst, x)
}
continue Loop
}
break
}
}
if p.Text != "" {
stk := &stack[stackOf(p.Text[0])]
if p.Text == "'" {
p.Text = "β"
}
if p.Text == "\"" {
if p.canClose {
p.Text = "β"
} else {
p.Text = "β"
}
}
if p.canOpen {
p.i = len(dst)
dst = append(dst, p)
*stk = append(*stk, p)
} else {
dst = append(dst, &p.Plain)
}
}
}
return dst
}
func mdUnescape(s string) string {
if !strings.Contains(s, `\`) && !strings.Contains(s, `&`) {
return s
}
return mdUnescaper.Replace(s)
}
var mdUnescaper = func() *strings.Replacer {
var list = []string{
`\!`, `!`,
`\"`, `"`,
`\#`, `#`,
`\$`, `$`,
`\%`, `%`,
`\&`, `&`,
`\'`, `'`,
`\(`, `(`,
`\)`, `)`,
`\*`, `*`,
`\+`, `+`,
`\,`, `,`,
`\-`, `-`,
`\.`, `.`,
`\/`, `/`,
`\:`, `:`,
`\;`, `;`,
`\<`, `<`,
`\=`, `=`,
`\>`, `>`,
`\?`, `?`,
`\@`, `@`,
`\[`, `[`,
`\\`, `\`,
`\]`, `]`,
`\^`, `^`,
`\_`, `_`,
"\\`", "`",
`\{`, `{`,
`\|`, `|`,
`\}`, `}`,
`\~`, `~`,
}
for name, repl := range htmlEntity {
list = append(list, name, repl)
}
return strings.NewReplacer(list...)
}()
func isPunct(c byte) bool {
return '!' <= c && c <= '/' || ':' <= c && c <= '@' || '[' <= c && c <= '`' || '{' <= c && c <= '~'
}
func parseEscape(p *parseState, s string, i int) (Inline, int, int, bool) {
if i+1 < len(s) {
c := s[i+1]
if isPunct(c) {
return &Escaped{Plain{s[i+1 : i+2]}}, i, i + 2, true
}
if c == '\n' { // TODO what about eof
if i > 0 && s[i-1] == '\\' {
p.corner = true // goldmark mishandles \\\ newline
}
end := i + 2
for end < len(s) && (s[end] == ' ' || s[end] == '\t') {
end++
}
return &HardBreak{}, i, end, true
}
}
return nil, 0, 0, false
}
func parseDot(p *parseState, s string, i int) (Inline, int, int, bool) {
if i+2 < len(s) && s[i+1] == '.' && s[i+2] == '.' {
return &Plain{"β¦"}, i, i + 3, true
}
return nil, 0, 0, false
}
func parseDash(p *parseState, s string, i int) (Inline, int, int, bool) {
if i+1 >= len(s) || s[i+1] != '-' {
return nil, 0, 0, false
}
n := 2
for i+n < len(s) && s[i+n] == '-' {
n++
}
// Mimic cmark-gfm. Can't make this stuff up.
em, en := 0, 0
switch {
case n%3 == 0:
em = n / 3
case n%2 == 0:
en = n / 2
case n%3 == 2:
em = (n - 2) / 3
en = 1
case n%3 == 1:
em = (n - 4) / 3
en = 2
}
return &Plain{strings.Repeat("β", em) + strings.Repeat("β", en)}, i, i + n, true
}
// Inline code span markers must fit on punched cards, to match cmark-gfm.
const maxBackticks = 80
type backtickParser struct {
last [maxBackticks]int
scanned bool
}
func (b *backtickParser) reset() {
*b = backtickParser{}
}
func (b *backtickParser) parseCodeSpan(p *parseState, s string, i int) (Inline, int, int, bool) {
start := i
// Count leading backticks. Need to find that many again.
n := 1
for i+n < len(s) && s[i+n] == '`' {
n++
}
// If we've already scanned the whole string (for a different count),
// we can skip a failed scan by checking whether we saw this count.
// To enable this optimization, following cmark-gfm, we declare by fiat
// that more than maxBackticks backquotes is too many.
if n > len(b.last) || b.scanned && b.last[n-1] < i+n {
goto NoMatch
}
for end := i + n; end < len(s); {
if s[end] != '`' {
end++
continue
}
estart := end
for end < len(s) && s[end] == '`' {
end++
}
m := end - estart
if !b.scanned && m < len(b.last) {
b.last[m-1] = estart
}
if m == n {
// Match.
// Line endings are converted to single spaces.
text := s[i+n : estart]
text = strings.ReplaceAll(text, "\n", " ")
// If enclosed text starts and ends with a space and is not all spaces,
// one space is removed from start and end, to allow `` ` `` to quote a single backquote.
if len(text) >= 2 && text[0] == ' ' && text[len(text)-1] == ' ' && trimSpace(text) != "" {
text = text[1 : len(text)-1]
}
return &Code{text}, start, end, true
}
}
b.scanned = true
NoMatch:
// No match, so none of these backticks count: skip them all.
// For example ``x` is not a single backtick followed by a code span.
// Returning nil, 0, false would advance to the second backtick and try again.
return &Plain{s[i : i+n]}, start, i + n, true
}
func parseAutoLinkOrHTML(p *parseState, s string, i int) (Inline, int, int, bool) {
if x, end, ok := parseAutoLinkURI(s, i); ok {
return x, i, end, true
}
if x, end, ok := parseAutoLinkEmail(s, i); ok {
return x, i, end, true
}
if x, end, ok := parseHTMLTag(p, s, i); ok {
return x, i, end, true
}
return nil, 0, 0, false
}
func isLetter(c byte) bool {
return 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z'
}
func isLDH(c byte) bool {
return isLetterDigit(c) || c == '-'
}
func isLetterDigit(c byte) bool {
return 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' || '0' <= c && c <= '9'
}
func parseLinkOpen(_ *parseState, s string, i int) (Inline, int, int, bool) {
return &openPlain{Plain{s[i : i+1]}, i + 1}, i, i + 1, true
}
func parseImageOpen(_ *parseState, s string, i int) (Inline, int, int, bool) {
if i+1 < len(s) && s[i+1] == '[' {
return &openPlain{Plain{s[i : i+2]}, i + 2}, i, i + 2, true
}
return nil, 0, 0, false
}
func parseEmph(p *parseState, s string, i int) (Inline, int, int, bool) {
c := s[i]
j := i + 1
if c == '*' || c == '~' || c == '_' {
for j < len(s) && s[j] == c {
j++
}
}
if c == '~' && j-i != 2 {
// Goldmark does not accept ~text~
// and incorrectly accepts ~~~text~~~.
// Only ~~ is correct.
p.corner = true
}
if c == '~' && j-i > 2 {
return &Plain{s[i:j]}, i, j, true
}
var before, after rune
if i == 0 {
before = ' '
} else {
before, _ = utf8.DecodeLastRuneInString(s[:i])
}
if j >= len(s) {
after = ' '
} else {
after, _ = utf8.DecodeRuneInString(s[j:])
}
// βA left-flanking delimiter run is a delimiter run that is
// (1) not followed by Unicode whitespace, and either
// (2a) not followed by a Unicode punctuation character, or
// (2b) followed by a Unicode punctuation character
// and preceded by Unicode whitespace or a Unicode punctuation character.
// For purposes of this definition, the beginning and the end
// of the line count as Unicode whitespace.β
leftFlank := !isUnicodeSpace(after) &&
(!isUnicodePunct(after) || isUnicodeSpace(before) || isUnicodePunct(before))
// βA right-flanking delimiter run is a delimiter run that is
// (1) not preceded by Unicode whitespace, and either
// (2a) not preceded by a Unicode punctuation character, or
// (2b) preceded by a Unicode punctuation character
// and followed by Unicode whitespace or a Unicode punctuation character.
// For purposes of this definition, the beginning and the end
// of the line count as Unicode whitespace.β
rightFlank := !isUnicodeSpace(before) &&
(!isUnicodePunct(before) || isUnicodeSpace(after) || isUnicodePunct(after))
var canOpen, canClose bool
switch c {
case '\'', '"':
canOpen = leftFlank && !rightFlank && before != ']' && before != ')'
canClose = rightFlank
case '*', '~':
// βA single * character can open emphasis iff
// it is part of a left-flanking delimiter run.β
// βA double ** can open strong emphasis iff
// it is part of a left-flanking delimiter run.β
canOpen = leftFlank
// βA single * character can close emphasis iff
// it is part of a right-flanking delimiter run.β
// βA double ** can close strong emphasis iff
// it is part of a right-flanking delimiter run.β
canClose = rightFlank
case '_':
// βA single _ character can open emphasis iff
// it is part of a left-flanking delimiter run and either
// (a) not part of a right-flanking delimiter run or
// (b) part of a right-flanking delimiter run preceded by a Unicode punctuation character.β
// βA double __ can open strong emphasis iff
// it is part of a left-flanking delimiter run and either
// (a) not part of a right-flanking delimiter run or
// (b) part of a right-flanking delimiter run preceded by a Unicode punctuation character.β
canOpen = leftFlank && (!rightFlank || isUnicodePunct(before))
// βA single _ character can close emphasis iff
// it is part of a right-flanking delimiter run and either
// (a) not part of a left-flanking delimiter run or
// (b) part of a left-flanking delimiter run followed by a Unicode punctuation character.β
// βA double __ can close strong emphasis iff
// it is part of a right-flanking delimiter run and either
// (a) not part of a left-flanking delimiter run or
// (b) part of a left-flanking delimiter run followed by a Unicode punctuation character.β
canClose = rightFlank && (!leftFlank || isUnicodePunct(after))
}
return &emphPlain{Plain: Plain{s[i:j]}, canOpen: canOpen, canClose: canClose, n: j - i}, i, j, true
}
func isUnicodeSpace(r rune) bool {
if r < 0x80 {
return r == ' ' || r == '\t' || r == '\f' || r == '\n'
}
return unicode.In(r, unicode.Zs)
}
func isUnicodePunct(r rune) bool {
if r < 0x80 {
return isPunct(byte(r))
}
return unicode.In(r, unicode.Punct)
}
func (p *parseState) parseLinkClose(s string, i int, open *openPlain) (*Link, int, bool) {
if i+1 < len(s) {
switch s[i+1] {
case '(':
// Inline link - [Text](Dest Title), with Title omitted or both Dest and Title omitted.
i := skipSpace(s, i+2)
var dest, title string
var titleChar byte
var corner bool
if i < len(s) && s[i] != ')' {
var ok bool
dest, i, ok = parseLinkDest(s, i)
if !ok {
break
}
i = skipSpace(s, i)
if i < len(s) && s[i] != ')' {
title, titleChar, i, ok = parseLinkTitle(s, i)
if title == "" {
corner = true
}
if !ok {
break
}
i = skipSpace(s, i)
}
}
if i < len(s) && s[i] == ')' {
return &Link{URL: dest, Title: title, TitleChar: titleChar, corner: corner}, i + 1, true
}
// NOTE: Test malformed ( ) with shortcut reference
// TODO fall back on syntax error?
case '[':
// Full reference link - [Text][Label]
label, i, ok := parseLinkLabel(p, s, i+1)
if !ok {
break
}
if link, ok := p.links[normalizeLabel(label)]; ok {
return &Link{URL: link.URL, Title: link.Title, corner: link.corner}, i, true
}
// Note: Could break here, but CommonMark dingus does not
// fall back to trying Text for [Text][Label] when Label is unknown.
// Unclear from spec what the correct answer is.
return nil, 0, false
}
}
// Collapsed or shortcut reference link: [Text][] or [Text].
end := i + 1
if strings.HasPrefix(s[end:], "[]") {
end += 2
}
if link, ok := p.links[normalizeLabel(s[open.i:i])]; ok {
return &Link{URL: link.URL, Title: link.Title, corner: link.corner}, end, true
}
return nil, 0, false
}
func skipSpace(s string, i int) int {
// Note: Blank lines have already been removed.
for i < len(s) && (s[i] == ' ' || s[i] == '\t' || s[i] == '\n') {
i++
}
return i
}
func linkCorner(url string) bool {
for i := 0; i < len(url); i++ {
if url[i] == '%' {
if i+2 >= len(url) || !isHexDigit(url[i+1]) || !isHexDigit(url[i+2]) {
// Goldmark and the Dingus re-escape such percents as %25,
// but the spec does not seem to require this behavior.
return true
}
}
}
return false
}
func (p *parseState) mergePlain(list []Inline) []Inline {
out := list[:0]
start := 0
for i := 0; ; i++ {
if i < len(list) && toPlain(list[i]) != nil {
continue
}
// Non-Plain or end of list.
if start < i {
out = append(out, mergePlain1(list[start:i]))
}
if i >= len(list) {
break
}
out = append(out, list[i])
start = i + 1
}
return out
}
func toPlain(x Inline) *Plain {
// TODO what about Escaped?
switch x := x.(type) {
case *Plain:
return x
case *emphPlain:
return &x.Plain
case *openPlain:
return &x.Plain
}
return nil
}
func mergePlain1(list []Inline) *Plain {
if len(list) == 1 {
return toPlain(list[0])
}
var all []string
for _, pl := range list {
all = append(all, toPlain(pl).Text)
}
return &Plain{Text: strings.Join(all, "")}
}
func parseEmoji(p *parseState, s string, i int) (Inline, int, int, bool) {
for j := i + 1; ; j++ {
if j >= len(s) || j-i > 2+maxEmojiLen {
break
}
if s[j] == ':' {
name := s[i+1 : j]
if utf, ok := emoji[name]; ok {
return &Emoji{s[i : j+1], utf}, i, j + 1, true
}
break
}
}
return nil, 0, 0, false
}
type Emoji struct {
Name string // emoji :name:, including colons
Text string // Unicode for emoji sequence
}
func (*Emoji) Inline() {}
func (x *Emoji) PrintHTML(buf *bytes.Buffer) {
htmlEscaper.WriteString(buf, x.Text)
}
func (x *Emoji) printMarkdown(buf *bytes.Buffer) {
buf.WriteString(x.Text)
}
func (x *Emoji) PrintText(buf *bytes.Buffer) {
htmlEscaper.WriteString(buf, x.Text)
}
|
go/src/cmd/vendor/rsc.io/markdown/inline.go/0
|
{
"file_path": "go/src/cmd/vendor/rsc.io/markdown/inline.go",
"repo_id": "go",
"token_count": 9747
}
| 198 |
// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package nilfunc
func F() {}
func Comparison() {
if F == nil { // ERROR "comparison of function F == nil is always false"
panic("can't happen")
}
}
|
go/src/cmd/vet/testdata/nilfunc/nilfunc.go/0
|
{
"file_path": "go/src/cmd/vet/testdata/nilfunc/nilfunc.go",
"repo_id": "go",
"token_count": 93
}
| 199 |
// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"bytes"
"errors"
"fmt"
"internal/testenv"
"log"
"os"
"os/exec"
"path"
"path/filepath"
"regexp"
"strconv"
"strings"
"sync"
"testing"
)
// TestMain executes the test binary as the vet command if
// GO_VETTEST_IS_VET is set, and runs the tests otherwise.
func TestMain(m *testing.M) {
if os.Getenv("GO_VETTEST_IS_VET") != "" {
main()
os.Exit(0)
}
os.Setenv("GO_VETTEST_IS_VET", "1") // Set for subprocesses to inherit.
os.Exit(m.Run())
}
// vetPath returns the path to the "vet" binary to run.
func vetPath(t testing.TB) string {
t.Helper()
testenv.MustHaveExec(t)
vetPathOnce.Do(func() {
vetExePath, vetPathErr = os.Executable()
})
if vetPathErr != nil {
t.Fatal(vetPathErr)
}
return vetExePath
}
var (
vetPathOnce sync.Once
vetExePath string
vetPathErr error
)
func vetCmd(t *testing.T, arg, pkg string) *exec.Cmd {
cmd := testenv.Command(t, testenv.GoToolPath(t), "vet", "-vettool="+vetPath(t), arg, path.Join("cmd/vet/testdata", pkg))
cmd.Env = os.Environ()
return cmd
}
func TestVet(t *testing.T) {
t.Parallel()
for _, pkg := range []string{
"appends",
"asm",
"assign",
"atomic",
"bool",
"buildtag",
"cgo",
"composite",
"copylock",
"deadcode",
"directive",
"httpresponse",
"lostcancel",
"method",
"nilfunc",
"print",
"shift",
"slog",
"structtag",
"testingpkg",
// "testtag" has its own test
"unmarshal",
"unsafeptr",
"unused",
} {
pkg := pkg
t.Run(pkg, func(t *testing.T) {
t.Parallel()
// Skip cgo test on platforms without cgo.
if pkg == "cgo" && !cgoEnabled(t) {
return
}
cmd := vetCmd(t, "-printfuncs=Warn,Warnf", pkg)
// The asm test assumes amd64.
if pkg == "asm" {
cmd.Env = append(cmd.Env, "GOOS=linux", "GOARCH=amd64")
}
dir := filepath.Join("testdata", pkg)
gos, err := filepath.Glob(filepath.Join(dir, "*.go"))
if err != nil {
t.Fatal(err)
}
asms, err := filepath.Glob(filepath.Join(dir, "*.s"))
if err != nil {
t.Fatal(err)
}
var files []string
files = append(files, gos...)
files = append(files, asms...)
errchk(cmd, files, t)
})
}
// The loopclosure analyzer (aka "rangeloop" before CL 140578)
// is a no-op for files whose version >= go1.22, so we use a
// go.mod file in the rangeloop directory to "downgrade".
//
// TOOD(adonovan): delete when go1.21 goes away.
t.Run("loopclosure", func(t *testing.T) {
cmd := testenv.Command(t, testenv.GoToolPath(t), "vet", "-vettool="+vetPath(t), ".")
cmd.Env = append(os.Environ(), "GOWORK=off")
cmd.Dir = "testdata/rangeloop"
cmd.Stderr = new(strings.Builder) // all vet output goes to stderr
cmd.Run()
stderr := cmd.Stderr.(fmt.Stringer).String()
filename := filepath.FromSlash("testdata/rangeloop/rangeloop.go")
// Unlike the tests above, which runs vet in cmd/vet/, this one
// runs it in subdirectory, so the "full names" in the output
// are in fact short "./rangeloop.go".
// But we can't just pass "./rangeloop.go" as the "full name"
// argument to errorCheck as it does double duty as both a
// string that appears in the output, and as file name
// openable relative to the test directory, containing text
// expectations.
//
// So, we munge the file.
stderr = strings.ReplaceAll(stderr, filepath.FromSlash("./rangeloop.go"), filename)
if err := errorCheck(stderr, false, filename, filepath.Base(filename)); err != nil {
t.Errorf("error check failed: %s", err)
t.Log("vet stderr:\n", cmd.Stderr)
}
})
// The stdversion analyzer requires a lower-than-tip go
// version in its go.mod file for it to report anything.
// So again we use a testdata go.mod file to "downgrade".
t.Run("stdversion", func(t *testing.T) {
cmd := testenv.Command(t, testenv.GoToolPath(t), "vet", "-vettool="+vetPath(t), ".")
cmd.Env = append(os.Environ(), "GOWORK=off")
cmd.Dir = "testdata/stdversion"
cmd.Stderr = new(strings.Builder) // all vet output goes to stderr
cmd.Run()
stderr := cmd.Stderr.(fmt.Stringer).String()
filename := filepath.FromSlash("testdata/stdversion/stdversion.go")
// Unlike the tests above, which runs vet in cmd/vet/, this one
// runs it in subdirectory, so the "full names" in the output
// are in fact short "./rangeloop.go".
// But we can't just pass "./rangeloop.go" as the "full name"
// argument to errorCheck as it does double duty as both a
// string that appears in the output, and as file name
// openable relative to the test directory, containing text
// expectations.
//
// So, we munge the file.
stderr = strings.ReplaceAll(stderr, filepath.FromSlash("./stdversion.go"), filename)
if err := errorCheck(stderr, false, filename, filepath.Base(filename)); err != nil {
t.Errorf("error check failed: %s", err)
t.Log("vet stderr:\n", cmd.Stderr)
}
})
}
func cgoEnabled(t *testing.T) bool {
// Don't trust build.Default.CgoEnabled as it is false for
// cross-builds unless CGO_ENABLED is explicitly specified.
// That's fine for the builders, but causes commands like
// 'GOARCH=386 go test .' to fail.
// Instead, we ask the go command.
cmd := testenv.Command(t, testenv.GoToolPath(t), "list", "-f", "{{context.CgoEnabled}}")
out, _ := cmd.CombinedOutput()
return string(out) == "true\n"
}
func errchk(c *exec.Cmd, files []string, t *testing.T) {
output, err := c.CombinedOutput()
if _, ok := err.(*exec.ExitError); !ok {
t.Logf("vet output:\n%s", output)
t.Fatal(err)
}
fullshort := make([]string, 0, len(files)*2)
for _, f := range files {
fullshort = append(fullshort, f, filepath.Base(f))
}
err = errorCheck(string(output), false, fullshort...)
if err != nil {
t.Errorf("error check failed: %s", err)
}
}
// TestTags verifies that the -tags argument controls which files to check.
func TestTags(t *testing.T) {
t.Parallel()
for tag, wantFile := range map[string]int{
"testtag": 1, // file1
"x testtag y": 1,
"othertag": 2,
} {
tag, wantFile := tag, wantFile
t.Run(tag, func(t *testing.T) {
t.Parallel()
t.Logf("-tags=%s", tag)
cmd := vetCmd(t, "-tags="+tag, "tagtest")
output, err := cmd.CombinedOutput()
want := fmt.Sprintf("file%d.go", wantFile)
dontwant := fmt.Sprintf("file%d.go", 3-wantFile)
// file1 has testtag and file2 has !testtag.
if !bytes.Contains(output, []byte(filepath.Join("tagtest", want))) {
t.Errorf("%s: %s was excluded, should be included", tag, want)
}
if bytes.Contains(output, []byte(filepath.Join("tagtest", dontwant))) {
t.Errorf("%s: %s was included, should be excluded", tag, dontwant)
}
if t.Failed() {
t.Logf("err=%s, output=<<%s>>", err, output)
}
})
}
}
// All declarations below were adapted from test/run.go.
// errorCheck matches errors in outStr against comments in source files.
// For each line of the source files which should generate an error,
// there should be a comment of the form // ERROR "regexp".
// If outStr has an error for a line which has no such comment,
// this function will report an error.
// Likewise if outStr does not have an error for a line which has a comment,
// or if the error message does not match the <regexp>.
// The <regexp> syntax is Perl but it's best to stick to egrep.
//
// Sources files are supplied as fullshort slice.
// It consists of pairs: full path to source file and its base name.
func errorCheck(outStr string, wantAuto bool, fullshort ...string) (err error) {
var errs []error
out := splitOutput(outStr, wantAuto)
// Cut directory name.
for i := range out {
for j := 0; j < len(fullshort); j += 2 {
full, short := fullshort[j], fullshort[j+1]
out[i] = strings.ReplaceAll(out[i], full, short)
}
}
var want []wantedError
for j := 0; j < len(fullshort); j += 2 {
full, short := fullshort[j], fullshort[j+1]
want = append(want, wantedErrors(full, short)...)
}
for _, we := range want {
var errmsgs []string
if we.auto {
errmsgs, out = partitionStrings("<autogenerated>", out)
} else {
errmsgs, out = partitionStrings(we.prefix, out)
}
if len(errmsgs) == 0 {
errs = append(errs, fmt.Errorf("%s:%d: missing error %q", we.file, we.lineNum, we.reStr))
continue
}
matched := false
n := len(out)
for _, errmsg := range errmsgs {
// Assume errmsg says "file:line: foo".
// Cut leading "file:line: " to avoid accidental matching of file name instead of message.
text := errmsg
if _, suffix, ok := strings.Cut(text, " "); ok {
text = suffix
}
if we.re.MatchString(text) {
matched = true
} else {
out = append(out, errmsg)
}
}
if !matched {
errs = append(errs, fmt.Errorf("%s:%d: no match for %#q in:\n\t%s", we.file, we.lineNum, we.reStr, strings.Join(out[n:], "\n\t")))
continue
}
}
if len(out) > 0 {
errs = append(errs, fmt.Errorf("Unmatched Errors:"))
for _, errLine := range out {
errs = append(errs, fmt.Errorf("%s", errLine))
}
}
if len(errs) == 0 {
return nil
}
if len(errs) == 1 {
return errs[0]
}
var buf strings.Builder
fmt.Fprintf(&buf, "\n")
for _, err := range errs {
fmt.Fprintf(&buf, "%s\n", err.Error())
}
return errors.New(buf.String())
}
func splitOutput(out string, wantAuto bool) []string {
// gc error messages continue onto additional lines with leading tabs.
// Split the output at the beginning of each line that doesn't begin with a tab.
// <autogenerated> lines are impossible to match so those are filtered out.
var res []string
for _, line := range strings.Split(out, "\n") {
line = strings.TrimSuffix(line, "\r") // normalize Windows output
if strings.HasPrefix(line, "\t") {
res[len(res)-1] += "\n" + line
} else if strings.HasPrefix(line, "go tool") || strings.HasPrefix(line, "#") || !wantAuto && strings.HasPrefix(line, "<autogenerated>") {
continue
} else if strings.TrimSpace(line) != "" {
res = append(res, line)
}
}
return res
}
// matchPrefix reports whether s starts with file name prefix followed by a :,
// and possibly preceded by a directory name.
func matchPrefix(s, prefix string) bool {
i := strings.Index(s, ":")
if i < 0 {
return false
}
j := strings.LastIndex(s[:i], "/")
s = s[j+1:]
if len(s) <= len(prefix) || s[:len(prefix)] != prefix {
return false
}
if s[len(prefix)] == ':' {
return true
}
return false
}
func partitionStrings(prefix string, strs []string) (matched, unmatched []string) {
for _, s := range strs {
if matchPrefix(s, prefix) {
matched = append(matched, s)
} else {
unmatched = append(unmatched, s)
}
}
return
}
type wantedError struct {
reStr string
re *regexp.Regexp
lineNum int
auto bool // match <autogenerated> line
file string
prefix string
}
var (
errRx = regexp.MustCompile(`// (?:GC_)?ERROR(NEXT)? (.*)`)
errAutoRx = regexp.MustCompile(`// (?:GC_)?ERRORAUTO(NEXT)? (.*)`)
errQuotesRx = regexp.MustCompile(`"([^"]*)"`)
lineRx = regexp.MustCompile(`LINE(([+-])(\d+))?`)
)
// wantedErrors parses expected errors from comments in a file.
func wantedErrors(file, short string) (errs []wantedError) {
cache := make(map[string]*regexp.Regexp)
src, err := os.ReadFile(file)
if err != nil {
log.Fatal(err)
}
for i, line := range strings.Split(string(src), "\n") {
lineNum := i + 1
if strings.Contains(line, "////") {
// double comment disables ERROR
continue
}
var auto bool
m := errAutoRx.FindStringSubmatch(line)
if m != nil {
auto = true
} else {
m = errRx.FindStringSubmatch(line)
}
if m == nil {
continue
}
if m[1] == "NEXT" {
lineNum++
}
all := m[2]
mm := errQuotesRx.FindAllStringSubmatch(all, -1)
if mm == nil {
log.Fatalf("%s:%d: invalid errchk line: %s", file, lineNum, line)
}
for _, m := range mm {
replacedOnce := false
rx := lineRx.ReplaceAllStringFunc(m[1], func(m string) string {
if replacedOnce {
return m
}
replacedOnce = true
n := lineNum
if strings.HasPrefix(m, "LINE+") {
delta, _ := strconv.Atoi(m[5:])
n += delta
} else if strings.HasPrefix(m, "LINE-") {
delta, _ := strconv.Atoi(m[5:])
n -= delta
}
return fmt.Sprintf("%s:%d", short, n)
})
re := cache[rx]
if re == nil {
var err error
re, err = regexp.Compile(rx)
if err != nil {
log.Fatalf("%s:%d: invalid regexp \"%#q\" in ERROR line: %v", file, lineNum, rx, err)
}
cache[rx] = re
}
prefix := fmt.Sprintf("%s:%d", short, lineNum)
errs = append(errs, wantedError{
reStr: rx,
re: re,
prefix: prefix,
auto: auto,
lineNum: lineNum,
file: short,
})
}
}
return
}
|
go/src/cmd/vet/vet_test.go/0
|
{
"file_path": "go/src/cmd/vet/vet_test.go",
"repo_id": "go",
"token_count": 5212
}
| 200 |
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package lzw
import (
"bytes"
"fmt"
"internal/testenv"
"io"
"math"
"os"
"runtime"
"testing"
)
var filenames = []string{
"../testdata/gettysburg.txt",
"../testdata/e.txt",
"../testdata/pi.txt",
}
// testFile tests that compressing and then decompressing the given file with
// the given options yields equivalent bytes to the original file.
func testFile(t *testing.T, fn string, order Order, litWidth int) {
// Read the file, as golden output.
golden, err := os.Open(fn)
if err != nil {
t.Errorf("%s (order=%d litWidth=%d): %v", fn, order, litWidth, err)
return
}
defer golden.Close()
// Read the file again, and push it through a pipe that compresses at the write end, and decompresses at the read end.
raw, err := os.Open(fn)
if err != nil {
t.Errorf("%s (order=%d litWidth=%d): %v", fn, order, litWidth, err)
return
}
piper, pipew := io.Pipe()
defer piper.Close()
go func() {
defer raw.Close()
defer pipew.Close()
lzww := NewWriter(pipew, order, litWidth)
defer lzww.Close()
var b [4096]byte
for {
n, err0 := raw.Read(b[:])
if err0 != nil && err0 != io.EOF {
t.Errorf("%s (order=%d litWidth=%d): %v", fn, order, litWidth, err0)
return
}
_, err1 := lzww.Write(b[:n])
if err1 != nil {
t.Errorf("%s (order=%d litWidth=%d): %v", fn, order, litWidth, err1)
return
}
if err0 == io.EOF {
break
}
}
}()
lzwr := NewReader(piper, order, litWidth)
defer lzwr.Close()
// Compare the two.
b0, err0 := io.ReadAll(golden)
b1, err1 := io.ReadAll(lzwr)
if err0 != nil {
t.Errorf("%s (order=%d litWidth=%d): %v", fn, order, litWidth, err0)
return
}
if err1 != nil {
t.Errorf("%s (order=%d litWidth=%d): %v", fn, order, litWidth, err1)
return
}
if len(b1) != len(b0) {
t.Errorf("%s (order=%d litWidth=%d): length mismatch %d != %d", fn, order, litWidth, len(b1), len(b0))
return
}
for i := 0; i < len(b0); i++ {
if b1[i] != b0[i] {
t.Errorf("%s (order=%d litWidth=%d): mismatch at %d, 0x%02x != 0x%02x\n", fn, order, litWidth, i, b1[i], b0[i])
return
}
}
}
func TestWriter(t *testing.T) {
for _, filename := range filenames {
for _, order := range [...]Order{LSB, MSB} {
// The test data "2.71828 etcetera" is ASCII text requiring at least 6 bits.
for litWidth := 6; litWidth <= 8; litWidth++ {
if filename == "../testdata/gettysburg.txt" && litWidth == 6 {
continue
}
testFile(t, filename, order, litWidth)
}
}
if testing.Short() && testenv.Builder() == "" {
break
}
}
}
func TestWriterReset(t *testing.T) {
for _, order := range [...]Order{LSB, MSB} {
t.Run(fmt.Sprintf("Order %d", order), func(t *testing.T) {
for litWidth := 6; litWidth <= 8; litWidth++ {
t.Run(fmt.Sprintf("LitWidth %d", litWidth), func(t *testing.T) {
var data []byte
if litWidth == 6 {
data = []byte{1, 2, 3}
} else {
data = []byte(`lorem ipsum dolor sit amet`)
}
var buf bytes.Buffer
w := NewWriter(&buf, order, litWidth)
if _, err := w.Write(data); err != nil {
t.Errorf("write: %v: %v", string(data), err)
}
if err := w.Close(); err != nil {
t.Errorf("close: %v", err)
}
b1 := buf.Bytes()
buf.Reset()
w.(*Writer).Reset(&buf, order, litWidth)
if _, err := w.Write(data); err != nil {
t.Errorf("write: %v: %v", string(data), err)
}
if err := w.Close(); err != nil {
t.Errorf("close: %v", err)
}
b2 := buf.Bytes()
if !bytes.Equal(b1, b2) {
t.Errorf("bytes written were not same")
}
})
}
})
}
}
func TestWriterReturnValues(t *testing.T) {
w := NewWriter(io.Discard, LSB, 8)
n, err := w.Write([]byte("asdf"))
if n != 4 || err != nil {
t.Errorf("got %d, %v, want 4, nil", n, err)
}
}
func TestSmallLitWidth(t *testing.T) {
w := NewWriter(io.Discard, LSB, 2)
if _, err := w.Write([]byte{0x03}); err != nil {
t.Fatalf("write a byte < 1<<2: %v", err)
}
if _, err := w.Write([]byte{0x04}); err == nil {
t.Fatal("write a byte >= 1<<2: got nil error, want non-nil")
}
}
func TestStartsWithClearCode(t *testing.T) {
// A literal width of 7 bits means that the code width starts at 8 bits,
// which makes it easier to visually inspect the output (provided that the
// output is short so codes don't get longer). Each byte is a code:
// - ASCII bytes are literal codes,
// - 0x80 is the clear code,
// - 0x81 is the end code.
// - 0x82 and above are copy codes (unused in this test case).
for _, empty := range []bool{false, true} {
var buf bytes.Buffer
w := NewWriter(&buf, LSB, 7)
if !empty {
w.Write([]byte("Hi"))
}
w.Close()
got := buf.String()
want := "\x80\x81"
if !empty {
want = "\x80Hi\x81"
}
if got != want {
t.Errorf("empty=%t: got %q, want %q", empty, got, want)
}
}
}
func BenchmarkEncoder(b *testing.B) {
buf, err := os.ReadFile("../testdata/e.txt")
if err != nil {
b.Fatal(err)
}
if len(buf) == 0 {
b.Fatalf("test file has no data")
}
for e := 4; e <= 6; e++ {
n := int(math.Pow10(e))
buf0 := buf
buf1 := make([]byte, n)
for i := 0; i < n; i += len(buf0) {
if len(buf0) > n-i {
buf0 = buf0[:n-i]
}
copy(buf1[i:], buf0)
}
buf0 = nil
runtime.GC()
b.Run(fmt.Sprint("1e", e), func(b *testing.B) {
b.SetBytes(int64(n))
for i := 0; i < b.N; i++ {
w := NewWriter(io.Discard, LSB, 8)
w.Write(buf1)
w.Close()
}
})
b.Run(fmt.Sprint("1e-Reuse", e), func(b *testing.B) {
b.SetBytes(int64(n))
w := NewWriter(io.Discard, LSB, 8)
for i := 0; i < b.N; i++ {
w.Write(buf1)
w.Close()
w.(*Writer).Reset(io.Discard, LSB, 8)
}
})
}
}
|
go/src/compress/lzw/writer_test.go/0
|
{
"file_path": "go/src/compress/lzw/writer_test.go",
"repo_id": "go",
"token_count": 2686
}
| 201 |
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package ring_test
import (
"container/ring"
"fmt"
)
func ExampleRing_Len() {
// Create a new ring of size 4
r := ring.New(4)
// Print out its length
fmt.Println(r.Len())
// Output:
// 4
}
func ExampleRing_Next() {
// Create a new ring of size 5
r := ring.New(5)
// Get the length of the ring
n := r.Len()
// Initialize the ring with some integer values
for i := 0; i < n; i++ {
r.Value = i
r = r.Next()
}
// Iterate through the ring and print its contents
for j := 0; j < n; j++ {
fmt.Println(r.Value)
r = r.Next()
}
// Output:
// 0
// 1
// 2
// 3
// 4
}
func ExampleRing_Prev() {
// Create a new ring of size 5
r := ring.New(5)
// Get the length of the ring
n := r.Len()
// Initialize the ring with some integer values
for i := 0; i < n; i++ {
r.Value = i
r = r.Next()
}
// Iterate through the ring backwards and print its contents
for j := 0; j < n; j++ {
r = r.Prev()
fmt.Println(r.Value)
}
// Output:
// 4
// 3
// 2
// 1
// 0
}
func ExampleRing_Do() {
// Create a new ring of size 5
r := ring.New(5)
// Get the length of the ring
n := r.Len()
// Initialize the ring with some integer values
for i := 0; i < n; i++ {
r.Value = i
r = r.Next()
}
// Iterate through the ring and print its contents
r.Do(func(p any) {
fmt.Println(p.(int))
})
// Output:
// 0
// 1
// 2
// 3
// 4
}
func ExampleRing_Move() {
// Create a new ring of size 5
r := ring.New(5)
// Get the length of the ring
n := r.Len()
// Initialize the ring with some integer values
for i := 0; i < n; i++ {
r.Value = i
r = r.Next()
}
// Move the pointer forward by three steps
r = r.Move(3)
// Iterate through the ring and print its contents
r.Do(func(p any) {
fmt.Println(p.(int))
})
// Output:
// 3
// 4
// 0
// 1
// 2
}
func ExampleRing_Link() {
// Create two rings, r and s, of size 2
r := ring.New(2)
s := ring.New(2)
// Get the length of the ring
lr := r.Len()
ls := s.Len()
// Initialize r with 0s
for i := 0; i < lr; i++ {
r.Value = 0
r = r.Next()
}
// Initialize s with 1s
for j := 0; j < ls; j++ {
s.Value = 1
s = s.Next()
}
// Link ring r and ring s
rs := r.Link(s)
// Iterate through the combined ring and print its contents
rs.Do(func(p any) {
fmt.Println(p.(int))
})
// Output:
// 0
// 0
// 1
// 1
}
func ExampleRing_Unlink() {
// Create a new ring of size 6
r := ring.New(6)
// Get the length of the ring
n := r.Len()
// Initialize the ring with some integer values
for i := 0; i < n; i++ {
r.Value = i
r = r.Next()
}
// Unlink three elements from r, starting from r.Next()
r.Unlink(3)
// Iterate through the remaining ring and print its contents
r.Do(func(p any) {
fmt.Println(p.(int))
})
// Output:
// 0
// 4
// 5
}
|
go/src/container/ring/example_test.go/0
|
{
"file_path": "go/src/container/ring/example_test.go",
"repo_id": "go",
"token_count": 1214
}
| 202 |
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This Go implementation is derived in part from the reference
// ANSI C implementation, which carries the following notice:
//
// rijndael-alg-fst.c
//
// @version 3.0 (December 2000)
//
// Optimised ANSI C code for the Rijndael cipher (now AES)
//
// @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be>
// @author Antoon Bosselaers <antoon.bosselaers@esat.kuleuven.ac.be>
// @author Paulo Barreto <paulo.barreto@terra.com.br>
//
// This code is hereby placed in the public domain.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// See FIPS 197 for specification, and see Daemen and Rijmen's Rijndael submission
// for implementation details.
// https://csrc.nist.gov/csrc/media/publications/fips/197/final/documents/fips-197.pdf
// https://csrc.nist.gov/archive/aes/rijndael/Rijndael-ammended.pdf
package aes
import "internal/byteorder"
// Encrypt one block from src into dst, using the expanded key xk.
func encryptBlockGo(xk []uint32, dst, src []byte) {
_ = src[15] // early bounds check
s0 := byteorder.BeUint32(src[0:4])
s1 := byteorder.BeUint32(src[4:8])
s2 := byteorder.BeUint32(src[8:12])
s3 := byteorder.BeUint32(src[12:16])
// First round just XORs input with key.
s0 ^= xk[0]
s1 ^= xk[1]
s2 ^= xk[2]
s3 ^= xk[3]
// Middle rounds shuffle using tables.
// Number of rounds is set by length of expanded key.
nr := len(xk)/4 - 2 // - 2: one above, one more below
k := 4
var t0, t1, t2, t3 uint32
for r := 0; r < nr; r++ {
t0 = xk[k+0] ^ te0[uint8(s0>>24)] ^ te1[uint8(s1>>16)] ^ te2[uint8(s2>>8)] ^ te3[uint8(s3)]
t1 = xk[k+1] ^ te0[uint8(s1>>24)] ^ te1[uint8(s2>>16)] ^ te2[uint8(s3>>8)] ^ te3[uint8(s0)]
t2 = xk[k+2] ^ te0[uint8(s2>>24)] ^ te1[uint8(s3>>16)] ^ te2[uint8(s0>>8)] ^ te3[uint8(s1)]
t3 = xk[k+3] ^ te0[uint8(s3>>24)] ^ te1[uint8(s0>>16)] ^ te2[uint8(s1>>8)] ^ te3[uint8(s2)]
k += 4
s0, s1, s2, s3 = t0, t1, t2, t3
}
// Last round uses s-box directly and XORs to produce output.
s0 = uint32(sbox0[t0>>24])<<24 | uint32(sbox0[t1>>16&0xff])<<16 | uint32(sbox0[t2>>8&0xff])<<8 | uint32(sbox0[t3&0xff])
s1 = uint32(sbox0[t1>>24])<<24 | uint32(sbox0[t2>>16&0xff])<<16 | uint32(sbox0[t3>>8&0xff])<<8 | uint32(sbox0[t0&0xff])
s2 = uint32(sbox0[t2>>24])<<24 | uint32(sbox0[t3>>16&0xff])<<16 | uint32(sbox0[t0>>8&0xff])<<8 | uint32(sbox0[t1&0xff])
s3 = uint32(sbox0[t3>>24])<<24 | uint32(sbox0[t0>>16&0xff])<<16 | uint32(sbox0[t1>>8&0xff])<<8 | uint32(sbox0[t2&0xff])
s0 ^= xk[k+0]
s1 ^= xk[k+1]
s2 ^= xk[k+2]
s3 ^= xk[k+3]
_ = dst[15] // early bounds check
byteorder.BePutUint32(dst[0:4], s0)
byteorder.BePutUint32(dst[4:8], s1)
byteorder.BePutUint32(dst[8:12], s2)
byteorder.BePutUint32(dst[12:16], s3)
}
// Decrypt one block from src into dst, using the expanded key xk.
func decryptBlockGo(xk []uint32, dst, src []byte) {
_ = src[15] // early bounds check
s0 := byteorder.BeUint32(src[0:4])
s1 := byteorder.BeUint32(src[4:8])
s2 := byteorder.BeUint32(src[8:12])
s3 := byteorder.BeUint32(src[12:16])
// First round just XORs input with key.
s0 ^= xk[0]
s1 ^= xk[1]
s2 ^= xk[2]
s3 ^= xk[3]
// Middle rounds shuffle using tables.
// Number of rounds is set by length of expanded key.
nr := len(xk)/4 - 2 // - 2: one above, one more below
k := 4
var t0, t1, t2, t3 uint32
for r := 0; r < nr; r++ {
t0 = xk[k+0] ^ td0[uint8(s0>>24)] ^ td1[uint8(s3>>16)] ^ td2[uint8(s2>>8)] ^ td3[uint8(s1)]
t1 = xk[k+1] ^ td0[uint8(s1>>24)] ^ td1[uint8(s0>>16)] ^ td2[uint8(s3>>8)] ^ td3[uint8(s2)]
t2 = xk[k+2] ^ td0[uint8(s2>>24)] ^ td1[uint8(s1>>16)] ^ td2[uint8(s0>>8)] ^ td3[uint8(s3)]
t3 = xk[k+3] ^ td0[uint8(s3>>24)] ^ td1[uint8(s2>>16)] ^ td2[uint8(s1>>8)] ^ td3[uint8(s0)]
k += 4
s0, s1, s2, s3 = t0, t1, t2, t3
}
// Last round uses s-box directly and XORs to produce output.
s0 = uint32(sbox1[t0>>24])<<24 | uint32(sbox1[t3>>16&0xff])<<16 | uint32(sbox1[t2>>8&0xff])<<8 | uint32(sbox1[t1&0xff])
s1 = uint32(sbox1[t1>>24])<<24 | uint32(sbox1[t0>>16&0xff])<<16 | uint32(sbox1[t3>>8&0xff])<<8 | uint32(sbox1[t2&0xff])
s2 = uint32(sbox1[t2>>24])<<24 | uint32(sbox1[t1>>16&0xff])<<16 | uint32(sbox1[t0>>8&0xff])<<8 | uint32(sbox1[t3&0xff])
s3 = uint32(sbox1[t3>>24])<<24 | uint32(sbox1[t2>>16&0xff])<<16 | uint32(sbox1[t1>>8&0xff])<<8 | uint32(sbox1[t0&0xff])
s0 ^= xk[k+0]
s1 ^= xk[k+1]
s2 ^= xk[k+2]
s3 ^= xk[k+3]
_ = dst[15] // early bounds check
byteorder.BePutUint32(dst[0:4], s0)
byteorder.BePutUint32(dst[4:8], s1)
byteorder.BePutUint32(dst[8:12], s2)
byteorder.BePutUint32(dst[12:16], s3)
}
// Apply sbox0 to each byte in w.
func subw(w uint32) uint32 {
return uint32(sbox0[w>>24])<<24 |
uint32(sbox0[w>>16&0xff])<<16 |
uint32(sbox0[w>>8&0xff])<<8 |
uint32(sbox0[w&0xff])
}
// Rotate
func rotw(w uint32) uint32 { return w<<8 | w>>24 }
// Key expansion algorithm. See FIPS-197, Figure 11.
// Their rcon[i] is our powx[i-1] << 24.
func expandKeyGo(key []byte, enc, dec []uint32) {
// Encryption key setup.
var i int
nk := len(key) / 4
for i = 0; i < nk; i++ {
enc[i] = byteorder.BeUint32(key[4*i:])
}
for ; i < len(enc); i++ {
t := enc[i-1]
if i%nk == 0 {
t = subw(rotw(t)) ^ (uint32(powx[i/nk-1]) << 24)
} else if nk > 6 && i%nk == 4 {
t = subw(t)
}
enc[i] = enc[i-nk] ^ t
}
// Derive decryption key from encryption key.
// Reverse the 4-word round key sets from enc to produce dec.
// All sets but the first and last get the MixColumn transform applied.
if dec == nil {
return
}
n := len(enc)
for i := 0; i < n; i += 4 {
ei := n - i - 4
for j := 0; j < 4; j++ {
x := enc[ei+j]
if i > 0 && i+4 < n {
x = td0[sbox0[x>>24]] ^ td1[sbox0[x>>16&0xff]] ^ td2[sbox0[x>>8&0xff]] ^ td3[sbox0[x&0xff]]
}
dec[i+j] = x
}
}
}
|
go/src/crypto/aes/block.go/0
|
{
"file_path": "go/src/crypto/aes/block.go",
"repo_id": "go",
"token_count": 3138
}
| 203 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.