deps: bump to go-criu v8.3.0

go-criu v8.3.0 switches to protobuf-go-lite, which helps to remove
google.golang.org/protobuf dependency from here, reducing the runc
binary size from ~16M to ~14M.

The only missing piece is proto.String, proto.Bool, proto.Int32 etc.
helpers that return a pointer to a given variable. Those are replaced
by a generic mkPtr, which in turn is to be replaced by the new builtin
once Go < 1.26 is no longer supported.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit f66ace4cfa)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2026-06-03 18:20:59 -07:00
parent 750317a2f7
commit cc3c5c1655
230 changed files with 15226 additions and 37363 deletions
+3 -3
View File
@@ -3,7 +3,7 @@ module github.com/opencontainers/runc
go 1.25.0
require (
github.com/checkpoint-restore/go-criu/v8 v8.2.0
github.com/checkpoint-restore/go-criu/v8 v8.3.0
github.com/containerd/console v1.0.5
github.com/coreos/go-systemd/v22 v22.7.0
github.com/cyphar/filepath-securejoin v0.6.1
@@ -24,12 +24,12 @@ require (
github.com/vishvananda/netlink v1.3.1
github.com/vishvananda/netns v0.0.5
golang.org/x/net v0.50.0
golang.org/x/sys v0.41.0
google.golang.org/protobuf v1.36.11
golang.org/x/sys v0.46.0
)
require (
cyphar.com/go-pathrs v0.2.4 // indirect
github.com/aperturerobotics/protobuf-go-lite v0.14.0 // indirect
github.com/cilium/ebpf v0.17.3 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
+6 -6
View File
@@ -1,8 +1,10 @@
cyphar.com/go-pathrs v0.2.4 h1:iD/mge36swa1UFKdINkr1Frkpp6wZsy3YYEildj9cLY=
cyphar.com/go-pathrs v0.2.4/go.mod h1:y8f1EMG7r+hCuFf/rXsKqMJrJAUoADZGNh5/vZPKcGc=
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/checkpoint-restore/go-criu/v8 v8.2.0 h1:dsgMgj/eJtZNKn3qn/+Ri0b4bd0uo6o2zt1yd8Nj2NI=
github.com/checkpoint-restore/go-criu/v8 v8.2.0/go.mod h1:HVKJ1dK+bowJcFI1MtdL2ECIuY+/AtRMHzD9Lqa4uA4=
github.com/aperturerobotics/protobuf-go-lite v0.14.0 h1:6YhovtoUZtXgXLHZ2VV2GCYUzFfi8UN6172Vl2flNlE=
github.com/aperturerobotics/protobuf-go-lite v0.14.0/go.mod h1:lGH3s5ArCTXKI4wJdlNpaybUtwSjfAG0vdWjxOfMcF8=
github.com/checkpoint-restore/go-criu/v8 v8.3.0 h1:UC3Ioay1OMN2Wg33U53enRoG2701vJ9Y2Ex4APmC52w=
github.com/checkpoint-restore/go-criu/v8 v8.3.0/go.mod h1:33d6FwGJGwnzKVvaO0SxlN0tPSuArKU9X/inD/L7/qA=
github.com/cilium/ebpf v0.17.3 h1:FnP4r16PWYSE4ux6zN+//jMcW4nMVRvuTLVTvCjyyjg=
github.com/cilium/ebpf v0.17.3/go.mod h1:G5EDHij8yiLzaqn0WjyfJHvRa+3aDlReIaLVRMvOyJk=
github.com/containerd/console v1.0.5 h1:R0ymNeydRqH2DmakFNdmjR2k0t7UPuiOV/N/27/qqsc=
@@ -87,10 +89,8 @@ golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k=
golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw=
golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+73 -71
View File
@@ -22,7 +22,6 @@ import (
securejoin "github.com/cyphar/filepath-securejoin"
"github.com/sirupsen/logrus"
"golang.org/x/sys/unix"
"google.golang.org/protobuf/proto"
"github.com/opencontainers/cgroups"
"github.com/opencontainers/runc/internal/cmsg"
@@ -110,14 +109,17 @@ func (c *Container) checkCriuVersion(minVersion int) error {
const descriptorsFilename = "descriptors.json"
// TODO: replace with new(v) once Go < 1.26 is not supported.
func mkPtr[T any](v T) *T { return &v }
func (c *Container) addCriuDumpMount(req *criurpc.CriuReq, m *configs.Mount) {
mountDest := strings.TrimPrefix(m.Destination, c.config.Rootfs)
if dest, err := securejoin.SecureJoin(c.config.Rootfs, mountDest); err == nil {
mountDest = dest[len(c.config.Rootfs):]
}
extMnt := &criurpc.ExtMountMap{
Key: proto.String(mountDest),
Val: proto.String(mountDest),
Key: mkPtr(mountDest),
Val: mkPtr(mountDest),
}
req.Opts.ExtMnt = append(req.Opts.ExtMnt, extMnt)
}
@@ -136,8 +138,8 @@ func (c *Container) addMaskPaths(req *criurpc.CriuReq) error {
}
extMnt := &criurpc.ExtMountMap{
Key: proto.String(path),
Val: proto.String("/dev/null"),
Key: mkPtr(path),
Val: mkPtr("/dev/null"),
}
req.Opts.ExtMnt = append(req.Opts.ExtMnt, extMnt)
}
@@ -157,7 +159,7 @@ func (c *Container) handleCriuConfigurationFile(rpcOpts *criurpc.CriuOpts) {
// configuration file. If the file does not exist, CRIU
// will just ignore it.
if configFile != "" {
rpcOpts.ConfigFile = proto.String(configFile)
rpcOpts.ConfigFile = mkPtr(configFile)
}
// If 'org.criu.config' exists and is set to an empty
// string, a runc specific CRIU configuration file will
@@ -165,7 +167,7 @@ func (c *Container) handleCriuConfigurationFile(rpcOpts *criurpc.CriuOpts) {
} else {
// If the mentioned annotation has not been found, specify
// a default CRIU configuration file.
rpcOpts.ConfigFile = proto.String("/etc/criu/runc.conf")
rpcOpts.ConfigFile = mkPtr("/etc/criu/runc.conf")
}
}
@@ -252,8 +254,8 @@ func (c *Container) handleRestoringNamespaces(rpcOpts *criurpc.CriuOpts, extraFi
// CRIU will issue a warning for NEWUSER:
// criu/namespaces.c: 'join-ns with user-namespace is not fully tested and dangerous'
rpcOpts.JoinNs = append(rpcOpts.JoinNs, &criurpc.JoinNamespace{
Ns: proto.String(configs.NsName(ns.Type)),
NsFile: proto.String(nsPath),
Ns: mkPtr(configs.NsName(ns.Type)),
NsFile: mkPtr(nsPath),
})
}
}
@@ -280,10 +282,10 @@ func (c *Container) handleRestoringExternalNamespaces(rpcOpts *criurpc.CriuOpts,
return fmt.Errorf("Requested network namespace %v does not exist", nsPath)
}
inheritFd := &criurpc.InheritFd{
Key: proto.String(criuNsToKey(t)),
Key: mkPtr(criuNsToKey(t)),
// The offset of four is necessary because 0, 1, 2 and 3 are
// already used by stdin, stdout, stderr, 'criu swrk' socket.
Fd: proto.Int32(int32(4 + len(*extraFiles))),
Fd: mkPtr(int32(4 + len(*extraFiles))),
}
rpcOpts.InheritFd = append(rpcOpts.InheritFd, inheritFd)
// All open FDs need to be transferred to CRIU via extraFiles
@@ -331,25 +333,25 @@ func (c *Container) Checkpoint(criuOpts *CriuOpts) error {
defer imageDir.Close()
rpcOpts := criurpc.CriuOpts{
ImagesDirFd: proto.Int32(int32(imageDir.Fd())),
LogLevel: proto.Int32(4),
LogFile: proto.String(logFile),
Root: proto.String(c.config.Rootfs),
ManageCgroups: proto.Bool(true), // Obsoleted by ManageCgroupsMode.
ImagesDirFd: mkPtr(int32(imageDir.Fd())),
LogLevel: mkPtr(int32(4)),
LogFile: mkPtr(logFile),
Root: mkPtr(c.config.Rootfs),
ManageCgroups: mkPtr(true), // Obsoleted by ManageCgroupsMode.
ManageCgroupsMode: &cgMode,
NotifyScripts: proto.Bool(true),
Pid: proto.Int32(int32(c.initProcess.pid())),
ShellJob: proto.Bool(criuOpts.ShellJob),
LeaveRunning: proto.Bool(criuOpts.LeaveRunning),
TcpEstablished: proto.Bool(criuOpts.TcpEstablished),
TcpSkipInFlight: proto.Bool(criuOpts.TcpSkipInFlight),
LinkRemap: proto.Bool(criuOpts.LinkRemap),
ExtUnixSk: proto.Bool(criuOpts.ExternalUnixConnections),
FileLocks: proto.Bool(criuOpts.FileLocks),
EmptyNs: proto.Uint32(criuOpts.EmptyNs),
OrphanPtsMaster: proto.Bool(true),
AutoDedup: proto.Bool(criuOpts.AutoDedup),
LazyPages: proto.Bool(criuOpts.LazyPages),
NotifyScripts: mkPtr(true),
Pid: mkPtr(int32(c.initProcess.pid())),
ShellJob: mkPtr(criuOpts.ShellJob),
LeaveRunning: mkPtr(criuOpts.LeaveRunning),
TcpEstablished: mkPtr(criuOpts.TcpEstablished),
TcpSkipInFlight: mkPtr(criuOpts.TcpSkipInFlight),
LinkRemap: mkPtr(criuOpts.LinkRemap),
ExtUnixSk: mkPtr(criuOpts.ExternalUnixConnections),
FileLocks: mkPtr(criuOpts.FileLocks),
EmptyNs: mkPtr(criuOpts.EmptyNs),
OrphanPtsMaster: mkPtr(true),
AutoDedup: mkPtr(criuOpts.AutoDedup),
LazyPages: mkPtr(criuOpts.LazyPages),
}
// if criuOpts.WorkDirectory is not set, criu default is used.
@@ -362,7 +364,7 @@ func (c *Container) Checkpoint(criuOpts *CriuOpts) error {
return err
}
defer workDir.Close()
rpcOpts.WorkDirFd = proto.Int32(int32(workDir.Fd()))
rpcOpts.WorkDirFd = mkPtr(int32(workDir.Fd()))
logDir = criuOpts.WorkDirectory
}
@@ -388,28 +390,28 @@ func (c *Container) Checkpoint(criuOpts *CriuOpts) error {
// Note cgroup v2 freezer is only supported since CRIU release 3.14.
if !cgroups.IsCgroup2UnifiedMode() || c.checkCriuVersion(31400) == nil {
if fcg := c.cgroupManager.Path("freezer"); fcg != "" {
rpcOpts.FreezeCgroup = proto.String(fcg)
rpcOpts.FreezeCgroup = mkPtr(fcg)
}
}
// append optional criu opts, e.g., page-server and port
if criuOpts.PageServer.Address != "" && criuOpts.PageServer.Port != 0 {
rpcOpts.Ps = &criurpc.CriuPageServerInfo{
Address: proto.String(criuOpts.PageServer.Address),
Port: proto.Int32(criuOpts.PageServer.Port),
Address: mkPtr(criuOpts.PageServer.Address),
Port: mkPtr(criuOpts.PageServer.Port),
}
}
// pre-dump may need parentImage param to complete iterative migration
if criuOpts.ParentImage != "" {
rpcOpts.ParentImg = proto.String(criuOpts.ParentImage)
rpcOpts.TrackMem = proto.Bool(true)
rpcOpts.ParentImg = mkPtr(criuOpts.ParentImage)
rpcOpts.TrackMem = mkPtr(true)
}
var t criurpc.CriuReqType
if criuOpts.PreDump {
feat := criurpc.CriuFeatures{
MemTrack: proto.Bool(true),
MemTrack: mkPtr(true),
}
if err := c.checkCriuFeatures(criuOpts, &feat); err != nil {
@@ -424,7 +426,7 @@ func (c *Container) Checkpoint(criuOpts *CriuOpts) error {
if criuOpts.LazyPages {
// lazy migration requested; check if criu supports it
feat := criurpc.CriuFeatures{
LazyPages: proto.Bool(true),
LazyPages: mkPtr(true),
}
if err := c.checkCriuFeatures(criuOpts, &feat); err != nil {
return err
@@ -444,7 +446,7 @@ func (c *Container) Checkpoint(criuOpts *CriuOpts) error {
if c.checkCriuVersion(31500) != nil {
// For criu 3.15+, use notifications (see case "status-ready"
// in criuNotifications). Otherwise, rely on criu status fd.
rpcOpts.StatusFd = proto.Int32(int32(fd))
rpcOpts.StatusFd = mkPtr(int32(fd))
}
}
}
@@ -512,8 +514,8 @@ func (c *Container) addCriuRestoreMount(req *criurpc.CriuReq, m *configs.Mount)
mountDest = dest[len(c.config.Rootfs):]
}
extMnt := &criurpc.ExtMountMap{
Key: proto.String(mountDest),
Val: proto.String(m.Source),
Key: mkPtr(mountDest),
Val: mkPtr(m.Source),
}
req.Opts.ExtMnt = append(req.Opts.ExtMnt, extMnt)
}
@@ -523,8 +525,8 @@ func (c *Container) restoreNetwork(req *criurpc.CriuReq, criuOpts *CriuOpts) {
switch iface.Type {
case "veth":
veth := new(criurpc.CriuVethPair)
veth.IfOut = proto.String(iface.HostInterfaceName)
veth.IfIn = proto.String(iface.Name)
veth.IfOut = mkPtr(iface.HostInterfaceName)
veth.IfIn = mkPtr(iface.Name)
req.Opts.Veths = append(req.Opts.Veths, veth)
case "loopback":
// Do nothing
@@ -532,8 +534,8 @@ func (c *Container) restoreNetwork(req *criurpc.CriuReq, criuOpts *CriuOpts) {
}
for _, i := range criuOpts.VethPairs {
veth := new(criurpc.CriuVethPair)
veth.IfOut = proto.String(i.HostInterfaceName)
veth.IfIn = proto.String(i.ContainerInterfaceName)
veth.IfOut = mkPtr(i.HostInterfaceName)
veth.IfIn = mkPtr(i.ContainerInterfaceName)
req.Opts.Veths = append(req.Opts.Veths, veth)
}
}
@@ -687,23 +689,23 @@ func (c *Container) Restore(process *Process, criuOpts *CriuOpts) error {
req := &criurpc.CriuReq{
Type: &t,
Opts: &criurpc.CriuOpts{
ImagesDirFd: proto.Int32(int32(imageDir.Fd())),
EvasiveDevices: proto.Bool(true),
LogLevel: proto.Int32(4),
LogFile: proto.String(logFile),
RstSibling: proto.Bool(true),
Root: proto.String(root),
ManageCgroups: proto.Bool(true), // Obsoleted by ManageCgroupsMode.
ImagesDirFd: mkPtr(int32(imageDir.Fd())),
EvasiveDevices: mkPtr(true),
LogLevel: mkPtr(int32(4)),
LogFile: mkPtr(logFile),
RstSibling: mkPtr(true),
Root: mkPtr(root),
ManageCgroups: mkPtr(true), // Obsoleted by ManageCgroupsMode.
ManageCgroupsMode: &cgMode,
NotifyScripts: proto.Bool(true),
ShellJob: proto.Bool(criuOpts.ShellJob),
ExtUnixSk: proto.Bool(criuOpts.ExternalUnixConnections),
TcpEstablished: proto.Bool(criuOpts.TcpEstablished),
FileLocks: proto.Bool(criuOpts.FileLocks),
EmptyNs: proto.Uint32(criuOpts.EmptyNs),
OrphanPtsMaster: proto.Bool(true),
AutoDedup: proto.Bool(criuOpts.AutoDedup),
LazyPages: proto.Bool(criuOpts.LazyPages),
NotifyScripts: mkPtr(true),
ShellJob: mkPtr(criuOpts.ShellJob),
ExtUnixSk: mkPtr(criuOpts.ExternalUnixConnections),
TcpEstablished: mkPtr(criuOpts.TcpEstablished),
FileLocks: mkPtr(criuOpts.FileLocks),
EmptyNs: mkPtr(criuOpts.EmptyNs),
OrphanPtsMaster: mkPtr(true),
AutoDedup: mkPtr(criuOpts.AutoDedup),
LazyPages: mkPtr(criuOpts.LazyPages),
},
}
@@ -713,13 +715,13 @@ func (c *Container) Restore(process *Process, criuOpts *CriuOpts) error {
if err := c.checkCriuVersion(31600); err != nil {
return errors.New("--lsm-profile requires at least CRIU 3.16")
}
req.Opts.LsmProfile = proto.String(criuOpts.LsmProfile)
req.Opts.LsmProfile = mkPtr(criuOpts.LsmProfile)
}
if criuOpts.LsmMountContext != "" {
if err := c.checkCriuVersion(31600); err != nil {
return errors.New("--lsm-mount-context requires at least CRIU 3.16")
}
req.Opts.LsmMountContext = proto.String(criuOpts.LsmMountContext)
req.Opts.LsmMountContext = mkPtr(criuOpts.LsmMountContext)
}
if criuOpts.WorkDirectory != "" {
@@ -733,7 +735,7 @@ func (c *Container) Restore(process *Process, criuOpts *CriuOpts) error {
return err
}
defer workDir.Close()
req.Opts.WorkDirFd = proto.Int32(int32(workDir.Fd()))
req.Opts.WorkDirFd = mkPtr(int32(workDir.Fd()))
logDir = criuOpts.WorkDirectory
}
c.handleCriuConfigurationFile(req.Opts)
@@ -796,8 +798,8 @@ func (c *Container) Restore(process *Process, criuOpts *CriuOpts) error {
for i := range fds {
if s := fds[i]; strings.Contains(s, "pipe:") {
inheritFd := new(criurpc.InheritFd)
inheritFd.Key = proto.String(s)
inheritFd.Fd = proto.Int32(int32(i))
inheritFd.Key = mkPtr(s)
inheritFd.Fd = mkPtr(int32(i))
req.Opts.InheritFd = append(req.Opts.InheritFd, inheritFd)
}
}
@@ -889,8 +891,8 @@ func (c *Container) criuApplyCgroups(pid int, req *criurpc.CriuReq) error {
for c, p := range cgroupsPaths {
cgroupRoot := &criurpc.CgroupRoot{
Ctrl: proto.String(c),
Path: proto.String(p),
Ctrl: mkPtr(c),
Path: mkPtr(p),
}
req.Opts.CgRoot = append(req.Opts.CgRoot, cgroupRoot)
}
@@ -984,7 +986,7 @@ func (c *Container) criuSwrk(process *Process, req *criurpc.CriuReq, opts *CriuO
}
}
}
data, err := proto.Marshal(req)
data, err := req.MarshalVT()
if err != nil {
return err
}
@@ -1017,7 +1019,7 @@ func (c *Container) criuSwrk(process *Process, req *criurpc.CriuReq, opts *CriuO
}
resp := new(criurpc.CriuResp)
err = proto.Unmarshal(buf[:n], resp)
err = resp.UnmarshalVT(buf[:n])
if err != nil {
return err
}
@@ -1036,9 +1038,9 @@ func (c *Container) criuSwrk(process *Process, req *criurpc.CriuReq, opts *CriuO
}
req = &criurpc.CriuReq{
Type: &t,
NotifySuccess: proto.Bool(true),
NotifySuccess: mkPtr(true),
}
data, err = proto.Marshal(req)
data, err = req.MarshalVT()
if err != nil {
return err
}
+1
View File
@@ -17,6 +17,7 @@ import (
"github.com/urfave/cli"
)
// TODO: replace with new(v) once Go < 1.26 is not supported.
func mkPtr[T any](v T) *T { return &v }
var updateCommand = cli.Command{
@@ -0,0 +1 @@
*.pb.* linguist-generated
@@ -0,0 +1,8 @@
/.cache/
/.gocache/
/bin/
/vendor/
.#*
.aider*
debug.test*
/node_modules
+69
View File
@@ -0,0 +1,69 @@
linters:
enable:
- depguard
- goimports
- gosec
- gosimple
- govet
- importas
- ineffassign
- misspell
- revive
- staticcheck
- typecheck
- unconvert
- unused
disable:
- errcheck
run:
concurrency: 4
modules-download-mode: vendor
skip-dirs:
- hack
linters-settings:
staticcheck:
checks:
- all
- '-SA1012' # Allow passing nil contexts.
- '-SA1019' # Allow calling deprecated symbols.
importas:
# Do not allow unaliased imports of aliased packages.
no-unaliased: true
maligned:
suggest-new: true
depguard:
rules:
main:
deny:
- pkg: io/ioutil
desc: The io/ioutil package has been deprecated, see https://go.dev/doc/go1.16#ioutil
#- pkg: "github.com/stretchr/testify/assert"
# desc: Use "gotest.tools/v3/assert" instead
#- pkg: "github.com/stretchr/testify/require"
# desc: Use "gotest.tools/v3/assert" instead
- pkg: "github.com/stretchr/testify/suite"
desc: Do not use
revive:
rules:
- name: package-comments
disabled: true
issues:
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
max-issues-per-linter: 0
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
max-same-issues: 0
exclude:
- G601
- G306
- G204
+5
View File
@@ -0,0 +1,5 @@
*.pb.go
*.pb.ts
go.sum
testdata
thirdparty
@@ -1,3 +1,7 @@
Copyright (c) 2024-2025 Aperture Robotics, LLC. All rights reserved.
Copyright (c) 2024-2025 Christian Stewart <christian@aperture.us>. All rights reserved.
Copyright (c) 2021, PlanetScale Inc. All rights reserved.
Copyright (c) 2013, The GoGo Authors. All rights reserved.
Copyright (c) 2018 The Go Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -24,4 +28,4 @@ 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.
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+112
View File
@@ -0,0 +1,112 @@
SHELL:=bash
PROTOWRAP=hack/bin/protowrap
GOIMPORTS=hack/bin/goimports
GOFUMPT=hack/bin/gofumpt
GOLANGCI_LINT=hack/bin/golangci-lint
PROTOC_GEN_GO=hack/bin/protoc-gen-go-lite
GOLIST=go list -f "{{ .Dir }}" -m
export GO111MODULE=on
undefine GOOS
undefine GOARCH
all:
vendor:
go mod vendor
$(GOIMPORTS):
cd ./hack; \
go build -v \
-o ./bin/goimports \
golang.org/x/tools/cmd/goimports
$(GOFUMPT):
cd ./hack; \
go build -v \
-o ./bin/gofumpt \
mvdan.cc/gofumpt
$(PROTOWRAP):
cd ./hack; \
go build -v \
-o ./bin/protowrap \
github.com/aperturerobotics/goprotowrap/cmd/protowrap
$(GOLANGCI_LINT):
cd ./hack; \
go build -v \
-o ./bin/golangci-lint \
github.com/golangci/golangci-lint/cmd/golangci-lint
$(PROTOC_GEN_GO):
cd ./hack; \
go build -v \
-o ./bin/protoc-gen-go-lite \
github.com/aperturerobotics/protobuf-go-lite/cmd/protoc-gen-go-lite
.PHONY: protoc-gen-go-lite-tool
protoc-gen-go-lite-tool:
cd ./hack; \
go build -v \
-o ./bin/protoc-gen-go-lite \
github.com/aperturerobotics/protobuf-go-lite/cmd/protoc-gen-go-lite
.PHONY: build
build: vendor
go build -v
.PHONY: lint
lint: $(GOLANGCI_LINT)
$(GOLANGCI_LINT) run --timeout=10m
.PHONY: fix
fix: $(GOLANGCI_LINT)
$(GOLANGCI_LINT) run --fix --timeout=10m
.PHONY: format
format: $(GOFUMPT) $(GOIMPORTS)
$(GOIMPORTS) -w ./
$(GOFUMPT) -w ./
.PHONY: test
test:
go test -v ./...
.PHONY: gengo
gengo: $(GOIMPORTS) $(PROTOWRAP) protoc-gen-go-lite-tool
shopt -s globstar; \
set -eo pipefail; \
export PROJECT=$$(go list -m); \
export PATH=$$(pwd)/hack/bin:$${PATH}; \
mkdir -p $$(pwd)/vendor/$$(dirname $${PROJECT}); \
rm $$(pwd)/vendor/$${PROJECT} || true; \
ln -s $$(pwd) $$(pwd)/vendor/$${PROJECT} ; \
protogen() { \
$(PROTOWRAP) \
-I $$(pwd)/vendor \
-I $$(pwd) \
--go-lite_out=$$(pwd)/vendor \
--proto_path $$(pwd)/vendor \
--print_structure \
--only_specified_files \
$$2 \
$$(\
git \
ls-files "$$1" |\
xargs printf -- \
"$$(pwd)/vendor/$${PROJECT}/%s "); \
}; \
for d in ./types/known/*; do \
protogen "$${d}/*.proto" "--go-lite_opt=features=marshal+marshal_strict+unmarshal+unmarshal_unsafe+size+equal+clone+text"; \
done; \
protogen "./types/descriptorpb/*.proto" ""; \
protogen "./types/pluginpb/*.proto" ""; \
protogen "./testproto/*.proto" ""; \
rm $$(pwd)/vendor/$${PROJECT} || true
$(GOIMPORTS) -w ./
.PHONY: check-gengo
check-gengo: gengo
git diff --exit-code HEAD
test -z "$$(git ls-files --others --exclude-standard)" || (git ls-files --others --exclude-standard; exit 1)
+157
View File
@@ -0,0 +1,157 @@
# protobuf-go-lite
[![GoDoc Widget]][GoDoc] [![Go Report Card Widget]][Go Report Card] [![DeepWiki Widget]][DeepWiki]
[GoDoc]: https://godoc.org/github.com/aperturerobotics/protobuf-go-lite
[GoDoc Widget]: https://godoc.org/github.com/aperturerobotics/protobuf-go-lite?status.svg
[Go Report Card Widget]: https://goreportcard.com/badge/github.com/aperturerobotics/protobuf-go-lite
[Go Report Card]: https://goreportcard.com/report/github.com/aperturerobotics/protobuf-go-lite
[DeepWiki Widget]: https://img.shields.io/badge/DeepWiki-aperturerobotics%2Fprotobuf--go--lite-blue.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAAyCAYAAAAnWDnqAAAAAXNSR0IArs4c6QAAA05JREFUaEPtmUtyEzEQhtWTQyQLHNak2AB7ZnyXZMEjXMGeK/AIi+QuHrMnbChYY7MIh8g01fJoopFb0uhhEqqcbWTp06/uv1saEDv4O3n3dV60RfP947Mm9/SQc0ICFQgzfc4CYZoTPAswgSJCCUJUnAAoRHOAUOcATwbmVLWdGoH//PB8mnKqScAhsD0kYP3j/Yt5LPQe2KvcXmGvRHcDnpxfL2zOYJ1mFwrryWTz0advv1Ut4CJgf5uhDuDj5eUcAUoahrdY/56ebRWeraTjMt/00Sh3UDtjgHtQNHwcRGOC98BJEAEymycmYcWwOprTgcB6VZ5JK5TAJ+fXGLBm3FDAmn6oPPjR4rKCAoJCal2eAiQp2x0vxTPB3ALO2CRkwmDy5WohzBDwSEFKRwPbknEggCPB/imwrycgxX2NzoMCHhPkDwqYMr9tRcP5qNrMZHkVnOjRMWwLCcr8ohBVb1OMjxLwGCvjTikrsBOiA6fNyCrm8V1rP93iVPpwaE+gO0SsWmPiXB+jikdf6SizrT5qKasx5j8ABbHpFTx+vFXp9EnYQmLx02h1QTTrl6eDqxLnGjporxl3NL3agEvXdT0WmEost648sQOYAeJS9Q7bfUVoMGnjo4AZdUMQku50McDcMWcBPvr0SzbTAFDfvJqwLzgxwATnCgnp4wDl6Aa+Ax283gghmj+vj7feE2KBBRMW3FzOpLOADl0Isb5587h/U4gGvkt5v60Z1VLG8BhYjbzRwyQZemwAd6cCR5/XFWLYZRIMpX39AR0tjaGGiGzLVyhse5C9RKC6ai42ppWPKiBagOvaYk8lO7DajerabOZP46Lby5wKjw1HCRx7p9sVMOWGzb/vA1hwiWc6jm3MvQDTogQkiqIhJV0nBQBTU+3okKCFDy9WwferkHjtxib7t3xIUQtHxnIwtx4mpg26/HfwVNVDb4oI9RHmx5WGelRVlrtiw43zboCLaxv46AZeB3IlTkwouebTr1y2NjSpHz68WNFjHvupy3q8TFn3Hos2IAk4Ju5dCo8B3wP7VPr/FGaKiG+T+v+TQqIrOqMTL1VdWV1DdmcbO8KXBz6esmYWYKPwDL5b5FA1a0hwapHiom0r/cKaoqr+27/XcrS5UwSMbQAAAABJRU5ErkJggg==
[DeepWiki]: https://deepwiki.com/aperturerobotics/protobuf-go-lite
**protobuf-go-lite** is a stripped-down version of the [protobuf-go] code
generator modified to work without reflection and merged with [vtprotobuf] to
provide modular features with static code generation for marshal/unmarshal,
size, clone, and equal. It bundles a fork of [protoc-gen-go-json] for JSON.
[protobuf-go]: https://github.com/protocolbuffers/protobuf-go
[vtprotobuf]: https://github.com/planetscale/vtprotobuf
[protoc-gen-go-json]: https://github.com/TheThingsIndustries/protoc-gen-go-json
Static code generation without reflection is more efficient at runtime and
results in smaller code binaries. It also provides better support for [tinygo]
which has limited reflection support.
[tinygo]: https://github.com/tinygo-org/tinygo
protobuf-go-lite supports Edition 2024 schemas that resolve to the open Go API
and static, reflect-free generated output. The default `features=all` path
supports explicit and implicit presence, legacy required fields, packed
encoding, delimited message encoding, oneofs, maps, clone/equal, text,
unmarshal, unsafe unmarshal, and JSON when the resolved JSON format is
`ALLOW`.
protobuf-go-lite rejects Edition schemas that require closed enum semantics,
`LEGACY_BEST_EFFORT` JSON, or explicit hybrid/opaque Go APIs. It does not
support fieldmasks and extensions.
### Ecosystem
Lightweight Protobuf 3 RPCs are implemented in [StaRPC] for Go and TypeScript.
[StaRPC]: https://github.com/aperturerobotics/starpc
[protoc-gen-doc] is recommended for generating documentation.
[protoc-gen-doc]: https://github.com/pseudomuto/protoc-gen-doc
[protobuf-es-lite] is recommended for lightweight TypeScript protobufs.
[protobuf-es-lite]: https://github.com/aperturerobotics/protobuf-es-lite
## Protobuf
[protocol buffers](https://protobuf.dev) are a cross-platform cross-language
message serialization format. Protobuf is a language for specifying the schema
for structured data. This schema is compiled into language specific bindings.
This project provides both a tool to generate Go code for the protocol buffer
language, and also the runtime implementation to handle serialization of
messages in Go.
See the [protocol buffer developer guide](https://protobuf.dev/overview) for
more information about protocol buffers themselves.
## Example
See the [protobuf-project](https://github.com/aperturerobotics/protobuf-project)
template for an example of how to use this package and vtprotobuf together with
protowrap to generate protobufs for your project.
This package is available at **github.com/aperturerobotics/protobuf-go-lite**.
## Package index
Summary of the packages provided by this module:
* [`compiler/protogen`](https://pkg.go.dev/github.com/aperturerobotics/protobuf-go-lite/compiler/protogen):
Package `protogen` provides support for writing protoc plugins.
* [`cmd/protoc-gen-go-lite`](https://pkg.go.dev/github.com/aperturerobotics/protobuf-go-lite/cmd/protoc-gen-go-lite):
The `protoc-gen-go-lite` binary is a protoc plugin to generate a Go protocol
buffer package.
## Usage
1. Install `protoc-gen-go-lite`:
```
go install github.com/aperturerobotics/protobuf-go-lite/cmd/protoc-gen-go-lite@latest
```
2. Update your `protoc` generator to use the new plug-in.
```
for name in $(PROTO_SRC_NAMES); do \
protoc \
--plugin protoc-gen-go-lite="${GOBIN}/protoc-gen-go-lite" \
--go-lite_out=. \
--go-lite_opt=features=marshal+unmarshal+size+equal+clone \
proto/$${name}.proto; \
done
```
`protobuf-go-lite` replaces `protoc-gen-go` and `protoc-gen-go-vtprotobuf` and should not be used with those generators.
Check out the [template](https://github.com/aperturerobotics/template) for a quick start!
## Available features
The following additional features from vtprotobuf can be enabled:
- `size`: generates a `func (p *YourProto) SizeVT() int` helper that behaves identically to calling `proto.Size(p)` on the message, except the size calculation is fully unrolled and does not use reflection. This helper function can be used directly, and it'll also be used by the `marshal` codegen to ensure the destination buffer is properly sized before ProtoBuf objects are marshalled to it.
- `equal`: generates the following helper methods
- `func (this *YourProto) EqualVT(that *YourProto) bool`: this function behaves almost identically to calling `proto.Equal(this, that)` on messages, except the equality calculation is fully unrolled and does not use reflection. This helper function can be used directly.
- `func (this *YourProto) EqualMessageVT(thatMsg any) bool`: this function behaves like the above `this.EqualVT(that)`, but allows comparing against arbitrary proto messages. If `thatMsg` is not of type `*YourProto`, false is returned. The uniform signature provided by this method allows accessing this method via type assertions even if the message type is not known at compile time. This allows implementing a generic `func EqualVT(proto.Message, proto.Message) bool` without reflection.
- `marshal`: generates the following helper methods
- `func (p *YourProto) MarshalVT() ([]byte, error)`: this function behaves identically to calling `proto.Marshal(p)`, except the actual marshalling has been fully unrolled and does not use reflection or allocate memory. This function simply allocates a properly sized buffer by calling `SizeVT` on the message and then uses `MarshalToSizedBufferVT` to marshal to it.
- `func (p *YourProto) MarshalToVT(data []byte) (int, error)`: this function can be used to marshal a message to an existing buffer. The buffer must be large enough to hold the marshalled message, otherwise this function will panic. It returns the number of bytes marshalled. This function is useful e.g. when using memory pooling to re-use serialization buffers.
- `func (p *YourProto) MarshalToSizedBufferVT(data []byte) (int, error)`: this function behaves like `MarshalTo` but expects that the input buffer has the exact size required to hold the message, otherwise it will panic.
- `marshal_strict`: generates the following helper methods
- `func (p *YourProto) MarshalVTStrict() ([]byte, error)`: this function behaves like `MarshalVT`, except fields are marshalled in a strict order by field's numbers they were declared in .proto file.
- `func (p *YourProto) MarshalToVTStrict(data []byte) (int, error)`: this function behaves like `MarshalToVT`, except fields are marshalled in a strict order by field's numbers they were declared in .proto file.
- `func (p *YourProto) MarshalToSizedBufferVTStrict(data []byte) (int, error)`: this function behaves like `MarshalToSizedBufferVT`, except fields are marshalled in a strict order by field's numbers they were declared in .proto file.
- `unmarshal`: generates a `func (p *YourProto) UnmarshalVT(data []byte)` that behaves similarly to calling `proto.Unmarshal(data, p)` on the message, except the unmarshalling is performed by unrolled codegen without using reflection and allocating as little memory as possible. If the receiver `p` is **not** fully zeroed-out, the unmarshal call will actually behave like `proto.Merge(data, p)`. This is because the `proto.Unmarshal` in the ProtoBuf API is implemented by resetting the destination message and then calling `proto.Merge` on it. To ensure proper `Unmarshal` semantics, ensure you've called `proto.Reset` on your message before calling `UnmarshalVT`, or that your message has been newly allocated.
- `unmarshal_unsafe` generates a `func (p *YourProto) UnmarshalVTUnsafe(data []byte)` that behaves like `UnmarshalVT`, except it unsafely casts slices of data to `bytes` and `string` fields instead of copying them to newly allocated arrays, so that it performs less allocations. **Data received from the wire has to be left untouched for the lifetime of the message.** Otherwise, the message's `bytes` and `string` fields can be corrupted.
- `clone`: generates the following helper methods
- `func (p *YourProto) CloneVT() *YourProto`: this function behaves similarly to calling `proto.Clone(p)` on the message, except the cloning is performed by unrolled codegen without using reflection. If the receiver `p` is `nil` a typed `nil` is returned.
- `func (p *YourProto) CloneMessageVT() any`: this function behaves like the above `p.CloneVT()`, but provides a uniform signature in order to be accessible via type assertions even if the type is not known at compile time. This allows implementing a generic `func CloneMessageVT() any` without reflection. If the receiver `p` is `nil`, a typed `nil` pointer of the message type will be returned inside a `any` interface.
- `json`: generates the following helper methods
- `func (p *YourProto) UnmarshalJSON(data []byte) error` behaves similarly to calling `protojson.Unmarshal(data, p)` on the message, except the unmarshalling is performed by unrolled codegen without using reflection and allocating as little memory as possible (with json-iterator/go). If the receiver `p` is **not** fully zeroed-out, the unmarshal call will actually behave like `proto.Merge(data, p)`. To ensure proper `Unmarshal` semantics, ensure you've called `proto.Reset` on your message before calling `UnmarshalJSON`, or that your message has been newly allocated.
- `func (p *YourProto) UnmarshalJSONValue(val *fastjson.Value) error` unmarshals a `*fastjson.Value`.
- `func (p *YourProto) MarshalJSON() ([]byte, error)` behaves similarly to calling `protojson.Marshal(p)` on the message, except the marshalling is performed by unrolled codegen without using reflection and allocating as little memory as possible (with json-iterator/go).
- Adding a `//protobuf-go-lite:disable-json` comment before a message or enum will disable the json marshaler / unmarshaler.
## License
BSD-3
+594
View File
@@ -0,0 +1,594 @@
package protobuf_go_lite
import (
"errors"
"fmt"
"io"
"math"
"math/bits"
"slices"
"unsafe"
)
var (
// ErrInvalidLength is returned when decoding a negative length.
ErrInvalidLength = errors.New("proto: negative length found during unmarshaling")
// ErrIntOverflow is returned when decoding a varint representation of an integer that overflows 64 bits.
ErrIntOverflow = errors.New("proto: integer overflow")
// ErrUnexpectedEndOfGroup is returned when decoding a group end without a corresponding group start.
ErrUnexpectedEndOfGroup = errors.New("proto: unexpected end of group")
)
// Message is the base vtprotobuf message marshal/unmarshal interface.
type Message interface {
// SizeVT returns the size of the message when marshaled.
SizeVT() int
// MarshalToSizedBufferVT marshals to a buffer that already is SizeVT bytes long.
MarshalToSizedBufferVT(dAtA []byte) (int, error)
// MarshalVT marshals the message with vtprotobuf.
MarshalVT() ([]byte, error)
// UnmarshalVT unmarshals the message object with vtprotobuf.
UnmarshalVT(data []byte) error
// Reset resets the message.
Reset()
}
// JSONMessage is a message with MarshalJSON and UnmarshalJSON.
type JSONMessage interface {
// MarshalJSON marshals the message to JSON.
MarshalJSON() ([]byte, error)
// UnmarshalJSON unmarshals the message from JSON.
UnmarshalJSON(data []byte) error
}
// CloneMessage is a message with a CloneMessage function.
type CloneMessage interface {
// Message extends the base message type.
Message
// CloneMessageVT clones the object.
CloneMessageVT() CloneMessage
}
// CloneVT is a message with a CloneVT function (VTProtobuf).
type CloneVT[T comparable] interface {
comparable
// CloneMessage is the non-generic clone interface.
CloneMessage
// CloneVT clones the object.
CloneVT() T
}
// CloneVTSlice clones a slice of CloneVT messages.
func CloneVTSlice[S ~[]E, E CloneVT[E]](s S) S {
out := make([]E, len(s))
var empty E
for i := range s {
if s[i] != empty {
out[i] = s[i].CloneVT()
}
}
return out
}
// EqualVT is a message with a EqualVT function (VTProtobuf).
type EqualVT[T comparable] interface {
comparable
// EqualVT compares against the other message for equality.
EqualVT(other T) bool
}
// CompareComparable returns a compare function to compare two comparable types.
func CompareComparable[T comparable]() func(t1, t2 T) bool {
return func(t1, t2 T) bool {
return t1 == t2
}
}
// CompareEqualVT returns a compare function to compare two VTProtobuf messages.
func CompareEqualVT[T EqualVT[T]]() func(t1, t2 T) bool {
return func(t1, t2 T) bool {
return IsEqualVT(t1, t2)
}
}
// IsEqualVT checks if two EqualVT objects are equal.
func IsEqualVT[T EqualVT[T]](t1, t2 T) bool {
var empty T
t1Empty, t2Empty := t1 == empty, t2 == empty
if t1Empty != t2Empty {
return false
}
if t1Empty {
return true
}
return t1.EqualVT(t2)
}
// IsEqualVTSlice checks if two slices of EqualVT messages are equal.
func IsEqualVTSlice[S ~[]E, E EqualVT[E]](s1, s2 S) bool {
return slices.EqualFunc(s1, s2, CompareEqualVT[E]())
}
// EncodeVarint encodes a uint64 into a varint-encoded byte slice and returns the offset of the encoded value.
// The provided offset is the offset after the last byte of the encoded value.
func EncodeVarint(dAtA []byte, offset int, v uint64) int {
offset -= SizeOfVarint(v)
base := offset
for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80) //nolint:gosec
v >>= 7
offset++
}
dAtA[offset] = uint8(v)
return base
}
// AppendVarint appends v to b as a varint-encoded uint64.
func AppendVarint(b []byte, v uint64) []byte {
switch {
case v < 1<<7:
b = append(b, byte(v))
case v < 1<<14:
b = append(b,
byte((v>>0)&0x7f|0x80),
byte(v>>7))
case v < 1<<21:
b = append(b,
byte((v>>0)&0x7f|0x80),
byte((v>>7)&0x7f|0x80),
byte(v>>14))
case v < 1<<28:
b = append(b,
byte((v>>0)&0x7f|0x80),
byte((v>>7)&0x7f|0x80),
byte((v>>14)&0x7f|0x80),
byte(v>>21))
case v < 1<<35:
b = append(b,
byte((v>>0)&0x7f|0x80),
byte((v>>7)&0x7f|0x80),
byte((v>>14)&0x7f|0x80),
byte((v>>21)&0x7f|0x80),
byte(v>>28))
case v < 1<<42:
b = append(b,
byte((v>>0)&0x7f|0x80),
byte((v>>7)&0x7f|0x80),
byte((v>>14)&0x7f|0x80),
byte((v>>21)&0x7f|0x80),
byte((v>>28)&0x7f|0x80),
byte(v>>35))
case v < 1<<49:
b = append(b,
byte((v>>0)&0x7f|0x80),
byte((v>>7)&0x7f|0x80),
byte((v>>14)&0x7f|0x80),
byte((v>>21)&0x7f|0x80),
byte((v>>28)&0x7f|0x80),
byte((v>>35)&0x7f|0x80),
byte(v>>42))
case v < 1<<56:
b = append(b,
byte((v>>0)&0x7f|0x80),
byte((v>>7)&0x7f|0x80),
byte((v>>14)&0x7f|0x80),
byte((v>>21)&0x7f|0x80),
byte((v>>28)&0x7f|0x80),
byte((v>>35)&0x7f|0x80),
byte((v>>42)&0x7f|0x80),
byte(v>>49))
case v < 1<<63:
b = append(b,
byte((v>>0)&0x7f|0x80),
byte((v>>7)&0x7f|0x80),
byte((v>>14)&0x7f|0x80),
byte((v>>21)&0x7f|0x80),
byte((v>>28)&0x7f|0x80),
byte((v>>35)&0x7f|0x80),
byte((v>>42)&0x7f|0x80),
byte((v>>49)&0x7f|0x80),
byte(v>>56))
default:
b = append(b,
byte((v>>0)&0x7f|0x80),
byte((v>>7)&0x7f|0x80),
byte((v>>14)&0x7f|0x80),
byte((v>>21)&0x7f|0x80),
byte((v>>28)&0x7f|0x80),
byte((v>>35)&0x7f|0x80),
byte((v>>42)&0x7f|0x80),
byte((v>>49)&0x7f|0x80),
byte((v>>56)&0x7f|0x80),
1)
}
return b
}
// ConsumeVarint parses b as a varint-encoded uint64, reporting its length.
// This returns -1 upon any error, -1 for parse error and -2 for overflow.
func ConsumeVarint(b []byte) (v uint64, n int) {
var y uint64
if len(b) <= 0 {
return 0, -1
}
v = uint64(b[0])
if v < 0x80 {
return v, 1
}
v -= 0x80
if len(b) <= 1 {
return 0, -1
}
y = uint64(b[1])
v += y << 7
if y < 0x80 {
return v, 2
}
v -= 0x80 << 7
if len(b) <= 2 {
return 0, -1
}
y = uint64(b[2])
v += y << 14
if y < 0x80 {
return v, 3
}
v -= 0x80 << 14
if len(b) <= 3 {
return 0, -1
}
y = uint64(b[3])
v += y << 21
if y < 0x80 {
return v, 4
}
v -= 0x80 << 21
if len(b) <= 4 {
return 0, -1
}
y = uint64(b[4])
v += y << 28
if y < 0x80 {
return v, 5
}
v -= 0x80 << 28
if len(b) <= 5 {
return 0, -1
}
y = uint64(b[5])
v += y << 35
if y < 0x80 {
return v, 6
}
v -= 0x80 << 35
if len(b) <= 6 {
return 0, -1
}
y = uint64(b[6])
v += y << 42
if y < 0x80 {
return v, 7
}
v -= 0x80 << 42
if len(b) <= 7 {
return 0, -1
}
y = uint64(b[7])
v += y << 49
if y < 0x80 {
return v, 8
}
v -= 0x80 << 49
if len(b) <= 8 {
return 0, -1
}
y = uint64(b[8])
v += y << 56
if y < 0x80 {
return v, 9
}
v -= 0x80 << 56
if len(b) <= 9 {
return 0, -1
}
y = uint64(b[9])
v += y << 63
if y < 2 {
return v, 10
}
return 0, -2
}
// SizeOfVarint returns the size of the varint-encoded value.
func SizeOfVarint(x uint64) (n int) {
return (bits.Len64(x|1) + 6) / 7
}
// DecodeVarint decodes a varint at the given index, returning value, new index, and error.
// Assumes idx is within bounds (0 <= idx <= len(b)); generated code maintains this invariant.
func DecodeVarint(b []byte, idx int) (uint64, int, error) {
v, n := ConsumeVarint(b[idx:])
if n < 0 {
if n == -1 {
return 0, 0, io.ErrUnexpectedEOF
}
return 0, 0, ErrIntOverflow
}
return v, idx + n, nil
}
// DecodeVarintInt32 decodes a varint as int32.
// Assumes idx is within bounds (0 <= idx <= len(b)); generated code maintains this invariant.
func DecodeVarintInt32(b []byte, idx int) (int32, int, error) {
v, n := ConsumeVarint(b[idx:])
if n < 0 {
if n == -1 {
return 0, 0, io.ErrUnexpectedEOF
}
return 0, 0, ErrIntOverflow
}
return int32(v), idx + n, nil //nolint:gosec
}
// DecodeVarintInt64 decodes a varint as int64.
// Assumes idx is within bounds (0 <= idx <= len(b)); generated code maintains this invariant.
func DecodeVarintInt64(b []byte, idx int) (int64, int, error) {
v, n := ConsumeVarint(b[idx:])
if n < 0 {
if n == -1 {
return 0, 0, io.ErrUnexpectedEOF
}
return 0, 0, ErrIntOverflow
}
return int64(v), idx + n, nil //nolint:gosec
}
// DecodeVarintUint32 decodes a varint as uint32.
// Assumes idx is within bounds (0 <= idx <= len(b)); generated code maintains this invariant.
func DecodeVarintUint32(b []byte, idx int) (uint32, int, error) {
v, n := ConsumeVarint(b[idx:])
if n < 0 {
if n == -1 {
return 0, 0, io.ErrUnexpectedEOF
}
return 0, 0, ErrIntOverflow
}
return uint32(v), idx + n, nil //nolint:gosec
}
// DecodeVarintBool decodes a varint as bool.
// Assumes idx is within bounds (0 <= idx <= len(b)); generated code maintains this invariant.
func DecodeVarintBool(b []byte, idx int) (bool, int, error) {
v, n := ConsumeVarint(b[idx:])
if n < 0 {
if n == -1 {
return false, 0, io.ErrUnexpectedEOF
}
return false, 0, ErrIntOverflow
}
return v != 0, idx + n, nil
}
// DecodeSint32 decodes a zigzag-encoded sint32.
// Assumes idx is within bounds (0 <= idx <= len(b)); generated code maintains this invariant.
func DecodeSint32(b []byte, idx int) (int32, int, error) {
v, n := ConsumeVarint(b[idx:])
if n < 0 {
if n == -1 {
return 0, 0, io.ErrUnexpectedEOF
}
return 0, 0, ErrIntOverflow
}
return int32((uint32(v) >> 1) ^ uint32((int32(v&1)<<31)>>31)), idx + n, nil //nolint:gosec
}
// DecodeSint64 decodes a zigzag-encoded sint64.
// Assumes idx is within bounds (0 <= idx <= len(b)); generated code maintains this invariant.
func DecodeSint64(b []byte, idx int) (int64, int, error) {
v, n := ConsumeVarint(b[idx:])
if n < 0 {
if n == -1 {
return 0, 0, io.ErrUnexpectedEOF
}
return 0, 0, ErrIntOverflow
}
return int64((v >> 1) ^ uint64((int64(v&1)<<63)>>63)), idx + n, nil //nolint:gosec
}
// DecodeFixed32 decodes a fixed 32-bit value.
// Assumes idx is within bounds (0 <= idx <= len(b)); generated code maintains this invariant.
func DecodeFixed32(b []byte, idx int) (uint32, int, error) {
if idx+4 > len(b) {
return 0, 0, io.ErrUnexpectedEOF
}
v := uint32(b[idx]) | uint32(b[idx+1])<<8 | uint32(b[idx+2])<<16 | uint32(b[idx+3])<<24
return v, idx + 4, nil
}
// DecodeFixed64 decodes a fixed 64-bit value.
// Assumes idx is within bounds (0 <= idx <= len(b)); generated code maintains this invariant.
func DecodeFixed64(b []byte, idx int) (uint64, int, error) {
if idx+8 > len(b) {
return 0, 0, io.ErrUnexpectedEOF
}
v := uint64(b[idx]) | uint64(b[idx+1])<<8 | uint64(b[idx+2])<<16 | uint64(b[idx+3])<<24 |
uint64(b[idx+4])<<32 | uint64(b[idx+5])<<40 | uint64(b[idx+6])<<48 | uint64(b[idx+7])<<56
return v, idx + 8, nil
}
// DecodeFloat32 decodes a 32-bit float.
// Assumes idx is within bounds (0 <= idx <= len(b)); generated code maintains this invariant.
func DecodeFloat32(b []byte, idx int) (float32, int, error) {
v, idx, err := DecodeFixed32(b, idx)
if err != nil {
return 0, 0, err
}
return math.Float32frombits(v), idx, nil
}
// DecodeFloat64 decodes a 64-bit float.
// Assumes idx is within bounds (0 <= idx <= len(b)); generated code maintains this invariant.
func DecodeFloat64(b []byte, idx int) (float64, int, error) {
v, idx, err := DecodeFixed64(b, idx)
if err != nil {
return 0, 0, err
}
return math.Float64frombits(v), idx, nil
}
// DecodeBytes decodes a length-prefixed byte slice. If copy is false, returns a sub-slice.
// Assumes idx is within bounds (0 <= idx <= len(b)); generated code maintains this invariant.
func DecodeBytes(b []byte, idx int, cp bool) ([]byte, int, error) {
length, idx, err := DecodeVarint(b, idx)
if err != nil {
return nil, 0, err
}
l := int(length) //nolint:gosec
if l < 0 {
return nil, 0, ErrInvalidLength
}
end := idx + l
if end < idx || end > len(b) {
return nil, 0, io.ErrUnexpectedEOF
}
if cp {
out := make([]byte, l)
copy(out, b[idx:end])
return out, end, nil
}
return b[idx:end], end, nil
}
// DecodeString decodes a length-prefixed string (with copy).
// Assumes idx is within bounds (0 <= idx <= len(b)); generated code maintains this invariant.
func DecodeString(b []byte, idx int) (string, int, error) {
length, idx, err := DecodeVarint(b, idx)
if err != nil {
return "", 0, err
}
l := int(length) //nolint:gosec
if l < 0 {
return "", 0, ErrInvalidLength
}
end := idx + l
if end < idx || end > len(b) {
return "", 0, io.ErrUnexpectedEOF
}
return string(b[idx:end]), end, nil
}
// DecodeStringUnsafe decodes a length-prefixed string without copying.
// The returned string shares memory with the input slice.
// Assumes idx is within bounds (0 <= idx <= len(b)); generated code maintains this invariant.
func DecodeStringUnsafe(b []byte, idx int) (string, int, error) {
length, idx, err := DecodeVarint(b, idx)
if err != nil {
return "", 0, err
}
l := int(length) //nolint:gosec
if l < 0 {
return "", 0, ErrInvalidLength
}
end := idx + l
if end < idx || end > len(b) {
return "", 0, io.ErrUnexpectedEOF
}
if l == 0 {
return "", end, nil
}
return unsafe.String(&b[idx], l), end, nil
}
// SizeOfZigzag returns the size of the zigzag-encoded value.
func SizeOfZigzag(x uint64) (n int) {
return SizeOfVarint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) //nolint
}
// Skip the first record of the byte slice and return the offset of the next record.
func Skip(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
depth := 0
for iNdEx < l {
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflow
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
wireType := int(wire & 0x7) //nolint:gosec
switch wireType {
case 0:
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflow
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
iNdEx++
if dAtA[iNdEx-1] < 0x80 {
break
}
}
case 1:
iNdEx += 8
case 2:
var length int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflow
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
length |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if length < 0 {
return 0, ErrInvalidLength
}
iNdEx += length
case 3:
depth++
case 4:
if depth == 0 {
return 0, ErrUnexpectedEndOfGroup
}
depth--
case 5:
iNdEx += 4
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
if iNdEx < 0 {
return 0, ErrInvalidLength
}
if depth == 0 {
return iNdEx, nil
}
}
return 0, io.ErrUnexpectedEOF
}
+2 -2
View File
@@ -22,13 +22,13 @@ rpc/rpc.proto:
curl -sSL https://raw.githubusercontent.com/checkpoint-restore/criu/master/images/rpc.proto -o $@
rpc/rpc.pb.go: rpc/rpc.proto
protoc --go_out=. --go_opt=M$^=rpc/ $^
protoc --go-lite_out=. --go-lite_opt=M$^=rpc/ $^
stats/stats.proto:
curl -sSL https://raw.githubusercontent.com/checkpoint-restore/criu/master/images/stats.proto -o $@
stats/stats.pb.go: stats/stats.proto
protoc --go_out=. --go_opt=M$^=stats/ $^
protoc --go-lite_out=. --go-lite_opt=M$^=stats/ $^
vendor:
$(GO) mod tidy
@@ -0,0 +1,13 @@
// Package proto provides a small helper for constructing pointers to
// scalar values, as used by proto2-generated optional/required fields.
//
// protobuf-go-lite does not ship the proto.String/Int32/Bool constructors
// that google.golang.org/protobuf/proto offers, so Ptr replaces them.
package proto
// Ptr returns a pointer to v. It is handy for setting proto2 optional and
// required scalar fields, e.g. Ptr("foo"), Ptr(true), Ptr[int32](4).
//
// TODO: drop this in favor of the built-in new(v) once the minimum
// supported Go version is 1.26 or later.
func Ptr[T any](v T) *T { return &v }
+7 -7
View File
@@ -9,8 +9,8 @@ import (
"strconv"
"syscall"
proto "github.com/checkpoint-restore/go-criu/v8/internal/proto"
"github.com/checkpoint-restore/go-criu/v8/rpc"
"google.golang.org/protobuf/proto"
)
// extraFilesStartFd is the first fd number assigned to cmd.ExtraFiles by os/exec.
@@ -72,8 +72,8 @@ func (c *Criu) ensureInheritFd(opts *rpc.CriuOpts) {
for i, key := range keys {
fd := int32(extraFilesStartFd + i)
opts.InheritFd = append(opts.InheritFd, &rpc.InheritFd{
Key: proto.String(key),
Fd: proto.Int32(fd),
Key: proto.Ptr(key),
Fd: proto.Ptr(fd),
})
}
}
@@ -177,7 +177,7 @@ func (c *Criu) doSwrkWithResp(reqType rpc.CriuReqType, opts *rpc.CriuOpts, nfy N
}
if nfy != nil {
opts.NotifyScripts = proto.Bool(true)
opts.NotifyScripts = proto.Ptr(true)
}
if features != nil {
@@ -200,7 +200,7 @@ func (c *Criu) doSwrkWithResp(reqType rpc.CriuReqType, opts *rpc.CriuOpts, nfy N
}
for {
reqB, err := proto.Marshal(&req)
reqB, err := req.MarshalVT()
if err != nil {
return nil, err
}
@@ -211,7 +211,7 @@ func (c *Criu) doSwrkWithResp(reqType rpc.CriuReqType, opts *rpc.CriuOpts, nfy N
}
resp = &rpc.CriuResp{}
err = proto.Unmarshal(respB[:respS], resp)
err = resp.UnmarshalVT(respB[:respS])
if err != nil {
return nil, err
}
@@ -259,7 +259,7 @@ func (c *Criu) doSwrkWithResp(reqType rpc.CriuReqType, opts *rpc.CriuOpts, nfy N
req = rpc.CriuReq{
Type: &respType,
NotifySuccess: proto.Bool(true),
NotifySuccess: proto.Ptr(true),
}
}
File diff suppressed because it is too large Load Diff
+112 -16
View File
@@ -13,11 +13,19 @@ import (
const cpuSetSize = _CPU_SETSIZE / _NCPUBITS
// CPUSet represents a CPU affinity mask.
// CPUSet represents a bit mask of CPUs, to be used with [SchedGetaffinity], [SchedSetaffinity],
// and [SetMemPolicy].
//
// Note this type can only represent CPU IDs 0 through 1023.
// Use [CPUSetDynamic]/[NewCPUSet] instead to avoid this limit.
type CPUSet [cpuSetSize]cpuMask
func schedAffinity(trap uintptr, pid int, set *CPUSet) error {
_, _, e := RawSyscall(trap, uintptr(pid), uintptr(unsafe.Sizeof(*set)), uintptr(unsafe.Pointer(set)))
// CPUSetDynamic represents a bit mask of CPUs, to be used with [SchedGetaffinityDynamic],
// [SchedSetaffinityDynamic], and [SetMemPolicyDynamic]. Use [NewCPUSet] to allocate.
type CPUSetDynamic []cpuMask
func schedAffinity(trap uintptr, pid int, size uintptr, ptr unsafe.Pointer) error {
_, _, e := RawSyscall(trap, uintptr(pid), uintptr(size), uintptr(ptr))
if e != 0 {
return errnoErr(e)
}
@@ -27,13 +35,13 @@ func schedAffinity(trap uintptr, pid int, set *CPUSet) error {
// SchedGetaffinity gets the CPU affinity mask of the thread specified by pid.
// If pid is 0 the calling thread is used.
func SchedGetaffinity(pid int, set *CPUSet) error {
return schedAffinity(SYS_SCHED_GETAFFINITY, pid, set)
return schedAffinity(SYS_SCHED_GETAFFINITY, pid, unsafe.Sizeof(*set), unsafe.Pointer(set))
}
// SchedSetaffinity sets the CPU affinity mask of the thread specified by pid.
// If pid is 0 the calling thread is used.
func SchedSetaffinity(pid int, set *CPUSet) error {
return schedAffinity(SYS_SCHED_SETAFFINITY, pid, set)
return schedAffinity(SYS_SCHED_SETAFFINITY, pid, unsafe.Sizeof(*set), unsafe.Pointer(set))
}
// Zero clears the set s, so that it contains no CPUs.
@@ -45,9 +53,7 @@ func (s *CPUSet) Zero() {
// will silently ignore any invalid CPU bits in [CPUSet] so this is an
// efficient way of resetting the CPU affinity of a process.
func (s *CPUSet) Fill() {
for i := range s {
s[i] = ^cpuMask(0)
}
cpuMaskFill(s[:])
}
func cpuBitsIndex(cpu int) int {
@@ -58,24 +64,27 @@ func cpuBitsMask(cpu int) cpuMask {
return cpuMask(1 << (uint(cpu) % _NCPUBITS))
}
// Set adds cpu to the set s.
func (s *CPUSet) Set(cpu int) {
func cpuMaskFill(s []cpuMask) {
for i := range s {
s[i] = ^cpuMask(0)
}
}
func cpuMaskSet(s []cpuMask, cpu int) {
i := cpuBitsIndex(cpu)
if i < len(s) {
s[i] |= cpuBitsMask(cpu)
}
}
// Clear removes cpu from the set s.
func (s *CPUSet) Clear(cpu int) {
func cpuMaskClear(s []cpuMask, cpu int) {
i := cpuBitsIndex(cpu)
if i < len(s) {
s[i] &^= cpuBitsMask(cpu)
}
}
// IsSet reports whether cpu is in the set s.
func (s *CPUSet) IsSet(cpu int) bool {
func cpuMaskIsSet(s []cpuMask, cpu int) bool {
i := cpuBitsIndex(cpu)
if i < len(s) {
return s[i]&cpuBitsMask(cpu) != 0
@@ -83,11 +92,98 @@ func (s *CPUSet) IsSet(cpu int) bool {
return false
}
// Count returns the number of CPUs in the set s.
func (s *CPUSet) Count() int {
func cpuMaskCount(s []cpuMask) int {
c := 0
for _, b := range s {
c += bits.OnesCount64(uint64(b))
}
return c
}
// Set adds cpu to the set s. If cpu is out of bounds for s, no action is taken.
func (s *CPUSet) Set(cpu int) {
cpuMaskSet(s[:], cpu)
}
// Clear removes cpu from the set s. If cpu is out of bounds for s, no action is taken.
func (s *CPUSet) Clear(cpu int) {
cpuMaskClear(s[:], cpu)
}
// IsSet reports whether cpu is in the set s.
func (s *CPUSet) IsSet(cpu int) bool {
return cpuMaskIsSet(s[:], cpu)
}
// Count returns the number of CPUs in the set s.
func (s *CPUSet) Count() int {
return cpuMaskCount(s[:])
}
// NewCPUSet creates a CPU affinity mask capable of representing CPU IDs
// up to maxCPU (exclusive).
func NewCPUSet(maxCPU int) CPUSetDynamic {
numMasks := (maxCPU + _NCPUBITS - 1) / _NCPUBITS
if numMasks == 0 {
numMasks = 1
}
return make(CPUSetDynamic, numMasks)
}
// Zero clears the set s, so that it contains no CPUs.
func (s CPUSetDynamic) Zero() {
clear(s)
}
// Fill adds all possible CPU bits to the set s. On Linux, [SchedSetaffinityDynamic]
// will silently ignore any invalid CPU bits in [CPUSetDynamic] so this is an
// efficient way of resetting the CPU affinity of a process.
func (s CPUSetDynamic) Fill() {
cpuMaskFill(s)
}
// Set adds cpu to the set s. If cpu is out of bounds for s, no action is taken.
func (s CPUSetDynamic) Set(cpu int) {
cpuMaskSet(s, cpu)
}
// Clear removes cpu from the set s. If cpu is out of bounds for s, no action is taken.
func (s CPUSetDynamic) Clear(cpu int) {
cpuMaskClear(s, cpu)
}
// IsSet reports whether cpu is in the set s.
func (s CPUSetDynamic) IsSet(cpu int) bool {
return cpuMaskIsSet(s, cpu)
}
// Count returns the number of CPUs in the set s.
func (s CPUSetDynamic) Count() int {
return cpuMaskCount(s)
}
func (s CPUSetDynamic) size() uintptr {
return uintptr(len(s)) * unsafe.Sizeof(cpuMask(0))
}
func (s CPUSetDynamic) pointer() unsafe.Pointer {
if len(s) == 0 {
return nil
}
return unsafe.Pointer(&s[0])
}
// SchedGetaffinityDynamic gets the CPU affinity mask of the thread specified by pid.
// If pid is 0 the calling thread is used.
//
// If the set is smaller than the size of the affinity mask used by the kernel,
// [EINVAL] is returned.
func SchedGetaffinityDynamic(pid int, set CPUSetDynamic) error {
return schedAffinity(SYS_SCHED_GETAFFINITY, pid, set.size(), set.pointer())
}
// SchedSetaffinityDynamic sets the CPU affinity mask of the thread specified by pid.
// If pid is 0 the calling thread is used.
func SchedSetaffinityDynamic(pid int, set CPUSetDynamic) error {
return schedAffinity(SYS_SCHED_SETAFFINITY, pid, set.size(), set.pointer())
}
+1 -1
View File
@@ -51,7 +51,7 @@ if [[ "$GOOS" = "linux" ]]; then
# Files generated through docker (use $cmd so you can Ctl-C the build or run)
set -e
$cmd docker build --tag generate:$GOOS $GOOS
$cmd docker run --interactive --tty --volume $(cd -- "$(dirname -- "$0")/.." && pwd):/build generate:$GOOS
$cmd docker run --rm --interactive --tty --volume $(cd -- "$(dirname -- "$0")/.." && pwd):/build generate:$GOOS
exit
fi
+3
View File
@@ -354,6 +354,9 @@ struct ltchars {
// Renamed in v6.16, commit c6d732c38f93 ("net: ethtool: remove duplicate defines for family info")
#define ETHTOOL_FAMILY_NAME ETHTOOL_GENL_NAME
#define ETHTOOL_FAMILY_VERSION ETHTOOL_GENL_VERSION
// Removed in v6.17, commit 760e6f7befba ("futex: Remove support for IMMUTABLE")
#define PR_FUTEX_HASH_GET_IMMUTABLE 3
'
includes_NetBSD='
+103
View File
@@ -0,0 +1,103 @@
// Copyright 2026 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 darwin || linux || openbsd
package unix
import "unsafe"
// minIovec is the size of the small initial allocation used by
// Readv, Writev, etc.
//
// This small allocation gets stack allocated, which lets the
// common use case of len(iovs) <= minIovec avoid more expensive
// heap allocations.
const minIovec = 8
// appendBytes converts bs to Iovecs and appends them to vecs.
func appendBytes(vecs []Iovec, bs [][]byte) []Iovec {
for _, b := range bs {
var v Iovec
v.SetLen(len(b))
if len(b) > 0 {
v.Base = &b[0]
} else {
v.Base = (*byte)(unsafe.Pointer(&_zero))
}
vecs = append(vecs, v)
}
return vecs
}
// writevRaceDetect tells the race detector that the program
// has read the first n bytes stored in iovecs.
func writevRaceDetect(iovecs []Iovec, n int) {
if !raceenabled {
return
}
for i := 0; n > 0 && i < len(iovecs); i++ {
m := min(int(iovecs[i].Len), n)
n -= m
if m > 0 {
raceReadRange(unsafe.Pointer(iovecs[i].Base), m)
}
}
}
// readvRaceDetect tells the race detector that the program
// has written to the first n bytes stored in iovecs.
func readvRaceDetect(iovecs []Iovec, n int, err error) {
if !raceenabled {
return
}
for i := 0; n > 0 && i < len(iovecs); i++ {
m := min(int(iovecs[i].Len), n)
n -= m
if m > 0 {
raceWriteRange(unsafe.Pointer(iovecs[i].Base), m)
}
}
if err == nil {
raceAcquire(unsafe.Pointer(&ioSync))
}
}
func Readv(fd int, iovs [][]byte) (n int, err error) {
iovecs := make([]Iovec, 0, minIovec)
iovecs = appendBytes(iovecs, iovs)
n, err = readv(fd, iovecs)
readvRaceDetect(iovecs, n, err)
return n, err
}
func Preadv(fd int, iovs [][]byte, offset int64) (n int, err error) {
iovecs := make([]Iovec, 0, minIovec)
iovecs = appendBytes(iovecs, iovs)
n, err = preadv(fd, iovecs, offset)
readvRaceDetect(iovecs, n, err)
return n, err
}
func Writev(fd int, iovs [][]byte) (n int, err error) {
iovecs := make([]Iovec, 0, minIovec)
iovecs = appendBytes(iovecs, iovs)
if raceenabled {
raceReleaseMerge(unsafe.Pointer(&ioSync))
}
n, err = writev(fd, iovecs)
writevRaceDetect(iovecs, n)
return n, err
}
func Pwritev(fd int, iovs [][]byte, offset int64) (n int, err error) {
iovecs := make([]Iovec, 0, minIovec)
iovecs = appendBytes(iovecs, iovs)
if raceenabled {
raceReleaseMerge(unsafe.Pointer(&ioSync))
}
n, err = pwritev(fd, iovecs, offset)
writevRaceDetect(iovecs, n)
return n, err
}
-89
View File
@@ -602,95 +602,6 @@ func Connectx(fd int, srcIf uint32, srcAddr, dstAddr Sockaddr, associd SaeAssocI
return
}
const minIovec = 8
func Readv(fd int, iovs [][]byte) (n int, err error) {
iovecs := make([]Iovec, 0, minIovec)
iovecs = appendBytes(iovecs, iovs)
n, err = readv(fd, iovecs)
readvRacedetect(iovecs, n, err)
return n, err
}
func Preadv(fd int, iovs [][]byte, offset int64) (n int, err error) {
iovecs := make([]Iovec, 0, minIovec)
iovecs = appendBytes(iovecs, iovs)
n, err = preadv(fd, iovecs, offset)
readvRacedetect(iovecs, n, err)
return n, err
}
func Writev(fd int, iovs [][]byte) (n int, err error) {
iovecs := make([]Iovec, 0, minIovec)
iovecs = appendBytes(iovecs, iovs)
if raceenabled {
raceReleaseMerge(unsafe.Pointer(&ioSync))
}
n, err = writev(fd, iovecs)
writevRacedetect(iovecs, n)
return n, err
}
func Pwritev(fd int, iovs [][]byte, offset int64) (n int, err error) {
iovecs := make([]Iovec, 0, minIovec)
iovecs = appendBytes(iovecs, iovs)
if raceenabled {
raceReleaseMerge(unsafe.Pointer(&ioSync))
}
n, err = pwritev(fd, iovecs, offset)
writevRacedetect(iovecs, n)
return n, err
}
func appendBytes(vecs []Iovec, bs [][]byte) []Iovec {
for _, b := range bs {
var v Iovec
v.SetLen(len(b))
if len(b) > 0 {
v.Base = &b[0]
} else {
v.Base = (*byte)(unsafe.Pointer(&_zero))
}
vecs = append(vecs, v)
}
return vecs
}
func writevRacedetect(iovecs []Iovec, n int) {
if !raceenabled {
return
}
for i := 0; n > 0 && i < len(iovecs); i++ {
m := int(iovecs[i].Len)
if m > n {
m = n
}
n -= m
if m > 0 {
raceReadRange(unsafe.Pointer(iovecs[i].Base), m)
}
}
}
func readvRacedetect(iovecs []Iovec, n int, err error) {
if !raceenabled {
return
}
for i := 0; n > 0 && i < len(iovecs); i++ {
m := int(iovecs[i].Len)
if m > n {
m = n
}
n -= m
if m > 0 {
raceWriteRange(unsafe.Pointer(iovecs[i].Base), m)
}
}
if err == nil {
raceAcquire(unsafe.Pointer(&ioSync))
}
}
//sys connectx(fd int, endpoints *SaEndpoints, associd SaeAssocID, flags uint32, iov []Iovec, n *uintptr, connid *SaeConnID) (err error)
//sys sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error)
+18 -96
View File
@@ -2150,33 +2150,10 @@ func Signalfd(fd int, sigmask *Sigset_t, flags int) (newfd int, err error) {
//sys exitThread(code int) (err error) = SYS_EXIT
//sys readv(fd int, iovs []Iovec) (n int, err error) = SYS_READV
//sys writev(fd int, iovs []Iovec) (n int, err error) = SYS_WRITEV
//sys preadv(fd int, iovs []Iovec, offs_l uintptr, offs_h uintptr) (n int, err error) = SYS_PREADV
//sys pwritev(fd int, iovs []Iovec, offs_l uintptr, offs_h uintptr) (n int, err error) = SYS_PWRITEV
//sys preadv2(fd int, iovs []Iovec, offs_l uintptr, offs_h uintptr, flags int) (n int, err error) = SYS_PREADV2
//sys pwritev2(fd int, iovs []Iovec, offs_l uintptr, offs_h uintptr, flags int) (n int, err error) = SYS_PWRITEV2
// minIovec is the size of the small initial allocation used by
// Readv, Writev, etc.
//
// This small allocation gets stack allocated, which lets the
// common use case of len(iovs) <= minIovs avoid more expensive
// heap allocations.
const minIovec = 8
// appendBytes converts bs to Iovecs and appends them to vecs.
func appendBytes(vecs []Iovec, bs [][]byte) []Iovec {
for _, b := range bs {
var v Iovec
v.SetLen(len(b))
if len(b) > 0 {
v.Base = &b[0]
} else {
v.Base = (*byte)(unsafe.Pointer(&_zero))
}
vecs = append(vecs, v)
}
return vecs
}
//sys preadvSyscall(fd int, iovs []Iovec, offs_l uintptr, offs_h uintptr) (n int, err error) = SYS_PREADV
//sys pwritevSyscall(fd int, iovs []Iovec, offs_l uintptr, offs_h uintptr) (n int, err error) = SYS_PWRITEV
//sys preadv2Syscall(fd int, iovs []Iovec, offs_l uintptr, offs_h uintptr, flags int) (n int, err error) = SYS_PREADV2
//sys pwritev2Syscall(fd int, iovs []Iovec, offs_l uintptr, offs_h uintptr, flags int) (n int, err error) = SYS_PWRITEV2
// offs2lohi splits offs into its low and high order bits.
func offs2lohi(offs int64) (lo, hi uintptr) {
@@ -2184,69 +2161,23 @@ func offs2lohi(offs int64) (lo, hi uintptr) {
return uintptr(offs), uintptr(uint64(offs) >> (longBits - 1) >> 1) // two shifts to avoid false positive in vet
}
func Readv(fd int, iovs [][]byte) (n int, err error) {
iovecs := make([]Iovec, 0, minIovec)
iovecs = appendBytes(iovecs, iovs)
n, err = readv(fd, iovecs)
readvRacedetect(iovecs, n, err)
return n, err
}
func Preadv(fd int, iovs [][]byte, offset int64) (n int, err error) {
iovecs := make([]Iovec, 0, minIovec)
iovecs = appendBytes(iovecs, iovs)
func preadv(fd int, iovecs []Iovec, offset int64) (n int, err error) {
lo, hi := offs2lohi(offset)
n, err = preadv(fd, iovecs, lo, hi)
readvRacedetect(iovecs, n, err)
return n, err
return preadvSyscall(fd, iovecs, lo, hi)
}
func Preadv2(fd int, iovs [][]byte, offset int64, flags int) (n int, err error) {
iovecs := make([]Iovec, 0, minIovec)
iovecs = appendBytes(iovecs, iovs)
lo, hi := offs2lohi(offset)
n, err = preadv2(fd, iovecs, lo, hi, flags)
readvRacedetect(iovecs, n, err)
n, err = preadv2Syscall(fd, iovecs, lo, hi, flags)
readvRaceDetect(iovecs, n, err)
return n, err
}
func readvRacedetect(iovecs []Iovec, n int, err error) {
if !raceenabled {
return
}
for i := 0; n > 0 && i < len(iovecs); i++ {
m := min(int(iovecs[i].Len), n)
n -= m
if m > 0 {
raceWriteRange(unsafe.Pointer(iovecs[i].Base), m)
}
}
if err == nil {
raceAcquire(unsafe.Pointer(&ioSync))
}
}
func Writev(fd int, iovs [][]byte) (n int, err error) {
iovecs := make([]Iovec, 0, minIovec)
iovecs = appendBytes(iovecs, iovs)
if raceenabled {
raceReleaseMerge(unsafe.Pointer(&ioSync))
}
n, err = writev(fd, iovecs)
writevRacedetect(iovecs, n)
return n, err
}
func Pwritev(fd int, iovs [][]byte, offset int64) (n int, err error) {
iovecs := make([]Iovec, 0, minIovec)
iovecs = appendBytes(iovecs, iovs)
if raceenabled {
raceReleaseMerge(unsafe.Pointer(&ioSync))
}
func pwritev(fd int, iovecs []Iovec, offset int64) (n int, err error) {
lo, hi := offs2lohi(offset)
n, err = pwritev(fd, iovecs, lo, hi)
writevRacedetect(iovecs, n)
return n, err
return pwritevSyscall(fd, iovecs, lo, hi)
}
func Pwritev2(fd int, iovs [][]byte, offset int64, flags int) (n int, err error) {
@@ -2256,24 +2187,11 @@ func Pwritev2(fd int, iovs [][]byte, offset int64, flags int) (n int, err error)
raceReleaseMerge(unsafe.Pointer(&ioSync))
}
lo, hi := offs2lohi(offset)
n, err = pwritev2(fd, iovecs, lo, hi, flags)
writevRacedetect(iovecs, n)
n, err = pwritev2Syscall(fd, iovecs, lo, hi, flags)
writevRaceDetect(iovecs, n)
return n, err
}
func writevRacedetect(iovecs []Iovec, n int) {
if !raceenabled {
return
}
for i := 0; n > 0 && i < len(iovecs); i++ {
m := min(int(iovecs[i].Len), n)
n -= m
if m > 0 {
raceReadRange(unsafe.Pointer(iovecs[i].Base), m)
}
}
}
// mmap varies by architecture; see syscall_linux_*.go.
//sys munmap(addr uintptr, length uintptr) (err error)
//sys mremap(oldaddr uintptr, oldlength uintptr, newlength uintptr, flags int, newaddr uintptr) (xaddr uintptr, err error)
@@ -2644,8 +2562,12 @@ func SchedGetAttr(pid int, flags uint) (*SchedAttr, error) {
//sys Cachestat(fd uint, crange *CachestatRange, cstat *Cachestat_t, flags uint) (err error)
//sys Mseal(b []byte, flags uint) (err error)
//sys setMemPolicy(mode int, mask *CPUSet, size int) (err error) = SYS_SET_MEMPOLICY
//sys setMemPolicy(mode int, mask unsafe.Pointer, size uintptr) (err error) = SYS_SET_MEMPOLICY
func SetMemPolicy(mode int, mask *CPUSet) error {
return setMemPolicy(mode, mask, _CPU_SETSIZE)
return setMemPolicy(mode, unsafe.Pointer(mask), _CPU_SETSIZE)
}
func SetMemPolicyDynamic(mode int, mask CPUSetDynamic) error {
return setMemPolicy(mode, mask.pointer(), mask.size())
}
+3
View File
@@ -82,6 +82,9 @@ func Time(t *Time_t) (Time_t, error) {
}
func Utime(path string, buf *Utimbuf) error {
if buf == nil {
return Utimes(path, nil)
}
tv := []Timeval{
{Sec: buf.Actime},
{Sec: buf.Modtime},
+3
View File
@@ -113,6 +113,9 @@ func Time(t *Time_t) (Time_t, error) {
}
func Utime(path string, buf *Utimbuf) error {
if buf == nil {
return Utimes(path, nil)
}
tv := []Timeval{
{Sec: buf.Actime},
{Sec: buf.Modtime},
+3
View File
@@ -150,6 +150,9 @@ func Time(t *Time_t) (Time_t, error) {
}
func Utime(path string, buf *Utimbuf) error {
if buf == nil {
return Utimes(path, nil)
}
tv := []Timeval{
{Sec: buf.Actime},
{Sec: buf.Modtime},
+3
View File
@@ -112,6 +112,9 @@ func Time(t *Time_t) (Time_t, error) {
}
func Utime(path string, buf *Utimbuf) error {
if buf == nil {
return Utimes(path, nil)
}
tv := []Timeval{
{Sec: buf.Actime},
{Sec: buf.Modtime},
+4
View File
@@ -300,6 +300,10 @@ func Uname(uname *Utsname) error {
//sys Pathconf(path string, name int) (val 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 readv(fd int, iovecs []Iovec) (n int, err error)
//sys writev(fd int, iovecs []Iovec) (n int, err error)
//sys preadv(fd int, iovecs []Iovec, offset int64) (n int, err error)
//sys pwritev(fd int, iovecs []Iovec, offset int64) (n int, err error)
//sys read(fd int, p []byte) (n int, err error)
//sys Readlink(path string, buf []byte) (n int, err error)
//sys Readlinkat(dirfd int, path string, buf []byte) (n int, err error)
+59 -2
View File
@@ -353,8 +353,10 @@ const (
AUDIT_MAC_IPSEC_EVENT = 0x587
AUDIT_MAC_MAP_ADD = 0x581
AUDIT_MAC_MAP_DEL = 0x582
AUDIT_MAC_OBJ_CONTEXTS = 0x592
AUDIT_MAC_POLICY_LOAD = 0x57b
AUDIT_MAC_STATUS = 0x57c
AUDIT_MAC_TASK_CONTEXTS = 0x591
AUDIT_MAC_UNLBL_ALLOW = 0x57e
AUDIT_MAC_UNLBL_STCADD = 0x588
AUDIT_MAC_UNLBL_STCDEL = 0x589
@@ -591,8 +593,13 @@ const (
CAN_CTRLMODE_LOOPBACK = 0x1
CAN_CTRLMODE_ONE_SHOT = 0x8
CAN_CTRLMODE_PRESUME_ACK = 0x40
CAN_CTRLMODE_RESTRICTED = 0x800
CAN_CTRLMODE_TDC_AUTO = 0x200
CAN_CTRLMODE_TDC_MANUAL = 0x400
CAN_CTRLMODE_XL = 0x1000
CAN_CTRLMODE_XL_TDC_AUTO = 0x2000
CAN_CTRLMODE_XL_TDC_MANUAL = 0x4000
CAN_CTRLMODE_XL_TMS = 0x8000
CAN_EFF_FLAG = 0x80000000
CAN_EFF_ID_BITS = 0x1d
CAN_EFF_MASK = 0x1fffffff
@@ -800,6 +807,8 @@ const (
DEVLINK_PORT_FN_CAP_IPSEC_PACKET = 0x8
DEVLINK_PORT_FN_CAP_MIGRATABLE = 0x2
DEVLINK_PORT_FN_CAP_ROCE = 0x1
DEVLINK_RATE_TCS_MAX = 0x8
DEVLINK_RATE_TC_INDEX_MAX = 0x7
DEVLINK_SB_THRESHOLD_TO_ALPHA_MAX = 0x14
DEVLINK_SUPPORTED_FLASH_OVERWRITE_SECTIONS = 0x3
DEVMEM_MAGIC = 0x454d444d
@@ -1186,6 +1195,7 @@ const (
ETH_P_MPLS_UC = 0x8847
ETH_P_MRP = 0x88e3
ETH_P_MVRP = 0x88f5
ETH_P_MXLGSW = 0x88c3
ETH_P_NCSI = 0x88f8
ETH_P_NSH = 0x894f
ETH_P_PAE = 0x888e
@@ -1218,6 +1228,7 @@ const (
ETH_P_WCCP = 0x883e
ETH_P_X25 = 0x805
ETH_P_XDSA = 0xf8
ETH_P_YT921X = 0x9988
ET_CORE = 0x4
ET_DYN = 0x3
ET_EXEC = 0x2
@@ -1258,6 +1269,7 @@ const (
FALLOC_FL_NO_HIDE_STALE = 0x4
FALLOC_FL_PUNCH_HOLE = 0x2
FALLOC_FL_UNSHARE_RANGE = 0x40
FALLOC_FL_WRITE_ZEROES = 0x80
FALLOC_FL_ZERO_RANGE = 0x10
FANOTIFY_METADATA_VERSION = 0x3
FAN_ACCESS = 0x1
@@ -1477,6 +1489,7 @@ const (
GRND_INSECURE = 0x4
GRND_NONBLOCK = 0x1
GRND_RANDOM = 0x2
GUEST_MEMFD_MAGIC = 0x474d454d
HDIO_DRIVE_CMD = 0x31f
HDIO_DRIVE_CMD_AEB = 0x31e
HDIO_DRIVE_CMD_HDR_SIZE = 0x4
@@ -1517,6 +1530,7 @@ const (
HDIO_SET_XFER = 0x306
HDIO_TRISTATE_HWIF = 0x31b
HDIO_UNREGISTER_HWIF = 0x32a
HIDIOCTL_LAST = 0xd
HID_MAX_DESCRIPTOR_SIZE = 0x1000
HOSTFS_SUPER_MAGIC = 0xc0ffee
HPFS_SUPER_MAGIC = 0xf995e849
@@ -1809,6 +1823,8 @@ const (
KEXEC_ARCH_X86_64 = 0x3e0000
KEXEC_CRASH_HOTPLUG_SUPPORT = 0x8
KEXEC_FILE_DEBUG = 0x8
KEXEC_FILE_FORCE_DTB = 0x20
KEXEC_FILE_NO_CMA = 0x10
KEXEC_FILE_NO_INITRAMFS = 0x4
KEXEC_FILE_ON_CRASH = 0x2
KEXEC_FILE_UNLOAD = 0x1
@@ -1905,6 +1921,7 @@ const (
LANDLOCK_RESTRICT_SELF_LOG_NEW_EXEC_ON = 0x2
LANDLOCK_RESTRICT_SELF_LOG_SAME_EXEC_OFF = 0x1
LANDLOCK_RESTRICT_SELF_LOG_SUBDOMAINS_OFF = 0x4
LANDLOCK_RESTRICT_SELF_TSYNC = 0x8
LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET = 0x1
LANDLOCK_SCOPE_SIGNAL = 0x2
LINUX_REBOOT_CMD_CAD_OFF = 0x0
@@ -2412,6 +2429,7 @@ const (
NN_PRXFPREG = "LINUX"
NN_RISCV_CSR = "LINUX"
NN_RISCV_TAGGED_ADDR_CTRL = "LINUX"
NN_RISCV_USER_CFI = "LINUX"
NN_RISCV_VECTOR = "LINUX"
NN_S390_CTRS = "LINUX"
NN_S390_GS_BC = "LINUX"
@@ -2493,6 +2511,7 @@ const (
NT_PRXFPREG = 0x46e62b7f
NT_RISCV_CSR = 0x900
NT_RISCV_TAGGED_ADDR_CTRL = 0x902
NT_RISCV_USER_CFI = 0x903
NT_RISCV_VECTOR = 0x901
NT_S390_CTRS = 0x304
NT_S390_GS_BC = 0x30c
@@ -2515,6 +2534,7 @@ const (
NT_X86_SHSTK = 0x204
NT_X86_XSAVE_LAYOUT = 0x205
NT_X86_XSTATE = 0x202
NULL_FS_MAGIC = 0x4e554c4c
OCFS2_SUPER_MAGIC = 0x7461636f
OCRNL = 0x8
OFDEL = 0x80
@@ -2594,6 +2614,7 @@ const (
PERF_ATTR_SIZE_VER6 = 0x78
PERF_ATTR_SIZE_VER7 = 0x80
PERF_ATTR_SIZE_VER8 = 0x88
PERF_ATTR_SIZE_VER9 = 0x90
PERF_AUX_FLAG_COLLISION = 0x8
PERF_AUX_FLAG_CORESIGHT_FORMAT_CORESIGHT = 0x0
PERF_AUX_FLAG_CORESIGHT_FORMAT_RAW = 0x100
@@ -2629,6 +2650,7 @@ const (
PERF_MEM_LVLNUM_ANY_CACHE = 0xb
PERF_MEM_LVLNUM_CXL = 0x9
PERF_MEM_LVLNUM_IO = 0xa
PERF_MEM_LVLNUM_L0 = 0x7
PERF_MEM_LVLNUM_L1 = 0x1
PERF_MEM_LVLNUM_L2 = 0x2
PERF_MEM_LVLNUM_L2_MHB = 0x5
@@ -2662,6 +2684,23 @@ const (
PERF_MEM_OP_PFETCH = 0x8
PERF_MEM_OP_SHIFT = 0x0
PERF_MEM_OP_STORE = 0x4
PERF_MEM_REGION_L_NON_SHARE = 0x3
PERF_MEM_REGION_L_SHARE = 0x2
PERF_MEM_REGION_MEM0 = 0x8
PERF_MEM_REGION_MEM1 = 0x9
PERF_MEM_REGION_MEM2 = 0xa
PERF_MEM_REGION_MEM3 = 0xb
PERF_MEM_REGION_MEM4 = 0xc
PERF_MEM_REGION_MEM5 = 0xd
PERF_MEM_REGION_MEM6 = 0xe
PERF_MEM_REGION_MEM7 = 0xf
PERF_MEM_REGION_MMIO = 0x7
PERF_MEM_REGION_NA = 0x0
PERF_MEM_REGION_O_IO = 0x4
PERF_MEM_REGION_O_NON_SHARE = 0x6
PERF_MEM_REGION_O_SHARE = 0x5
PERF_MEM_REGION_RSVD = 0x1
PERF_MEM_REGION_SHIFT = 0x2e
PERF_MEM_REMOTE_REMOTE = 0x1
PERF_MEM_REMOTE_SHIFT = 0x25
PERF_MEM_SNOOPX_FWD = 0x1
@@ -2776,6 +2815,10 @@ const (
PR_CAP_AMBIENT_IS_SET = 0x1
PR_CAP_AMBIENT_LOWER = 0x3
PR_CAP_AMBIENT_RAISE = 0x2
PR_CFI_BRANCH_LANDING_PADS = 0x0
PR_CFI_DISABLE = 0x2
PR_CFI_ENABLE = 0x1
PR_CFI_LOCK = 0x4
PR_ENDIAN_BIG = 0x0
PR_ENDIAN_LITTLE = 0x1
PR_ENDIAN_PPC_LITTLE = 0x2
@@ -2798,6 +2841,7 @@ const (
PR_FUTEX_HASH_GET_SLOTS = 0x2
PR_FUTEX_HASH_SET_SLOTS = 0x1
PR_GET_AUXV = 0x41555856
PR_GET_CFI = 0x50
PR_GET_CHILD_SUBREAPER = 0x25
PR_GET_DUMPABLE = 0x3
PR_GET_ENDIAN = 0x13
@@ -2834,6 +2878,7 @@ const (
PR_MDWE_REFUSE_EXEC_GAIN = 0x1
PR_MPX_DISABLE_MANAGEMENT = 0x2c
PR_MPX_ENABLE_MANAGEMENT = 0x2b
PR_MTE_STORE_ONLY = 0x80000
PR_MTE_TAG_MASK = 0x7fff8
PR_MTE_TAG_SHIFT = 0x3
PR_MTE_TCF_ASYNC = 0x4
@@ -2877,6 +2922,10 @@ const (
PR_RISCV_V_VSTATE_CTRL_NEXT_MASK = 0xc
PR_RISCV_V_VSTATE_CTRL_OFF = 0x1
PR_RISCV_V_VSTATE_CTRL_ON = 0x2
PR_RSEQ_SLICE_EXTENSION = 0x4f
PR_RSEQ_SLICE_EXTENSION_GET = 0x1
PR_RSEQ_SLICE_EXTENSION_SET = 0x2
PR_RSEQ_SLICE_EXT_ENABLE = 0x1
PR_SCHED_CORE = 0x3e
PR_SCHED_CORE_CREATE = 0x1
PR_SCHED_CORE_GET = 0x0
@@ -2886,6 +2935,7 @@ const (
PR_SCHED_CORE_SCOPE_THREAD_GROUP = 0x1
PR_SCHED_CORE_SHARE_FROM = 0x3
PR_SCHED_CORE_SHARE_TO = 0x2
PR_SET_CFI = 0x51
PR_SET_CHILD_SUBREAPER = 0x24
PR_SET_DUMPABLE = 0x4
PR_SET_ENDIAN = 0x14
@@ -2951,11 +3001,14 @@ const (
PR_SVE_SET_VL_ONEXEC = 0x40000
PR_SVE_VL_INHERIT = 0x20000
PR_SVE_VL_LEN_MASK = 0xffff
PR_SYS_DISPATCH_EXCLUSIVE_ON = 0x1
PR_SYS_DISPATCH_INCLUSIVE_ON = 0x2
PR_SYS_DISPATCH_OFF = 0x0
PR_SYS_DISPATCH_ON = 0x1
PR_TAGGED_ADDR_ENABLE = 0x1
PR_TASK_PERF_EVENTS_DISABLE = 0x1f
PR_TASK_PERF_EVENTS_ENABLE = 0x20
PR_THP_DISABLE_EXCEPT_ADVISED = 0x2
PR_TIMER_CREATE_RESTORE_IDS = 0x4d
PR_TIMER_CREATE_RESTORE_IDS_GET = 0x2
PR_TIMER_CREATE_RESTORE_IDS_OFF = 0x0
@@ -2987,8 +3040,10 @@ const (
PTP_STRICT_FLAGS = 0x8
PTP_SYS_OFFSET_EXTENDED = 0xc4c03d09
PTP_SYS_OFFSET_EXTENDED2 = 0xc4c03d12
PTP_SYS_OFFSET_EXTENDED_CYCLES = 0xc4c03d16
PTP_SYS_OFFSET_PRECISE = 0xc0403d08
PTP_SYS_OFFSET_PRECISE2 = 0xc0403d11
PTP_SYS_OFFSET_PRECISE_CYCLES = 0xc0403d15
PTRACE_ATTACH = 0x10
PTRACE_CONT = 0x7
PTRACE_DETACH = 0x11
@@ -3330,8 +3385,9 @@ const (
RWF_DSYNC = 0x2
RWF_HIPRI = 0x1
RWF_NOAPPEND = 0x20
RWF_NOSIGNAL = 0x100
RWF_NOWAIT = 0x8
RWF_SUPPORTED = 0xff
RWF_SUPPORTED = 0x1ff
RWF_SYNC = 0x4
RWF_WRITE_LIFE_NOT_SET = 0x0
SCHED_BATCH = 0x3
@@ -3714,7 +3770,7 @@ const (
TASKSTATS_GENL_NAME = "TASKSTATS"
TASKSTATS_GENL_VERSION = 0x1
TASKSTATS_TYPE_MAX = 0x6
TASKSTATS_VERSION = 0x10
TASKSTATS_VERSION = 0x11
TCIFLUSH = 0x0
TCIOFF = 0x2
TCIOFLUSH = 0x2
@@ -4052,6 +4108,7 @@ const (
XDP_FLAGS_REPLACE = 0x10
XDP_FLAGS_SKB_MODE = 0x2
XDP_FLAGS_UPDATE_IF_NOEXIST = 0x1
XDP_MAX_TX_SKB_BUDGET = 0x9
XDP_MMAP_OFFSETS = 0x1
XDP_OPTIONS = 0x8
XDP_OPTIONS_ZEROCOPY = 0x1
+6 -1
View File
@@ -159,6 +159,7 @@ const (
NFDBITS = 0x20
NLDLY = 0x100
NOFLSH = 0x80
NS_GET_ID = 0x8008b70d
NS_GET_MNTNS_ID = 0x8008b705
NS_GET_NSTYPE = 0xb703
NS_GET_OWNER_UID = 0xb704
@@ -305,6 +306,7 @@ const (
RTC_WKALM_SET = 0x4028700f
SCM_DEVMEM_DMABUF = 0x4f
SCM_DEVMEM_LINEAR = 0x4e
SCM_INQ = 0x54
SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a
@@ -352,6 +354,7 @@ const (
SO_ERROR = 0x4
SO_INCOMING_CPU = 0x31
SO_INCOMING_NAPI_ID = 0x38
SO_INQ = 0x54
SO_KEEPALIVE = 0x9
SO_LINGER = 0xd
SO_LOCK_FILTER = 0x2c
@@ -596,6 +599,8 @@ const (
EDESTADDRREQ = syscall.Errno(0x59)
EDOTDOT = syscall.Errno(0x49)
EDQUOT = syscall.Errno(0x7a)
EFSBADCRC = syscall.Errno(0x4a)
EFSCORRUPTED = syscall.Errno(0x75)
EHOSTDOWN = syscall.Errno(0x70)
EHOSTUNREACH = syscall.Errno(0x71)
EHWPOISON = syscall.Errno(0x85)
@@ -819,7 +824,7 @@ var errorList = [...]struct {
{114, "EALREADY", "operation already in progress"},
{115, "EINPROGRESS", "operation now in progress"},
{116, "ESTALE", "stale file handle"},
{117, "EUCLEAN", "structure needs cleaning"},
{117, "EFSCORRUPTED", "structure needs cleaning"},
{118, "ENOTNAM", "not a XENIX named type file"},
{119, "ENAVAIL", "no XENIX semaphores available"},
{120, "EISNAM", "is a named type file"},
+6 -1
View File
@@ -159,6 +159,7 @@ const (
NFDBITS = 0x40
NLDLY = 0x100
NOFLSH = 0x80
NS_GET_ID = 0x8008b70d
NS_GET_MNTNS_ID = 0x8008b705
NS_GET_NSTYPE = 0xb703
NS_GET_OWNER_UID = 0xb704
@@ -306,6 +307,7 @@ const (
RTC_WKALM_SET = 0x4028700f
SCM_DEVMEM_DMABUF = 0x4f
SCM_DEVMEM_LINEAR = 0x4e
SCM_INQ = 0x54
SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a
@@ -353,6 +355,7 @@ const (
SO_ERROR = 0x4
SO_INCOMING_CPU = 0x31
SO_INCOMING_NAPI_ID = 0x38
SO_INQ = 0x54
SO_KEEPALIVE = 0x9
SO_LINGER = 0xd
SO_LOCK_FILTER = 0x2c
@@ -596,6 +599,8 @@ const (
EDESTADDRREQ = syscall.Errno(0x59)
EDOTDOT = syscall.Errno(0x49)
EDQUOT = syscall.Errno(0x7a)
EFSBADCRC = syscall.Errno(0x4a)
EFSCORRUPTED = syscall.Errno(0x75)
EHOSTDOWN = syscall.Errno(0x70)
EHOSTUNREACH = syscall.Errno(0x71)
EHWPOISON = syscall.Errno(0x85)
@@ -819,7 +824,7 @@ var errorList = [...]struct {
{114, "EALREADY", "operation already in progress"},
{115, "EINPROGRESS", "operation now in progress"},
{116, "ESTALE", "stale file handle"},
{117, "EUCLEAN", "structure needs cleaning"},
{117, "EFSCORRUPTED", "structure needs cleaning"},
{118, "ENOTNAM", "not a XENIX named type file"},
{119, "ENAVAIL", "no XENIX semaphores available"},
{120, "EISNAM", "is a named type file"},
+6 -1
View File
@@ -156,6 +156,7 @@ const (
NFDBITS = 0x20
NLDLY = 0x100
NOFLSH = 0x80
NS_GET_ID = 0x8008b70d
NS_GET_MNTNS_ID = 0x8008b705
NS_GET_NSTYPE = 0xb703
NS_GET_OWNER_UID = 0xb704
@@ -311,6 +312,7 @@ const (
RTC_WKALM_SET = 0x4028700f
SCM_DEVMEM_DMABUF = 0x4f
SCM_DEVMEM_LINEAR = 0x4e
SCM_INQ = 0x54
SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a
@@ -358,6 +360,7 @@ const (
SO_ERROR = 0x4
SO_INCOMING_CPU = 0x31
SO_INCOMING_NAPI_ID = 0x38
SO_INQ = 0x54
SO_KEEPALIVE = 0x9
SO_LINGER = 0xd
SO_LOCK_FILTER = 0x2c
@@ -601,6 +604,8 @@ const (
EDESTADDRREQ = syscall.Errno(0x59)
EDOTDOT = syscall.Errno(0x49)
EDQUOT = syscall.Errno(0x7a)
EFSBADCRC = syscall.Errno(0x4a)
EFSCORRUPTED = syscall.Errno(0x75)
EHOSTDOWN = syscall.Errno(0x70)
EHOSTUNREACH = syscall.Errno(0x71)
EHWPOISON = syscall.Errno(0x85)
@@ -824,7 +829,7 @@ var errorList = [...]struct {
{114, "EALREADY", "operation already in progress"},
{115, "EINPROGRESS", "operation now in progress"},
{116, "ESTALE", "stale file handle"},
{117, "EUCLEAN", "structure needs cleaning"},
{117, "EFSCORRUPTED", "structure needs cleaning"},
{118, "ENOTNAM", "not a XENIX named type file"},
{119, "ENAVAIL", "no XENIX semaphores available"},
{120, "EISNAM", "is a named type file"},
+6 -1
View File
@@ -161,6 +161,7 @@ const (
NFDBITS = 0x40
NLDLY = 0x100
NOFLSH = 0x80
NS_GET_ID = 0x8008b70d
NS_GET_MNTNS_ID = 0x8008b705
NS_GET_NSTYPE = 0xb703
NS_GET_OWNER_UID = 0xb704
@@ -304,6 +305,7 @@ const (
RTC_WKALM_SET = 0x4028700f
SCM_DEVMEM_DMABUF = 0x4f
SCM_DEVMEM_LINEAR = 0x4e
SCM_INQ = 0x54
SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a
@@ -351,6 +353,7 @@ const (
SO_ERROR = 0x4
SO_INCOMING_CPU = 0x31
SO_INCOMING_NAPI_ID = 0x38
SO_INQ = 0x54
SO_KEEPALIVE = 0x9
SO_LINGER = 0xd
SO_LOCK_FILTER = 0x2c
@@ -598,6 +601,8 @@ const (
EDESTADDRREQ = syscall.Errno(0x59)
EDOTDOT = syscall.Errno(0x49)
EDQUOT = syscall.Errno(0x7a)
EFSBADCRC = syscall.Errno(0x4a)
EFSCORRUPTED = syscall.Errno(0x75)
EHOSTDOWN = syscall.Errno(0x70)
EHOSTUNREACH = syscall.Errno(0x71)
EHWPOISON = syscall.Errno(0x85)
@@ -821,7 +826,7 @@ var errorList = [...]struct {
{114, "EALREADY", "operation already in progress"},
{115, "EINPROGRESS", "operation now in progress"},
{116, "ESTALE", "stale file handle"},
{117, "EUCLEAN", "structure needs cleaning"},
{117, "EFSCORRUPTED", "structure needs cleaning"},
{118, "ENOTNAM", "not a XENIX named type file"},
{119, "ENAVAIL", "no XENIX semaphores available"},
{120, "EISNAM", "is a named type file"},
+6 -1
View File
@@ -160,6 +160,7 @@ const (
NFDBITS = 0x40
NLDLY = 0x100
NOFLSH = 0x80
NS_GET_ID = 0x8008b70d
NS_GET_MNTNS_ID = 0x8008b705
NS_GET_NSTYPE = 0xb703
NS_GET_OWNER_UID = 0xb704
@@ -298,6 +299,7 @@ const (
RTC_WKALM_SET = 0x4028700f
SCM_DEVMEM_DMABUF = 0x4f
SCM_DEVMEM_LINEAR = 0x4e
SCM_INQ = 0x54
SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a
@@ -345,6 +347,7 @@ const (
SO_ERROR = 0x4
SO_INCOMING_CPU = 0x31
SO_INCOMING_NAPI_ID = 0x38
SO_INQ = 0x54
SO_KEEPALIVE = 0x9
SO_LINGER = 0xd
SO_LOCK_FILTER = 0x2c
@@ -588,6 +591,8 @@ const (
EDESTADDRREQ = syscall.Errno(0x59)
EDOTDOT = syscall.Errno(0x49)
EDQUOT = syscall.Errno(0x7a)
EFSBADCRC = syscall.Errno(0x4a)
EFSCORRUPTED = syscall.Errno(0x75)
EHOSTDOWN = syscall.Errno(0x70)
EHOSTUNREACH = syscall.Errno(0x71)
EHWPOISON = syscall.Errno(0x85)
@@ -811,7 +816,7 @@ var errorList = [...]struct {
{114, "EALREADY", "operation already in progress"},
{115, "EINPROGRESS", "operation now in progress"},
{116, "ESTALE", "stale file handle"},
{117, "EUCLEAN", "structure needs cleaning"},
{117, "EFSCORRUPTED", "structure needs cleaning"},
{118, "ENOTNAM", "not a XENIX named type file"},
{119, "ENAVAIL", "no XENIX semaphores available"},
{120, "EISNAM", "is a named type file"},
+6 -1
View File
@@ -156,6 +156,7 @@ const (
NFDBITS = 0x20
NLDLY = 0x100
NOFLSH = 0x80
NS_GET_ID = 0x4008b70d
NS_GET_MNTNS_ID = 0x4008b705
NS_GET_NSTYPE = 0x2000b703
NS_GET_OWNER_UID = 0x2000b704
@@ -304,6 +305,7 @@ const (
RTC_WKALM_SET = 0x8028700f
SCM_DEVMEM_DMABUF = 0x4f
SCM_DEVMEM_LINEAR = 0x4e
SCM_INQ = 0x54
SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a
@@ -351,6 +353,7 @@ const (
SO_ERROR = 0x1007
SO_INCOMING_CPU = 0x31
SO_INCOMING_NAPI_ID = 0x38
SO_INQ = 0x54
SO_KEEPALIVE = 0x8
SO_LINGER = 0x80
SO_LOCK_FILTER = 0x2c
@@ -597,6 +600,8 @@ const (
EDESTADDRREQ = syscall.Errno(0x60)
EDOTDOT = syscall.Errno(0x49)
EDQUOT = syscall.Errno(0x46d)
EFSBADCRC = syscall.Errno(0x4d)
EFSCORRUPTED = syscall.Errno(0x87)
EHOSTDOWN = syscall.Errno(0x93)
EHOSTUNREACH = syscall.Errno(0x94)
EHWPOISON = syscall.Errno(0xa8)
@@ -814,7 +819,7 @@ var errorList = [...]struct {
{132, "ENOBUFS", "no buffer space available"},
{133, "EISCONN", "transport endpoint is already connected"},
{134, "ENOTCONN", "transport endpoint is not connected"},
{135, "EUCLEAN", "structure needs cleaning"},
{135, "EFSCORRUPTED", "structure needs cleaning"},
{137, "ENOTNAM", "not a XENIX named type file"},
{138, "ENAVAIL", "no XENIX semaphores available"},
{139, "EISNAM", "is a named type file"},
+6 -1
View File
@@ -156,6 +156,7 @@ const (
NFDBITS = 0x40
NLDLY = 0x100
NOFLSH = 0x80
NS_GET_ID = 0x4008b70d
NS_GET_MNTNS_ID = 0x4008b705
NS_GET_NSTYPE = 0x2000b703
NS_GET_OWNER_UID = 0x2000b704
@@ -304,6 +305,7 @@ const (
RTC_WKALM_SET = 0x8028700f
SCM_DEVMEM_DMABUF = 0x4f
SCM_DEVMEM_LINEAR = 0x4e
SCM_INQ = 0x54
SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a
@@ -351,6 +353,7 @@ const (
SO_ERROR = 0x1007
SO_INCOMING_CPU = 0x31
SO_INCOMING_NAPI_ID = 0x38
SO_INQ = 0x54
SO_KEEPALIVE = 0x8
SO_LINGER = 0x80
SO_LOCK_FILTER = 0x2c
@@ -597,6 +600,8 @@ const (
EDESTADDRREQ = syscall.Errno(0x60)
EDOTDOT = syscall.Errno(0x49)
EDQUOT = syscall.Errno(0x46d)
EFSBADCRC = syscall.Errno(0x4d)
EFSCORRUPTED = syscall.Errno(0x87)
EHOSTDOWN = syscall.Errno(0x93)
EHOSTUNREACH = syscall.Errno(0x94)
EHWPOISON = syscall.Errno(0xa8)
@@ -814,7 +819,7 @@ var errorList = [...]struct {
{132, "ENOBUFS", "no buffer space available"},
{133, "EISCONN", "transport endpoint is already connected"},
{134, "ENOTCONN", "transport endpoint is not connected"},
{135, "EUCLEAN", "structure needs cleaning"},
{135, "EFSCORRUPTED", "structure needs cleaning"},
{137, "ENOTNAM", "not a XENIX named type file"},
{138, "ENAVAIL", "no XENIX semaphores available"},
{139, "EISNAM", "is a named type file"},
+6 -1
View File
@@ -156,6 +156,7 @@ const (
NFDBITS = 0x40
NLDLY = 0x100
NOFLSH = 0x80
NS_GET_ID = 0x4008b70d
NS_GET_MNTNS_ID = 0x4008b705
NS_GET_NSTYPE = 0x2000b703
NS_GET_OWNER_UID = 0x2000b704
@@ -304,6 +305,7 @@ const (
RTC_WKALM_SET = 0x8028700f
SCM_DEVMEM_DMABUF = 0x4f
SCM_DEVMEM_LINEAR = 0x4e
SCM_INQ = 0x54
SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a
@@ -351,6 +353,7 @@ const (
SO_ERROR = 0x1007
SO_INCOMING_CPU = 0x31
SO_INCOMING_NAPI_ID = 0x38
SO_INQ = 0x54
SO_KEEPALIVE = 0x8
SO_LINGER = 0x80
SO_LOCK_FILTER = 0x2c
@@ -597,6 +600,8 @@ const (
EDESTADDRREQ = syscall.Errno(0x60)
EDOTDOT = syscall.Errno(0x49)
EDQUOT = syscall.Errno(0x46d)
EFSBADCRC = syscall.Errno(0x4d)
EFSCORRUPTED = syscall.Errno(0x87)
EHOSTDOWN = syscall.Errno(0x93)
EHOSTUNREACH = syscall.Errno(0x94)
EHWPOISON = syscall.Errno(0xa8)
@@ -814,7 +819,7 @@ var errorList = [...]struct {
{132, "ENOBUFS", "no buffer space available"},
{133, "EISCONN", "transport endpoint is already connected"},
{134, "ENOTCONN", "transport endpoint is not connected"},
{135, "EUCLEAN", "structure needs cleaning"},
{135, "EFSCORRUPTED", "structure needs cleaning"},
{137, "ENOTNAM", "not a XENIX named type file"},
{138, "ENAVAIL", "no XENIX semaphores available"},
{139, "EISNAM", "is a named type file"},
+6 -1
View File
@@ -156,6 +156,7 @@ const (
NFDBITS = 0x20
NLDLY = 0x100
NOFLSH = 0x80
NS_GET_ID = 0x4008b70d
NS_GET_MNTNS_ID = 0x4008b705
NS_GET_NSTYPE = 0x2000b703
NS_GET_OWNER_UID = 0x2000b704
@@ -304,6 +305,7 @@ const (
RTC_WKALM_SET = 0x8028700f
SCM_DEVMEM_DMABUF = 0x4f
SCM_DEVMEM_LINEAR = 0x4e
SCM_INQ = 0x54
SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a
@@ -351,6 +353,7 @@ const (
SO_ERROR = 0x1007
SO_INCOMING_CPU = 0x31
SO_INCOMING_NAPI_ID = 0x38
SO_INQ = 0x54
SO_KEEPALIVE = 0x8
SO_LINGER = 0x80
SO_LOCK_FILTER = 0x2c
@@ -597,6 +600,8 @@ const (
EDESTADDRREQ = syscall.Errno(0x60)
EDOTDOT = syscall.Errno(0x49)
EDQUOT = syscall.Errno(0x46d)
EFSBADCRC = syscall.Errno(0x4d)
EFSCORRUPTED = syscall.Errno(0x87)
EHOSTDOWN = syscall.Errno(0x93)
EHOSTUNREACH = syscall.Errno(0x94)
EHWPOISON = syscall.Errno(0xa8)
@@ -814,7 +819,7 @@ var errorList = [...]struct {
{132, "ENOBUFS", "no buffer space available"},
{133, "EISCONN", "transport endpoint is already connected"},
{134, "ENOTCONN", "transport endpoint is not connected"},
{135, "EUCLEAN", "structure needs cleaning"},
{135, "EFSCORRUPTED", "structure needs cleaning"},
{137, "ENOTNAM", "not a XENIX named type file"},
{138, "ENAVAIL", "no XENIX semaphores available"},
{139, "EISNAM", "is a named type file"},
+6 -1
View File
@@ -158,6 +158,7 @@ const (
NL3 = 0x300
NLDLY = 0x300
NOFLSH = 0x80000000
NS_GET_ID = 0x4008b70d
NS_GET_MNTNS_ID = 0x4008b705
NS_GET_NSTYPE = 0x2000b703
NS_GET_OWNER_UID = 0x2000b704
@@ -359,6 +360,7 @@ const (
RTC_WKALM_SET = 0x8028700f
SCM_DEVMEM_DMABUF = 0x4f
SCM_DEVMEM_LINEAR = 0x4e
SCM_INQ = 0x54
SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a
@@ -406,6 +408,7 @@ const (
SO_ERROR = 0x4
SO_INCOMING_CPU = 0x31
SO_INCOMING_NAPI_ID = 0x38
SO_INQ = 0x54
SO_KEEPALIVE = 0x9
SO_LINGER = 0xd
SO_LOCK_FILTER = 0x2c
@@ -653,6 +656,8 @@ const (
EDESTADDRREQ = syscall.Errno(0x59)
EDOTDOT = syscall.Errno(0x49)
EDQUOT = syscall.Errno(0x7a)
EFSBADCRC = syscall.Errno(0x4a)
EFSCORRUPTED = syscall.Errno(0x75)
EHOSTDOWN = syscall.Errno(0x70)
EHOSTUNREACH = syscall.Errno(0x71)
EHWPOISON = syscall.Errno(0x85)
@@ -877,7 +882,7 @@ var errorList = [...]struct {
{114, "EALREADY", "operation already in progress"},
{115, "EINPROGRESS", "operation now in progress"},
{116, "ESTALE", "stale file handle"},
{117, "EUCLEAN", "structure needs cleaning"},
{117, "EFSCORRUPTED", "structure needs cleaning"},
{118, "ENOTNAM", "not a XENIX named type file"},
{119, "ENAVAIL", "no XENIX semaphores available"},
{120, "EISNAM", "is a named type file"},
+6 -1
View File
@@ -158,6 +158,7 @@ const (
NL3 = 0x300
NLDLY = 0x300
NOFLSH = 0x80000000
NS_GET_ID = 0x4008b70d
NS_GET_MNTNS_ID = 0x4008b705
NS_GET_NSTYPE = 0x2000b703
NS_GET_OWNER_UID = 0x2000b704
@@ -363,6 +364,7 @@ const (
RTC_WKALM_SET = 0x8028700f
SCM_DEVMEM_DMABUF = 0x4f
SCM_DEVMEM_LINEAR = 0x4e
SCM_INQ = 0x54
SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a
@@ -410,6 +412,7 @@ const (
SO_ERROR = 0x4
SO_INCOMING_CPU = 0x31
SO_INCOMING_NAPI_ID = 0x38
SO_INQ = 0x54
SO_KEEPALIVE = 0x9
SO_LINGER = 0xd
SO_LOCK_FILTER = 0x2c
@@ -657,6 +660,8 @@ const (
EDESTADDRREQ = syscall.Errno(0x59)
EDOTDOT = syscall.Errno(0x49)
EDQUOT = syscall.Errno(0x7a)
EFSBADCRC = syscall.Errno(0x4a)
EFSCORRUPTED = syscall.Errno(0x75)
EHOSTDOWN = syscall.Errno(0x70)
EHOSTUNREACH = syscall.Errno(0x71)
EHWPOISON = syscall.Errno(0x85)
@@ -881,7 +886,7 @@ var errorList = [...]struct {
{114, "EALREADY", "operation already in progress"},
{115, "EINPROGRESS", "operation now in progress"},
{116, "ESTALE", "stale file handle"},
{117, "EUCLEAN", "structure needs cleaning"},
{117, "EFSCORRUPTED", "structure needs cleaning"},
{118, "ENOTNAM", "not a XENIX named type file"},
{119, "ENAVAIL", "no XENIX semaphores available"},
{120, "EISNAM", "is a named type file"},
+6 -1
View File
@@ -158,6 +158,7 @@ const (
NL3 = 0x300
NLDLY = 0x300
NOFLSH = 0x80000000
NS_GET_ID = 0x4008b70d
NS_GET_MNTNS_ID = 0x4008b705
NS_GET_NSTYPE = 0x2000b703
NS_GET_OWNER_UID = 0x2000b704
@@ -363,6 +364,7 @@ const (
RTC_WKALM_SET = 0x8028700f
SCM_DEVMEM_DMABUF = 0x4f
SCM_DEVMEM_LINEAR = 0x4e
SCM_INQ = 0x54
SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a
@@ -410,6 +412,7 @@ const (
SO_ERROR = 0x4
SO_INCOMING_CPU = 0x31
SO_INCOMING_NAPI_ID = 0x38
SO_INQ = 0x54
SO_KEEPALIVE = 0x9
SO_LINGER = 0xd
SO_LOCK_FILTER = 0x2c
@@ -657,6 +660,8 @@ const (
EDESTADDRREQ = syscall.Errno(0x59)
EDOTDOT = syscall.Errno(0x49)
EDQUOT = syscall.Errno(0x7a)
EFSBADCRC = syscall.Errno(0x4a)
EFSCORRUPTED = syscall.Errno(0x75)
EHOSTDOWN = syscall.Errno(0x70)
EHOSTUNREACH = syscall.Errno(0x71)
EHWPOISON = syscall.Errno(0x85)
@@ -881,7 +886,7 @@ var errorList = [...]struct {
{114, "EALREADY", "operation already in progress"},
{115, "EINPROGRESS", "operation now in progress"},
{116, "ESTALE", "stale file handle"},
{117, "EUCLEAN", "structure needs cleaning"},
{117, "EFSCORRUPTED", "structure needs cleaning"},
{118, "ENOTNAM", "not a XENIX named type file"},
{119, "ENAVAIL", "no XENIX semaphores available"},
{120, "EISNAM", "is a named type file"},
+566 -548
View File
File diff suppressed because it is too large Load Diff
+6 -1
View File
@@ -156,6 +156,7 @@ const (
NFDBITS = 0x40
NLDLY = 0x100
NOFLSH = 0x80
NS_GET_ID = 0x8008b70d
NS_GET_MNTNS_ID = 0x8008b705
NS_GET_NSTYPE = 0xb703
NS_GET_OWNER_UID = 0xb704
@@ -367,6 +368,7 @@ const (
RTC_WKALM_SET = 0x4028700f
SCM_DEVMEM_DMABUF = 0x4f
SCM_DEVMEM_LINEAR = 0x4e
SCM_INQ = 0x54
SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a
@@ -414,6 +416,7 @@ const (
SO_ERROR = 0x4
SO_INCOMING_CPU = 0x31
SO_INCOMING_NAPI_ID = 0x38
SO_INQ = 0x54
SO_KEEPALIVE = 0x9
SO_LINGER = 0xd
SO_LOCK_FILTER = 0x2c
@@ -657,6 +660,8 @@ const (
EDESTADDRREQ = syscall.Errno(0x59)
EDOTDOT = syscall.Errno(0x49)
EDQUOT = syscall.Errno(0x7a)
EFSBADCRC = syscall.Errno(0x4a)
EFSCORRUPTED = syscall.Errno(0x75)
EHOSTDOWN = syscall.Errno(0x70)
EHOSTUNREACH = syscall.Errno(0x71)
EHWPOISON = syscall.Errno(0x85)
@@ -880,7 +885,7 @@ var errorList = [...]struct {
{114, "EALREADY", "operation already in progress"},
{115, "EINPROGRESS", "operation now in progress"},
{116, "ESTALE", "stale file handle"},
{117, "EUCLEAN", "structure needs cleaning"},
{117, "EFSCORRUPTED", "structure needs cleaning"},
{118, "ENOTNAM", "not a XENIX named type file"},
{119, "ENAVAIL", "no XENIX semaphores available"},
{120, "EISNAM", "is a named type file"},
+6 -1
View File
@@ -161,6 +161,7 @@ const (
NFDBITS = 0x40
NLDLY = 0x100
NOFLSH = 0x80
NS_GET_ID = 0x4008b70d
NS_GET_MNTNS_ID = 0x4008b705
NS_GET_NSTYPE = 0x2000b703
NS_GET_OWNER_UID = 0x2000b704
@@ -358,6 +359,7 @@ const (
RTC_WKALM_SET = 0x8028700f
SCM_DEVMEM_DMABUF = 0x58
SCM_DEVMEM_LINEAR = 0x57
SCM_INQ = 0x5d
SCM_TIMESTAMPING = 0x23
SCM_TIMESTAMPING_OPT_STATS = 0x38
SCM_TIMESTAMPING_PKTINFO = 0x3c
@@ -453,6 +455,7 @@ const (
SO_ERROR = 0x1007
SO_INCOMING_CPU = 0x33
SO_INCOMING_NAPI_ID = 0x3a
SO_INQ = 0x5d
SO_KEEPALIVE = 0x8
SO_LINGER = 0x80
SO_LOCK_FILTER = 0x28
@@ -694,6 +697,8 @@ const (
EDESTADDRREQ = syscall.Errno(0x27)
EDOTDOT = syscall.Errno(0x58)
EDQUOT = syscall.Errno(0x45)
EFSBADCRC = syscall.Errno(0x4c)
EFSCORRUPTED = syscall.Errno(0x75)
EHOSTDOWN = syscall.Errno(0x40)
EHOSTUNREACH = syscall.Errno(0x41)
EHWPOISON = syscall.Errno(0x87)
@@ -921,7 +926,7 @@ var errorList = [...]struct {
{114, "ELIBACC", "can not access a needed shared library"},
{115, "ENOTUNIQ", "name not unique on network"},
{116, "ERESTART", "interrupted system call should be restarted"},
{117, "EUCLEAN", "structure needs cleaning"},
{117, "EFSCORRUPTED", "structure needs cleaning"},
{118, "ENOTNAM", "not a XENIX named type file"},
{119, "ENAVAIL", "no XENIX semaphores available"},
{120, "EISNAM", "is a named type file"},
+6 -6
View File
@@ -1785,7 +1785,7 @@ func writev(fd int, iovs []Iovec) (n int, err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func preadv(fd int, iovs []Iovec, offs_l uintptr, offs_h uintptr) (n int, err error) {
func preadvSyscall(fd int, iovs []Iovec, offs_l uintptr, offs_h uintptr) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovs) > 0 {
_p0 = unsafe.Pointer(&iovs[0])
@@ -1802,7 +1802,7 @@ func preadv(fd int, iovs []Iovec, offs_l uintptr, offs_h uintptr) (n int, err er
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func pwritev(fd int, iovs []Iovec, offs_l uintptr, offs_h uintptr) (n int, err error) {
func pwritevSyscall(fd int, iovs []Iovec, offs_l uintptr, offs_h uintptr) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovs) > 0 {
_p0 = unsafe.Pointer(&iovs[0])
@@ -1819,7 +1819,7 @@ func pwritev(fd int, iovs []Iovec, offs_l uintptr, offs_h uintptr) (n int, err e
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func preadv2(fd int, iovs []Iovec, offs_l uintptr, offs_h uintptr, flags int) (n int, err error) {
func preadv2Syscall(fd int, iovs []Iovec, offs_l uintptr, offs_h uintptr, flags int) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovs) > 0 {
_p0 = unsafe.Pointer(&iovs[0])
@@ -1836,7 +1836,7 @@ func preadv2(fd int, iovs []Iovec, offs_l uintptr, offs_h uintptr, flags int) (n
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func pwritev2(fd int, iovs []Iovec, offs_l uintptr, offs_h uintptr, flags int) (n int, err error) {
func pwritev2Syscall(fd int, iovs []Iovec, offs_l uintptr, offs_h uintptr, flags int) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovs) > 0 {
_p0 = unsafe.Pointer(&iovs[0])
@@ -2241,8 +2241,8 @@ func Mseal(b []byte, flags uint) (err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func setMemPolicy(mode int, mask *CPUSet, size int) (err error) {
_, _, e1 := Syscall(SYS_SET_MEMPOLICY, uintptr(mode), uintptr(unsafe.Pointer(mask)), uintptr(size))
func setMemPolicy(mode int, mask unsafe.Pointer, size uintptr) (err error) {
_, _, e1 := Syscall(SYS_SET_MEMPOLICY, uintptr(mode), uintptr(mask), uintptr(size))
if e1 != 0 {
err = errnoErr(e1)
}
+84
View File
@@ -1633,6 +1633,90 @@ var libc_pwrite_trampoline_addr uintptr
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func readv(fd int, iovecs []Iovec) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovecs) > 0 {
_p0 = unsafe.Pointer(&iovecs[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall(libc_readv_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_readv_trampoline_addr uintptr
//go:cgo_import_dynamic libc_readv readv "libc.so"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func writev(fd int, iovecs []Iovec) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovecs) > 0 {
_p0 = unsafe.Pointer(&iovecs[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall(libc_writev_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_writev_trampoline_addr uintptr
//go:cgo_import_dynamic libc_writev writev "libc.so"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func preadv(fd int, iovecs []Iovec, offset int64) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovecs) > 0 {
_p0 = unsafe.Pointer(&iovecs[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall6(libc_preadv_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)), uintptr(offset), uintptr(offset>>32), 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_preadv_trampoline_addr uintptr
//go:cgo_import_dynamic libc_preadv preadv "libc.so"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func pwritev(fd int, iovecs []Iovec, offset int64) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovecs) > 0 {
_p0 = unsafe.Pointer(&iovecs[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall6(libc_pwritev_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)), uintptr(offset), uintptr(offset>>32), 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_pwritev_trampoline_addr uintptr
//go:cgo_import_dynamic libc_pwritev pwritev "libc.so"
// 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 {
+20
View File
@@ -498,6 +498,26 @@ TEXT libc_pwrite_trampoline<>(SB),NOSPLIT,$0-0
GLOBL ·libc_pwrite_trampoline_addr(SB), RODATA, $4
DATA ·libc_pwrite_trampoline_addr(SB)/4, $libc_pwrite_trampoline<>(SB)
TEXT libc_readv_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_readv(SB)
GLOBL ·libc_readv_trampoline_addr(SB), RODATA, $4
DATA ·libc_readv_trampoline_addr(SB)/4, $libc_readv_trampoline<>(SB)
TEXT libc_writev_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_writev(SB)
GLOBL ·libc_writev_trampoline_addr(SB), RODATA, $4
DATA ·libc_writev_trampoline_addr(SB)/4, $libc_writev_trampoline<>(SB)
TEXT libc_preadv_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_preadv(SB)
GLOBL ·libc_preadv_trampoline_addr(SB), RODATA, $4
DATA ·libc_preadv_trampoline_addr(SB)/4, $libc_preadv_trampoline<>(SB)
TEXT libc_pwritev_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_pwritev(SB)
GLOBL ·libc_pwritev_trampoline_addr(SB), RODATA, $4
DATA ·libc_pwritev_trampoline_addr(SB)/4, $libc_pwritev_trampoline<>(SB)
TEXT libc_read_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_read(SB)
GLOBL ·libc_read_trampoline_addr(SB), RODATA, $4
+84
View File
@@ -1633,6 +1633,90 @@ var libc_pwrite_trampoline_addr uintptr
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func readv(fd int, iovecs []Iovec) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovecs) > 0 {
_p0 = unsafe.Pointer(&iovecs[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall(libc_readv_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_readv_trampoline_addr uintptr
//go:cgo_import_dynamic libc_readv readv "libc.so"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func writev(fd int, iovecs []Iovec) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovecs) > 0 {
_p0 = unsafe.Pointer(&iovecs[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall(libc_writev_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_writev_trampoline_addr uintptr
//go:cgo_import_dynamic libc_writev writev "libc.so"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func preadv(fd int, iovecs []Iovec, offset int64) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovecs) > 0 {
_p0 = unsafe.Pointer(&iovecs[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall6(libc_preadv_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)), uintptr(offset), 0, 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_preadv_trampoline_addr uintptr
//go:cgo_import_dynamic libc_preadv preadv "libc.so"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func pwritev(fd int, iovecs []Iovec, offset int64) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovecs) > 0 {
_p0 = unsafe.Pointer(&iovecs[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall6(libc_pwritev_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)), uintptr(offset), 0, 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_pwritev_trampoline_addr uintptr
//go:cgo_import_dynamic libc_pwritev pwritev "libc.so"
// 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 {
+20
View File
@@ -498,6 +498,26 @@ TEXT libc_pwrite_trampoline<>(SB),NOSPLIT,$0-0
GLOBL ·libc_pwrite_trampoline_addr(SB), RODATA, $8
DATA ·libc_pwrite_trampoline_addr(SB)/8, $libc_pwrite_trampoline<>(SB)
TEXT libc_readv_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_readv(SB)
GLOBL ·libc_readv_trampoline_addr(SB), RODATA, $8
DATA ·libc_readv_trampoline_addr(SB)/8, $libc_readv_trampoline<>(SB)
TEXT libc_writev_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_writev(SB)
GLOBL ·libc_writev_trampoline_addr(SB), RODATA, $8
DATA ·libc_writev_trampoline_addr(SB)/8, $libc_writev_trampoline<>(SB)
TEXT libc_preadv_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_preadv(SB)
GLOBL ·libc_preadv_trampoline_addr(SB), RODATA, $8
DATA ·libc_preadv_trampoline_addr(SB)/8, $libc_preadv_trampoline<>(SB)
TEXT libc_pwritev_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_pwritev(SB)
GLOBL ·libc_pwritev_trampoline_addr(SB), RODATA, $8
DATA ·libc_pwritev_trampoline_addr(SB)/8, $libc_pwritev_trampoline<>(SB)
TEXT libc_read_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_read(SB)
GLOBL ·libc_read_trampoline_addr(SB), RODATA, $8
+84
View File
@@ -1633,6 +1633,90 @@ var libc_pwrite_trampoline_addr uintptr
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func readv(fd int, iovecs []Iovec) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovecs) > 0 {
_p0 = unsafe.Pointer(&iovecs[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall(libc_readv_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_readv_trampoline_addr uintptr
//go:cgo_import_dynamic libc_readv readv "libc.so"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func writev(fd int, iovecs []Iovec) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovecs) > 0 {
_p0 = unsafe.Pointer(&iovecs[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall(libc_writev_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_writev_trampoline_addr uintptr
//go:cgo_import_dynamic libc_writev writev "libc.so"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func preadv(fd int, iovecs []Iovec, offset int64) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovecs) > 0 {
_p0 = unsafe.Pointer(&iovecs[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall6(libc_preadv_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)), 0, uintptr(offset), uintptr(offset>>32))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_preadv_trampoline_addr uintptr
//go:cgo_import_dynamic libc_preadv preadv "libc.so"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func pwritev(fd int, iovecs []Iovec, offset int64) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovecs) > 0 {
_p0 = unsafe.Pointer(&iovecs[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall6(libc_pwritev_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)), 0, uintptr(offset), uintptr(offset>>32))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_pwritev_trampoline_addr uintptr
//go:cgo_import_dynamic libc_pwritev pwritev "libc.so"
// 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 {
+20
View File
@@ -498,6 +498,26 @@ TEXT libc_pwrite_trampoline<>(SB),NOSPLIT,$0-0
GLOBL ·libc_pwrite_trampoline_addr(SB), RODATA, $4
DATA ·libc_pwrite_trampoline_addr(SB)/4, $libc_pwrite_trampoline<>(SB)
TEXT libc_readv_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_readv(SB)
GLOBL ·libc_readv_trampoline_addr(SB), RODATA, $4
DATA ·libc_readv_trampoline_addr(SB)/4, $libc_readv_trampoline<>(SB)
TEXT libc_writev_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_writev(SB)
GLOBL ·libc_writev_trampoline_addr(SB), RODATA, $4
DATA ·libc_writev_trampoline_addr(SB)/4, $libc_writev_trampoline<>(SB)
TEXT libc_preadv_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_preadv(SB)
GLOBL ·libc_preadv_trampoline_addr(SB), RODATA, $4
DATA ·libc_preadv_trampoline_addr(SB)/4, $libc_preadv_trampoline<>(SB)
TEXT libc_pwritev_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_pwritev(SB)
GLOBL ·libc_pwritev_trampoline_addr(SB), RODATA, $4
DATA ·libc_pwritev_trampoline_addr(SB)/4, $libc_pwritev_trampoline<>(SB)
TEXT libc_read_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_read(SB)
GLOBL ·libc_read_trampoline_addr(SB), RODATA, $4
+84
View File
@@ -1633,6 +1633,90 @@ var libc_pwrite_trampoline_addr uintptr
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func readv(fd int, iovecs []Iovec) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovecs) > 0 {
_p0 = unsafe.Pointer(&iovecs[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall(libc_readv_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_readv_trampoline_addr uintptr
//go:cgo_import_dynamic libc_readv readv "libc.so"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func writev(fd int, iovecs []Iovec) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovecs) > 0 {
_p0 = unsafe.Pointer(&iovecs[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall(libc_writev_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_writev_trampoline_addr uintptr
//go:cgo_import_dynamic libc_writev writev "libc.so"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func preadv(fd int, iovecs []Iovec, offset int64) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovecs) > 0 {
_p0 = unsafe.Pointer(&iovecs[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall6(libc_preadv_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)), uintptr(offset), 0, 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_preadv_trampoline_addr uintptr
//go:cgo_import_dynamic libc_preadv preadv "libc.so"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func pwritev(fd int, iovecs []Iovec, offset int64) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovecs) > 0 {
_p0 = unsafe.Pointer(&iovecs[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall6(libc_pwritev_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)), uintptr(offset), 0, 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_pwritev_trampoline_addr uintptr
//go:cgo_import_dynamic libc_pwritev pwritev "libc.so"
// 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 {
+20
View File
@@ -498,6 +498,26 @@ TEXT libc_pwrite_trampoline<>(SB),NOSPLIT,$0-0
GLOBL ·libc_pwrite_trampoline_addr(SB), RODATA, $8
DATA ·libc_pwrite_trampoline_addr(SB)/8, $libc_pwrite_trampoline<>(SB)
TEXT libc_readv_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_readv(SB)
GLOBL ·libc_readv_trampoline_addr(SB), RODATA, $8
DATA ·libc_readv_trampoline_addr(SB)/8, $libc_readv_trampoline<>(SB)
TEXT libc_writev_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_writev(SB)
GLOBL ·libc_writev_trampoline_addr(SB), RODATA, $8
DATA ·libc_writev_trampoline_addr(SB)/8, $libc_writev_trampoline<>(SB)
TEXT libc_preadv_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_preadv(SB)
GLOBL ·libc_preadv_trampoline_addr(SB), RODATA, $8
DATA ·libc_preadv_trampoline_addr(SB)/8, $libc_preadv_trampoline<>(SB)
TEXT libc_pwritev_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_pwritev(SB)
GLOBL ·libc_pwritev_trampoline_addr(SB), RODATA, $8
DATA ·libc_pwritev_trampoline_addr(SB)/8, $libc_pwritev_trampoline<>(SB)
TEXT libc_read_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_read(SB)
GLOBL ·libc_read_trampoline_addr(SB), RODATA, $8
+84
View File
@@ -1633,6 +1633,90 @@ var libc_pwrite_trampoline_addr uintptr
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func readv(fd int, iovecs []Iovec) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovecs) > 0 {
_p0 = unsafe.Pointer(&iovecs[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall(libc_readv_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_readv_trampoline_addr uintptr
//go:cgo_import_dynamic libc_readv readv "libc.so"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func writev(fd int, iovecs []Iovec) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovecs) > 0 {
_p0 = unsafe.Pointer(&iovecs[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall(libc_writev_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_writev_trampoline_addr uintptr
//go:cgo_import_dynamic libc_writev writev "libc.so"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func preadv(fd int, iovecs []Iovec, offset int64) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovecs) > 0 {
_p0 = unsafe.Pointer(&iovecs[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall6(libc_preadv_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)), uintptr(offset), 0, 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_preadv_trampoline_addr uintptr
//go:cgo_import_dynamic libc_preadv preadv "libc.so"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func pwritev(fd int, iovecs []Iovec, offset int64) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovecs) > 0 {
_p0 = unsafe.Pointer(&iovecs[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall6(libc_pwritev_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)), uintptr(offset), 0, 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_pwritev_trampoline_addr uintptr
//go:cgo_import_dynamic libc_pwritev pwritev "libc.so"
// 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 {
+20
View File
@@ -498,6 +498,26 @@ TEXT libc_pwrite_trampoline<>(SB),NOSPLIT,$0-0
GLOBL ·libc_pwrite_trampoline_addr(SB), RODATA, $8
DATA ·libc_pwrite_trampoline_addr(SB)/8, $libc_pwrite_trampoline<>(SB)
TEXT libc_readv_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_readv(SB)
GLOBL ·libc_readv_trampoline_addr(SB), RODATA, $8
DATA ·libc_readv_trampoline_addr(SB)/8, $libc_readv_trampoline<>(SB)
TEXT libc_writev_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_writev(SB)
GLOBL ·libc_writev_trampoline_addr(SB), RODATA, $8
DATA ·libc_writev_trampoline_addr(SB)/8, $libc_writev_trampoline<>(SB)
TEXT libc_preadv_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_preadv(SB)
GLOBL ·libc_preadv_trampoline_addr(SB), RODATA, $8
DATA ·libc_preadv_trampoline_addr(SB)/8, $libc_preadv_trampoline<>(SB)
TEXT libc_pwritev_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_pwritev(SB)
GLOBL ·libc_pwritev_trampoline_addr(SB), RODATA, $8
DATA ·libc_pwritev_trampoline_addr(SB)/8, $libc_pwritev_trampoline<>(SB)
TEXT libc_read_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_read(SB)
GLOBL ·libc_read_trampoline_addr(SB), RODATA, $8
+84
View File
@@ -1633,6 +1633,90 @@ var libc_pwrite_trampoline_addr uintptr
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func readv(fd int, iovecs []Iovec) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovecs) > 0 {
_p0 = unsafe.Pointer(&iovecs[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall(libc_readv_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_readv_trampoline_addr uintptr
//go:cgo_import_dynamic libc_readv readv "libc.so"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func writev(fd int, iovecs []Iovec) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovecs) > 0 {
_p0 = unsafe.Pointer(&iovecs[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall(libc_writev_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_writev_trampoline_addr uintptr
//go:cgo_import_dynamic libc_writev writev "libc.so"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func preadv(fd int, iovecs []Iovec, offset int64) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovecs) > 0 {
_p0 = unsafe.Pointer(&iovecs[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall6(libc_preadv_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)), uintptr(offset), 0, 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_preadv_trampoline_addr uintptr
//go:cgo_import_dynamic libc_preadv preadv "libc.so"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func pwritev(fd int, iovecs []Iovec, offset int64) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovecs) > 0 {
_p0 = unsafe.Pointer(&iovecs[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall6(libc_pwritev_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)), uintptr(offset), 0, 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_pwritev_trampoline_addr uintptr
//go:cgo_import_dynamic libc_pwritev pwritev "libc.so"
// 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 {
+24
View File
@@ -597,6 +597,30 @@ TEXT libc_pwrite_trampoline<>(SB),NOSPLIT,$0-0
GLOBL ·libc_pwrite_trampoline_addr(SB), RODATA, $8
DATA ·libc_pwrite_trampoline_addr(SB)/8, $libc_pwrite_trampoline<>(SB)
TEXT libc_readv_trampoline<>(SB),NOSPLIT,$0-0
CALL libc_readv(SB)
RET
GLOBL ·libc_readv_trampoline_addr(SB), RODATA, $8
DATA ·libc_readv_trampoline_addr(SB)/8, $libc_readv_trampoline<>(SB)
TEXT libc_writev_trampoline<>(SB),NOSPLIT,$0-0
CALL libc_writev(SB)
RET
GLOBL ·libc_writev_trampoline_addr(SB), RODATA, $8
DATA ·libc_writev_trampoline_addr(SB)/8, $libc_writev_trampoline<>(SB)
TEXT libc_preadv_trampoline<>(SB),NOSPLIT,$0-0
CALL libc_preadv(SB)
RET
GLOBL ·libc_preadv_trampoline_addr(SB), RODATA, $8
DATA ·libc_preadv_trampoline_addr(SB)/8, $libc_preadv_trampoline<>(SB)
TEXT libc_pwritev_trampoline<>(SB),NOSPLIT,$0-0
CALL libc_pwritev(SB)
RET
GLOBL ·libc_pwritev_trampoline_addr(SB), RODATA, $8
DATA ·libc_pwritev_trampoline_addr(SB)/8, $libc_pwritev_trampoline<>(SB)
TEXT libc_read_trampoline<>(SB),NOSPLIT,$0-0
CALL libc_read(SB)
RET
+84
View File
@@ -1633,6 +1633,90 @@ var libc_pwrite_trampoline_addr uintptr
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func readv(fd int, iovecs []Iovec) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovecs) > 0 {
_p0 = unsafe.Pointer(&iovecs[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall(libc_readv_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_readv_trampoline_addr uintptr
//go:cgo_import_dynamic libc_readv readv "libc.so"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func writev(fd int, iovecs []Iovec) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovecs) > 0 {
_p0 = unsafe.Pointer(&iovecs[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall(libc_writev_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_writev_trampoline_addr uintptr
//go:cgo_import_dynamic libc_writev writev "libc.so"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func preadv(fd int, iovecs []Iovec, offset int64) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovecs) > 0 {
_p0 = unsafe.Pointer(&iovecs[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall6(libc_preadv_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)), uintptr(offset), 0, 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_preadv_trampoline_addr uintptr
//go:cgo_import_dynamic libc_preadv preadv "libc.so"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func pwritev(fd int, iovecs []Iovec, offset int64) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovecs) > 0 {
_p0 = unsafe.Pointer(&iovecs[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall_syscall6(libc_pwritev_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)), uintptr(offset), 0, 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
var libc_pwritev_trampoline_addr uintptr
//go:cgo_import_dynamic libc_pwritev pwritev "libc.so"
// 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 {
+20
View File
@@ -498,6 +498,26 @@ TEXT libc_pwrite_trampoline<>(SB),NOSPLIT,$0-0
GLOBL ·libc_pwrite_trampoline_addr(SB), RODATA, $8
DATA ·libc_pwrite_trampoline_addr(SB)/8, $libc_pwrite_trampoline<>(SB)
TEXT libc_readv_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_readv(SB)
GLOBL ·libc_readv_trampoline_addr(SB), RODATA, $8
DATA ·libc_readv_trampoline_addr(SB)/8, $libc_readv_trampoline<>(SB)
TEXT libc_writev_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_writev(SB)
GLOBL ·libc_writev_trampoline_addr(SB), RODATA, $8
DATA ·libc_writev_trampoline_addr(SB)/8, $libc_writev_trampoline<>(SB)
TEXT libc_preadv_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_preadv(SB)
GLOBL ·libc_preadv_trampoline_addr(SB), RODATA, $8
DATA ·libc_preadv_trampoline_addr(SB)/8, $libc_preadv_trampoline<>(SB)
TEXT libc_pwritev_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_pwritev(SB)
GLOBL ·libc_pwritev_trampoline_addr(SB), RODATA, $8
DATA ·libc_pwritev_trampoline_addr(SB)/8, $libc_pwritev_trampoline<>(SB)
TEXT libc_read_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_read(SB)
GLOBL ·libc_read_trampoline_addr(SB), RODATA, $8
+4
View File
@@ -463,4 +463,8 @@ const (
SYS_LISTXATTRAT = 465
SYS_REMOVEXATTRAT = 466
SYS_OPEN_TREE_ATTR = 467
SYS_FILE_GETATTR = 468
SYS_FILE_SETATTR = 469
SYS_LISTNS = 470
SYS_RSEQ_SLICE_YIELD = 471
)
+5
View File
@@ -342,6 +342,7 @@ const (
SYS_IO_PGETEVENTS = 333
SYS_RSEQ = 334
SYS_URETPROBE = 335
SYS_UPROBE = 336
SYS_PIDFD_SEND_SIGNAL = 424
SYS_IO_URING_SETUP = 425
SYS_IO_URING_ENTER = 426
@@ -386,4 +387,8 @@ const (
SYS_LISTXATTRAT = 465
SYS_REMOVEXATTRAT = 466
SYS_OPEN_TREE_ATTR = 467
SYS_FILE_GETATTR = 468
SYS_FILE_SETATTR = 469
SYS_LISTNS = 470
SYS_RSEQ_SLICE_YIELD = 471
)
+4
View File
@@ -427,4 +427,8 @@ const (
SYS_LISTXATTRAT = 465
SYS_REMOVEXATTRAT = 466
SYS_OPEN_TREE_ATTR = 467
SYS_FILE_GETATTR = 468
SYS_FILE_SETATTR = 469
SYS_LISTNS = 470
SYS_RSEQ_SLICE_YIELD = 471
)
+4
View File
@@ -330,4 +330,8 @@ const (
SYS_LISTXATTRAT = 465
SYS_REMOVEXATTRAT = 466
SYS_OPEN_TREE_ATTR = 467
SYS_FILE_GETATTR = 468
SYS_FILE_SETATTR = 469
SYS_LISTNS = 470
SYS_RSEQ_SLICE_YIELD = 471
)
+5
View File
@@ -306,6 +306,7 @@ const (
SYS_LANDLOCK_CREATE_RULESET = 444
SYS_LANDLOCK_ADD_RULE = 445
SYS_LANDLOCK_RESTRICT_SELF = 446
SYS_MEMFD_SECRET = 447
SYS_PROCESS_MRELEASE = 448
SYS_FUTEX_WAITV = 449
SYS_SET_MEMPOLICY_HOME_NODE = 450
@@ -326,4 +327,8 @@ const (
SYS_LISTXATTRAT = 465
SYS_REMOVEXATTRAT = 466
SYS_OPEN_TREE_ATTR = 467
SYS_FILE_GETATTR = 468
SYS_FILE_SETATTR = 469
SYS_LISTNS = 470
SYS_RSEQ_SLICE_YIELD = 471
)
+4
View File
@@ -447,4 +447,8 @@ const (
SYS_LISTXATTRAT = 4465
SYS_REMOVEXATTRAT = 4466
SYS_OPEN_TREE_ATTR = 4467
SYS_FILE_GETATTR = 4468
SYS_FILE_SETATTR = 4469
SYS_LISTNS = 4470
SYS_RSEQ_SLICE_YIELD = 4471
)
+4
View File
@@ -377,4 +377,8 @@ const (
SYS_LISTXATTRAT = 5465
SYS_REMOVEXATTRAT = 5466
SYS_OPEN_TREE_ATTR = 5467
SYS_FILE_GETATTR = 5468
SYS_FILE_SETATTR = 5469
SYS_LISTNS = 5470
SYS_RSEQ_SLICE_YIELD = 5471
)
+4
View File
@@ -377,4 +377,8 @@ const (
SYS_LISTXATTRAT = 5465
SYS_REMOVEXATTRAT = 5466
SYS_OPEN_TREE_ATTR = 5467
SYS_FILE_GETATTR = 5468
SYS_FILE_SETATTR = 5469
SYS_LISTNS = 5470
SYS_RSEQ_SLICE_YIELD = 5471
)
+4
View File
@@ -447,4 +447,8 @@ const (
SYS_LISTXATTRAT = 4465
SYS_REMOVEXATTRAT = 4466
SYS_OPEN_TREE_ATTR = 4467
SYS_FILE_GETATTR = 4468
SYS_FILE_SETATTR = 4469
SYS_LISTNS = 4470
SYS_RSEQ_SLICE_YIELD = 4471
)
+4
View File
@@ -454,4 +454,8 @@ const (
SYS_LISTXATTRAT = 465
SYS_REMOVEXATTRAT = 466
SYS_OPEN_TREE_ATTR = 467
SYS_FILE_GETATTR = 468
SYS_FILE_SETATTR = 469
SYS_LISTNS = 470
SYS_RSEQ_SLICE_YIELD = 471
)
+4
View File
@@ -426,4 +426,8 @@ const (
SYS_LISTXATTRAT = 465
SYS_REMOVEXATTRAT = 466
SYS_OPEN_TREE_ATTR = 467
SYS_FILE_GETATTR = 468
SYS_FILE_SETATTR = 469
SYS_LISTNS = 470
SYS_RSEQ_SLICE_YIELD = 471
)
+4
View File
@@ -426,4 +426,8 @@ const (
SYS_LISTXATTRAT = 465
SYS_REMOVEXATTRAT = 466
SYS_OPEN_TREE_ATTR = 467
SYS_FILE_GETATTR = 468
SYS_FILE_SETATTR = 469
SYS_LISTNS = 470
SYS_RSEQ_SLICE_YIELD = 471
)
+4
View File
@@ -331,4 +331,8 @@ const (
SYS_LISTXATTRAT = 465
SYS_REMOVEXATTRAT = 466
SYS_OPEN_TREE_ATTR = 467
SYS_FILE_GETATTR = 468
SYS_FILE_SETATTR = 469
SYS_LISTNS = 470
SYS_RSEQ_SLICE_YIELD = 471
)
+4
View File
@@ -392,4 +392,8 @@ const (
SYS_LISTXATTRAT = 465
SYS_REMOVEXATTRAT = 466
SYS_OPEN_TREE_ATTR = 467
SYS_FILE_GETATTR = 468
SYS_FILE_SETATTR = 469
SYS_LISTNS = 470
SYS_RSEQ_SLICE_YIELD = 471
)
+5
View File
@@ -374,6 +374,7 @@ const (
SYS_FSMOUNT = 432
SYS_FSPICK = 433
SYS_PIDFD_OPEN = 434
SYS_CLONE3 = 435
SYS_CLOSE_RANGE = 436
SYS_OPENAT2 = 437
SYS_PIDFD_GETFD = 438
@@ -405,4 +406,8 @@ const (
SYS_LISTXATTRAT = 465
SYS_REMOVEXATTRAT = 466
SYS_OPEN_TREE_ATTR = 467
SYS_FILE_GETATTR = 468
SYS_FILE_SETATTR = 469
SYS_LISTNS = 470
SYS_RSEQ_SLICE_YIELD = 471
)
+231 -121
View File
@@ -18,6 +18,11 @@ type (
_C_long_long int64
)
type KernelTimespec struct {
Sec int64
Nsec int64
}
type ItimerSpec struct {
Interval Timespec
Value Timespec
@@ -521,6 +526,14 @@ type TCPInfo struct {
Total_rto uint16
Total_rto_recoveries uint16
Total_rto_time uint32
Received_ce uint32
Delivered_e1_bytes uint32
Delivered_e0_bytes uint32
Delivered_ce_bytes uint32
Received_e1_bytes uint32
Received_e0_bytes uint32
Received_ce_bytes uint32
_ [4]byte
}
type TCPVegasInfo struct {
@@ -586,117 +599,122 @@ const (
SizeofIPv6MTUInfo = 0x20
SizeofICMPv6Filter = 0x20
SizeofUcred = 0xc
SizeofTCPInfo = 0xf8
SizeofTCPInfo = 0x118
SizeofTCPCCInfo = 0x14
SizeofCanFilter = 0x8
SizeofTCPRepairOpt = 0x8
)
const (
NDA_UNSPEC = 0x0
NDA_DST = 0x1
NDA_LLADDR = 0x2
NDA_CACHEINFO = 0x3
NDA_PROBES = 0x4
NDA_VLAN = 0x5
NDA_PORT = 0x6
NDA_VNI = 0x7
NDA_IFINDEX = 0x8
NDA_MASTER = 0x9
NDA_LINK_NETNSID = 0xa
NDA_SRC_VNI = 0xb
NTF_USE = 0x1
NTF_SELF = 0x2
NTF_MASTER = 0x4
NTF_PROXY = 0x8
NTF_EXT_LEARNED = 0x10
NTF_OFFLOADED = 0x20
NTF_ROUTER = 0x80
NUD_INCOMPLETE = 0x1
NUD_REACHABLE = 0x2
NUD_STALE = 0x4
NUD_DELAY = 0x8
NUD_PROBE = 0x10
NUD_FAILED = 0x20
NUD_NOARP = 0x40
NUD_PERMANENT = 0x80
NUD_NONE = 0x0
IFA_UNSPEC = 0x0
IFA_ADDRESS = 0x1
IFA_LOCAL = 0x2
IFA_LABEL = 0x3
IFA_BROADCAST = 0x4
IFA_ANYCAST = 0x5
IFA_CACHEINFO = 0x6
IFA_MULTICAST = 0x7
IFA_FLAGS = 0x8
IFA_RT_PRIORITY = 0x9
IFA_TARGET_NETNSID = 0xa
IFAL_LABEL = 0x2
IFAL_ADDRESS = 0x1
RT_SCOPE_UNIVERSE = 0x0
RT_SCOPE_SITE = 0xc8
RT_SCOPE_LINK = 0xfd
RT_SCOPE_HOST = 0xfe
RT_SCOPE_NOWHERE = 0xff
RT_TABLE_UNSPEC = 0x0
RT_TABLE_COMPAT = 0xfc
RT_TABLE_DEFAULT = 0xfd
RT_TABLE_MAIN = 0xfe
RT_TABLE_LOCAL = 0xff
RT_TABLE_MAX = 0xffffffff
RTA_UNSPEC = 0x0
RTA_DST = 0x1
RTA_SRC = 0x2
RTA_IIF = 0x3
RTA_OIF = 0x4
RTA_GATEWAY = 0x5
RTA_PRIORITY = 0x6
RTA_PREFSRC = 0x7
RTA_METRICS = 0x8
RTA_MULTIPATH = 0x9
RTA_FLOW = 0xb
RTA_CACHEINFO = 0xc
RTA_TABLE = 0xf
RTA_MARK = 0x10
RTA_MFC_STATS = 0x11
RTA_VIA = 0x12
RTA_NEWDST = 0x13
RTA_PREF = 0x14
RTA_ENCAP_TYPE = 0x15
RTA_ENCAP = 0x16
RTA_EXPIRES = 0x17
RTA_PAD = 0x18
RTA_UID = 0x19
RTA_TTL_PROPAGATE = 0x1a
RTA_IP_PROTO = 0x1b
RTA_SPORT = 0x1c
RTA_DPORT = 0x1d
RTN_UNSPEC = 0x0
RTN_UNICAST = 0x1
RTN_LOCAL = 0x2
RTN_BROADCAST = 0x3
RTN_ANYCAST = 0x4
RTN_MULTICAST = 0x5
RTN_BLACKHOLE = 0x6
RTN_UNREACHABLE = 0x7
RTN_PROHIBIT = 0x8
RTN_THROW = 0x9
RTN_NAT = 0xa
RTN_XRESOLVE = 0xb
SizeofNlMsghdr = 0x10
SizeofNlMsgerr = 0x14
SizeofRtGenmsg = 0x1
SizeofNlAttr = 0x4
SizeofRtAttr = 0x4
SizeofIfInfomsg = 0x10
SizeofIfAddrmsg = 0x8
SizeofIfAddrlblmsg = 0xc
SizeofIfaCacheinfo = 0x10
SizeofRtMsg = 0xc
SizeofRtNexthop = 0x8
SizeofNdUseroptmsg = 0x10
SizeofNdMsg = 0xc
NDA_UNSPEC = 0x0
NDA_DST = 0x1
NDA_LLADDR = 0x2
NDA_CACHEINFO = 0x3
NDA_PROBES = 0x4
NDA_VLAN = 0x5
NDA_PORT = 0x6
NDA_VNI = 0x7
NDA_IFINDEX = 0x8
NDA_MASTER = 0x9
NDA_LINK_NETNSID = 0xa
NDA_SRC_VNI = 0xb
NTF_USE = 0x1
NTF_SELF = 0x2
NTF_MASTER = 0x4
NTF_PROXY = 0x8
NTF_EXT_LEARNED = 0x10
NTF_OFFLOADED = 0x20
NTF_ROUTER = 0x80
NUD_INCOMPLETE = 0x1
NUD_REACHABLE = 0x2
NUD_STALE = 0x4
NUD_DELAY = 0x8
NUD_PROBE = 0x10
NUD_FAILED = 0x20
NUD_NOARP = 0x40
NUD_PERMANENT = 0x80
NUD_NONE = 0x0
IFA_UNSPEC = 0x0
IFA_ADDRESS = 0x1
IFA_LOCAL = 0x2
IFA_LABEL = 0x3
IFA_BROADCAST = 0x4
IFA_ANYCAST = 0x5
IFA_CACHEINFO = 0x6
IFA_MULTICAST = 0x7
IFA_FLAGS = 0x8
IFA_RT_PRIORITY = 0x9
IFA_TARGET_NETNSID = 0xa
IFAL_LABEL = 0x2
IFAL_ADDRESS = 0x1
RT_SCOPE_UNIVERSE = 0x0
RT_SCOPE_SITE = 0xc8
RT_SCOPE_LINK = 0xfd
RT_SCOPE_HOST = 0xfe
RT_SCOPE_NOWHERE = 0xff
RT_TABLE_UNSPEC = 0x0
RT_TABLE_COMPAT = 0xfc
RT_TABLE_DEFAULT = 0xfd
RT_TABLE_MAIN = 0xfe
RT_TABLE_LOCAL = 0xff
RT_TABLE_MAX = 0xffffffff
RTA_UNSPEC = 0x0
RTA_DST = 0x1
RTA_SRC = 0x2
RTA_IIF = 0x3
RTA_OIF = 0x4
RTA_GATEWAY = 0x5
RTA_PRIORITY = 0x6
RTA_PREFSRC = 0x7
RTA_METRICS = 0x8
RTA_MULTIPATH = 0x9
RTA_FLOW = 0xb
RTA_CACHEINFO = 0xc
RTA_TABLE = 0xf
RTA_MARK = 0x10
RTA_MFC_STATS = 0x11
RTA_VIA = 0x12
RTA_NEWDST = 0x13
RTA_PREF = 0x14
RTA_ENCAP_TYPE = 0x15
RTA_ENCAP = 0x16
RTA_EXPIRES = 0x17
RTA_PAD = 0x18
RTA_UID = 0x19
RTA_TTL_PROPAGATE = 0x1a
RTA_IP_PROTO = 0x1b
RTA_SPORT = 0x1c
RTA_DPORT = 0x1d
RTN_UNSPEC = 0x0
RTN_UNICAST = 0x1
RTN_LOCAL = 0x2
RTN_BROADCAST = 0x3
RTN_ANYCAST = 0x4
RTN_MULTICAST = 0x5
RTN_BLACKHOLE = 0x6
RTN_UNREACHABLE = 0x7
RTN_PROHIBIT = 0x8
RTN_THROW = 0x9
RTN_NAT = 0xa
RTN_XRESOLVE = 0xb
PREFIX_UNSPEC = 0x0
PREFIX_ADDRESS = 0x1
PREFIX_CACHEINFO = 0x2
SizeofNlMsghdr = 0x10
SizeofNlMsgerr = 0x14
SizeofRtGenmsg = 0x1
SizeofNlAttr = 0x4
SizeofRtAttr = 0x4
SizeofIfInfomsg = 0x10
SizeofPrefixmsg = 0xc
SizeofPrefixCacheinfo = 0x8
SizeofIfAddrmsg = 0x8
SizeofIfAddrlblmsg = 0xc
SizeofIfaCacheinfo = 0x10
SizeofRtMsg = 0xc
SizeofRtNexthop = 0x8
SizeofNdUseroptmsg = 0x10
SizeofNdMsg = 0xc
)
type NlMsghdr struct {
@@ -735,6 +753,22 @@ type IfInfomsg struct {
Change uint32
}
type Prefixmsg struct {
Family uint8
Pad1 uint8
Pad2 uint16
Ifindex int32
Type uint8
Len uint8
Flags uint8
Pad3 uint8
}
type PrefixCacheinfo struct {
Preferred_time uint32
Valid_time uint32
}
type IfAddrmsg struct {
Family uint8
Prefixlen uint8
@@ -1303,7 +1337,7 @@ const (
PERF_RECORD_CGROUP = 0x13
PERF_RECORD_TEXT_POKE = 0x14
PERF_RECORD_AUX_OUTPUT_HW_ID = 0x15
PERF_RECORD_MAX = 0x16
PERF_RECORD_MAX = 0x17
PERF_RECORD_KSYMBOL_TYPE_UNKNOWN = 0x0
PERF_RECORD_KSYMBOL_TYPE_BPF = 0x1
PERF_RECORD_KSYMBOL_TYPE_OOL = 0x2
@@ -3545,7 +3579,7 @@ const (
DEVLINK_ATTR_LINECARD_SUPPORTED_TYPES = 0xae
DEVLINK_ATTR_NESTED_DEVLINK = 0xaf
DEVLINK_ATTR_SELFTESTS = 0xb0
DEVLINK_ATTR_MAX = 0xb3
DEVLINK_ATTR_MAX = 0xb7
DEVLINK_DPIPE_FIELD_MAPPING_TYPE_NONE = 0x0
DEVLINK_DPIPE_FIELD_MAPPING_TYPE_IFINDEX = 0x1
DEVLINK_DPIPE_MATCH_TYPE_FIELD_EXACT = 0x0
@@ -3867,7 +3901,7 @@ const (
ETHTOOL_MSG_PHY_GET = 0x2d
ETHTOOL_MSG_TSCONFIG_GET = 0x2e
ETHTOOL_MSG_TSCONFIG_SET = 0x2f
ETHTOOL_MSG_USER_MAX = 0x2f
ETHTOOL_MSG_USER_MAX = 0x33
ETHTOOL_MSG_KERNEL_NONE = 0x0
ETHTOOL_MSG_STRSET_GET_REPLY = 0x1
ETHTOOL_MSG_LINKINFO_GET_REPLY = 0x2
@@ -3917,7 +3951,7 @@ const (
ETHTOOL_MSG_PHY_NTF = 0x2e
ETHTOOL_MSG_TSCONFIG_GET_REPLY = 0x2f
ETHTOOL_MSG_TSCONFIG_SET_REPLY = 0x30
ETHTOOL_MSG_KERNEL_MAX = 0x30
ETHTOOL_MSG_KERNEL_MAX = 0x36
ETHTOOL_FLAG_COMPACT_BITSETS = 0x1
ETHTOOL_FLAG_OMIT_REPLY = 0x2
ETHTOOL_FLAG_STATS = 0x4
@@ -4846,7 +4880,7 @@ const (
NL80211_ATTR_MAC_HINT = 0xc8
NL80211_ATTR_MAC_MASK = 0xd7
NL80211_ATTR_MAX_AP_ASSOC_STA = 0xca
NL80211_ATTR_MAX = 0x151
NL80211_ATTR_MAX = 0x15c
NL80211_ATTR_MAX_CRIT_PROT_DURATION = 0xb4
NL80211_ATTR_MAX_CSA_COUNTERS = 0xce
NL80211_ATTR_MAX_HW_TIMESTAMP_PEERS = 0x143
@@ -5061,12 +5095,12 @@ const (
NL80211_ATTR_WOWLAN_TRIGGERS = 0x75
NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED = 0x76
NL80211_ATTR_WPA_VERSIONS = 0x4b
NL80211_AUTHTYPE_AUTOMATIC = 0x8
NL80211_AUTHTYPE_AUTOMATIC = 0x9
NL80211_AUTHTYPE_FILS_PK = 0x7
NL80211_AUTHTYPE_FILS_SK = 0x5
NL80211_AUTHTYPE_FILS_SK_PFS = 0x6
NL80211_AUTHTYPE_FT = 0x2
NL80211_AUTHTYPE_MAX = 0x7
NL80211_AUTHTYPE_MAX = 0x8
NL80211_AUTHTYPE_NETWORK_EAP = 0x3
NL80211_AUTHTYPE_OPEN_SYSTEM = 0x0
NL80211_AUTHTYPE_SAE = 0x4
@@ -5099,7 +5133,7 @@ const (
NL80211_BAND_IFTYPE_ATTR_HE_CAP_PHY = 0x3
NL80211_BAND_IFTYPE_ATTR_HE_CAP_PPE = 0x5
NL80211_BAND_IFTYPE_ATTR_IFTYPES = 0x1
NL80211_BAND_IFTYPE_ATTR_MAX = 0xb
NL80211_BAND_IFTYPE_ATTR_MAX = 0xd
NL80211_BAND_IFTYPE_ATTR_VENDOR_ELEMS = 0x7
NL80211_BAND_LC = 0x5
NL80211_BAND_S1GHZ = 0x4
@@ -5234,7 +5268,7 @@ const (
NL80211_CMD_LEAVE_MESH = 0x45
NL80211_CMD_LEAVE_OCB = 0x6d
NL80211_CMD_LINKS_REMOVED = 0x9a
NL80211_CMD_MAX = 0x9d
NL80211_CMD_MAX = 0x9f
NL80211_CMD_MICHAEL_MIC_FAILURE = 0x29
NL80211_CMD_MODIFY_LINK_STA = 0x97
NL80211_CMD_NAN_MATCH = 0x78
@@ -5480,7 +5514,7 @@ const (
NL80211_FREQUENCY_ATTR_GO_CONCURRENT = 0xf
NL80211_FREQUENCY_ATTR_INDOOR_ONLY = 0xe
NL80211_FREQUENCY_ATTR_IR_CONCURRENT = 0xf
NL80211_FREQUENCY_ATTR_MAX = 0x22
NL80211_FREQUENCY_ATTR_MAX = 0x27
NL80211_FREQUENCY_ATTR_MAX_TX_POWER = 0x6
NL80211_FREQUENCY_ATTR_NO_10MHZ = 0x11
NL80211_FREQUENCY_ATTR_NO_160MHZ = 0xc
@@ -5745,7 +5779,7 @@ const (
NL80211_PMSR_FTM_CAPA_ATTR_ASAP = 0x1
NL80211_PMSR_FTM_CAPA_ATTR_BANDWIDTHS = 0x6
NL80211_PMSR_FTM_CAPA_ATTR_MAX_BURSTS_EXPONENT = 0x7
NL80211_PMSR_FTM_CAPA_ATTR_MAX = 0xa
NL80211_PMSR_FTM_CAPA_ATTR_MAX = 0x12
NL80211_PMSR_FTM_CAPA_ATTR_MAX_FTMS_PER_BURST = 0x8
NL80211_PMSR_FTM_CAPA_ATTR_NON_ASAP = 0x2
NL80211_PMSR_FTM_CAPA_ATTR_NON_TRIGGER_BASED = 0xa
@@ -5767,7 +5801,7 @@ const (
NL80211_PMSR_FTM_REQ_ATTR_BURST_PERIOD = 0x4
NL80211_PMSR_FTM_REQ_ATTR_FTMS_PER_BURST = 0x6
NL80211_PMSR_FTM_REQ_ATTR_LMR_FEEDBACK = 0xc
NL80211_PMSR_FTM_REQ_ATTR_MAX = 0xd
NL80211_PMSR_FTM_REQ_ATTR_MAX = 0xe
NL80211_PMSR_FTM_REQ_ATTR_NON_TRIGGER_BASED = 0xb
NL80211_PMSR_FTM_REQ_ATTR_NUM_BURSTS_EXP = 0x3
NL80211_PMSR_FTM_REQ_ATTR_NUM_FTMR_RETRIES = 0x7
@@ -5785,7 +5819,7 @@ const (
NL80211_PMSR_FTM_RESP_ATTR_FAIL_REASON = 0x1
NL80211_PMSR_FTM_RESP_ATTR_FTMS_PER_BURST = 0x8
NL80211_PMSR_FTM_RESP_ATTR_LCI = 0x13
NL80211_PMSR_FTM_RESP_ATTR_MAX = 0x15
NL80211_PMSR_FTM_RESP_ATTR_MAX = 0x16
NL80211_PMSR_FTM_RESP_ATTR_NUM_BURSTS_EXP = 0x6
NL80211_PMSR_FTM_RESP_ATTR_NUM_FTMR_ATTEMPTS = 0x3
NL80211_PMSR_FTM_RESP_ATTR_NUM_FTMR_SUCCESSES = 0x4
@@ -5892,7 +5926,7 @@ const (
NL80211_RATE_INFO_HE_RU_ALLOC_52 = 0x1
NL80211_RATE_INFO_HE_RU_ALLOC_996 = 0x5
NL80211_RATE_INFO_HE_RU_ALLOC = 0x11
NL80211_RATE_INFO_MAX = 0x1d
NL80211_RATE_INFO_MAX = 0x20
NL80211_RATE_INFO_MCS = 0x2
NL80211_RATE_INFO_S1G_MCS = 0x17
NL80211_RATE_INFO_S1G_NSS = 0x18
@@ -6146,7 +6180,7 @@ const (
NL80211_TXRATE_HT = 0x2
NL80211_TXRATE_LEGACY = 0x1
NL80211_TX_RATE_LIMITED = 0x1
NL80211_TXRATE_MAX = 0x7
NL80211_TXRATE_MAX = 0xa
NL80211_TXRATE_MCS = 0x2
NL80211_TXRATE_VHT = 0x3
NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_INT = 0x1
@@ -6162,7 +6196,7 @@ const (
NL80211_WIPHY_RADIO_ATTR_FREQ_RANGE = 0x2
NL80211_WIPHY_RADIO_ATTR_INDEX = 0x1
NL80211_WIPHY_RADIO_ATTR_INTERFACE_COMBINATION = 0x3
NL80211_WIPHY_RADIO_ATTR_MAX = 0x4
NL80211_WIPHY_RADIO_ATTR_MAX = 0x5
NL80211_WIPHY_RADIO_FREQ_ATTR_END = 0x2
NL80211_WIPHY_RADIO_FREQ_ATTR_MAX = 0x2
NL80211_WIPHY_RADIO_FREQ_ATTR_START = 0x1
@@ -6363,3 +6397,79 @@ const (
MPOL_PREFERRED_MANY = 0x5
MPOL_WEIGHTED_INTERLEAVE = 0x6
)
const (
GPIO_V2_GET_LINEINFO_IOCTL = 0xc100b405
GPIO_V2_GET_LINE_IOCTL = 0xc250b407
GPIO_V2_LINE_GET_VALUES_IOCTL = 0xc010b40e
GPIO_V2_LINE_SET_VALUES_IOCTL = 0xc010b40f
GPIO_V2_GET_LINEINFO_WATCH_IOCTL = 0xc100b406
GPIO_GET_LINEINFO_UNWATCH_IOCTL = 0xc004b40c
)
const (
GPIO_V2_LINE_ATTR_ID_FLAGS = 0x1
GPIO_V2_LINE_ATTR_ID_OUTPUT_VALUES = 0x2
GPIO_V2_LINE_ATTR_ID_DEBOUNCE = 0x3
GPIO_V2_LINE_CHANGED_REQUESTED = 0x1
GPIO_V2_LINE_CHANGED_RELEASED = 0x2
GPIO_V2_LINE_CHANGED_CONFIG = 0x3
GPIO_V2_LINE_EVENT_RISING_EDGE = 0x1
GPIO_V2_LINE_EVENT_FALLING_EDGE = 0x2
)
type GPIOChipInfo struct {
Name [32]byte
Label [32]byte
Lines uint32
}
type GPIOV2LineValues struct {
Bits uint64
Mask uint64
}
type GPIOV2LineAttribute struct {
Id uint32
_ uint32
Flags uint64
}
type GPIOV2LineConfigAttribute struct {
Attr GPIOV2LineAttribute
Mask uint64
}
type GPIOV2LineConfig struct {
Flags uint64
Num_attrs uint32
_ [5]uint32
Attrs [10]GPIOV2LineConfigAttribute
}
type GPIOV2LineRequest struct {
Offsets [64]uint32
Consumer [32]byte
Config GPIOV2LineConfig
Num_lines uint32
Event_buffer_size uint32
_ [5]uint32
Fd int32
}
type GPIOV2LineInfo struct {
Name [32]byte
Consumer [32]byte
Offset uint32
Num_attrs uint32
Flags uint64
Attrs [10]GPIOV2LineAttribute
_ [4]uint32
}
type GPIOV2LineInfoChanged struct {
Info GPIOV2LineInfo
Timestamp_ns uint64
Event_type uint32
_ [5]uint32
}
type GPIOV2LineEvent struct {
Timestamp_ns uint64
Id uint32
Offset uint32
Seqno uint32
Line_seqno uint32
_ [6]uint32
}
+12
View File
@@ -354,6 +354,14 @@ type Taskstats struct {
Wpcopy_delay_min uint64
Irq_delay_max uint64
Irq_delay_min uint64
Cpu_delay_max_ts KernelTimespec
Blkio_delay_max_ts KernelTimespec
Swapin_delay_max_ts KernelTimespec
Freepages_delay_max_ts KernelTimespec
Thrashing_delay_max_ts KernelTimespec
Compact_delay_max_ts KernelTimespec
Wpcopy_delay_max_ts KernelTimespec
Irq_delay_max_ts KernelTimespec
}
type cpuMask uint32
@@ -703,3 +711,7 @@ type SysvShmDesc struct {
_ uint32
_ uint32
}
const (
GPIO_GET_CHIPINFO_IOCTL = 0x8044b401
)
+12
View File
@@ -367,6 +367,14 @@ type Taskstats struct {
Wpcopy_delay_min uint64
Irq_delay_max uint64
Irq_delay_min uint64
Cpu_delay_max_ts KernelTimespec
Blkio_delay_max_ts KernelTimespec
Swapin_delay_max_ts KernelTimespec
Freepages_delay_max_ts KernelTimespec
Thrashing_delay_max_ts KernelTimespec
Compact_delay_max_ts KernelTimespec
Wpcopy_delay_max_ts KernelTimespec
Irq_delay_max_ts KernelTimespec
}
type cpuMask uint64
@@ -717,3 +725,7 @@ type SysvShmDesc struct {
_ uint64
_ uint64
}
const (
GPIO_GET_CHIPINFO_IOCTL = 0x8044b401
)
+12
View File
@@ -345,6 +345,14 @@ type Taskstats struct {
Wpcopy_delay_min uint64
Irq_delay_max uint64
Irq_delay_min uint64
Cpu_delay_max_ts KernelTimespec
Blkio_delay_max_ts KernelTimespec
Swapin_delay_max_ts KernelTimespec
Freepages_delay_max_ts KernelTimespec
Thrashing_delay_max_ts KernelTimespec
Compact_delay_max_ts KernelTimespec
Wpcopy_delay_max_ts KernelTimespec
Irq_delay_max_ts KernelTimespec
}
type cpuMask uint32
@@ -697,3 +705,7 @@ type SysvShmDesc struct {
_ uint32
_ uint32
}
const (
GPIO_GET_CHIPINFO_IOCTL = 0x8044b401
)
+12
View File
@@ -346,6 +346,14 @@ type Taskstats struct {
Wpcopy_delay_min uint64
Irq_delay_max uint64
Irq_delay_min uint64
Cpu_delay_max_ts KernelTimespec
Blkio_delay_max_ts KernelTimespec
Swapin_delay_max_ts KernelTimespec
Freepages_delay_max_ts KernelTimespec
Thrashing_delay_max_ts KernelTimespec
Compact_delay_max_ts KernelTimespec
Wpcopy_delay_max_ts KernelTimespec
Irq_delay_max_ts KernelTimespec
}
type cpuMask uint64
@@ -696,3 +704,7 @@ type SysvShmDesc struct {
_ uint64
_ uint64
}
const (
GPIO_GET_CHIPINFO_IOCTL = 0x8044b401
)
+12
View File
@@ -347,6 +347,14 @@ type Taskstats struct {
Wpcopy_delay_min uint64
Irq_delay_max uint64
Irq_delay_min uint64
Cpu_delay_max_ts KernelTimespec
Blkio_delay_max_ts KernelTimespec
Swapin_delay_max_ts KernelTimespec
Freepages_delay_max_ts KernelTimespec
Thrashing_delay_max_ts KernelTimespec
Compact_delay_max_ts KernelTimespec
Wpcopy_delay_max_ts KernelTimespec
Irq_delay_max_ts KernelTimespec
}
type cpuMask uint64
@@ -697,3 +705,7 @@ type SysvShmDesc struct {
_ uint64
_ uint64
}
const (
GPIO_GET_CHIPINFO_IOCTL = 0x8044b401
)
+12
View File
@@ -350,6 +350,14 @@ type Taskstats struct {
Wpcopy_delay_min uint64
Irq_delay_max uint64
Irq_delay_min uint64
Cpu_delay_max_ts KernelTimespec
Blkio_delay_max_ts KernelTimespec
Swapin_delay_max_ts KernelTimespec
Freepages_delay_max_ts KernelTimespec
Thrashing_delay_max_ts KernelTimespec
Compact_delay_max_ts KernelTimespec
Wpcopy_delay_max_ts KernelTimespec
Irq_delay_max_ts KernelTimespec
}
type cpuMask uint32
@@ -702,3 +710,7 @@ type SysvShmDesc struct {
Ctime_high uint16
_ uint16
}
const (
GPIO_GET_CHIPINFO_IOCTL = 0x4044b401
)
+12
View File
@@ -349,6 +349,14 @@ type Taskstats struct {
Wpcopy_delay_min uint64
Irq_delay_max uint64
Irq_delay_min uint64
Cpu_delay_max_ts KernelTimespec
Blkio_delay_max_ts KernelTimespec
Swapin_delay_max_ts KernelTimespec
Freepages_delay_max_ts KernelTimespec
Thrashing_delay_max_ts KernelTimespec
Compact_delay_max_ts KernelTimespec
Wpcopy_delay_max_ts KernelTimespec
Irq_delay_max_ts KernelTimespec
}
type cpuMask uint64
@@ -699,3 +707,7 @@ type SysvShmDesc struct {
_ uint64
_ uint64
}
const (
GPIO_GET_CHIPINFO_IOCTL = 0x4044b401
)
+12
View File
@@ -349,6 +349,14 @@ type Taskstats struct {
Wpcopy_delay_min uint64
Irq_delay_max uint64
Irq_delay_min uint64
Cpu_delay_max_ts KernelTimespec
Blkio_delay_max_ts KernelTimespec
Swapin_delay_max_ts KernelTimespec
Freepages_delay_max_ts KernelTimespec
Thrashing_delay_max_ts KernelTimespec
Compact_delay_max_ts KernelTimespec
Wpcopy_delay_max_ts KernelTimespec
Irq_delay_max_ts KernelTimespec
}
type cpuMask uint64
@@ -699,3 +707,7 @@ type SysvShmDesc struct {
_ uint64
_ uint64
}
const (
GPIO_GET_CHIPINFO_IOCTL = 0x4044b401
)
+12
View File
@@ -350,6 +350,14 @@ type Taskstats struct {
Wpcopy_delay_min uint64
Irq_delay_max uint64
Irq_delay_min uint64
Cpu_delay_max_ts KernelTimespec
Blkio_delay_max_ts KernelTimespec
Swapin_delay_max_ts KernelTimespec
Freepages_delay_max_ts KernelTimespec
Thrashing_delay_max_ts KernelTimespec
Compact_delay_max_ts KernelTimespec
Wpcopy_delay_max_ts KernelTimespec
Irq_delay_max_ts KernelTimespec
}
type cpuMask uint32
@@ -702,3 +710,7 @@ type SysvShmDesc struct {
Ctime_high uint16
_ uint16
}
const (
GPIO_GET_CHIPINFO_IOCTL = 0x4044b401
)
+12
View File
@@ -357,6 +357,14 @@ type Taskstats struct {
Wpcopy_delay_min uint64
Irq_delay_max uint64
Irq_delay_min uint64
Cpu_delay_max_ts KernelTimespec
Blkio_delay_max_ts KernelTimespec
Swapin_delay_max_ts KernelTimespec
Freepages_delay_max_ts KernelTimespec
Thrashing_delay_max_ts KernelTimespec
Compact_delay_max_ts KernelTimespec
Wpcopy_delay_max_ts KernelTimespec
Irq_delay_max_ts KernelTimespec
}
type cpuMask uint32
@@ -710,3 +718,7 @@ type SysvShmDesc struct {
_ uint32
_ [4]byte
}
const (
GPIO_GET_CHIPINFO_IOCTL = 0x4044b401
)
+12
View File
@@ -356,6 +356,14 @@ type Taskstats struct {
Wpcopy_delay_min uint64
Irq_delay_max uint64
Irq_delay_min uint64
Cpu_delay_max_ts KernelTimespec
Blkio_delay_max_ts KernelTimespec
Swapin_delay_max_ts KernelTimespec
Freepages_delay_max_ts KernelTimespec
Thrashing_delay_max_ts KernelTimespec
Compact_delay_max_ts KernelTimespec
Wpcopy_delay_max_ts KernelTimespec
Irq_delay_max_ts KernelTimespec
}
type cpuMask uint64
@@ -705,3 +713,7 @@ type SysvShmDesc struct {
_ uint64
_ uint64
}
const (
GPIO_GET_CHIPINFO_IOCTL = 0x4044b401
)
+12
View File
@@ -356,6 +356,14 @@ type Taskstats struct {
Wpcopy_delay_min uint64
Irq_delay_max uint64
Irq_delay_min uint64
Cpu_delay_max_ts KernelTimespec
Blkio_delay_max_ts KernelTimespec
Swapin_delay_max_ts KernelTimespec
Freepages_delay_max_ts KernelTimespec
Thrashing_delay_max_ts KernelTimespec
Compact_delay_max_ts KernelTimespec
Wpcopy_delay_max_ts KernelTimespec
Irq_delay_max_ts KernelTimespec
}
type cpuMask uint64
@@ -705,3 +713,7 @@ type SysvShmDesc struct {
_ uint64
_ uint64
}
const (
GPIO_GET_CHIPINFO_IOCTL = 0x4044b401
)
+12
View File
@@ -374,6 +374,14 @@ type Taskstats struct {
Wpcopy_delay_min uint64
Irq_delay_max uint64
Irq_delay_min uint64
Cpu_delay_max_ts KernelTimespec
Blkio_delay_max_ts KernelTimespec
Swapin_delay_max_ts KernelTimespec
Freepages_delay_max_ts KernelTimespec
Thrashing_delay_max_ts KernelTimespec
Compact_delay_max_ts KernelTimespec
Wpcopy_delay_max_ts KernelTimespec
Irq_delay_max_ts KernelTimespec
}
type cpuMask uint64
@@ -784,3 +792,7 @@ const (
RISCV_HWPROBE_KEY_ZICBOZ_BLOCK_SIZE = 0x6
RISCV_HWPROBE_WHICH_CPUS = 0x1
)
const (
GPIO_GET_CHIPINFO_IOCTL = 0x8044b401
)
+12
View File
@@ -369,6 +369,14 @@ type Taskstats struct {
Wpcopy_delay_min uint64
Irq_delay_max uint64
Irq_delay_min uint64
Cpu_delay_max_ts KernelTimespec
Blkio_delay_max_ts KernelTimespec
Swapin_delay_max_ts KernelTimespec
Freepages_delay_max_ts KernelTimespec
Thrashing_delay_max_ts KernelTimespec
Compact_delay_max_ts KernelTimespec
Wpcopy_delay_max_ts KernelTimespec
Irq_delay_max_ts KernelTimespec
}
type cpuMask uint64
@@ -719,3 +727,7 @@ type SysvShmDesc struct {
_ uint64
_ uint64
}
const (
GPIO_GET_CHIPINFO_IOCTL = 0x8044b401
)
+12
View File
@@ -351,6 +351,14 @@ type Taskstats struct {
Wpcopy_delay_min uint64
Irq_delay_max uint64
Irq_delay_min uint64
Cpu_delay_max_ts KernelTimespec
Blkio_delay_max_ts KernelTimespec
Swapin_delay_max_ts KernelTimespec
Freepages_delay_max_ts KernelTimespec
Thrashing_delay_max_ts KernelTimespec
Compact_delay_max_ts KernelTimespec
Wpcopy_delay_max_ts KernelTimespec
Irq_delay_max_ts KernelTimespec
}
type cpuMask uint64
@@ -700,3 +708,7 @@ type SysvShmDesc struct {
_ uint64
_ uint64
}
const (
GPIO_GET_CHIPINFO_IOCTL = 0x4044b401
)
+1
View File
@@ -8,5 +8,6 @@ package windows
import "syscall"
type Signal = syscall.Signal
type Errno = syscall.Errno
type SysProcAttr = syscall.SysProcAttr
+1 -36
View File
@@ -163,42 +163,7 @@ func (p *Proc) Addr() uintptr {
// (according to the semantics of the specific function being called) before consulting
// the error. The error will be guaranteed to contain windows.Errno.
func (p *Proc) Call(a ...uintptr) (r1, r2 uintptr, lastErr error) {
switch len(a) {
case 0:
return syscall.Syscall(p.Addr(), uintptr(len(a)), 0, 0, 0)
case 1:
return syscall.Syscall(p.Addr(), uintptr(len(a)), a[0], 0, 0)
case 2:
return syscall.Syscall(p.Addr(), uintptr(len(a)), a[0], a[1], 0)
case 3:
return syscall.Syscall(p.Addr(), uintptr(len(a)), a[0], a[1], a[2])
case 4:
return syscall.Syscall6(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], 0, 0)
case 5:
return syscall.Syscall6(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], 0)
case 6:
return syscall.Syscall6(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5])
case 7:
return syscall.Syscall9(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], 0, 0)
case 8:
return syscall.Syscall9(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], 0)
case 9:
return syscall.Syscall9(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8])
case 10:
return syscall.Syscall12(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], 0, 0)
case 11:
return syscall.Syscall12(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], 0)
case 12:
return syscall.Syscall12(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11])
case 13:
return syscall.Syscall15(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], 0, 0)
case 14:
return syscall.Syscall15(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], 0)
case 15:
return syscall.Syscall15(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14])
default:
panic("Call " + p.Name + " with too many arguments " + itoa(len(a)) + ".")
}
return syscall.SyscallN(p.Addr(), a...)
}
// A LazyDLL implements access to a single DLL.
+5 -1
View File
@@ -1438,13 +1438,17 @@ func GetSecurityInfo(handle Handle, objectType SE_OBJECT_TYPE, securityInformati
}
// GetNamedSecurityInfo queries the security information for a given named object and returns the self-relative security
// descriptor result on the Go heap.
// descriptor result on the Go heap. The security descriptor might be nil, even when err is nil, if the object exists
// but has no security descriptor.
func GetNamedSecurityInfo(objectName string, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION) (sd *SECURITY_DESCRIPTOR, err error) {
var winHeapSD *SECURITY_DESCRIPTOR
err = getNamedSecurityInfo(objectName, objectType, securityInformation, nil, nil, nil, nil, &winHeapSD)
if err != nil {
return
}
if winHeapSD == nil {
return nil, nil
}
defer LocalFree(Handle(unsafe.Pointer(winHeapSD)))
return winHeapSD.copySelfRelativeSecurityDescriptor(), nil
}
+13 -17
View File
@@ -452,6 +452,7 @@ func NewCallbackCDecl(fn interface{}) uintptr {
//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 NtQueryInformationFile(handle Handle, iosb *IO_STATUS_BLOCK, outBuffer *byte, outBufferLen uint32, class uint32) (ntstatus error) = ntdll.NtQueryInformationFile
//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
@@ -460,6 +461,8 @@ func NewCallbackCDecl(fn interface{}) uintptr {
//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 NtQueryEaFile(handle Handle, iosb *IO_STATUS_BLOCK, outBuffer *byte, outBufferLen uint32, returnSingleEntry bool, eaList *byte, eaListLen uint32, eaIndex *uint32, restartScan bool) (ntstatus error) = ntdll.NtQueryEaFile
//sys NtSetEaFile(handle Handle, iosb *IO_STATUS_BLOCK, inBuffer *byte, inBufferLen uint32) (ntstatus error) = ntdll.NtSetEaFile
//sys RtlAddFunctionTable(functionTable *RUNTIME_FUNCTION, entryCount uint32, baseAddress uintptr) (ret bool) = ntdll.RtlAddFunctionTable
//sys RtlDeleteFunctionTable(functionTable *RUNTIME_FUNCTION) (ret bool) = ntdll.RtlDeleteFunctionTable
@@ -892,9 +895,13 @@ const socket_error = uintptr(^uint32(0))
//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
//sys GetIfEntry2Ex(level uint32, row *MibIfRow2) (errcode error) = iphlpapi.GetIfEntry2Ex
//sys GetIfTable2Ex(level uint32, table **MibIfTable2) (errcode error) = iphlpapi.GetIfTable2Ex
//sys GetIpForwardEntry2(row *MibIpForwardRow2) (errcode error) = iphlpapi.GetIpForwardEntry2
//sys GetIpForwardTable2(family uint16, table **MibIpForwardTable2) (errcode error) = iphlpapi.GetIpForwardTable2
//sys GetIpInterfaceEntry(row *MibIpInterfaceRow) (errcode error) = iphlpapi.GetIpInterfaceEntry
//sys GetIpInterfaceTable(family uint16, table **MibIpInterfaceTable) (errcode error) = iphlpapi.GetIpInterfaceTable
//sys GetUnicastIpAddressEntry(row *MibUnicastIpAddressRow) (errcode error) = iphlpapi.GetUnicastIpAddressEntry
//sys GetUnicastIpAddressTable(family uint16, table **MibUnicastIpAddressTable) (errcode error) = iphlpapi.GetUnicastIpAddressTable
//sys FreeMibTable(memory unsafe.Pointer) = iphlpapi.FreeMibTable
//sys NotifyIpInterfaceChange(family uint16, callback uintptr, callerContext unsafe.Pointer, initialNotification bool, notificationHandle *Handle) (errcode error) = iphlpapi.NotifyIpInterfaceChange
//sys NotifyRouteChange2(family uint16, callback uintptr, callerContext unsafe.Pointer, initialNotification bool, notificationHandle *Handle) (errcode error) = iphlpapi.NotifyRouteChange2
@@ -1490,20 +1497,6 @@ 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()
}
@@ -1707,10 +1700,13 @@ func NewNTUnicodeString(s string) (*NTUnicodeString, error) {
if err != nil {
return nil, err
}
n := uint16(len(s16) * 2)
n := len(s16) * 2
if n > (1<<16)-1 {
return nil, syscall.EINVAL
}
return &NTUnicodeString{
Length: n - 2, // subtract 2 bytes for the NULL terminator
MaximumLength: n,
Length: uint16(n) - 2, // subtract 2 bytes for the NULL terminator
MaximumLength: uint16(n),
Buffer: &s16[0],
}, nil
}
+32 -1
View File
@@ -2320,6 +2320,21 @@ type MibIfRow2 struct {
OutQLen uint64
}
// MIB_IF_TABLE_LEVEL enumeration from netioapi.h or
// https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ne-netioapi-mib_if_table_level.
const (
MibIfTableNormal = 0
MibIfTableRaw = 1
MibIfTableNormalWithoutStatistics = 2
)
// MibIfTable2 contains a table of logical and physical interface entries. See
// https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-mib_if_table2.
type MibIfTable2 struct {
NumEntries uint32
Table [1]MibIfRow2
}
// IP_ADDRESS_PREFIX stores an IP address prefix. See
// https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-ip_address_prefix.
type IpAddressPrefix struct {
@@ -2413,6 +2428,13 @@ type MibUnicastIpAddressRow struct {
CreationTimeStamp Filetime
}
// MibUnicastIpAddressTable contains a table of unicast IP address entries. See
// https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-mib_unicastipaddress_table.
type MibUnicastIpAddressTable struct {
NumEntries uint32
Table [1]MibUnicastIpAddressRow
}
const ScopeLevelCount = 16
// MIB_IPINTERFACE_ROW stores interface management information for a particular IP address family on a network interface.
@@ -2455,6 +2477,13 @@ type MibIpInterfaceRow struct {
DisableDefaultRoutes uint8
}
// MibIpInterfaceTable contains a table of IP interface entries. See
// https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-mib_ipinterface_table.
type MibIpInterfaceTable struct {
NumEntries uint32
Table [1]MibIpInterfaceRow
}
// Console related constants used for the mode parameter to SetConsoleMode. See
// https://docs.microsoft.com/en-us/windows/console/setconsolemode for details.
@@ -3014,8 +3043,10 @@ const (
)
const (
// FileInformationClass for NtSetInformationFile
// FileInformationClass for NtSetInformationFile/NtQueryInformationFile, see
// https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/ne-wdm-_file_information_class
FileBasicInformation = 4
FileEaInformation = 7
FileRenameInformation = 10
FileDispositionInformation = 13
FilePositionInformation = 14
+71
View File
@@ -188,9 +188,13 @@ var (
procGetBestInterfaceEx = modiphlpapi.NewProc("GetBestInterfaceEx")
procGetIfEntry = modiphlpapi.NewProc("GetIfEntry")
procGetIfEntry2Ex = modiphlpapi.NewProc("GetIfEntry2Ex")
procGetIfTable2Ex = modiphlpapi.NewProc("GetIfTable2Ex")
procGetIpForwardEntry2 = modiphlpapi.NewProc("GetIpForwardEntry2")
procGetIpForwardTable2 = modiphlpapi.NewProc("GetIpForwardTable2")
procGetIpInterfaceEntry = modiphlpapi.NewProc("GetIpInterfaceEntry")
procGetIpInterfaceTable = modiphlpapi.NewProc("GetIpInterfaceTable")
procGetUnicastIpAddressEntry = modiphlpapi.NewProc("GetUnicastIpAddressEntry")
procGetUnicastIpAddressTable = modiphlpapi.NewProc("GetUnicastIpAddressTable")
procNotifyIpInterfaceChange = modiphlpapi.NewProc("NotifyIpInterfaceChange")
procNotifyRouteChange2 = modiphlpapi.NewProc("NotifyRouteChange2")
procNotifyUnicastIpAddressChange = modiphlpapi.NewProc("NotifyUnicastIpAddressChange")
@@ -424,8 +428,11 @@ var (
procNetUserGetInfo = modnetapi32.NewProc("NetUserGetInfo")
procNtCreateFile = modntdll.NewProc("NtCreateFile")
procNtCreateNamedPipeFile = modntdll.NewProc("NtCreateNamedPipeFile")
procNtQueryEaFile = modntdll.NewProc("NtQueryEaFile")
procNtQueryInformationFile = modntdll.NewProc("NtQueryInformationFile")
procNtQueryInformationProcess = modntdll.NewProc("NtQueryInformationProcess")
procNtQuerySystemInformation = modntdll.NewProc("NtQuerySystemInformation")
procNtSetEaFile = modntdll.NewProc("NtSetEaFile")
procNtSetInformationFile = modntdll.NewProc("NtSetInformationFile")
procNtSetInformationProcess = modntdll.NewProc("NtSetInformationProcess")
procNtSetSystemInformation = modntdll.NewProc("NtSetSystemInformation")
@@ -1674,6 +1681,14 @@ func GetIfEntry2Ex(level uint32, row *MibIfRow2) (errcode error) {
return
}
func GetIfTable2Ex(level uint32, table **MibIfTable2) (errcode error) {
r0, _, _ := syscall.SyscallN(procGetIfTable2Ex.Addr(), uintptr(level), uintptr(unsafe.Pointer(table)))
if r0 != 0 {
errcode = syscall.Errno(r0)
}
return
}
func GetIpForwardEntry2(row *MibIpForwardRow2) (errcode error) {
r0, _, _ := syscall.SyscallN(procGetIpForwardEntry2.Addr(), uintptr(unsafe.Pointer(row)))
if r0 != 0 {
@@ -1690,6 +1705,22 @@ func GetIpForwardTable2(family uint16, table **MibIpForwardTable2) (errcode erro
return
}
func GetIpInterfaceEntry(row *MibIpInterfaceRow) (errcode error) {
r0, _, _ := syscall.SyscallN(procGetIpInterfaceEntry.Addr(), uintptr(unsafe.Pointer(row)))
if r0 != 0 {
errcode = syscall.Errno(r0)
}
return
}
func GetIpInterfaceTable(family uint16, table **MibIpInterfaceTable) (errcode error) {
r0, _, _ := syscall.SyscallN(procGetIpInterfaceTable.Addr(), uintptr(family), uintptr(unsafe.Pointer(table)))
if r0 != 0 {
errcode = syscall.Errno(r0)
}
return
}
func GetUnicastIpAddressEntry(row *MibUnicastIpAddressRow) (errcode error) {
r0, _, _ := syscall.SyscallN(procGetUnicastIpAddressEntry.Addr(), uintptr(unsafe.Pointer(row)))
if r0 != 0 {
@@ -1698,6 +1729,14 @@ func GetUnicastIpAddressEntry(row *MibUnicastIpAddressRow) (errcode error) {
return
}
func GetUnicastIpAddressTable(family uint16, table **MibUnicastIpAddressTable) (errcode error) {
r0, _, _ := syscall.SyscallN(procGetUnicastIpAddressTable.Addr(), uintptr(family), uintptr(unsafe.Pointer(table)))
if r0 != 0 {
errcode = syscall.Errno(r0)
}
return
}
func NotifyIpInterfaceChange(family uint16, callback uintptr, callerContext unsafe.Pointer, initialNotification bool, notificationHandle *Handle) (errcode error) {
var _p0 uint32
if initialNotification {
@@ -3704,6 +3743,30 @@ func NtCreateNamedPipeFile(pipe *Handle, access uint32, oa *OBJECT_ATTRIBUTES, i
return
}
func NtQueryEaFile(handle Handle, iosb *IO_STATUS_BLOCK, outBuffer *byte, outBufferLen uint32, returnSingleEntry bool, eaList *byte, eaListLen uint32, eaIndex *uint32, restartScan bool) (ntstatus error) {
var _p0 uint32
if returnSingleEntry {
_p0 = 1
}
var _p1 uint32
if restartScan {
_p1 = 1
}
r0, _, _ := syscall.SyscallN(procNtQueryEaFile.Addr(), uintptr(handle), uintptr(unsafe.Pointer(iosb)), uintptr(unsafe.Pointer(outBuffer)), uintptr(outBufferLen), uintptr(_p0), uintptr(unsafe.Pointer(eaList)), uintptr(eaListLen), uintptr(unsafe.Pointer(eaIndex)), uintptr(_p1))
if r0 != 0 {
ntstatus = NTStatus(r0)
}
return
}
func NtQueryInformationFile(handle Handle, iosb *IO_STATUS_BLOCK, outBuffer *byte, outBufferLen uint32, class uint32) (ntstatus error) {
r0, _, _ := syscall.SyscallN(procNtQueryInformationFile.Addr(), uintptr(handle), uintptr(unsafe.Pointer(iosb)), uintptr(unsafe.Pointer(outBuffer)), uintptr(outBufferLen), uintptr(class))
if r0 != 0 {
ntstatus = NTStatus(r0)
}
return
}
func NtQueryInformationProcess(proc Handle, procInfoClass int32, procInfo unsafe.Pointer, procInfoLen uint32, retLen *uint32) (ntstatus error) {
r0, _, _ := syscall.SyscallN(procNtQueryInformationProcess.Addr(), uintptr(proc), uintptr(procInfoClass), uintptr(procInfo), uintptr(procInfoLen), uintptr(unsafe.Pointer(retLen)))
if r0 != 0 {
@@ -3720,6 +3783,14 @@ func NtQuerySystemInformation(sysInfoClass int32, sysInfo unsafe.Pointer, sysInf
return
}
func NtSetEaFile(handle Handle, iosb *IO_STATUS_BLOCK, inBuffer *byte, inBufferLen uint32) (ntstatus error) {
r0, _, _ := syscall.SyscallN(procNtSetEaFile.Addr(), uintptr(handle), uintptr(unsafe.Pointer(iosb)), uintptr(unsafe.Pointer(inBuffer)), uintptr(inBufferLen))
if r0 != 0 {
ntstatus = NTStatus(r0)
}
return
}
func NtSetInformationFile(handle Handle, iosb *IO_STATUS_BLOCK, inBuffer *byte, inBufferLen uint32, class uint32) (ntstatus error) {
r0, _, _ := syscall.SyscallN(procNtSetInformationFile.Addr(), uintptr(handle), uintptr(unsafe.Pointer(iosb)), uintptr(unsafe.Pointer(inBuffer)), uintptr(inBufferLen), uintptr(class))
if r0 != 0 {
-767
View File
@@ -1,767 +0,0 @@
// 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 prototext
import (
"fmt"
"unicode/utf8"
"google.golang.org/protobuf/internal/encoding/messageset"
"google.golang.org/protobuf/internal/encoding/text"
"google.golang.org/protobuf/internal/errors"
"google.golang.org/protobuf/internal/flags"
"google.golang.org/protobuf/internal/genid"
"google.golang.org/protobuf/internal/pragma"
"google.golang.org/protobuf/internal/set"
"google.golang.org/protobuf/internal/strs"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/reflect/protoreflect"
"google.golang.org/protobuf/reflect/protoregistry"
)
// Unmarshal reads the given []byte into the given [proto.Message].
// The provided message must be mutable (e.g., a non-nil pointer to a message).
func Unmarshal(b []byte, m proto.Message) error {
return UnmarshalOptions{}.Unmarshal(b, m)
}
// UnmarshalOptions is a configurable textproto format unmarshaler.
type UnmarshalOptions struct {
pragma.NoUnkeyedLiterals
// AllowPartial accepts input for messages that will result in missing
// required fields. If AllowPartial is false (the default), Unmarshal will
// return error if there are any missing required fields.
AllowPartial bool
// DiscardUnknown specifies whether to ignore unknown fields when parsing.
// An unknown field is any field whose field name or field number does not
// resolve to any known or extension field in the message.
// By default, unmarshal rejects unknown fields as an error.
DiscardUnknown bool
// Resolver is used for looking up types when unmarshaling
// google.protobuf.Any messages or extension fields.
// If nil, this defaults to using protoregistry.GlobalTypes.
Resolver interface {
protoregistry.MessageTypeResolver
protoregistry.ExtensionTypeResolver
}
}
// Unmarshal reads the given []byte and populates the given [proto.Message]
// using options in the UnmarshalOptions object.
// The provided message must be mutable (e.g., a non-nil pointer to a message).
func (o UnmarshalOptions) Unmarshal(b []byte, m proto.Message) error {
return o.unmarshal(b, m)
}
// unmarshal is a centralized function that all unmarshal operations go through.
// For profiling purposes, avoid changing the name of this function or
// introducing other code paths for unmarshal that do not go through this.
func (o UnmarshalOptions) unmarshal(b []byte, m proto.Message) error {
proto.Reset(m)
if o.Resolver == nil {
o.Resolver = protoregistry.GlobalTypes
}
dec := decoder{text.NewDecoder(b), o}
if err := dec.unmarshalMessage(m.ProtoReflect(), false); err != nil {
return err
}
if o.AllowPartial {
return nil
}
return proto.CheckInitialized(m)
}
type decoder struct {
*text.Decoder
opts UnmarshalOptions
}
// newError returns an error object with position info.
func (d decoder) newError(pos int, f string, x ...any) error {
line, column := d.Position(pos)
head := fmt.Sprintf("(line %d:%d): ", line, column)
return errors.New(head+f, x...)
}
// unexpectedTokenError returns a syntax error for the given unexpected token.
func (d decoder) unexpectedTokenError(tok text.Token) error {
return d.syntaxError(tok.Pos(), "unexpected token: %s", tok.RawString())
}
// syntaxError returns a syntax error for given position.
func (d decoder) syntaxError(pos int, f string, x ...any) error {
line, column := d.Position(pos)
head := fmt.Sprintf("syntax error (line %d:%d): ", line, column)
return errors.New(head+f, x...)
}
// unmarshalMessage unmarshals into the given protoreflect.Message.
func (d decoder) unmarshalMessage(m protoreflect.Message, checkDelims bool) error {
messageDesc := m.Descriptor()
if !flags.ProtoLegacy && messageset.IsMessageSet(messageDesc) {
return errors.New("no support for proto1 MessageSets")
}
if messageDesc.FullName() == genid.Any_message_fullname {
return d.unmarshalAny(m, checkDelims)
}
if checkDelims {
tok, err := d.Read()
if err != nil {
return err
}
if tok.Kind() != text.MessageOpen {
return d.unexpectedTokenError(tok)
}
}
var seenNums set.Ints
var seenOneofs set.Ints
fieldDescs := messageDesc.Fields()
for {
// Read field name.
tok, err := d.Read()
if err != nil {
return err
}
switch typ := tok.Kind(); typ {
case text.Name:
// Continue below.
case text.EOF:
if checkDelims {
return text.ErrUnexpectedEOF
}
return nil
default:
if checkDelims && typ == text.MessageClose {
return nil
}
return d.unexpectedTokenError(tok)
}
// Resolve the field descriptor.
var name protoreflect.Name
var fd protoreflect.FieldDescriptor
var xt protoreflect.ExtensionType
var xtErr error
var isFieldNumberName bool
switch tok.NameKind() {
case text.IdentName:
name = protoreflect.Name(tok.IdentName())
fd = fieldDescs.ByTextName(string(name))
case text.TypeName:
// Handle extensions only. This code path is not for Any.
xt, xtErr = d.opts.Resolver.FindExtensionByName(protoreflect.FullName(tok.TypeName()))
case text.FieldNumber:
isFieldNumberName = true
num := protoreflect.FieldNumber(tok.FieldNumber())
if !num.IsValid() {
return d.newError(tok.Pos(), "invalid field number: %d", num)
}
fd = fieldDescs.ByNumber(num)
if fd == nil {
xt, xtErr = d.opts.Resolver.FindExtensionByNumber(messageDesc.FullName(), num)
}
}
if xt != nil {
fd = xt.TypeDescriptor()
if !messageDesc.ExtensionRanges().Has(fd.Number()) || fd.ContainingMessage().FullName() != messageDesc.FullName() {
return d.newError(tok.Pos(), "message %v cannot be extended by %v", messageDesc.FullName(), fd.FullName())
}
} else if xtErr != nil && xtErr != protoregistry.NotFound {
return d.newError(tok.Pos(), "unable to resolve [%s]: %v", tok.RawString(), xtErr)
}
// Handle unknown fields.
if fd == nil {
if d.opts.DiscardUnknown || messageDesc.ReservedNames().Has(name) {
d.skipValue()
continue
}
return d.newError(tok.Pos(), "unknown field: %v", tok.RawString())
}
// Handle fields identified by field number.
if isFieldNumberName {
// TODO: Add an option to permit parsing field numbers.
//
// This requires careful thought as the MarshalOptions.EmitUnknown
// option allows formatting unknown fields as the field number and the
// best-effort textual representation of the field value. In that case,
// it may not be possible to unmarshal the value from a parser that does
// have information about the unknown field.
return d.newError(tok.Pos(), "cannot specify field by number: %v", tok.RawString())
}
switch {
case fd.IsList():
kind := fd.Kind()
if kind != protoreflect.MessageKind && kind != protoreflect.GroupKind && !tok.HasSeparator() {
return d.syntaxError(tok.Pos(), "missing field separator :")
}
list := m.Mutable(fd).List()
if err := d.unmarshalList(fd, list); err != nil {
return err
}
case fd.IsMap():
mmap := m.Mutable(fd).Map()
if err := d.unmarshalMap(fd, mmap); err != nil {
return err
}
default:
kind := fd.Kind()
if kind != protoreflect.MessageKind && kind != protoreflect.GroupKind && !tok.HasSeparator() {
return d.syntaxError(tok.Pos(), "missing field separator :")
}
// If field is a oneof, check if it has already been set.
if od := fd.ContainingOneof(); od != nil {
idx := uint64(od.Index())
if seenOneofs.Has(idx) {
return d.newError(tok.Pos(), "error parsing %q, oneof %v is already set", tok.RawString(), od.FullName())
}
seenOneofs.Set(idx)
}
num := uint64(fd.Number())
if seenNums.Has(num) {
return d.newError(tok.Pos(), "non-repeated field %q is repeated", tok.RawString())
}
if err := d.unmarshalSingular(fd, m); err != nil {
return err
}
seenNums.Set(num)
}
}
return nil
}
// unmarshalSingular unmarshals a non-repeated field value specified by the
// given FieldDescriptor.
func (d decoder) unmarshalSingular(fd protoreflect.FieldDescriptor, m protoreflect.Message) error {
var val protoreflect.Value
var err error
switch fd.Kind() {
case protoreflect.MessageKind, protoreflect.GroupKind:
val = m.NewField(fd)
err = d.unmarshalMessage(val.Message(), true)
default:
val, err = d.unmarshalScalar(fd)
}
if err == nil {
m.Set(fd, val)
}
return err
}
// unmarshalScalar unmarshals a scalar/enum protoreflect.Value specified by the
// given FieldDescriptor.
func (d decoder) unmarshalScalar(fd protoreflect.FieldDescriptor) (protoreflect.Value, error) {
tok, err := d.Read()
if err != nil {
return protoreflect.Value{}, err
}
if tok.Kind() != text.Scalar {
return protoreflect.Value{}, d.unexpectedTokenError(tok)
}
kind := fd.Kind()
switch kind {
case protoreflect.BoolKind:
if b, ok := tok.Bool(); ok {
return protoreflect.ValueOfBool(b), nil
}
case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind:
if n, ok := tok.Int32(); ok {
return protoreflect.ValueOfInt32(n), nil
}
case protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Sfixed64Kind:
if n, ok := tok.Int64(); ok {
return protoreflect.ValueOfInt64(n), nil
}
case protoreflect.Uint32Kind, protoreflect.Fixed32Kind:
if n, ok := tok.Uint32(); ok {
return protoreflect.ValueOfUint32(n), nil
}
case protoreflect.Uint64Kind, protoreflect.Fixed64Kind:
if n, ok := tok.Uint64(); ok {
return protoreflect.ValueOfUint64(n), nil
}
case protoreflect.FloatKind:
if n, ok := tok.Float32(); ok {
return protoreflect.ValueOfFloat32(n), nil
}
case protoreflect.DoubleKind:
if n, ok := tok.Float64(); ok {
return protoreflect.ValueOfFloat64(n), nil
}
case protoreflect.StringKind:
if s, ok := tok.String(); ok {
if strs.EnforceUTF8(fd) && !utf8.ValidString(s) {
return protoreflect.Value{}, d.newError(tok.Pos(), "contains invalid UTF-8")
}
return protoreflect.ValueOfString(s), nil
}
case protoreflect.BytesKind:
if b, ok := tok.String(); ok {
return protoreflect.ValueOfBytes([]byte(b)), nil
}
case protoreflect.EnumKind:
if lit, ok := tok.Enum(); ok {
// Lookup EnumNumber based on name.
if enumVal := fd.Enum().Values().ByName(protoreflect.Name(lit)); enumVal != nil {
return protoreflect.ValueOfEnum(enumVal.Number()), nil
}
}
if num, ok := tok.Int32(); ok {
return protoreflect.ValueOfEnum(protoreflect.EnumNumber(num)), nil
}
default:
panic(fmt.Sprintf("invalid scalar kind %v", kind))
}
return protoreflect.Value{}, d.newError(tok.Pos(), "invalid value for %v type: %v", kind, tok.RawString())
}
// unmarshalList unmarshals into given protoreflect.List. A list value can
// either be in [] syntax or simply just a single scalar/message value.
func (d decoder) unmarshalList(fd protoreflect.FieldDescriptor, list protoreflect.List) error {
tok, err := d.Peek()
if err != nil {
return err
}
switch fd.Kind() {
case protoreflect.MessageKind, protoreflect.GroupKind:
switch tok.Kind() {
case text.ListOpen:
d.Read()
for {
tok, err := d.Peek()
if err != nil {
return err
}
switch tok.Kind() {
case text.ListClose:
d.Read()
return nil
case text.MessageOpen:
pval := list.NewElement()
if err := d.unmarshalMessage(pval.Message(), true); err != nil {
return err
}
list.Append(pval)
default:
return d.unexpectedTokenError(tok)
}
}
case text.MessageOpen:
pval := list.NewElement()
if err := d.unmarshalMessage(pval.Message(), true); err != nil {
return err
}
list.Append(pval)
return nil
}
default:
switch tok.Kind() {
case text.ListOpen:
d.Read()
for {
tok, err := d.Peek()
if err != nil {
return err
}
switch tok.Kind() {
case text.ListClose:
d.Read()
return nil
case text.Scalar:
pval, err := d.unmarshalScalar(fd)
if err != nil {
return err
}
list.Append(pval)
default:
return d.unexpectedTokenError(tok)
}
}
case text.Scalar:
pval, err := d.unmarshalScalar(fd)
if err != nil {
return err
}
list.Append(pval)
return nil
}
}
return d.unexpectedTokenError(tok)
}
// unmarshalMap unmarshals into given protoreflect.Map. A map value is a
// textproto message containing {key: <kvalue>, value: <mvalue>}.
func (d decoder) unmarshalMap(fd protoreflect.FieldDescriptor, mmap protoreflect.Map) error {
// Determine ahead whether map entry is a scalar type or a message type in
// order to call the appropriate unmarshalMapValue func inside
// unmarshalMapEntry.
var unmarshalMapValue func() (protoreflect.Value, error)
switch fd.MapValue().Kind() {
case protoreflect.MessageKind, protoreflect.GroupKind:
unmarshalMapValue = func() (protoreflect.Value, error) {
pval := mmap.NewValue()
if err := d.unmarshalMessage(pval.Message(), true); err != nil {
return protoreflect.Value{}, err
}
return pval, nil
}
default:
unmarshalMapValue = func() (protoreflect.Value, error) {
return d.unmarshalScalar(fd.MapValue())
}
}
tok, err := d.Read()
if err != nil {
return err
}
switch tok.Kind() {
case text.MessageOpen:
return d.unmarshalMapEntry(fd, mmap, unmarshalMapValue)
case text.ListOpen:
for {
tok, err := d.Read()
if err != nil {
return err
}
switch tok.Kind() {
case text.ListClose:
return nil
case text.MessageOpen:
if err := d.unmarshalMapEntry(fd, mmap, unmarshalMapValue); err != nil {
return err
}
default:
return d.unexpectedTokenError(tok)
}
}
default:
return d.unexpectedTokenError(tok)
}
}
// unmarshalMap unmarshals into given protoreflect.Map. A map value is a
// textproto message containing {key: <kvalue>, value: <mvalue>}.
func (d decoder) unmarshalMapEntry(fd protoreflect.FieldDescriptor, mmap protoreflect.Map, unmarshalMapValue func() (protoreflect.Value, error)) error {
var key protoreflect.MapKey
var pval protoreflect.Value
Loop:
for {
// Read field name.
tok, err := d.Read()
if err != nil {
return err
}
switch tok.Kind() {
case text.Name:
if tok.NameKind() != text.IdentName {
if !d.opts.DiscardUnknown {
return d.newError(tok.Pos(), "unknown map entry field %q", tok.RawString())
}
d.skipValue()
continue Loop
}
// Continue below.
case text.MessageClose:
break Loop
default:
return d.unexpectedTokenError(tok)
}
switch name := protoreflect.Name(tok.IdentName()); name {
case genid.MapEntry_Key_field_name:
if !tok.HasSeparator() {
return d.syntaxError(tok.Pos(), "missing field separator :")
}
if key.IsValid() {
return d.newError(tok.Pos(), "map entry %q cannot be repeated", name)
}
val, err := d.unmarshalScalar(fd.MapKey())
if err != nil {
return err
}
key = val.MapKey()
case genid.MapEntry_Value_field_name:
if kind := fd.MapValue().Kind(); (kind != protoreflect.MessageKind) && (kind != protoreflect.GroupKind) {
if !tok.HasSeparator() {
return d.syntaxError(tok.Pos(), "missing field separator :")
}
}
if pval.IsValid() {
return d.newError(tok.Pos(), "map entry %q cannot be repeated", name)
}
pval, err = unmarshalMapValue()
if err != nil {
return err
}
default:
if !d.opts.DiscardUnknown {
return d.newError(tok.Pos(), "unknown map entry field %q", name)
}
d.skipValue()
}
}
if !key.IsValid() {
key = fd.MapKey().Default().MapKey()
}
if !pval.IsValid() {
switch fd.MapValue().Kind() {
case protoreflect.MessageKind, protoreflect.GroupKind:
// If value field is not set for message/group types, construct an
// empty one as default.
pval = mmap.NewValue()
default:
pval = fd.MapValue().Default()
}
}
mmap.Set(key, pval)
return nil
}
// unmarshalAny unmarshals an Any textproto. It can either be in expanded form
// or non-expanded form.
func (d decoder) unmarshalAny(m protoreflect.Message, checkDelims bool) error {
var typeURL string
var bValue []byte
var seenTypeUrl bool
var seenValue bool
var isExpanded bool
if checkDelims {
tok, err := d.Read()
if err != nil {
return err
}
if tok.Kind() != text.MessageOpen {
return d.unexpectedTokenError(tok)
}
}
Loop:
for {
// Read field name. Can only have 3 possible field names, i.e. type_url,
// value and type URL name inside [].
tok, err := d.Read()
if err != nil {
return err
}
if typ := tok.Kind(); typ != text.Name {
if checkDelims {
if typ == text.MessageClose {
break Loop
}
} else if typ == text.EOF {
break Loop
}
return d.unexpectedTokenError(tok)
}
switch tok.NameKind() {
case text.IdentName:
// Both type_url and value fields require field separator :.
if !tok.HasSeparator() {
return d.syntaxError(tok.Pos(), "missing field separator :")
}
switch name := protoreflect.Name(tok.IdentName()); name {
case genid.Any_TypeUrl_field_name:
if seenTypeUrl {
return d.newError(tok.Pos(), "duplicate %v field", genid.Any_TypeUrl_field_fullname)
}
if isExpanded {
return d.newError(tok.Pos(), "conflict with [%s] field", typeURL)
}
tok, err := d.Read()
if err != nil {
return err
}
var ok bool
typeURL, ok = tok.String()
if !ok {
return d.newError(tok.Pos(), "invalid %v field value: %v", genid.Any_TypeUrl_field_fullname, tok.RawString())
}
seenTypeUrl = true
case genid.Any_Value_field_name:
if seenValue {
return d.newError(tok.Pos(), "duplicate %v field", genid.Any_Value_field_fullname)
}
if isExpanded {
return d.newError(tok.Pos(), "conflict with [%s] field", typeURL)
}
tok, err := d.Read()
if err != nil {
return err
}
s, ok := tok.String()
if !ok {
return d.newError(tok.Pos(), "invalid %v field value: %v", genid.Any_Value_field_fullname, tok.RawString())
}
bValue = []byte(s)
seenValue = true
default:
if !d.opts.DiscardUnknown {
return d.newError(tok.Pos(), "invalid field name %q in %v message", tok.RawString(), genid.Any_message_fullname)
}
}
case text.TypeName:
if isExpanded {
return d.newError(tok.Pos(), "cannot have more than one type")
}
if seenTypeUrl {
return d.newError(tok.Pos(), "conflict with type_url field")
}
typeURL = tok.TypeName()
var err error
bValue, err = d.unmarshalExpandedAny(typeURL, tok.Pos())
if err != nil {
return err
}
isExpanded = true
default:
if !d.opts.DiscardUnknown {
return d.newError(tok.Pos(), "invalid field name %q in %v message", tok.RawString(), genid.Any_message_fullname)
}
}
}
fds := m.Descriptor().Fields()
if len(typeURL) > 0 {
m.Set(fds.ByNumber(genid.Any_TypeUrl_field_number), protoreflect.ValueOfString(typeURL))
}
if len(bValue) > 0 {
m.Set(fds.ByNumber(genid.Any_Value_field_number), protoreflect.ValueOfBytes(bValue))
}
return nil
}
func (d decoder) unmarshalExpandedAny(typeURL string, pos int) ([]byte, error) {
mt, err := d.opts.Resolver.FindMessageByURL(typeURL)
if err != nil {
return nil, d.newError(pos, "unable to resolve message [%v]: %v", typeURL, err)
}
// Create new message for the embedded message type and unmarshal the value
// field into it.
m := mt.New()
if err := d.unmarshalMessage(m, true); err != nil {
return nil, err
}
// Serialize the embedded message and return the resulting bytes.
b, err := proto.MarshalOptions{
AllowPartial: true, // Never check required fields inside an Any.
Deterministic: true,
}.Marshal(m.Interface())
if err != nil {
return nil, d.newError(pos, "error in marshaling message into Any.value: %v", err)
}
return b, nil
}
// skipValue makes the decoder parse a field value in order to advance the read
// to the next field. It relies on Read returning an error if the types are not
// in valid sequence.
func (d decoder) skipValue() error {
tok, err := d.Read()
if err != nil {
return err
}
// Only need to continue reading for messages and lists.
switch tok.Kind() {
case text.MessageOpen:
return d.skipMessageValue()
case text.ListOpen:
for {
tok, err := d.Read()
if err != nil {
return err
}
switch tok.Kind() {
case text.ListClose:
return nil
case text.MessageOpen:
if err := d.skipMessageValue(); err != nil {
return err
}
default:
// Skip items. This will not validate whether skipped values are
// of the same type or not, same behavior as C++
// TextFormat::Parser::AllowUnknownField(true) version 3.8.0.
}
}
}
return nil
}
// skipMessageValue makes the decoder parse and skip over all fields in a
// message. It assumes that the previous read type is MessageOpen.
func (d decoder) skipMessageValue() error {
for {
tok, err := d.Read()
if err != nil {
return err
}
switch tok.Kind() {
case text.MessageClose:
return nil
case text.Name:
if err := d.skipValue(); err != nil {
return err
}
}
}
}
-7
View File
@@ -1,7 +0,0 @@
// 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 prototext marshals and unmarshals protocol buffer messages as the
// textproto format.
package prototext
-380
View File
@@ -1,380 +0,0 @@
// 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 prototext
import (
"fmt"
"strconv"
"unicode/utf8"
"google.golang.org/protobuf/encoding/protowire"
"google.golang.org/protobuf/internal/encoding/messageset"
"google.golang.org/protobuf/internal/encoding/text"
"google.golang.org/protobuf/internal/errors"
"google.golang.org/protobuf/internal/flags"
"google.golang.org/protobuf/internal/genid"
"google.golang.org/protobuf/internal/order"
"google.golang.org/protobuf/internal/pragma"
"google.golang.org/protobuf/internal/strs"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/reflect/protoreflect"
"google.golang.org/protobuf/reflect/protoregistry"
)
const defaultIndent = " "
// Format formats the message as a multiline string.
// This function is only intended for human consumption and ignores errors.
// Do not depend on the output being stable. Its output will change across
// different builds of your program, even when using the same version of the
// protobuf module.
func Format(m proto.Message) string {
return MarshalOptions{Multiline: true}.Format(m)
}
// Marshal writes the given [proto.Message] in textproto format using default
// options. Do not depend on the output being stable. Its output will change
// across different builds of your program, even when using the same version of
// the protobuf module.
func Marshal(m proto.Message) ([]byte, error) {
return MarshalOptions{}.Marshal(m)
}
// MarshalOptions is a configurable text format marshaler.
type MarshalOptions struct {
pragma.NoUnkeyedLiterals
// Multiline specifies whether the marshaler should format the output in
// indented-form with every textual element on a new line.
// If Indent is an empty string, then an arbitrary indent is chosen.
Multiline bool
// Indent specifies the set of indentation characters to use in a multiline
// formatted output such that every entry is preceded by Indent and
// terminated by a newline. If non-empty, then Multiline is treated as true.
// Indent can only be composed of space or tab characters.
Indent string
// EmitASCII specifies whether to format strings and bytes as ASCII only
// as opposed to using UTF-8 encoding when possible.
EmitASCII bool
// allowInvalidUTF8 specifies whether to permit the encoding of strings
// with invalid UTF-8. This is unexported as it is intended to only
// be specified by the Format method.
allowInvalidUTF8 bool
// AllowPartial allows messages that have missing required fields to marshal
// without returning an error. If AllowPartial is false (the default),
// Marshal will return error if there are any missing required fields.
AllowPartial bool
// EmitUnknown specifies whether to emit unknown fields in the output.
// If specified, the unmarshaler may be unable to parse the output.
// The default is to exclude unknown fields.
EmitUnknown bool
// Resolver is used for looking up types when expanding google.protobuf.Any
// messages. If nil, this defaults to using protoregistry.GlobalTypes.
Resolver interface {
protoregistry.ExtensionTypeResolver
protoregistry.MessageTypeResolver
}
}
// Format formats the message as a string.
// This method is only intended for human consumption and ignores errors.
// Do not depend on the output being stable. Its output will change across
// different builds of your program, even when using the same version of the
// protobuf module.
func (o MarshalOptions) Format(m proto.Message) string {
if m == nil || !m.ProtoReflect().IsValid() {
return "<nil>" // invalid syntax, but okay since this is for debugging
}
o.allowInvalidUTF8 = true
o.AllowPartial = true
o.EmitUnknown = true
b, _ := o.Marshal(m)
return string(b)
}
// Marshal writes the given [proto.Message] in textproto format using options in
// MarshalOptions object. Do not depend on the output being stable. Its output
// will change across different builds of your program, even when using the
// same version of the protobuf module.
func (o MarshalOptions) Marshal(m proto.Message) ([]byte, error) {
return o.marshal(nil, m)
}
// MarshalAppend appends the textproto format encoding of m to b,
// returning the result.
func (o MarshalOptions) MarshalAppend(b []byte, m proto.Message) ([]byte, error) {
return o.marshal(b, m)
}
// marshal is a centralized function that all marshal operations go through.
// For profiling purposes, avoid changing the name of this function or
// introducing other code paths for marshal that do not go through this.
func (o MarshalOptions) marshal(b []byte, m proto.Message) ([]byte, error) {
var delims = [2]byte{'{', '}'}
if o.Multiline && o.Indent == "" {
o.Indent = defaultIndent
}
if o.Resolver == nil {
o.Resolver = protoregistry.GlobalTypes
}
internalEnc, err := text.NewEncoder(b, o.Indent, delims, o.EmitASCII)
if err != nil {
return nil, err
}
// Treat nil message interface as an empty message,
// in which case there is nothing to output.
if m == nil {
return b, nil
}
enc := encoder{internalEnc, o}
err = enc.marshalMessage(m.ProtoReflect(), false)
if err != nil {
return nil, err
}
out := enc.Bytes()
if len(o.Indent) > 0 && len(out) > 0 {
out = append(out, '\n')
}
if o.AllowPartial {
return out, nil
}
return out, proto.CheckInitialized(m)
}
type encoder struct {
*text.Encoder
opts MarshalOptions
}
// marshalMessage marshals the given protoreflect.Message.
func (e encoder) marshalMessage(m protoreflect.Message, inclDelims bool) error {
messageDesc := m.Descriptor()
if !flags.ProtoLegacy && messageset.IsMessageSet(messageDesc) {
return errors.New("no support for proto1 MessageSets")
}
if inclDelims {
e.StartMessage()
defer e.EndMessage()
}
// Handle Any expansion.
if messageDesc.FullName() == genid.Any_message_fullname {
if e.marshalAny(m) {
return nil
}
// If unable to expand, continue on to marshal Any as a regular message.
}
// Marshal fields.
var err error
order.RangeFields(m, order.IndexNameFieldOrder, func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool {
if err = e.marshalField(fd.TextName(), v, fd); err != nil {
return false
}
return true
})
if err != nil {
return err
}
// Marshal unknown fields.
if e.opts.EmitUnknown {
e.marshalUnknown(m.GetUnknown())
}
return nil
}
// marshalField marshals the given field with protoreflect.Value.
func (e encoder) marshalField(name string, val protoreflect.Value, fd protoreflect.FieldDescriptor) error {
switch {
case fd.IsList():
return e.marshalList(name, val.List(), fd)
case fd.IsMap():
return e.marshalMap(name, val.Map(), fd)
default:
e.WriteName(name)
return e.marshalSingular(val, fd)
}
}
// marshalSingular marshals the given non-repeated field value. This includes
// all scalar types, enums, messages, and groups.
func (e encoder) marshalSingular(val protoreflect.Value, fd protoreflect.FieldDescriptor) error {
kind := fd.Kind()
switch kind {
case protoreflect.BoolKind:
e.WriteBool(val.Bool())
case protoreflect.StringKind:
s := val.String()
if !e.opts.allowInvalidUTF8 && strs.EnforceUTF8(fd) && !utf8.ValidString(s) {
return errors.InvalidUTF8(string(fd.FullName()))
}
e.WriteString(s)
case protoreflect.Int32Kind, protoreflect.Int64Kind,
protoreflect.Sint32Kind, protoreflect.Sint64Kind,
protoreflect.Sfixed32Kind, protoreflect.Sfixed64Kind:
e.WriteInt(val.Int())
case protoreflect.Uint32Kind, protoreflect.Uint64Kind,
protoreflect.Fixed32Kind, protoreflect.Fixed64Kind:
e.WriteUint(val.Uint())
case protoreflect.FloatKind:
// Encoder.WriteFloat handles the special numbers NaN and infinites.
e.WriteFloat(val.Float(), 32)
case protoreflect.DoubleKind:
// Encoder.WriteFloat handles the special numbers NaN and infinites.
e.WriteFloat(val.Float(), 64)
case protoreflect.BytesKind:
e.WriteString(string(val.Bytes()))
case protoreflect.EnumKind:
num := val.Enum()
if desc := fd.Enum().Values().ByNumber(num); desc != nil {
e.WriteLiteral(string(desc.Name()))
} else {
// Use numeric value if there is no enum description.
e.WriteInt(int64(num))
}
case protoreflect.MessageKind, protoreflect.GroupKind:
return e.marshalMessage(val.Message(), true)
default:
panic(fmt.Sprintf("%v has unknown kind: %v", fd.FullName(), kind))
}
return nil
}
// marshalList marshals the given protoreflect.List as multiple name-value fields.
func (e encoder) marshalList(name string, list protoreflect.List, fd protoreflect.FieldDescriptor) error {
size := list.Len()
for i := 0; i < size; i++ {
e.WriteName(name)
if err := e.marshalSingular(list.Get(i), fd); err != nil {
return err
}
}
return nil
}
// marshalMap marshals the given protoreflect.Map as multiple name-value fields.
func (e encoder) marshalMap(name string, mmap protoreflect.Map, fd protoreflect.FieldDescriptor) error {
var err error
order.RangeEntries(mmap, order.GenericKeyOrder, func(key protoreflect.MapKey, val protoreflect.Value) bool {
e.WriteName(name)
e.StartMessage()
defer e.EndMessage()
e.WriteName(string(genid.MapEntry_Key_field_name))
err = e.marshalSingular(key.Value(), fd.MapKey())
if err != nil {
return false
}
e.WriteName(string(genid.MapEntry_Value_field_name))
err = e.marshalSingular(val, fd.MapValue())
if err != nil {
return false
}
return true
})
return err
}
// marshalUnknown parses the given []byte and marshals fields out.
// This function assumes proper encoding in the given []byte.
func (e encoder) marshalUnknown(b []byte) {
const dec = 10
const hex = 16
for len(b) > 0 {
num, wtype, n := protowire.ConsumeTag(b)
b = b[n:]
e.WriteName(strconv.FormatInt(int64(num), dec))
switch wtype {
case protowire.VarintType:
var v uint64
v, n = protowire.ConsumeVarint(b)
e.WriteUint(v)
case protowire.Fixed32Type:
var v uint32
v, n = protowire.ConsumeFixed32(b)
e.WriteLiteral("0x" + strconv.FormatUint(uint64(v), hex))
case protowire.Fixed64Type:
var v uint64
v, n = protowire.ConsumeFixed64(b)
e.WriteLiteral("0x" + strconv.FormatUint(v, hex))
case protowire.BytesType:
var v []byte
v, n = protowire.ConsumeBytes(b)
e.WriteString(string(v))
case protowire.StartGroupType:
e.StartMessage()
var v []byte
v, n = protowire.ConsumeGroup(num, b)
e.marshalUnknown(v)
e.EndMessage()
default:
panic(fmt.Sprintf("prototext: error parsing unknown field wire type: %v", wtype))
}
b = b[n:]
}
}
// marshalAny marshals the given google.protobuf.Any message in expanded form.
// It returns true if it was able to marshal, else false.
func (e encoder) marshalAny(any protoreflect.Message) bool {
// Construct the embedded message.
fds := any.Descriptor().Fields()
fdType := fds.ByNumber(genid.Any_TypeUrl_field_number)
typeURL := any.Get(fdType).String()
mt, err := e.opts.Resolver.FindMessageByURL(typeURL)
if err != nil {
return false
}
m := mt.New().Interface()
// Unmarshal bytes into embedded message.
fdValue := fds.ByNumber(genid.Any_Value_field_number)
value := any.Get(fdValue)
err = proto.UnmarshalOptions{
AllowPartial: true,
Resolver: e.opts.Resolver,
}.Unmarshal(value.Bytes(), m)
if err != nil {
return false
}
// Get current encoder position. If marshaling fails, reset encoder output
// back to this position.
pos := e.Snapshot()
// Field name is the proto field name enclosed in [].
e.WriteName("[" + typeURL + "]")
err = e.marshalMessage(m.ProtoReflect(), true)
if err != nil {
e.Reset(pos)
return false
}
return true
}
-571
View File
@@ -1,571 +0,0 @@
// 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 protowire parses and formats the raw wire encoding.
// See https://protobuf.dev/programming-guides/encoding.
//
// For marshaling and unmarshaling entire protobuf messages,
// use the [google.golang.org/protobuf/proto] package instead.
package protowire
import (
"io"
"math"
"math/bits"
"google.golang.org/protobuf/internal/errors"
)
// Number represents the field number.
type Number int32
const (
MinValidNumber Number = 1
FirstReservedNumber Number = 19000
LastReservedNumber Number = 19999
MaxValidNumber Number = 1<<29 - 1
DefaultRecursionLimit = 10000
)
// IsValid reports whether the field number is semantically valid.
func (n Number) IsValid() bool {
return MinValidNumber <= n && n <= MaxValidNumber
}
// Type represents the wire type.
type Type int8
const (
VarintType Type = 0
Fixed32Type Type = 5
Fixed64Type Type = 1
BytesType Type = 2
StartGroupType Type = 3
EndGroupType Type = 4
)
const (
_ = -iota
errCodeTruncated
errCodeFieldNumber
errCodeOverflow
errCodeReserved
errCodeEndGroup
errCodeRecursionDepth
)
var (
errFieldNumber = errors.New("invalid field number")
errOverflow = errors.New("variable length integer overflow")
errReserved = errors.New("cannot parse reserved wire type")
errEndGroup = errors.New("mismatching end group marker")
errParse = errors.New("parse error")
)
// ParseError converts an error code into an error value.
// This returns nil if n is a non-negative number.
func ParseError(n int) error {
if n >= 0 {
return nil
}
switch n {
case errCodeTruncated:
return io.ErrUnexpectedEOF
case errCodeFieldNumber:
return errFieldNumber
case errCodeOverflow:
return errOverflow
case errCodeReserved:
return errReserved
case errCodeEndGroup:
return errEndGroup
default:
return errParse
}
}
// ConsumeField parses an entire field record (both tag and value) and returns
// the field number, the wire type, and the total length.
// This returns a negative length upon an error (see [ParseError]).
//
// The total length includes the tag header and the end group marker (if the
// field is a group).
func ConsumeField(b []byte) (Number, Type, int) {
num, typ, n := ConsumeTag(b)
if n < 0 {
return 0, 0, n // forward error code
}
m := ConsumeFieldValue(num, typ, b[n:])
if m < 0 {
return 0, 0, m // forward error code
}
return num, typ, n + m
}
// ConsumeFieldValue parses a field value and returns its length.
// This assumes that the field [Number] and wire [Type] have already been parsed.
// This returns a negative length upon an error (see [ParseError]).
//
// When parsing a group, the length includes the end group marker and
// the end group is verified to match the starting field number.
func ConsumeFieldValue(num Number, typ Type, b []byte) (n int) {
return consumeFieldValueD(num, typ, b, DefaultRecursionLimit)
}
func consumeFieldValueD(num Number, typ Type, b []byte, depth int) (n int) {
switch typ {
case VarintType:
_, n = ConsumeVarint(b)
return n
case Fixed32Type:
_, n = ConsumeFixed32(b)
return n
case Fixed64Type:
_, n = ConsumeFixed64(b)
return n
case BytesType:
_, n = ConsumeBytes(b)
return n
case StartGroupType:
if depth < 0 {
return errCodeRecursionDepth
}
n0 := len(b)
for {
num2, typ2, n := ConsumeTag(b)
if n < 0 {
return n // forward error code
}
b = b[n:]
if typ2 == EndGroupType {
if num != num2 {
return errCodeEndGroup
}
return n0 - len(b)
}
n = consumeFieldValueD(num2, typ2, b, depth-1)
if n < 0 {
return n // forward error code
}
b = b[n:]
}
case EndGroupType:
return errCodeEndGroup
default:
return errCodeReserved
}
}
// AppendTag encodes num and typ as a varint-encoded tag and appends it to b.
func AppendTag(b []byte, num Number, typ Type) []byte {
return AppendVarint(b, EncodeTag(num, typ))
}
// ConsumeTag parses b as a varint-encoded tag, reporting its length.
// This returns a negative length upon an error (see [ParseError]).
func ConsumeTag(b []byte) (Number, Type, int) {
v, n := ConsumeVarint(b)
if n < 0 {
return 0, 0, n // forward error code
}
num, typ := DecodeTag(v)
if num < MinValidNumber {
return 0, 0, errCodeFieldNumber
}
return num, typ, n
}
func SizeTag(num Number) int {
return SizeVarint(EncodeTag(num, 0)) // wire type has no effect on size
}
// AppendVarint appends v to b as a varint-encoded uint64.
func AppendVarint(b []byte, v uint64) []byte {
switch {
case v < 1<<7:
b = append(b, byte(v))
case v < 1<<14:
b = append(b,
byte((v>>0)&0x7f|0x80),
byte(v>>7))
case v < 1<<21:
b = append(b,
byte((v>>0)&0x7f|0x80),
byte((v>>7)&0x7f|0x80),
byte(v>>14))
case v < 1<<28:
b = append(b,
byte((v>>0)&0x7f|0x80),
byte((v>>7)&0x7f|0x80),
byte((v>>14)&0x7f|0x80),
byte(v>>21))
case v < 1<<35:
b = append(b,
byte((v>>0)&0x7f|0x80),
byte((v>>7)&0x7f|0x80),
byte((v>>14)&0x7f|0x80),
byte((v>>21)&0x7f|0x80),
byte(v>>28))
case v < 1<<42:
b = append(b,
byte((v>>0)&0x7f|0x80),
byte((v>>7)&0x7f|0x80),
byte((v>>14)&0x7f|0x80),
byte((v>>21)&0x7f|0x80),
byte((v>>28)&0x7f|0x80),
byte(v>>35))
case v < 1<<49:
b = append(b,
byte((v>>0)&0x7f|0x80),
byte((v>>7)&0x7f|0x80),
byte((v>>14)&0x7f|0x80),
byte((v>>21)&0x7f|0x80),
byte((v>>28)&0x7f|0x80),
byte((v>>35)&0x7f|0x80),
byte(v>>42))
case v < 1<<56:
b = append(b,
byte((v>>0)&0x7f|0x80),
byte((v>>7)&0x7f|0x80),
byte((v>>14)&0x7f|0x80),
byte((v>>21)&0x7f|0x80),
byte((v>>28)&0x7f|0x80),
byte((v>>35)&0x7f|0x80),
byte((v>>42)&0x7f|0x80),
byte(v>>49))
case v < 1<<63:
b = append(b,
byte((v>>0)&0x7f|0x80),
byte((v>>7)&0x7f|0x80),
byte((v>>14)&0x7f|0x80),
byte((v>>21)&0x7f|0x80),
byte((v>>28)&0x7f|0x80),
byte((v>>35)&0x7f|0x80),
byte((v>>42)&0x7f|0x80),
byte((v>>49)&0x7f|0x80),
byte(v>>56))
default:
b = append(b,
byte((v>>0)&0x7f|0x80),
byte((v>>7)&0x7f|0x80),
byte((v>>14)&0x7f|0x80),
byte((v>>21)&0x7f|0x80),
byte((v>>28)&0x7f|0x80),
byte((v>>35)&0x7f|0x80),
byte((v>>42)&0x7f|0x80),
byte((v>>49)&0x7f|0x80),
byte((v>>56)&0x7f|0x80),
1)
}
return b
}
// ConsumeVarint parses b as a varint-encoded uint64, reporting its length.
// This returns a negative length upon an error (see [ParseError]).
func ConsumeVarint(b []byte) (v uint64, n int) {
var y uint64
if len(b) <= 0 {
return 0, errCodeTruncated
}
v = uint64(b[0])
if v < 0x80 {
return v, 1
}
v -= 0x80
if len(b) <= 1 {
return 0, errCodeTruncated
}
y = uint64(b[1])
v += y << 7
if y < 0x80 {
return v, 2
}
v -= 0x80 << 7
if len(b) <= 2 {
return 0, errCodeTruncated
}
y = uint64(b[2])
v += y << 14
if y < 0x80 {
return v, 3
}
v -= 0x80 << 14
if len(b) <= 3 {
return 0, errCodeTruncated
}
y = uint64(b[3])
v += y << 21
if y < 0x80 {
return v, 4
}
v -= 0x80 << 21
if len(b) <= 4 {
return 0, errCodeTruncated
}
y = uint64(b[4])
v += y << 28
if y < 0x80 {
return v, 5
}
v -= 0x80 << 28
if len(b) <= 5 {
return 0, errCodeTruncated
}
y = uint64(b[5])
v += y << 35
if y < 0x80 {
return v, 6
}
v -= 0x80 << 35
if len(b) <= 6 {
return 0, errCodeTruncated
}
y = uint64(b[6])
v += y << 42
if y < 0x80 {
return v, 7
}
v -= 0x80 << 42
if len(b) <= 7 {
return 0, errCodeTruncated
}
y = uint64(b[7])
v += y << 49
if y < 0x80 {
return v, 8
}
v -= 0x80 << 49
if len(b) <= 8 {
return 0, errCodeTruncated
}
y = uint64(b[8])
v += y << 56
if y < 0x80 {
return v, 9
}
v -= 0x80 << 56
if len(b) <= 9 {
return 0, errCodeTruncated
}
y = uint64(b[9])
v += y << 63
if y < 2 {
return v, 10
}
return 0, errCodeOverflow
}
// SizeVarint returns the encoded size of a varint.
// The size is guaranteed to be within 1 and 10, inclusive.
func SizeVarint(v uint64) int {
// This computes 1 + (bits.Len64(v)-1)/7.
// 9/64 is a good enough approximation of 1/7
//
// The Go compiler can translate the bits.LeadingZeros64 call into the LZCNT
// instruction, which is very fast on CPUs from the last few years. The
// specific way of expressing the calculation matches C++ Protobuf, see
// https://godbolt.org/z/4P3h53oM4 for the C++ code and how gcc/clang
// optimize that function for GOAMD64=v1 and GOAMD64=v3 (-march=haswell).
// By OR'ing v with 1, we guarantee that v is never 0, without changing the
// result of SizeVarint. LZCNT is not defined for 0, meaning the compiler
// needs to add extra instructions to handle that case.
//
// The Go compiler currently (go1.24.4) does not make use of this knowledge.
// This opportunity (removing the XOR instruction, which handles the 0 case)
// results in a small (1%) performance win across CPU architectures.
//
// Independently of avoiding the 0 case, we need the v |= 1 line because
// it allows the Go compiler to eliminate an extra XCHGL barrier.
v |= 1
// It would be clearer to write log2value := 63 - uint32(...), but
// writing uint32(...) ^ 63 is much more efficient (-14% ARM, -20% Intel).
// Proof of identity for our value range [0..63]:
// https://go.dev/play/p/Pdn9hEWYakX
log2value := uint32(bits.LeadingZeros64(v)) ^ 63
return int((log2value*9 + (64 + 9)) / 64)
}
// AppendFixed32 appends v to b as a little-endian uint32.
func AppendFixed32(b []byte, v uint32) []byte {
return append(b,
byte(v>>0),
byte(v>>8),
byte(v>>16),
byte(v>>24))
}
// ConsumeFixed32 parses b as a little-endian uint32, reporting its length.
// This returns a negative length upon an error (see [ParseError]).
func ConsumeFixed32(b []byte) (v uint32, n int) {
if len(b) < 4 {
return 0, errCodeTruncated
}
v = uint32(b[0])<<0 | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24
return v, 4
}
// SizeFixed32 returns the encoded size of a fixed32; which is always 4.
func SizeFixed32() int {
return 4
}
// AppendFixed64 appends v to b as a little-endian uint64.
func AppendFixed64(b []byte, v uint64) []byte {
return append(b,
byte(v>>0),
byte(v>>8),
byte(v>>16),
byte(v>>24),
byte(v>>32),
byte(v>>40),
byte(v>>48),
byte(v>>56))
}
// ConsumeFixed64 parses b as a little-endian uint64, reporting its length.
// This returns a negative length upon an error (see [ParseError]).
func ConsumeFixed64(b []byte) (v uint64, n int) {
if len(b) < 8 {
return 0, errCodeTruncated
}
v = uint64(b[0])<<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
return v, 8
}
// SizeFixed64 returns the encoded size of a fixed64; which is always 8.
func SizeFixed64() int {
return 8
}
// AppendBytes appends v to b as a length-prefixed bytes value.
func AppendBytes(b []byte, v []byte) []byte {
return append(AppendVarint(b, uint64(len(v))), v...)
}
// ConsumeBytes parses b as a length-prefixed bytes value, reporting its length.
// This returns a negative length upon an error (see [ParseError]).
func ConsumeBytes(b []byte) (v []byte, n int) {
m, n := ConsumeVarint(b)
if n < 0 {
return nil, n // forward error code
}
if m > uint64(len(b[n:])) {
return nil, errCodeTruncated
}
return b[n:][:m], n + int(m)
}
// SizeBytes returns the encoded size of a length-prefixed bytes value,
// given only the length.
func SizeBytes(n int) int {
return SizeVarint(uint64(n)) + n
}
// AppendString appends v to b as a length-prefixed bytes value.
func AppendString(b []byte, v string) []byte {
return append(AppendVarint(b, uint64(len(v))), v...)
}
// ConsumeString parses b as a length-prefixed bytes value, reporting its length.
// This returns a negative length upon an error (see [ParseError]).
func ConsumeString(b []byte) (v string, n int) {
bb, n := ConsumeBytes(b)
return string(bb), n
}
// AppendGroup appends v to b as group value, with a trailing end group marker.
// The value v must not contain the end marker.
func AppendGroup(b []byte, num Number, v []byte) []byte {
return AppendVarint(append(b, v...), EncodeTag(num, EndGroupType))
}
// ConsumeGroup parses b as a group value until the trailing end group marker,
// and verifies that the end marker matches the provided num. The value v
// does not contain the end marker, while the length does contain the end marker.
// This returns a negative length upon an error (see [ParseError]).
func ConsumeGroup(num Number, b []byte) (v []byte, n int) {
n = ConsumeFieldValue(num, StartGroupType, b)
if n < 0 {
return nil, n // forward error code
}
b = b[:n]
// Truncate off end group marker, but need to handle denormalized varints.
// Assuming end marker is never 0 (which is always the case since
// EndGroupType is non-zero), we can truncate all trailing bytes where the
// lower 7 bits are all zero (implying that the varint is denormalized).
for len(b) > 0 && b[len(b)-1]&0x7f == 0 {
b = b[:len(b)-1]
}
b = b[:len(b)-SizeTag(num)]
return b, n
}
// SizeGroup returns the encoded size of a group, given only the length.
func SizeGroup(num Number, n int) int {
return n + SizeTag(num)
}
// DecodeTag decodes the field [Number] and wire [Type] from its unified form.
// The [Number] is -1 if the decoded field number overflows int32.
// Other than overflow, this does not check for field number validity.
func DecodeTag(x uint64) (Number, Type) {
// NOTE: MessageSet allows for larger field numbers than normal.
if x>>3 > uint64(math.MaxInt32) {
return -1, 0
}
return Number(x >> 3), Type(x & 7)
}
// EncodeTag encodes the field [Number] and wire [Type] into its unified form.
func EncodeTag(num Number, typ Type) uint64 {
return uint64(num)<<3 | uint64(typ&7)
}
// DecodeZigZag decodes a zig-zag-encoded uint64 as an int64.
//
// Input: {…, 5, 3, 1, 0, 2, 4, 6, …}
// Output: {…, -3, -2, -1, 0, +1, +2, +3, …}
func DecodeZigZag(x uint64) int64 {
return int64(x>>1) ^ int64(x)<<63>>63
}
// EncodeZigZag encodes an int64 as a zig-zag-encoded uint64.
//
// Input: {…, -3, -2, -1, 0, +1, +2, +3, …}
// Output: {…, 5, 3, 1, 0, 2, 4, 6, …}
func EncodeZigZag(x int64) uint64 {
return uint64(x<<1) ^ uint64(x>>63)
}
// DecodeBool decodes a uint64 as a bool.
//
// Input: { 0, 1, 2, …}
// Output: {false, true, true, …}
func DecodeBool(x uint64) bool {
return x != 0
}
// EncodeBool encodes a bool as a uint64.
//
// Input: {false, true}
// Output: { 0, 1}
func EncodeBool(x bool) uint64 {
if x {
return 1
}
return 0
}

Some files were not shown because too many files have changed in this diff Show More