From 46f61fd5adc9d724d1921f866d51ee43b5f113db Mon Sep 17 00:00:00 2001 From: Christian Haudum Date: Thu, 3 Oct 2024 18:02:52 +0200 Subject: [PATCH 01/26] chore: Remove ring client pool from JumpHashClientPool (#14367) The ring client pool has functionality, such as periodic health checking of the servers and removing of stale clients, which is not needed in the JumpHashClientPool. The removal of stale clients was problematic, because it compared the original server list (which is a list of CNAME records from the DNS lookup) with the client cache, which uses the IP of the server as key. Therefore it removed all cached clients on every check interval. Signed-off-by: Christian Haudum --- docs/sources/shared/configuration.md | 13 +--- pkg/bloomgateway/client.go | 17 ++-- pkg/bloomgateway/client_pool.go | 111 ++++++++++++++++----------- pkg/bloomgateway/client_pool_test.go | 3 +- 4 files changed, 74 insertions(+), 70 deletions(-) diff --git a/docs/sources/shared/configuration.md b/docs/sources/shared/configuration.md index ce2c8d359d752..64cfdf6d835a7 100644 --- a/docs/sources/shared/configuration.md +++ b/docs/sources/shared/configuration.md @@ -1298,18 +1298,9 @@ Experimental: The `bloom_gateway` block configures the Loki bloom gateway server client: # Configures the behavior of the connection pool. pool_config: - # How frequently to clean up clients for servers that have gone away or are - # unhealthy. + # How frequently to update the list of servers. # CLI flag: -bloom-gateway-client.pool.check-interval - [check_interval: | default = 10s] - - # Run a health check on each server during periodic cleanup. - # CLI flag: -bloom-gateway-client.pool.enable-health-check - [enable_health_check: | default = true] - - # Timeout for the health check if health check is enabled. - # CLI flag: -bloom-gateway-client.pool.health-check-timeout - [health_check_timeout: | default = 1s] + [check_interval: | default = 15s] # The grpc_client block configures the gRPC client used to communicate between # a client and server component in Loki. diff --git a/pkg/bloomgateway/client.go b/pkg/bloomgateway/client.go index 2529a678e7794..a873d04960b47 100644 --- a/pkg/bloomgateway/client.go +++ b/pkg/bloomgateway/client.go @@ -161,7 +161,7 @@ func NewClient( } } - poolFactory := func(addr string) (ringclient.PoolClient, error) { + clientFactory := func(addr string) (ringclient.PoolClient, error) { pool, err := NewBloomGatewayGRPCPool(addr, dialOpts) if err != nil { return nil, errors.Wrap(err, "new bloom gateway grpc pool") @@ -185,17 +185,10 @@ func NewClient( // Make an attempt to do one DNS lookup so we can start with addresses dnsProvider.RunOnce() - clientPool := ringclient.NewPool( - "bloom-gateway", - ringclient.PoolConfig(cfg.PoolConfig), - func() ([]string, error) { return dnsProvider.Addresses(), nil }, - ringclient.PoolAddrFunc(poolFactory), - metrics.clients, - logger, - ) - - pool := NewJumpHashClientPool(clientPool, dnsProvider, cfg.PoolConfig.CheckInterval, logger) - pool.Start() + pool, err := NewJumpHashClientPool(clientFactory, dnsProvider, cfg.PoolConfig.CheckInterval, logger) + if err != nil { + return nil, err + } return &GatewayClient{ cfg: cfg, diff --git a/pkg/bloomgateway/client_pool.go b/pkg/bloomgateway/client_pool.go index 989ced34c6730..4b45292bef889 100644 --- a/pkg/bloomgateway/client_pool.go +++ b/pkg/bloomgateway/client_pool.go @@ -3,7 +3,7 @@ package bloomgateway import ( "context" "flag" - "sort" + "sync" "time" "github.com/go-kit/log" @@ -15,38 +15,45 @@ import ( ) // PoolConfig is config for creating a Pool. -// It has the same fields as "github.com/grafana/dskit/ring/client.PoolConfig" so it can be cast. type PoolConfig struct { - CheckInterval time.Duration `yaml:"check_interval"` - HealthCheckEnabled bool `yaml:"enable_health_check"` - HealthCheckTimeout time.Duration `yaml:"health_check_timeout"` - MaxConcurrentHealthChecks int `yaml:"-"` + CheckInterval time.Duration `yaml:"check_interval"` } // RegisterFlags adds the flags required to config this to the given FlagSet. func (cfg *PoolConfig) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) { - f.DurationVar(&cfg.CheckInterval, prefix+"check-interval", 10*time.Second, "How frequently to clean up clients for servers that have gone away or are unhealthy.") - f.BoolVar(&cfg.HealthCheckEnabled, prefix+"enable-health-check", true, "Run a health check on each server during periodic cleanup.") - f.DurationVar(&cfg.HealthCheckTimeout, prefix+"health-check-timeout", 1*time.Second, "Timeout for the health check if health check is enabled.") + f.DurationVar(&cfg.CheckInterval, prefix+"check-interval", 15*time.Second, "How frequently to update the list of servers.") } func (cfg *PoolConfig) Validate() error { return nil } +// compiler check +var _ clientPool = &JumpHashClientPool{} + +type ClientFactory func(addr string) (client.PoolClient, error) + +func (f ClientFactory) New(addr string) (client.PoolClient, error) { + return f(addr) +} + type JumpHashClientPool struct { - *client.Pool + services.Service *jumphash.Selector + sync.RWMutex + + provider AddressProvider + logger log.Logger - done chan struct{} - logger log.Logger + clients map[string]client.PoolClient + clientFactory ClientFactory } type AddressProvider interface { Addresses() []string } -func NewJumpHashClientPool(pool *client.Pool, dnsProvider AddressProvider, updateInterval time.Duration, logger log.Logger) *JumpHashClientPool { +func NewJumpHashClientPool(clientFactory ClientFactory, dnsProvider AddressProvider, updateInterval time.Duration, logger log.Logger) (*JumpHashClientPool, error) { selector := jumphash.DefaultSelector() err := selector.SetServers(dnsProvider.Addresses()...) if err != nil { @@ -54,14 +61,19 @@ func NewJumpHashClientPool(pool *client.Pool, dnsProvider AddressProvider, updat } p := &JumpHashClientPool{ - Pool: pool, - Selector: selector, - done: make(chan struct{}), - logger: logger, + Selector: selector, + clientFactory: clientFactory, + provider: dnsProvider, + logger: logger, + clients: make(map[string]client.PoolClient, len(dnsProvider.Addresses())), } - go p.updateLoop(dnsProvider, updateInterval) - return p + p.Service = services.NewTimerService(updateInterval, nil, p.updateLoop, nil) + return p, services.StartAndAwaitRunning(context.Background(), p.Service) +} + +func (p *JumpHashClientPool) Stop() { + _ = services.StopAndAwaitTerminated(context.Background(), p.Service) } func (p *JumpHashClientPool) AddrForFingerprint(fp uint64) (string, error) { @@ -80,35 +92,42 @@ func (p *JumpHashClientPool) Addr(key string) (string, error) { return addr.String(), nil } -func (p *JumpHashClientPool) Start() { - ctx := context.Background() - _ = services.StartAndAwaitRunning(ctx, p.Pool) +func (p *JumpHashClientPool) updateLoop(_ context.Context) error { + err := p.SetServers(p.provider.Addresses()...) + if err != nil { + level.Warn(p.logger).Log("msg", "error updating servers", "err", err) + } + return nil } -func (p *JumpHashClientPool) Stop() { - ctx := context.Background() - _ = services.StopAndAwaitTerminated(ctx, p.Pool) - close(p.done) -} +// GetClientFor implements clientPool. +func (p *JumpHashClientPool) GetClientFor(addr string) (client.PoolClient, error) { + client, ok := p.fromCache(addr) + if ok { + return client, nil + } + + // No client in cache so create one + p.Lock() + defer p.Unlock() -func (p *JumpHashClientPool) updateLoop(provider AddressProvider, updateInterval time.Duration) { - ticker := time.NewTicker(updateInterval) - defer ticker.Stop() - - for { - select { - case <-p.done: - return - case <-ticker.C: - servers := provider.Addresses() - // ServerList deterministically maps keys to _index_ of the server list. - // Since DNS returns records in different order each time, we sort to - // guarantee best possible match between nodes. - sort.Strings(servers) - err := p.SetServers(servers...) - if err != nil { - level.Warn(p.logger).Log("msg", "error updating servers", "err", err) - } - } + // Check if a client has been created just after checking the cache and before acquiring the lock. + client, ok = p.clients[addr] + if ok { + return client, nil } + + client, err := p.clientFactory.New(addr) + if err != nil { + return nil, err + } + p.clients[addr] = client + return client, nil +} + +func (p *JumpHashClientPool) fromCache(addr string) (client.PoolClient, bool) { + p.RLock() + defer p.RUnlock() + client, ok := p.clients[addr] + return client, ok } diff --git a/pkg/bloomgateway/client_pool_test.go b/pkg/bloomgateway/client_pool_test.go index 5e3792861f4c3..a592bf2417866 100644 --- a/pkg/bloomgateway/client_pool_test.go +++ b/pkg/bloomgateway/client_pool_test.go @@ -31,7 +31,8 @@ func TestJumpHashClientPool_UpdateLoop(t *testing.T) { provider := &provider{} provider.UpdateAddresses([]string{"localhost:9095"}) - pool := NewJumpHashClientPool(nil, provider, interval, log.NewNopLogger()) + pool, err := NewJumpHashClientPool(nil, provider, interval, log.NewNopLogger()) + require.NoError(t, err) require.Len(t, pool.Addrs(), 1) require.Equal(t, "127.0.0.1:9095", pool.Addrs()[0].String()) From c8e6a9d38f36ccf1f32e634765bb2363628f3710 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 3 Oct 2024 11:34:29 -0600 Subject: [PATCH 02/26] fix(deps): update module github.com/shirou/gopsutil/v4 to v4.24.9 (#14357) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- go.mod | 4 +- go.sum | 10 +- .../github.com/ebitengine/purego/.gitignore | 1 + vendor/github.com/ebitengine/purego/LICENSE | 201 + vendor/github.com/ebitengine/purego/README.md | 97 + .../github.com/ebitengine/purego/abi_amd64.h | 99 + .../github.com/ebitengine/purego/abi_arm64.h | 39 + vendor/github.com/ebitengine/purego/cgo.go | 19 + .../github.com/ebitengine/purego/dlerror.go | 17 + vendor/github.com/ebitengine/purego/dlfcn.go | 99 + .../ebitengine/purego/dlfcn_android.go | 34 + .../ebitengine/purego/dlfcn_darwin.go | 24 + .../ebitengine/purego/dlfcn_freebsd.go | 14 + .../ebitengine/purego/dlfcn_linux.go | 16 + .../ebitengine/purego/dlfcn_nocgo_freebsd.go | 11 + .../ebitengine/purego/dlfcn_nocgo_linux.go | 19 + .../ebitengine/purego/dlfcn_playground.go | 24 + .../ebitengine/purego/dlfcn_stubs.s | 26 + vendor/github.com/ebitengine/purego/func.go | 436 ++ .../ebitengine/purego/go_runtime.go | 13 + .../purego/internal/cgo/dlfcn_cgo_unix.go | 56 + .../ebitengine/purego/internal/cgo/empty.go | 6 + .../purego/internal/cgo/syscall_cgo_unix.go | 55 + .../purego/internal/fakecgo/abi_amd64.h | 99 + .../purego/internal/fakecgo/abi_arm64.h | 39 + .../purego/internal/fakecgo/asm_amd64.s | 39 + .../purego/internal/fakecgo/asm_arm64.s | 36 + .../purego/internal/fakecgo/callbacks.go | 93 + .../ebitengine/purego/internal/fakecgo/doc.go | 32 + .../purego/internal/fakecgo/freebsd.go | 27 + .../internal/fakecgo/go_darwin_amd64.go | 73 + .../internal/fakecgo/go_darwin_arm64.go | 88 + .../internal/fakecgo/go_freebsd_amd64.go | 95 + .../internal/fakecgo/go_freebsd_arm64.go | 98 + .../purego/internal/fakecgo/go_libinit.go | 66 + .../purego/internal/fakecgo/go_linux_amd64.go | 95 + .../purego/internal/fakecgo/go_linux_arm64.go | 98 + .../purego/internal/fakecgo/go_setenv.go | 18 + .../purego/internal/fakecgo/go_util.go | 37 + .../purego/internal/fakecgo/iscgo.go | 19 + .../purego/internal/fakecgo/libcgo.go | 35 + .../purego/internal/fakecgo/libcgo_darwin.go | 22 + .../purego/internal/fakecgo/libcgo_freebsd.go | 16 + .../purego/internal/fakecgo/libcgo_linux.go | 16 + .../purego/internal/fakecgo/setenv.go | 19 + .../purego/internal/fakecgo/symbols.go | 181 + .../purego/internal/fakecgo/symbols_darwin.go | 29 + .../internal/fakecgo/symbols_freebsd.go | 29 + .../purego/internal/fakecgo/symbols_linux.go | 29 + .../internal/fakecgo/trampolines_amd64.s | 104 + .../internal/fakecgo/trampolines_arm64.s | 72 + .../internal/fakecgo/trampolines_stubs.s | 90 + .../purego/internal/strings/strings.go | 40 + vendor/github.com/ebitengine/purego/is_ios.go | 13 + vendor/github.com/ebitengine/purego/nocgo.go | 25 + .../ebitengine/purego/struct_amd64.go | 272 ++ .../ebitengine/purego/struct_arm64.go | 274 ++ .../ebitengine/purego/struct_other.go | 16 + .../github.com/ebitengine/purego/sys_amd64.s | 164 + .../github.com/ebitengine/purego/sys_arm64.s | 92 + .../ebitengine/purego/sys_unix_arm64.s | 70 + .../github.com/ebitengine/purego/syscall.go | 53 + .../ebitengine/purego/syscall_cgo_linux.go | 21 + .../ebitengine/purego/syscall_sysv.go | 223 + .../ebitengine/purego/syscall_windows.go | 46 + .../ebitengine/purego/zcallback_amd64.s | 2014 +++++++++ .../ebitengine/purego/zcallback_arm64.s | 4014 +++++++++++++++++ .../shirou/gopsutil/v4/common/env.go | 15 +- .../shirou/gopsutil/v4/cpu/cpu_aix_nocgo.go | 79 +- .../shirou/gopsutil/v4/cpu/cpu_darwin.go | 105 +- .../gopsutil/v4/cpu/cpu_darwin_arm64.go | 80 + .../shirou/gopsutil/v4/cpu/cpu_darwin_cgo.go | 111 - .../gopsutil/v4/cpu/cpu_darwin_fallback.go | 13 + .../gopsutil/v4/cpu/cpu_darwin_nocgo.go | 14 - .../shirou/gopsutil/v4/cpu/cpu_freebsd.go | 9 +- .../shirou/gopsutil/v4/cpu/cpu_linux.go | 6 +- .../shirou/gopsutil/v4/cpu/cpu_netbsd.go | 3 +- .../gopsutil/v4/internal/common/common.go | 13 +- .../v4/internal/common/common_darwin.go | 298 ++ .../v4/internal/common/common_linux.go | 5 +- .../v4/internal/common/common_unix.go | 20 - .../gopsutil/v4/internal/common/sleep.go | 2 +- .../shirou/gopsutil/v4/mem/mem_aix.go | 6 + .../shirou/gopsutil/v4/mem/mem_aix_nocgo.go | 8 +- .../shirou/gopsutil/v4/mem/mem_darwin.go | 58 + .../shirou/gopsutil/v4/mem/mem_darwin_cgo.go | 58 - .../gopsutil/v4/mem/mem_darwin_nocgo.go | 89 - .../shirou/gopsutil/v4/mem/mem_freebsd.go | 4 +- .../shirou/gopsutil/v4/mem/mem_windows.go | 34 +- .../shirou/gopsutil/v4/net/net_aix.go | 22 +- .../shirou/gopsutil/v4/net/net_darwin.go | 10 +- .../shirou/gopsutil/v4/net/net_fallback.go | 20 +- .../shirou/gopsutil/v4/net/net_freebsd.go | 4 +- .../shirou/gopsutil/v4/net/net_linux.go | 56 +- .../shirou/gopsutil/v4/net/net_openbsd.go | 44 +- .../shirou/gopsutil/v4/net/net_unix.go | 32 +- .../shirou/gopsutil/v4/net/net_windows.go | 20 +- .../shirou/gopsutil/v4/process/process.go | 24 +- .../gopsutil/v4/process/process_darwin.go | 287 +- .../v4/process/process_darwin_amd64.go | 21 + .../v4/process/process_darwin_arm64.go | 21 + .../gopsutil/v4/process/process_darwin_cgo.go | 222 - .../v4/process/process_darwin_nocgo.go | 127 - .../gopsutil/v4/process/process_fallback.go | 2 +- .../gopsutil/v4/process/process_freebsd.go | 33 +- .../v4/process/process_freebsd_arm64.go | 33 +- .../gopsutil/v4/process/process_linux.go | 49 +- .../gopsutil/v4/process/process_openbsd.go | 30 +- .../v4/process/process_openbsd_386.go | 1 + .../v4/process/process_openbsd_amd64.go | 1 + .../v4/process/process_openbsd_arm.go | 1 + .../v4/process/process_openbsd_arm64.go | 1 + .../v4/process/process_openbsd_riscv64.go | 1 + .../gopsutil/v4/process/process_plan9.go | 2 +- .../gopsutil/v4/process/process_solaris.go | 2 +- .../gopsutil/v4/process/process_windows.go | 18 +- .../shoenig/go-m1cpu/.golangci.yaml | 12 - vendor/github.com/shoenig/go-m1cpu/LICENSE | 363 -- vendor/github.com/shoenig/go-m1cpu/Makefile | 12 - vendor/github.com/shoenig/go-m1cpu/README.md | 66 - vendor/github.com/shoenig/go-m1cpu/cpu.go | 213 - .../shoenig/go-m1cpu/incompatible.go | 53 - vendor/modules.txt | 13 +- 123 files changed, 11541 insertions(+), 1656 deletions(-) create mode 100644 vendor/github.com/ebitengine/purego/.gitignore create mode 100644 vendor/github.com/ebitengine/purego/LICENSE create mode 100644 vendor/github.com/ebitengine/purego/README.md create mode 100644 vendor/github.com/ebitengine/purego/abi_amd64.h create mode 100644 vendor/github.com/ebitengine/purego/abi_arm64.h create mode 100644 vendor/github.com/ebitengine/purego/cgo.go create mode 100644 vendor/github.com/ebitengine/purego/dlerror.go create mode 100644 vendor/github.com/ebitengine/purego/dlfcn.go create mode 100644 vendor/github.com/ebitengine/purego/dlfcn_android.go create mode 100644 vendor/github.com/ebitengine/purego/dlfcn_darwin.go create mode 100644 vendor/github.com/ebitengine/purego/dlfcn_freebsd.go create mode 100644 vendor/github.com/ebitengine/purego/dlfcn_linux.go create mode 100644 vendor/github.com/ebitengine/purego/dlfcn_nocgo_freebsd.go create mode 100644 vendor/github.com/ebitengine/purego/dlfcn_nocgo_linux.go create mode 100644 vendor/github.com/ebitengine/purego/dlfcn_playground.go create mode 100644 vendor/github.com/ebitengine/purego/dlfcn_stubs.s create mode 100644 vendor/github.com/ebitengine/purego/func.go create mode 100644 vendor/github.com/ebitengine/purego/go_runtime.go create mode 100644 vendor/github.com/ebitengine/purego/internal/cgo/dlfcn_cgo_unix.go create mode 100644 vendor/github.com/ebitengine/purego/internal/cgo/empty.go create mode 100644 vendor/github.com/ebitengine/purego/internal/cgo/syscall_cgo_unix.go create mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/abi_amd64.h create mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/abi_arm64.h create mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/asm_amd64.s create mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/asm_arm64.s create mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/callbacks.go create mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/doc.go create mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/freebsd.go create mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/go_darwin_amd64.go create mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/go_darwin_arm64.go create mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/go_freebsd_amd64.go create mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/go_freebsd_arm64.go create mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/go_libinit.go create mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/go_linux_amd64.go create mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/go_linux_arm64.go create mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/go_setenv.go create mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/go_util.go create mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/iscgo.go create mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo.go create mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_darwin.go create mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_freebsd.go create mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_linux.go create mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/setenv.go create mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/symbols.go create mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/symbols_darwin.go create mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/symbols_freebsd.go create mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/symbols_linux.go create mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_amd64.s create mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_arm64.s create mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_stubs.s create mode 100644 vendor/github.com/ebitengine/purego/internal/strings/strings.go create mode 100644 vendor/github.com/ebitengine/purego/is_ios.go create mode 100644 vendor/github.com/ebitengine/purego/nocgo.go create mode 100644 vendor/github.com/ebitengine/purego/struct_amd64.go create mode 100644 vendor/github.com/ebitengine/purego/struct_arm64.go create mode 100644 vendor/github.com/ebitengine/purego/struct_other.go create mode 100644 vendor/github.com/ebitengine/purego/sys_amd64.s create mode 100644 vendor/github.com/ebitengine/purego/sys_arm64.s create mode 100644 vendor/github.com/ebitengine/purego/sys_unix_arm64.s create mode 100644 vendor/github.com/ebitengine/purego/syscall.go create mode 100644 vendor/github.com/ebitengine/purego/syscall_cgo_linux.go create mode 100644 vendor/github.com/ebitengine/purego/syscall_sysv.go create mode 100644 vendor/github.com/ebitengine/purego/syscall_windows.go create mode 100644 vendor/github.com/ebitengine/purego/zcallback_amd64.s create mode 100644 vendor/github.com/ebitengine/purego/zcallback_arm64.s create mode 100644 vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin_arm64.go delete mode 100644 vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin_cgo.go create mode 100644 vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin_fallback.go delete mode 100644 vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin_nocgo.go delete mode 100644 vendor/github.com/shirou/gopsutil/v4/mem/mem_darwin_cgo.go delete mode 100644 vendor/github.com/shirou/gopsutil/v4/mem/mem_darwin_nocgo.go delete mode 100644 vendor/github.com/shirou/gopsutil/v4/process/process_darwin_cgo.go delete mode 100644 vendor/github.com/shirou/gopsutil/v4/process/process_darwin_nocgo.go delete mode 100644 vendor/github.com/shoenig/go-m1cpu/.golangci.yaml delete mode 100644 vendor/github.com/shoenig/go-m1cpu/LICENSE delete mode 100644 vendor/github.com/shoenig/go-m1cpu/Makefile delete mode 100644 vendor/github.com/shoenig/go-m1cpu/README.md delete mode 100644 vendor/github.com/shoenig/go-m1cpu/cpu.go delete mode 100644 vendor/github.com/shoenig/go-m1cpu/incompatible.go diff --git a/go.mod b/go.mod index 0c57aaded1b51..e63fbf945081b 100644 --- a/go.mod +++ b/go.mod @@ -136,7 +136,7 @@ require ( github.com/prometheus/common/sigv4 v0.1.0 github.com/richardartoul/molecule v1.0.0 github.com/schollz/progressbar/v3 v3.14.6 - github.com/shirou/gopsutil/v4 v4.24.0-alpha.1 + github.com/shirou/gopsutil/v4 v4.24.9 github.com/thanos-io/objstore v0.0.0-20240818203309-0363dadfdfb1 github.com/twmb/franz-go v1.17.1 github.com/twmb/franz-go/pkg/kadm v1.13.0 @@ -166,6 +166,7 @@ require ( github.com/coreos/etcd v3.3.27+incompatible // indirect github.com/coreos/pkg v0.0.0-20220810130054-c7d1c02cb6cf // indirect github.com/dlclark/regexp2 v1.4.0 // indirect + github.com/ebitengine/purego v0.8.0 // indirect github.com/gabriel-vasile/mimetype v1.4.3 // indirect github.com/go-ini/ini v1.67.0 // indirect github.com/go-ole/go-ole v1.2.6 // indirect @@ -179,7 +180,6 @@ require ( github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect github.com/rivo/uniseg v0.4.7 // indirect - github.com/shoenig/go-m1cpu v0.1.6 // indirect github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/numcpus v0.6.1 // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect diff --git a/go.sum b/go.sum index eae4cb57fffb1..84a9caeb8034d 100644 --- a/go.sum +++ b/go.sum @@ -578,6 +578,8 @@ github.com/eapache/go-xerial-snappy v0.0.0-20230111030713-bf00bc1b83b6 h1:8yY/I9 github.com/eapache/go-xerial-snappy v0.0.0-20230111030713-bf00bc1b83b6/go.mod h1:YvSRo5mw33fLEx1+DlK6L2VV43tJt5Eyel9n9XBcR+0= github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= +github.com/ebitengine/purego v0.8.0 h1:JbqvnEzRvPpxhCJzJJ2y0RbiZ8nyjccVUrSM3q+GvvE= +github.com/ebitengine/purego v0.8.0/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ= github.com/eclipse/paho.mqtt.golang v1.2.0/go.mod h1:H9keYFcgq3Qr5OUJm/JZI/i6U7joQ8SYLhZwfeOo6Ts= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/edsrzf/mmap-go v1.1.0 h1:6EUwBLQ/Mcr1EYLE4Tn1VdW1A4ckqCQWZBw8Hr0kjpQ= @@ -1709,12 +1711,8 @@ github.com/sercand/kuberesolver/v5 v5.1.1/go.mod h1:Fs1KbKhVRnB2aDWN12NjKCB+RgYM github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/shirou/gopsutil v2.20.9+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil/v3 v3.22.8/go.mod h1:s648gW4IywYzUfE/KjXxUsqrqx/T2xO5VqOXxONeRfI= -github.com/shirou/gopsutil/v4 v4.24.0-alpha.1 h1:lLPAdP4TpfgJ5byoc3EFwNSKZj8kCnDFHtuWTktWl0s= -github.com/shirou/gopsutil/v4 v4.24.0-alpha.1/go.mod h1:GVpYUxBee6CTWux2/JslZ7fYPwqkQ8YDJSXmGAryYy4= -github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= -github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= -github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= -github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k= +github.com/shirou/gopsutil/v4 v4.24.9 h1:KIV+/HaHD5ka5f570RZq+2SaeFsb/pq+fp2DGNWYoOI= +github.com/shirou/gopsutil/v4 v4.24.9/go.mod h1:3fkaHNeYsUFCGZ8+9vZVWtbyM1k2eRnlL+bWO8Bxa/Q= github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= github.com/shopspring/decimal v0.0.0-20200105231215-408a2507e114/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= diff --git a/vendor/github.com/ebitengine/purego/.gitignore b/vendor/github.com/ebitengine/purego/.gitignore new file mode 100644 index 0000000000000..b25c15b81fae0 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/.gitignore @@ -0,0 +1 @@ +*~ diff --git a/vendor/github.com/ebitengine/purego/LICENSE b/vendor/github.com/ebitengine/purego/LICENSE new file mode 100644 index 0000000000000..8dada3edaf50d --- /dev/null +++ b/vendor/github.com/ebitengine/purego/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/ebitengine/purego/README.md b/vendor/github.com/ebitengine/purego/README.md new file mode 100644 index 0000000000000..f1ff9053aceeb --- /dev/null +++ b/vendor/github.com/ebitengine/purego/README.md @@ -0,0 +1,97 @@ +# purego +[![Go Reference](https://pkg.go.dev/badge/github.com/ebitengine/purego?GOOS=darwin.svg)](https://pkg.go.dev/github.com/ebitengine/purego?GOOS=darwin) + +A library for calling C functions from Go without Cgo. + +> This is beta software so expect bugs and potentially API breaking changes +> but each release will be tagged to avoid breaking people's code. +> Bug reports are encouraged. + +## Motivation + +The [Ebitengine](https://github.com/hajimehoshi/ebiten) game engine was ported to use only Go on Windows. This enabled +cross-compiling to Windows from any other operating system simply by setting `GOOS=windows`. The purego project was +born to bring that same vision to the other platforms supported by Ebitengine. + +## Benefits + +- **Simple Cross-Compilation**: No C means you can build for other platforms easily without a C compiler. +- **Faster Compilation**: Efficiently cache your entirely Go builds. +- **Smaller Binaries**: Using Cgo generates a C wrapper function for each C function called. Purego doesn't! +- **Dynamic Linking**: Load symbols at runtime and use it as a plugin system. +- **Foreign Function Interface**: Call into other languages that are compiled into shared objects. +- **Cgo Fallback**: Works even with CGO_ENABLED=1 so incremental porting is possible. +This also means unsupported GOARCHs (freebsd/riscv64, linux/mips, etc.) will still work +except for float arguments and return values. + +## Supported Platforms + +- **FreeBSD**: amd64, arm64 +- **Linux**: amd64, arm64 +- **macOS / iOS**: amd64, arm64 +- **Windows**: 386*, amd64, arm*, arm64 + +`*` These architectures only support SyscallN and NewCallback + +## Example + +The example below only showcases purego use for macOS and Linux. The other platforms require special handling which can +be seen in the complete example at [examples/libc](https://github.com/ebitengine/purego/tree/main/examples/libc) which supports Windows and FreeBSD. + +```go +package main + +import ( + "fmt" + "runtime" + + "github.com/ebitengine/purego" +) + +func getSystemLibrary() string { + switch runtime.GOOS { + case "darwin": + return "/usr/lib/libSystem.B.dylib" + case "linux": + return "libc.so.6" + default: + panic(fmt.Errorf("GOOS=%s is not supported", runtime.GOOS)) + } +} + +func main() { + libc, err := purego.Dlopen(getSystemLibrary(), purego.RTLD_NOW|purego.RTLD_GLOBAL) + if err != nil { + panic(err) + } + var puts func(string) + purego.RegisterLibFunc(&puts, libc, "puts") + puts("Calling C from Go without Cgo!") +} +``` + +Then to run: `CGO_ENABLED=0 go run main.go` + +## Questions + +If you have questions about how to incorporate purego in your project or want to discuss +how it works join the [Discord](https://discord.gg/HzGZVD6BkY)! + +### External Code + +Purego uses code that originates from the Go runtime. These files are under the BSD-3 +License that can be found [in the Go Source](https://github.com/golang/go/blob/master/LICENSE). +This is a list of the copied files: + +* `abi_*.h` from package `runtime/cgo` +* `zcallback_darwin_*.s` from package `runtime` +* `internal/fakecgo/abi_*.h` from package `runtime/cgo` +* `internal/fakecgo/asm_GOARCH.s` from package `runtime/cgo` +* `internal/fakecgo/callbacks.go` from package `runtime/cgo` +* `internal/fakecgo/go_GOOS_GOARCH.go` from package `runtime/cgo` +* `internal/fakecgo/iscgo.go` from package `runtime/cgo` +* `internal/fakecgo/setenv.go` from package `runtime/cgo` +* `internal/fakecgo/freebsd.go` from package `runtime/cgo` + +The files `abi_*.h` and `internal/fakecgo/abi_*.h` are the same because Bazel does not support cross-package use of +`#include` so we need each one once per package. (cf. [issue](https://github.com/bazelbuild/rules_go/issues/3636)) diff --git a/vendor/github.com/ebitengine/purego/abi_amd64.h b/vendor/github.com/ebitengine/purego/abi_amd64.h new file mode 100644 index 0000000000000..9949435fe9e0a --- /dev/null +++ b/vendor/github.com/ebitengine/purego/abi_amd64.h @@ -0,0 +1,99 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Macros for transitioning from the host ABI to Go ABI0. +// +// These save the frame pointer, so in general, functions that use +// these should have zero frame size to suppress the automatic frame +// pointer, though it's harmless to not do this. + +#ifdef GOOS_windows + +// REGS_HOST_TO_ABI0_STACK is the stack bytes used by +// PUSH_REGS_HOST_TO_ABI0. +#define REGS_HOST_TO_ABI0_STACK (28*8 + 8) + +// PUSH_REGS_HOST_TO_ABI0 prepares for transitioning from +// the host ABI to Go ABI0 code. It saves all registers that are +// callee-save in the host ABI and caller-save in Go ABI0 and prepares +// for entry to Go. +// +// Save DI SI BP BX R12 R13 R14 R15 X6-X15 registers and the DF flag. +// Clear the DF flag for the Go ABI. +// MXCSR matches the Go ABI, so we don't have to set that, +// and Go doesn't modify it, so we don't have to save it. +#define PUSH_REGS_HOST_TO_ABI0() \ + PUSHFQ \ + CLD \ + ADJSP $(REGS_HOST_TO_ABI0_STACK - 8) \ + MOVQ DI, (0*0)(SP) \ + MOVQ SI, (1*8)(SP) \ + MOVQ BP, (2*8)(SP) \ + MOVQ BX, (3*8)(SP) \ + MOVQ R12, (4*8)(SP) \ + MOVQ R13, (5*8)(SP) \ + MOVQ R14, (6*8)(SP) \ + MOVQ R15, (7*8)(SP) \ + MOVUPS X6, (8*8)(SP) \ + MOVUPS X7, (10*8)(SP) \ + MOVUPS X8, (12*8)(SP) \ + MOVUPS X9, (14*8)(SP) \ + MOVUPS X10, (16*8)(SP) \ + MOVUPS X11, (18*8)(SP) \ + MOVUPS X12, (20*8)(SP) \ + MOVUPS X13, (22*8)(SP) \ + MOVUPS X14, (24*8)(SP) \ + MOVUPS X15, (26*8)(SP) + +#define POP_REGS_HOST_TO_ABI0() \ + MOVQ (0*0)(SP), DI \ + MOVQ (1*8)(SP), SI \ + MOVQ (2*8)(SP), BP \ + MOVQ (3*8)(SP), BX \ + MOVQ (4*8)(SP), R12 \ + MOVQ (5*8)(SP), R13 \ + MOVQ (6*8)(SP), R14 \ + MOVQ (7*8)(SP), R15 \ + MOVUPS (8*8)(SP), X6 \ + MOVUPS (10*8)(SP), X7 \ + MOVUPS (12*8)(SP), X8 \ + MOVUPS (14*8)(SP), X9 \ + MOVUPS (16*8)(SP), X10 \ + MOVUPS (18*8)(SP), X11 \ + MOVUPS (20*8)(SP), X12 \ + MOVUPS (22*8)(SP), X13 \ + MOVUPS (24*8)(SP), X14 \ + MOVUPS (26*8)(SP), X15 \ + ADJSP $-(REGS_HOST_TO_ABI0_STACK - 8) \ + POPFQ + +#else +// SysV ABI + +#define REGS_HOST_TO_ABI0_STACK (6*8) + +// SysV MXCSR matches the Go ABI, so we don't have to set that, +// and Go doesn't modify it, so we don't have to save it. +// Both SysV and Go require DF to be cleared, so that's already clear. +// The SysV and Go frame pointer conventions are compatible. +#define PUSH_REGS_HOST_TO_ABI0() \ + ADJSP $(REGS_HOST_TO_ABI0_STACK) \ + MOVQ BP, (5*8)(SP) \ + LEAQ (5*8)(SP), BP \ + MOVQ BX, (0*8)(SP) \ + MOVQ R12, (1*8)(SP) \ + MOVQ R13, (2*8)(SP) \ + MOVQ R14, (3*8)(SP) \ + MOVQ R15, (4*8)(SP) + +#define POP_REGS_HOST_TO_ABI0() \ + MOVQ (0*8)(SP), BX \ + MOVQ (1*8)(SP), R12 \ + MOVQ (2*8)(SP), R13 \ + MOVQ (3*8)(SP), R14 \ + MOVQ (4*8)(SP), R15 \ + MOVQ (5*8)(SP), BP \ + ADJSP $-(REGS_HOST_TO_ABI0_STACK) + +#endif diff --git a/vendor/github.com/ebitengine/purego/abi_arm64.h b/vendor/github.com/ebitengine/purego/abi_arm64.h new file mode 100644 index 0000000000000..5d5061ec1dbf8 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/abi_arm64.h @@ -0,0 +1,39 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Macros for transitioning from the host ABI to Go ABI0. +// +// These macros save and restore the callee-saved registers +// from the stack, but they don't adjust stack pointer, so +// the user should prepare stack space in advance. +// SAVE_R19_TO_R28(offset) saves R19 ~ R28 to the stack space +// of ((offset)+0*8)(RSP) ~ ((offset)+9*8)(RSP). +// +// SAVE_F8_TO_F15(offset) saves F8 ~ F15 to the stack space +// of ((offset)+0*8)(RSP) ~ ((offset)+7*8)(RSP). +// +// R29 is not saved because Go will save and restore it. + +#define SAVE_R19_TO_R28(offset) \ + STP (R19, R20), ((offset)+0*8)(RSP) \ + STP (R21, R22), ((offset)+2*8)(RSP) \ + STP (R23, R24), ((offset)+4*8)(RSP) \ + STP (R25, R26), ((offset)+6*8)(RSP) \ + STP (R27, g), ((offset)+8*8)(RSP) +#define RESTORE_R19_TO_R28(offset) \ + LDP ((offset)+0*8)(RSP), (R19, R20) \ + LDP ((offset)+2*8)(RSP), (R21, R22) \ + LDP ((offset)+4*8)(RSP), (R23, R24) \ + LDP ((offset)+6*8)(RSP), (R25, R26) \ + LDP ((offset)+8*8)(RSP), (R27, g) /* R28 */ +#define SAVE_F8_TO_F15(offset) \ + FSTPD (F8, F9), ((offset)+0*8)(RSP) \ + FSTPD (F10, F11), ((offset)+2*8)(RSP) \ + FSTPD (F12, F13), ((offset)+4*8)(RSP) \ + FSTPD (F14, F15), ((offset)+6*8)(RSP) +#define RESTORE_F8_TO_F15(offset) \ + FLDPD ((offset)+0*8)(RSP), (F8, F9) \ + FLDPD ((offset)+2*8)(RSP), (F10, F11) \ + FLDPD ((offset)+4*8)(RSP), (F12, F13) \ + FLDPD ((offset)+6*8)(RSP), (F14, F15) diff --git a/vendor/github.com/ebitengine/purego/cgo.go b/vendor/github.com/ebitengine/purego/cgo.go new file mode 100644 index 0000000000000..7d5abef349983 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/cgo.go @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2022 The Ebitengine Authors + +//go:build cgo && (darwin || freebsd || linux) + +package purego + +// if CGO_ENABLED=1 import the Cgo runtime to ensure that it is set up properly. +// This is required since some frameworks need TLS setup the C way which Go doesn't do. +// We currently don't support ios in fakecgo mode so force Cgo or fail +// Even if CGO_ENABLED=1 the Cgo runtime is not imported unless `import "C"` is used. +// which will import this package automatically. Normally this isn't an issue since it +// usually isn't possible to call into C without using that import. However, with purego +// it is since we don't use `import "C"`! +import ( + _ "runtime/cgo" + + _ "github.com/ebitengine/purego/internal/cgo" +) diff --git a/vendor/github.com/ebitengine/purego/dlerror.go b/vendor/github.com/ebitengine/purego/dlerror.go new file mode 100644 index 0000000000000..95cdfe16f2488 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/dlerror.go @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2023 The Ebitengine Authors + +//go:build darwin || freebsd || linux + +package purego + +// Dlerror represents an error value returned from Dlopen, Dlsym, or Dlclose. +// +// This type is not available on Windows as there is no counterpart to it on Windows. +type Dlerror struct { + s string +} + +func (e Dlerror) Error() string { + return e.s +} diff --git a/vendor/github.com/ebitengine/purego/dlfcn.go b/vendor/github.com/ebitengine/purego/dlfcn.go new file mode 100644 index 0000000000000..f70a24584d659 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/dlfcn.go @@ -0,0 +1,99 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2022 The Ebitengine Authors + +//go:build (darwin || freebsd || linux) && !android && !faketime + +package purego + +import ( + "unsafe" +) + +// Unix Specification for dlfcn.h: https://pubs.opengroup.org/onlinepubs/7908799/xsh/dlfcn.h.html + +var ( + fnDlopen func(path string, mode int) uintptr + fnDlsym func(handle uintptr, name string) uintptr + fnDlerror func() string + fnDlclose func(handle uintptr) bool +) + +func init() { + RegisterFunc(&fnDlopen, dlopenABI0) + RegisterFunc(&fnDlsym, dlsymABI0) + RegisterFunc(&fnDlerror, dlerrorABI0) + RegisterFunc(&fnDlclose, dlcloseABI0) +} + +// Dlopen examines the dynamic library or bundle file specified by path. If the file is compatible +// with the current process and has not already been loaded into the +// current process, it is loaded and linked. After being linked, if it contains +// any initializer functions, they are called, before Dlopen +// returns. It returns a handle that can be used with Dlsym and Dlclose. +// A second call to Dlopen with the same path will return the same handle, but the internal +// reference count for the handle will be incremented. Therefore, all +// Dlopen calls should be balanced with a Dlclose call. +// +// This function is not available on Windows. +// Use [golang.org/x/sys/windows.LoadLibrary], [golang.org/x/sys/windows.LoadLibraryEx], +// [golang.org/x/sys/windows.NewLazyDLL], or [golang.org/x/sys/windows.NewLazySystemDLL] for Windows instead. +func Dlopen(path string, mode int) (uintptr, error) { + u := fnDlopen(path, mode) + if u == 0 { + return 0, Dlerror{fnDlerror()} + } + return u, nil +} + +// Dlsym takes a "handle" of a dynamic library returned by Dlopen and the symbol name. +// It returns the address where that symbol is loaded into memory. If the symbol is not found, +// in the specified library or any of the libraries that were automatically loaded by Dlopen +// when that library was loaded, Dlsym returns zero. +// +// This function is not available on Windows. +// Use [golang.org/x/sys/windows.GetProcAddress] for Windows instead. +func Dlsym(handle uintptr, name string) (uintptr, error) { + u := fnDlsym(handle, name) + if u == 0 { + return 0, Dlerror{fnDlerror()} + } + return u, nil +} + +// Dlclose decrements the reference count on the dynamic library handle. +// If the reference count drops to zero and no other loaded libraries +// use symbols in it, then the dynamic library is unloaded. +// +// This function is not available on Windows. +// Use [golang.org/x/sys/windows.FreeLibrary] for Windows instead. +func Dlclose(handle uintptr) error { + if fnDlclose(handle) { + return Dlerror{fnDlerror()} + } + return nil +} + +func loadSymbol(handle uintptr, name string) (uintptr, error) { + return Dlsym(handle, name) +} + +// these functions exist in dlfcn_stubs.s and are calling C functions linked to in dlfcn_GOOS.go +// the indirection is necessary because a function is actually a pointer to the pointer to the code. +// sadly, I do not know of anyway to remove the assembly stubs entirely because //go:linkname doesn't +// appear to work if you link directly to the C function on darwin arm64. + +//go:linkname dlopen dlopen +var dlopen uintptr +var dlopenABI0 = uintptr(unsafe.Pointer(&dlopen)) + +//go:linkname dlsym dlsym +var dlsym uintptr +var dlsymABI0 = uintptr(unsafe.Pointer(&dlsym)) + +//go:linkname dlclose dlclose +var dlclose uintptr +var dlcloseABI0 = uintptr(unsafe.Pointer(&dlclose)) + +//go:linkname dlerror dlerror +var dlerror uintptr +var dlerrorABI0 = uintptr(unsafe.Pointer(&dlerror)) diff --git a/vendor/github.com/ebitengine/purego/dlfcn_android.go b/vendor/github.com/ebitengine/purego/dlfcn_android.go new file mode 100644 index 0000000000000..0d5341764edef --- /dev/null +++ b/vendor/github.com/ebitengine/purego/dlfcn_android.go @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2024 The Ebitengine Authors + +package purego + +import "github.com/ebitengine/purego/internal/cgo" + +// Source for constants: https://android.googlesource.com/platform/bionic/+/refs/heads/main/libc/include/dlfcn.h + +const ( + is64bit = 1 << (^uintptr(0) >> 63) / 2 + is32bit = 1 - is64bit + RTLD_DEFAULT = is32bit * 0xffffffff + RTLD_LAZY = 0x00000001 + RTLD_NOW = is64bit * 0x00000002 + RTLD_LOCAL = 0x00000000 + RTLD_GLOBAL = is64bit*0x00100 | is32bit*0x00000002 +) + +func Dlopen(path string, mode int) (uintptr, error) { + return cgo.Dlopen(path, mode) +} + +func Dlsym(handle uintptr, name string) (uintptr, error) { + return cgo.Dlsym(handle, name) +} + +func Dlclose(handle uintptr) error { + return cgo.Dlclose(handle) +} + +func loadSymbol(handle uintptr, name string) (uintptr, error) { + return Dlsym(handle, name) +} diff --git a/vendor/github.com/ebitengine/purego/dlfcn_darwin.go b/vendor/github.com/ebitengine/purego/dlfcn_darwin.go new file mode 100644 index 0000000000000..5f876278a3e66 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/dlfcn_darwin.go @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2022 The Ebitengine Authors + +package purego + +// Source for constants: https://opensource.apple.com/source/dyld/dyld-360.14/include/dlfcn.h.auto.html + +const ( + RTLD_DEFAULT = 1<<64 - 2 // Pseudo-handle for dlsym so search for any loaded symbol + RTLD_LAZY = 0x1 // Relocations are performed at an implementation-dependent time. + RTLD_NOW = 0x2 // Relocations are performed when the object is loaded. + RTLD_LOCAL = 0x4 // All symbols are not made available for relocation processing by other modules. + RTLD_GLOBAL = 0x8 // All symbols are available for relocation processing of other modules. +) + +//go:cgo_import_dynamic purego_dlopen dlopen "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic purego_dlsym dlsym "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic purego_dlerror dlerror "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic purego_dlclose dlclose "/usr/lib/libSystem.B.dylib" + +//go:cgo_import_dynamic purego_dlopen dlopen "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic purego_dlsym dlsym "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic purego_dlerror dlerror "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic purego_dlclose dlclose "/usr/lib/libSystem.B.dylib" diff --git a/vendor/github.com/ebitengine/purego/dlfcn_freebsd.go b/vendor/github.com/ebitengine/purego/dlfcn_freebsd.go new file mode 100644 index 0000000000000..6b371620d969d --- /dev/null +++ b/vendor/github.com/ebitengine/purego/dlfcn_freebsd.go @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2022 The Ebitengine Authors + +package purego + +// Constants as defined in https://github.com/freebsd/freebsd-src/blob/main/include/dlfcn.h +const ( + intSize = 32 << (^uint(0) >> 63) // 32 or 64 + RTLD_DEFAULT = 1< C) +// +// string <=> char* +// bool <=> _Bool +// uintptr <=> uintptr_t +// uint <=> uint32_t or uint64_t +// uint8 <=> uint8_t +// uint16 <=> uint16_t +// uint32 <=> uint32_t +// uint64 <=> uint64_t +// int <=> int32_t or int64_t +// int8 <=> int8_t +// int16 <=> int16_t +// int32 <=> int32_t +// int64 <=> int64_t +// float32 <=> float +// float64 <=> double +// struct <=> struct (WIP - darwin only) +// func <=> C function +// unsafe.Pointer, *T <=> void* +// []T => void* +// +// There is a special case when the last argument of fptr is a variadic interface (or []interface} +// it will be expanded into a call to the C function as if it had the arguments in that slice. +// This means that using arg ...interface{} is like a cast to the function with the arguments inside arg. +// This is not the same as C variadic. +// +// # Memory +// +// In general it is not possible for purego to guarantee the lifetimes of objects returned or received from +// calling functions using RegisterFunc. For arguments to a C function it is important that the C function doesn't +// hold onto a reference to Go memory. This is the same as the [Cgo rules]. +// +// However, there are some special cases. When passing a string as an argument if the string does not end in a null +// terminated byte (\x00) then the string will be copied into memory maintained by purego. The memory is only valid for +// that specific call. Therefore, if the C code keeps a reference to that string it may become invalid at some +// undefined time. However, if the string does already contain a null-terminated byte then no copy is done. +// It is then the responsibility of the caller to ensure the string stays alive as long as it's needed in C memory. +// This can be done using runtime.KeepAlive or allocating the string in C memory using malloc. When a C function +// returns a null-terminated pointer to char a Go string can be used. Purego will allocate a new string in Go memory +// and copy the data over. This string will be garbage collected whenever Go decides it's no longer referenced. +// This C created string will not be freed by purego. If the pointer to char is not null-terminated or must continue +// to point to C memory (because it's a buffer for example) then use a pointer to byte and then convert that to a slice +// using unsafe.Slice. Doing this means that it becomes the responsibility of the caller to care about the lifetime +// of the pointer +// +// # Structs +// +// Purego can handle the most common structs that have fields of builtin types like int8, uint16, float32, etc. However, +// it does not support aligning fields properly. It is therefore the responsibility of the caller to ensure +// that all padding is added to the Go struct to match the C one. See `BoolStructFn` in struct_test.go for an example. +// +// # Example +// +// All functions below call this C function: +// +// char *foo(char *str); +// +// // Let purego convert types +// var foo func(s string) string +// goString := foo("copied") +// // Go will garbage collect this string +// +// // Manually, handle allocations +// var foo2 func(b string) *byte +// mustFree := foo2("not copied\x00") +// defer free(mustFree) +// +// [Cgo rules]: https://pkg.go.dev/cmd/cgo#hdr-Go_references_to_C +func RegisterFunc(fptr interface{}, cfn uintptr) { + fn := reflect.ValueOf(fptr).Elem() + ty := fn.Type() + if ty.Kind() != reflect.Func { + panic("purego: fptr must be a function pointer") + } + if ty.NumOut() > 1 { + panic("purego: function can only return zero or one values") + } + if cfn == 0 { + panic("purego: cfn is nil") + } + if ty.NumOut() == 1 && (ty.Out(0).Kind() == reflect.Float32 || ty.Out(0).Kind() == reflect.Float64) && + runtime.GOARCH != "arm64" && runtime.GOARCH != "amd64" { + panic("purego: float returns are not supported") + } + { + // this code checks how many registers and stack this function will use + // to avoid crashing with too many arguments + var ints int + var floats int + var stack int + for i := 0; i < ty.NumIn(); i++ { + arg := ty.In(i) + switch arg.Kind() { + case reflect.Func: + // This only does preliminary testing to ensure the CDecl argument + // is the first argument. Full testing is done when the callback is actually + // created in NewCallback. + for j := 0; j < arg.NumIn(); j++ { + in := arg.In(j) + if !in.AssignableTo(reflect.TypeOf(CDecl{})) { + continue + } + if j != 0 { + panic("purego: CDecl must be the first argument") + } + } + case reflect.String, reflect.Uintptr, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, + reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Ptr, reflect.UnsafePointer, + reflect.Slice, reflect.Bool: + if ints < numOfIntegerRegisters() { + ints++ + } else { + stack++ + } + case reflect.Float32, reflect.Float64: + const is32bit = unsafe.Sizeof(uintptr(0)) == 4 + if is32bit { + panic("purego: floats only supported on 64bit platforms") + } + if floats < numOfFloats { + floats++ + } else { + stack++ + } + case reflect.Struct: + if runtime.GOOS != "darwin" || (runtime.GOARCH != "amd64" && runtime.GOARCH != "arm64") { + panic("purego: struct arguments are only supported on darwin amd64 & arm64") + } + if arg.Size() == 0 { + continue + } + addInt := func(u uintptr) { + ints++ + } + addFloat := func(u uintptr) { + floats++ + } + addStack := func(u uintptr) { + stack++ + } + _ = addStruct(reflect.New(arg).Elem(), &ints, &floats, &stack, addInt, addFloat, addStack, nil) + default: + panic("purego: unsupported kind " + arg.Kind().String()) + } + } + if ty.NumOut() == 1 && ty.Out(0).Kind() == reflect.Struct { + if runtime.GOOS != "darwin" { + panic("purego: struct return values only supported on darwin arm64 & amd64") + } + outType := ty.Out(0) + checkStructFieldsSupported(outType) + if runtime.GOARCH == "amd64" && outType.Size() > maxRegAllocStructSize { + // on amd64 if struct is bigger than 16 bytes allocate the return struct + // and pass it in as a hidden first argument. + ints++ + } + } + sizeOfStack := maxArgs - numOfIntegerRegisters() + if stack > sizeOfStack { + panic("purego: too many arguments") + } + } + v := reflect.MakeFunc(ty, func(args []reflect.Value) (results []reflect.Value) { + if len(args) > 0 { + if variadic, ok := args[len(args)-1].Interface().([]interface{}); ok { + // subtract one from args bc the last argument in args is []interface{} + // which we are currently expanding + tmp := make([]reflect.Value, len(args)-1+len(variadic)) + n := copy(tmp, args[:len(args)-1]) + for i, v := range variadic { + tmp[n+i] = reflect.ValueOf(v) + } + args = tmp + } + } + var sysargs [maxArgs]uintptr + stack := sysargs[numOfIntegerRegisters():] + var floats [numOfFloats]uintptr + var numInts int + var numFloats int + var numStack int + var addStack, addInt, addFloat func(x uintptr) + if runtime.GOARCH == "arm64" || runtime.GOOS != "windows" { + // Windows arm64 uses the same calling convention as macOS and Linux + addStack = func(x uintptr) { + stack[numStack] = x + numStack++ + } + addInt = func(x uintptr) { + if numInts >= numOfIntegerRegisters() { + addStack(x) + } else { + sysargs[numInts] = x + numInts++ + } + } + addFloat = func(x uintptr) { + if numFloats < len(floats) { + floats[numFloats] = x + numFloats++ + } else { + addStack(x) + } + } + } else { + // On Windows amd64 the arguments are passed in the numbered registered. + // So the first int is in the first integer register and the first float + // is in the second floating register if there is already a first int. + // This is in contrast to how macOS and Linux pass arguments which + // tries to use as many registers as possible in the calling convention. + addStack = func(x uintptr) { + sysargs[numStack] = x + numStack++ + } + addInt = addStack + addFloat = addStack + } + + var keepAlive []interface{} + defer func() { + runtime.KeepAlive(keepAlive) + runtime.KeepAlive(args) + }() + var syscall syscall15Args + if ty.NumOut() == 1 && ty.Out(0).Kind() == reflect.Struct { + outType := ty.Out(0) + if runtime.GOARCH == "amd64" && outType.Size() > maxRegAllocStructSize { + val := reflect.New(outType) + keepAlive = append(keepAlive, val) + addInt(val.Pointer()) + } else if runtime.GOARCH == "arm64" && outType.Size() > maxRegAllocStructSize { + isAllFloats, numFields := isAllSameFloat(outType) + if !isAllFloats || numFields > 4 { + val := reflect.New(outType) + keepAlive = append(keepAlive, val) + syscall.arm64_r8 = val.Pointer() + } + } + } + for _, v := range args { + switch v.Kind() { + case reflect.String: + ptr := strings.CString(v.String()) + keepAlive = append(keepAlive, ptr) + addInt(uintptr(unsafe.Pointer(ptr))) + case reflect.Uintptr, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + addInt(uintptr(v.Uint())) + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + addInt(uintptr(v.Int())) + case reflect.Ptr, reflect.UnsafePointer, reflect.Slice: + // There is no need to keepAlive this pointer separately because it is kept alive in the args variable + addInt(v.Pointer()) + case reflect.Func: + addInt(NewCallback(v.Interface())) + case reflect.Bool: + if v.Bool() { + addInt(1) + } else { + addInt(0) + } + case reflect.Float32: + addFloat(uintptr(math.Float32bits(float32(v.Float())))) + case reflect.Float64: + addFloat(uintptr(math.Float64bits(v.Float()))) + case reflect.Struct: + keepAlive = addStruct(v, &numInts, &numFloats, &numStack, addInt, addFloat, addStack, keepAlive) + default: + panic("purego: unsupported kind: " + v.Kind().String()) + } + } + if runtime.GOARCH == "arm64" || runtime.GOOS != "windows" { + // Use the normal arm64 calling convention even on Windows + syscall = syscall15Args{ + cfn, + sysargs[0], sysargs[1], sysargs[2], sysargs[3], sysargs[4], sysargs[5], + sysargs[6], sysargs[7], sysargs[8], sysargs[9], sysargs[10], sysargs[11], + sysargs[12], sysargs[13], sysargs[14], + floats[0], floats[1], floats[2], floats[3], floats[4], floats[5], floats[6], floats[7], + syscall.arm64_r8, + } + runtime_cgocall(syscall15XABI0, unsafe.Pointer(&syscall)) + } else { + // This is a fallback for Windows amd64, 386, and arm. Note this may not support floats + syscall.a1, syscall.a2, _ = syscall_syscall15X(cfn, sysargs[0], sysargs[1], sysargs[2], sysargs[3], sysargs[4], + sysargs[5], sysargs[6], sysargs[7], sysargs[8], sysargs[9], sysargs[10], sysargs[11], + sysargs[12], sysargs[13], sysargs[14]) + syscall.f1 = syscall.a2 // on amd64 a2 stores the float return. On 32bit platforms floats aren't support + } + if ty.NumOut() == 0 { + return nil + } + outType := ty.Out(0) + v := reflect.New(outType).Elem() + switch outType.Kind() { + case reflect.Uintptr, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + v.SetUint(uint64(syscall.a1)) + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + v.SetInt(int64(syscall.a1)) + case reflect.Bool: + v.SetBool(byte(syscall.a1) != 0) + case reflect.UnsafePointer: + // We take the address and then dereference it to trick go vet from creating a possible miss-use of unsafe.Pointer + v.SetPointer(*(*unsafe.Pointer)(unsafe.Pointer(&syscall.a1))) + case reflect.Ptr: + v = reflect.NewAt(outType, unsafe.Pointer(&syscall.a1)).Elem() + case reflect.Func: + // wrap this C function in a nicely typed Go function + v = reflect.New(outType) + RegisterFunc(v.Interface(), syscall.a1) + case reflect.String: + v.SetString(strings.GoString(syscall.a1)) + case reflect.Float32: + // NOTE: syscall.r2 is only the floating return value on 64bit platforms. + // On 32bit platforms syscall.r2 is the upper part of a 64bit return. + v.SetFloat(float64(math.Float32frombits(uint32(syscall.f1)))) + case reflect.Float64: + // NOTE: syscall.r2 is only the floating return value on 64bit platforms. + // On 32bit platforms syscall.r2 is the upper part of a 64bit return. + v.SetFloat(math.Float64frombits(uint64(syscall.f1))) + case reflect.Struct: + v = getStruct(outType, syscall) + default: + panic("purego: unsupported return kind: " + outType.Kind().String()) + } + return []reflect.Value{v} + }) + fn.Set(v) +} + +// maxRegAllocStructSize is the biggest a struct can be while still fitting in registers. +// if it is bigger than this than enough space must be allocated on the heap and then passed into +// the function as the first parameter on amd64 or in R8 on arm64. +// +// If you change this make sure to update it in objc_runtime_darwin.go +const maxRegAllocStructSize = 16 + +func isAllSameFloat(ty reflect.Type) (allFloats bool, numFields int) { + allFloats = true + root := ty.Field(0).Type + for root.Kind() == reflect.Struct { + root = root.Field(0).Type + } + first := root.Kind() + if first != reflect.Float32 && first != reflect.Float64 { + allFloats = false + } + for i := 0; i < ty.NumField(); i++ { + f := ty.Field(i).Type + if f.Kind() == reflect.Struct { + var structNumFields int + allFloats, structNumFields = isAllSameFloat(f) + numFields += structNumFields + continue + } + numFields++ + if f.Kind() != first { + allFloats = false + } + } + return allFloats, numFields +} + +func checkStructFieldsSupported(ty reflect.Type) { + for i := 0; i < ty.NumField(); i++ { + f := ty.Field(i).Type + if f.Kind() == reflect.Array { + f = f.Elem() + } else if f.Kind() == reflect.Struct { + checkStructFieldsSupported(f) + continue + } + switch f.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, + reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, + reflect.Uintptr, reflect.Ptr, reflect.UnsafePointer, reflect.Float64, reflect.Float32: + default: + panic(fmt.Sprintf("purego: struct field type %s is not supported", f)) + } + } +} + +func roundUpTo8(val uintptr) uintptr { + return (val + 7) &^ 7 +} + +func numOfIntegerRegisters() int { + switch runtime.GOARCH { + case "arm64": + return 8 + case "amd64": + return 6 + default: + // since this platform isn't supported and can therefore only access + // integer registers it is fine to return the maxArgs + return maxArgs + } +} diff --git a/vendor/github.com/ebitengine/purego/go_runtime.go b/vendor/github.com/ebitengine/purego/go_runtime.go new file mode 100644 index 0000000000000..13671ff23f270 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/go_runtime.go @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2022 The Ebitengine Authors + +//go:build darwin || freebsd || linux || windows + +package purego + +import ( + "unsafe" +) + +//go:linkname runtime_cgocall runtime.cgocall +func runtime_cgocall(fn uintptr, arg unsafe.Pointer) int32 // from runtime/sys_libc.go diff --git a/vendor/github.com/ebitengine/purego/internal/cgo/dlfcn_cgo_unix.go b/vendor/github.com/ebitengine/purego/internal/cgo/dlfcn_cgo_unix.go new file mode 100644 index 0000000000000..b09ecac1cfebb --- /dev/null +++ b/vendor/github.com/ebitengine/purego/internal/cgo/dlfcn_cgo_unix.go @@ -0,0 +1,56 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2024 The Ebitengine Authors + +//go:build freebsd || linux + +package cgo + +/* + #cgo LDFLAGS: -ldl + +#include +#include +*/ +import "C" + +import ( + "errors" + "unsafe" +) + +func Dlopen(filename string, flag int) (uintptr, error) { + cfilename := C.CString(filename) + defer C.free(unsafe.Pointer(cfilename)) + handle := C.dlopen(cfilename, C.int(flag)) + if handle == nil { + return 0, errors.New(C.GoString(C.dlerror())) + } + return uintptr(handle), nil +} + +func Dlsym(handle uintptr, symbol string) (uintptr, error) { + csymbol := C.CString(symbol) + defer C.free(unsafe.Pointer(csymbol)) + symbolAddr := C.dlsym(*(*unsafe.Pointer)(unsafe.Pointer(&handle)), csymbol) + if symbolAddr == nil { + return 0, errors.New(C.GoString(C.dlerror())) + } + return uintptr(symbolAddr), nil +} + +func Dlclose(handle uintptr) error { + result := C.dlclose(*(*unsafe.Pointer)(unsafe.Pointer(&handle))) + if result != 0 { + return errors.New(C.GoString(C.dlerror())) + } + return nil +} + +// all that is needed is to assign each dl function because then its +// symbol will then be made available to the linker and linked to inside dlfcn.go +var ( + _ = C.dlopen + _ = C.dlsym + _ = C.dlerror + _ = C.dlclose +) diff --git a/vendor/github.com/ebitengine/purego/internal/cgo/empty.go b/vendor/github.com/ebitengine/purego/internal/cgo/empty.go new file mode 100644 index 0000000000000..1d7cffe2a7e5f --- /dev/null +++ b/vendor/github.com/ebitengine/purego/internal/cgo/empty.go @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2024 The Ebitengine Authors + +package cgo + +// Empty so that importing this package doesn't cause issue for certain platforms. diff --git a/vendor/github.com/ebitengine/purego/internal/cgo/syscall_cgo_unix.go b/vendor/github.com/ebitengine/purego/internal/cgo/syscall_cgo_unix.go new file mode 100644 index 0000000000000..37ff24d5c1de7 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/internal/cgo/syscall_cgo_unix.go @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2022 The Ebitengine Authors + +//go:build freebsd || (linux && !(arm64 || amd64)) + +package cgo + +// this file is placed inside internal/cgo and not package purego +// because Cgo and assembly files can't be in the same package. + +/* + #cgo LDFLAGS: -ldl + +#include +#include +#include +#include + +typedef struct syscall15Args { + uintptr_t fn; + uintptr_t a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15; + uintptr_t f1, f2, f3, f4, f5, f6, f7, f8; + uintptr_t err; +} syscall15Args; + +void syscall15(struct syscall15Args *args) { + assert((args->f1|args->f2|args->f3|args->f4|args->f5|args->f6|args->f7|args->f8) == 0); + uintptr_t (*func_name)(uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, + uintptr_t a7, uintptr_t a8, uintptr_t a9, uintptr_t a10, uintptr_t a11, uintptr_t a12, + uintptr_t a13, uintptr_t a14, uintptr_t a15); + *(void**)(&func_name) = (void*)(args->fn); + uintptr_t r1 = func_name(args->a1,args->a2,args->a3,args->a4,args->a5,args->a6,args->a7,args->a8,args->a9, + args->a10,args->a11,args->a12,args->a13,args->a14,args->a15); + args->a1 = r1; + args->err = errno; +} + +*/ +import "C" +import "unsafe" + +// assign purego.syscall15XABI0 to the C version of this function. +var Syscall15XABI0 = unsafe.Pointer(C.syscall15) + +//go:nosplit +func Syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15 uintptr) (r1, r2, err uintptr) { + args := C.syscall15Args{ + C.uintptr_t(fn), C.uintptr_t(a1), C.uintptr_t(a2), C.uintptr_t(a3), + C.uintptr_t(a4), C.uintptr_t(a5), C.uintptr_t(a6), + C.uintptr_t(a7), C.uintptr_t(a8), C.uintptr_t(a9), C.uintptr_t(a10), C.uintptr_t(a11), C.uintptr_t(a12), + C.uintptr_t(a13), C.uintptr_t(a14), C.uintptr_t(a15), 0, 0, 0, 0, 0, 0, 0, 0, 0, + } + C.syscall15(&args) + return uintptr(args.a1), 0, uintptr(args.err) +} diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/abi_amd64.h b/vendor/github.com/ebitengine/purego/internal/fakecgo/abi_amd64.h new file mode 100644 index 0000000000000..9949435fe9e0a --- /dev/null +++ b/vendor/github.com/ebitengine/purego/internal/fakecgo/abi_amd64.h @@ -0,0 +1,99 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Macros for transitioning from the host ABI to Go ABI0. +// +// These save the frame pointer, so in general, functions that use +// these should have zero frame size to suppress the automatic frame +// pointer, though it's harmless to not do this. + +#ifdef GOOS_windows + +// REGS_HOST_TO_ABI0_STACK is the stack bytes used by +// PUSH_REGS_HOST_TO_ABI0. +#define REGS_HOST_TO_ABI0_STACK (28*8 + 8) + +// PUSH_REGS_HOST_TO_ABI0 prepares for transitioning from +// the host ABI to Go ABI0 code. It saves all registers that are +// callee-save in the host ABI and caller-save in Go ABI0 and prepares +// for entry to Go. +// +// Save DI SI BP BX R12 R13 R14 R15 X6-X15 registers and the DF flag. +// Clear the DF flag for the Go ABI. +// MXCSR matches the Go ABI, so we don't have to set that, +// and Go doesn't modify it, so we don't have to save it. +#define PUSH_REGS_HOST_TO_ABI0() \ + PUSHFQ \ + CLD \ + ADJSP $(REGS_HOST_TO_ABI0_STACK - 8) \ + MOVQ DI, (0*0)(SP) \ + MOVQ SI, (1*8)(SP) \ + MOVQ BP, (2*8)(SP) \ + MOVQ BX, (3*8)(SP) \ + MOVQ R12, (4*8)(SP) \ + MOVQ R13, (5*8)(SP) \ + MOVQ R14, (6*8)(SP) \ + MOVQ R15, (7*8)(SP) \ + MOVUPS X6, (8*8)(SP) \ + MOVUPS X7, (10*8)(SP) \ + MOVUPS X8, (12*8)(SP) \ + MOVUPS X9, (14*8)(SP) \ + MOVUPS X10, (16*8)(SP) \ + MOVUPS X11, (18*8)(SP) \ + MOVUPS X12, (20*8)(SP) \ + MOVUPS X13, (22*8)(SP) \ + MOVUPS X14, (24*8)(SP) \ + MOVUPS X15, (26*8)(SP) + +#define POP_REGS_HOST_TO_ABI0() \ + MOVQ (0*0)(SP), DI \ + MOVQ (1*8)(SP), SI \ + MOVQ (2*8)(SP), BP \ + MOVQ (3*8)(SP), BX \ + MOVQ (4*8)(SP), R12 \ + MOVQ (5*8)(SP), R13 \ + MOVQ (6*8)(SP), R14 \ + MOVQ (7*8)(SP), R15 \ + MOVUPS (8*8)(SP), X6 \ + MOVUPS (10*8)(SP), X7 \ + MOVUPS (12*8)(SP), X8 \ + MOVUPS (14*8)(SP), X9 \ + MOVUPS (16*8)(SP), X10 \ + MOVUPS (18*8)(SP), X11 \ + MOVUPS (20*8)(SP), X12 \ + MOVUPS (22*8)(SP), X13 \ + MOVUPS (24*8)(SP), X14 \ + MOVUPS (26*8)(SP), X15 \ + ADJSP $-(REGS_HOST_TO_ABI0_STACK - 8) \ + POPFQ + +#else +// SysV ABI + +#define REGS_HOST_TO_ABI0_STACK (6*8) + +// SysV MXCSR matches the Go ABI, so we don't have to set that, +// and Go doesn't modify it, so we don't have to save it. +// Both SysV and Go require DF to be cleared, so that's already clear. +// The SysV and Go frame pointer conventions are compatible. +#define PUSH_REGS_HOST_TO_ABI0() \ + ADJSP $(REGS_HOST_TO_ABI0_STACK) \ + MOVQ BP, (5*8)(SP) \ + LEAQ (5*8)(SP), BP \ + MOVQ BX, (0*8)(SP) \ + MOVQ R12, (1*8)(SP) \ + MOVQ R13, (2*8)(SP) \ + MOVQ R14, (3*8)(SP) \ + MOVQ R15, (4*8)(SP) + +#define POP_REGS_HOST_TO_ABI0() \ + MOVQ (0*8)(SP), BX \ + MOVQ (1*8)(SP), R12 \ + MOVQ (2*8)(SP), R13 \ + MOVQ (3*8)(SP), R14 \ + MOVQ (4*8)(SP), R15 \ + MOVQ (5*8)(SP), BP \ + ADJSP $-(REGS_HOST_TO_ABI0_STACK) + +#endif diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/abi_arm64.h b/vendor/github.com/ebitengine/purego/internal/fakecgo/abi_arm64.h new file mode 100644 index 0000000000000..5d5061ec1dbf8 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/internal/fakecgo/abi_arm64.h @@ -0,0 +1,39 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Macros for transitioning from the host ABI to Go ABI0. +// +// These macros save and restore the callee-saved registers +// from the stack, but they don't adjust stack pointer, so +// the user should prepare stack space in advance. +// SAVE_R19_TO_R28(offset) saves R19 ~ R28 to the stack space +// of ((offset)+0*8)(RSP) ~ ((offset)+9*8)(RSP). +// +// SAVE_F8_TO_F15(offset) saves F8 ~ F15 to the stack space +// of ((offset)+0*8)(RSP) ~ ((offset)+7*8)(RSP). +// +// R29 is not saved because Go will save and restore it. + +#define SAVE_R19_TO_R28(offset) \ + STP (R19, R20), ((offset)+0*8)(RSP) \ + STP (R21, R22), ((offset)+2*8)(RSP) \ + STP (R23, R24), ((offset)+4*8)(RSP) \ + STP (R25, R26), ((offset)+6*8)(RSP) \ + STP (R27, g), ((offset)+8*8)(RSP) +#define RESTORE_R19_TO_R28(offset) \ + LDP ((offset)+0*8)(RSP), (R19, R20) \ + LDP ((offset)+2*8)(RSP), (R21, R22) \ + LDP ((offset)+4*8)(RSP), (R23, R24) \ + LDP ((offset)+6*8)(RSP), (R25, R26) \ + LDP ((offset)+8*8)(RSP), (R27, g) /* R28 */ +#define SAVE_F8_TO_F15(offset) \ + FSTPD (F8, F9), ((offset)+0*8)(RSP) \ + FSTPD (F10, F11), ((offset)+2*8)(RSP) \ + FSTPD (F12, F13), ((offset)+4*8)(RSP) \ + FSTPD (F14, F15), ((offset)+6*8)(RSP) +#define RESTORE_F8_TO_F15(offset) \ + FLDPD ((offset)+0*8)(RSP), (F8, F9) \ + FLDPD ((offset)+2*8)(RSP), (F10, F11) \ + FLDPD ((offset)+4*8)(RSP), (F12, F13) \ + FLDPD ((offset)+6*8)(RSP), (F14, F15) diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/asm_amd64.s b/vendor/github.com/ebitengine/purego/internal/fakecgo/asm_amd64.s new file mode 100644 index 0000000000000..2b7eb57f8ae78 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/internal/fakecgo/asm_amd64.s @@ -0,0 +1,39 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +#include "textflag.h" +#include "abi_amd64.h" + +// Called by C code generated by cmd/cgo. +// func crosscall2(fn, a unsafe.Pointer, n int32, ctxt uintptr) +// Saves C callee-saved registers and calls cgocallback with three arguments. +// fn is the PC of a func(a unsafe.Pointer) function. +// This signature is known to SWIG, so we can't change it. +TEXT crosscall2(SB), NOSPLIT, $0-0 + PUSH_REGS_HOST_TO_ABI0() + + // Make room for arguments to cgocallback. + ADJSP $0x18 + +#ifndef GOOS_windows + MOVQ DI, 0x0(SP) // fn + MOVQ SI, 0x8(SP) // arg + + // Skip n in DX. + MOVQ CX, 0x10(SP) // ctxt + +#else + MOVQ CX, 0x0(SP) // fn + MOVQ DX, 0x8(SP) // arg + + // Skip n in R8. + MOVQ R9, 0x10(SP) // ctxt + +#endif + + CALL runtime·cgocallback(SB) + + ADJSP $-0x18 + POP_REGS_HOST_TO_ABI0() + RET diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/asm_arm64.s b/vendor/github.com/ebitengine/purego/internal/fakecgo/asm_arm64.s new file mode 100644 index 0000000000000..50e5261d922c5 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/internal/fakecgo/asm_arm64.s @@ -0,0 +1,36 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +#include "textflag.h" +#include "abi_arm64.h" + +// Called by C code generated by cmd/cgo. +// func crosscall2(fn, a unsafe.Pointer, n int32, ctxt uintptr) +// Saves C callee-saved registers and calls cgocallback with three arguments. +// fn is the PC of a func(a unsafe.Pointer) function. +TEXT crosscall2(SB), NOSPLIT|NOFRAME, $0 +/* + * We still need to save all callee save register as before, and then + * push 3 args for fn (R0, R1, R3), skipping R2. + * Also note that at procedure entry in gc world, 8(RSP) will be the + * first arg. + */ + SUB $(8*24), RSP + STP (R0, R1), (8*1)(RSP) + MOVD R3, (8*3)(RSP) + + SAVE_R19_TO_R28(8*4) + SAVE_F8_TO_F15(8*14) + STP (R29, R30), (8*22)(RSP) + + // Initialize Go ABI environment + BL runtime·load_g(SB) + BL runtime·cgocallback(SB) + + RESTORE_R19_TO_R28(8*4) + RESTORE_F8_TO_F15(8*14) + LDP (8*22)(RSP), (R29, R30) + + ADD $(8*24), RSP + RET diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/callbacks.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/callbacks.go new file mode 100644 index 0000000000000..f29e690cc15b3 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/internal/fakecgo/callbacks.go @@ -0,0 +1,93 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !cgo && (darwin || freebsd || linux) + +package fakecgo + +import ( + _ "unsafe" +) + +// TODO: decide if we need _runtime_cgo_panic_internal + +//go:linkname x_cgo_init_trampoline x_cgo_init_trampoline +//go:linkname _cgo_init _cgo_init +var x_cgo_init_trampoline byte +var _cgo_init = &x_cgo_init_trampoline + +// Creates a new system thread without updating any Go state. +// +// This method is invoked during shared library loading to create a new OS +// thread to perform the runtime initialization. This method is similar to +// _cgo_sys_thread_start except that it doesn't update any Go state. + +//go:linkname x_cgo_thread_start_trampoline x_cgo_thread_start_trampoline +//go:linkname _cgo_thread_start _cgo_thread_start +var x_cgo_thread_start_trampoline byte +var _cgo_thread_start = &x_cgo_thread_start_trampoline + +// Notifies that the runtime has been initialized. +// +// We currently block at every CGO entry point (via _cgo_wait_runtime_init_done) +// to ensure that the runtime has been initialized before the CGO call is +// executed. This is necessary for shared libraries where we kickoff runtime +// initialization in a separate thread and return without waiting for this +// thread to complete the init. + +//go:linkname x_cgo_notify_runtime_init_done_trampoline x_cgo_notify_runtime_init_done_trampoline +//go:linkname _cgo_notify_runtime_init_done _cgo_notify_runtime_init_done +var x_cgo_notify_runtime_init_done_trampoline byte +var _cgo_notify_runtime_init_done = &x_cgo_notify_runtime_init_done_trampoline + +// Indicates whether a dummy thread key has been created or not. +// +// When calling go exported function from C, we register a destructor +// callback, for a dummy thread key, by using pthread_key_create. + +//go:linkname _cgo_pthread_key_created _cgo_pthread_key_created +var x_cgo_pthread_key_created uintptr +var _cgo_pthread_key_created = &x_cgo_pthread_key_created + +// Set the x_crosscall2_ptr C function pointer variable point to crosscall2. +// It's for the runtime package to call at init time. +func set_crosscall2() { + // nothing needs to be done here for fakecgo + // because it's possible to just call cgocallback directly +} + +//go:linkname _set_crosscall2 runtime.set_crosscall2 +var _set_crosscall2 = set_crosscall2 + +// Store the g into the thread-specific value. +// So that pthread_key_destructor will dropm when the thread is exiting. + +//go:linkname x_cgo_bindm_trampoline x_cgo_bindm_trampoline +//go:linkname _cgo_bindm _cgo_bindm +var x_cgo_bindm_trampoline byte +var _cgo_bindm = &x_cgo_bindm_trampoline + +// TODO: decide if we need x_cgo_set_context_function +// TODO: decide if we need _cgo_yield + +var ( + // In Go 1.20 the race detector was rewritten to pure Go + // on darwin. This means that when CGO_ENABLED=0 is set + // fakecgo is built with race detector code. This is not + // good since this code is pretending to be C. The go:norace + // pragma is not enough, since it only applies to the native + // ABIInternal function. The ABIO wrapper (which is necessary, + // since all references to text symbols from assembly will use it) + // does not inherit the go:norace pragma, so it will still be + // instrumented by the race detector. + // + // To circumvent this issue, using closure calls in the + // assembly, which forces the compiler to use the ABIInternal + // native implementation (which has go:norace) instead. + threadentry_call = threadentry + x_cgo_init_call = x_cgo_init + x_cgo_setenv_call = x_cgo_setenv + x_cgo_unsetenv_call = x_cgo_unsetenv + x_cgo_thread_start_call = x_cgo_thread_start +) diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/doc.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/doc.go new file mode 100644 index 0000000000000..be82f7dfca90f --- /dev/null +++ b/vendor/github.com/ebitengine/purego/internal/fakecgo/doc.go @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2022 The Ebitengine Authors + +//go:build !cgo && (darwin || freebsd || linux) + +// Package fakecgo implements the Cgo runtime (runtime/cgo) entirely in Go. +// This allows code that calls into C to function properly when CGO_ENABLED=0. +// +// # Goals +// +// fakecgo attempts to replicate the same naming structure as in the runtime. +// For example, functions that have the prefix "gcc_*" are named "go_*". +// This makes it easier to port other GOOSs and GOARCHs as well as to keep +// it in sync with runtime/cgo. +// +// # Support +// +// Currently, fakecgo only supports macOS on amd64 & arm64. It also cannot +// be used with -buildmode=c-archive because that requires special initialization +// that fakecgo does not implement at the moment. +// +// # Usage +// +// Using fakecgo is easy just import _ "github.com/ebitengine/purego" and then +// set the environment variable CGO_ENABLED=0. +// The recommended usage for fakecgo is to prefer using runtime/cgo if possible +// but if cross-compiling or fast build times are important fakecgo is available. +// Purego will pick which ever Cgo runtime is available and prefer the one that +// comes with Go (runtime/cgo). +package fakecgo + +//go:generate go run gen.go diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/freebsd.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/freebsd.go new file mode 100644 index 0000000000000..bb73a709e6918 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/internal/fakecgo/freebsd.go @@ -0,0 +1,27 @@ +// Copyright 2010 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build freebsd && !cgo + +package fakecgo + +import _ "unsafe" // for go:linkname + +// Supply environ and __progname, because we don't +// link against the standard FreeBSD crt0.o and the +// libc dynamic library needs them. + +// Note: when building with cross-compiling or CGO_ENABLED=0, add +// the following argument to `go` so that these symbols are defined by +// making fakecgo the Cgo. +// -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" + +//go:linkname _environ environ +//go:linkname _progname __progname + +//go:cgo_export_dynamic environ +//go:cgo_export_dynamic __progname + +var _environ uintptr +var _progname uintptr diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/go_darwin_amd64.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/go_darwin_amd64.go new file mode 100644 index 0000000000000..39f5ff1f06a0e --- /dev/null +++ b/vendor/github.com/ebitengine/purego/internal/fakecgo/go_darwin_amd64.go @@ -0,0 +1,73 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !cgo + +package fakecgo + +import "unsafe" + +//go:nosplit +//go:norace +func _cgo_sys_thread_start(ts *ThreadStart) { + var attr pthread_attr_t + var ign, oset sigset_t + var p pthread_t + var size size_t + var err int + + sigfillset(&ign) + pthread_sigmask(SIG_SETMASK, &ign, &oset) + + size = pthread_get_stacksize_np(pthread_self()) + pthread_attr_init(&attr) + pthread_attr_setstacksize(&attr, size) + // Leave stacklo=0 and set stackhi=size; mstart will do the rest. + ts.g.stackhi = uintptr(size) + + err = _cgo_try_pthread_create(&p, &attr, unsafe.Pointer(threadentry_trampolineABI0), ts) + + pthread_sigmask(SIG_SETMASK, &oset, nil) + + if err != 0 { + print("fakecgo: pthread_create failed: ") + println(err) + abort() + } +} + +// threadentry_trampolineABI0 maps the C ABI to Go ABI then calls the Go function +// +//go:linkname x_threadentry_trampoline threadentry_trampoline +var x_threadentry_trampoline byte +var threadentry_trampolineABI0 = &x_threadentry_trampoline + +//go:nosplit +//go:norace +func threadentry(v unsafe.Pointer) unsafe.Pointer { + ts := *(*ThreadStart)(v) + free(v) + + setg_trampoline(setg_func, uintptr(unsafe.Pointer(ts.g))) + + // faking funcs in go is a bit a... involved - but the following works :) + fn := uintptr(unsafe.Pointer(&ts.fn)) + (*(*func())(unsafe.Pointer(&fn)))() + + return nil +} + +// here we will store a pointer to the provided setg func +var setg_func uintptr + +//go:nosplit +//go:norace +func x_cgo_init(g *G, setg uintptr) { + var size size_t + + setg_func = setg + + size = pthread_get_stacksize_np(pthread_self()) + g.stacklo = uintptr(unsafe.Add(unsafe.Pointer(&size), -size+4096)) +} diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/go_darwin_arm64.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/go_darwin_arm64.go new file mode 100644 index 0000000000000..d0868f0f79035 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/internal/fakecgo/go_darwin_arm64.go @@ -0,0 +1,88 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !cgo + +package fakecgo + +import "unsafe" + +//go:nosplit +//go:norace +func _cgo_sys_thread_start(ts *ThreadStart) { + var attr pthread_attr_t + var ign, oset sigset_t + var p pthread_t + var size size_t + var err int + + sigfillset(&ign) + pthread_sigmask(SIG_SETMASK, &ign, &oset) + + size = pthread_get_stacksize_np(pthread_self()) + pthread_attr_init(&attr) + pthread_attr_setstacksize(&attr, size) + // Leave stacklo=0 and set stackhi=size; mstart will do the rest. + ts.g.stackhi = uintptr(size) + + err = _cgo_try_pthread_create(&p, &attr, unsafe.Pointer(threadentry_trampolineABI0), ts) + + pthread_sigmask(SIG_SETMASK, &oset, nil) + + if err != 0 { + print("fakecgo: pthread_create failed: ") + println(err) + abort() + } +} + +// threadentry_trampolineABI0 maps the C ABI to Go ABI then calls the Go function +// +//go:linkname x_threadentry_trampoline threadentry_trampoline +var x_threadentry_trampoline byte +var threadentry_trampolineABI0 = &x_threadentry_trampoline + +//go:nosplit +//go:norace +func threadentry(v unsafe.Pointer) unsafe.Pointer { + ts := *(*ThreadStart)(v) + free(v) + + // TODO: support ios + //#if TARGET_OS_IPHONE + // darwin_arm_init_thread_exception_port(); + //#endif + setg_trampoline(setg_func, uintptr(unsafe.Pointer(ts.g))) + + // faking funcs in go is a bit a... involved - but the following works :) + fn := uintptr(unsafe.Pointer(&ts.fn)) + (*(*func())(unsafe.Pointer(&fn)))() + + return nil +} + +// here we will store a pointer to the provided setg func +var setg_func uintptr + +// x_cgo_init(G *g, void (*setg)(void*)) (runtime/cgo/gcc_linux_amd64.c) +// This get's called during startup, adjusts stacklo, and provides a pointer to setg_gcc for us +// Additionally, if we set _cgo_init to non-null, go won't do it's own TLS setup +// This function can't be go:systemstack since go is not in a state where the systemcheck would work. +// +//go:nosplit +//go:norace +func x_cgo_init(g *G, setg uintptr) { + var size size_t + + setg_func = setg + size = pthread_get_stacksize_np(pthread_self()) + g.stacklo = uintptr(unsafe.Add(unsafe.Pointer(&size), -size+4096)) + + //TODO: support ios + //#if TARGET_OS_IPHONE + // darwin_arm_init_mach_exception_handler(); + // darwin_arm_init_thread_exception_port(); + // init_working_dir(); + //#endif +} diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/go_freebsd_amd64.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/go_freebsd_amd64.go new file mode 100644 index 0000000000000..c9ff7156a8974 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/internal/fakecgo/go_freebsd_amd64.go @@ -0,0 +1,95 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !cgo + +package fakecgo + +import "unsafe" + +//go:nosplit +func _cgo_sys_thread_start(ts *ThreadStart) { + var attr pthread_attr_t + var ign, oset sigset_t + var p pthread_t + var size size_t + var err int + + //fprintf(stderr, "runtime/cgo: _cgo_sys_thread_start: fn=%p, g=%p\n", ts->fn, ts->g); // debug + sigfillset(&ign) + pthread_sigmask(SIG_SETMASK, &ign, &oset) + + pthread_attr_init(&attr) + pthread_attr_getstacksize(&attr, &size) + // Leave stacklo=0 and set stackhi=size; mstart will do the rest. + ts.g.stackhi = uintptr(size) + + err = _cgo_try_pthread_create(&p, &attr, unsafe.Pointer(threadentry_trampolineABI0), ts) + + pthread_sigmask(SIG_SETMASK, &oset, nil) + + if err != 0 { + print("fakecgo: pthread_create failed: ") + println(err) + abort() + } +} + +// threadentry_trampolineABI0 maps the C ABI to Go ABI then calls the Go function +// +//go:linkname x_threadentry_trampoline threadentry_trampoline +var x_threadentry_trampoline byte +var threadentry_trampolineABI0 = &x_threadentry_trampoline + +//go:nosplit +func threadentry(v unsafe.Pointer) unsafe.Pointer { + ts := *(*ThreadStart)(v) + free(v) + + setg_trampoline(setg_func, uintptr(unsafe.Pointer(ts.g))) + + // faking funcs in go is a bit a... involved - but the following works :) + fn := uintptr(unsafe.Pointer(&ts.fn)) + (*(*func())(unsafe.Pointer(&fn)))() + + return nil +} + +// here we will store a pointer to the provided setg func +var setg_func uintptr + +//go:nosplit +func x_cgo_init(g *G, setg uintptr) { + var size size_t + var attr *pthread_attr_t + + /* The memory sanitizer distributed with versions of clang + before 3.8 has a bug: if you call mmap before malloc, mmap + may return an address that is later overwritten by the msan + library. Avoid this problem by forcing a call to malloc + here, before we ever call malloc. + + This is only required for the memory sanitizer, so it's + unfortunate that we always run it. It should be possible + to remove this when we no longer care about versions of + clang before 3.8. The test for this is + misc/cgo/testsanitizers. + + GCC works hard to eliminate a seemingly unnecessary call to + malloc, so we actually use the memory we allocate. */ + + setg_func = setg + attr = (*pthread_attr_t)(malloc(unsafe.Sizeof(*attr))) + if attr == nil { + println("fakecgo: malloc failed") + abort() + } + pthread_attr_init(attr) + pthread_attr_getstacksize(attr, &size) + // runtime/cgo uses __builtin_frame_address(0) instead of `uintptr(unsafe.Pointer(&size))` + // but this should be OK since we are taking the address of the first variable in this function. + g.stacklo = uintptr(unsafe.Pointer(&size)) - uintptr(size) + 4096 + pthread_attr_destroy(attr) + free(unsafe.Pointer(attr)) +} diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/go_freebsd_arm64.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/go_freebsd_arm64.go new file mode 100644 index 0000000000000..e3a060b93506a --- /dev/null +++ b/vendor/github.com/ebitengine/purego/internal/fakecgo/go_freebsd_arm64.go @@ -0,0 +1,98 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !cgo + +package fakecgo + +import "unsafe" + +//go:nosplit +func _cgo_sys_thread_start(ts *ThreadStart) { + var attr pthread_attr_t + var ign, oset sigset_t + var p pthread_t + var size size_t + var err int + + // fprintf(stderr, "runtime/cgo: _cgo_sys_thread_start: fn=%p, g=%p\n", ts->fn, ts->g); // debug + sigfillset(&ign) + pthread_sigmask(SIG_SETMASK, &ign, &oset) + + pthread_attr_init(&attr) + pthread_attr_getstacksize(&attr, &size) + // Leave stacklo=0 and set stackhi=size; mstart will do the rest. + ts.g.stackhi = uintptr(size) + + err = _cgo_try_pthread_create(&p, &attr, unsafe.Pointer(threadentry_trampolineABI0), ts) + + pthread_sigmask(SIG_SETMASK, &oset, nil) + + if err != 0 { + print("fakecgo: pthread_create failed: ") + println(err) + abort() + } +} + +// threadentry_trampolineABI0 maps the C ABI to Go ABI then calls the Go function +// +//go:linkname x_threadentry_trampoline threadentry_trampoline +var x_threadentry_trampoline byte +var threadentry_trampolineABI0 = &x_threadentry_trampoline + +//go:nosplit +func threadentry(v unsafe.Pointer) unsafe.Pointer { + ts := *(*ThreadStart)(v) + free(v) + + setg_trampoline(setg_func, uintptr(unsafe.Pointer(ts.g))) + + // faking funcs in go is a bit a... involved - but the following works :) + fn := uintptr(unsafe.Pointer(&ts.fn)) + (*(*func())(unsafe.Pointer(&fn)))() + + return nil +} + +// here we will store a pointer to the provided setg func +var setg_func uintptr + +// x_cgo_init(G *g, void (*setg)(void*)) (runtime/cgo/gcc_linux_amd64.c) +// This get's called during startup, adjusts stacklo, and provides a pointer to setg_gcc for us +// Additionally, if we set _cgo_init to non-null, go won't do it's own TLS setup +// This function can't be go:systemstack since go is not in a state where the systemcheck would work. +// +//go:nosplit +func x_cgo_init(g *G, setg uintptr) { + var size size_t + var attr *pthread_attr_t + + /* The memory sanitizer distributed with versions of clang + before 3.8 has a bug: if you call mmap before malloc, mmap + may return an address that is later overwritten by the msan + library. Avoid this problem by forcing a call to malloc + here, before we ever call malloc. + + This is only required for the memory sanitizer, so it's + unfortunate that we always run it. It should be possible + to remove this when we no longer care about versions of + clang before 3.8. The test for this is + misc/cgo/testsanitizers. + + GCC works hard to eliminate a seemingly unnecessary call to + malloc, so we actually use the memory we allocate. */ + + setg_func = setg + attr = (*pthread_attr_t)(malloc(unsafe.Sizeof(*attr))) + if attr == nil { + println("fakecgo: malloc failed") + abort() + } + pthread_attr_init(attr) + pthread_attr_getstacksize(attr, &size) + g.stacklo = uintptr(unsafe.Pointer(&size)) - uintptr(size) + 4096 + pthread_attr_destroy(attr) + free(unsafe.Pointer(attr)) +} diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/go_libinit.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/go_libinit.go new file mode 100644 index 0000000000000..e5cb46be4557c --- /dev/null +++ b/vendor/github.com/ebitengine/purego/internal/fakecgo/go_libinit.go @@ -0,0 +1,66 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2022 The Ebitengine Authors + +//go:build !cgo && (darwin || freebsd || linux) + +package fakecgo + +import ( + "syscall" + "unsafe" +) + +var ( + pthread_g pthread_key_t + + runtime_init_cond = PTHREAD_COND_INITIALIZER + runtime_init_mu = PTHREAD_MUTEX_INITIALIZER + runtime_init_done int +) + +//go:nosplit +func x_cgo_notify_runtime_init_done() { + pthread_mutex_lock(&runtime_init_mu) + runtime_init_done = 1 + pthread_cond_broadcast(&runtime_init_cond) + pthread_mutex_unlock(&runtime_init_mu) +} + +// Store the g into a thread-specific value associated with the pthread key pthread_g. +// And pthread_key_destructor will dropm when the thread is exiting. +func x_cgo_bindm(g unsafe.Pointer) { + // We assume this will always succeed, otherwise, there might be extra M leaking, + // when a C thread exits after a cgo call. + // We only invoke this function once per thread in runtime.needAndBindM, + // and the next calls just reuse the bound m. + pthread_setspecific(pthread_g, g) +} + +// _cgo_try_pthread_create retries pthread_create if it fails with +// EAGAIN. +// +//go:nosplit +//go:norace +func _cgo_try_pthread_create(thread *pthread_t, attr *pthread_attr_t, pfn unsafe.Pointer, arg *ThreadStart) int { + var ts syscall.Timespec + // tries needs to be the same type as syscall.Timespec.Nsec + // but the fields are int32 on 32bit and int64 on 64bit. + // tries is assigned to syscall.Timespec.Nsec in order to match its type. + tries := ts.Nsec + var err int + + for tries = 0; tries < 20; tries++ { + err = int(pthread_create(thread, attr, pfn, unsafe.Pointer(arg))) + if err == 0 { + pthread_detach(*thread) + return 0 + } + if err != int(syscall.EAGAIN) { + return err + } + ts.Sec = 0 + ts.Nsec = (tries + 1) * 1000 * 1000 // Milliseconds. + nanosleep(&ts, nil) + } + return int(syscall.EAGAIN) +} diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/go_linux_amd64.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/go_linux_amd64.go new file mode 100644 index 0000000000000..c9ff7156a8974 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/internal/fakecgo/go_linux_amd64.go @@ -0,0 +1,95 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !cgo + +package fakecgo + +import "unsafe" + +//go:nosplit +func _cgo_sys_thread_start(ts *ThreadStart) { + var attr pthread_attr_t + var ign, oset sigset_t + var p pthread_t + var size size_t + var err int + + //fprintf(stderr, "runtime/cgo: _cgo_sys_thread_start: fn=%p, g=%p\n", ts->fn, ts->g); // debug + sigfillset(&ign) + pthread_sigmask(SIG_SETMASK, &ign, &oset) + + pthread_attr_init(&attr) + pthread_attr_getstacksize(&attr, &size) + // Leave stacklo=0 and set stackhi=size; mstart will do the rest. + ts.g.stackhi = uintptr(size) + + err = _cgo_try_pthread_create(&p, &attr, unsafe.Pointer(threadentry_trampolineABI0), ts) + + pthread_sigmask(SIG_SETMASK, &oset, nil) + + if err != 0 { + print("fakecgo: pthread_create failed: ") + println(err) + abort() + } +} + +// threadentry_trampolineABI0 maps the C ABI to Go ABI then calls the Go function +// +//go:linkname x_threadentry_trampoline threadentry_trampoline +var x_threadentry_trampoline byte +var threadentry_trampolineABI0 = &x_threadentry_trampoline + +//go:nosplit +func threadentry(v unsafe.Pointer) unsafe.Pointer { + ts := *(*ThreadStart)(v) + free(v) + + setg_trampoline(setg_func, uintptr(unsafe.Pointer(ts.g))) + + // faking funcs in go is a bit a... involved - but the following works :) + fn := uintptr(unsafe.Pointer(&ts.fn)) + (*(*func())(unsafe.Pointer(&fn)))() + + return nil +} + +// here we will store a pointer to the provided setg func +var setg_func uintptr + +//go:nosplit +func x_cgo_init(g *G, setg uintptr) { + var size size_t + var attr *pthread_attr_t + + /* The memory sanitizer distributed with versions of clang + before 3.8 has a bug: if you call mmap before malloc, mmap + may return an address that is later overwritten by the msan + library. Avoid this problem by forcing a call to malloc + here, before we ever call malloc. + + This is only required for the memory sanitizer, so it's + unfortunate that we always run it. It should be possible + to remove this when we no longer care about versions of + clang before 3.8. The test for this is + misc/cgo/testsanitizers. + + GCC works hard to eliminate a seemingly unnecessary call to + malloc, so we actually use the memory we allocate. */ + + setg_func = setg + attr = (*pthread_attr_t)(malloc(unsafe.Sizeof(*attr))) + if attr == nil { + println("fakecgo: malloc failed") + abort() + } + pthread_attr_init(attr) + pthread_attr_getstacksize(attr, &size) + // runtime/cgo uses __builtin_frame_address(0) instead of `uintptr(unsafe.Pointer(&size))` + // but this should be OK since we are taking the address of the first variable in this function. + g.stacklo = uintptr(unsafe.Pointer(&size)) - uintptr(size) + 4096 + pthread_attr_destroy(attr) + free(unsafe.Pointer(attr)) +} diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/go_linux_arm64.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/go_linux_arm64.go new file mode 100644 index 0000000000000..a3b1cca59a086 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/internal/fakecgo/go_linux_arm64.go @@ -0,0 +1,98 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !cgo + +package fakecgo + +import "unsafe" + +//go:nosplit +func _cgo_sys_thread_start(ts *ThreadStart) { + var attr pthread_attr_t + var ign, oset sigset_t + var p pthread_t + var size size_t + var err int + + //fprintf(stderr, "runtime/cgo: _cgo_sys_thread_start: fn=%p, g=%p\n", ts->fn, ts->g); // debug + sigfillset(&ign) + pthread_sigmask(SIG_SETMASK, &ign, &oset) + + pthread_attr_init(&attr) + pthread_attr_getstacksize(&attr, &size) + // Leave stacklo=0 and set stackhi=size; mstart will do the rest. + ts.g.stackhi = uintptr(size) + + err = _cgo_try_pthread_create(&p, &attr, unsafe.Pointer(threadentry_trampolineABI0), ts) + + pthread_sigmask(SIG_SETMASK, &oset, nil) + + if err != 0 { + print("fakecgo: pthread_create failed: ") + println(err) + abort() + } +} + +// threadentry_trampolineABI0 maps the C ABI to Go ABI then calls the Go function +// +//go:linkname x_threadentry_trampoline threadentry_trampoline +var x_threadentry_trampoline byte +var threadentry_trampolineABI0 = &x_threadentry_trampoline + +//go:nosplit +func threadentry(v unsafe.Pointer) unsafe.Pointer { + ts := *(*ThreadStart)(v) + free(v) + + setg_trampoline(setg_func, uintptr(unsafe.Pointer(ts.g))) + + // faking funcs in go is a bit a... involved - but the following works :) + fn := uintptr(unsafe.Pointer(&ts.fn)) + (*(*func())(unsafe.Pointer(&fn)))() + + return nil +} + +// here we will store a pointer to the provided setg func +var setg_func uintptr + +// x_cgo_init(G *g, void (*setg)(void*)) (runtime/cgo/gcc_linux_amd64.c) +// This get's called during startup, adjusts stacklo, and provides a pointer to setg_gcc for us +// Additionally, if we set _cgo_init to non-null, go won't do it's own TLS setup +// This function can't be go:systemstack since go is not in a state where the systemcheck would work. +// +//go:nosplit +func x_cgo_init(g *G, setg uintptr) { + var size size_t + var attr *pthread_attr_t + + /* The memory sanitizer distributed with versions of clang + before 3.8 has a bug: if you call mmap before malloc, mmap + may return an address that is later overwritten by the msan + library. Avoid this problem by forcing a call to malloc + here, before we ever call malloc. + + This is only required for the memory sanitizer, so it's + unfortunate that we always run it. It should be possible + to remove this when we no longer care about versions of + clang before 3.8. The test for this is + misc/cgo/testsanitizers. + + GCC works hard to eliminate a seemingly unnecessary call to + malloc, so we actually use the memory we allocate. */ + + setg_func = setg + attr = (*pthread_attr_t)(malloc(unsafe.Sizeof(*attr))) + if attr == nil { + println("fakecgo: malloc failed") + abort() + } + pthread_attr_init(attr) + pthread_attr_getstacksize(attr, &size) + g.stacklo = uintptr(unsafe.Pointer(&size)) - uintptr(size) + 4096 + pthread_attr_destroy(attr) + free(unsafe.Pointer(attr)) +} diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/go_setenv.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/go_setenv.go new file mode 100644 index 0000000000000..e42d84f0b75ea --- /dev/null +++ b/vendor/github.com/ebitengine/purego/internal/fakecgo/go_setenv.go @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2022 The Ebitengine Authors + +//go:build !cgo && (darwin || freebsd || linux) + +package fakecgo + +//go:nosplit +//go:norace +func x_cgo_setenv(arg *[2]*byte) { + setenv(arg[0], arg[1], 1) +} + +//go:nosplit +//go:norace +func x_cgo_unsetenv(arg *[1]*byte) { + unsetenv(arg[0]) +} diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/go_util.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/go_util.go new file mode 100644 index 0000000000000..0ac10d1f1578d --- /dev/null +++ b/vendor/github.com/ebitengine/purego/internal/fakecgo/go_util.go @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2022 The Ebitengine Authors + +//go:build !cgo && (darwin || freebsd || linux) + +package fakecgo + +import "unsafe" + +// _cgo_thread_start is split into three parts in cgo since only one part is system dependent (keep it here for easier handling) + +// _cgo_thread_start(ThreadStart *arg) (runtime/cgo/gcc_util.c) +// This get's called instead of the go code for creating new threads +// -> pthread_* stuff is used, so threads are setup correctly for C +// If this is missing, TLS is only setup correctly on thread 1! +// This function should be go:systemstack instead of go:nosplit (but that requires runtime) +// +//go:nosplit +//go:norace +func x_cgo_thread_start(arg *ThreadStart) { + var ts *ThreadStart + // Make our own copy that can persist after we return. + // _cgo_tsan_acquire(); + ts = (*ThreadStart)(malloc(unsafe.Sizeof(*ts))) + // _cgo_tsan_release(); + if ts == nil { + println("fakecgo: out of memory in thread_start") + abort() + } + // *ts = *arg would cause a writebarrier so copy using slices + s1 := unsafe.Slice((*uintptr)(unsafe.Pointer(ts)), unsafe.Sizeof(*ts)/8) + s2 := unsafe.Slice((*uintptr)(unsafe.Pointer(arg)), unsafe.Sizeof(*arg)/8) + for i := range s2 { + s1[i] = s2[i] + } + _cgo_sys_thread_start(ts) // OS-dependent half +} diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/iscgo.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/iscgo.go new file mode 100644 index 0000000000000..28af41cc64072 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/internal/fakecgo/iscgo.go @@ -0,0 +1,19 @@ +// Copyright 2010 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 !cgo && (darwin || freebsd || linux) + +// The runtime package contains an uninitialized definition +// for runtime·iscgo. Override it to tell the runtime we're here. +// There are various function pointers that should be set too, +// but those depend on dynamic linker magic to get initialized +// correctly, and sometimes they break. This variable is a +// backup: it depends only on old C style static linking rules. + +package fakecgo + +import _ "unsafe" // for go:linkname + +//go:linkname _iscgo runtime.iscgo +var _iscgo bool = true diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo.go new file mode 100644 index 0000000000000..74626c64a0e9a --- /dev/null +++ b/vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo.go @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2022 The Ebitengine Authors + +//go:build !cgo && (darwin || freebsd || linux) + +package fakecgo + +type ( + size_t uintptr + sigset_t [128]byte + pthread_attr_t [64]byte + pthread_t int + pthread_key_t uint64 +) + +// for pthread_sigmask: + +type sighow int32 + +const ( + SIG_BLOCK sighow = 0 + SIG_UNBLOCK sighow = 1 + SIG_SETMASK sighow = 2 +) + +type G struct { + stacklo uintptr + stackhi uintptr +} + +type ThreadStart struct { + g *G + tls *uintptr + fn uintptr +} diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_darwin.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_darwin.go new file mode 100644 index 0000000000000..af148333f6d9c --- /dev/null +++ b/vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_darwin.go @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2022 The Ebitengine Authors + +//go:build !cgo + +package fakecgo + +type ( + pthread_mutex_t struct { + sig int64 + opaque [56]byte + } + pthread_cond_t struct { + sig int64 + opaque [40]byte + } +) + +var ( + PTHREAD_COND_INITIALIZER = pthread_cond_t{sig: 0x3CB0B1BB} + PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t{sig: 0x32AAABA7} +) diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_freebsd.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_freebsd.go new file mode 100644 index 0000000000000..ca1f722c93989 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_freebsd.go @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2022 The Ebitengine Authors + +//go:build !cgo + +package fakecgo + +type ( + pthread_cond_t uintptr + pthread_mutex_t uintptr +) + +var ( + PTHREAD_COND_INITIALIZER = pthread_cond_t(0) + PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t(0) +) diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_linux.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_linux.go new file mode 100644 index 0000000000000..c4b6e9ea5a4cf --- /dev/null +++ b/vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_linux.go @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2022 The Ebitengine Authors + +//go:build !cgo + +package fakecgo + +type ( + pthread_cond_t [48]byte + pthread_mutex_t [48]byte +) + +var ( + PTHREAD_COND_INITIALIZER = pthread_cond_t{} + PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t{} +) diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/setenv.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/setenv.go new file mode 100644 index 0000000000000..f30af0e151569 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/internal/fakecgo/setenv.go @@ -0,0 +1,19 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !cgo && (darwin || freebsd || linux) + +package fakecgo + +import _ "unsafe" // for go:linkname + +//go:linkname x_cgo_setenv_trampoline x_cgo_setenv_trampoline +//go:linkname _cgo_setenv runtime._cgo_setenv +var x_cgo_setenv_trampoline byte +var _cgo_setenv = &x_cgo_setenv_trampoline + +//go:linkname x_cgo_unsetenv_trampoline x_cgo_unsetenv_trampoline +//go:linkname _cgo_unsetenv runtime._cgo_unsetenv +var x_cgo_unsetenv_trampoline byte +var _cgo_unsetenv = &x_cgo_unsetenv_trampoline diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols.go new file mode 100644 index 0000000000000..3d19fd822a73e --- /dev/null +++ b/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols.go @@ -0,0 +1,181 @@ +// Code generated by 'go generate' with gen.go. DO NOT EDIT. + +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2022 The Ebitengine Authors + +//go:build !cgo && (darwin || freebsd || linux) + +package fakecgo + +import ( + "syscall" + "unsafe" +) + +// setg_trampoline calls setg with the G provided +func setg_trampoline(setg uintptr, G uintptr) + +// call5 takes fn the C function and 5 arguments and calls the function with those arguments +func call5(fn, a1, a2, a3, a4, a5 uintptr) uintptr + +func malloc(size uintptr) unsafe.Pointer { + ret := call5(mallocABI0, uintptr(size), 0, 0, 0, 0) + // this indirection is to avoid go vet complaining about possible misuse of unsafe.Pointer + return *(*unsafe.Pointer)(unsafe.Pointer(&ret)) +} + +func free(ptr unsafe.Pointer) { + call5(freeABI0, uintptr(ptr), 0, 0, 0, 0) +} + +func setenv(name *byte, value *byte, overwrite int32) int32 { + return int32(call5(setenvABI0, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(value)), uintptr(overwrite), 0, 0)) +} + +func unsetenv(name *byte) int32 { + return int32(call5(unsetenvABI0, uintptr(unsafe.Pointer(name)), 0, 0, 0, 0)) +} + +func sigfillset(set *sigset_t) int32 { + return int32(call5(sigfillsetABI0, uintptr(unsafe.Pointer(set)), 0, 0, 0, 0)) +} + +func nanosleep(ts *syscall.Timespec, rem *syscall.Timespec) int32 { + return int32(call5(nanosleepABI0, uintptr(unsafe.Pointer(ts)), uintptr(unsafe.Pointer(rem)), 0, 0, 0)) +} + +func abort() { + call5(abortABI0, 0, 0, 0, 0, 0) +} + +func pthread_attr_init(attr *pthread_attr_t) int32 { + return int32(call5(pthread_attr_initABI0, uintptr(unsafe.Pointer(attr)), 0, 0, 0, 0)) +} + +func pthread_create(thread *pthread_t, attr *pthread_attr_t, start unsafe.Pointer, arg unsafe.Pointer) int32 { + return int32(call5(pthread_createABI0, uintptr(unsafe.Pointer(thread)), uintptr(unsafe.Pointer(attr)), uintptr(start), uintptr(arg), 0)) +} + +func pthread_detach(thread pthread_t) int32 { + return int32(call5(pthread_detachABI0, uintptr(thread), 0, 0, 0, 0)) +} + +func pthread_sigmask(how sighow, ign *sigset_t, oset *sigset_t) int32 { + return int32(call5(pthread_sigmaskABI0, uintptr(how), uintptr(unsafe.Pointer(ign)), uintptr(unsafe.Pointer(oset)), 0, 0)) +} + +func pthread_self() pthread_t { + return pthread_t(call5(pthread_selfABI0, 0, 0, 0, 0, 0)) +} + +func pthread_get_stacksize_np(thread pthread_t) size_t { + return size_t(call5(pthread_get_stacksize_npABI0, uintptr(thread), 0, 0, 0, 0)) +} + +func pthread_attr_getstacksize(attr *pthread_attr_t, stacksize *size_t) int32 { + return int32(call5(pthread_attr_getstacksizeABI0, uintptr(unsafe.Pointer(attr)), uintptr(unsafe.Pointer(stacksize)), 0, 0, 0)) +} + +func pthread_attr_setstacksize(attr *pthread_attr_t, size size_t) int32 { + return int32(call5(pthread_attr_setstacksizeABI0, uintptr(unsafe.Pointer(attr)), uintptr(size), 0, 0, 0)) +} + +func pthread_attr_destroy(attr *pthread_attr_t) int32 { + return int32(call5(pthread_attr_destroyABI0, uintptr(unsafe.Pointer(attr)), 0, 0, 0, 0)) +} + +func pthread_mutex_lock(mutex *pthread_mutex_t) int32 { + return int32(call5(pthread_mutex_lockABI0, uintptr(unsafe.Pointer(mutex)), 0, 0, 0, 0)) +} + +func pthread_mutex_unlock(mutex *pthread_mutex_t) int32 { + return int32(call5(pthread_mutex_unlockABI0, uintptr(unsafe.Pointer(mutex)), 0, 0, 0, 0)) +} + +func pthread_cond_broadcast(cond *pthread_cond_t) int32 { + return int32(call5(pthread_cond_broadcastABI0, uintptr(unsafe.Pointer(cond)), 0, 0, 0, 0)) +} + +func pthread_setspecific(key pthread_key_t, value unsafe.Pointer) int32 { + return int32(call5(pthread_setspecificABI0, uintptr(key), uintptr(value), 0, 0, 0)) +} + +//go:linkname _malloc _malloc +var _malloc uintptr +var mallocABI0 = uintptr(unsafe.Pointer(&_malloc)) + +//go:linkname _free _free +var _free uintptr +var freeABI0 = uintptr(unsafe.Pointer(&_free)) + +//go:linkname _setenv _setenv +var _setenv uintptr +var setenvABI0 = uintptr(unsafe.Pointer(&_setenv)) + +//go:linkname _unsetenv _unsetenv +var _unsetenv uintptr +var unsetenvABI0 = uintptr(unsafe.Pointer(&_unsetenv)) + +//go:linkname _sigfillset _sigfillset +var _sigfillset uintptr +var sigfillsetABI0 = uintptr(unsafe.Pointer(&_sigfillset)) + +//go:linkname _nanosleep _nanosleep +var _nanosleep uintptr +var nanosleepABI0 = uintptr(unsafe.Pointer(&_nanosleep)) + +//go:linkname _abort _abort +var _abort uintptr +var abortABI0 = uintptr(unsafe.Pointer(&_abort)) + +//go:linkname _pthread_attr_init _pthread_attr_init +var _pthread_attr_init uintptr +var pthread_attr_initABI0 = uintptr(unsafe.Pointer(&_pthread_attr_init)) + +//go:linkname _pthread_create _pthread_create +var _pthread_create uintptr +var pthread_createABI0 = uintptr(unsafe.Pointer(&_pthread_create)) + +//go:linkname _pthread_detach _pthread_detach +var _pthread_detach uintptr +var pthread_detachABI0 = uintptr(unsafe.Pointer(&_pthread_detach)) + +//go:linkname _pthread_sigmask _pthread_sigmask +var _pthread_sigmask uintptr +var pthread_sigmaskABI0 = uintptr(unsafe.Pointer(&_pthread_sigmask)) + +//go:linkname _pthread_self _pthread_self +var _pthread_self uintptr +var pthread_selfABI0 = uintptr(unsafe.Pointer(&_pthread_self)) + +//go:linkname _pthread_get_stacksize_np _pthread_get_stacksize_np +var _pthread_get_stacksize_np uintptr +var pthread_get_stacksize_npABI0 = uintptr(unsafe.Pointer(&_pthread_get_stacksize_np)) + +//go:linkname _pthread_attr_getstacksize _pthread_attr_getstacksize +var _pthread_attr_getstacksize uintptr +var pthread_attr_getstacksizeABI0 = uintptr(unsafe.Pointer(&_pthread_attr_getstacksize)) + +//go:linkname _pthread_attr_setstacksize _pthread_attr_setstacksize +var _pthread_attr_setstacksize uintptr +var pthread_attr_setstacksizeABI0 = uintptr(unsafe.Pointer(&_pthread_attr_setstacksize)) + +//go:linkname _pthread_attr_destroy _pthread_attr_destroy +var _pthread_attr_destroy uintptr +var pthread_attr_destroyABI0 = uintptr(unsafe.Pointer(&_pthread_attr_destroy)) + +//go:linkname _pthread_mutex_lock _pthread_mutex_lock +var _pthread_mutex_lock uintptr +var pthread_mutex_lockABI0 = uintptr(unsafe.Pointer(&_pthread_mutex_lock)) + +//go:linkname _pthread_mutex_unlock _pthread_mutex_unlock +var _pthread_mutex_unlock uintptr +var pthread_mutex_unlockABI0 = uintptr(unsafe.Pointer(&_pthread_mutex_unlock)) + +//go:linkname _pthread_cond_broadcast _pthread_cond_broadcast +var _pthread_cond_broadcast uintptr +var pthread_cond_broadcastABI0 = uintptr(unsafe.Pointer(&_pthread_cond_broadcast)) + +//go:linkname _pthread_setspecific _pthread_setspecific +var _pthread_setspecific uintptr +var pthread_setspecificABI0 = uintptr(unsafe.Pointer(&_pthread_setspecific)) diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols_darwin.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols_darwin.go new file mode 100644 index 0000000000000..54aaa46285c86 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols_darwin.go @@ -0,0 +1,29 @@ +// Code generated by 'go generate' with gen.go. DO NOT EDIT. + +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2022 The Ebitengine Authors + +//go:build !cgo + +package fakecgo + +//go:cgo_import_dynamic purego_malloc malloc "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic purego_free free "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic purego_setenv setenv "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic purego_unsetenv unsetenv "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic purego_sigfillset sigfillset "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic purego_nanosleep nanosleep "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic purego_abort abort "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic purego_pthread_attr_init pthread_attr_init "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic purego_pthread_create pthread_create "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic purego_pthread_detach pthread_detach "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic purego_pthread_sigmask pthread_sigmask "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic purego_pthread_self pthread_self "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic purego_pthread_get_stacksize_np pthread_get_stacksize_np "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic purego_pthread_attr_getstacksize pthread_attr_getstacksize "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic purego_pthread_attr_setstacksize pthread_attr_setstacksize "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic purego_pthread_attr_destroy pthread_attr_destroy "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic purego_pthread_mutex_lock pthread_mutex_lock "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic purego_pthread_mutex_unlock pthread_mutex_unlock "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic purego_pthread_cond_broadcast pthread_cond_broadcast "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic purego_pthread_setspecific pthread_setspecific "/usr/lib/libSystem.B.dylib" diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols_freebsd.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols_freebsd.go new file mode 100644 index 0000000000000..81538119799f5 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols_freebsd.go @@ -0,0 +1,29 @@ +// Code generated by 'go generate' with gen.go. DO NOT EDIT. + +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2022 The Ebitengine Authors + +//go:build !cgo + +package fakecgo + +//go:cgo_import_dynamic purego_malloc malloc "libc.so.7" +//go:cgo_import_dynamic purego_free free "libc.so.7" +//go:cgo_import_dynamic purego_setenv setenv "libc.so.7" +//go:cgo_import_dynamic purego_unsetenv unsetenv "libc.so.7" +//go:cgo_import_dynamic purego_sigfillset sigfillset "libc.so.7" +//go:cgo_import_dynamic purego_nanosleep nanosleep "libc.so.7" +//go:cgo_import_dynamic purego_abort abort "libc.so.7" +//go:cgo_import_dynamic purego_pthread_attr_init pthread_attr_init "libpthread.so" +//go:cgo_import_dynamic purego_pthread_create pthread_create "libpthread.so" +//go:cgo_import_dynamic purego_pthread_detach pthread_detach "libpthread.so" +//go:cgo_import_dynamic purego_pthread_sigmask pthread_sigmask "libpthread.so" +//go:cgo_import_dynamic purego_pthread_self pthread_self "libpthread.so" +//go:cgo_import_dynamic purego_pthread_get_stacksize_np pthread_get_stacksize_np "libpthread.so" +//go:cgo_import_dynamic purego_pthread_attr_getstacksize pthread_attr_getstacksize "libpthread.so" +//go:cgo_import_dynamic purego_pthread_attr_setstacksize pthread_attr_setstacksize "libpthread.so" +//go:cgo_import_dynamic purego_pthread_attr_destroy pthread_attr_destroy "libpthread.so" +//go:cgo_import_dynamic purego_pthread_mutex_lock pthread_mutex_lock "libpthread.so" +//go:cgo_import_dynamic purego_pthread_mutex_unlock pthread_mutex_unlock "libpthread.so" +//go:cgo_import_dynamic purego_pthread_cond_broadcast pthread_cond_broadcast "libpthread.so" +//go:cgo_import_dynamic purego_pthread_setspecific pthread_setspecific "libpthread.so" diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols_linux.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols_linux.go new file mode 100644 index 0000000000000..180057d0156d8 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols_linux.go @@ -0,0 +1,29 @@ +// Code generated by 'go generate' with gen.go. DO NOT EDIT. + +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2022 The Ebitengine Authors + +//go:build !cgo + +package fakecgo + +//go:cgo_import_dynamic purego_malloc malloc "libc.so.6" +//go:cgo_import_dynamic purego_free free "libc.so.6" +//go:cgo_import_dynamic purego_setenv setenv "libc.so.6" +//go:cgo_import_dynamic purego_unsetenv unsetenv "libc.so.6" +//go:cgo_import_dynamic purego_sigfillset sigfillset "libc.so.6" +//go:cgo_import_dynamic purego_nanosleep nanosleep "libc.so.6" +//go:cgo_import_dynamic purego_abort abort "libc.so.6" +//go:cgo_import_dynamic purego_pthread_attr_init pthread_attr_init "libpthread.so.0" +//go:cgo_import_dynamic purego_pthread_create pthread_create "libpthread.so.0" +//go:cgo_import_dynamic purego_pthread_detach pthread_detach "libpthread.so.0" +//go:cgo_import_dynamic purego_pthread_sigmask pthread_sigmask "libpthread.so.0" +//go:cgo_import_dynamic purego_pthread_self pthread_self "libpthread.so.0" +//go:cgo_import_dynamic purego_pthread_get_stacksize_np pthread_get_stacksize_np "libpthread.so.0" +//go:cgo_import_dynamic purego_pthread_attr_getstacksize pthread_attr_getstacksize "libpthread.so.0" +//go:cgo_import_dynamic purego_pthread_attr_setstacksize pthread_attr_setstacksize "libpthread.so.0" +//go:cgo_import_dynamic purego_pthread_attr_destroy pthread_attr_destroy "libpthread.so.0" +//go:cgo_import_dynamic purego_pthread_mutex_lock pthread_mutex_lock "libpthread.so.0" +//go:cgo_import_dynamic purego_pthread_mutex_unlock pthread_mutex_unlock "libpthread.so.0" +//go:cgo_import_dynamic purego_pthread_cond_broadcast pthread_cond_broadcast "libpthread.so.0" +//go:cgo_import_dynamic purego_pthread_setspecific pthread_setspecific "libpthread.so.0" diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_amd64.s b/vendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_amd64.s new file mode 100644 index 0000000000000..c9a3cc09eb318 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_amd64.s @@ -0,0 +1,104 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2022 The Ebitengine Authors + +//go:build !cgo && (darwin || linux || freebsd) + +/* +trampoline for emulating required C functions for cgo in go (see cgo.go) +(we convert cdecl calling convention to go and vice-versa) + +Since we're called from go and call into C we can cheat a bit with the calling conventions: + - in go all the registers are caller saved + - in C we have a couple of callee saved registers + +=> we can use BX, R12, R13, R14, R15 instead of the stack + +C Calling convention cdecl used here (we only need integer args): +1. arg: DI +2. arg: SI +3. arg: DX +4. arg: CX +5. arg: R8 +6. arg: R9 +We don't need floats with these functions -> AX=0 +return value will be in AX +*/ +#include "textflag.h" +#include "go_asm.h" + +// these trampolines map the gcc ABI to Go ABI and then calls into the Go equivalent functions. + +TEXT x_cgo_init_trampoline(SB), NOSPLIT, $16 + MOVQ DI, AX + MOVQ SI, BX + MOVQ ·x_cgo_init_call(SB), DX + MOVQ (DX), CX + CALL CX + RET + +TEXT x_cgo_thread_start_trampoline(SB), NOSPLIT, $8 + MOVQ DI, AX + MOVQ ·x_cgo_thread_start_call(SB), DX + MOVQ (DX), CX + CALL CX + RET + +TEXT x_cgo_setenv_trampoline(SB), NOSPLIT, $8 + MOVQ DI, AX + MOVQ ·x_cgo_setenv_call(SB), DX + MOVQ (DX), CX + CALL CX + RET + +TEXT x_cgo_unsetenv_trampoline(SB), NOSPLIT, $8 + MOVQ DI, AX + MOVQ ·x_cgo_unsetenv_call(SB), DX + MOVQ (DX), CX + CALL CX + RET + +TEXT x_cgo_notify_runtime_init_done_trampoline(SB), NOSPLIT, $0 + CALL ·x_cgo_notify_runtime_init_done(SB) + RET + +TEXT x_cgo_bindm_trampoline(SB), NOSPLIT, $0 + CALL ·x_cgo_bindm(SB) + RET + +// func setg_trampoline(setg uintptr, g uintptr) +TEXT ·setg_trampoline(SB), NOSPLIT, $0-16 + MOVQ G+8(FP), DI + MOVQ setg+0(FP), BX + XORL AX, AX + CALL BX + RET + +TEXT threadentry_trampoline(SB), NOSPLIT, $16 + MOVQ DI, AX + MOVQ ·threadentry_call(SB), DX + MOVQ (DX), CX + CALL CX + RET + +TEXT ·call5(SB), NOSPLIT, $0-56 + MOVQ fn+0(FP), BX + MOVQ a1+8(FP), DI + MOVQ a2+16(FP), SI + MOVQ a3+24(FP), DX + MOVQ a4+32(FP), CX + MOVQ a5+40(FP), R8 + + XORL AX, AX // no floats + + PUSHQ BP // save BP + MOVQ SP, BP // save SP inside BP bc BP is callee-saved + SUBQ $16, SP // allocate space for alignment + ANDQ $-16, SP // align on 16 bytes for SSE + + CALL BX + + MOVQ BP, SP // get SP back + POPQ BP // restore BP + + MOVQ AX, ret+48(FP) + RET diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_arm64.s b/vendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_arm64.s new file mode 100644 index 0000000000000..9dbdbc0139db4 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_arm64.s @@ -0,0 +1,72 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2022 The Ebitengine Authors + +//go:build !cgo && (darwin || freebsd || linux) + +#include "textflag.h" +#include "go_asm.h" + +// these trampolines map the gcc ABI to Go ABI and then calls into the Go equivalent functions. + +TEXT x_cgo_init_trampoline(SB), NOSPLIT, $0-0 + MOVD R0, 8(RSP) + MOVD R1, 16(RSP) + MOVD ·x_cgo_init_call(SB), R26 + MOVD (R26), R2 + CALL (R2) + RET + +TEXT x_cgo_thread_start_trampoline(SB), NOSPLIT, $0-0 + MOVD R0, 8(RSP) + MOVD ·x_cgo_thread_start_call(SB), R26 + MOVD (R26), R2 + CALL (R2) + RET + +TEXT x_cgo_setenv_trampoline(SB), NOSPLIT, $0-0 + MOVD R0, 8(RSP) + MOVD ·x_cgo_setenv_call(SB), R26 + MOVD (R26), R2 + CALL (R2) + RET + +TEXT x_cgo_unsetenv_trampoline(SB), NOSPLIT, $0-0 + MOVD R0, 8(RSP) + MOVD ·x_cgo_unsetenv_call(SB), R26 + MOVD (R26), R2 + CALL (R2) + RET + +TEXT x_cgo_notify_runtime_init_done_trampoline(SB), NOSPLIT, $0-0 + CALL ·x_cgo_notify_runtime_init_done(SB) + RET + +TEXT x_cgo_bindm_trampoline(SB), NOSPLIT, $0 + CALL ·x_cgo_bindm(SB) + RET + +// func setg_trampoline(setg uintptr, g uintptr) +TEXT ·setg_trampoline(SB), NOSPLIT, $0-16 + MOVD G+8(FP), R0 + MOVD setg+0(FP), R1 + CALL R1 + RET + +TEXT threadentry_trampoline(SB), NOSPLIT, $0-0 + MOVD R0, 8(RSP) + MOVD ·threadentry_call(SB), R26 + MOVD (R26), R2 + CALL (R2) + MOVD $0, R0 // TODO: get the return value from threadentry + RET + +TEXT ·call5(SB), NOSPLIT, $0-0 + MOVD fn+0(FP), R6 + MOVD a1+8(FP), R0 + MOVD a2+16(FP), R1 + MOVD a3+24(FP), R2 + MOVD a4+32(FP), R3 + MOVD a5+40(FP), R4 + CALL R6 + MOVD R0, ret+48(FP) + RET diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_stubs.s b/vendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_stubs.s new file mode 100644 index 0000000000000..a65b2012c1b40 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_stubs.s @@ -0,0 +1,90 @@ +// Code generated by 'go generate' with gen.go. DO NOT EDIT. + +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2022 The Ebitengine Authors + +//go:build !cgo && (darwin || freebsd || linux) + +#include "textflag.h" + +// these stubs are here because it is not possible to go:linkname directly the C functions on darwin arm64 + +TEXT _malloc(SB), NOSPLIT|NOFRAME, $0-0 + JMP purego_malloc(SB) + RET + +TEXT _free(SB), NOSPLIT|NOFRAME, $0-0 + JMP purego_free(SB) + RET + +TEXT _setenv(SB), NOSPLIT|NOFRAME, $0-0 + JMP purego_setenv(SB) + RET + +TEXT _unsetenv(SB), NOSPLIT|NOFRAME, $0-0 + JMP purego_unsetenv(SB) + RET + +TEXT _sigfillset(SB), NOSPLIT|NOFRAME, $0-0 + JMP purego_sigfillset(SB) + RET + +TEXT _nanosleep(SB), NOSPLIT|NOFRAME, $0-0 + JMP purego_nanosleep(SB) + RET + +TEXT _abort(SB), NOSPLIT|NOFRAME, $0-0 + JMP purego_abort(SB) + RET + +TEXT _pthread_attr_init(SB), NOSPLIT|NOFRAME, $0-0 + JMP purego_pthread_attr_init(SB) + RET + +TEXT _pthread_create(SB), NOSPLIT|NOFRAME, $0-0 + JMP purego_pthread_create(SB) + RET + +TEXT _pthread_detach(SB), NOSPLIT|NOFRAME, $0-0 + JMP purego_pthread_detach(SB) + RET + +TEXT _pthread_sigmask(SB), NOSPLIT|NOFRAME, $0-0 + JMP purego_pthread_sigmask(SB) + RET + +TEXT _pthread_self(SB), NOSPLIT|NOFRAME, $0-0 + JMP purego_pthread_self(SB) + RET + +TEXT _pthread_get_stacksize_np(SB), NOSPLIT|NOFRAME, $0-0 + JMP purego_pthread_get_stacksize_np(SB) + RET + +TEXT _pthread_attr_getstacksize(SB), NOSPLIT|NOFRAME, $0-0 + JMP purego_pthread_attr_getstacksize(SB) + RET + +TEXT _pthread_attr_setstacksize(SB), NOSPLIT|NOFRAME, $0-0 + JMP purego_pthread_attr_setstacksize(SB) + RET + +TEXT _pthread_attr_destroy(SB), NOSPLIT|NOFRAME, $0-0 + JMP purego_pthread_attr_destroy(SB) + RET + +TEXT _pthread_mutex_lock(SB), NOSPLIT|NOFRAME, $0-0 + JMP purego_pthread_mutex_lock(SB) + RET + +TEXT _pthread_mutex_unlock(SB), NOSPLIT|NOFRAME, $0-0 + JMP purego_pthread_mutex_unlock(SB) + RET + +TEXT _pthread_cond_broadcast(SB), NOSPLIT|NOFRAME, $0-0 + JMP purego_pthread_cond_broadcast(SB) + RET + +TEXT _pthread_setspecific(SB), NOSPLIT|NOFRAME, $0-0 + JMP purego_pthread_setspecific(SB) + RET diff --git a/vendor/github.com/ebitengine/purego/internal/strings/strings.go b/vendor/github.com/ebitengine/purego/internal/strings/strings.go new file mode 100644 index 0000000000000..5b0d252255477 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/internal/strings/strings.go @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2022 The Ebitengine Authors + +package strings + +import ( + "unsafe" +) + +// hasSuffix tests whether the string s ends with suffix. +func hasSuffix(s, suffix string) bool { + return len(s) >= len(suffix) && s[len(s)-len(suffix):] == suffix +} + +// CString converts a go string to *byte that can be passed to C code. +func CString(name string) *byte { + if hasSuffix(name, "\x00") { + return &(*(*[]byte)(unsafe.Pointer(&name)))[0] + } + b := make([]byte, len(name)+1) + copy(b, name) + return &b[0] +} + +// GoString copies a null-terminated char* to a Go string. +func GoString(c uintptr) string { + // We take the address and then dereference it to trick go vet from creating a possible misuse of unsafe.Pointer + ptr := *(*unsafe.Pointer)(unsafe.Pointer(&c)) + if ptr == nil { + return "" + } + var length int + for { + if *(*byte)(unsafe.Add(ptr, uintptr(length))) == '\x00' { + break + } + length++ + } + return string(unsafe.Slice((*byte)(ptr), length)) +} diff --git a/vendor/github.com/ebitengine/purego/is_ios.go b/vendor/github.com/ebitengine/purego/is_ios.go new file mode 100644 index 0000000000000..ed31da9782401 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/is_ios.go @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2022 The Ebitengine Authors + +//go:build !cgo + +package purego + +// if you are getting this error it means that you have +// CGO_ENABLED=0 while trying to build for ios. +// purego does not support this mode yet. +// the fix is to set CGO_ENABLED=1 which will require +// a C compiler. +var _ = _PUREGO_REQUIRES_CGO_ON_IOS diff --git a/vendor/github.com/ebitengine/purego/nocgo.go b/vendor/github.com/ebitengine/purego/nocgo.go new file mode 100644 index 0000000000000..5b989ea814e70 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/nocgo.go @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2022 The Ebitengine Authors + +//go:build !cgo && (darwin || freebsd || linux) + +package purego + +// if CGO_ENABLED=0 import fakecgo to setup the Cgo runtime correctly. +// This is required since some frameworks need TLS setup the C way which Go doesn't do. +// We currently don't support ios in fakecgo mode so force Cgo or fail +// +// The way that the Cgo runtime (runtime/cgo) works is by setting some variables found +// in runtime with non-null GCC compiled functions. The variables that are replaced are +// var ( +// iscgo bool // in runtime/cgo.go +// _cgo_init unsafe.Pointer // in runtime/cgo.go +// _cgo_thread_start unsafe.Pointer // in runtime/cgo.go +// _cgo_notify_runtime_init_done unsafe.Pointer // in runtime/cgo.go +// _cgo_setenv unsafe.Pointer // in runtime/env_posix.go +// _cgo_unsetenv unsafe.Pointer // in runtime/env_posix.go +// ) +// importing fakecgo will set these (using //go:linkname) with functions written +// entirely in Go (except for some assembly trampolines to change GCC ABI to Go ABI). +// Doing so makes it possible to build applications that call into C without CGO_ENABLED=1. +import _ "github.com/ebitengine/purego/internal/fakecgo" diff --git a/vendor/github.com/ebitengine/purego/struct_amd64.go b/vendor/github.com/ebitengine/purego/struct_amd64.go new file mode 100644 index 0000000000000..06a82dd8c5b4b --- /dev/null +++ b/vendor/github.com/ebitengine/purego/struct_amd64.go @@ -0,0 +1,272 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2024 The Ebitengine Authors + +package purego + +import ( + "math" + "reflect" + "unsafe" +) + +func getStruct(outType reflect.Type, syscall syscall15Args) (v reflect.Value) { + outSize := outType.Size() + switch { + case outSize == 0: + return reflect.New(outType).Elem() + case outSize <= 8: + if isAllFloats(outType) { + // 2 float32s or 1 float64s are return in the float register + return reflect.NewAt(outType, unsafe.Pointer(&struct{ a uintptr }{syscall.f1})).Elem() + } + // up to 8 bytes is returned in RAX + return reflect.NewAt(outType, unsafe.Pointer(&struct{ a uintptr }{syscall.a1})).Elem() + case outSize <= 16: + r1, r2 := syscall.a1, syscall.a2 + if isAllFloats(outType) { + r1 = syscall.f1 + r2 = syscall.f2 + } else { + // check first 8 bytes if it's floats + hasFirstFloat := false + f1 := outType.Field(0).Type + if f1.Kind() == reflect.Float64 || f1.Kind() == reflect.Float32 && outType.Field(1).Type.Kind() == reflect.Float32 { + r1 = syscall.f1 + hasFirstFloat = true + } + + // find index of the field that starts the second 8 bytes + var i int + for i = 0; i < outType.NumField(); i++ { + if outType.Field(i).Offset == 8 { + break + } + } + + // check last 8 bytes if they are floats + f1 = outType.Field(i).Type + if f1.Kind() == reflect.Float64 || f1.Kind() == reflect.Float32 && i+1 == outType.NumField() { + r2 = syscall.f1 + } else if hasFirstFloat { + // if the first field was a float then that means the second integer field + // comes from the first integer register + r2 = syscall.a1 + } + } + return reflect.NewAt(outType, unsafe.Pointer(&struct{ a, b uintptr }{r1, r2})).Elem() + default: + // create struct from the Go pointer created above + // weird pointer dereference to circumvent go vet + return reflect.NewAt(outType, *(*unsafe.Pointer)(unsafe.Pointer(&syscall.a1))).Elem() + } +} + +func isAllFloats(ty reflect.Type) bool { + for i := 0; i < ty.NumField(); i++ { + f := ty.Field(i) + switch f.Type.Kind() { + case reflect.Float64, reflect.Float32: + default: + return false + } + } + return true +} + +// https://refspecs.linuxbase.org/elf/x86_64-abi-0.99.pdf +// https://gitlab.com/x86-psABIs/x86-64-ABI +// Class determines where the 8 byte value goes. +// Higher value classes win over lower value classes +const ( + _NO_CLASS = 0b0000 + _SSE = 0b0001 + _X87 = 0b0011 // long double not used in Go + _INTEGER = 0b0111 + _MEMORY = 0b1111 +) + +func addStruct(v reflect.Value, numInts, numFloats, numStack *int, addInt, addFloat, addStack func(uintptr), keepAlive []interface{}) []interface{} { + if v.Type().Size() == 0 { + return keepAlive + } + + // if greater than 64 bytes place on stack + if v.Type().Size() > 8*8 { + placeStack(v, addStack) + return keepAlive + } + var ( + savedNumFloats = *numFloats + savedNumInts = *numInts + savedNumStack = *numStack + ) + placeOnStack := postMerger(v.Type()) || !tryPlaceRegister(v, addFloat, addInt) + if placeOnStack { + // reset any values placed in registers + *numFloats = savedNumFloats + *numInts = savedNumInts + *numStack = savedNumStack + placeStack(v, addStack) + } + return keepAlive +} + +func postMerger(t reflect.Type) bool { + // (c) If the size of the aggregate exceeds two eightbytes and the first eight- byte isn’t SSE or any other + // eightbyte isn’t SSEUP, the whole argument is passed in memory. + if t.Kind() != reflect.Struct { + return false + } + if t.Size() <= 2*8 { + return false + } + first := getFirst(t).Kind() + if first != reflect.Float32 && first != reflect.Float64 { + return false + } + return true +} + +func getFirst(t reflect.Type) reflect.Type { + first := t.Field(0).Type + if first.Kind() == reflect.Struct { + return getFirst(first) + } + return first +} + +func tryPlaceRegister(v reflect.Value, addFloat func(uintptr), addInt func(uintptr)) (ok bool) { + ok = true + var val uint64 + var shift byte // # of bits to shift + var flushed bool + class := _NO_CLASS + flushIfNeeded := func() { + if flushed { + return + } + flushed = true + if class == _SSE { + addFloat(uintptr(val)) + } else { + addInt(uintptr(val)) + } + val = 0 + shift = 0 + class = _NO_CLASS + } + var place func(v reflect.Value) + place = func(v reflect.Value) { + var numFields int + if v.Kind() == reflect.Struct { + numFields = v.Type().NumField() + } else { + numFields = v.Type().Len() + } + + for i := 0; i < numFields; i++ { + flushed = false + var f reflect.Value + if v.Kind() == reflect.Struct { + f = v.Field(i) + } else { + f = v.Index(i) + } + switch f.Kind() { + case reflect.Struct: + place(f) + case reflect.Bool: + if f.Bool() { + val |= 1 + } + shift += 8 + class |= _INTEGER + case reflect.Pointer: + ok = false + return + case reflect.Int8: + val |= uint64(f.Int()&0xFF) << shift + shift += 8 + class |= _INTEGER + case reflect.Int16: + val |= uint64(f.Int()&0xFFFF) << shift + shift += 16 + class |= _INTEGER + case reflect.Int32: + val |= uint64(f.Int()&0xFFFF_FFFF) << shift + shift += 32 + class |= _INTEGER + case reflect.Int64: + val = uint64(f.Int()) + shift = 64 + class = _INTEGER + case reflect.Uint8: + val |= f.Uint() << shift + shift += 8 + class |= _INTEGER + case reflect.Uint16: + val |= f.Uint() << shift + shift += 16 + class |= _INTEGER + case reflect.Uint32: + val |= f.Uint() << shift + shift += 32 + class |= _INTEGER + case reflect.Uint64: + val = f.Uint() + shift = 64 + class = _INTEGER + case reflect.Float32: + val |= uint64(math.Float32bits(float32(f.Float()))) << shift + shift += 32 + class |= _SSE + case reflect.Float64: + if v.Type().Size() > 16 { + ok = false + return + } + val = uint64(math.Float64bits(f.Float())) + shift = 64 + class = _SSE + case reflect.Array: + place(f) + default: + panic("purego: unsupported kind " + f.Kind().String()) + } + + if shift == 64 { + flushIfNeeded() + } else if shift > 64 { + // Should never happen, but may if we forget to reset shift after flush (or forget to flush), + // better fall apart here, than corrupt arguments. + panic("purego: tryPlaceRegisters shift > 64") + } + } + } + + place(v) + flushIfNeeded() + return ok +} + +func placeStack(v reflect.Value, addStack func(uintptr)) { + for i := 0; i < v.Type().NumField(); i++ { + f := v.Field(i) + switch f.Kind() { + case reflect.Pointer: + addStack(f.Pointer()) + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + addStack(uintptr(f.Int())) + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + addStack(uintptr(f.Uint())) + case reflect.Float32: + addStack(uintptr(math.Float32bits(float32(f.Float())))) + case reflect.Float64: + addStack(uintptr(math.Float64bits(f.Float()))) + case reflect.Struct: + placeStack(f, addStack) + default: + panic("purego: unsupported kind " + f.Kind().String()) + } + } +} diff --git a/vendor/github.com/ebitengine/purego/struct_arm64.go b/vendor/github.com/ebitengine/purego/struct_arm64.go new file mode 100644 index 0000000000000..11c36bd6e47b9 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/struct_arm64.go @@ -0,0 +1,274 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2024 The Ebitengine Authors + +package purego + +import ( + "math" + "reflect" + "unsafe" +) + +func getStruct(outType reflect.Type, syscall syscall15Args) (v reflect.Value) { + outSize := outType.Size() + switch { + case outSize == 0: + return reflect.New(outType).Elem() + case outSize <= 8: + r1 := syscall.a1 + if isAllFloats, numFields := isAllSameFloat(outType); isAllFloats { + r1 = syscall.f1 + if numFields == 2 { + r1 = syscall.f2<<32 | syscall.f1 + } + } + return reflect.NewAt(outType, unsafe.Pointer(&struct{ a uintptr }{r1})).Elem() + case outSize <= 16: + r1, r2 := syscall.a1, syscall.a2 + if isAllFloats, numFields := isAllSameFloat(outType); isAllFloats { + switch numFields { + case 4: + r1 = syscall.f2<<32 | syscall.f1 + r2 = syscall.f4<<32 | syscall.f3 + case 3: + r1 = syscall.f2<<32 | syscall.f1 + r2 = syscall.f3 + case 2: + r1 = syscall.f1 + r2 = syscall.f2 + default: + panic("unreachable") + } + } + return reflect.NewAt(outType, unsafe.Pointer(&struct{ a, b uintptr }{r1, r2})).Elem() + default: + if isAllFloats, numFields := isAllSameFloat(outType); isAllFloats && numFields <= 4 { + switch numFields { + case 4: + return reflect.NewAt(outType, unsafe.Pointer(&struct{ a, b, c, d uintptr }{syscall.f1, syscall.f2, syscall.f3, syscall.f4})).Elem() + case 3: + return reflect.NewAt(outType, unsafe.Pointer(&struct{ a, b, c uintptr }{syscall.f1, syscall.f2, syscall.f3})).Elem() + default: + panic("unreachable") + } + } + // create struct from the Go pointer created in arm64_r8 + // weird pointer dereference to circumvent go vet + return reflect.NewAt(outType, *(*unsafe.Pointer)(unsafe.Pointer(&syscall.arm64_r8))).Elem() + } +} + +// https://github.com/ARM-software/abi-aa/blob/main/sysvabi64/sysvabi64.rst +const ( + _NO_CLASS = 0b00 + _FLOAT = 0b01 + _INT = 0b11 +) + +func addStruct(v reflect.Value, numInts, numFloats, numStack *int, addInt, addFloat, addStack func(uintptr), keepAlive []interface{}) []interface{} { + if v.Type().Size() == 0 { + return keepAlive + } + + if hva, hfa, size := isHVA(v.Type()), isHFA(v.Type()), v.Type().Size(); hva || hfa || size <= 16 { + // if this doesn't fit entirely in registers then + // each element goes onto the stack + if hfa && *numFloats+v.NumField() > numOfFloats { + *numFloats = numOfFloats + } else if hva && *numInts+v.NumField() > numOfIntegerRegisters() { + *numInts = numOfIntegerRegisters() + } + + placeRegisters(v, addFloat, addInt) + } else { + keepAlive = placeStack(v, keepAlive, addInt) + } + return keepAlive // the struct was allocated so don't panic +} + +func placeRegisters(v reflect.Value, addFloat func(uintptr), addInt func(uintptr)) { + var val uint64 + var shift byte + var flushed bool + class := _NO_CLASS + var place func(v reflect.Value) + place = func(v reflect.Value) { + var numFields int + if v.Kind() == reflect.Struct { + numFields = v.Type().NumField() + } else { + numFields = v.Type().Len() + } + for k := 0; k < numFields; k++ { + flushed = false + var f reflect.Value + if v.Kind() == reflect.Struct { + f = v.Field(k) + } else { + f = v.Index(k) + } + if shift >= 64 { + shift = 0 + flushed = true + if class == _FLOAT { + addFloat(uintptr(val)) + } else { + addInt(uintptr(val)) + } + } + switch f.Type().Kind() { + case reflect.Struct: + place(f) + case reflect.Bool: + if f.Bool() { + val |= 1 + } + shift += 8 + class |= _INT + case reflect.Uint8: + val |= f.Uint() << shift + shift += 8 + class |= _INT + case reflect.Uint16: + val |= f.Uint() << shift + shift += 16 + class |= _INT + case reflect.Uint32: + val |= f.Uint() << shift + shift += 32 + class |= _INT + case reflect.Uint64: + addInt(uintptr(f.Uint())) + shift = 0 + flushed = true + case reflect.Int8: + val |= uint64(f.Int()&0xFF) << shift + shift += 8 + class |= _INT + case reflect.Int16: + val |= uint64(f.Int()&0xFFFF) << shift + shift += 16 + class |= _INT + case reflect.Int32: + val |= uint64(f.Int()&0xFFFF_FFFF) << shift + shift += 32 + class |= _INT + case reflect.Int64: + addInt(uintptr(f.Int())) + shift = 0 + flushed = true + case reflect.Float32: + if class == _FLOAT { + addFloat(uintptr(val)) + val = 0 + shift = 0 + } + val |= uint64(math.Float32bits(float32(f.Float()))) << shift + shift += 32 + class |= _FLOAT + case reflect.Float64: + addFloat(uintptr(math.Float64bits(float64(f.Float())))) + shift = 0 + flushed = true + case reflect.Array: + place(f) + default: + panic("purego: unsupported kind " + f.Kind().String()) + } + } + } + place(v) + if !flushed { + if class == _FLOAT { + addFloat(uintptr(val)) + } else { + addInt(uintptr(val)) + } + } +} + +func placeStack(v reflect.Value, keepAlive []interface{}, addInt func(uintptr)) []interface{} { + // Struct is too big to be placed in registers. + // Copy to heap and place the pointer in register + ptrStruct := reflect.New(v.Type()) + ptrStruct.Elem().Set(v) + ptr := ptrStruct.Elem().Addr().UnsafePointer() + keepAlive = append(keepAlive, ptr) + addInt(uintptr(ptr)) + return keepAlive +} + +// isHFA reports a Homogeneous Floating-point Aggregate (HFA) which is a Fundamental Data Type that is a +// Floating-Point type and at most four uniquely addressable members (5.9.5.1 in [Arm64 Calling Convention]). +// This type of struct will be placed more compactly than the individual fields. +// +// [Arm64 Calling Convention]: https://github.com/ARM-software/abi-aa/blob/main/sysvabi64/sysvabi64.rst +func isHFA(t reflect.Type) bool { + // round up struct size to nearest 8 see section B.4 + structSize := roundUpTo8(t.Size()) + if structSize == 0 || t.NumField() > 4 { + return false + } + first := t.Field(0) + switch first.Type.Kind() { + case reflect.Float32, reflect.Float64: + firstKind := first.Type.Kind() + for i := 0; i < t.NumField(); i++ { + if t.Field(i).Type.Kind() != firstKind { + return false + } + } + return true + case reflect.Array: + switch first.Type.Elem().Kind() { + case reflect.Float32, reflect.Float64: + return true + default: + return false + } + case reflect.Struct: + for i := 0; i < first.Type.NumField(); i++ { + if !isHFA(first.Type) { + return false + } + } + return true + default: + return false + } +} + +// isHVA reports a Homogeneous Aggregate with a Fundamental Data Type that is a Short-Vector type +// and at most four uniquely addressable members (5.9.5.2 in [Arm64 Calling Convention]). +// A short vector is a machine type that is composed of repeated instances of one fundamental integral or +// floating-point type. It may be 8 or 16 bytes in total size (5.4 in [Arm64 Calling Convention]). +// This type of struct will be placed more compactly than the individual fields. +// +// [Arm64 Calling Convention]: https://github.com/ARM-software/abi-aa/blob/main/sysvabi64/sysvabi64.rst +func isHVA(t reflect.Type) bool { + // round up struct size to nearest 8 see section B.4 + structSize := roundUpTo8(t.Size()) + if structSize == 0 || (structSize != 8 && structSize != 16) { + return false + } + first := t.Field(0) + switch first.Type.Kind() { + case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Int8, reflect.Int16, reflect.Int32: + firstKind := first.Type.Kind() + for i := 0; i < t.NumField(); i++ { + if t.Field(i).Type.Kind() != firstKind { + return false + } + } + return true + case reflect.Array: + switch first.Type.Elem().Kind() { + case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Int8, reflect.Int16, reflect.Int32: + return true + default: + return false + } + default: + return false + } +} diff --git a/vendor/github.com/ebitengine/purego/struct_other.go b/vendor/github.com/ebitengine/purego/struct_other.go new file mode 100644 index 0000000000000..9d42adac898e5 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/struct_other.go @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2024 The Ebitengine Authors + +//go:build !amd64 && !arm64 + +package purego + +import "reflect" + +func addStruct(v reflect.Value, numInts, numFloats, numStack *int, addInt, addFloat, addStack func(uintptr), keepAlive []interface{}) []interface{} { + panic("purego: struct arguments are not supported") +} + +func getStruct(outType reflect.Type, syscall syscall15Args) (v reflect.Value) { + panic("purego: struct returns are not supported") +} diff --git a/vendor/github.com/ebitengine/purego/sys_amd64.s b/vendor/github.com/ebitengine/purego/sys_amd64.s new file mode 100644 index 0000000000000..cabde1a584e98 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/sys_amd64.s @@ -0,0 +1,164 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2022 The Ebitengine Authors + +//go:build darwin || freebsd || linux + +#include "textflag.h" +#include "abi_amd64.h" +#include "go_asm.h" +#include "funcdata.h" + +#define STACK_SIZE 80 +#define PTR_ADDRESS (STACK_SIZE - 8) + +// syscall15X calls a function in libc on behalf of the syscall package. +// syscall15X takes a pointer to a struct like: +// struct { +// fn uintptr +// a1 uintptr +// a2 uintptr +// a3 uintptr +// a4 uintptr +// a5 uintptr +// a6 uintptr +// a7 uintptr +// a8 uintptr +// a9 uintptr +// a10 uintptr +// a11 uintptr +// a12 uintptr +// a13 uintptr +// a14 uintptr +// a15 uintptr +// r1 uintptr +// r2 uintptr +// err uintptr +// } +// syscall15X must be called on the g0 stack with the +// C calling convention (use libcCall). +GLOBL ·syscall15XABI0(SB), NOPTR|RODATA, $8 +DATA ·syscall15XABI0(SB)/8, $syscall15X(SB) +TEXT syscall15X(SB), NOSPLIT|NOFRAME, $0 + PUSHQ BP + MOVQ SP, BP + SUBQ $STACK_SIZE, SP + MOVQ DI, PTR_ADDRESS(BP) // save the pointer + MOVQ DI, R11 + + MOVQ syscall15Args_f1(R11), X0 // f1 + MOVQ syscall15Args_f2(R11), X1 // f2 + MOVQ syscall15Args_f3(R11), X2 // f3 + MOVQ syscall15Args_f4(R11), X3 // f4 + MOVQ syscall15Args_f5(R11), X4 // f5 + MOVQ syscall15Args_f6(R11), X5 // f6 + MOVQ syscall15Args_f7(R11), X6 // f7 + MOVQ syscall15Args_f8(R11), X7 // f8 + + MOVQ syscall15Args_a1(R11), DI // a1 + MOVQ syscall15Args_a2(R11), SI // a2 + MOVQ syscall15Args_a3(R11), DX // a3 + MOVQ syscall15Args_a4(R11), CX // a4 + MOVQ syscall15Args_a5(R11), R8 // a5 + MOVQ syscall15Args_a6(R11), R9 // a6 + + // push the remaining paramters onto the stack + MOVQ syscall15Args_a7(R11), R12 + MOVQ R12, 0(SP) // push a7 + MOVQ syscall15Args_a8(R11), R12 + MOVQ R12, 8(SP) // push a8 + MOVQ syscall15Args_a9(R11), R12 + MOVQ R12, 16(SP) // push a9 + MOVQ syscall15Args_a10(R11), R12 + MOVQ R12, 24(SP) // push a10 + MOVQ syscall15Args_a11(R11), R12 + MOVQ R12, 32(SP) // push a11 + MOVQ syscall15Args_a12(R11), R12 + MOVQ R12, 40(SP) // push a12 + MOVQ syscall15Args_a13(R11), R12 + MOVQ R12, 48(SP) // push a13 + MOVQ syscall15Args_a14(R11), R12 + MOVQ R12, 56(SP) // push a14 + MOVQ syscall15Args_a15(R11), R12 + MOVQ R12, 64(SP) // push a15 + XORL AX, AX // vararg: say "no float args" + + MOVQ syscall15Args_fn(R11), R10 // fn + CALL R10 + + MOVQ PTR_ADDRESS(BP), DI // get the pointer back + MOVQ AX, syscall15Args_a1(DI) // r1 + MOVQ DX, syscall15Args_a2(DI) // r3 + MOVQ X0, syscall15Args_f1(DI) // f1 + MOVQ X1, syscall15Args_f2(DI) // f2 + + XORL AX, AX // no error (it's ignored anyway) + ADDQ $STACK_SIZE, SP + MOVQ BP, SP + POPQ BP + RET + +TEXT callbackasm1(SB), NOSPLIT|NOFRAME, $0 + MOVQ 0(SP), AX // save the return address to calculate the cb index + MOVQ 8(SP), R10 // get the return SP so that we can align register args with stack args + ADDQ $8, SP // remove return address from stack, we are not returning to callbackasm, but to its caller. + + // make space for first six int and 8 float arguments below the frame + ADJSP $14*8, SP + MOVSD X0, (1*8)(SP) + MOVSD X1, (2*8)(SP) + MOVSD X2, (3*8)(SP) + MOVSD X3, (4*8)(SP) + MOVSD X4, (5*8)(SP) + MOVSD X5, (6*8)(SP) + MOVSD X6, (7*8)(SP) + MOVSD X7, (8*8)(SP) + MOVQ DI, (9*8)(SP) + MOVQ SI, (10*8)(SP) + MOVQ DX, (11*8)(SP) + MOVQ CX, (12*8)(SP) + MOVQ R8, (13*8)(SP) + MOVQ R9, (14*8)(SP) + LEAQ 8(SP), R8 // R8 = address of args vector + + PUSHQ R10 // push the stack pointer below registers + + // Switch from the host ABI to the Go ABI. + PUSH_REGS_HOST_TO_ABI0() + + // determine index into runtime·cbs table + MOVQ $callbackasm(SB), DX + SUBQ DX, AX + MOVQ $0, DX + MOVQ $5, CX // divide by 5 because each call instruction in ·callbacks is 5 bytes long + DIVL CX + SUBQ $1, AX // subtract 1 because return PC is to the next slot + + // Create a struct callbackArgs on our stack to be passed as + // the "frame" to cgocallback and on to callbackWrap. + // $24 to make enough room for the arguments to runtime.cgocallback + SUBQ $(24+callbackArgs__size), SP + MOVQ AX, (24+callbackArgs_index)(SP) // callback index + MOVQ R8, (24+callbackArgs_args)(SP) // address of args vector + MOVQ $0, (24+callbackArgs_result)(SP) // result + LEAQ 24(SP), AX // take the address of callbackArgs + + // Call cgocallback, which will call callbackWrap(frame). + MOVQ ·callbackWrap_call(SB), DI // Get the ABIInternal function pointer + MOVQ (DI), DI // without by using a closure. + MOVQ AX, SI // frame (address of callbackArgs) + MOVQ $0, CX // context + + CALL crosscall2(SB) // runtime.cgocallback(fn, frame, ctxt uintptr) + + // Get callback result. + MOVQ (24+callbackArgs_result)(SP), AX + ADDQ $(24+callbackArgs__size), SP // remove callbackArgs struct + + POP_REGS_HOST_TO_ABI0() + + POPQ R10 // get the SP back + ADJSP $-14*8, SP // remove arguments + + MOVQ R10, 0(SP) + + RET diff --git a/vendor/github.com/ebitengine/purego/sys_arm64.s b/vendor/github.com/ebitengine/purego/sys_arm64.s new file mode 100644 index 0000000000000..a68fdb99ba7aa --- /dev/null +++ b/vendor/github.com/ebitengine/purego/sys_arm64.s @@ -0,0 +1,92 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2022 The Ebitengine Authors + +//go:build darwin || freebsd || linux || windows + +#include "textflag.h" +#include "go_asm.h" +#include "funcdata.h" + +#define STACK_SIZE 64 +#define PTR_ADDRESS (STACK_SIZE - 8) + +// syscall15X calls a function in libc on behalf of the syscall package. +// syscall15X takes a pointer to a struct like: +// struct { +// fn uintptr +// a1 uintptr +// a2 uintptr +// a3 uintptr +// a4 uintptr +// a5 uintptr +// a6 uintptr +// a7 uintptr +// a8 uintptr +// a9 uintptr +// a10 uintptr +// a11 uintptr +// a12 uintptr +// a13 uintptr +// a14 uintptr +// a15 uintptr +// r1 uintptr +// r2 uintptr +// err uintptr +// } +// syscall15X must be called on the g0 stack with the +// C calling convention (use libcCall). +GLOBL ·syscall15XABI0(SB), NOPTR|RODATA, $8 +DATA ·syscall15XABI0(SB)/8, $syscall15X(SB) +TEXT syscall15X(SB), NOSPLIT, $0 + SUB $STACK_SIZE, RSP // push structure pointer + MOVD R0, PTR_ADDRESS(RSP) + MOVD R0, R9 + + FMOVD syscall15Args_f1(R9), F0 // f1 + FMOVD syscall15Args_f2(R9), F1 // f2 + FMOVD syscall15Args_f3(R9), F2 // f3 + FMOVD syscall15Args_f4(R9), F3 // f4 + FMOVD syscall15Args_f5(R9), F4 // f5 + FMOVD syscall15Args_f6(R9), F5 // f6 + FMOVD syscall15Args_f7(R9), F6 // f7 + FMOVD syscall15Args_f8(R9), F7 // f8 + + MOVD syscall15Args_a1(R9), R0 // a1 + MOVD syscall15Args_a2(R9), R1 // a2 + MOVD syscall15Args_a3(R9), R2 // a3 + MOVD syscall15Args_a4(R9), R3 // a4 + MOVD syscall15Args_a5(R9), R4 // a5 + MOVD syscall15Args_a6(R9), R5 // a6 + MOVD syscall15Args_a7(R9), R6 // a7 + MOVD syscall15Args_a8(R9), R7 // a8 + MOVD syscall15Args_arm64_r8(R9), R8 // r8 + + MOVD syscall15Args_a9(R9), R10 + MOVD R10, 0(RSP) // push a9 onto stack + MOVD syscall15Args_a10(R9), R10 + MOVD R10, 8(RSP) // push a10 onto stack + MOVD syscall15Args_a11(R9), R10 + MOVD R10, 16(RSP) // push a11 onto stack + MOVD syscall15Args_a12(R9), R10 + MOVD R10, 24(RSP) // push a12 onto stack + MOVD syscall15Args_a13(R9), R10 + MOVD R10, 32(RSP) // push a13 onto stack + MOVD syscall15Args_a14(R9), R10 + MOVD R10, 40(RSP) // push a14 onto stack + MOVD syscall15Args_a15(R9), R10 + MOVD R10, 48(RSP) // push a15 onto stack + + MOVD syscall15Args_fn(R9), R10 // fn + BL (R10) + + MOVD PTR_ADDRESS(RSP), R2 // pop structure pointer + ADD $STACK_SIZE, RSP + + MOVD R0, syscall15Args_a1(R2) // save r1 + MOVD R1, syscall15Args_a2(R2) // save r3 + FMOVD F0, syscall15Args_f1(R2) // save f0 + FMOVD F1, syscall15Args_f2(R2) // save f1 + FMOVD F2, syscall15Args_f3(R2) // save f2 + FMOVD F3, syscall15Args_f4(R2) // save f3 + + RET diff --git a/vendor/github.com/ebitengine/purego/sys_unix_arm64.s b/vendor/github.com/ebitengine/purego/sys_unix_arm64.s new file mode 100644 index 0000000000000..6da06b4d18826 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/sys_unix_arm64.s @@ -0,0 +1,70 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2023 The Ebitengine Authors + +//go:build darwin || freebsd || linux + +#include "textflag.h" +#include "go_asm.h" +#include "funcdata.h" +#include "abi_arm64.h" + +TEXT callbackasm1(SB), NOSPLIT|NOFRAME, $0 + NO_LOCAL_POINTERS + + // On entry, the trampoline in zcallback_darwin_arm64.s left + // the callback index in R12 (which is volatile in the C ABI). + + // Save callback register arguments R0-R7 and F0-F7. + // We do this at the top of the frame so they're contiguous with stack arguments. + SUB $(16*8), RSP, R14 + FSTPD (F0, F1), (0*8)(R14) + FSTPD (F2, F3), (2*8)(R14) + FSTPD (F4, F5), (4*8)(R14) + FSTPD (F6, F7), (6*8)(R14) + STP (R0, R1), (8*8)(R14) + STP (R2, R3), (10*8)(R14) + STP (R4, R5), (12*8)(R14) + STP (R6, R7), (14*8)(R14) + + // Adjust SP by frame size. + SUB $(26*8), RSP + + // It is important to save R27 because the go assembler + // uses it for move instructions for a variable. + // This line: + // MOVD ·callbackWrap_call(SB), R0 + // Creates the instructions: + // ADRP 14335(PC), R27 + // MOVD 388(27), R0 + // R27 is a callee saved register so we are responsible + // for ensuring its value doesn't change. So save it and + // restore it at the end of this function. + // R30 is the link register. crosscall2 doesn't save it + // so it's saved here. + STP (R27, R30), 0(RSP) + + // Create a struct callbackArgs on our stack. + MOVD $(callbackArgs__size)(RSP), R13 + MOVD R12, callbackArgs_index(R13) // callback index + MOVD R14, callbackArgs_args(R13) // address of args vector + MOVD ZR, callbackArgs_result(R13) // result + + // Move parameters into registers + // Get the ABIInternal function pointer + // without by using a closure. + MOVD ·callbackWrap_call(SB), R0 + MOVD (R0), R0 // fn unsafe.Pointer + MOVD R13, R1 // frame (&callbackArgs{...}) + MOVD $0, R3 // ctxt uintptr + + BL crosscall2(SB) + + // Get callback result. + MOVD $(callbackArgs__size)(RSP), R13 + MOVD callbackArgs_result(R13), R0 + + // Restore LR and R27 + LDP 0(RSP), (R27, R30) + ADD $(26*8), RSP + + RET diff --git a/vendor/github.com/ebitengine/purego/syscall.go b/vendor/github.com/ebitengine/purego/syscall.go new file mode 100644 index 0000000000000..c30688dda130e --- /dev/null +++ b/vendor/github.com/ebitengine/purego/syscall.go @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2022 The Ebitengine Authors + +//go:build darwin || freebsd || linux || windows + +package purego + +// CDecl marks a function as being called using the __cdecl calling convention as defined in +// the [MSDocs] when passed to NewCallback. It must be the first argument to the function. +// This is only useful on 386 Windows, but it is safe to use on other platforms. +// +// [MSDocs]: https://learn.microsoft.com/en-us/cpp/cpp/cdecl?view=msvc-170 +type CDecl struct{} + +const ( + maxArgs = 15 + numOfFloats = 8 // arm64 and amd64 both have 8 float registers +) + +type syscall15Args struct { + fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15 uintptr + f1, f2, f3, f4, f5, f6, f7, f8 uintptr + arm64_r8 uintptr +} + +// SyscallN takes fn, a C function pointer and a list of arguments as uintptr. +// There is an internal maximum number of arguments that SyscallN can take. It panics +// when the maximum is exceeded. It returns the result and the libc error code if there is one. +// +// NOTE: SyscallN does not properly call functions that have both integer and float parameters. +// See discussion comment https://github.com/ebiten/purego/pull/1#issuecomment-1128057607 +// for an explanation of why that is. +// +// On amd64, if there are more than 8 floats the 9th and so on will be placed incorrectly on the +// stack. +// +// The pragma go:nosplit is not needed at this function declaration because it uses go:uintptrescapes +// which forces all the objects that the uintptrs point to onto the heap where a stack split won't affect +// their memory location. +// +//go:uintptrescapes +func SyscallN(fn uintptr, args ...uintptr) (r1, r2, err uintptr) { + if fn == 0 { + panic("purego: fn is nil") + } + if len(args) > maxArgs { + panic("purego: too many arguments to SyscallN") + } + // add padding so there is no out-of-bounds slicing + var tmp [maxArgs]uintptr + copy(tmp[:], args) + return syscall_syscall15X(fn, tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5], tmp[6], tmp[7], tmp[8], tmp[9], tmp[10], tmp[11], tmp[12], tmp[13], tmp[14]) +} diff --git a/vendor/github.com/ebitengine/purego/syscall_cgo_linux.go b/vendor/github.com/ebitengine/purego/syscall_cgo_linux.go new file mode 100644 index 0000000000000..36ee14e3b732a --- /dev/null +++ b/vendor/github.com/ebitengine/purego/syscall_cgo_linux.go @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2022 The Ebitengine Authors + +//go:build cgo && !(amd64 || arm64) + +package purego + +import ( + "github.com/ebitengine/purego/internal/cgo" +) + +var syscall15XABI0 = uintptr(cgo.Syscall15XABI0) + +//go:nosplit +func syscall_syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15 uintptr) (r1, r2, err uintptr) { + return cgo.Syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) +} + +func NewCallback(_ interface{}) uintptr { + panic("purego: NewCallback on Linux is only supported on amd64/arm64") +} diff --git a/vendor/github.com/ebitengine/purego/syscall_sysv.go b/vendor/github.com/ebitengine/purego/syscall_sysv.go new file mode 100644 index 0000000000000..cce171c8f609a --- /dev/null +++ b/vendor/github.com/ebitengine/purego/syscall_sysv.go @@ -0,0 +1,223 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2022 The Ebitengine Authors + +//go:build darwin || freebsd || (linux && (amd64 || arm64)) + +package purego + +import ( + "reflect" + "runtime" + "sync" + "unsafe" +) + +var syscall15XABI0 uintptr + +//go:nosplit +func syscall_syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15 uintptr) (r1, r2, err uintptr) { + args := syscall15Args{ + fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, + a1, a2, a3, a4, a5, a6, a7, a8, + 0, + } + runtime_cgocall(syscall15XABI0, unsafe.Pointer(&args)) + return args.a1, args.a2, 0 +} + +// NewCallback converts a Go function to a function pointer conforming to the C calling convention. +// This is useful when interoperating with C code requiring callbacks. The argument is expected to be a +// function with zero or one uintptr-sized result. The function must not have arguments with size larger than the size +// of uintptr. Only a limited number of callbacks may be created in a single Go process, and any memory allocated +// for these callbacks is never released. At least 2000 callbacks can always be created. Although this function +// provides similar functionality to windows.NewCallback it is distinct. +func NewCallback(fn interface{}) uintptr { + ty := reflect.TypeOf(fn) + for i := 0; i < ty.NumIn(); i++ { + in := ty.In(i) + if !in.AssignableTo(reflect.TypeOf(CDecl{})) { + continue + } + if i != 0 { + panic("purego: CDecl must be the first argument") + } + } + return compileCallback(fn) +} + +// maxCb is the maximum number of callbacks +// only increase this if you have added more to the callbackasm function +const maxCB = 2000 + +var cbs struct { + lock sync.Mutex + numFn int // the number of functions currently in cbs.funcs + funcs [maxCB]reflect.Value // the saved callbacks +} + +type callbackArgs struct { + index uintptr + // args points to the argument block. + // + // The structure of the arguments goes + // float registers followed by the + // integer registers followed by the stack. + // + // This variable is treated as a continuous + // block of memory containing all of the arguments + // for this callback. + args unsafe.Pointer + // Below are out-args from callbackWrap + result uintptr +} + +func compileCallback(fn interface{}) uintptr { + val := reflect.ValueOf(fn) + if val.Kind() != reflect.Func { + panic("purego: the type must be a function but was not") + } + if val.IsNil() { + panic("purego: function must not be nil") + } + ty := val.Type() + for i := 0; i < ty.NumIn(); i++ { + in := ty.In(i) + switch in.Kind() { + case reflect.Struct: + if i == 0 && in.AssignableTo(reflect.TypeOf(CDecl{})) { + continue + } + fallthrough + case reflect.Interface, reflect.Func, reflect.Slice, + reflect.Chan, reflect.Complex64, reflect.Complex128, + reflect.String, reflect.Map, reflect.Invalid: + panic("purego: unsupported argument type: " + in.Kind().String()) + } + } +output: + switch { + case ty.NumOut() == 1: + switch ty.Out(0).Kind() { + case reflect.Pointer, reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, + reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr, + reflect.Bool, reflect.UnsafePointer: + break output + } + panic("purego: unsupported return type: " + ty.String()) + case ty.NumOut() > 1: + panic("purego: callbacks can only have one return") + } + cbs.lock.Lock() + defer cbs.lock.Unlock() + if cbs.numFn >= maxCB { + panic("purego: the maximum number of callbacks has been reached") + } + cbs.funcs[cbs.numFn] = val + cbs.numFn++ + return callbackasmAddr(cbs.numFn - 1) +} + +const ptrSize = unsafe.Sizeof((*int)(nil)) + +const callbackMaxFrame = 64 * ptrSize + +// callbackasm is implemented in zcallback_GOOS_GOARCH.s +// +//go:linkname __callbackasm callbackasm +var __callbackasm byte +var callbackasmABI0 = uintptr(unsafe.Pointer(&__callbackasm)) + +// callbackWrap_call allows the calling of the ABIInternal wrapper +// which is required for runtime.cgocallback without the +// tag which is only allowed in the runtime. +// This closure is used inside sys_darwin_GOARCH.s +var callbackWrap_call = callbackWrap + +// callbackWrap is called by assembly code which determines which Go function to call. +// This function takes the arguments and passes them to the Go function and returns the result. +func callbackWrap(a *callbackArgs) { + cbs.lock.Lock() + fn := cbs.funcs[a.index] + cbs.lock.Unlock() + fnType := fn.Type() + args := make([]reflect.Value, fnType.NumIn()) + frame := (*[callbackMaxFrame]uintptr)(a.args) + var floatsN int // floatsN represents the number of float arguments processed + var intsN int // intsN represents the number of integer arguments processed + // stack points to the index into frame of the current stack element. + // The stack begins after the float and integer registers. + stack := numOfIntegerRegisters() + numOfFloats + for i := range args { + var pos int + switch fnType.In(i).Kind() { + case reflect.Float32, reflect.Float64: + if floatsN >= numOfFloats { + pos = stack + stack++ + } else { + pos = floatsN + } + floatsN++ + case reflect.Struct: + // This is the CDecl field + args[i] = reflect.Zero(fnType.In(i)) + continue + default: + + if intsN >= numOfIntegerRegisters() { + pos = stack + stack++ + } else { + // the integers begin after the floats in frame + pos = intsN + numOfFloats + } + intsN++ + } + args[i] = reflect.NewAt(fnType.In(i), unsafe.Pointer(&frame[pos])).Elem() + } + ret := fn.Call(args) + if len(ret) > 0 { + switch k := ret[0].Kind(); k { + case reflect.Uint, reflect.Uint64, reflect.Uint32, reflect.Uint16, reflect.Uint8, reflect.Uintptr: + a.result = uintptr(ret[0].Uint()) + case reflect.Int, reflect.Int64, reflect.Int32, reflect.Int16, reflect.Int8: + a.result = uintptr(ret[0].Int()) + case reflect.Bool: + if ret[0].Bool() { + a.result = 1 + } else { + a.result = 0 + } + case reflect.Pointer: + a.result = ret[0].Pointer() + case reflect.UnsafePointer: + a.result = ret[0].Pointer() + default: + panic("purego: unsupported kind: " + k.String()) + } + } +} + +// callbackasmAddr returns address of runtime.callbackasm +// function adjusted by i. +// On x86 and amd64, runtime.callbackasm is a series of CALL instructions, +// and we want callback to arrive at +// correspondent call instruction instead of start of +// runtime.callbackasm. +// On ARM, runtime.callbackasm is a series of mov and branch instructions. +// R12 is loaded with the callback index. Each entry is two instructions, +// hence 8 bytes. +func callbackasmAddr(i int) uintptr { + var entrySize int + switch runtime.GOARCH { + default: + panic("purego: unsupported architecture") + case "386", "amd64": + entrySize = 5 + case "arm", "arm64": + // On ARM and ARM64, each entry is a MOV instruction + // followed by a branch instruction + entrySize = 8 + } + return callbackasmABI0 + uintptr(i*entrySize) +} diff --git a/vendor/github.com/ebitengine/purego/syscall_windows.go b/vendor/github.com/ebitengine/purego/syscall_windows.go new file mode 100644 index 0000000000000..5fbfcabfdc930 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/syscall_windows.go @@ -0,0 +1,46 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2022 The Ebitengine Authors + +package purego + +import ( + "reflect" + "syscall" +) + +var syscall15XABI0 uintptr + +func syscall_syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15 uintptr) (r1, r2, err uintptr) { + r1, r2, errno := syscall.Syscall15(fn, 15, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) + return r1, r2, uintptr(errno) +} + +// NewCallback converts a Go function to a function pointer conforming to the stdcall calling convention. +// This is useful when interoperating with Windows code requiring callbacks. The argument is expected to be a +// function with one uintptr-sized result. The function must not have arguments with size larger than the +// size of uintptr. Only a limited number of callbacks may be created in a single Go process, and any memory +// allocated for these callbacks is never released. Between NewCallback and NewCallbackCDecl, at least 1024 +// callbacks can always be created. Although this function is similiar to the darwin version it may act +// differently. +func NewCallback(fn interface{}) uintptr { + isCDecl := false + ty := reflect.TypeOf(fn) + for i := 0; i < ty.NumIn(); i++ { + in := ty.In(i) + if !in.AssignableTo(reflect.TypeOf(CDecl{})) { + continue + } + if i != 0 { + panic("purego: CDecl must be the first argument") + } + isCDecl = true + } + if isCDecl { + return syscall.NewCallbackCDecl(fn) + } + return syscall.NewCallback(fn) +} + +func loadSymbol(handle uintptr, name string) (uintptr, error) { + return syscall.GetProcAddress(syscall.Handle(handle), name) +} diff --git a/vendor/github.com/ebitengine/purego/zcallback_amd64.s b/vendor/github.com/ebitengine/purego/zcallback_amd64.s new file mode 100644 index 0000000000000..6a778bfcad177 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/zcallback_amd64.s @@ -0,0 +1,2014 @@ +// Code generated by wincallback.go using 'go generate'. DO NOT EDIT. + +//go:build darwin || freebsd || linux + +// runtime·callbackasm is called by external code to +// execute Go implemented callback function. It is not +// called from the start, instead runtime·compilecallback +// always returns address into runtime·callbackasm offset +// appropriately so different callbacks start with different +// CALL instruction in runtime·callbackasm. This determines +// which Go callback function is executed later on. +#include "textflag.h" + +TEXT callbackasm(SB), NOSPLIT|NOFRAME, $0 + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) + CALL callbackasm1(SB) diff --git a/vendor/github.com/ebitengine/purego/zcallback_arm64.s b/vendor/github.com/ebitengine/purego/zcallback_arm64.s new file mode 100644 index 0000000000000..c079b8038e377 --- /dev/null +++ b/vendor/github.com/ebitengine/purego/zcallback_arm64.s @@ -0,0 +1,4014 @@ +// Code generated by wincallback.go using 'go generate'. DO NOT EDIT. + +//go:build darwin || freebsd || linux + +// External code calls into callbackasm at an offset corresponding +// to the callback index. Callbackasm is a table of MOV and B instructions. +// The MOV instruction loads R12 with the callback index, and the +// B instruction branches to callbackasm1. +// callbackasm1 takes the callback index from R12 and +// indexes into an array that stores information about each callback. +// It then calls the Go implementation for that callback. +#include "textflag.h" + +TEXT callbackasm(SB), NOSPLIT|NOFRAME, $0 + MOVD $0, R12 + B callbackasm1(SB) + MOVD $1, R12 + B callbackasm1(SB) + MOVD $2, R12 + B callbackasm1(SB) + MOVD $3, R12 + B callbackasm1(SB) + MOVD $4, R12 + B callbackasm1(SB) + MOVD $5, R12 + B callbackasm1(SB) + MOVD $6, R12 + B callbackasm1(SB) + MOVD $7, R12 + B callbackasm1(SB) + MOVD $8, R12 + B callbackasm1(SB) + MOVD $9, R12 + B callbackasm1(SB) + MOVD $10, R12 + B callbackasm1(SB) + MOVD $11, R12 + B callbackasm1(SB) + MOVD $12, R12 + B callbackasm1(SB) + MOVD $13, R12 + B callbackasm1(SB) + MOVD $14, R12 + B callbackasm1(SB) + MOVD $15, R12 + B callbackasm1(SB) + MOVD $16, R12 + B callbackasm1(SB) + MOVD $17, R12 + B callbackasm1(SB) + MOVD $18, R12 + B callbackasm1(SB) + MOVD $19, R12 + B callbackasm1(SB) + MOVD $20, R12 + B callbackasm1(SB) + MOVD $21, R12 + B callbackasm1(SB) + MOVD $22, R12 + B callbackasm1(SB) + MOVD $23, R12 + B callbackasm1(SB) + MOVD $24, R12 + B callbackasm1(SB) + MOVD $25, R12 + B callbackasm1(SB) + MOVD $26, R12 + B callbackasm1(SB) + MOVD $27, R12 + B callbackasm1(SB) + MOVD $28, R12 + B callbackasm1(SB) + MOVD $29, R12 + B callbackasm1(SB) + MOVD $30, R12 + B callbackasm1(SB) + MOVD $31, R12 + B callbackasm1(SB) + MOVD $32, R12 + B callbackasm1(SB) + MOVD $33, R12 + B callbackasm1(SB) + MOVD $34, R12 + B callbackasm1(SB) + MOVD $35, R12 + B callbackasm1(SB) + MOVD $36, R12 + B callbackasm1(SB) + MOVD $37, R12 + B callbackasm1(SB) + MOVD $38, R12 + B callbackasm1(SB) + MOVD $39, R12 + B callbackasm1(SB) + MOVD $40, R12 + B callbackasm1(SB) + MOVD $41, R12 + B callbackasm1(SB) + MOVD $42, R12 + B callbackasm1(SB) + MOVD $43, R12 + B callbackasm1(SB) + MOVD $44, R12 + B callbackasm1(SB) + MOVD $45, R12 + B callbackasm1(SB) + MOVD $46, R12 + B callbackasm1(SB) + MOVD $47, R12 + B callbackasm1(SB) + MOVD $48, R12 + B callbackasm1(SB) + MOVD $49, R12 + B callbackasm1(SB) + MOVD $50, R12 + B callbackasm1(SB) + MOVD $51, R12 + B callbackasm1(SB) + MOVD $52, R12 + B callbackasm1(SB) + MOVD $53, R12 + B callbackasm1(SB) + MOVD $54, R12 + B callbackasm1(SB) + MOVD $55, R12 + B callbackasm1(SB) + MOVD $56, R12 + B callbackasm1(SB) + MOVD $57, R12 + B callbackasm1(SB) + MOVD $58, R12 + B callbackasm1(SB) + MOVD $59, R12 + B callbackasm1(SB) + MOVD $60, R12 + B callbackasm1(SB) + MOVD $61, R12 + B callbackasm1(SB) + MOVD $62, R12 + B callbackasm1(SB) + MOVD $63, R12 + B callbackasm1(SB) + MOVD $64, R12 + B callbackasm1(SB) + MOVD $65, R12 + B callbackasm1(SB) + MOVD $66, R12 + B callbackasm1(SB) + MOVD $67, R12 + B callbackasm1(SB) + MOVD $68, R12 + B callbackasm1(SB) + MOVD $69, R12 + B callbackasm1(SB) + MOVD $70, R12 + B callbackasm1(SB) + MOVD $71, R12 + B callbackasm1(SB) + MOVD $72, R12 + B callbackasm1(SB) + MOVD $73, R12 + B callbackasm1(SB) + MOVD $74, R12 + B callbackasm1(SB) + MOVD $75, R12 + B callbackasm1(SB) + MOVD $76, R12 + B callbackasm1(SB) + MOVD $77, R12 + B callbackasm1(SB) + MOVD $78, R12 + B callbackasm1(SB) + MOVD $79, R12 + B callbackasm1(SB) + MOVD $80, R12 + B callbackasm1(SB) + MOVD $81, R12 + B callbackasm1(SB) + MOVD $82, R12 + B callbackasm1(SB) + MOVD $83, R12 + B callbackasm1(SB) + MOVD $84, R12 + B callbackasm1(SB) + MOVD $85, R12 + B callbackasm1(SB) + MOVD $86, R12 + B callbackasm1(SB) + MOVD $87, R12 + B callbackasm1(SB) + MOVD $88, R12 + B callbackasm1(SB) + MOVD $89, R12 + B callbackasm1(SB) + MOVD $90, R12 + B callbackasm1(SB) + MOVD $91, R12 + B callbackasm1(SB) + MOVD $92, R12 + B callbackasm1(SB) + MOVD $93, R12 + B callbackasm1(SB) + MOVD $94, R12 + B callbackasm1(SB) + MOVD $95, R12 + B callbackasm1(SB) + MOVD $96, R12 + B callbackasm1(SB) + MOVD $97, R12 + B callbackasm1(SB) + MOVD $98, R12 + B callbackasm1(SB) + MOVD $99, R12 + B callbackasm1(SB) + MOVD $100, R12 + B callbackasm1(SB) + MOVD $101, R12 + B callbackasm1(SB) + MOVD $102, R12 + B callbackasm1(SB) + MOVD $103, R12 + B callbackasm1(SB) + MOVD $104, R12 + B callbackasm1(SB) + MOVD $105, R12 + B callbackasm1(SB) + MOVD $106, R12 + B callbackasm1(SB) + MOVD $107, R12 + B callbackasm1(SB) + MOVD $108, R12 + B callbackasm1(SB) + MOVD $109, R12 + B callbackasm1(SB) + MOVD $110, R12 + B callbackasm1(SB) + MOVD $111, R12 + B callbackasm1(SB) + MOVD $112, R12 + B callbackasm1(SB) + MOVD $113, R12 + B callbackasm1(SB) + MOVD $114, R12 + B callbackasm1(SB) + MOVD $115, R12 + B callbackasm1(SB) + MOVD $116, R12 + B callbackasm1(SB) + MOVD $117, R12 + B callbackasm1(SB) + MOVD $118, R12 + B callbackasm1(SB) + MOVD $119, R12 + B callbackasm1(SB) + MOVD $120, R12 + B callbackasm1(SB) + MOVD $121, R12 + B callbackasm1(SB) + MOVD $122, R12 + B callbackasm1(SB) + MOVD $123, R12 + B callbackasm1(SB) + MOVD $124, R12 + B callbackasm1(SB) + MOVD $125, R12 + B callbackasm1(SB) + MOVD $126, R12 + B callbackasm1(SB) + MOVD $127, R12 + B callbackasm1(SB) + MOVD $128, R12 + B callbackasm1(SB) + MOVD $129, R12 + B callbackasm1(SB) + MOVD $130, R12 + B callbackasm1(SB) + MOVD $131, R12 + B callbackasm1(SB) + MOVD $132, R12 + B callbackasm1(SB) + MOVD $133, R12 + B callbackasm1(SB) + MOVD $134, R12 + B callbackasm1(SB) + MOVD $135, R12 + B callbackasm1(SB) + MOVD $136, R12 + B callbackasm1(SB) + MOVD $137, R12 + B callbackasm1(SB) + MOVD $138, R12 + B callbackasm1(SB) + MOVD $139, R12 + B callbackasm1(SB) + MOVD $140, R12 + B callbackasm1(SB) + MOVD $141, R12 + B callbackasm1(SB) + MOVD $142, R12 + B callbackasm1(SB) + MOVD $143, R12 + B callbackasm1(SB) + MOVD $144, R12 + B callbackasm1(SB) + MOVD $145, R12 + B callbackasm1(SB) + MOVD $146, R12 + B callbackasm1(SB) + MOVD $147, R12 + B callbackasm1(SB) + MOVD $148, R12 + B callbackasm1(SB) + MOVD $149, R12 + B callbackasm1(SB) + MOVD $150, R12 + B callbackasm1(SB) + MOVD $151, R12 + B callbackasm1(SB) + MOVD $152, R12 + B callbackasm1(SB) + MOVD $153, R12 + B callbackasm1(SB) + MOVD $154, R12 + B callbackasm1(SB) + MOVD $155, R12 + B callbackasm1(SB) + MOVD $156, R12 + B callbackasm1(SB) + MOVD $157, R12 + B callbackasm1(SB) + MOVD $158, R12 + B callbackasm1(SB) + MOVD $159, R12 + B callbackasm1(SB) + MOVD $160, R12 + B callbackasm1(SB) + MOVD $161, R12 + B callbackasm1(SB) + MOVD $162, R12 + B callbackasm1(SB) + MOVD $163, R12 + B callbackasm1(SB) + MOVD $164, R12 + B callbackasm1(SB) + MOVD $165, R12 + B callbackasm1(SB) + MOVD $166, R12 + B callbackasm1(SB) + MOVD $167, R12 + B callbackasm1(SB) + MOVD $168, R12 + B callbackasm1(SB) + MOVD $169, R12 + B callbackasm1(SB) + MOVD $170, R12 + B callbackasm1(SB) + MOVD $171, R12 + B callbackasm1(SB) + MOVD $172, R12 + B callbackasm1(SB) + MOVD $173, R12 + B callbackasm1(SB) + MOVD $174, R12 + B callbackasm1(SB) + MOVD $175, R12 + B callbackasm1(SB) + MOVD $176, R12 + B callbackasm1(SB) + MOVD $177, R12 + B callbackasm1(SB) + MOVD $178, R12 + B callbackasm1(SB) + MOVD $179, R12 + B callbackasm1(SB) + MOVD $180, R12 + B callbackasm1(SB) + MOVD $181, R12 + B callbackasm1(SB) + MOVD $182, R12 + B callbackasm1(SB) + MOVD $183, R12 + B callbackasm1(SB) + MOVD $184, R12 + B callbackasm1(SB) + MOVD $185, R12 + B callbackasm1(SB) + MOVD $186, R12 + B callbackasm1(SB) + MOVD $187, R12 + B callbackasm1(SB) + MOVD $188, R12 + B callbackasm1(SB) + MOVD $189, R12 + B callbackasm1(SB) + MOVD $190, R12 + B callbackasm1(SB) + MOVD $191, R12 + B callbackasm1(SB) + MOVD $192, R12 + B callbackasm1(SB) + MOVD $193, R12 + B callbackasm1(SB) + MOVD $194, R12 + B callbackasm1(SB) + MOVD $195, R12 + B callbackasm1(SB) + MOVD $196, R12 + B callbackasm1(SB) + MOVD $197, R12 + B callbackasm1(SB) + MOVD $198, R12 + B callbackasm1(SB) + MOVD $199, R12 + B callbackasm1(SB) + MOVD $200, R12 + B callbackasm1(SB) + MOVD $201, R12 + B callbackasm1(SB) + MOVD $202, R12 + B callbackasm1(SB) + MOVD $203, R12 + B callbackasm1(SB) + MOVD $204, R12 + B callbackasm1(SB) + MOVD $205, R12 + B callbackasm1(SB) + MOVD $206, R12 + B callbackasm1(SB) + MOVD $207, R12 + B callbackasm1(SB) + MOVD $208, R12 + B callbackasm1(SB) + MOVD $209, R12 + B callbackasm1(SB) + MOVD $210, R12 + B callbackasm1(SB) + MOVD $211, R12 + B callbackasm1(SB) + MOVD $212, R12 + B callbackasm1(SB) + MOVD $213, R12 + B callbackasm1(SB) + MOVD $214, R12 + B callbackasm1(SB) + MOVD $215, R12 + B callbackasm1(SB) + MOVD $216, R12 + B callbackasm1(SB) + MOVD $217, R12 + B callbackasm1(SB) + MOVD $218, R12 + B callbackasm1(SB) + MOVD $219, R12 + B callbackasm1(SB) + MOVD $220, R12 + B callbackasm1(SB) + MOVD $221, R12 + B callbackasm1(SB) + MOVD $222, R12 + B callbackasm1(SB) + MOVD $223, R12 + B callbackasm1(SB) + MOVD $224, R12 + B callbackasm1(SB) + MOVD $225, R12 + B callbackasm1(SB) + MOVD $226, R12 + B callbackasm1(SB) + MOVD $227, R12 + B callbackasm1(SB) + MOVD $228, R12 + B callbackasm1(SB) + MOVD $229, R12 + B callbackasm1(SB) + MOVD $230, R12 + B callbackasm1(SB) + MOVD $231, R12 + B callbackasm1(SB) + MOVD $232, R12 + B callbackasm1(SB) + MOVD $233, R12 + B callbackasm1(SB) + MOVD $234, R12 + B callbackasm1(SB) + MOVD $235, R12 + B callbackasm1(SB) + MOVD $236, R12 + B callbackasm1(SB) + MOVD $237, R12 + B callbackasm1(SB) + MOVD $238, R12 + B callbackasm1(SB) + MOVD $239, R12 + B callbackasm1(SB) + MOVD $240, R12 + B callbackasm1(SB) + MOVD $241, R12 + B callbackasm1(SB) + MOVD $242, R12 + B callbackasm1(SB) + MOVD $243, R12 + B callbackasm1(SB) + MOVD $244, R12 + B callbackasm1(SB) + MOVD $245, R12 + B callbackasm1(SB) + MOVD $246, R12 + B callbackasm1(SB) + MOVD $247, R12 + B callbackasm1(SB) + MOVD $248, R12 + B callbackasm1(SB) + MOVD $249, R12 + B callbackasm1(SB) + MOVD $250, R12 + B callbackasm1(SB) + MOVD $251, R12 + B callbackasm1(SB) + MOVD $252, R12 + B callbackasm1(SB) + MOVD $253, R12 + B callbackasm1(SB) + MOVD $254, R12 + B callbackasm1(SB) + MOVD $255, R12 + B callbackasm1(SB) + MOVD $256, R12 + B callbackasm1(SB) + MOVD $257, R12 + B callbackasm1(SB) + MOVD $258, R12 + B callbackasm1(SB) + MOVD $259, R12 + B callbackasm1(SB) + MOVD $260, R12 + B callbackasm1(SB) + MOVD $261, R12 + B callbackasm1(SB) + MOVD $262, R12 + B callbackasm1(SB) + MOVD $263, R12 + B callbackasm1(SB) + MOVD $264, R12 + B callbackasm1(SB) + MOVD $265, R12 + B callbackasm1(SB) + MOVD $266, R12 + B callbackasm1(SB) + MOVD $267, R12 + B callbackasm1(SB) + MOVD $268, R12 + B callbackasm1(SB) + MOVD $269, R12 + B callbackasm1(SB) + MOVD $270, R12 + B callbackasm1(SB) + MOVD $271, R12 + B callbackasm1(SB) + MOVD $272, R12 + B callbackasm1(SB) + MOVD $273, R12 + B callbackasm1(SB) + MOVD $274, R12 + B callbackasm1(SB) + MOVD $275, R12 + B callbackasm1(SB) + MOVD $276, R12 + B callbackasm1(SB) + MOVD $277, R12 + B callbackasm1(SB) + MOVD $278, R12 + B callbackasm1(SB) + MOVD $279, R12 + B callbackasm1(SB) + MOVD $280, R12 + B callbackasm1(SB) + MOVD $281, R12 + B callbackasm1(SB) + MOVD $282, R12 + B callbackasm1(SB) + MOVD $283, R12 + B callbackasm1(SB) + MOVD $284, R12 + B callbackasm1(SB) + MOVD $285, R12 + B callbackasm1(SB) + MOVD $286, R12 + B callbackasm1(SB) + MOVD $287, R12 + B callbackasm1(SB) + MOVD $288, R12 + B callbackasm1(SB) + MOVD $289, R12 + B callbackasm1(SB) + MOVD $290, R12 + B callbackasm1(SB) + MOVD $291, R12 + B callbackasm1(SB) + MOVD $292, R12 + B callbackasm1(SB) + MOVD $293, R12 + B callbackasm1(SB) + MOVD $294, R12 + B callbackasm1(SB) + MOVD $295, R12 + B callbackasm1(SB) + MOVD $296, R12 + B callbackasm1(SB) + MOVD $297, R12 + B callbackasm1(SB) + MOVD $298, R12 + B callbackasm1(SB) + MOVD $299, R12 + B callbackasm1(SB) + MOVD $300, R12 + B callbackasm1(SB) + MOVD $301, R12 + B callbackasm1(SB) + MOVD $302, R12 + B callbackasm1(SB) + MOVD $303, R12 + B callbackasm1(SB) + MOVD $304, R12 + B callbackasm1(SB) + MOVD $305, R12 + B callbackasm1(SB) + MOVD $306, R12 + B callbackasm1(SB) + MOVD $307, R12 + B callbackasm1(SB) + MOVD $308, R12 + B callbackasm1(SB) + MOVD $309, R12 + B callbackasm1(SB) + MOVD $310, R12 + B callbackasm1(SB) + MOVD $311, R12 + B callbackasm1(SB) + MOVD $312, R12 + B callbackasm1(SB) + MOVD $313, R12 + B callbackasm1(SB) + MOVD $314, R12 + B callbackasm1(SB) + MOVD $315, R12 + B callbackasm1(SB) + MOVD $316, R12 + B callbackasm1(SB) + MOVD $317, R12 + B callbackasm1(SB) + MOVD $318, R12 + B callbackasm1(SB) + MOVD $319, R12 + B callbackasm1(SB) + MOVD $320, R12 + B callbackasm1(SB) + MOVD $321, R12 + B callbackasm1(SB) + MOVD $322, R12 + B callbackasm1(SB) + MOVD $323, R12 + B callbackasm1(SB) + MOVD $324, R12 + B callbackasm1(SB) + MOVD $325, R12 + B callbackasm1(SB) + MOVD $326, R12 + B callbackasm1(SB) + MOVD $327, R12 + B callbackasm1(SB) + MOVD $328, R12 + B callbackasm1(SB) + MOVD $329, R12 + B callbackasm1(SB) + MOVD $330, R12 + B callbackasm1(SB) + MOVD $331, R12 + B callbackasm1(SB) + MOVD $332, R12 + B callbackasm1(SB) + MOVD $333, R12 + B callbackasm1(SB) + MOVD $334, R12 + B callbackasm1(SB) + MOVD $335, R12 + B callbackasm1(SB) + MOVD $336, R12 + B callbackasm1(SB) + MOVD $337, R12 + B callbackasm1(SB) + MOVD $338, R12 + B callbackasm1(SB) + MOVD $339, R12 + B callbackasm1(SB) + MOVD $340, R12 + B callbackasm1(SB) + MOVD $341, R12 + B callbackasm1(SB) + MOVD $342, R12 + B callbackasm1(SB) + MOVD $343, R12 + B callbackasm1(SB) + MOVD $344, R12 + B callbackasm1(SB) + MOVD $345, R12 + B callbackasm1(SB) + MOVD $346, R12 + B callbackasm1(SB) + MOVD $347, R12 + B callbackasm1(SB) + MOVD $348, R12 + B callbackasm1(SB) + MOVD $349, R12 + B callbackasm1(SB) + MOVD $350, R12 + B callbackasm1(SB) + MOVD $351, R12 + B callbackasm1(SB) + MOVD $352, R12 + B callbackasm1(SB) + MOVD $353, R12 + B callbackasm1(SB) + MOVD $354, R12 + B callbackasm1(SB) + MOVD $355, R12 + B callbackasm1(SB) + MOVD $356, R12 + B callbackasm1(SB) + MOVD $357, R12 + B callbackasm1(SB) + MOVD $358, R12 + B callbackasm1(SB) + MOVD $359, R12 + B callbackasm1(SB) + MOVD $360, R12 + B callbackasm1(SB) + MOVD $361, R12 + B callbackasm1(SB) + MOVD $362, R12 + B callbackasm1(SB) + MOVD $363, R12 + B callbackasm1(SB) + MOVD $364, R12 + B callbackasm1(SB) + MOVD $365, R12 + B callbackasm1(SB) + MOVD $366, R12 + B callbackasm1(SB) + MOVD $367, R12 + B callbackasm1(SB) + MOVD $368, R12 + B callbackasm1(SB) + MOVD $369, R12 + B callbackasm1(SB) + MOVD $370, R12 + B callbackasm1(SB) + MOVD $371, R12 + B callbackasm1(SB) + MOVD $372, R12 + B callbackasm1(SB) + MOVD $373, R12 + B callbackasm1(SB) + MOVD $374, R12 + B callbackasm1(SB) + MOVD $375, R12 + B callbackasm1(SB) + MOVD $376, R12 + B callbackasm1(SB) + MOVD $377, R12 + B callbackasm1(SB) + MOVD $378, R12 + B callbackasm1(SB) + MOVD $379, R12 + B callbackasm1(SB) + MOVD $380, R12 + B callbackasm1(SB) + MOVD $381, R12 + B callbackasm1(SB) + MOVD $382, R12 + B callbackasm1(SB) + MOVD $383, R12 + B callbackasm1(SB) + MOVD $384, R12 + B callbackasm1(SB) + MOVD $385, R12 + B callbackasm1(SB) + MOVD $386, R12 + B callbackasm1(SB) + MOVD $387, R12 + B callbackasm1(SB) + MOVD $388, R12 + B callbackasm1(SB) + MOVD $389, R12 + B callbackasm1(SB) + MOVD $390, R12 + B callbackasm1(SB) + MOVD $391, R12 + B callbackasm1(SB) + MOVD $392, R12 + B callbackasm1(SB) + MOVD $393, R12 + B callbackasm1(SB) + MOVD $394, R12 + B callbackasm1(SB) + MOVD $395, R12 + B callbackasm1(SB) + MOVD $396, R12 + B callbackasm1(SB) + MOVD $397, R12 + B callbackasm1(SB) + MOVD $398, R12 + B callbackasm1(SB) + MOVD $399, R12 + B callbackasm1(SB) + MOVD $400, R12 + B callbackasm1(SB) + MOVD $401, R12 + B callbackasm1(SB) + MOVD $402, R12 + B callbackasm1(SB) + MOVD $403, R12 + B callbackasm1(SB) + MOVD $404, R12 + B callbackasm1(SB) + MOVD $405, R12 + B callbackasm1(SB) + MOVD $406, R12 + B callbackasm1(SB) + MOVD $407, R12 + B callbackasm1(SB) + MOVD $408, R12 + B callbackasm1(SB) + MOVD $409, R12 + B callbackasm1(SB) + MOVD $410, R12 + B callbackasm1(SB) + MOVD $411, R12 + B callbackasm1(SB) + MOVD $412, R12 + B callbackasm1(SB) + MOVD $413, R12 + B callbackasm1(SB) + MOVD $414, R12 + B callbackasm1(SB) + MOVD $415, R12 + B callbackasm1(SB) + MOVD $416, R12 + B callbackasm1(SB) + MOVD $417, R12 + B callbackasm1(SB) + MOVD $418, R12 + B callbackasm1(SB) + MOVD $419, R12 + B callbackasm1(SB) + MOVD $420, R12 + B callbackasm1(SB) + MOVD $421, R12 + B callbackasm1(SB) + MOVD $422, R12 + B callbackasm1(SB) + MOVD $423, R12 + B callbackasm1(SB) + MOVD $424, R12 + B callbackasm1(SB) + MOVD $425, R12 + B callbackasm1(SB) + MOVD $426, R12 + B callbackasm1(SB) + MOVD $427, R12 + B callbackasm1(SB) + MOVD $428, R12 + B callbackasm1(SB) + MOVD $429, R12 + B callbackasm1(SB) + MOVD $430, R12 + B callbackasm1(SB) + MOVD $431, R12 + B callbackasm1(SB) + MOVD $432, R12 + B callbackasm1(SB) + MOVD $433, R12 + B callbackasm1(SB) + MOVD $434, R12 + B callbackasm1(SB) + MOVD $435, R12 + B callbackasm1(SB) + MOVD $436, R12 + B callbackasm1(SB) + MOVD $437, R12 + B callbackasm1(SB) + MOVD $438, R12 + B callbackasm1(SB) + MOVD $439, R12 + B callbackasm1(SB) + MOVD $440, R12 + B callbackasm1(SB) + MOVD $441, R12 + B callbackasm1(SB) + MOVD $442, R12 + B callbackasm1(SB) + MOVD $443, R12 + B callbackasm1(SB) + MOVD $444, R12 + B callbackasm1(SB) + MOVD $445, R12 + B callbackasm1(SB) + MOVD $446, R12 + B callbackasm1(SB) + MOVD $447, R12 + B callbackasm1(SB) + MOVD $448, R12 + B callbackasm1(SB) + MOVD $449, R12 + B callbackasm1(SB) + MOVD $450, R12 + B callbackasm1(SB) + MOVD $451, R12 + B callbackasm1(SB) + MOVD $452, R12 + B callbackasm1(SB) + MOVD $453, R12 + B callbackasm1(SB) + MOVD $454, R12 + B callbackasm1(SB) + MOVD $455, R12 + B callbackasm1(SB) + MOVD $456, R12 + B callbackasm1(SB) + MOVD $457, R12 + B callbackasm1(SB) + MOVD $458, R12 + B callbackasm1(SB) + MOVD $459, R12 + B callbackasm1(SB) + MOVD $460, R12 + B callbackasm1(SB) + MOVD $461, R12 + B callbackasm1(SB) + MOVD $462, R12 + B callbackasm1(SB) + MOVD $463, R12 + B callbackasm1(SB) + MOVD $464, R12 + B callbackasm1(SB) + MOVD $465, R12 + B callbackasm1(SB) + MOVD $466, R12 + B callbackasm1(SB) + MOVD $467, R12 + B callbackasm1(SB) + MOVD $468, R12 + B callbackasm1(SB) + MOVD $469, R12 + B callbackasm1(SB) + MOVD $470, R12 + B callbackasm1(SB) + MOVD $471, R12 + B callbackasm1(SB) + MOVD $472, R12 + B callbackasm1(SB) + MOVD $473, R12 + B callbackasm1(SB) + MOVD $474, R12 + B callbackasm1(SB) + MOVD $475, R12 + B callbackasm1(SB) + MOVD $476, R12 + B callbackasm1(SB) + MOVD $477, R12 + B callbackasm1(SB) + MOVD $478, R12 + B callbackasm1(SB) + MOVD $479, R12 + B callbackasm1(SB) + MOVD $480, R12 + B callbackasm1(SB) + MOVD $481, R12 + B callbackasm1(SB) + MOVD $482, R12 + B callbackasm1(SB) + MOVD $483, R12 + B callbackasm1(SB) + MOVD $484, R12 + B callbackasm1(SB) + MOVD $485, R12 + B callbackasm1(SB) + MOVD $486, R12 + B callbackasm1(SB) + MOVD $487, R12 + B callbackasm1(SB) + MOVD $488, R12 + B callbackasm1(SB) + MOVD $489, R12 + B callbackasm1(SB) + MOVD $490, R12 + B callbackasm1(SB) + MOVD $491, R12 + B callbackasm1(SB) + MOVD $492, R12 + B callbackasm1(SB) + MOVD $493, R12 + B callbackasm1(SB) + MOVD $494, R12 + B callbackasm1(SB) + MOVD $495, R12 + B callbackasm1(SB) + MOVD $496, R12 + B callbackasm1(SB) + MOVD $497, R12 + B callbackasm1(SB) + MOVD $498, R12 + B callbackasm1(SB) + MOVD $499, R12 + B callbackasm1(SB) + MOVD $500, R12 + B callbackasm1(SB) + MOVD $501, R12 + B callbackasm1(SB) + MOVD $502, R12 + B callbackasm1(SB) + MOVD $503, R12 + B callbackasm1(SB) + MOVD $504, R12 + B callbackasm1(SB) + MOVD $505, R12 + B callbackasm1(SB) + MOVD $506, R12 + B callbackasm1(SB) + MOVD $507, R12 + B callbackasm1(SB) + MOVD $508, R12 + B callbackasm1(SB) + MOVD $509, R12 + B callbackasm1(SB) + MOVD $510, R12 + B callbackasm1(SB) + MOVD $511, R12 + B callbackasm1(SB) + MOVD $512, R12 + B callbackasm1(SB) + MOVD $513, R12 + B callbackasm1(SB) + MOVD $514, R12 + B callbackasm1(SB) + MOVD $515, R12 + B callbackasm1(SB) + MOVD $516, R12 + B callbackasm1(SB) + MOVD $517, R12 + B callbackasm1(SB) + MOVD $518, R12 + B callbackasm1(SB) + MOVD $519, R12 + B callbackasm1(SB) + MOVD $520, R12 + B callbackasm1(SB) + MOVD $521, R12 + B callbackasm1(SB) + MOVD $522, R12 + B callbackasm1(SB) + MOVD $523, R12 + B callbackasm1(SB) + MOVD $524, R12 + B callbackasm1(SB) + MOVD $525, R12 + B callbackasm1(SB) + MOVD $526, R12 + B callbackasm1(SB) + MOVD $527, R12 + B callbackasm1(SB) + MOVD $528, R12 + B callbackasm1(SB) + MOVD $529, R12 + B callbackasm1(SB) + MOVD $530, R12 + B callbackasm1(SB) + MOVD $531, R12 + B callbackasm1(SB) + MOVD $532, R12 + B callbackasm1(SB) + MOVD $533, R12 + B callbackasm1(SB) + MOVD $534, R12 + B callbackasm1(SB) + MOVD $535, R12 + B callbackasm1(SB) + MOVD $536, R12 + B callbackasm1(SB) + MOVD $537, R12 + B callbackasm1(SB) + MOVD $538, R12 + B callbackasm1(SB) + MOVD $539, R12 + B callbackasm1(SB) + MOVD $540, R12 + B callbackasm1(SB) + MOVD $541, R12 + B callbackasm1(SB) + MOVD $542, R12 + B callbackasm1(SB) + MOVD $543, R12 + B callbackasm1(SB) + MOVD $544, R12 + B callbackasm1(SB) + MOVD $545, R12 + B callbackasm1(SB) + MOVD $546, R12 + B callbackasm1(SB) + MOVD $547, R12 + B callbackasm1(SB) + MOVD $548, R12 + B callbackasm1(SB) + MOVD $549, R12 + B callbackasm1(SB) + MOVD $550, R12 + B callbackasm1(SB) + MOVD $551, R12 + B callbackasm1(SB) + MOVD $552, R12 + B callbackasm1(SB) + MOVD $553, R12 + B callbackasm1(SB) + MOVD $554, R12 + B callbackasm1(SB) + MOVD $555, R12 + B callbackasm1(SB) + MOVD $556, R12 + B callbackasm1(SB) + MOVD $557, R12 + B callbackasm1(SB) + MOVD $558, R12 + B callbackasm1(SB) + MOVD $559, R12 + B callbackasm1(SB) + MOVD $560, R12 + B callbackasm1(SB) + MOVD $561, R12 + B callbackasm1(SB) + MOVD $562, R12 + B callbackasm1(SB) + MOVD $563, R12 + B callbackasm1(SB) + MOVD $564, R12 + B callbackasm1(SB) + MOVD $565, R12 + B callbackasm1(SB) + MOVD $566, R12 + B callbackasm1(SB) + MOVD $567, R12 + B callbackasm1(SB) + MOVD $568, R12 + B callbackasm1(SB) + MOVD $569, R12 + B callbackasm1(SB) + MOVD $570, R12 + B callbackasm1(SB) + MOVD $571, R12 + B callbackasm1(SB) + MOVD $572, R12 + B callbackasm1(SB) + MOVD $573, R12 + B callbackasm1(SB) + MOVD $574, R12 + B callbackasm1(SB) + MOVD $575, R12 + B callbackasm1(SB) + MOVD $576, R12 + B callbackasm1(SB) + MOVD $577, R12 + B callbackasm1(SB) + MOVD $578, R12 + B callbackasm1(SB) + MOVD $579, R12 + B callbackasm1(SB) + MOVD $580, R12 + B callbackasm1(SB) + MOVD $581, R12 + B callbackasm1(SB) + MOVD $582, R12 + B callbackasm1(SB) + MOVD $583, R12 + B callbackasm1(SB) + MOVD $584, R12 + B callbackasm1(SB) + MOVD $585, R12 + B callbackasm1(SB) + MOVD $586, R12 + B callbackasm1(SB) + MOVD $587, R12 + B callbackasm1(SB) + MOVD $588, R12 + B callbackasm1(SB) + MOVD $589, R12 + B callbackasm1(SB) + MOVD $590, R12 + B callbackasm1(SB) + MOVD $591, R12 + B callbackasm1(SB) + MOVD $592, R12 + B callbackasm1(SB) + MOVD $593, R12 + B callbackasm1(SB) + MOVD $594, R12 + B callbackasm1(SB) + MOVD $595, R12 + B callbackasm1(SB) + MOVD $596, R12 + B callbackasm1(SB) + MOVD $597, R12 + B callbackasm1(SB) + MOVD $598, R12 + B callbackasm1(SB) + MOVD $599, R12 + B callbackasm1(SB) + MOVD $600, R12 + B callbackasm1(SB) + MOVD $601, R12 + B callbackasm1(SB) + MOVD $602, R12 + B callbackasm1(SB) + MOVD $603, R12 + B callbackasm1(SB) + MOVD $604, R12 + B callbackasm1(SB) + MOVD $605, R12 + B callbackasm1(SB) + MOVD $606, R12 + B callbackasm1(SB) + MOVD $607, R12 + B callbackasm1(SB) + MOVD $608, R12 + B callbackasm1(SB) + MOVD $609, R12 + B callbackasm1(SB) + MOVD $610, R12 + B callbackasm1(SB) + MOVD $611, R12 + B callbackasm1(SB) + MOVD $612, R12 + B callbackasm1(SB) + MOVD $613, R12 + B callbackasm1(SB) + MOVD $614, R12 + B callbackasm1(SB) + MOVD $615, R12 + B callbackasm1(SB) + MOVD $616, R12 + B callbackasm1(SB) + MOVD $617, R12 + B callbackasm1(SB) + MOVD $618, R12 + B callbackasm1(SB) + MOVD $619, R12 + B callbackasm1(SB) + MOVD $620, R12 + B callbackasm1(SB) + MOVD $621, R12 + B callbackasm1(SB) + MOVD $622, R12 + B callbackasm1(SB) + MOVD $623, R12 + B callbackasm1(SB) + MOVD $624, R12 + B callbackasm1(SB) + MOVD $625, R12 + B callbackasm1(SB) + MOVD $626, R12 + B callbackasm1(SB) + MOVD $627, R12 + B callbackasm1(SB) + MOVD $628, R12 + B callbackasm1(SB) + MOVD $629, R12 + B callbackasm1(SB) + MOVD $630, R12 + B callbackasm1(SB) + MOVD $631, R12 + B callbackasm1(SB) + MOVD $632, R12 + B callbackasm1(SB) + MOVD $633, R12 + B callbackasm1(SB) + MOVD $634, R12 + B callbackasm1(SB) + MOVD $635, R12 + B callbackasm1(SB) + MOVD $636, R12 + B callbackasm1(SB) + MOVD $637, R12 + B callbackasm1(SB) + MOVD $638, R12 + B callbackasm1(SB) + MOVD $639, R12 + B callbackasm1(SB) + MOVD $640, R12 + B callbackasm1(SB) + MOVD $641, R12 + B callbackasm1(SB) + MOVD $642, R12 + B callbackasm1(SB) + MOVD $643, R12 + B callbackasm1(SB) + MOVD $644, R12 + B callbackasm1(SB) + MOVD $645, R12 + B callbackasm1(SB) + MOVD $646, R12 + B callbackasm1(SB) + MOVD $647, R12 + B callbackasm1(SB) + MOVD $648, R12 + B callbackasm1(SB) + MOVD $649, R12 + B callbackasm1(SB) + MOVD $650, R12 + B callbackasm1(SB) + MOVD $651, R12 + B callbackasm1(SB) + MOVD $652, R12 + B callbackasm1(SB) + MOVD $653, R12 + B callbackasm1(SB) + MOVD $654, R12 + B callbackasm1(SB) + MOVD $655, R12 + B callbackasm1(SB) + MOVD $656, R12 + B callbackasm1(SB) + MOVD $657, R12 + B callbackasm1(SB) + MOVD $658, R12 + B callbackasm1(SB) + MOVD $659, R12 + B callbackasm1(SB) + MOVD $660, R12 + B callbackasm1(SB) + MOVD $661, R12 + B callbackasm1(SB) + MOVD $662, R12 + B callbackasm1(SB) + MOVD $663, R12 + B callbackasm1(SB) + MOVD $664, R12 + B callbackasm1(SB) + MOVD $665, R12 + B callbackasm1(SB) + MOVD $666, R12 + B callbackasm1(SB) + MOVD $667, R12 + B callbackasm1(SB) + MOVD $668, R12 + B callbackasm1(SB) + MOVD $669, R12 + B callbackasm1(SB) + MOVD $670, R12 + B callbackasm1(SB) + MOVD $671, R12 + B callbackasm1(SB) + MOVD $672, R12 + B callbackasm1(SB) + MOVD $673, R12 + B callbackasm1(SB) + MOVD $674, R12 + B callbackasm1(SB) + MOVD $675, R12 + B callbackasm1(SB) + MOVD $676, R12 + B callbackasm1(SB) + MOVD $677, R12 + B callbackasm1(SB) + MOVD $678, R12 + B callbackasm1(SB) + MOVD $679, R12 + B callbackasm1(SB) + MOVD $680, R12 + B callbackasm1(SB) + MOVD $681, R12 + B callbackasm1(SB) + MOVD $682, R12 + B callbackasm1(SB) + MOVD $683, R12 + B callbackasm1(SB) + MOVD $684, R12 + B callbackasm1(SB) + MOVD $685, R12 + B callbackasm1(SB) + MOVD $686, R12 + B callbackasm1(SB) + MOVD $687, R12 + B callbackasm1(SB) + MOVD $688, R12 + B callbackasm1(SB) + MOVD $689, R12 + B callbackasm1(SB) + MOVD $690, R12 + B callbackasm1(SB) + MOVD $691, R12 + B callbackasm1(SB) + MOVD $692, R12 + B callbackasm1(SB) + MOVD $693, R12 + B callbackasm1(SB) + MOVD $694, R12 + B callbackasm1(SB) + MOVD $695, R12 + B callbackasm1(SB) + MOVD $696, R12 + B callbackasm1(SB) + MOVD $697, R12 + B callbackasm1(SB) + MOVD $698, R12 + B callbackasm1(SB) + MOVD $699, R12 + B callbackasm1(SB) + MOVD $700, R12 + B callbackasm1(SB) + MOVD $701, R12 + B callbackasm1(SB) + MOVD $702, R12 + B callbackasm1(SB) + MOVD $703, R12 + B callbackasm1(SB) + MOVD $704, R12 + B callbackasm1(SB) + MOVD $705, R12 + B callbackasm1(SB) + MOVD $706, R12 + B callbackasm1(SB) + MOVD $707, R12 + B callbackasm1(SB) + MOVD $708, R12 + B callbackasm1(SB) + MOVD $709, R12 + B callbackasm1(SB) + MOVD $710, R12 + B callbackasm1(SB) + MOVD $711, R12 + B callbackasm1(SB) + MOVD $712, R12 + B callbackasm1(SB) + MOVD $713, R12 + B callbackasm1(SB) + MOVD $714, R12 + B callbackasm1(SB) + MOVD $715, R12 + B callbackasm1(SB) + MOVD $716, R12 + B callbackasm1(SB) + MOVD $717, R12 + B callbackasm1(SB) + MOVD $718, R12 + B callbackasm1(SB) + MOVD $719, R12 + B callbackasm1(SB) + MOVD $720, R12 + B callbackasm1(SB) + MOVD $721, R12 + B callbackasm1(SB) + MOVD $722, R12 + B callbackasm1(SB) + MOVD $723, R12 + B callbackasm1(SB) + MOVD $724, R12 + B callbackasm1(SB) + MOVD $725, R12 + B callbackasm1(SB) + MOVD $726, R12 + B callbackasm1(SB) + MOVD $727, R12 + B callbackasm1(SB) + MOVD $728, R12 + B callbackasm1(SB) + MOVD $729, R12 + B callbackasm1(SB) + MOVD $730, R12 + B callbackasm1(SB) + MOVD $731, R12 + B callbackasm1(SB) + MOVD $732, R12 + B callbackasm1(SB) + MOVD $733, R12 + B callbackasm1(SB) + MOVD $734, R12 + B callbackasm1(SB) + MOVD $735, R12 + B callbackasm1(SB) + MOVD $736, R12 + B callbackasm1(SB) + MOVD $737, R12 + B callbackasm1(SB) + MOVD $738, R12 + B callbackasm1(SB) + MOVD $739, R12 + B callbackasm1(SB) + MOVD $740, R12 + B callbackasm1(SB) + MOVD $741, R12 + B callbackasm1(SB) + MOVD $742, R12 + B callbackasm1(SB) + MOVD $743, R12 + B callbackasm1(SB) + MOVD $744, R12 + B callbackasm1(SB) + MOVD $745, R12 + B callbackasm1(SB) + MOVD $746, R12 + B callbackasm1(SB) + MOVD $747, R12 + B callbackasm1(SB) + MOVD $748, R12 + B callbackasm1(SB) + MOVD $749, R12 + B callbackasm1(SB) + MOVD $750, R12 + B callbackasm1(SB) + MOVD $751, R12 + B callbackasm1(SB) + MOVD $752, R12 + B callbackasm1(SB) + MOVD $753, R12 + B callbackasm1(SB) + MOVD $754, R12 + B callbackasm1(SB) + MOVD $755, R12 + B callbackasm1(SB) + MOVD $756, R12 + B callbackasm1(SB) + MOVD $757, R12 + B callbackasm1(SB) + MOVD $758, R12 + B callbackasm1(SB) + MOVD $759, R12 + B callbackasm1(SB) + MOVD $760, R12 + B callbackasm1(SB) + MOVD $761, R12 + B callbackasm1(SB) + MOVD $762, R12 + B callbackasm1(SB) + MOVD $763, R12 + B callbackasm1(SB) + MOVD $764, R12 + B callbackasm1(SB) + MOVD $765, R12 + B callbackasm1(SB) + MOVD $766, R12 + B callbackasm1(SB) + MOVD $767, R12 + B callbackasm1(SB) + MOVD $768, R12 + B callbackasm1(SB) + MOVD $769, R12 + B callbackasm1(SB) + MOVD $770, R12 + B callbackasm1(SB) + MOVD $771, R12 + B callbackasm1(SB) + MOVD $772, R12 + B callbackasm1(SB) + MOVD $773, R12 + B callbackasm1(SB) + MOVD $774, R12 + B callbackasm1(SB) + MOVD $775, R12 + B callbackasm1(SB) + MOVD $776, R12 + B callbackasm1(SB) + MOVD $777, R12 + B callbackasm1(SB) + MOVD $778, R12 + B callbackasm1(SB) + MOVD $779, R12 + B callbackasm1(SB) + MOVD $780, R12 + B callbackasm1(SB) + MOVD $781, R12 + B callbackasm1(SB) + MOVD $782, R12 + B callbackasm1(SB) + MOVD $783, R12 + B callbackasm1(SB) + MOVD $784, R12 + B callbackasm1(SB) + MOVD $785, R12 + B callbackasm1(SB) + MOVD $786, R12 + B callbackasm1(SB) + MOVD $787, R12 + B callbackasm1(SB) + MOVD $788, R12 + B callbackasm1(SB) + MOVD $789, R12 + B callbackasm1(SB) + MOVD $790, R12 + B callbackasm1(SB) + MOVD $791, R12 + B callbackasm1(SB) + MOVD $792, R12 + B callbackasm1(SB) + MOVD $793, R12 + B callbackasm1(SB) + MOVD $794, R12 + B callbackasm1(SB) + MOVD $795, R12 + B callbackasm1(SB) + MOVD $796, R12 + B callbackasm1(SB) + MOVD $797, R12 + B callbackasm1(SB) + MOVD $798, R12 + B callbackasm1(SB) + MOVD $799, R12 + B callbackasm1(SB) + MOVD $800, R12 + B callbackasm1(SB) + MOVD $801, R12 + B callbackasm1(SB) + MOVD $802, R12 + B callbackasm1(SB) + MOVD $803, R12 + B callbackasm1(SB) + MOVD $804, R12 + B callbackasm1(SB) + MOVD $805, R12 + B callbackasm1(SB) + MOVD $806, R12 + B callbackasm1(SB) + MOVD $807, R12 + B callbackasm1(SB) + MOVD $808, R12 + B callbackasm1(SB) + MOVD $809, R12 + B callbackasm1(SB) + MOVD $810, R12 + B callbackasm1(SB) + MOVD $811, R12 + B callbackasm1(SB) + MOVD $812, R12 + B callbackasm1(SB) + MOVD $813, R12 + B callbackasm1(SB) + MOVD $814, R12 + B callbackasm1(SB) + MOVD $815, R12 + B callbackasm1(SB) + MOVD $816, R12 + B callbackasm1(SB) + MOVD $817, R12 + B callbackasm1(SB) + MOVD $818, R12 + B callbackasm1(SB) + MOVD $819, R12 + B callbackasm1(SB) + MOVD $820, R12 + B callbackasm1(SB) + MOVD $821, R12 + B callbackasm1(SB) + MOVD $822, R12 + B callbackasm1(SB) + MOVD $823, R12 + B callbackasm1(SB) + MOVD $824, R12 + B callbackasm1(SB) + MOVD $825, R12 + B callbackasm1(SB) + MOVD $826, R12 + B callbackasm1(SB) + MOVD $827, R12 + B callbackasm1(SB) + MOVD $828, R12 + B callbackasm1(SB) + MOVD $829, R12 + B callbackasm1(SB) + MOVD $830, R12 + B callbackasm1(SB) + MOVD $831, R12 + B callbackasm1(SB) + MOVD $832, R12 + B callbackasm1(SB) + MOVD $833, R12 + B callbackasm1(SB) + MOVD $834, R12 + B callbackasm1(SB) + MOVD $835, R12 + B callbackasm1(SB) + MOVD $836, R12 + B callbackasm1(SB) + MOVD $837, R12 + B callbackasm1(SB) + MOVD $838, R12 + B callbackasm1(SB) + MOVD $839, R12 + B callbackasm1(SB) + MOVD $840, R12 + B callbackasm1(SB) + MOVD $841, R12 + B callbackasm1(SB) + MOVD $842, R12 + B callbackasm1(SB) + MOVD $843, R12 + B callbackasm1(SB) + MOVD $844, R12 + B callbackasm1(SB) + MOVD $845, R12 + B callbackasm1(SB) + MOVD $846, R12 + B callbackasm1(SB) + MOVD $847, R12 + B callbackasm1(SB) + MOVD $848, R12 + B callbackasm1(SB) + MOVD $849, R12 + B callbackasm1(SB) + MOVD $850, R12 + B callbackasm1(SB) + MOVD $851, R12 + B callbackasm1(SB) + MOVD $852, R12 + B callbackasm1(SB) + MOVD $853, R12 + B callbackasm1(SB) + MOVD $854, R12 + B callbackasm1(SB) + MOVD $855, R12 + B callbackasm1(SB) + MOVD $856, R12 + B callbackasm1(SB) + MOVD $857, R12 + B callbackasm1(SB) + MOVD $858, R12 + B callbackasm1(SB) + MOVD $859, R12 + B callbackasm1(SB) + MOVD $860, R12 + B callbackasm1(SB) + MOVD $861, R12 + B callbackasm1(SB) + MOVD $862, R12 + B callbackasm1(SB) + MOVD $863, R12 + B callbackasm1(SB) + MOVD $864, R12 + B callbackasm1(SB) + MOVD $865, R12 + B callbackasm1(SB) + MOVD $866, R12 + B callbackasm1(SB) + MOVD $867, R12 + B callbackasm1(SB) + MOVD $868, R12 + B callbackasm1(SB) + MOVD $869, R12 + B callbackasm1(SB) + MOVD $870, R12 + B callbackasm1(SB) + MOVD $871, R12 + B callbackasm1(SB) + MOVD $872, R12 + B callbackasm1(SB) + MOVD $873, R12 + B callbackasm1(SB) + MOVD $874, R12 + B callbackasm1(SB) + MOVD $875, R12 + B callbackasm1(SB) + MOVD $876, R12 + B callbackasm1(SB) + MOVD $877, R12 + B callbackasm1(SB) + MOVD $878, R12 + B callbackasm1(SB) + MOVD $879, R12 + B callbackasm1(SB) + MOVD $880, R12 + B callbackasm1(SB) + MOVD $881, R12 + B callbackasm1(SB) + MOVD $882, R12 + B callbackasm1(SB) + MOVD $883, R12 + B callbackasm1(SB) + MOVD $884, R12 + B callbackasm1(SB) + MOVD $885, R12 + B callbackasm1(SB) + MOVD $886, R12 + B callbackasm1(SB) + MOVD $887, R12 + B callbackasm1(SB) + MOVD $888, R12 + B callbackasm1(SB) + MOVD $889, R12 + B callbackasm1(SB) + MOVD $890, R12 + B callbackasm1(SB) + MOVD $891, R12 + B callbackasm1(SB) + MOVD $892, R12 + B callbackasm1(SB) + MOVD $893, R12 + B callbackasm1(SB) + MOVD $894, R12 + B callbackasm1(SB) + MOVD $895, R12 + B callbackasm1(SB) + MOVD $896, R12 + B callbackasm1(SB) + MOVD $897, R12 + B callbackasm1(SB) + MOVD $898, R12 + B callbackasm1(SB) + MOVD $899, R12 + B callbackasm1(SB) + MOVD $900, R12 + B callbackasm1(SB) + MOVD $901, R12 + B callbackasm1(SB) + MOVD $902, R12 + B callbackasm1(SB) + MOVD $903, R12 + B callbackasm1(SB) + MOVD $904, R12 + B callbackasm1(SB) + MOVD $905, R12 + B callbackasm1(SB) + MOVD $906, R12 + B callbackasm1(SB) + MOVD $907, R12 + B callbackasm1(SB) + MOVD $908, R12 + B callbackasm1(SB) + MOVD $909, R12 + B callbackasm1(SB) + MOVD $910, R12 + B callbackasm1(SB) + MOVD $911, R12 + B callbackasm1(SB) + MOVD $912, R12 + B callbackasm1(SB) + MOVD $913, R12 + B callbackasm1(SB) + MOVD $914, R12 + B callbackasm1(SB) + MOVD $915, R12 + B callbackasm1(SB) + MOVD $916, R12 + B callbackasm1(SB) + MOVD $917, R12 + B callbackasm1(SB) + MOVD $918, R12 + B callbackasm1(SB) + MOVD $919, R12 + B callbackasm1(SB) + MOVD $920, R12 + B callbackasm1(SB) + MOVD $921, R12 + B callbackasm1(SB) + MOVD $922, R12 + B callbackasm1(SB) + MOVD $923, R12 + B callbackasm1(SB) + MOVD $924, R12 + B callbackasm1(SB) + MOVD $925, R12 + B callbackasm1(SB) + MOVD $926, R12 + B callbackasm1(SB) + MOVD $927, R12 + B callbackasm1(SB) + MOVD $928, R12 + B callbackasm1(SB) + MOVD $929, R12 + B callbackasm1(SB) + MOVD $930, R12 + B callbackasm1(SB) + MOVD $931, R12 + B callbackasm1(SB) + MOVD $932, R12 + B callbackasm1(SB) + MOVD $933, R12 + B callbackasm1(SB) + MOVD $934, R12 + B callbackasm1(SB) + MOVD $935, R12 + B callbackasm1(SB) + MOVD $936, R12 + B callbackasm1(SB) + MOVD $937, R12 + B callbackasm1(SB) + MOVD $938, R12 + B callbackasm1(SB) + MOVD $939, R12 + B callbackasm1(SB) + MOVD $940, R12 + B callbackasm1(SB) + MOVD $941, R12 + B callbackasm1(SB) + MOVD $942, R12 + B callbackasm1(SB) + MOVD $943, R12 + B callbackasm1(SB) + MOVD $944, R12 + B callbackasm1(SB) + MOVD $945, R12 + B callbackasm1(SB) + MOVD $946, R12 + B callbackasm1(SB) + MOVD $947, R12 + B callbackasm1(SB) + MOVD $948, R12 + B callbackasm1(SB) + MOVD $949, R12 + B callbackasm1(SB) + MOVD $950, R12 + B callbackasm1(SB) + MOVD $951, R12 + B callbackasm1(SB) + MOVD $952, R12 + B callbackasm1(SB) + MOVD $953, R12 + B callbackasm1(SB) + MOVD $954, R12 + B callbackasm1(SB) + MOVD $955, R12 + B callbackasm1(SB) + MOVD $956, R12 + B callbackasm1(SB) + MOVD $957, R12 + B callbackasm1(SB) + MOVD $958, R12 + B callbackasm1(SB) + MOVD $959, R12 + B callbackasm1(SB) + MOVD $960, R12 + B callbackasm1(SB) + MOVD $961, R12 + B callbackasm1(SB) + MOVD $962, R12 + B callbackasm1(SB) + MOVD $963, R12 + B callbackasm1(SB) + MOVD $964, R12 + B callbackasm1(SB) + MOVD $965, R12 + B callbackasm1(SB) + MOVD $966, R12 + B callbackasm1(SB) + MOVD $967, R12 + B callbackasm1(SB) + MOVD $968, R12 + B callbackasm1(SB) + MOVD $969, R12 + B callbackasm1(SB) + MOVD $970, R12 + B callbackasm1(SB) + MOVD $971, R12 + B callbackasm1(SB) + MOVD $972, R12 + B callbackasm1(SB) + MOVD $973, R12 + B callbackasm1(SB) + MOVD $974, R12 + B callbackasm1(SB) + MOVD $975, R12 + B callbackasm1(SB) + MOVD $976, R12 + B callbackasm1(SB) + MOVD $977, R12 + B callbackasm1(SB) + MOVD $978, R12 + B callbackasm1(SB) + MOVD $979, R12 + B callbackasm1(SB) + MOVD $980, R12 + B callbackasm1(SB) + MOVD $981, R12 + B callbackasm1(SB) + MOVD $982, R12 + B callbackasm1(SB) + MOVD $983, R12 + B callbackasm1(SB) + MOVD $984, R12 + B callbackasm1(SB) + MOVD $985, R12 + B callbackasm1(SB) + MOVD $986, R12 + B callbackasm1(SB) + MOVD $987, R12 + B callbackasm1(SB) + MOVD $988, R12 + B callbackasm1(SB) + MOVD $989, R12 + B callbackasm1(SB) + MOVD $990, R12 + B callbackasm1(SB) + MOVD $991, R12 + B callbackasm1(SB) + MOVD $992, R12 + B callbackasm1(SB) + MOVD $993, R12 + B callbackasm1(SB) + MOVD $994, R12 + B callbackasm1(SB) + MOVD $995, R12 + B callbackasm1(SB) + MOVD $996, R12 + B callbackasm1(SB) + MOVD $997, R12 + B callbackasm1(SB) + MOVD $998, R12 + B callbackasm1(SB) + MOVD $999, R12 + B callbackasm1(SB) + MOVD $1000, R12 + B callbackasm1(SB) + MOVD $1001, R12 + B callbackasm1(SB) + MOVD $1002, R12 + B callbackasm1(SB) + MOVD $1003, R12 + B callbackasm1(SB) + MOVD $1004, R12 + B callbackasm1(SB) + MOVD $1005, R12 + B callbackasm1(SB) + MOVD $1006, R12 + B callbackasm1(SB) + MOVD $1007, R12 + B callbackasm1(SB) + MOVD $1008, R12 + B callbackasm1(SB) + MOVD $1009, R12 + B callbackasm1(SB) + MOVD $1010, R12 + B callbackasm1(SB) + MOVD $1011, R12 + B callbackasm1(SB) + MOVD $1012, R12 + B callbackasm1(SB) + MOVD $1013, R12 + B callbackasm1(SB) + MOVD $1014, R12 + B callbackasm1(SB) + MOVD $1015, R12 + B callbackasm1(SB) + MOVD $1016, R12 + B callbackasm1(SB) + MOVD $1017, R12 + B callbackasm1(SB) + MOVD $1018, R12 + B callbackasm1(SB) + MOVD $1019, R12 + B callbackasm1(SB) + MOVD $1020, R12 + B callbackasm1(SB) + MOVD $1021, R12 + B callbackasm1(SB) + MOVD $1022, R12 + B callbackasm1(SB) + MOVD $1023, R12 + B callbackasm1(SB) + MOVD $1024, R12 + B callbackasm1(SB) + MOVD $1025, R12 + B callbackasm1(SB) + MOVD $1026, R12 + B callbackasm1(SB) + MOVD $1027, R12 + B callbackasm1(SB) + MOVD $1028, R12 + B callbackasm1(SB) + MOVD $1029, R12 + B callbackasm1(SB) + MOVD $1030, R12 + B callbackasm1(SB) + MOVD $1031, R12 + B callbackasm1(SB) + MOVD $1032, R12 + B callbackasm1(SB) + MOVD $1033, R12 + B callbackasm1(SB) + MOVD $1034, R12 + B callbackasm1(SB) + MOVD $1035, R12 + B callbackasm1(SB) + MOVD $1036, R12 + B callbackasm1(SB) + MOVD $1037, R12 + B callbackasm1(SB) + MOVD $1038, R12 + B callbackasm1(SB) + MOVD $1039, R12 + B callbackasm1(SB) + MOVD $1040, R12 + B callbackasm1(SB) + MOVD $1041, R12 + B callbackasm1(SB) + MOVD $1042, R12 + B callbackasm1(SB) + MOVD $1043, R12 + B callbackasm1(SB) + MOVD $1044, R12 + B callbackasm1(SB) + MOVD $1045, R12 + B callbackasm1(SB) + MOVD $1046, R12 + B callbackasm1(SB) + MOVD $1047, R12 + B callbackasm1(SB) + MOVD $1048, R12 + B callbackasm1(SB) + MOVD $1049, R12 + B callbackasm1(SB) + MOVD $1050, R12 + B callbackasm1(SB) + MOVD $1051, R12 + B callbackasm1(SB) + MOVD $1052, R12 + B callbackasm1(SB) + MOVD $1053, R12 + B callbackasm1(SB) + MOVD $1054, R12 + B callbackasm1(SB) + MOVD $1055, R12 + B callbackasm1(SB) + MOVD $1056, R12 + B callbackasm1(SB) + MOVD $1057, R12 + B callbackasm1(SB) + MOVD $1058, R12 + B callbackasm1(SB) + MOVD $1059, R12 + B callbackasm1(SB) + MOVD $1060, R12 + B callbackasm1(SB) + MOVD $1061, R12 + B callbackasm1(SB) + MOVD $1062, R12 + B callbackasm1(SB) + MOVD $1063, R12 + B callbackasm1(SB) + MOVD $1064, R12 + B callbackasm1(SB) + MOVD $1065, R12 + B callbackasm1(SB) + MOVD $1066, R12 + B callbackasm1(SB) + MOVD $1067, R12 + B callbackasm1(SB) + MOVD $1068, R12 + B callbackasm1(SB) + MOVD $1069, R12 + B callbackasm1(SB) + MOVD $1070, R12 + B callbackasm1(SB) + MOVD $1071, R12 + B callbackasm1(SB) + MOVD $1072, R12 + B callbackasm1(SB) + MOVD $1073, R12 + B callbackasm1(SB) + MOVD $1074, R12 + B callbackasm1(SB) + MOVD $1075, R12 + B callbackasm1(SB) + MOVD $1076, R12 + B callbackasm1(SB) + MOVD $1077, R12 + B callbackasm1(SB) + MOVD $1078, R12 + B callbackasm1(SB) + MOVD $1079, R12 + B callbackasm1(SB) + MOVD $1080, R12 + B callbackasm1(SB) + MOVD $1081, R12 + B callbackasm1(SB) + MOVD $1082, R12 + B callbackasm1(SB) + MOVD $1083, R12 + B callbackasm1(SB) + MOVD $1084, R12 + B callbackasm1(SB) + MOVD $1085, R12 + B callbackasm1(SB) + MOVD $1086, R12 + B callbackasm1(SB) + MOVD $1087, R12 + B callbackasm1(SB) + MOVD $1088, R12 + B callbackasm1(SB) + MOVD $1089, R12 + B callbackasm1(SB) + MOVD $1090, R12 + B callbackasm1(SB) + MOVD $1091, R12 + B callbackasm1(SB) + MOVD $1092, R12 + B callbackasm1(SB) + MOVD $1093, R12 + B callbackasm1(SB) + MOVD $1094, R12 + B callbackasm1(SB) + MOVD $1095, R12 + B callbackasm1(SB) + MOVD $1096, R12 + B callbackasm1(SB) + MOVD $1097, R12 + B callbackasm1(SB) + MOVD $1098, R12 + B callbackasm1(SB) + MOVD $1099, R12 + B callbackasm1(SB) + MOVD $1100, R12 + B callbackasm1(SB) + MOVD $1101, R12 + B callbackasm1(SB) + MOVD $1102, R12 + B callbackasm1(SB) + MOVD $1103, R12 + B callbackasm1(SB) + MOVD $1104, R12 + B callbackasm1(SB) + MOVD $1105, R12 + B callbackasm1(SB) + MOVD $1106, R12 + B callbackasm1(SB) + MOVD $1107, R12 + B callbackasm1(SB) + MOVD $1108, R12 + B callbackasm1(SB) + MOVD $1109, R12 + B callbackasm1(SB) + MOVD $1110, R12 + B callbackasm1(SB) + MOVD $1111, R12 + B callbackasm1(SB) + MOVD $1112, R12 + B callbackasm1(SB) + MOVD $1113, R12 + B callbackasm1(SB) + MOVD $1114, R12 + B callbackasm1(SB) + MOVD $1115, R12 + B callbackasm1(SB) + MOVD $1116, R12 + B callbackasm1(SB) + MOVD $1117, R12 + B callbackasm1(SB) + MOVD $1118, R12 + B callbackasm1(SB) + MOVD $1119, R12 + B callbackasm1(SB) + MOVD $1120, R12 + B callbackasm1(SB) + MOVD $1121, R12 + B callbackasm1(SB) + MOVD $1122, R12 + B callbackasm1(SB) + MOVD $1123, R12 + B callbackasm1(SB) + MOVD $1124, R12 + B callbackasm1(SB) + MOVD $1125, R12 + B callbackasm1(SB) + MOVD $1126, R12 + B callbackasm1(SB) + MOVD $1127, R12 + B callbackasm1(SB) + MOVD $1128, R12 + B callbackasm1(SB) + MOVD $1129, R12 + B callbackasm1(SB) + MOVD $1130, R12 + B callbackasm1(SB) + MOVD $1131, R12 + B callbackasm1(SB) + MOVD $1132, R12 + B callbackasm1(SB) + MOVD $1133, R12 + B callbackasm1(SB) + MOVD $1134, R12 + B callbackasm1(SB) + MOVD $1135, R12 + B callbackasm1(SB) + MOVD $1136, R12 + B callbackasm1(SB) + MOVD $1137, R12 + B callbackasm1(SB) + MOVD $1138, R12 + B callbackasm1(SB) + MOVD $1139, R12 + B callbackasm1(SB) + MOVD $1140, R12 + B callbackasm1(SB) + MOVD $1141, R12 + B callbackasm1(SB) + MOVD $1142, R12 + B callbackasm1(SB) + MOVD $1143, R12 + B callbackasm1(SB) + MOVD $1144, R12 + B callbackasm1(SB) + MOVD $1145, R12 + B callbackasm1(SB) + MOVD $1146, R12 + B callbackasm1(SB) + MOVD $1147, R12 + B callbackasm1(SB) + MOVD $1148, R12 + B callbackasm1(SB) + MOVD $1149, R12 + B callbackasm1(SB) + MOVD $1150, R12 + B callbackasm1(SB) + MOVD $1151, R12 + B callbackasm1(SB) + MOVD $1152, R12 + B callbackasm1(SB) + MOVD $1153, R12 + B callbackasm1(SB) + MOVD $1154, R12 + B callbackasm1(SB) + MOVD $1155, R12 + B callbackasm1(SB) + MOVD $1156, R12 + B callbackasm1(SB) + MOVD $1157, R12 + B callbackasm1(SB) + MOVD $1158, R12 + B callbackasm1(SB) + MOVD $1159, R12 + B callbackasm1(SB) + MOVD $1160, R12 + B callbackasm1(SB) + MOVD $1161, R12 + B callbackasm1(SB) + MOVD $1162, R12 + B callbackasm1(SB) + MOVD $1163, R12 + B callbackasm1(SB) + MOVD $1164, R12 + B callbackasm1(SB) + MOVD $1165, R12 + B callbackasm1(SB) + MOVD $1166, R12 + B callbackasm1(SB) + MOVD $1167, R12 + B callbackasm1(SB) + MOVD $1168, R12 + B callbackasm1(SB) + MOVD $1169, R12 + B callbackasm1(SB) + MOVD $1170, R12 + B callbackasm1(SB) + MOVD $1171, R12 + B callbackasm1(SB) + MOVD $1172, R12 + B callbackasm1(SB) + MOVD $1173, R12 + B callbackasm1(SB) + MOVD $1174, R12 + B callbackasm1(SB) + MOVD $1175, R12 + B callbackasm1(SB) + MOVD $1176, R12 + B callbackasm1(SB) + MOVD $1177, R12 + B callbackasm1(SB) + MOVD $1178, R12 + B callbackasm1(SB) + MOVD $1179, R12 + B callbackasm1(SB) + MOVD $1180, R12 + B callbackasm1(SB) + MOVD $1181, R12 + B callbackasm1(SB) + MOVD $1182, R12 + B callbackasm1(SB) + MOVD $1183, R12 + B callbackasm1(SB) + MOVD $1184, R12 + B callbackasm1(SB) + MOVD $1185, R12 + B callbackasm1(SB) + MOVD $1186, R12 + B callbackasm1(SB) + MOVD $1187, R12 + B callbackasm1(SB) + MOVD $1188, R12 + B callbackasm1(SB) + MOVD $1189, R12 + B callbackasm1(SB) + MOVD $1190, R12 + B callbackasm1(SB) + MOVD $1191, R12 + B callbackasm1(SB) + MOVD $1192, R12 + B callbackasm1(SB) + MOVD $1193, R12 + B callbackasm1(SB) + MOVD $1194, R12 + B callbackasm1(SB) + MOVD $1195, R12 + B callbackasm1(SB) + MOVD $1196, R12 + B callbackasm1(SB) + MOVD $1197, R12 + B callbackasm1(SB) + MOVD $1198, R12 + B callbackasm1(SB) + MOVD $1199, R12 + B callbackasm1(SB) + MOVD $1200, R12 + B callbackasm1(SB) + MOVD $1201, R12 + B callbackasm1(SB) + MOVD $1202, R12 + B callbackasm1(SB) + MOVD $1203, R12 + B callbackasm1(SB) + MOVD $1204, R12 + B callbackasm1(SB) + MOVD $1205, R12 + B callbackasm1(SB) + MOVD $1206, R12 + B callbackasm1(SB) + MOVD $1207, R12 + B callbackasm1(SB) + MOVD $1208, R12 + B callbackasm1(SB) + MOVD $1209, R12 + B callbackasm1(SB) + MOVD $1210, R12 + B callbackasm1(SB) + MOVD $1211, R12 + B callbackasm1(SB) + MOVD $1212, R12 + B callbackasm1(SB) + MOVD $1213, R12 + B callbackasm1(SB) + MOVD $1214, R12 + B callbackasm1(SB) + MOVD $1215, R12 + B callbackasm1(SB) + MOVD $1216, R12 + B callbackasm1(SB) + MOVD $1217, R12 + B callbackasm1(SB) + MOVD $1218, R12 + B callbackasm1(SB) + MOVD $1219, R12 + B callbackasm1(SB) + MOVD $1220, R12 + B callbackasm1(SB) + MOVD $1221, R12 + B callbackasm1(SB) + MOVD $1222, R12 + B callbackasm1(SB) + MOVD $1223, R12 + B callbackasm1(SB) + MOVD $1224, R12 + B callbackasm1(SB) + MOVD $1225, R12 + B callbackasm1(SB) + MOVD $1226, R12 + B callbackasm1(SB) + MOVD $1227, R12 + B callbackasm1(SB) + MOVD $1228, R12 + B callbackasm1(SB) + MOVD $1229, R12 + B callbackasm1(SB) + MOVD $1230, R12 + B callbackasm1(SB) + MOVD $1231, R12 + B callbackasm1(SB) + MOVD $1232, R12 + B callbackasm1(SB) + MOVD $1233, R12 + B callbackasm1(SB) + MOVD $1234, R12 + B callbackasm1(SB) + MOVD $1235, R12 + B callbackasm1(SB) + MOVD $1236, R12 + B callbackasm1(SB) + MOVD $1237, R12 + B callbackasm1(SB) + MOVD $1238, R12 + B callbackasm1(SB) + MOVD $1239, R12 + B callbackasm1(SB) + MOVD $1240, R12 + B callbackasm1(SB) + MOVD $1241, R12 + B callbackasm1(SB) + MOVD $1242, R12 + B callbackasm1(SB) + MOVD $1243, R12 + B callbackasm1(SB) + MOVD $1244, R12 + B callbackasm1(SB) + MOVD $1245, R12 + B callbackasm1(SB) + MOVD $1246, R12 + B callbackasm1(SB) + MOVD $1247, R12 + B callbackasm1(SB) + MOVD $1248, R12 + B callbackasm1(SB) + MOVD $1249, R12 + B callbackasm1(SB) + MOVD $1250, R12 + B callbackasm1(SB) + MOVD $1251, R12 + B callbackasm1(SB) + MOVD $1252, R12 + B callbackasm1(SB) + MOVD $1253, R12 + B callbackasm1(SB) + MOVD $1254, R12 + B callbackasm1(SB) + MOVD $1255, R12 + B callbackasm1(SB) + MOVD $1256, R12 + B callbackasm1(SB) + MOVD $1257, R12 + B callbackasm1(SB) + MOVD $1258, R12 + B callbackasm1(SB) + MOVD $1259, R12 + B callbackasm1(SB) + MOVD $1260, R12 + B callbackasm1(SB) + MOVD $1261, R12 + B callbackasm1(SB) + MOVD $1262, R12 + B callbackasm1(SB) + MOVD $1263, R12 + B callbackasm1(SB) + MOVD $1264, R12 + B callbackasm1(SB) + MOVD $1265, R12 + B callbackasm1(SB) + MOVD $1266, R12 + B callbackasm1(SB) + MOVD $1267, R12 + B callbackasm1(SB) + MOVD $1268, R12 + B callbackasm1(SB) + MOVD $1269, R12 + B callbackasm1(SB) + MOVD $1270, R12 + B callbackasm1(SB) + MOVD $1271, R12 + B callbackasm1(SB) + MOVD $1272, R12 + B callbackasm1(SB) + MOVD $1273, R12 + B callbackasm1(SB) + MOVD $1274, R12 + B callbackasm1(SB) + MOVD $1275, R12 + B callbackasm1(SB) + MOVD $1276, R12 + B callbackasm1(SB) + MOVD $1277, R12 + B callbackasm1(SB) + MOVD $1278, R12 + B callbackasm1(SB) + MOVD $1279, R12 + B callbackasm1(SB) + MOVD $1280, R12 + B callbackasm1(SB) + MOVD $1281, R12 + B callbackasm1(SB) + MOVD $1282, R12 + B callbackasm1(SB) + MOVD $1283, R12 + B callbackasm1(SB) + MOVD $1284, R12 + B callbackasm1(SB) + MOVD $1285, R12 + B callbackasm1(SB) + MOVD $1286, R12 + B callbackasm1(SB) + MOVD $1287, R12 + B callbackasm1(SB) + MOVD $1288, R12 + B callbackasm1(SB) + MOVD $1289, R12 + B callbackasm1(SB) + MOVD $1290, R12 + B callbackasm1(SB) + MOVD $1291, R12 + B callbackasm1(SB) + MOVD $1292, R12 + B callbackasm1(SB) + MOVD $1293, R12 + B callbackasm1(SB) + MOVD $1294, R12 + B callbackasm1(SB) + MOVD $1295, R12 + B callbackasm1(SB) + MOVD $1296, R12 + B callbackasm1(SB) + MOVD $1297, R12 + B callbackasm1(SB) + MOVD $1298, R12 + B callbackasm1(SB) + MOVD $1299, R12 + B callbackasm1(SB) + MOVD $1300, R12 + B callbackasm1(SB) + MOVD $1301, R12 + B callbackasm1(SB) + MOVD $1302, R12 + B callbackasm1(SB) + MOVD $1303, R12 + B callbackasm1(SB) + MOVD $1304, R12 + B callbackasm1(SB) + MOVD $1305, R12 + B callbackasm1(SB) + MOVD $1306, R12 + B callbackasm1(SB) + MOVD $1307, R12 + B callbackasm1(SB) + MOVD $1308, R12 + B callbackasm1(SB) + MOVD $1309, R12 + B callbackasm1(SB) + MOVD $1310, R12 + B callbackasm1(SB) + MOVD $1311, R12 + B callbackasm1(SB) + MOVD $1312, R12 + B callbackasm1(SB) + MOVD $1313, R12 + B callbackasm1(SB) + MOVD $1314, R12 + B callbackasm1(SB) + MOVD $1315, R12 + B callbackasm1(SB) + MOVD $1316, R12 + B callbackasm1(SB) + MOVD $1317, R12 + B callbackasm1(SB) + MOVD $1318, R12 + B callbackasm1(SB) + MOVD $1319, R12 + B callbackasm1(SB) + MOVD $1320, R12 + B callbackasm1(SB) + MOVD $1321, R12 + B callbackasm1(SB) + MOVD $1322, R12 + B callbackasm1(SB) + MOVD $1323, R12 + B callbackasm1(SB) + MOVD $1324, R12 + B callbackasm1(SB) + MOVD $1325, R12 + B callbackasm1(SB) + MOVD $1326, R12 + B callbackasm1(SB) + MOVD $1327, R12 + B callbackasm1(SB) + MOVD $1328, R12 + B callbackasm1(SB) + MOVD $1329, R12 + B callbackasm1(SB) + MOVD $1330, R12 + B callbackasm1(SB) + MOVD $1331, R12 + B callbackasm1(SB) + MOVD $1332, R12 + B callbackasm1(SB) + MOVD $1333, R12 + B callbackasm1(SB) + MOVD $1334, R12 + B callbackasm1(SB) + MOVD $1335, R12 + B callbackasm1(SB) + MOVD $1336, R12 + B callbackasm1(SB) + MOVD $1337, R12 + B callbackasm1(SB) + MOVD $1338, R12 + B callbackasm1(SB) + MOVD $1339, R12 + B callbackasm1(SB) + MOVD $1340, R12 + B callbackasm1(SB) + MOVD $1341, R12 + B callbackasm1(SB) + MOVD $1342, R12 + B callbackasm1(SB) + MOVD $1343, R12 + B callbackasm1(SB) + MOVD $1344, R12 + B callbackasm1(SB) + MOVD $1345, R12 + B callbackasm1(SB) + MOVD $1346, R12 + B callbackasm1(SB) + MOVD $1347, R12 + B callbackasm1(SB) + MOVD $1348, R12 + B callbackasm1(SB) + MOVD $1349, R12 + B callbackasm1(SB) + MOVD $1350, R12 + B callbackasm1(SB) + MOVD $1351, R12 + B callbackasm1(SB) + MOVD $1352, R12 + B callbackasm1(SB) + MOVD $1353, R12 + B callbackasm1(SB) + MOVD $1354, R12 + B callbackasm1(SB) + MOVD $1355, R12 + B callbackasm1(SB) + MOVD $1356, R12 + B callbackasm1(SB) + MOVD $1357, R12 + B callbackasm1(SB) + MOVD $1358, R12 + B callbackasm1(SB) + MOVD $1359, R12 + B callbackasm1(SB) + MOVD $1360, R12 + B callbackasm1(SB) + MOVD $1361, R12 + B callbackasm1(SB) + MOVD $1362, R12 + B callbackasm1(SB) + MOVD $1363, R12 + B callbackasm1(SB) + MOVD $1364, R12 + B callbackasm1(SB) + MOVD $1365, R12 + B callbackasm1(SB) + MOVD $1366, R12 + B callbackasm1(SB) + MOVD $1367, R12 + B callbackasm1(SB) + MOVD $1368, R12 + B callbackasm1(SB) + MOVD $1369, R12 + B callbackasm1(SB) + MOVD $1370, R12 + B callbackasm1(SB) + MOVD $1371, R12 + B callbackasm1(SB) + MOVD $1372, R12 + B callbackasm1(SB) + MOVD $1373, R12 + B callbackasm1(SB) + MOVD $1374, R12 + B callbackasm1(SB) + MOVD $1375, R12 + B callbackasm1(SB) + MOVD $1376, R12 + B callbackasm1(SB) + MOVD $1377, R12 + B callbackasm1(SB) + MOVD $1378, R12 + B callbackasm1(SB) + MOVD $1379, R12 + B callbackasm1(SB) + MOVD $1380, R12 + B callbackasm1(SB) + MOVD $1381, R12 + B callbackasm1(SB) + MOVD $1382, R12 + B callbackasm1(SB) + MOVD $1383, R12 + B callbackasm1(SB) + MOVD $1384, R12 + B callbackasm1(SB) + MOVD $1385, R12 + B callbackasm1(SB) + MOVD $1386, R12 + B callbackasm1(SB) + MOVD $1387, R12 + B callbackasm1(SB) + MOVD $1388, R12 + B callbackasm1(SB) + MOVD $1389, R12 + B callbackasm1(SB) + MOVD $1390, R12 + B callbackasm1(SB) + MOVD $1391, R12 + B callbackasm1(SB) + MOVD $1392, R12 + B callbackasm1(SB) + MOVD $1393, R12 + B callbackasm1(SB) + MOVD $1394, R12 + B callbackasm1(SB) + MOVD $1395, R12 + B callbackasm1(SB) + MOVD $1396, R12 + B callbackasm1(SB) + MOVD $1397, R12 + B callbackasm1(SB) + MOVD $1398, R12 + B callbackasm1(SB) + MOVD $1399, R12 + B callbackasm1(SB) + MOVD $1400, R12 + B callbackasm1(SB) + MOVD $1401, R12 + B callbackasm1(SB) + MOVD $1402, R12 + B callbackasm1(SB) + MOVD $1403, R12 + B callbackasm1(SB) + MOVD $1404, R12 + B callbackasm1(SB) + MOVD $1405, R12 + B callbackasm1(SB) + MOVD $1406, R12 + B callbackasm1(SB) + MOVD $1407, R12 + B callbackasm1(SB) + MOVD $1408, R12 + B callbackasm1(SB) + MOVD $1409, R12 + B callbackasm1(SB) + MOVD $1410, R12 + B callbackasm1(SB) + MOVD $1411, R12 + B callbackasm1(SB) + MOVD $1412, R12 + B callbackasm1(SB) + MOVD $1413, R12 + B callbackasm1(SB) + MOVD $1414, R12 + B callbackasm1(SB) + MOVD $1415, R12 + B callbackasm1(SB) + MOVD $1416, R12 + B callbackasm1(SB) + MOVD $1417, R12 + B callbackasm1(SB) + MOVD $1418, R12 + B callbackasm1(SB) + MOVD $1419, R12 + B callbackasm1(SB) + MOVD $1420, R12 + B callbackasm1(SB) + MOVD $1421, R12 + B callbackasm1(SB) + MOVD $1422, R12 + B callbackasm1(SB) + MOVD $1423, R12 + B callbackasm1(SB) + MOVD $1424, R12 + B callbackasm1(SB) + MOVD $1425, R12 + B callbackasm1(SB) + MOVD $1426, R12 + B callbackasm1(SB) + MOVD $1427, R12 + B callbackasm1(SB) + MOVD $1428, R12 + B callbackasm1(SB) + MOVD $1429, R12 + B callbackasm1(SB) + MOVD $1430, R12 + B callbackasm1(SB) + MOVD $1431, R12 + B callbackasm1(SB) + MOVD $1432, R12 + B callbackasm1(SB) + MOVD $1433, R12 + B callbackasm1(SB) + MOVD $1434, R12 + B callbackasm1(SB) + MOVD $1435, R12 + B callbackasm1(SB) + MOVD $1436, R12 + B callbackasm1(SB) + MOVD $1437, R12 + B callbackasm1(SB) + MOVD $1438, R12 + B callbackasm1(SB) + MOVD $1439, R12 + B callbackasm1(SB) + MOVD $1440, R12 + B callbackasm1(SB) + MOVD $1441, R12 + B callbackasm1(SB) + MOVD $1442, R12 + B callbackasm1(SB) + MOVD $1443, R12 + B callbackasm1(SB) + MOVD $1444, R12 + B callbackasm1(SB) + MOVD $1445, R12 + B callbackasm1(SB) + MOVD $1446, R12 + B callbackasm1(SB) + MOVD $1447, R12 + B callbackasm1(SB) + MOVD $1448, R12 + B callbackasm1(SB) + MOVD $1449, R12 + B callbackasm1(SB) + MOVD $1450, R12 + B callbackasm1(SB) + MOVD $1451, R12 + B callbackasm1(SB) + MOVD $1452, R12 + B callbackasm1(SB) + MOVD $1453, R12 + B callbackasm1(SB) + MOVD $1454, R12 + B callbackasm1(SB) + MOVD $1455, R12 + B callbackasm1(SB) + MOVD $1456, R12 + B callbackasm1(SB) + MOVD $1457, R12 + B callbackasm1(SB) + MOVD $1458, R12 + B callbackasm1(SB) + MOVD $1459, R12 + B callbackasm1(SB) + MOVD $1460, R12 + B callbackasm1(SB) + MOVD $1461, R12 + B callbackasm1(SB) + MOVD $1462, R12 + B callbackasm1(SB) + MOVD $1463, R12 + B callbackasm1(SB) + MOVD $1464, R12 + B callbackasm1(SB) + MOVD $1465, R12 + B callbackasm1(SB) + MOVD $1466, R12 + B callbackasm1(SB) + MOVD $1467, R12 + B callbackasm1(SB) + MOVD $1468, R12 + B callbackasm1(SB) + MOVD $1469, R12 + B callbackasm1(SB) + MOVD $1470, R12 + B callbackasm1(SB) + MOVD $1471, R12 + B callbackasm1(SB) + MOVD $1472, R12 + B callbackasm1(SB) + MOVD $1473, R12 + B callbackasm1(SB) + MOVD $1474, R12 + B callbackasm1(SB) + MOVD $1475, R12 + B callbackasm1(SB) + MOVD $1476, R12 + B callbackasm1(SB) + MOVD $1477, R12 + B callbackasm1(SB) + MOVD $1478, R12 + B callbackasm1(SB) + MOVD $1479, R12 + B callbackasm1(SB) + MOVD $1480, R12 + B callbackasm1(SB) + MOVD $1481, R12 + B callbackasm1(SB) + MOVD $1482, R12 + B callbackasm1(SB) + MOVD $1483, R12 + B callbackasm1(SB) + MOVD $1484, R12 + B callbackasm1(SB) + MOVD $1485, R12 + B callbackasm1(SB) + MOVD $1486, R12 + B callbackasm1(SB) + MOVD $1487, R12 + B callbackasm1(SB) + MOVD $1488, R12 + B callbackasm1(SB) + MOVD $1489, R12 + B callbackasm1(SB) + MOVD $1490, R12 + B callbackasm1(SB) + MOVD $1491, R12 + B callbackasm1(SB) + MOVD $1492, R12 + B callbackasm1(SB) + MOVD $1493, R12 + B callbackasm1(SB) + MOVD $1494, R12 + B callbackasm1(SB) + MOVD $1495, R12 + B callbackasm1(SB) + MOVD $1496, R12 + B callbackasm1(SB) + MOVD $1497, R12 + B callbackasm1(SB) + MOVD $1498, R12 + B callbackasm1(SB) + MOVD $1499, R12 + B callbackasm1(SB) + MOVD $1500, R12 + B callbackasm1(SB) + MOVD $1501, R12 + B callbackasm1(SB) + MOVD $1502, R12 + B callbackasm1(SB) + MOVD $1503, R12 + B callbackasm1(SB) + MOVD $1504, R12 + B callbackasm1(SB) + MOVD $1505, R12 + B callbackasm1(SB) + MOVD $1506, R12 + B callbackasm1(SB) + MOVD $1507, R12 + B callbackasm1(SB) + MOVD $1508, R12 + B callbackasm1(SB) + MOVD $1509, R12 + B callbackasm1(SB) + MOVD $1510, R12 + B callbackasm1(SB) + MOVD $1511, R12 + B callbackasm1(SB) + MOVD $1512, R12 + B callbackasm1(SB) + MOVD $1513, R12 + B callbackasm1(SB) + MOVD $1514, R12 + B callbackasm1(SB) + MOVD $1515, R12 + B callbackasm1(SB) + MOVD $1516, R12 + B callbackasm1(SB) + MOVD $1517, R12 + B callbackasm1(SB) + MOVD $1518, R12 + B callbackasm1(SB) + MOVD $1519, R12 + B callbackasm1(SB) + MOVD $1520, R12 + B callbackasm1(SB) + MOVD $1521, R12 + B callbackasm1(SB) + MOVD $1522, R12 + B callbackasm1(SB) + MOVD $1523, R12 + B callbackasm1(SB) + MOVD $1524, R12 + B callbackasm1(SB) + MOVD $1525, R12 + B callbackasm1(SB) + MOVD $1526, R12 + B callbackasm1(SB) + MOVD $1527, R12 + B callbackasm1(SB) + MOVD $1528, R12 + B callbackasm1(SB) + MOVD $1529, R12 + B callbackasm1(SB) + MOVD $1530, R12 + B callbackasm1(SB) + MOVD $1531, R12 + B callbackasm1(SB) + MOVD $1532, R12 + B callbackasm1(SB) + MOVD $1533, R12 + B callbackasm1(SB) + MOVD $1534, R12 + B callbackasm1(SB) + MOVD $1535, R12 + B callbackasm1(SB) + MOVD $1536, R12 + B callbackasm1(SB) + MOVD $1537, R12 + B callbackasm1(SB) + MOVD $1538, R12 + B callbackasm1(SB) + MOVD $1539, R12 + B callbackasm1(SB) + MOVD $1540, R12 + B callbackasm1(SB) + MOVD $1541, R12 + B callbackasm1(SB) + MOVD $1542, R12 + B callbackasm1(SB) + MOVD $1543, R12 + B callbackasm1(SB) + MOVD $1544, R12 + B callbackasm1(SB) + MOVD $1545, R12 + B callbackasm1(SB) + MOVD $1546, R12 + B callbackasm1(SB) + MOVD $1547, R12 + B callbackasm1(SB) + MOVD $1548, R12 + B callbackasm1(SB) + MOVD $1549, R12 + B callbackasm1(SB) + MOVD $1550, R12 + B callbackasm1(SB) + MOVD $1551, R12 + B callbackasm1(SB) + MOVD $1552, R12 + B callbackasm1(SB) + MOVD $1553, R12 + B callbackasm1(SB) + MOVD $1554, R12 + B callbackasm1(SB) + MOVD $1555, R12 + B callbackasm1(SB) + MOVD $1556, R12 + B callbackasm1(SB) + MOVD $1557, R12 + B callbackasm1(SB) + MOVD $1558, R12 + B callbackasm1(SB) + MOVD $1559, R12 + B callbackasm1(SB) + MOVD $1560, R12 + B callbackasm1(SB) + MOVD $1561, R12 + B callbackasm1(SB) + MOVD $1562, R12 + B callbackasm1(SB) + MOVD $1563, R12 + B callbackasm1(SB) + MOVD $1564, R12 + B callbackasm1(SB) + MOVD $1565, R12 + B callbackasm1(SB) + MOVD $1566, R12 + B callbackasm1(SB) + MOVD $1567, R12 + B callbackasm1(SB) + MOVD $1568, R12 + B callbackasm1(SB) + MOVD $1569, R12 + B callbackasm1(SB) + MOVD $1570, R12 + B callbackasm1(SB) + MOVD $1571, R12 + B callbackasm1(SB) + MOVD $1572, R12 + B callbackasm1(SB) + MOVD $1573, R12 + B callbackasm1(SB) + MOVD $1574, R12 + B callbackasm1(SB) + MOVD $1575, R12 + B callbackasm1(SB) + MOVD $1576, R12 + B callbackasm1(SB) + MOVD $1577, R12 + B callbackasm1(SB) + MOVD $1578, R12 + B callbackasm1(SB) + MOVD $1579, R12 + B callbackasm1(SB) + MOVD $1580, R12 + B callbackasm1(SB) + MOVD $1581, R12 + B callbackasm1(SB) + MOVD $1582, R12 + B callbackasm1(SB) + MOVD $1583, R12 + B callbackasm1(SB) + MOVD $1584, R12 + B callbackasm1(SB) + MOVD $1585, R12 + B callbackasm1(SB) + MOVD $1586, R12 + B callbackasm1(SB) + MOVD $1587, R12 + B callbackasm1(SB) + MOVD $1588, R12 + B callbackasm1(SB) + MOVD $1589, R12 + B callbackasm1(SB) + MOVD $1590, R12 + B callbackasm1(SB) + MOVD $1591, R12 + B callbackasm1(SB) + MOVD $1592, R12 + B callbackasm1(SB) + MOVD $1593, R12 + B callbackasm1(SB) + MOVD $1594, R12 + B callbackasm1(SB) + MOVD $1595, R12 + B callbackasm1(SB) + MOVD $1596, R12 + B callbackasm1(SB) + MOVD $1597, R12 + B callbackasm1(SB) + MOVD $1598, R12 + B callbackasm1(SB) + MOVD $1599, R12 + B callbackasm1(SB) + MOVD $1600, R12 + B callbackasm1(SB) + MOVD $1601, R12 + B callbackasm1(SB) + MOVD $1602, R12 + B callbackasm1(SB) + MOVD $1603, R12 + B callbackasm1(SB) + MOVD $1604, R12 + B callbackasm1(SB) + MOVD $1605, R12 + B callbackasm1(SB) + MOVD $1606, R12 + B callbackasm1(SB) + MOVD $1607, R12 + B callbackasm1(SB) + MOVD $1608, R12 + B callbackasm1(SB) + MOVD $1609, R12 + B callbackasm1(SB) + MOVD $1610, R12 + B callbackasm1(SB) + MOVD $1611, R12 + B callbackasm1(SB) + MOVD $1612, R12 + B callbackasm1(SB) + MOVD $1613, R12 + B callbackasm1(SB) + MOVD $1614, R12 + B callbackasm1(SB) + MOVD $1615, R12 + B callbackasm1(SB) + MOVD $1616, R12 + B callbackasm1(SB) + MOVD $1617, R12 + B callbackasm1(SB) + MOVD $1618, R12 + B callbackasm1(SB) + MOVD $1619, R12 + B callbackasm1(SB) + MOVD $1620, R12 + B callbackasm1(SB) + MOVD $1621, R12 + B callbackasm1(SB) + MOVD $1622, R12 + B callbackasm1(SB) + MOVD $1623, R12 + B callbackasm1(SB) + MOVD $1624, R12 + B callbackasm1(SB) + MOVD $1625, R12 + B callbackasm1(SB) + MOVD $1626, R12 + B callbackasm1(SB) + MOVD $1627, R12 + B callbackasm1(SB) + MOVD $1628, R12 + B callbackasm1(SB) + MOVD $1629, R12 + B callbackasm1(SB) + MOVD $1630, R12 + B callbackasm1(SB) + MOVD $1631, R12 + B callbackasm1(SB) + MOVD $1632, R12 + B callbackasm1(SB) + MOVD $1633, R12 + B callbackasm1(SB) + MOVD $1634, R12 + B callbackasm1(SB) + MOVD $1635, R12 + B callbackasm1(SB) + MOVD $1636, R12 + B callbackasm1(SB) + MOVD $1637, R12 + B callbackasm1(SB) + MOVD $1638, R12 + B callbackasm1(SB) + MOVD $1639, R12 + B callbackasm1(SB) + MOVD $1640, R12 + B callbackasm1(SB) + MOVD $1641, R12 + B callbackasm1(SB) + MOVD $1642, R12 + B callbackasm1(SB) + MOVD $1643, R12 + B callbackasm1(SB) + MOVD $1644, R12 + B callbackasm1(SB) + MOVD $1645, R12 + B callbackasm1(SB) + MOVD $1646, R12 + B callbackasm1(SB) + MOVD $1647, R12 + B callbackasm1(SB) + MOVD $1648, R12 + B callbackasm1(SB) + MOVD $1649, R12 + B callbackasm1(SB) + MOVD $1650, R12 + B callbackasm1(SB) + MOVD $1651, R12 + B callbackasm1(SB) + MOVD $1652, R12 + B callbackasm1(SB) + MOVD $1653, R12 + B callbackasm1(SB) + MOVD $1654, R12 + B callbackasm1(SB) + MOVD $1655, R12 + B callbackasm1(SB) + MOVD $1656, R12 + B callbackasm1(SB) + MOVD $1657, R12 + B callbackasm1(SB) + MOVD $1658, R12 + B callbackasm1(SB) + MOVD $1659, R12 + B callbackasm1(SB) + MOVD $1660, R12 + B callbackasm1(SB) + MOVD $1661, R12 + B callbackasm1(SB) + MOVD $1662, R12 + B callbackasm1(SB) + MOVD $1663, R12 + B callbackasm1(SB) + MOVD $1664, R12 + B callbackasm1(SB) + MOVD $1665, R12 + B callbackasm1(SB) + MOVD $1666, R12 + B callbackasm1(SB) + MOVD $1667, R12 + B callbackasm1(SB) + MOVD $1668, R12 + B callbackasm1(SB) + MOVD $1669, R12 + B callbackasm1(SB) + MOVD $1670, R12 + B callbackasm1(SB) + MOVD $1671, R12 + B callbackasm1(SB) + MOVD $1672, R12 + B callbackasm1(SB) + MOVD $1673, R12 + B callbackasm1(SB) + MOVD $1674, R12 + B callbackasm1(SB) + MOVD $1675, R12 + B callbackasm1(SB) + MOVD $1676, R12 + B callbackasm1(SB) + MOVD $1677, R12 + B callbackasm1(SB) + MOVD $1678, R12 + B callbackasm1(SB) + MOVD $1679, R12 + B callbackasm1(SB) + MOVD $1680, R12 + B callbackasm1(SB) + MOVD $1681, R12 + B callbackasm1(SB) + MOVD $1682, R12 + B callbackasm1(SB) + MOVD $1683, R12 + B callbackasm1(SB) + MOVD $1684, R12 + B callbackasm1(SB) + MOVD $1685, R12 + B callbackasm1(SB) + MOVD $1686, R12 + B callbackasm1(SB) + MOVD $1687, R12 + B callbackasm1(SB) + MOVD $1688, R12 + B callbackasm1(SB) + MOVD $1689, R12 + B callbackasm1(SB) + MOVD $1690, R12 + B callbackasm1(SB) + MOVD $1691, R12 + B callbackasm1(SB) + MOVD $1692, R12 + B callbackasm1(SB) + MOVD $1693, R12 + B callbackasm1(SB) + MOVD $1694, R12 + B callbackasm1(SB) + MOVD $1695, R12 + B callbackasm1(SB) + MOVD $1696, R12 + B callbackasm1(SB) + MOVD $1697, R12 + B callbackasm1(SB) + MOVD $1698, R12 + B callbackasm1(SB) + MOVD $1699, R12 + B callbackasm1(SB) + MOVD $1700, R12 + B callbackasm1(SB) + MOVD $1701, R12 + B callbackasm1(SB) + MOVD $1702, R12 + B callbackasm1(SB) + MOVD $1703, R12 + B callbackasm1(SB) + MOVD $1704, R12 + B callbackasm1(SB) + MOVD $1705, R12 + B callbackasm1(SB) + MOVD $1706, R12 + B callbackasm1(SB) + MOVD $1707, R12 + B callbackasm1(SB) + MOVD $1708, R12 + B callbackasm1(SB) + MOVD $1709, R12 + B callbackasm1(SB) + MOVD $1710, R12 + B callbackasm1(SB) + MOVD $1711, R12 + B callbackasm1(SB) + MOVD $1712, R12 + B callbackasm1(SB) + MOVD $1713, R12 + B callbackasm1(SB) + MOVD $1714, R12 + B callbackasm1(SB) + MOVD $1715, R12 + B callbackasm1(SB) + MOVD $1716, R12 + B callbackasm1(SB) + MOVD $1717, R12 + B callbackasm1(SB) + MOVD $1718, R12 + B callbackasm1(SB) + MOVD $1719, R12 + B callbackasm1(SB) + MOVD $1720, R12 + B callbackasm1(SB) + MOVD $1721, R12 + B callbackasm1(SB) + MOVD $1722, R12 + B callbackasm1(SB) + MOVD $1723, R12 + B callbackasm1(SB) + MOVD $1724, R12 + B callbackasm1(SB) + MOVD $1725, R12 + B callbackasm1(SB) + MOVD $1726, R12 + B callbackasm1(SB) + MOVD $1727, R12 + B callbackasm1(SB) + MOVD $1728, R12 + B callbackasm1(SB) + MOVD $1729, R12 + B callbackasm1(SB) + MOVD $1730, R12 + B callbackasm1(SB) + MOVD $1731, R12 + B callbackasm1(SB) + MOVD $1732, R12 + B callbackasm1(SB) + MOVD $1733, R12 + B callbackasm1(SB) + MOVD $1734, R12 + B callbackasm1(SB) + MOVD $1735, R12 + B callbackasm1(SB) + MOVD $1736, R12 + B callbackasm1(SB) + MOVD $1737, R12 + B callbackasm1(SB) + MOVD $1738, R12 + B callbackasm1(SB) + MOVD $1739, R12 + B callbackasm1(SB) + MOVD $1740, R12 + B callbackasm1(SB) + MOVD $1741, R12 + B callbackasm1(SB) + MOVD $1742, R12 + B callbackasm1(SB) + MOVD $1743, R12 + B callbackasm1(SB) + MOVD $1744, R12 + B callbackasm1(SB) + MOVD $1745, R12 + B callbackasm1(SB) + MOVD $1746, R12 + B callbackasm1(SB) + MOVD $1747, R12 + B callbackasm1(SB) + MOVD $1748, R12 + B callbackasm1(SB) + MOVD $1749, R12 + B callbackasm1(SB) + MOVD $1750, R12 + B callbackasm1(SB) + MOVD $1751, R12 + B callbackasm1(SB) + MOVD $1752, R12 + B callbackasm1(SB) + MOVD $1753, R12 + B callbackasm1(SB) + MOVD $1754, R12 + B callbackasm1(SB) + MOVD $1755, R12 + B callbackasm1(SB) + MOVD $1756, R12 + B callbackasm1(SB) + MOVD $1757, R12 + B callbackasm1(SB) + MOVD $1758, R12 + B callbackasm1(SB) + MOVD $1759, R12 + B callbackasm1(SB) + MOVD $1760, R12 + B callbackasm1(SB) + MOVD $1761, R12 + B callbackasm1(SB) + MOVD $1762, R12 + B callbackasm1(SB) + MOVD $1763, R12 + B callbackasm1(SB) + MOVD $1764, R12 + B callbackasm1(SB) + MOVD $1765, R12 + B callbackasm1(SB) + MOVD $1766, R12 + B callbackasm1(SB) + MOVD $1767, R12 + B callbackasm1(SB) + MOVD $1768, R12 + B callbackasm1(SB) + MOVD $1769, R12 + B callbackasm1(SB) + MOVD $1770, R12 + B callbackasm1(SB) + MOVD $1771, R12 + B callbackasm1(SB) + MOVD $1772, R12 + B callbackasm1(SB) + MOVD $1773, R12 + B callbackasm1(SB) + MOVD $1774, R12 + B callbackasm1(SB) + MOVD $1775, R12 + B callbackasm1(SB) + MOVD $1776, R12 + B callbackasm1(SB) + MOVD $1777, R12 + B callbackasm1(SB) + MOVD $1778, R12 + B callbackasm1(SB) + MOVD $1779, R12 + B callbackasm1(SB) + MOVD $1780, R12 + B callbackasm1(SB) + MOVD $1781, R12 + B callbackasm1(SB) + MOVD $1782, R12 + B callbackasm1(SB) + MOVD $1783, R12 + B callbackasm1(SB) + MOVD $1784, R12 + B callbackasm1(SB) + MOVD $1785, R12 + B callbackasm1(SB) + MOVD $1786, R12 + B callbackasm1(SB) + MOVD $1787, R12 + B callbackasm1(SB) + MOVD $1788, R12 + B callbackasm1(SB) + MOVD $1789, R12 + B callbackasm1(SB) + MOVD $1790, R12 + B callbackasm1(SB) + MOVD $1791, R12 + B callbackasm1(SB) + MOVD $1792, R12 + B callbackasm1(SB) + MOVD $1793, R12 + B callbackasm1(SB) + MOVD $1794, R12 + B callbackasm1(SB) + MOVD $1795, R12 + B callbackasm1(SB) + MOVD $1796, R12 + B callbackasm1(SB) + MOVD $1797, R12 + B callbackasm1(SB) + MOVD $1798, R12 + B callbackasm1(SB) + MOVD $1799, R12 + B callbackasm1(SB) + MOVD $1800, R12 + B callbackasm1(SB) + MOVD $1801, R12 + B callbackasm1(SB) + MOVD $1802, R12 + B callbackasm1(SB) + MOVD $1803, R12 + B callbackasm1(SB) + MOVD $1804, R12 + B callbackasm1(SB) + MOVD $1805, R12 + B callbackasm1(SB) + MOVD $1806, R12 + B callbackasm1(SB) + MOVD $1807, R12 + B callbackasm1(SB) + MOVD $1808, R12 + B callbackasm1(SB) + MOVD $1809, R12 + B callbackasm1(SB) + MOVD $1810, R12 + B callbackasm1(SB) + MOVD $1811, R12 + B callbackasm1(SB) + MOVD $1812, R12 + B callbackasm1(SB) + MOVD $1813, R12 + B callbackasm1(SB) + MOVD $1814, R12 + B callbackasm1(SB) + MOVD $1815, R12 + B callbackasm1(SB) + MOVD $1816, R12 + B callbackasm1(SB) + MOVD $1817, R12 + B callbackasm1(SB) + MOVD $1818, R12 + B callbackasm1(SB) + MOVD $1819, R12 + B callbackasm1(SB) + MOVD $1820, R12 + B callbackasm1(SB) + MOVD $1821, R12 + B callbackasm1(SB) + MOVD $1822, R12 + B callbackasm1(SB) + MOVD $1823, R12 + B callbackasm1(SB) + MOVD $1824, R12 + B callbackasm1(SB) + MOVD $1825, R12 + B callbackasm1(SB) + MOVD $1826, R12 + B callbackasm1(SB) + MOVD $1827, R12 + B callbackasm1(SB) + MOVD $1828, R12 + B callbackasm1(SB) + MOVD $1829, R12 + B callbackasm1(SB) + MOVD $1830, R12 + B callbackasm1(SB) + MOVD $1831, R12 + B callbackasm1(SB) + MOVD $1832, R12 + B callbackasm1(SB) + MOVD $1833, R12 + B callbackasm1(SB) + MOVD $1834, R12 + B callbackasm1(SB) + MOVD $1835, R12 + B callbackasm1(SB) + MOVD $1836, R12 + B callbackasm1(SB) + MOVD $1837, R12 + B callbackasm1(SB) + MOVD $1838, R12 + B callbackasm1(SB) + MOVD $1839, R12 + B callbackasm1(SB) + MOVD $1840, R12 + B callbackasm1(SB) + MOVD $1841, R12 + B callbackasm1(SB) + MOVD $1842, R12 + B callbackasm1(SB) + MOVD $1843, R12 + B callbackasm1(SB) + MOVD $1844, R12 + B callbackasm1(SB) + MOVD $1845, R12 + B callbackasm1(SB) + MOVD $1846, R12 + B callbackasm1(SB) + MOVD $1847, R12 + B callbackasm1(SB) + MOVD $1848, R12 + B callbackasm1(SB) + MOVD $1849, R12 + B callbackasm1(SB) + MOVD $1850, R12 + B callbackasm1(SB) + MOVD $1851, R12 + B callbackasm1(SB) + MOVD $1852, R12 + B callbackasm1(SB) + MOVD $1853, R12 + B callbackasm1(SB) + MOVD $1854, R12 + B callbackasm1(SB) + MOVD $1855, R12 + B callbackasm1(SB) + MOVD $1856, R12 + B callbackasm1(SB) + MOVD $1857, R12 + B callbackasm1(SB) + MOVD $1858, R12 + B callbackasm1(SB) + MOVD $1859, R12 + B callbackasm1(SB) + MOVD $1860, R12 + B callbackasm1(SB) + MOVD $1861, R12 + B callbackasm1(SB) + MOVD $1862, R12 + B callbackasm1(SB) + MOVD $1863, R12 + B callbackasm1(SB) + MOVD $1864, R12 + B callbackasm1(SB) + MOVD $1865, R12 + B callbackasm1(SB) + MOVD $1866, R12 + B callbackasm1(SB) + MOVD $1867, R12 + B callbackasm1(SB) + MOVD $1868, R12 + B callbackasm1(SB) + MOVD $1869, R12 + B callbackasm1(SB) + MOVD $1870, R12 + B callbackasm1(SB) + MOVD $1871, R12 + B callbackasm1(SB) + MOVD $1872, R12 + B callbackasm1(SB) + MOVD $1873, R12 + B callbackasm1(SB) + MOVD $1874, R12 + B callbackasm1(SB) + MOVD $1875, R12 + B callbackasm1(SB) + MOVD $1876, R12 + B callbackasm1(SB) + MOVD $1877, R12 + B callbackasm1(SB) + MOVD $1878, R12 + B callbackasm1(SB) + MOVD $1879, R12 + B callbackasm1(SB) + MOVD $1880, R12 + B callbackasm1(SB) + MOVD $1881, R12 + B callbackasm1(SB) + MOVD $1882, R12 + B callbackasm1(SB) + MOVD $1883, R12 + B callbackasm1(SB) + MOVD $1884, R12 + B callbackasm1(SB) + MOVD $1885, R12 + B callbackasm1(SB) + MOVD $1886, R12 + B callbackasm1(SB) + MOVD $1887, R12 + B callbackasm1(SB) + MOVD $1888, R12 + B callbackasm1(SB) + MOVD $1889, R12 + B callbackasm1(SB) + MOVD $1890, R12 + B callbackasm1(SB) + MOVD $1891, R12 + B callbackasm1(SB) + MOVD $1892, R12 + B callbackasm1(SB) + MOVD $1893, R12 + B callbackasm1(SB) + MOVD $1894, R12 + B callbackasm1(SB) + MOVD $1895, R12 + B callbackasm1(SB) + MOVD $1896, R12 + B callbackasm1(SB) + MOVD $1897, R12 + B callbackasm1(SB) + MOVD $1898, R12 + B callbackasm1(SB) + MOVD $1899, R12 + B callbackasm1(SB) + MOVD $1900, R12 + B callbackasm1(SB) + MOVD $1901, R12 + B callbackasm1(SB) + MOVD $1902, R12 + B callbackasm1(SB) + MOVD $1903, R12 + B callbackasm1(SB) + MOVD $1904, R12 + B callbackasm1(SB) + MOVD $1905, R12 + B callbackasm1(SB) + MOVD $1906, R12 + B callbackasm1(SB) + MOVD $1907, R12 + B callbackasm1(SB) + MOVD $1908, R12 + B callbackasm1(SB) + MOVD $1909, R12 + B callbackasm1(SB) + MOVD $1910, R12 + B callbackasm1(SB) + MOVD $1911, R12 + B callbackasm1(SB) + MOVD $1912, R12 + B callbackasm1(SB) + MOVD $1913, R12 + B callbackasm1(SB) + MOVD $1914, R12 + B callbackasm1(SB) + MOVD $1915, R12 + B callbackasm1(SB) + MOVD $1916, R12 + B callbackasm1(SB) + MOVD $1917, R12 + B callbackasm1(SB) + MOVD $1918, R12 + B callbackasm1(SB) + MOVD $1919, R12 + B callbackasm1(SB) + MOVD $1920, R12 + B callbackasm1(SB) + MOVD $1921, R12 + B callbackasm1(SB) + MOVD $1922, R12 + B callbackasm1(SB) + MOVD $1923, R12 + B callbackasm1(SB) + MOVD $1924, R12 + B callbackasm1(SB) + MOVD $1925, R12 + B callbackasm1(SB) + MOVD $1926, R12 + B callbackasm1(SB) + MOVD $1927, R12 + B callbackasm1(SB) + MOVD $1928, R12 + B callbackasm1(SB) + MOVD $1929, R12 + B callbackasm1(SB) + MOVD $1930, R12 + B callbackasm1(SB) + MOVD $1931, R12 + B callbackasm1(SB) + MOVD $1932, R12 + B callbackasm1(SB) + MOVD $1933, R12 + B callbackasm1(SB) + MOVD $1934, R12 + B callbackasm1(SB) + MOVD $1935, R12 + B callbackasm1(SB) + MOVD $1936, R12 + B callbackasm1(SB) + MOVD $1937, R12 + B callbackasm1(SB) + MOVD $1938, R12 + B callbackasm1(SB) + MOVD $1939, R12 + B callbackasm1(SB) + MOVD $1940, R12 + B callbackasm1(SB) + MOVD $1941, R12 + B callbackasm1(SB) + MOVD $1942, R12 + B callbackasm1(SB) + MOVD $1943, R12 + B callbackasm1(SB) + MOVD $1944, R12 + B callbackasm1(SB) + MOVD $1945, R12 + B callbackasm1(SB) + MOVD $1946, R12 + B callbackasm1(SB) + MOVD $1947, R12 + B callbackasm1(SB) + MOVD $1948, R12 + B callbackasm1(SB) + MOVD $1949, R12 + B callbackasm1(SB) + MOVD $1950, R12 + B callbackasm1(SB) + MOVD $1951, R12 + B callbackasm1(SB) + MOVD $1952, R12 + B callbackasm1(SB) + MOVD $1953, R12 + B callbackasm1(SB) + MOVD $1954, R12 + B callbackasm1(SB) + MOVD $1955, R12 + B callbackasm1(SB) + MOVD $1956, R12 + B callbackasm1(SB) + MOVD $1957, R12 + B callbackasm1(SB) + MOVD $1958, R12 + B callbackasm1(SB) + MOVD $1959, R12 + B callbackasm1(SB) + MOVD $1960, R12 + B callbackasm1(SB) + MOVD $1961, R12 + B callbackasm1(SB) + MOVD $1962, R12 + B callbackasm1(SB) + MOVD $1963, R12 + B callbackasm1(SB) + MOVD $1964, R12 + B callbackasm1(SB) + MOVD $1965, R12 + B callbackasm1(SB) + MOVD $1966, R12 + B callbackasm1(SB) + MOVD $1967, R12 + B callbackasm1(SB) + MOVD $1968, R12 + B callbackasm1(SB) + MOVD $1969, R12 + B callbackasm1(SB) + MOVD $1970, R12 + B callbackasm1(SB) + MOVD $1971, R12 + B callbackasm1(SB) + MOVD $1972, R12 + B callbackasm1(SB) + MOVD $1973, R12 + B callbackasm1(SB) + MOVD $1974, R12 + B callbackasm1(SB) + MOVD $1975, R12 + B callbackasm1(SB) + MOVD $1976, R12 + B callbackasm1(SB) + MOVD $1977, R12 + B callbackasm1(SB) + MOVD $1978, R12 + B callbackasm1(SB) + MOVD $1979, R12 + B callbackasm1(SB) + MOVD $1980, R12 + B callbackasm1(SB) + MOVD $1981, R12 + B callbackasm1(SB) + MOVD $1982, R12 + B callbackasm1(SB) + MOVD $1983, R12 + B callbackasm1(SB) + MOVD $1984, R12 + B callbackasm1(SB) + MOVD $1985, R12 + B callbackasm1(SB) + MOVD $1986, R12 + B callbackasm1(SB) + MOVD $1987, R12 + B callbackasm1(SB) + MOVD $1988, R12 + B callbackasm1(SB) + MOVD $1989, R12 + B callbackasm1(SB) + MOVD $1990, R12 + B callbackasm1(SB) + MOVD $1991, R12 + B callbackasm1(SB) + MOVD $1992, R12 + B callbackasm1(SB) + MOVD $1993, R12 + B callbackasm1(SB) + MOVD $1994, R12 + B callbackasm1(SB) + MOVD $1995, R12 + B callbackasm1(SB) + MOVD $1996, R12 + B callbackasm1(SB) + MOVD $1997, R12 + B callbackasm1(SB) + MOVD $1998, R12 + B callbackasm1(SB) + MOVD $1999, R12 + B callbackasm1(SB) diff --git a/vendor/github.com/shirou/gopsutil/v4/common/env.go b/vendor/github.com/shirou/gopsutil/v4/common/env.go index 4acad1fd1e8a4..47e471c402f7e 100644 --- a/vendor/github.com/shirou/gopsutil/v4/common/env.go +++ b/vendor/github.com/shirou/gopsutil/v4/common/env.go @@ -12,13 +12,14 @@ type EnvKeyType string var EnvKey = EnvKeyType("env") const ( - HostProcEnvKey EnvKeyType = "HOST_PROC" - HostSysEnvKey EnvKeyType = "HOST_SYS" - HostEtcEnvKey EnvKeyType = "HOST_ETC" - HostVarEnvKey EnvKeyType = "HOST_VAR" - HostRunEnvKey EnvKeyType = "HOST_RUN" - HostDevEnvKey EnvKeyType = "HOST_DEV" - HostRootEnvKey EnvKeyType = "HOST_ROOT" + HostProcEnvKey EnvKeyType = "HOST_PROC" + HostSysEnvKey EnvKeyType = "HOST_SYS" + HostEtcEnvKey EnvKeyType = "HOST_ETC" + HostVarEnvKey EnvKeyType = "HOST_VAR" + HostRunEnvKey EnvKeyType = "HOST_RUN" + HostDevEnvKey EnvKeyType = "HOST_DEV" + HostRootEnvKey EnvKeyType = "HOST_ROOT" + HostProcMountinfo EnvKeyType = "HOST_PROC_MOUNTINFO" ) type EnvMap map[EnvKeyType]string diff --git a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_aix_nocgo.go b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_aix_nocgo.go index 51e295a2bccba..329ef8336669e 100644 --- a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_aix_nocgo.go +++ b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_aix_nocgo.go @@ -12,8 +12,57 @@ import ( ) func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) { + var ret []TimesStat if percpu { - return []TimesStat{}, common.ErrNotImplementedError + per_out, err := invoke.CommandWithContext(ctx, "sar", "-u", "-P", "ALL", "10", "1") + if err != nil { + return nil, err + } + lines := strings.Split(string(per_out), "\n") + if len(lines) < 6 { + return []TimesStat{}, common.ErrNotImplementedError + } + + hp := strings.Fields(lines[5]) // headers + for l := 6; l < len(lines)-1; l++ { + ct := &TimesStat{} + v := strings.Fields(lines[l]) // values + for i, header := range hp { + // We're done in any of these use cases + if i >= len(v) || v[0] == "-" { + break + } + + // Position variable for v + pos := i + // There is a missing field at the beginning of all but the first line + // so adjust the position + if l > 6 { + pos = i - 1 + } + // We don't want invalid positions + if pos < 0 { + continue + } + + if t, err := strconv.ParseFloat(v[pos], 64); err == nil { + switch header { + case `cpu`: + ct.CPU = strconv.FormatFloat(t, 'f', -1, 64) + case `%usr`: + ct.User = t + case `%sys`: + ct.System = t + case `%wio`: + ct.Iowait = t + case `%idle`: + ct.Idle = t + } + } + } + // Valid CPU data, so append it + ret = append(ret, *ct) + } } else { out, err := invoke.CommandWithContext(ctx, "sar", "-u", "10", "1") if err != nil { @@ -24,26 +73,28 @@ func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) { return []TimesStat{}, common.ErrNotImplementedError } - ret := TimesStat{CPU: "cpu-total"} + ct := &TimesStat{CPU: "cpu-total"} h := strings.Fields(lines[len(lines)-3]) // headers v := strings.Fields(lines[len(lines)-2]) // values for i, header := range h { if t, err := strconv.ParseFloat(v[i], 64); err == nil { switch header { case `%usr`: - ret.User = t + ct.User = t case `%sys`: - ret.System = t + ct.System = t case `%wio`: - ret.Iowait = t + ct.Iowait = t case `%idle`: - ret.Idle = t + ct.Idle = t } } } - return []TimesStat{ret}, nil + ret = append(ret, *ct) } + + return ret, nil } func InfoWithContext(ctx context.Context) ([]InfoStat, error) { @@ -78,6 +129,20 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) { } } break + } else if strings.HasPrefix(line, "System Model:") { + p := strings.Split(string(line), ":") + if p != nil { + ret.VendorID = strings.TrimSpace(p[1]) + } + } else if strings.HasPrefix(line, "Processor Type:") { + p := strings.Split(string(line), ":") + if p != nil { + c := strings.Split(string(p[1]), "_") + if c != nil { + ret.Family = strings.TrimSpace(c[0]) + ret.Model = strings.TrimSpace(c[1]) + } + } } } return []InfoStat{ret}, nil diff --git a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin.go b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin.go index 79a458b8e21cc..b3e3a668de133 100644 --- a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin.go +++ b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin.go @@ -5,12 +5,15 @@ package cpu import ( "context" + "fmt" "strconv" "strings" + "unsafe" - "github.com/shoenig/go-m1cpu" "github.com/tklauser/go-sysconf" "golang.org/x/sys/unix" + + "github.com/shirou/gopsutil/v4/internal/common" ) // sys/resource.h @@ -23,6 +26,24 @@ const ( cpUStates = 5 ) +// mach/machine.h +const ( + cpuStateUser = 0 + cpuStateSystem = 1 + cpuStateIdle = 2 + cpuStateNice = 3 + cpuStateMax = 4 +) + +// mach/processor_info.h +const ( + processorCpuLoadInfo = 2 +) + +type hostCpuLoadInfoData struct { + cpuTicks [cpuStateMax]uint32 +} + // default value. from time.h var ClocksPerSec = float64(128) @@ -39,11 +60,17 @@ func Times(percpu bool) ([]TimesStat, error) { } func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) { + lib, err := common.NewLibrary(common.System) + if err != nil { + return nil, err + } + defer lib.Close() + if percpu { - return perCPUTimes() + return perCPUTimes(lib) } - return allCPUTimes() + return allCPUTimes(lib) } // Returns only one CPUInfoStat on FreeBSD @@ -86,15 +113,9 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) { c.CacheSize = int32(cacheSize) c.VendorID, _ = unix.Sysctl("machdep.cpu.vendor") - if m1cpu.IsAppleSilicon() { - c.Mhz = float64(m1cpu.PCoreHz() / 1_000_000) - } else { - // Use the rated frequency of the CPU. This is a static value and does not - // account for low power or Turbo Boost modes. - cpuFrequency, err := unix.SysctlUint64("hw.cpufrequency") - if err == nil { - c.Mhz = float64(cpuFrequency) / 1000000.0 - } + v, err := getFrequency() + if err == nil { + c.Mhz = v } return append(ret, c), nil @@ -115,3 +136,63 @@ func CountsWithContext(ctx context.Context, logical bool) (int, error) { return int(count), nil } + +func perCPUTimes(machLib *common.Library) ([]TimesStat, error) { + machHostSelf := common.GetFunc[common.MachHostSelfFunc](machLib, common.MachHostSelfSym) + machTaskSelf := common.GetFunc[common.MachTaskSelfFunc](machLib, common.MachTaskSelfSym) + hostProcessorInfo := common.GetFunc[common.HostProcessorInfoFunc](machLib, common.HostProcessorInfoSym) + vmDeallocate := common.GetFunc[common.VMDeallocateFunc](machLib, common.VMDeallocateSym) + + var count, ncpu uint32 + var cpuload *hostCpuLoadInfoData + + status := hostProcessorInfo(machHostSelf(), processorCpuLoadInfo, &ncpu, uintptr(unsafe.Pointer(&cpuload)), &count) + + if status != common.KERN_SUCCESS { + return nil, fmt.Errorf("host_processor_info error=%d", status) + } + + defer vmDeallocate(machTaskSelf(), uintptr(unsafe.Pointer(cpuload)), uintptr(ncpu)) + + ret := []TimesStat{} + loads := unsafe.Slice(cpuload, ncpu) + + for i := 0; i < int(ncpu); i++ { + c := TimesStat{ + CPU: fmt.Sprintf("cpu%d", i), + User: float64(loads[i].cpuTicks[cpuStateUser]) / ClocksPerSec, + System: float64(loads[i].cpuTicks[cpuStateSystem]) / ClocksPerSec, + Nice: float64(loads[i].cpuTicks[cpuStateNice]) / ClocksPerSec, + Idle: float64(loads[i].cpuTicks[cpuStateIdle]) / ClocksPerSec, + } + + ret = append(ret, c) + } + + return ret, nil +} + +func allCPUTimes(machLib *common.Library) ([]TimesStat, error) { + machHostSelf := common.GetFunc[common.MachHostSelfFunc](machLib, common.MachHostSelfSym) + hostStatistics := common.GetFunc[common.HostStatisticsFunc](machLib, common.HostStatisticsSym) + + var cpuload hostCpuLoadInfoData + count := uint32(cpuStateMax) + + status := hostStatistics(machHostSelf(), common.HOST_CPU_LOAD_INFO, + uintptr(unsafe.Pointer(&cpuload)), &count) + + if status != common.KERN_SUCCESS { + return nil, fmt.Errorf("host_statistics error=%d", status) + } + + c := TimesStat{ + CPU: "cpu-total", + User: float64(cpuload.cpuTicks[cpuStateUser]) / ClocksPerSec, + System: float64(cpuload.cpuTicks[cpuStateSystem]) / ClocksPerSec, + Nice: float64(cpuload.cpuTicks[cpuStateNice]) / ClocksPerSec, + Idle: float64(cpuload.cpuTicks[cpuStateIdle]) / ClocksPerSec, + } + + return []TimesStat{c}, nil +} diff --git a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin_arm64.go b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin_arm64.go new file mode 100644 index 0000000000000..5031842439092 --- /dev/null +++ b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin_arm64.go @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: BSD-3-Clause +//go:build darwin && arm64 + +package cpu + +import ( + "encoding/binary" + "fmt" + "unsafe" + + "github.com/shirou/gopsutil/v4/internal/common" +) + +// https://github.com/shoenig/go-m1cpu/blob/v0.1.6/cpu.go +func getFrequency() (float64, error) { + ioKit, err := common.NewLibrary(common.IOKit) + if err != nil { + return 0, err + } + defer ioKit.Close() + + coreFoundation, err := common.NewLibrary(common.CoreFoundation) + if err != nil { + return 0, err + } + defer coreFoundation.Close() + + ioServiceMatching := common.GetFunc[common.IOServiceMatchingFunc](ioKit, common.IOServiceMatchingSym) + ioServiceGetMatchingServices := common.GetFunc[common.IOServiceGetMatchingServicesFunc](ioKit, common.IOServiceGetMatchingServicesSym) + ioIteratorNext := common.GetFunc[common.IOIteratorNextFunc](ioKit, common.IOIteratorNextSym) + ioRegistryEntryGetName := common.GetFunc[common.IORegistryEntryGetNameFunc](ioKit, common.IORegistryEntryGetNameSym) + ioRegistryEntryCreateCFProperty := common.GetFunc[common.IORegistryEntryCreateCFPropertyFunc](ioKit, common.IORegistryEntryCreateCFPropertySym) + ioObjectRelease := common.GetFunc[common.IOObjectReleaseFunc](ioKit, common.IOObjectReleaseSym) + + cfStringCreateWithCString := common.GetFunc[common.CFStringCreateWithCStringFunc](coreFoundation, common.CFStringCreateWithCStringSym) + cfDataGetLength := common.GetFunc[common.CFDataGetLengthFunc](coreFoundation, common.CFDataGetLengthSym) + cfDataGetBytePtr := common.GetFunc[common.CFDataGetBytePtrFunc](coreFoundation, common.CFDataGetBytePtrSym) + cfRelease := common.GetFunc[common.CFReleaseFunc](coreFoundation, common.CFReleaseSym) + + matching := ioServiceMatching("AppleARMIODevice") + + var iterator uint32 + if status := ioServiceGetMatchingServices(common.KIOMainPortDefault, uintptr(matching), &iterator); status != common.KERN_SUCCESS { + return 0.0, fmt.Errorf("IOServiceGetMatchingServices error=%d", status) + } + defer ioObjectRelease(iterator) + + pCorekey := cfStringCreateWithCString(common.KCFAllocatorDefault, "voltage-states5-sram", common.KCFStringEncodingUTF8) + defer cfRelease(uintptr(pCorekey)) + + var pCoreHz uint32 + for { + service := ioIteratorNext(iterator) + if !(service > 0) { + break + } + + buf := make([]byte, 512) + ioRegistryEntryGetName(service, &buf[0]) + + if common.GoString(&buf[0]) == "pmgr" { + pCoreRef := ioRegistryEntryCreateCFProperty(service, uintptr(pCorekey), common.KCFAllocatorDefault, common.KNilOptions) + length := cfDataGetLength(uintptr(pCoreRef)) + data := cfDataGetBytePtr(uintptr(pCoreRef)) + + // composite uint32 from the byte array + buf := unsafe.Slice((*byte)(data), length) + + // combine the bytes into a uint32 value + b := buf[length-8 : length-4] + pCoreHz = binary.LittleEndian.Uint32(b) + ioObjectRelease(service) + break + } + + ioObjectRelease(service) + } + + return float64(pCoreHz / 1_000_000), nil +} diff --git a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin_cgo.go b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin_cgo.go deleted file mode 100644 index 3a02024c5be46..0000000000000 --- a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin_cgo.go +++ /dev/null @@ -1,111 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -//go:build darwin && cgo - -package cpu - -/* -#include -#include -#include -#include -#include -#include -#include -#if TARGET_OS_MAC -#include -#endif -#include -#include -*/ -import "C" - -import ( - "bytes" - "encoding/binary" - "fmt" - "unsafe" -) - -// these CPU times for darwin is borrowed from influxdb/telegraf. - -func perCPUTimes() ([]TimesStat, error) { - var ( - count C.mach_msg_type_number_t - cpuload *C.processor_cpu_load_info_data_t - ncpu C.natural_t - ) - - status := C.host_processor_info(C.host_t(C.mach_host_self()), - C.PROCESSOR_CPU_LOAD_INFO, - &ncpu, - (*C.processor_info_array_t)(unsafe.Pointer(&cpuload)), - &count) - - if status != C.KERN_SUCCESS { - return nil, fmt.Errorf("host_processor_info error=%d", status) - } - - // jump through some cgo casting hoops and ensure we properly free - // the memory that cpuload points to - target := C.vm_map_t(C.mach_task_self_) - address := C.vm_address_t(uintptr(unsafe.Pointer(cpuload))) - defer C.vm_deallocate(target, address, C.vm_size_t(ncpu)) - - // the body of struct processor_cpu_load_info - // aka processor_cpu_load_info_data_t - var cpu_ticks [C.CPU_STATE_MAX]uint32 - - // copy the cpuload array to a []byte buffer - // where we can binary.Read the data - size := int(ncpu) * binary.Size(cpu_ticks) - buf := (*[1 << 30]byte)(unsafe.Pointer(cpuload))[:size:size] - - bbuf := bytes.NewBuffer(buf) - - var ret []TimesStat - - for i := 0; i < int(ncpu); i++ { - err := binary.Read(bbuf, binary.LittleEndian, &cpu_ticks) - if err != nil { - return nil, err - } - - c := TimesStat{ - CPU: fmt.Sprintf("cpu%d", i), - User: float64(cpu_ticks[C.CPU_STATE_USER]) / ClocksPerSec, - System: float64(cpu_ticks[C.CPU_STATE_SYSTEM]) / ClocksPerSec, - Nice: float64(cpu_ticks[C.CPU_STATE_NICE]) / ClocksPerSec, - Idle: float64(cpu_ticks[C.CPU_STATE_IDLE]) / ClocksPerSec, - } - - ret = append(ret, c) - } - - return ret, nil -} - -func allCPUTimes() ([]TimesStat, error) { - var count C.mach_msg_type_number_t - var cpuload C.host_cpu_load_info_data_t - - count = C.HOST_CPU_LOAD_INFO_COUNT - - status := C.host_statistics(C.host_t(C.mach_host_self()), - C.HOST_CPU_LOAD_INFO, - C.host_info_t(unsafe.Pointer(&cpuload)), - &count) - - if status != C.KERN_SUCCESS { - return nil, fmt.Errorf("host_statistics error=%d", status) - } - - c := TimesStat{ - CPU: "cpu-total", - User: float64(cpuload.cpu_ticks[C.CPU_STATE_USER]) / ClocksPerSec, - System: float64(cpuload.cpu_ticks[C.CPU_STATE_SYSTEM]) / ClocksPerSec, - Nice: float64(cpuload.cpu_ticks[C.CPU_STATE_NICE]) / ClocksPerSec, - Idle: float64(cpuload.cpu_ticks[C.CPU_STATE_IDLE]) / ClocksPerSec, - } - - return []TimesStat{c}, nil -} diff --git a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin_fallback.go b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin_fallback.go new file mode 100644 index 0000000000000..b9e52aba1762c --- /dev/null +++ b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin_fallback.go @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: BSD-3-Clause +//go:build darwin && !arm64 + +package cpu + +import "golang.org/x/sys/unix" + +func getFrequency() (float64, error) { + // Use the rated frequency of the CPU. This is a static value and does not + // account for low power or Turbo Boost modes. + cpuFrequency, err := unix.SysctlUint64("hw.cpufrequency") + return float64(cpuFrequency) / 1000000.0, err +} diff --git a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin_nocgo.go b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin_nocgo.go deleted file mode 100644 index 1af8566a67bef..0000000000000 --- a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin_nocgo.go +++ /dev/null @@ -1,14 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -//go:build darwin && !cgo - -package cpu - -import "github.com/shirou/gopsutil/v4/internal/common" - -func perCPUTimes() ([]TimesStat, error) { - return []TimesStat{}, common.ErrNotImplementedError -} - -func allCPUTimes() ([]TimesStat, error) { - return []TimesStat{}, common.ErrNotImplementedError -} diff --git a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_freebsd.go b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_freebsd.go index c68d6bff0f647..5d17c7e977e28 100644 --- a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_freebsd.go +++ b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_freebsd.go @@ -11,9 +11,10 @@ import ( "strings" "unsafe" - "github.com/shirou/gopsutil/v4/internal/common" "github.com/tklauser/go-sysconf" "golang.org/x/sys/unix" + + "github.com/shirou/gopsutil/v4/internal/common" ) var ( @@ -136,7 +137,7 @@ func parseDmesgBoot(fileName string) (InfoStat, int, error) { c.Model = matches[4] t, err := strconv.ParseInt(matches[5], 10, 32) if err != nil { - return c, 0, fmt.Errorf("unable to parse FreeBSD CPU stepping information from %q: %v", line, err) + return c, 0, fmt.Errorf("unable to parse FreeBSD CPU stepping information from %q: %w", line, err) } c.Stepping = int32(t) } else if matches := featuresMatch.FindStringSubmatch(line); matches != nil { @@ -150,12 +151,12 @@ func parseDmesgBoot(fileName string) (InfoStat, int, error) { } else if matches := cpuCores.FindStringSubmatch(line); matches != nil { t, err := strconv.ParseInt(matches[1], 10, 32) if err != nil { - return c, 0, fmt.Errorf("unable to parse FreeBSD CPU Nums from %q: %v", line, err) + return c, 0, fmt.Errorf("unable to parse FreeBSD CPU Nums from %q: %w", line, err) } cpuNum = int(t) t2, err := strconv.ParseInt(matches[2], 10, 32) if err != nil { - return c, 0, fmt.Errorf("unable to parse FreeBSD CPU cores from %q: %v", line, err) + return c, 0, fmt.Errorf("unable to parse FreeBSD CPU cores from %q: %w", line, err) } c.Cores = int32(t2) } diff --git a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_linux.go b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_linux.go index f78c61a25b621..5f595e7b3effd 100644 --- a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_linux.go +++ b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_linux.go @@ -395,7 +395,7 @@ func CountsWithContext(ctx context.Context, logical bool) (int, error) { for _, line := range lines { line = strings.ToLower(line) if strings.HasPrefix(line, "processor") { - _, err = strconv.Atoi(strings.TrimSpace(line[strings.IndexByte(line, ':')+1:])) + _, err = strconv.ParseInt(strings.TrimSpace(line[strings.IndexByte(line, ':')+1:]), 10, 32) if err == nil { ret++ } @@ -464,11 +464,11 @@ func CountsWithContext(ctx context.Context, logical bool) (int, error) { } fields[0] = strings.TrimSpace(fields[0]) if fields[0] == "physical id" || fields[0] == "cpu cores" { - val, err := strconv.Atoi(strings.TrimSpace(fields[1])) + val, err := strconv.ParseInt(strings.TrimSpace(fields[1]), 10, 32) if err != nil { continue } - currentInfo[fields[0]] = val + currentInfo[fields[0]] = int(val) } } ret := 0 diff --git a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_netbsd.go b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_netbsd.go index 2cda5cd24375e..198be5e644db7 100644 --- a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_netbsd.go +++ b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_netbsd.go @@ -9,9 +9,10 @@ import ( "runtime" "unsafe" - "github.com/shirou/gopsutil/v4/internal/common" "github.com/tklauser/go-sysconf" "golang.org/x/sys/unix" + + "github.com/shirou/gopsutil/v4/internal/common" ) const ( diff --git a/vendor/github.com/shirou/gopsutil/v4/internal/common/common.go b/vendor/github.com/shirou/gopsutil/v4/internal/common/common.go index 642aabc558321..868ea4daeed21 100644 --- a/vendor/github.com/shirou/gopsutil/v4/internal/common/common.go +++ b/vendor/github.com/shirou/gopsutil/v4/internal/common/common.go @@ -15,6 +15,7 @@ import ( "errors" "fmt" "io" + "math" "net/url" "os" "os/exec" @@ -153,7 +154,7 @@ func ReadLinesOffsetN(filename string, offset uint, n int) ([]string, error) { var ret []string r := bufio.NewReader(f) - for i := 0; i < n+int(offset) || n < 0; i++ { + for i := uint(0); i < uint(n)+offset || n < 0; i++ { line, err := r.ReadString('\n') if err != nil { if err == io.EOF && len(line) > 0 { @@ -161,7 +162,7 @@ func ReadLinesOffsetN(filename string, offset uint, n int) ([]string, error) { } break } - if i < int(offset) { + if i < offset { continue } ret = append(ret, strings.Trim(line, "\n")) @@ -463,3 +464,11 @@ func getSysctrlEnv(env []string) []string { } return env } + +// Round places rounds the number 'val' to 'n' decimal places +func Round(val float64, n int) float64 { + // Calculate the power of 10 to the n + pow10 := math.Pow(10, float64(n)) + // Multiply the value by pow10, round it, then divide it by pow10 + return math.Round(val*pow10) / pow10 +} diff --git a/vendor/github.com/shirou/gopsutil/v4/internal/common/common_darwin.go b/vendor/github.com/shirou/gopsutil/v4/internal/common/common_darwin.go index 53f9ae8d9a5a4..b473f88666eba 100644 --- a/vendor/github.com/shirou/gopsutil/v4/internal/common/common_darwin.go +++ b/vendor/github.com/shirou/gopsutil/v4/internal/common/common_darwin.go @@ -5,11 +5,13 @@ package common import ( "context" + "fmt" "os" "os/exec" "strings" "unsafe" + "github.com/ebitengine/purego" "golang.org/x/sys/unix" ) @@ -64,3 +66,299 @@ func CallSyscall(mib []int32) ([]byte, uint64, error) { return buf, length, nil } + +// Library represents a dynamic library loaded by purego. +type Library struct { + addr uintptr + path string + close func() +} + +// library paths +const ( + IOKit = "/System/Library/Frameworks/IOKit.framework/IOKit" + CoreFoundation = "/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation" + System = "/usr/lib/libSystem.B.dylib" +) + +func NewLibrary(path string) (*Library, error) { + lib, err := purego.Dlopen(path, purego.RTLD_LAZY|purego.RTLD_GLOBAL) + if err != nil { + return nil, err + } + + closeFunc := func() { + purego.Dlclose(lib) + } + + return &Library{ + addr: lib, + path: path, + close: closeFunc, + }, nil +} + +func (lib *Library) Dlsym(symbol string) (uintptr, error) { + return purego.Dlsym(lib.addr, symbol) +} + +func GetFunc[T any](lib *Library, symbol string) T { + var fptr T + purego.RegisterLibFunc(&fptr, lib.addr, symbol) + return fptr +} + +func (lib *Library) Close() { + lib.close() +} + +// status codes +const ( + KERN_SUCCESS = 0 +) + +// IOKit functions and symbols. +type ( + IOServiceGetMatchingServiceFunc func(mainPort uint32, matching uintptr) uint32 + IOServiceGetMatchingServicesFunc func(mainPort uint32, matching uintptr, existing *uint32) int + IOServiceMatchingFunc func(name string) unsafe.Pointer + IOServiceOpenFunc func(service, owningTask, connType uint32, connect *uint32) int + IOServiceCloseFunc func(connect uint32) int + IOIteratorNextFunc func(iterator uint32) uint32 + IORegistryEntryGetNameFunc func(entry uint32, name *byte) int + IORegistryEntryGetParentEntryFunc func(entry uint32, plane string, parent *uint32) int + IORegistryEntryCreateCFPropertyFunc func(entry uint32, key, allocator uintptr, options uint32) unsafe.Pointer + IORegistryEntryCreateCFPropertiesFunc func(entry uint32, properties unsafe.Pointer, allocator uintptr, options uint32) int + IOObjectConformsToFunc func(object uint32, className string) bool + IOObjectReleaseFunc func(object uint32) int + IOConnectCallStructMethodFunc func(connection, selector uint32, inputStruct, inputStructCnt, outputStruct uintptr, outputStructCnt *uintptr) int + + IOHIDEventSystemClientCreateFunc func(allocator uintptr) unsafe.Pointer + IOHIDEventSystemClientSetMatchingFunc func(client, match uintptr) int + IOHIDServiceClientCopyEventFunc func(service uintptr, eventType int64, + options int32, timeout int64) unsafe.Pointer + IOHIDServiceClientCopyPropertyFunc func(service, property uintptr) unsafe.Pointer + IOHIDEventGetFloatValueFunc func(event uintptr, field int32) float64 + IOHIDEventSystemClientCopyServicesFunc func(client uintptr) unsafe.Pointer +) + +const ( + IOServiceGetMatchingServiceSym = "IOServiceGetMatchingService" + IOServiceGetMatchingServicesSym = "IOServiceGetMatchingServices" + IOServiceMatchingSym = "IOServiceMatching" + IOServiceOpenSym = "IOServiceOpen" + IOServiceCloseSym = "IOServiceClose" + IOIteratorNextSym = "IOIteratorNext" + IORegistryEntryGetNameSym = "IORegistryEntryGetName" + IORegistryEntryGetParentEntrySym = "IORegistryEntryGetParentEntry" + IORegistryEntryCreateCFPropertySym = "IORegistryEntryCreateCFProperty" + IORegistryEntryCreateCFPropertiesSym = "IORegistryEntryCreateCFProperties" + IOObjectConformsToSym = "IOObjectConformsTo" + IOObjectReleaseSym = "IOObjectRelease" + IOConnectCallStructMethodSym = "IOConnectCallStructMethod" + + IOHIDEventSystemClientCreateSym = "IOHIDEventSystemClientCreate" + IOHIDEventSystemClientSetMatchingSym = "IOHIDEventSystemClientSetMatching" + IOHIDServiceClientCopyEventSym = "IOHIDServiceClientCopyEvent" + IOHIDServiceClientCopyPropertySym = "IOHIDServiceClientCopyProperty" + IOHIDEventGetFloatValueSym = "IOHIDEventGetFloatValue" + IOHIDEventSystemClientCopyServicesSym = "IOHIDEventSystemClientCopyServices" +) + +const ( + KIOMainPortDefault = 0 + + KIOHIDEventTypeTemperature = 15 + + KNilOptions = 0 +) + +const ( + KIOMediaWholeKey = "Media" + KIOServicePlane = "IOService" +) + +// CoreFoundation functions and symbols. +type ( + CFGetTypeIDFunc func(cf uintptr) int32 + CFNumberCreateFunc func(allocator uintptr, theType int32, valuePtr uintptr) unsafe.Pointer + CFNumberGetValueFunc func(num uintptr, theType int32, valuePtr uintptr) bool + CFDictionaryCreateFunc func(allocator uintptr, keys, values *unsafe.Pointer, numValues int32, + keyCallBacks, valueCallBacks uintptr) unsafe.Pointer + CFDictionaryAddValueFunc func(theDict, key, value uintptr) + CFDictionaryGetValueFunc func(theDict, key uintptr) unsafe.Pointer + CFArrayGetCountFunc func(theArray uintptr) int32 + CFArrayGetValueAtIndexFunc func(theArray uintptr, index int32) unsafe.Pointer + CFStringCreateMutableFunc func(alloc uintptr, maxLength int32) unsafe.Pointer + CFStringGetLengthFunc func(theString uintptr) int32 + CFStringGetCStringFunc func(theString uintptr, buffer *byte, bufferSize int32, encoding uint32) + CFStringCreateWithCStringFunc func(alloc uintptr, cStr string, encoding uint32) unsafe.Pointer + CFDataGetLengthFunc func(theData uintptr) int32 + CFDataGetBytePtrFunc func(theData uintptr) unsafe.Pointer + CFReleaseFunc func(cf uintptr) +) + +const ( + CFGetTypeIDSym = "CFGetTypeID" + CFNumberCreateSym = "CFNumberCreate" + CFNumberGetValueSym = "CFNumberGetValue" + CFDictionaryCreateSym = "CFDictionaryCreate" + CFDictionaryAddValueSym = "CFDictionaryAddValue" + CFDictionaryGetValueSym = "CFDictionaryGetValue" + CFArrayGetCountSym = "CFArrayGetCount" + CFArrayGetValueAtIndexSym = "CFArrayGetValueAtIndex" + CFStringCreateMutableSym = "CFStringCreateMutable" + CFStringGetLengthSym = "CFStringGetLength" + CFStringGetCStringSym = "CFStringGetCString" + CFStringCreateWithCStringSym = "CFStringCreateWithCString" + CFDataGetLengthSym = "CFDataGetLength" + CFDataGetBytePtrSym = "CFDataGetBytePtr" + CFReleaseSym = "CFRelease" +) + +const ( + KCFStringEncodingUTF8 = 0x08000100 + KCFNumberSInt64Type = 4 + KCFNumberIntType = 9 + KCFAllocatorDefault = 0 +) + +// Kernel functions and symbols. +type MachTimeBaseInfo struct { + Numer uint32 + Denom uint32 +} + +type ( + HostProcessorInfoFunc func(host uint32, flavor int32, outProcessorCount *uint32, outProcessorInfo uintptr, + outProcessorInfoCnt *uint32) int + HostStatisticsFunc func(host uint32, flavor int32, hostInfoOut uintptr, hostInfoOutCnt *uint32) int + MachHostSelfFunc func() uint32 + MachTaskSelfFunc func() uint32 + MachTimeBaseInfoFunc func(info uintptr) int + VMDeallocateFunc func(targetTask uint32, vmAddress, vmSize uintptr) int +) + +const ( + HostProcessorInfoSym = "host_processor_info" + HostStatisticsSym = "host_statistics" + MachHostSelfSym = "mach_host_self" + MachTaskSelfSym = "mach_task_self" + MachTimeBaseInfoSym = "mach_timebase_info" + VMDeallocateSym = "vm_deallocate" +) + +const ( + CTL_KERN = 1 + KERN_ARGMAX = 8 + KERN_PROCARGS2 = 49 + + HOST_VM_INFO = 2 + HOST_CPU_LOAD_INFO = 3 + + HOST_VM_INFO_COUNT = 0xf +) + +// System functions and symbols. +type ( + ProcPidPathFunc func(pid int32, buffer uintptr, bufferSize uint32) int32 + ProcPidInfoFunc func(pid, flavor int32, arg uint64, buffer uintptr, bufferSize int32) int32 +) + +const ( + SysctlSym = "sysctl" + ProcPidPathSym = "proc_pidpath" + ProcPidInfoSym = "proc_pidinfo" +) + +const ( + MAXPATHLEN = 1024 + PROC_PIDPATHINFO_MAXSIZE = 4 * MAXPATHLEN + PROC_PIDTASKINFO = 4 + PROC_PIDVNODEPATHINFO = 9 +) + +// SMC represents a SMC instance. +type SMC struct { + lib *Library + conn uint32 + callStruct IOConnectCallStructMethodFunc +} + +const ioServiceSMC = "AppleSMC" + +const ( + KSMCUserClientOpen = 0 + KSMCUserClientClose = 1 + KSMCHandleYPCEvent = 2 + KSMCReadKey = 5 + KSMCWriteKey = 6 + KSMCGetKeyCount = 7 + KSMCGetKeyFromIndex = 8 + KSMCGetKeyInfo = 9 +) + +const ( + KSMCSuccess = 0 + KSMCError = 1 + KSMCKeyNotFound = 132 +) + +func NewSMC(ioKit *Library) (*SMC, error) { + if ioKit.path != IOKit { + return nil, fmt.Errorf("library is not IOKit") + } + + ioServiceGetMatchingService := GetFunc[IOServiceGetMatchingServiceFunc](ioKit, IOServiceGetMatchingServiceSym) + ioServiceMatching := GetFunc[IOServiceMatchingFunc](ioKit, IOServiceMatchingSym) + ioServiceOpen := GetFunc[IOServiceOpenFunc](ioKit, IOServiceOpenSym) + ioObjectRelease := GetFunc[IOObjectReleaseFunc](ioKit, IOObjectReleaseSym) + machTaskSelf := GetFunc[MachTaskSelfFunc](ioKit, MachTaskSelfSym) + + ioConnectCallStructMethod := GetFunc[IOConnectCallStructMethodFunc](ioKit, IOConnectCallStructMethodSym) + + service := ioServiceGetMatchingService(0, uintptr(ioServiceMatching(ioServiceSMC))) + if service == 0 { + return nil, fmt.Errorf("ERROR: %s NOT FOUND", ioServiceSMC) + } + + var conn uint32 + if result := ioServiceOpen(service, machTaskSelf(), 0, &conn); result != 0 { + return nil, fmt.Errorf("ERROR: IOServiceOpen failed") + } + + ioObjectRelease(service) + return &SMC{ + lib: ioKit, + conn: conn, + callStruct: ioConnectCallStructMethod, + }, nil +} + +func (s *SMC) CallStruct(selector uint32, inputStruct, inputStructCnt, outputStruct uintptr, outputStructCnt *uintptr) int { + return s.callStruct(s.conn, selector, inputStruct, inputStructCnt, outputStruct, outputStructCnt) +} + +func (s *SMC) Close() error { + ioServiceClose := GetFunc[IOServiceCloseFunc](s.lib, IOServiceCloseSym) + + if result := ioServiceClose(s.conn); result != 0 { + return fmt.Errorf("ERROR: IOServiceClose failed") + } + return nil +} + +// https://github.com/ebitengine/purego/blob/main/internal/strings/strings.go#L26 +func GoString(cStr *byte) string { + if cStr == nil { + return "" + } + var length int + for { + if *(*byte)(unsafe.Add(unsafe.Pointer(cStr), uintptr(length))) == '\x00' { + break + } + length++ + } + return string(unsafe.Slice(cStr, length)) +} diff --git a/vendor/github.com/shirou/gopsutil/v4/internal/common/common_linux.go b/vendor/github.com/shirou/gopsutil/v4/internal/common/common_linux.go index 85802dcb097ab..541de93d3573f 100644 --- a/vendor/github.com/shirou/gopsutil/v4/internal/common/common_linux.go +++ b/vendor/github.com/shirou/gopsutil/v4/internal/common/common_linux.go @@ -90,6 +90,8 @@ func BootTimeWithContext(ctx context.Context, enableCache bool) (uint64, error) if enableCache { atomic.StoreUint64(&cachedBootTime, t) } + + return t, nil } filename := HostProcWithContext(ctx, "uptime") @@ -97,6 +99,8 @@ func BootTimeWithContext(ctx context.Context, enableCache bool) (uint64, error) if err != nil { return handleBootTimeFileReadErr(err) } + currentTime := float64(time.Now().UnixNano()) / float64(time.Second) + if len(lines) != 1 { return 0, fmt.Errorf("wrong uptime format") } @@ -105,7 +109,6 @@ func BootTimeWithContext(ctx context.Context, enableCache bool) (uint64, error) if err != nil { return 0, err } - currentTime := float64(time.Now().UnixNano()) / float64(time.Second) t := currentTime - b if enableCache { diff --git a/vendor/github.com/shirou/gopsutil/v4/internal/common/common_unix.go b/vendor/github.com/shirou/gopsutil/v4/internal/common/common_unix.go index 2715b890bef70..c9f91b1698ae1 100644 --- a/vendor/github.com/shirou/gopsutil/v4/internal/common/common_unix.go +++ b/vendor/github.com/shirou/gopsutil/v4/internal/common/common_unix.go @@ -40,23 +40,3 @@ func CallLsofWithContext(ctx context.Context, invoke Invoker, pid int32, args .. } return ret, nil } - -func CallPgrepWithContext(ctx context.Context, invoke Invoker, pid int32) ([]int32, error) { - out, err := invoke.CommandWithContext(ctx, "pgrep", "-P", strconv.Itoa(int(pid))) - if err != nil { - return []int32{}, err - } - lines := strings.Split(string(out), "\n") - ret := make([]int32, 0, len(lines)) - for _, l := range lines { - if len(l) == 0 { - continue - } - i, err := strconv.ParseInt(l, 10, 32) - if err != nil { - continue - } - ret = append(ret, int32(i)) - } - return ret, nil -} diff --git a/vendor/github.com/shirou/gopsutil/v4/internal/common/sleep.go b/vendor/github.com/shirou/gopsutil/v4/internal/common/sleep.go index 8108a1caca7b1..504f13ffd9801 100644 --- a/vendor/github.com/shirou/gopsutil/v4/internal/common/sleep.go +++ b/vendor/github.com/shirou/gopsutil/v4/internal/common/sleep.go @@ -7,7 +7,7 @@ import ( ) // Sleep awaits for provided interval. -// Can be interrupted by context cancelation. +// Can be interrupted by context cancellation. func Sleep(ctx context.Context, interval time.Duration) error { timer := time.NewTimer(interval) select { diff --git a/vendor/github.com/shirou/gopsutil/v4/mem/mem_aix.go b/vendor/github.com/shirou/gopsutil/v4/mem/mem_aix.go index 916bff30df3e1..ac2c39dd38251 100644 --- a/vendor/github.com/shirou/gopsutil/v4/mem/mem_aix.go +++ b/vendor/github.com/shirou/gopsutil/v4/mem/mem_aix.go @@ -5,6 +5,8 @@ package mem import ( "context" + + "github.com/shirou/gopsutil/v4/internal/common" ) func VirtualMemory() (*VirtualMemoryStat, error) { @@ -14,3 +16,7 @@ func VirtualMemory() (*VirtualMemoryStat, error) { func SwapMemory() (*SwapMemoryStat, error) { return SwapMemoryWithContext(context.Background()) } + +func SwapDevices() ([]*SwapDevice, error) { + return nil, common.ErrNotImplementedError +} diff --git a/vendor/github.com/shirou/gopsutil/v4/mem/mem_aix_nocgo.go b/vendor/github.com/shirou/gopsutil/v4/mem/mem_aix_nocgo.go index cfcc4f90f16e4..bc3c0ed3b4a86 100644 --- a/vendor/github.com/shirou/gopsutil/v4/mem/mem_aix_nocgo.go +++ b/vendor/github.com/shirou/gopsutil/v4/mem/mem_aix_nocgo.go @@ -12,7 +12,7 @@ import ( ) func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) { - vmem, swap, err := callSVMon(ctx) + vmem, swap, err := callSVMon(ctx, true) if err != nil { return nil, err } @@ -25,7 +25,7 @@ func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) { } func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) { - _, swap, err := callSVMon(ctx) + _, swap, err := callSVMon(ctx, false) if err != nil { return nil, err } @@ -35,7 +35,7 @@ func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) { return swap, nil } -func callSVMon(ctx context.Context) (*VirtualMemoryStat, *SwapMemoryStat, error) { +func callSVMon(ctx context.Context, virt bool) (*VirtualMemoryStat, *SwapMemoryStat, error) { out, err := invoke.CommandWithContext(ctx, "svmon", "-G") if err != nil { return nil, nil, err @@ -45,7 +45,7 @@ func callSVMon(ctx context.Context) (*VirtualMemoryStat, *SwapMemoryStat, error) vmem := &VirtualMemoryStat{} swap := &SwapMemoryStat{} for _, line := range strings.Split(string(out), "\n") { - if strings.HasPrefix(line, "memory") { + if virt && strings.HasPrefix(line, "memory") { p := strings.Fields(line) if len(p) > 2 { if t, err := strconv.ParseUint(p[1], 10, 64); err == nil { diff --git a/vendor/github.com/shirou/gopsutil/v4/mem/mem_darwin.go b/vendor/github.com/shirou/gopsutil/v4/mem/mem_darwin.go index a33c5f125a2b0..a4c15f6915d97 100644 --- a/vendor/github.com/shirou/gopsutil/v4/mem/mem_darwin.go +++ b/vendor/github.com/shirou/gopsutil/v4/mem/mem_darwin.go @@ -70,3 +70,61 @@ func SwapDevices() ([]*SwapDevice, error) { func SwapDevicesWithContext(ctx context.Context) ([]*SwapDevice, error) { return nil, common.ErrNotImplementedError } + +type vmStatisticsData struct { + freeCount uint32 + activeCount uint32 + inactiveCount uint32 + wireCount uint32 + _ [44]byte // Not used here +} + +// VirtualMemory returns VirtualmemoryStat. +func VirtualMemory() (*VirtualMemoryStat, error) { + return VirtualMemoryWithContext(context.Background()) +} + +func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) { + machLib, err := common.NewLibrary(common.System) + if err != nil { + return nil, err + } + defer machLib.Close() + + hostStatistics := common.GetFunc[common.HostStatisticsFunc](machLib, common.HostStatisticsSym) + machHostSelf := common.GetFunc[common.MachHostSelfFunc](machLib, common.MachHostSelfSym) + + count := uint32(common.HOST_VM_INFO_COUNT) + var vmstat vmStatisticsData + + status := hostStatistics(machHostSelf(), common.HOST_VM_INFO, + uintptr(unsafe.Pointer(&vmstat)), &count) + + if status != common.KERN_SUCCESS { + return nil, fmt.Errorf("host_statistics error=%d", status) + } + + pageSizeAddr, _ := machLib.Dlsym("vm_kernel_page_size") + pageSize := **(**uint64)(unsafe.Pointer(&pageSizeAddr)) + total, err := getHwMemsize() + if err != nil { + return nil, err + } + totalCount := uint32(total / pageSize) + + availableCount := vmstat.inactiveCount + vmstat.freeCount + usedPercent := 100 * float64(totalCount-availableCount) / float64(totalCount) + + usedCount := totalCount - availableCount + + return &VirtualMemoryStat{ + Total: total, + Available: pageSize * uint64(availableCount), + Used: pageSize * uint64(usedCount), + UsedPercent: usedPercent, + Free: pageSize * uint64(vmstat.freeCount), + Active: pageSize * uint64(vmstat.activeCount), + Inactive: pageSize * uint64(vmstat.inactiveCount), + Wired: pageSize * uint64(vmstat.wireCount), + }, nil +} diff --git a/vendor/github.com/shirou/gopsutil/v4/mem/mem_darwin_cgo.go b/vendor/github.com/shirou/gopsutil/v4/mem/mem_darwin_cgo.go deleted file mode 100644 index cc6657d045c13..0000000000000 --- a/vendor/github.com/shirou/gopsutil/v4/mem/mem_darwin_cgo.go +++ /dev/null @@ -1,58 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -//go:build darwin && cgo - -package mem - -/* -#include -#include -*/ -import "C" - -import ( - "context" - "fmt" - "unsafe" -) - -// VirtualMemory returns VirtualmemoryStat. -func VirtualMemory() (*VirtualMemoryStat, error) { - return VirtualMemoryWithContext(context.Background()) -} - -func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) { - count := C.mach_msg_type_number_t(C.HOST_VM_INFO_COUNT) - var vmstat C.vm_statistics_data_t - - status := C.host_statistics(C.host_t(C.mach_host_self()), - C.HOST_VM_INFO, - C.host_info_t(unsafe.Pointer(&vmstat)), - &count) - - if status != C.KERN_SUCCESS { - return nil, fmt.Errorf("host_statistics error=%d", status) - } - - pageSize := uint64(C.vm_kernel_page_size) - total, err := getHwMemsize() - if err != nil { - return nil, err - } - totalCount := C.natural_t(total / pageSize) - - availableCount := vmstat.inactive_count + vmstat.free_count - usedPercent := 100 * float64(totalCount-availableCount) / float64(totalCount) - - usedCount := totalCount - availableCount - - return &VirtualMemoryStat{ - Total: total, - Available: pageSize * uint64(availableCount), - Used: pageSize * uint64(usedCount), - UsedPercent: usedPercent, - Free: pageSize * uint64(vmstat.free_count), - Active: pageSize * uint64(vmstat.active_count), - Inactive: pageSize * uint64(vmstat.inactive_count), - Wired: pageSize * uint64(vmstat.wire_count), - }, nil -} diff --git a/vendor/github.com/shirou/gopsutil/v4/mem/mem_darwin_nocgo.go b/vendor/github.com/shirou/gopsutil/v4/mem/mem_darwin_nocgo.go deleted file mode 100644 index 097a93e63e4cc..0000000000000 --- a/vendor/github.com/shirou/gopsutil/v4/mem/mem_darwin_nocgo.go +++ /dev/null @@ -1,89 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -//go:build darwin && !cgo - -package mem - -import ( - "context" - "strconv" - "strings" - - "golang.org/x/sys/unix" -) - -// Runs vm_stat and returns Free and inactive pages -func getVMStat(vms *VirtualMemoryStat) error { - out, err := invoke.Command("vm_stat") - if err != nil { - return err - } - return parseVMStat(string(out), vms) -} - -func parseVMStat(out string, vms *VirtualMemoryStat) error { - var err error - - lines := strings.Split(out, "\n") - pagesize := uint64(unix.Getpagesize()) - for _, line := range lines { - fields := strings.Split(line, ":") - if len(fields) < 2 { - continue - } - key := strings.TrimSpace(fields[0]) - value := strings.Trim(fields[1], " .") - switch key { - case "Pages free": - free, e := strconv.ParseUint(value, 10, 64) - if e != nil { - err = e - } - vms.Free = free * pagesize - case "Pages inactive": - inactive, e := strconv.ParseUint(value, 10, 64) - if e != nil { - err = e - } - vms.Inactive = inactive * pagesize - case "Pages active": - active, e := strconv.ParseUint(value, 10, 64) - if e != nil { - err = e - } - vms.Active = active * pagesize - case "Pages wired down": - wired, e := strconv.ParseUint(value, 10, 64) - if e != nil { - err = e - } - vms.Wired = wired * pagesize - } - } - return err -} - -// VirtualMemory returns VirtualmemoryStat. -func VirtualMemory() (*VirtualMemoryStat, error) { - return VirtualMemoryWithContext(context.Background()) -} - -func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) { - ret := &VirtualMemoryStat{} - - total, err := getHwMemsize() - if err != nil { - return nil, err - } - err = getVMStat(ret) - if err != nil { - return nil, err - } - - ret.Available = ret.Free + ret.Inactive - ret.Total = total - - ret.Used = ret.Total - ret.Available - ret.UsedPercent = 100 * float64(ret.Used) / float64(ret.Total) - - return ret, nil -} diff --git a/vendor/github.com/shirou/gopsutil/v4/mem/mem_freebsd.go b/vendor/github.com/shirou/gopsutil/v4/mem/mem_freebsd.go index d9cae7116b240..a6deddebdd832 100644 --- a/vendor/github.com/shirou/gopsutil/v4/mem/mem_freebsd.go +++ b/vendor/github.com/shirou/gopsutil/v4/mem/mem_freebsd.go @@ -8,8 +8,9 @@ import ( "errors" "unsafe" - "github.com/shirou/gopsutil/v4/internal/common" "golang.org/x/sys/unix" + + "github.com/shirou/gopsutil/v4/internal/common" ) func VirtualMemory() (*VirtualMemoryStat, error) { @@ -85,7 +86,6 @@ func SwapMemory() (*SwapMemoryStat, error) { } // Constants from vm/vm_param.h -// nolint: golint const ( XSWDEV_VERSION11 = 1 XSWDEV_VERSION = 2 diff --git a/vendor/github.com/shirou/gopsutil/v4/mem/mem_windows.go b/vendor/github.com/shirou/gopsutil/v4/mem/mem_windows.go index 4666cbd01e8bc..522cfd1b38df6 100644 --- a/vendor/github.com/shirou/gopsutil/v4/mem/mem_windows.go +++ b/vendor/github.com/shirou/gopsutil/v4/mem/mem_windows.go @@ -77,26 +77,40 @@ func SwapMemory() (*SwapMemoryStat, error) { } func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) { + // Use the performance counter to get the swap usage percentage + counter, err := common.NewWin32PerformanceCounter("swap_percentage", `\Paging File(_Total)\% Usage`) + if err != nil { + return nil, err + } + usedPercent, err := counter.GetValue() + if err != nil { + return nil, err + } + + // Get total memory from performance information var perfInfo performanceInformation perfInfo.cb = uint32(unsafe.Sizeof(perfInfo)) mem, _, _ := procGetPerformanceInfo.Call(uintptr(unsafe.Pointer(&perfInfo)), uintptr(perfInfo.cb)) if mem == 0 { return nil, windows.GetLastError() } - tot := perfInfo.commitLimit * perfInfo.pageSize - used := perfInfo.commitTotal * perfInfo.pageSize - free := tot - used - var usedPercent float64 - if tot == 0 { - usedPercent = 0 + totalPhys := perfInfo.physicalTotal * perfInfo.pageSize + totalSys := perfInfo.commitLimit * perfInfo.pageSize + total := totalSys - totalPhys + + var used uint64 + if total > 0 { + used = uint64(0.01 * usedPercent * float64(total)) } else { - usedPercent = float64(used) / float64(tot) * 100 + usedPercent = 0.0 + used = 0 } + ret := &SwapMemoryStat{ - Total: tot, + Total: total, Used: used, - Free: free, - UsedPercent: usedPercent, + Free: total - used, + UsedPercent: common.Round(usedPercent, 1), } return ret, nil diff --git a/vendor/github.com/shirou/gopsutil/v4/net/net_aix.go b/vendor/github.com/shirou/gopsutil/v4/net/net_aix.go index df59abecbe1ad..08a100d811ae8 100644 --- a/vendor/github.com/shirou/gopsutil/v4/net/net_aix.go +++ b/vendor/github.com/shirou/gopsutil/v4/net/net_aix.go @@ -117,7 +117,7 @@ func parseNetstatAddr(local string, remote string, family uint32) (laddr Addr, r return Addr{}, fmt.Errorf("unknown family, %d", family) } } - lport, err := strconv.Atoi(port) + lport, err := strconv.ParseInt(port, 10, 32) if err != nil { return Addr{}, err } @@ -286,11 +286,11 @@ func ConnectionsWithContext(ctx context.Context, kind string) ([]ConnectionStat, return ret, nil } -func ConnectionsMax(kind string, max int) ([]ConnectionStat, error) { - return ConnectionsMaxWithContext(context.Background(), kind, max) +func ConnectionsMax(kind string, maxConn int) ([]ConnectionStat, error) { + return ConnectionsMaxWithContext(context.Background(), kind, maxConn) } -func ConnectionsMaxWithContext(ctx context.Context, kind string, max int) ([]ConnectionStat, error) { +func ConnectionsMaxWithContext(ctx context.Context, kind string, maxConn int) ([]ConnectionStat, error) { return []ConnectionStat{}, common.ErrNotImplementedError } @@ -305,8 +305,8 @@ func ConnectionsWithoutUidsWithContext(ctx context.Context, kind string) ([]Conn return ConnectionsMaxWithoutUidsWithContext(ctx, kind, 0) } -func ConnectionsMaxWithoutUidsWithContext(ctx context.Context, kind string, max int) ([]ConnectionStat, error) { - return ConnectionsPidMaxWithoutUidsWithContext(ctx, kind, 0, max) +func ConnectionsMaxWithoutUidsWithContext(ctx context.Context, kind string, maxConn int) ([]ConnectionStat, error) { + return ConnectionsPidMaxWithoutUidsWithContext(ctx, kind, 0, maxConn) } func ConnectionsPidWithoutUids(kind string, pid int32) ([]ConnectionStat, error) { @@ -317,14 +317,14 @@ func ConnectionsPidWithoutUidsWithContext(ctx context.Context, kind string, pid return ConnectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, 0) } -func ConnectionsPidMaxWithoutUids(kind string, pid int32, max int) ([]ConnectionStat, error) { - return ConnectionsPidMaxWithoutUidsWithContext(context.Background(), kind, pid, max) +func ConnectionsPidMaxWithoutUids(kind string, pid int32, maxConn int) ([]ConnectionStat, error) { + return ConnectionsPidMaxWithoutUidsWithContext(context.Background(), kind, pid, maxConn) } -func ConnectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, max int) ([]ConnectionStat, error) { - return connectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, max) +func ConnectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, maxConn int) ([]ConnectionStat, error) { + return connectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, maxConn) } -func connectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, max int) ([]ConnectionStat, error) { +func connectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, maxConn int) ([]ConnectionStat, error) { return []ConnectionStat{}, common.ErrNotImplementedError } diff --git a/vendor/github.com/shirou/gopsutil/v4/net/net_darwin.go b/vendor/github.com/shirou/gopsutil/v4/net/net_darwin.go index f86b7bf9e3b8e..8f3f4d386ddf3 100644 --- a/vendor/github.com/shirou/gopsutil/v4/net/net_darwin.go +++ b/vendor/github.com/shirou/gopsutil/v4/net/net_darwin.go @@ -143,8 +143,8 @@ func newMapInterfaceNameUsage(ifaces []netstatInterface) mapInterfaceNameUsage { return output } -func (min mapInterfaceNameUsage) isTruncated() bool { - for _, usage := range min { +func (mapi mapInterfaceNameUsage) isTruncated() bool { + for _, usage := range mapi { if usage > 1 { return true } @@ -152,9 +152,9 @@ func (min mapInterfaceNameUsage) isTruncated() bool { return false } -func (min mapInterfaceNameUsage) notTruncated() []string { +func (mapi mapInterfaceNameUsage) notTruncated() []string { output := make([]string, 0) - for ifaceName, usage := range min { + for ifaceName, usage := range mapi { if usage == 1 { output = append(output, ifaceName) } @@ -247,7 +247,7 @@ func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat, } } - if pernic == false { + if !pernic { return getIOCountersAll(ret) } return ret, nil diff --git a/vendor/github.com/shirou/gopsutil/v4/net/net_fallback.go b/vendor/github.com/shirou/gopsutil/v4/net/net_fallback.go index e62deeeed3616..a765e216b880a 100644 --- a/vendor/github.com/shirou/gopsutil/v4/net/net_fallback.go +++ b/vendor/github.com/shirou/gopsutil/v4/net/net_fallback.go @@ -49,11 +49,11 @@ func ConnectionsWithContext(ctx context.Context, kind string) ([]ConnectionStat, return []ConnectionStat{}, common.ErrNotImplementedError } -func ConnectionsMax(kind string, max int) ([]ConnectionStat, error) { - return ConnectionsMaxWithContext(context.Background(), kind, max) +func ConnectionsMax(kind string, maxConn int) ([]ConnectionStat, error) { + return ConnectionsMaxWithContext(context.Background(), kind, maxConn) } -func ConnectionsMaxWithContext(ctx context.Context, kind string, max int) ([]ConnectionStat, error) { +func ConnectionsMaxWithContext(ctx context.Context, kind string, maxConn int) ([]ConnectionStat, error) { return []ConnectionStat{}, common.ErrNotImplementedError } @@ -68,8 +68,8 @@ func ConnectionsWithoutUidsWithContext(ctx context.Context, kind string) ([]Conn return ConnectionsMaxWithoutUidsWithContext(ctx, kind, 0) } -func ConnectionsMaxWithoutUidsWithContext(ctx context.Context, kind string, max int) ([]ConnectionStat, error) { - return ConnectionsPidMaxWithoutUidsWithContext(ctx, kind, 0, max) +func ConnectionsMaxWithoutUidsWithContext(ctx context.Context, kind string, maxConn int) ([]ConnectionStat, error) { + return ConnectionsPidMaxWithoutUidsWithContext(ctx, kind, 0, maxConn) } func ConnectionsPidWithoutUids(kind string, pid int32) ([]ConnectionStat, error) { @@ -80,14 +80,14 @@ func ConnectionsPidWithoutUidsWithContext(ctx context.Context, kind string, pid return ConnectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, 0) } -func ConnectionsPidMaxWithoutUids(kind string, pid int32, max int) ([]ConnectionStat, error) { - return ConnectionsPidMaxWithoutUidsWithContext(context.Background(), kind, pid, max) +func ConnectionsPidMaxWithoutUids(kind string, pid int32, maxConn int) ([]ConnectionStat, error) { + return ConnectionsPidMaxWithoutUidsWithContext(context.Background(), kind, pid, maxConn) } -func ConnectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, max int) ([]ConnectionStat, error) { - return connectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, max) +func ConnectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, maxConn int) ([]ConnectionStat, error) { + return connectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, maxConn) } -func connectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, max int) ([]ConnectionStat, error) { +func connectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, maxConn int) ([]ConnectionStat, error) { return []ConnectionStat{}, common.ErrNotImplementedError } diff --git a/vendor/github.com/shirou/gopsutil/v4/net/net_freebsd.go b/vendor/github.com/shirou/gopsutil/v4/net/net_freebsd.go index 155a49c404522..ccaab73e0b3ea 100644 --- a/vendor/github.com/shirou/gopsutil/v4/net/net_freebsd.go +++ b/vendor/github.com/shirou/gopsutil/v4/net/net_freebsd.go @@ -83,7 +83,7 @@ func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat, ret = append(ret, n) } - if pernic == false { + if !pernic { return getIOCountersAll(ret) } @@ -96,7 +96,7 @@ func IOCountersByFile(pernic bool, filename string) ([]IOCountersStat, error) { } func IOCountersByFileWithContext(ctx context.Context, pernic bool, filename string) ([]IOCountersStat, error) { - return IOCounters(pernic) + return IOCountersWithContext(ctx, pernic) } func FilterCounters() ([]FilterStat, error) { diff --git a/vendor/github.com/shirou/gopsutil/v4/net/net_linux.go b/vendor/github.com/shirou/gopsutil/v4/net/net_linux.go index 6db04b6279bf9..2c79facb05738 100644 --- a/vendor/github.com/shirou/gopsutil/v4/net/net_linux.go +++ b/vendor/github.com/shirou/gopsutil/v4/net/net_linux.go @@ -238,14 +238,14 @@ func FilterCountersWithContext(ctx context.Context) ([]FilterStat, error) { } stats := make([]FilterStat, 0, 1) - max, err := common.ReadInts(maxfile) + maxConn, err := common.ReadInts(maxfile) if err != nil { return nil, err } payload := FilterStat{ ConnTrackCount: count[0], - ConnTrackMax: max[0], + ConnTrackMax: maxConn[0], } stats = append(stats, payload) @@ -396,12 +396,12 @@ func ConnectionsWithContext(ctx context.Context, kind string) ([]ConnectionStat, // Return a list of network connections opened returning at most `max` // connections for each running process. -func ConnectionsMax(kind string, max int) ([]ConnectionStat, error) { - return ConnectionsMaxWithContext(context.Background(), kind, max) +func ConnectionsMax(kind string, maxConn int) ([]ConnectionStat, error) { + return ConnectionsMaxWithContext(context.Background(), kind, maxConn) } -func ConnectionsMaxWithContext(ctx context.Context, kind string, max int) ([]ConnectionStat, error) { - return ConnectionsPidMaxWithContext(ctx, kind, 0, max) +func ConnectionsMaxWithContext(ctx context.Context, kind string, maxConn int) ([]ConnectionStat, error) { + return ConnectionsPidMaxWithContext(ctx, kind, 0, maxConn) } // Return a list of network connections opened, omitting `Uids`. @@ -415,8 +415,8 @@ func ConnectionsWithoutUidsWithContext(ctx context.Context, kind string) ([]Conn return ConnectionsMaxWithoutUidsWithContext(ctx, kind, 0) } -func ConnectionsMaxWithoutUidsWithContext(ctx context.Context, kind string, max int) ([]ConnectionStat, error) { - return ConnectionsPidMaxWithoutUidsWithContext(ctx, kind, 0, max) +func ConnectionsMaxWithoutUidsWithContext(ctx context.Context, kind string, maxConn int) ([]ConnectionStat, error) { + return ConnectionsPidMaxWithoutUidsWithContext(ctx, kind, 0, maxConn) } // Return a list of network connections opened by a process. @@ -437,23 +437,23 @@ func ConnectionsPidWithoutUidsWithContext(ctx context.Context, kind string, pid } // Return up to `max` network connections opened by a process. -func ConnectionsPidMax(kind string, pid int32, max int) ([]ConnectionStat, error) { - return ConnectionsPidMaxWithContext(context.Background(), kind, pid, max) +func ConnectionsPidMax(kind string, pid int32, maxConn int) ([]ConnectionStat, error) { + return ConnectionsPidMaxWithContext(context.Background(), kind, pid, maxConn) } -func ConnectionsPidMaxWithoutUids(kind string, pid int32, max int) ([]ConnectionStat, error) { - return ConnectionsPidMaxWithoutUidsWithContext(context.Background(), kind, pid, max) +func ConnectionsPidMaxWithoutUids(kind string, pid int32, maxConn int) ([]ConnectionStat, error) { + return ConnectionsPidMaxWithoutUidsWithContext(context.Background(), kind, pid, maxConn) } -func ConnectionsPidMaxWithContext(ctx context.Context, kind string, pid int32, max int) ([]ConnectionStat, error) { - return connectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, max, false) +func ConnectionsPidMaxWithContext(ctx context.Context, kind string, pid int32, maxConn int) ([]ConnectionStat, error) { + return connectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, maxConn, false) } -func ConnectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, max int) ([]ConnectionStat, error) { - return connectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, max, true) +func ConnectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, maxConn int) ([]ConnectionStat, error) { + return connectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, maxConn, true) } -func connectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, max int, skipUids bool) ([]ConnectionStat, error) { +func connectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, maxConn int, skipUids bool) ([]ConnectionStat, error) { tmap, ok := netConnectionKindMap[kind] if !ok { return nil, fmt.Errorf("invalid kind, %s", kind) @@ -462,16 +462,16 @@ func connectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, p var err error var inodes map[string][]inodeMap if pid == 0 { - inodes, err = getProcInodesAllWithContext(ctx, root, max) + inodes, err = getProcInodesAllWithContext(ctx, root, maxConn) } else { - inodes, err = getProcInodes(root, pid, max) + inodes, err = getProcInodes(root, pid, maxConn) if len(inodes) == 0 { // no connection for the pid return []ConnectionStat{}, nil } } if err != nil { - return nil, fmt.Errorf("cound not get pid(s), %d: %w", pid, err) + return nil, fmt.Errorf("could not get pid(s), %d: %w", pid, err) } return statsFromInodesWithContext(ctx, root, pid, tmap, inodes, skipUids) } @@ -543,7 +543,7 @@ func statsFromInodesWithContext(ctx context.Context, root string, pid int32, tma } // getProcInodes returns fd of the pid. -func getProcInodes(root string, pid int32, max int) (map[string][]inodeMap, error) { +func getProcInodes(root string, pid int32, maxConn int) (map[string][]inodeMap, error) { ret := make(map[string][]inodeMap) dir := fmt.Sprintf("%s/%d/fd", root, pid) @@ -552,7 +552,7 @@ func getProcInodes(root string, pid int32, max int) (map[string][]inodeMap, erro return ret, err } defer f.Close() - dirEntries, err := f.ReadDir(max) + dirEntries, err := f.ReadDir(maxConn) if err != nil { return ret, err } @@ -573,7 +573,7 @@ func getProcInodes(root string, pid int32, max int) (map[string][]inodeMap, erro if !ok { ret[inode] = make([]inodeMap, 0) } - fd, err := strconv.Atoi(dirEntry.Name()) + fd, err := strconv.ParseInt(dirEntry.Name(), 10, 32) if err != nil { continue } @@ -668,11 +668,11 @@ func (p *process) fillFromStatus(ctx context.Context) error { return nil } -func getProcInodesAll(root string, max int) (map[string][]inodeMap, error) { - return getProcInodesAllWithContext(context.Background(), root, max) +func getProcInodesAll(root string, maxConn int) (map[string][]inodeMap, error) { + return getProcInodesAllWithContext(context.Background(), root, maxConn) } -func getProcInodesAllWithContext(ctx context.Context, root string, max int) (map[string][]inodeMap, error) { +func getProcInodesAllWithContext(ctx context.Context, root string, maxConn int) (map[string][]inodeMap, error) { pids, err := PidsWithContext(ctx) if err != nil { return nil, err @@ -680,7 +680,7 @@ func getProcInodesAllWithContext(ctx context.Context, root string, max int) (map ret := make(map[string][]inodeMap) for _, pid := range pids { - t, err := getProcInodes(root, pid, max) + t, err := getProcInodes(root, pid, maxConn) if err != nil { // skip if permission error or no longer exists if os.IsPermission(err) || os.IsNotExist(err) || errors.Is(err, io.EOF) { @@ -858,7 +858,7 @@ func processUnix(file string, kind netConnectionKindType, inodes map[string][]in if len(tokens) < 6 { continue } - st, err := strconv.Atoi(tokens[4]) + st, err := strconv.ParseInt(tokens[4], 10, 32) if err != nil { return nil, err } diff --git a/vendor/github.com/shirou/gopsutil/v4/net/net_openbsd.go b/vendor/github.com/shirou/gopsutil/v4/net/net_openbsd.go index 50e37fe4029ce..7fae18b936cfc 100644 --- a/vendor/github.com/shirou/gopsutil/v4/net/net_openbsd.go +++ b/vendor/github.com/shirou/gopsutil/v4/net/net_openbsd.go @@ -24,9 +24,9 @@ func ParseNetstat(output string, mode string, exists := make([]string, 0, len(lines)-1) - columns := 6 - if mode == "ind" { - columns = 10 + columns := 9 + if mode == "inb" { + columns = 6 } for _, line := range lines { values := strings.Fields(line) @@ -49,18 +49,23 @@ func ParseNetstat(output string, mode string, parsed := make([]uint64, 0, 8) var vv []string - if mode == "inb" { + switch mode { + case "inb": vv = []string{ values[base+3], // BytesRecv values[base+4], // BytesSent } - } else { + case "ind": vv = []string{ values[base+3], // Ipkts - values[base+4], // Ierrs + values[base+4], // Idrop values[base+5], // Opkts + values[base+6], // Odrops + } + case "ine": + vv = []string{ + values[base+4], // Ierrs values[base+6], // Oerrs - values[base+8], // Drops } } for _, target := range vv { @@ -81,16 +86,19 @@ func ParseNetstat(output string, mode string, if !present { n = IOCountersStat{Name: values[0]} } - if mode == "inb" { + + switch mode { + case "inb": n.BytesRecv = parsed[0] n.BytesSent = parsed[1] - } else { + case "ind": n.PacketsRecv = parsed[0] - n.Errin = parsed[1] + n.Dropin = parsed[1] n.PacketsSent = parsed[2] - n.Errout = parsed[3] - n.Dropin = parsed[4] - n.Dropout = parsed[4] + n.Dropout = parsed[3] + case "ine": + n.Errin = parsed[0] + n.Errout = parsed[1] } iocs[n.Name] = n @@ -115,6 +123,10 @@ func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat, if err != nil { return nil, err } + out3, err := invoke.CommandWithContext(ctx, netstat, "-ine") + if err != nil { + return nil, err + } iocs := make(map[string]IOCountersStat) lines := strings.Split(string(out), "\n") @@ -128,6 +140,10 @@ func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat, if err != nil { return nil, err } + err = ParseNetstat(string(out3), "ine", iocs) + if err != nil { + return nil, err + } for _, ioc := range iocs { ret = append(ret, ioc) @@ -239,7 +255,7 @@ func parseNetstatAddr(local string, remote string, family uint32) (laddr Addr, r return Addr{}, fmt.Errorf("unknown family, %d", family) } } - lport, err := strconv.Atoi(port) + lport, err := strconv.ParseInt(port, 10, 32) if err != nil { return Addr{}, err } diff --git a/vendor/github.com/shirou/gopsutil/v4/net/net_unix.go b/vendor/github.com/shirou/gopsutil/v4/net/net_unix.go index 71fc3b972a298..62f8907abf532 100644 --- a/vendor/github.com/shirou/gopsutil/v4/net/net_unix.go +++ b/vendor/github.com/shirou/gopsutil/v4/net/net_unix.go @@ -25,11 +25,11 @@ func ConnectionsWithContext(ctx context.Context, kind string) ([]ConnectionStat, // Return a list of network connections opened returning at most `max` // connections for each running process. -func ConnectionsMax(kind string, max int) ([]ConnectionStat, error) { - return ConnectionsMaxWithContext(context.Background(), kind, max) +func ConnectionsMax(kind string, maxConn int) ([]ConnectionStat, error) { + return ConnectionsMaxWithContext(context.Background(), kind, maxConn) } -func ConnectionsMaxWithContext(ctx context.Context, kind string, max int) ([]ConnectionStat, error) { +func ConnectionsMaxWithContext(ctx context.Context, kind string, maxConn int) ([]ConnectionStat, error) { return []ConnectionStat{}, common.ErrNotImplementedError } @@ -109,11 +109,11 @@ func parseNetLine(line string) (ConnectionStat, error) { f[7] = "unix" } - pid, err := strconv.Atoi(f[1]) + pid, err := strconv.ParseInt(f[1], 10, 32) if err != nil { return ConnectionStat{}, err } - fd, err := strconv.Atoi(strings.Trim(f[3], "u")) + fd, err := strconv.ParseInt(strings.Trim(f[3], "u"), 10, 32) if err != nil { return ConnectionStat{}, fmt.Errorf("unknown fd, %s", f[3]) } @@ -157,7 +157,7 @@ func parseNetAddr(line string) (laddr Addr, raddr Addr, err error) { if err != nil { return Addr{}, fmt.Errorf("wrong addr, %s", l) } - lport, err := strconv.Atoi(port) + lport, err := strconv.ParseInt(port, 10, 32) if err != nil { return Addr{}, err } @@ -180,11 +180,11 @@ func parseNetAddr(line string) (laddr Addr, raddr Addr, err error) { } // Return up to `max` network connections opened by a process. -func ConnectionsPidMax(kind string, pid int32, max int) ([]ConnectionStat, error) { - return ConnectionsPidMaxWithContext(context.Background(), kind, pid, max) +func ConnectionsPidMax(kind string, pid int32, maxConn int) ([]ConnectionStat, error) { + return ConnectionsPidMaxWithContext(context.Background(), kind, pid, maxConn) } -func ConnectionsPidMaxWithContext(ctx context.Context, kind string, pid int32, max int) ([]ConnectionStat, error) { +func ConnectionsPidMaxWithContext(ctx context.Context, kind string, pid int32, maxConn int) ([]ConnectionStat, error) { return []ConnectionStat{}, common.ErrNotImplementedError } @@ -199,8 +199,8 @@ func ConnectionsWithoutUidsWithContext(ctx context.Context, kind string) ([]Conn return ConnectionsMaxWithoutUidsWithContext(ctx, kind, 0) } -func ConnectionsMaxWithoutUidsWithContext(ctx context.Context, kind string, max int) ([]ConnectionStat, error) { - return ConnectionsPidMaxWithoutUidsWithContext(ctx, kind, 0, max) +func ConnectionsMaxWithoutUidsWithContext(ctx context.Context, kind string, maxConn int) ([]ConnectionStat, error) { + return ConnectionsPidMaxWithoutUidsWithContext(ctx, kind, 0, maxConn) } func ConnectionsPidWithoutUids(kind string, pid int32) ([]ConnectionStat, error) { @@ -211,14 +211,14 @@ func ConnectionsPidWithoutUidsWithContext(ctx context.Context, kind string, pid return ConnectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, 0) } -func ConnectionsPidMaxWithoutUids(kind string, pid int32, max int) ([]ConnectionStat, error) { - return ConnectionsPidMaxWithoutUidsWithContext(context.Background(), kind, pid, max) +func ConnectionsPidMaxWithoutUids(kind string, pid int32, maxConn int) ([]ConnectionStat, error) { + return ConnectionsPidMaxWithoutUidsWithContext(context.Background(), kind, pid, maxConn) } -func ConnectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, max int) ([]ConnectionStat, error) { - return connectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, max) +func ConnectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, maxConn int) ([]ConnectionStat, error) { + return connectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, maxConn) } -func connectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, max int) ([]ConnectionStat, error) { +func connectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, maxConn int) ([]ConnectionStat, error) { return []ConnectionStat{}, common.ErrNotImplementedError } diff --git a/vendor/github.com/shirou/gopsutil/v4/net/net_windows.go b/vendor/github.com/shirou/gopsutil/v4/net/net_windows.go index 12f62cda05bc5..f1145feab291f 100644 --- a/vendor/github.com/shirou/gopsutil/v4/net/net_windows.go +++ b/vendor/github.com/shirou/gopsutil/v4/net/net_windows.go @@ -279,11 +279,11 @@ func getNetStatWithKind(kindType netConnectionKindType) ([]ConnectionStat, error // Return a list of network connections opened returning at most `max` // connections for each running process. -func ConnectionsMax(kind string, max int) ([]ConnectionStat, error) { - return ConnectionsMaxWithContext(context.Background(), kind, max) +func ConnectionsMax(kind string, maxConn int) ([]ConnectionStat, error) { + return ConnectionsMaxWithContext(context.Background(), kind, maxConn) } -func ConnectionsMaxWithContext(ctx context.Context, kind string, max int) ([]ConnectionStat, error) { +func ConnectionsMaxWithContext(ctx context.Context, kind string, maxConn int) ([]ConnectionStat, error) { return []ConnectionStat{}, common.ErrNotImplementedError } @@ -298,8 +298,8 @@ func ConnectionsWithoutUidsWithContext(ctx context.Context, kind string) ([]Conn return ConnectionsMaxWithoutUidsWithContext(ctx, kind, 0) } -func ConnectionsMaxWithoutUidsWithContext(ctx context.Context, kind string, max int) ([]ConnectionStat, error) { - return ConnectionsPidMaxWithoutUidsWithContext(ctx, kind, 0, max) +func ConnectionsMaxWithoutUidsWithContext(ctx context.Context, kind string, maxConn int) ([]ConnectionStat, error) { + return ConnectionsPidMaxWithoutUidsWithContext(ctx, kind, 0, maxConn) } func ConnectionsPidWithoutUids(kind string, pid int32) ([]ConnectionStat, error) { @@ -310,15 +310,15 @@ func ConnectionsPidWithoutUidsWithContext(ctx context.Context, kind string, pid return ConnectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, 0) } -func ConnectionsPidMaxWithoutUids(kind string, pid int32, max int) ([]ConnectionStat, error) { - return ConnectionsPidMaxWithoutUidsWithContext(context.Background(), kind, pid, max) +func ConnectionsPidMaxWithoutUids(kind string, pid int32, maxConn int) ([]ConnectionStat, error) { + return ConnectionsPidMaxWithoutUidsWithContext(context.Background(), kind, pid, maxConn) } -func ConnectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, max int) ([]ConnectionStat, error) { - return connectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, max) +func ConnectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, maxConn int) ([]ConnectionStat, error) { + return connectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, maxConn) } -func connectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, max int) ([]ConnectionStat, error) { +func connectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, maxConn int) ([]ConnectionStat, error) { return []ConnectionStat{}, common.ErrNotImplementedError } diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process.go b/vendor/github.com/shirou/gopsutil/v4/process/process.go index 4082fc95a2c63..70411c61644db 100644 --- a/vendor/github.com/shirou/gopsutil/v4/process/process.go +++ b/vendor/github.com/shirou/gopsutil/v4/process/process.go @@ -18,7 +18,7 @@ import ( var ( invoke common.Invoker = common.Invoke{} - ErrorNoChildren = errors.New("process does not have children") + ErrorNoChildren = errors.New("process does not have children") // Deprecated: ErrorNoChildren is never returned by process.Children(), check its returned []*Process slice length instead ErrorProcessNotRunning = errors.New("process does not exist") ErrorNotPermitted = errors.New("operation not permitted") ) @@ -103,10 +103,18 @@ type RlimitStat struct { } type IOCountersStat struct { - ReadCount uint64 `json:"readCount"` + // ReadCount is a number of read I/O operations such as syscalls. + ReadCount uint64 `json:"readCount"` + // WriteCount is a number of read I/O operations such as syscalls. WriteCount uint64 `json:"writeCount"` - ReadBytes uint64 `json:"readBytes"` + // ReadBytes is a number of all I/O read in bytes. This includes disk I/O on Linux and Windows. + ReadBytes uint64 `json:"readBytes"` + // WriteBytes is a number of all I/O write in bytes. This includes disk I/O on Linux and Windows. WriteBytes uint64 `json:"writeBytes"` + // DiskReadBytes is a number of disk I/O write in bytes. Currently only Linux has this value. + DiskReadBytes uint64 `json:"diskReadBytes"` + // DiskWriteBytes is a number of disk I/O read in bytes. Currently only Linux has this value. + DiskWriteBytes uint64 `json:"diskWriteBytes"` } type NumCtxSwitchesStat struct { @@ -317,7 +325,11 @@ func calculatePercent(t1, t2 *cpu.TimesStat, delta float64, numcpu int) float64 if delta == 0 { return 0 } - delta_proc := t2.Total() - t1.Total() + // https://github.com/giampaolo/psutil/blob/c034e6692cf736b5e87d14418a8153bb03f6cf42/psutil/__init__.py#L1064 + delta_proc := (t2.User - t1.User) + (t2.System - t1.System) + if delta_proc <= 0 { + return 0 + } overall_percent := ((delta_proc / delta) * 100) * float64(numcpu) return overall_percent } @@ -539,8 +551,8 @@ func (p *Process) Connections() ([]net.ConnectionStat, error) { } // ConnectionsMax returns a slice of net.ConnectionStat used by the process at most `max`. -func (p *Process) ConnectionsMax(max int) ([]net.ConnectionStat, error) { - return p.ConnectionsMaxWithContext(context.Background(), max) +func (p *Process) ConnectionsMax(maxConn int) ([]net.ConnectionStat, error) { + return p.ConnectionsMaxWithContext(context.Background(), maxConn) } // MemoryMaps get memory maps from /proc/(pid)/smaps diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_darwin.go b/vendor/github.com/shirou/gopsutil/v4/process/process_darwin.go index 5231007c3c377..05c7562b767c1 100644 --- a/vendor/github.com/shirou/gopsutil/v4/process/process_darwin.go +++ b/vendor/github.com/shirou/gopsutil/v4/process/process_darwin.go @@ -4,15 +4,20 @@ package process import ( + "bytes" "context" + "encoding/binary" "fmt" "path/filepath" + "runtime" + "sort" "strconv" "strings" + "unsafe" - "github.com/tklauser/go-sysconf" "golang.org/x/sys/unix" + "github.com/shirou/gopsutil/v4/cpu" "github.com/shirou/gopsutil/v4/internal/common" "github.com/shirou/gopsutil/v4/net" ) @@ -27,16 +32,6 @@ const ( KernProcPathname = 12 // path to executable ) -var clockTicks = 100 // default value - -func init() { - clkTck, err := sysconf.Sysconf(sysconf.SC_CLK_TCK) - // ignore errors - if err == nil { - clockTicks = int(clkTck) - } -} - type _Ctype_struct___0 struct { Pad uint64 } @@ -186,65 +181,22 @@ func (p *Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, e return nil, common.ErrNotImplementedError } -func convertCPUTimes(s string) (ret float64, err error) { - var t int - var _tmp string - if strings.Contains(s, ":") { - _t := strings.Split(s, ":") - switch len(_t) { - case 3: - hour, err := strconv.Atoi(_t[0]) - if err != nil { - return ret, err - } - t += hour * 60 * 60 * clockTicks - - mins, err := strconv.Atoi(_t[1]) - if err != nil { - return ret, err - } - t += mins * 60 * clockTicks - _tmp = _t[2] - case 2: - mins, err := strconv.Atoi(_t[0]) - if err != nil { - return ret, err - } - t += mins * 60 * clockTicks - _tmp = _t[1] - case 1, 0: - _tmp = s - default: - return ret, fmt.Errorf("wrong cpu time string") - } - } else { - _tmp = s - } - - _t := strings.Split(_tmp, ".") - if err != nil { - return ret, err - } - h, err := strconv.Atoi(_t[0]) - t += h * clockTicks - h, err = strconv.Atoi(_t[1]) - t += h - return float64(t) / float64(clockTicks), nil -} - func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) { - pids, err := common.CallPgrepWithContext(ctx, invoke, p.Pid) + procs, err := ProcessesWithContext(ctx) if err != nil { - return nil, err + return nil, nil } - ret := make([]*Process, 0, len(pids)) - for _, pid := range pids { - np, err := NewProcessWithContext(ctx, pid) + ret := make([]*Process, 0, len(procs)) + for _, proc := range procs { + ppid, err := proc.PpidWithContext(ctx) if err != nil { - return nil, err + continue + } + if ppid == p.Pid { + ret = append(ret, proc) } - ret = append(ret, np) } + sort.Slice(ret, func(i, j int) bool { return ret[i].Pid < ret[j].Pid }) return ret, nil } @@ -252,8 +204,8 @@ func (p *Process) ConnectionsWithContext(ctx context.Context) ([]net.ConnectionS return net.ConnectionsPidWithContext(ctx, "all", p.Pid) } -func (p *Process) ConnectionsMaxWithContext(ctx context.Context, max int) ([]net.ConnectionStat, error) { - return net.ConnectionsPidMaxWithContext(ctx, "all", p.Pid, max) +func (p *Process) ConnectionsMaxWithContext(ctx context.Context, maxConn int) ([]net.ConnectionStat, error) { + return net.ConnectionsPidMaxWithContext(ctx, "all", p.Pid, maxConn) } func ProcessesWithContext(ctx context.Context) ([]*Process, error) { @@ -323,3 +275,206 @@ func callPsWithContext(ctx context.Context, arg string, pid int32, threadOption return ret, nil } + +var ( + procPidPath common.ProcPidPathFunc + procPidInfo common.ProcPidInfoFunc + machTimeBaseInfo common.MachTimeBaseInfoFunc +) + +func registerFuncs() (*common.Library, error) { + lib, err := common.NewLibrary(common.System) + if err != nil { + return nil, err + } + + procPidPath = common.GetFunc[common.ProcPidPathFunc](lib, common.ProcPidPathSym) + procPidInfo = common.GetFunc[common.ProcPidInfoFunc](lib, common.ProcPidInfoSym) + machTimeBaseInfo = common.GetFunc[common.MachTimeBaseInfoFunc](lib, common.MachTimeBaseInfoSym) + + return lib, nil +} + +func getTimeScaleToNanoSeconds() float64 { + var timeBaseInfo common.MachTimeBaseInfo + + machTimeBaseInfo(uintptr(unsafe.Pointer(&timeBaseInfo))) + + return float64(timeBaseInfo.Numer) / float64(timeBaseInfo.Denom) +} + +func (p *Process) ExeWithContext(ctx context.Context) (string, error) { + lib, err := registerFuncs() + if err != nil { + return "", err + } + defer lib.Close() + + buf := make([]byte, common.PROC_PIDPATHINFO_MAXSIZE) + ret := procPidPath(p.Pid, uintptr(unsafe.Pointer(&buf[0])), common.PROC_PIDPATHINFO_MAXSIZE) + + if ret <= 0 { + return "", fmt.Errorf("unknown error: proc_pidpath returned %d", ret) + } + + return common.GoString(&buf[0]), nil +} + +// sys/proc_info.h +type vnodePathInfo struct { + _ [152]byte + vipPath [common.MAXPATHLEN]byte + _ [1176]byte +} + +// CwdWithContext retrieves the Current Working Directory for the given process. +// It uses the proc_pidinfo from libproc and will only work for processes the +// EUID can access. Otherwise "operation not permitted" will be returned as the +// error. +// Note: This might also work for other *BSD OSs. +func (p *Process) CwdWithContext(ctx context.Context) (string, error) { + lib, err := registerFuncs() + if err != nil { + return "", err + } + defer lib.Close() + + runtime.LockOSThread() + defer runtime.UnlockOSThread() + + var vpi vnodePathInfo + const vpiSize = int32(unsafe.Sizeof(vpi)) + ret := procPidInfo(p.Pid, common.PROC_PIDVNODEPATHINFO, 0, uintptr(unsafe.Pointer(&vpi)), vpiSize) + errno, _ := lib.Dlsym("errno") + err = *(**unix.Errno)(unsafe.Pointer(&errno)) + if err == unix.EPERM { + return "", ErrorNotPermitted + } + + if ret <= 0 { + return "", fmt.Errorf("unknown error: proc_pidinfo returned %d", ret) + } + + if ret != vpiSize { + return "", fmt.Errorf("too few bytes; expected %d, got %d", vpiSize, ret) + } + return common.GoString(&vpi.vipPath[0]), nil +} + +func procArgs(pid int32) ([]byte, int, error) { + procargs, _, err := common.CallSyscall([]int32{common.CTL_KERN, common.KERN_PROCARGS2, pid}) + if err != nil { + return nil, 0, err + } + nargs := procargs[:4] + return procargs, int(binary.LittleEndian.Uint32(nargs)), nil +} + +func (p *Process) CmdlineSliceWithContext(ctx context.Context) ([]string, error) { + return p.cmdlineSliceWithContext(ctx, true) +} + +func (p *Process) cmdlineSliceWithContext(ctx context.Context, fallback bool) ([]string, error) { + pargs, nargs, err := procArgs(p.Pid) + if err != nil { + return nil, err + } + // The first bytes hold the nargs int, skip it. + args := bytes.Split((pargs)[unsafe.Sizeof(int(0)):], []byte{0}) + var argStr string + // The first element is the actual binary/command path. + // command := args[0] + var argSlice []string + // var envSlice []string + // All other, non-zero elements are arguments. The first "nargs" elements + // are the arguments. Everything else in the slice is then the environment + // of the process. + for _, arg := range args[1:] { + argStr = string(arg[:]) + if len(argStr) > 0 { + if nargs > 0 { + argSlice = append(argSlice, argStr) + nargs-- + continue + } + break + // envSlice = append(envSlice, argStr) + } + } + return argSlice, err +} + +// cmdNameWithContext returns the command name (including spaces) without any arguments +func (p *Process) cmdNameWithContext(ctx context.Context) (string, error) { + r, err := p.cmdlineSliceWithContext(ctx, false) + if err != nil { + return "", err + } + + if len(r) == 0 { + return "", nil + } + + return r[0], err +} + +func (p *Process) CmdlineWithContext(ctx context.Context) (string, error) { + r, err := p.CmdlineSliceWithContext(ctx) + if err != nil { + return "", err + } + return strings.Join(r, " "), err +} + +func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) { + lib, err := registerFuncs() + if err != nil { + return 0, err + } + defer lib.Close() + + var ti ProcTaskInfo + const tiSize = int32(unsafe.Sizeof(ti)) + procPidInfo(p.Pid, common.PROC_PIDTASKINFO, 0, uintptr(unsafe.Pointer(&ti)), tiSize) + + return int32(ti.Threadnum), nil +} + +func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error) { + lib, err := registerFuncs() + if err != nil { + return nil, err + } + defer lib.Close() + + var ti ProcTaskInfo + const tiSize = int32(unsafe.Sizeof(ti)) + procPidInfo(p.Pid, common.PROC_PIDTASKINFO, 0, uintptr(unsafe.Pointer(&ti)), tiSize) + + timescaleToNanoSeconds := getTimeScaleToNanoSeconds() + ret := &cpu.TimesStat{ + CPU: "cpu", + User: float64(ti.Total_user) * timescaleToNanoSeconds / 1e9, + System: float64(ti.Total_system) * timescaleToNanoSeconds / 1e9, + } + return ret, nil +} + +func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, error) { + lib, err := registerFuncs() + if err != nil { + return nil, err + } + defer lib.Close() + + var ti ProcTaskInfo + const tiSize = int32(unsafe.Sizeof(ti)) + procPidInfo(p.Pid, common.PROC_PIDTASKINFO, 0, uintptr(unsafe.Pointer(&ti)), tiSize) + + ret := &MemoryInfoStat{ + RSS: uint64(ti.Resident_size), + VMS: uint64(ti.Virtual_size), + Swap: uint64(ti.Pageins), + } + return ret, nil +} diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_darwin_amd64.go b/vendor/github.com/shirou/gopsutil/v4/process/process_darwin_amd64.go index a13522473a1c3..890a5d5331a49 100644 --- a/vendor/github.com/shirou/gopsutil/v4/process/process_darwin_amd64.go +++ b/vendor/github.com/shirou/gopsutil/v4/process/process_darwin_amd64.go @@ -212,6 +212,27 @@ type Posix_cred struct { type Label struct{} +type ProcTaskInfo struct { + Virtual_size uint64 + Resident_size uint64 + Total_user uint64 + Total_system uint64 + Threads_user uint64 + Threads_system uint64 + Policy int32 + Faults int32 + Pageins int32 + Cow_faults int32 + Messages_sent int32 + Messages_received int32 + Syscalls_mach int32 + Syscalls_unix int32 + Csw int32 + Threadnum int32 + Numrunning int32 + Priority int32 +} + type AuditinfoAddr struct { Auid uint32 Mask AuMask diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_darwin_arm64.go b/vendor/github.com/shirou/gopsutil/v4/process/process_darwin_arm64.go index f1f3df365d919..8075cf227d19a 100644 --- a/vendor/github.com/shirou/gopsutil/v4/process/process_darwin_arm64.go +++ b/vendor/github.com/shirou/gopsutil/v4/process/process_darwin_arm64.go @@ -190,6 +190,27 @@ type Posix_cred struct{} type Label struct{} +type ProcTaskInfo struct { + Virtual_size uint64 + Resident_size uint64 + Total_user uint64 + Total_system uint64 + Threads_user uint64 + Threads_system uint64 + Policy int32 + Faults int32 + Pageins int32 + Cow_faults int32 + Messages_sent int32 + Messages_received int32 + Syscalls_mach int32 + Syscalls_unix int32 + Csw int32 + Threadnum int32 + Numrunning int32 + Priority int32 +} + type AuditinfoAddr struct { Auid uint32 Mask AuMask diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_darwin_cgo.go b/vendor/github.com/shirou/gopsutil/v4/process/process_darwin_cgo.go deleted file mode 100644 index bbdfc963ebbee..0000000000000 --- a/vendor/github.com/shirou/gopsutil/v4/process/process_darwin_cgo.go +++ /dev/null @@ -1,222 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -//go:build darwin && cgo - -package process - -// #include -// #include -// #include -// #include -// #include -// #include -// #include -import "C" - -import ( - "bytes" - "context" - "fmt" - "strings" - "syscall" - "unsafe" - - "github.com/shirou/gopsutil/v4/cpu" -) - -var ( - argMax int - timescaleToNanoSeconds float64 -) - -func init() { - argMax = getArgMax() - timescaleToNanoSeconds = getTimeScaleToNanoSeconds() -} - -func getArgMax() int { - var ( - mib = [...]C.int{C.CTL_KERN, C.KERN_ARGMAX} - argmax C.int - size C.size_t = C.ulong(unsafe.Sizeof(argmax)) - ) - retval := C.sysctl(&mib[0], 2, unsafe.Pointer(&argmax), &size, C.NULL, 0) - if retval == 0 { - return int(argmax) - } - return 0 -} - -func getTimeScaleToNanoSeconds() float64 { - var timeBaseInfo C.struct_mach_timebase_info - - C.mach_timebase_info(&timeBaseInfo) - - return float64(timeBaseInfo.numer) / float64(timeBaseInfo.denom) -} - -func (p *Process) ExeWithContext(ctx context.Context) (string, error) { - var c C.char // need a var for unsafe.Sizeof need a var - const bufsize = C.PROC_PIDPATHINFO_MAXSIZE * unsafe.Sizeof(c) - buffer := (*C.char)(C.malloc(C.size_t(bufsize))) - defer C.free(unsafe.Pointer(buffer)) - - ret, err := C.proc_pidpath(C.int(p.Pid), unsafe.Pointer(buffer), C.uint32_t(bufsize)) - if err != nil { - return "", err - } - if ret <= 0 { - return "", fmt.Errorf("unknown error: proc_pidpath returned %d", ret) - } - - return C.GoString(buffer), nil -} - -// CwdWithContext retrieves the Current Working Directory for the given process. -// It uses the proc_pidinfo from libproc and will only work for processes the -// EUID can access. Otherwise "operation not permitted" will be returned as the -// error. -// Note: This might also work for other *BSD OSs. -func (p *Process) CwdWithContext(ctx context.Context) (string, error) { - const vpiSize = C.sizeof_struct_proc_vnodepathinfo - vpi := (*C.struct_proc_vnodepathinfo)(C.malloc(vpiSize)) - defer C.free(unsafe.Pointer(vpi)) - ret, err := C.proc_pidinfo(C.int(p.Pid), C.PROC_PIDVNODEPATHINFO, 0, unsafe.Pointer(vpi), vpiSize) - if err != nil { - // fmt.Printf("ret: %d %T\n", ret, err) - if err == syscall.EPERM { - return "", ErrorNotPermitted - } - return "", err - } - if ret <= 0 { - return "", fmt.Errorf("unknown error: proc_pidinfo returned %d", ret) - } - if ret != C.sizeof_struct_proc_vnodepathinfo { - return "", fmt.Errorf("too few bytes; expected %d, got %d", vpiSize, ret) - } - return C.GoString(&vpi.pvi_cdir.vip_path[0]), err -} - -func procArgs(pid int32) ([]byte, int, error) { - var ( - mib = [...]C.int{C.CTL_KERN, C.KERN_PROCARGS2, C.int(pid)} - size C.size_t = C.ulong(argMax) - nargs C.int - result []byte - ) - procargs := (*C.char)(C.malloc(C.ulong(argMax))) - defer C.free(unsafe.Pointer(procargs)) - retval, err := C.sysctl(&mib[0], 3, unsafe.Pointer(procargs), &size, C.NULL, 0) - if retval == 0 { - C.memcpy(unsafe.Pointer(&nargs), unsafe.Pointer(procargs), C.sizeof_int) - result = C.GoBytes(unsafe.Pointer(procargs), C.int(size)) - // fmt.Printf("size: %d %d\n%s\n", size, nargs, hex.Dump(result)) - return result, int(nargs), nil - } - return nil, 0, err -} - -func (p *Process) CmdlineSliceWithContext(ctx context.Context) ([]string, error) { - return p.cmdlineSliceWithContext(ctx, true) -} - -func (p *Process) cmdlineSliceWithContext(ctx context.Context, fallback bool) ([]string, error) { - pargs, nargs, err := procArgs(p.Pid) - if err != nil { - return nil, err - } - // The first bytes hold the nargs int, skip it. - args := bytes.Split((pargs)[C.sizeof_int:], []byte{0}) - var argStr string - // The first element is the actual binary/command path. - // command := args[0] - var argSlice []string - // var envSlice []string - // All other, non-zero elements are arguments. The first "nargs" elements - // are the arguments. Everything else in the slice is then the environment - // of the process. - for _, arg := range args[1:] { - argStr = string(arg[:]) - if len(argStr) > 0 { - if nargs > 0 { - argSlice = append(argSlice, argStr) - nargs-- - continue - } - break - // envSlice = append(envSlice, argStr) - } - } - return argSlice, err -} - -// cmdNameWithContext returns the command name (including spaces) without any arguments -func (p *Process) cmdNameWithContext(ctx context.Context) (string, error) { - r, err := p.cmdlineSliceWithContext(ctx, false) - if err != nil { - return "", err - } - - if len(r) == 0 { - return "", nil - } - - return r[0], err -} - -func (p *Process) CmdlineWithContext(ctx context.Context) (string, error) { - r, err := p.CmdlineSliceWithContext(ctx) - if err != nil { - return "", err - } - return strings.Join(r, " "), err -} - -func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) { - const tiSize = C.sizeof_struct_proc_taskinfo - ti := (*C.struct_proc_taskinfo)(C.malloc(tiSize)) - defer C.free(unsafe.Pointer(ti)) - - _, err := C.proc_pidinfo(C.int(p.Pid), C.PROC_PIDTASKINFO, 0, unsafe.Pointer(ti), tiSize) - if err != nil { - return 0, err - } - - return int32(ti.pti_threadnum), nil -} - -func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error) { - const tiSize = C.sizeof_struct_proc_taskinfo - ti := (*C.struct_proc_taskinfo)(C.malloc(tiSize)) - defer C.free(unsafe.Pointer(ti)) - - _, err := C.proc_pidinfo(C.int(p.Pid), C.PROC_PIDTASKINFO, 0, unsafe.Pointer(ti), tiSize) - if err != nil { - return nil, err - } - - ret := &cpu.TimesStat{ - CPU: "cpu", - User: float64(ti.pti_total_user) * timescaleToNanoSeconds / 1e9, - System: float64(ti.pti_total_system) * timescaleToNanoSeconds / 1e9, - } - return ret, nil -} - -func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, error) { - const tiSize = C.sizeof_struct_proc_taskinfo - ti := (*C.struct_proc_taskinfo)(C.malloc(tiSize)) - defer C.free(unsafe.Pointer(ti)) - - _, err := C.proc_pidinfo(C.int(p.Pid), C.PROC_PIDTASKINFO, 0, unsafe.Pointer(ti), tiSize) - if err != nil { - return nil, err - } - - ret := &MemoryInfoStat{ - RSS: uint64(ti.pti_resident_size), - VMS: uint64(ti.pti_virtual_size), - Swap: uint64(ti.pti_pageins), - } - return ret, nil -} diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_darwin_nocgo.go b/vendor/github.com/shirou/gopsutil/v4/process/process_darwin_nocgo.go deleted file mode 100644 index 090e21e0c76cb..0000000000000 --- a/vendor/github.com/shirou/gopsutil/v4/process/process_darwin_nocgo.go +++ /dev/null @@ -1,127 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -//go:build darwin && !cgo - -package process - -import ( - "context" - "fmt" - "strconv" - "strings" - - "github.com/shirou/gopsutil/v4/cpu" - "github.com/shirou/gopsutil/v4/internal/common" -) - -func (p *Process) CwdWithContext(ctx context.Context) (string, error) { - return "", common.ErrNotImplementedError -} - -func (p *Process) ExeWithContext(ctx context.Context) (string, error) { - out, err := invoke.CommandWithContext(ctx, "lsof", "-p", strconv.Itoa(int(p.Pid)), "-Fpfn") - if err != nil { - return "", fmt.Errorf("bad call to lsof: %s", err) - } - txtFound := 0 - lines := strings.Split(string(out), "\n") - for i := 1; i < len(lines); i++ { - if lines[i] == "ftxt" { - txtFound++ - if txtFound == 2 { - return lines[i-1][1:], nil - } - } - } - return "", fmt.Errorf("missing txt data returned by lsof") -} - -func (p *Process) CmdlineWithContext(ctx context.Context) (string, error) { - r, err := callPsWithContext(ctx, "command", p.Pid, false, false) - if err != nil { - return "", err - } - return strings.Join(r[0], " "), err -} - -func (p *Process) cmdNameWithContext(ctx context.Context) (string, error) { - r, err := callPsWithContext(ctx, "command", p.Pid, false, true) - if err != nil { - return "", err - } - if len(r) > 0 && len(r[0]) > 0 { - return r[0][0], err - } - - return "", err -} - -// CmdlineSliceWithContext returns the command line arguments of the process as a slice with each -// element being an argument. Because of current deficiencies in the way that the command -// line arguments are found, single arguments that have spaces in the will actually be -// reported as two separate items. In order to do something better CGO would be needed -// to use the native darwin functions. -func (p *Process) CmdlineSliceWithContext(ctx context.Context) ([]string, error) { - r, err := callPsWithContext(ctx, "command", p.Pid, false, false) - if err != nil { - return nil, err - } - return r[0], err -} - -func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) { - r, err := callPsWithContext(ctx, "utime,stime", p.Pid, true, false) - if err != nil { - return 0, err - } - return int32(len(r)), nil -} - -func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error) { - r, err := callPsWithContext(ctx, "utime,stime", p.Pid, false, false) - if err != nil { - return nil, err - } - - utime, err := convertCPUTimes(r[0][0]) - if err != nil { - return nil, err - } - stime, err := convertCPUTimes(r[0][1]) - if err != nil { - return nil, err - } - - ret := &cpu.TimesStat{ - CPU: "cpu", - User: utime, - System: stime, - } - return ret, nil -} - -func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, error) { - r, err := callPsWithContext(ctx, "rss,vsize,pagein", p.Pid, false, false) - if err != nil { - return nil, err - } - rss, err := strconv.Atoi(r[0][0]) - if err != nil { - return nil, err - } - vms, err := strconv.Atoi(r[0][1]) - if err != nil { - return nil, err - } - pagein, err := strconv.Atoi(r[0][2]) - if err != nil { - return nil, err - } - - ret := &MemoryInfoStat{ - RSS: uint64(rss) * 1024, - VMS: uint64(vms) * 1024, - Swap: uint64(pagein), - } - - return ret, nil -} diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_fallback.go b/vendor/github.com/shirou/gopsutil/v4/process/process_fallback.go index 23793e92c506b..e5410ea049c58 100644 --- a/vendor/github.com/shirou/gopsutil/v4/process/process_fallback.go +++ b/vendor/github.com/shirou/gopsutil/v4/process/process_fallback.go @@ -166,7 +166,7 @@ func (p *Process) ConnectionsWithContext(ctx context.Context) ([]net.ConnectionS return nil, common.ErrNotImplementedError } -func (p *Process) ConnectionsMaxWithContext(ctx context.Context, max int) ([]net.ConnectionStat, error) { +func (p *Process) ConnectionsMaxWithContext(ctx context.Context, maxConn int) ([]net.ConnectionStat, error) { return nil, common.ErrNotImplementedError } diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_freebsd.go b/vendor/github.com/shirou/gopsutil/v4/process/process_freebsd.go index 3d21183d6561e..76373736bfc5b 100644 --- a/vendor/github.com/shirou/gopsutil/v4/process/process_freebsd.go +++ b/vendor/github.com/shirou/gopsutil/v4/process/process_freebsd.go @@ -6,14 +6,17 @@ package process import ( "bytes" "context" + "errors" "path/filepath" + "sort" "strconv" "strings" + "golang.org/x/sys/unix" + cpu "github.com/shirou/gopsutil/v4/cpu" "github.com/shirou/gopsutil/v4/internal/common" net "github.com/shirou/gopsutil/v4/net" - "golang.org/x/sys/unix" ) func pidsWithContext(ctx context.Context) ([]int32, error) { @@ -83,10 +86,7 @@ func (p *Process) CmdlineWithContext(ctx context.Context) (string, error) { return "", err } ret := strings.FieldsFunc(string(buf), func(r rune) bool { - if r == '\u0000' { - return true - } - return false + return r == '\u0000' }) return strings.Join(ret, " "), nil @@ -270,18 +270,21 @@ func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, e } func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) { - pids, err := common.CallPgrepWithContext(ctx, invoke, p.Pid) + procs, err := ProcessesWithContext(ctx) if err != nil { - return nil, err + return nil, nil } - ret := make([]*Process, 0, len(pids)) - for _, pid := range pids { - np, err := NewProcessWithContext(ctx, pid) + ret := make([]*Process, 0, len(procs)) + for _, proc := range procs { + ppid, err := proc.PpidWithContext(ctx) if err != nil { - return nil, err + continue + } + if ppid == p.Pid { + ret = append(ret, proc) } - ret = append(ret, np) } + sort.Slice(ret, func(i, j int) bool { return ret[i].Pid < ret[j].Pid }) return ret, nil } @@ -289,8 +292,8 @@ func (p *Process) ConnectionsWithContext(ctx context.Context) ([]net.ConnectionS return net.ConnectionsPidWithContext(ctx, "all", p.Pid) } -func (p *Process) ConnectionsMaxWithContext(ctx context.Context, max int) ([]net.ConnectionStat, error) { - return net.ConnectionsPidMaxWithContext(ctx, "all", p.Pid, max) +func (p *Process) ConnectionsMaxWithContext(ctx context.Context, maxConn int) ([]net.ConnectionStat, error) { + return net.ConnectionsPidMaxWithContext(ctx, "all", p.Pid, maxConn) } func ProcessesWithContext(ctx context.Context) ([]*Process, error) { @@ -331,7 +334,7 @@ func (p *Process) getKProc() (*KinfoProc, error) { return nil, err } if length != sizeOfKinfoProc { - return nil, err + return nil, errors.New("unexpected size of KinfoProc") } k, err := parseKinfoProc(buf) diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_freebsd_arm64.go b/vendor/github.com/shirou/gopsutil/v4/process/process_freebsd_arm64.go index dbb3baa3e756c..3dc301c027ff2 100644 --- a/vendor/github.com/shirou/gopsutil/v4/process/process_freebsd_arm64.go +++ b/vendor/github.com/shirou/gopsutil/v4/process/process_freebsd_arm64.go @@ -2,7 +2,7 @@ //go:build freebsd && arm64 // Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs process/types_freebsd.go +// cgo -godefs types_freebsd.go package process @@ -82,14 +82,14 @@ type Rlimit struct { type KinfoProc struct { Structsize int32 Layout int32 - Args *int64 /* pargs */ - Paddr *int64 /* proc */ - Addr *int64 /* user */ - Tracep *int64 /* vnode */ - Textvp *int64 /* vnode */ - Fd *int64 /* filedesc */ - Vmspace *int64 /* vmspace */ - Wchan *byte + Args int64 /* pargs */ + Paddr int64 /* proc */ + Addr int64 /* user */ + Tracep int64 /* vnode */ + Textvp int64 /* vnode */ + Fd int64 /* filedesc */ + Vmspace int64 /* vmspace */ + Wchan int64 Pid int32 Ppid int32 Pgid int32 @@ -140,7 +140,7 @@ type KinfoProc struct { Wmesg [9]uint8 Login [18]uint8 Lockname [9]uint8 - Comm [20]int8 + Comm [20]int8 // changed from uint8 by hand Emul [17]uint8 Loginclass [18]uint8 Moretdname [4]uint8 @@ -159,11 +159,12 @@ type KinfoProc struct { Pri Priority Rusage Rusage Rusage_ch Rusage - Pcb *int64 /* pcb */ - Kstack *byte - Udata *byte - Tdaddr *int64 /* thread */ - Spareptrs [6]*byte + Pcb int64 /* pcb */ + Kstack int64 + Udata int64 + Tdaddr int64 /* thread */ + Pd int64 /* pwddesc, not accurate */ + Spareptrs [5]int64 Sparelongs [12]int64 Sflag int64 Tdflags int64 @@ -195,7 +196,7 @@ type KinfoVmentry struct { Vn_rdev_freebsd11 uint32 Vn_mode uint16 Status uint16 - Vn_fsid uint64 + Type_spec [8]byte Vn_rdev uint64 X_kve_ispare [8]int32 Path [1024]uint8 diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_linux.go b/vendor/github.com/shirou/gopsutil/v4/process/process_linux.go index 2151ed5c84629..68a8c88c4a904 100644 --- a/vendor/github.com/shirou/gopsutil/v4/process/process_linux.go +++ b/vendor/github.com/shirou/gopsutil/v4/process/process_linux.go @@ -12,6 +12,7 @@ import ( "math" "os" "path/filepath" + "sort" "strconv" "strings" @@ -338,21 +339,34 @@ func (p *Process) PageFaultsWithContext(ctx context.Context) (*PageFaultsStat, e } func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) { - pids, err := common.CallPgrepWithContext(ctx, invoke, p.Pid) + statFiles, err := filepath.Glob(common.HostProcWithContext(ctx, "[0-9]*/stat")) if err != nil { return nil, err } - if len(pids) == 0 { - return nil, ErrorNoChildren - } - ret := make([]*Process, 0, len(pids)) - for _, pid := range pids { - np, err := NewProcessWithContext(ctx, pid) + ret := make([]*Process, 0, len(statFiles)) + for _, statFile := range statFiles { + statContents, err := os.ReadFile(statFile) if err != nil { - return nil, err + continue + } + fields := splitProcStat(statContents) + pid, err := strconv.ParseInt(fields[1], 10, 32) + if err != nil { + continue + } + ppid, err := strconv.ParseInt(fields[4], 10, 32) + if err != nil { + continue + } + if int32(ppid) == p.Pid { + np, err := NewProcessWithContext(ctx, int32(pid)) + if err != nil { + continue + } + ret = append(ret, np) } - ret = append(ret, np) } + sort.Slice(ret, func(i, j int) bool { return ret[i].Pid < ret[j].Pid }) return ret, nil } @@ -373,8 +387,8 @@ func (p *Process) ConnectionsWithContext(ctx context.Context) ([]net.ConnectionS return net.ConnectionsPidWithContext(ctx, "all", p.Pid) } -func (p *Process) ConnectionsMaxWithContext(ctx context.Context, max int) ([]net.ConnectionStat, error) { - return net.ConnectionsPidMaxWithContext(ctx, "all", p.Pid, max) +func (p *Process) ConnectionsMaxWithContext(ctx context.Context, maxConn int) ([]net.ConnectionStat, error) { + return net.ConnectionsPidMaxWithContext(ctx, "all", p.Pid, maxConn) } func (p *Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]MemoryMapsStat, error) { @@ -399,7 +413,9 @@ func (p *Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]M // function of parsing a block getBlock := func(firstLine []string, block []string) (MemoryMapsStat, error) { m := MemoryMapsStat{} - m.Path = firstLine[len(firstLine)-1] + if len(firstLine) >= 6 { + m.Path = strings.Join(firstLine[5:], " ") + } for _, line := range block { if strings.Contains(line, "VmFlags") { @@ -727,8 +743,12 @@ func (p *Process) fillFromIOWithContext(ctx context.Context) (*IOCountersStat, e case "syscw": ret.WriteCount = t case "read_bytes": - ret.ReadBytes = t + ret.DiskReadBytes = t case "write_bytes": + ret.DiskWriteBytes = t + case "rchar": + ret.ReadBytes = t + case "wchar": ret.WriteBytes = t } } @@ -1076,8 +1096,7 @@ func (p *Process) fillFromTIDStatWithContext(ctx context.Context, tid int32) (ui if err != nil { return 0, 0, nil, 0, 0, 0, nil, err } - ctime := (t / uint64(clockTicks)) + uint64(bootTime) - createTime := int64(ctime * 1000) + createTime := int64((t * 1000 / uint64(clockTicks)) + uint64(bootTime*1000)) rtpriority, err := strconv.ParseInt(fields[18], 10, 32) if err != nil { diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd.go b/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd.go index 7cd8ca7364299..5e8a9e0b45ee4 100644 --- a/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd.go +++ b/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd.go @@ -7,9 +7,11 @@ import ( "bytes" "context" "encoding/binary" + "errors" "fmt" "io" "path/filepath" + "sort" "strconv" "strings" "unsafe" @@ -68,7 +70,12 @@ func (p *Process) NameWithContext(ctx context.Context) (string, error) { } func (p *Process) CwdWithContext(ctx context.Context) (string, error) { - return "", common.ErrNotImplementedError + mib := []int32{CTLKern, KernProcCwd, p.Pid} + buf, _, err := common.CallSyscall(mib) + if err != nil { + return "", err + } + return common.ByteToString(buf), nil } func (p *Process) ExeWithContext(ctx context.Context) (string, error) { @@ -280,18 +287,21 @@ func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, e } func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) { - pids, err := common.CallPgrepWithContext(ctx, invoke, p.Pid) + procs, err := ProcessesWithContext(ctx) if err != nil { - return nil, err + return nil, nil } - ret := make([]*Process, 0, len(pids)) - for _, pid := range pids { - np, err := NewProcessWithContext(ctx, pid) + ret := make([]*Process, 0, len(procs)) + for _, proc := range procs { + ppid, err := proc.PpidWithContext(ctx) if err != nil { - return nil, err + continue + } + if ppid == p.Pid { + ret = append(ret, proc) } - ret = append(ret, np) } + sort.Slice(ret, func(i, j int) bool { return ret[i].Pid < ret[j].Pid }) return ret, nil } @@ -299,7 +309,7 @@ func (p *Process) ConnectionsWithContext(ctx context.Context) ([]net.ConnectionS return nil, common.ErrNotImplementedError } -func (p *Process) ConnectionsMaxWithContext(ctx context.Context, max int) ([]net.ConnectionStat, error) { +func (p *Process) ConnectionsMaxWithContext(ctx context.Context, maxConn int) ([]net.ConnectionStat, error) { return nil, common.ErrNotImplementedError } @@ -338,7 +348,7 @@ func (p *Process) getKProc() (*KinfoProc, error) { return nil, err } if length != sizeOfKinfoProc { - return nil, err + return nil, errors.New("unexpected size of KinfoProc") } k, err := parseKinfoProc(buf) diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd_386.go b/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd_386.go index e3c5c2b5a1dfb..5b84706a7cfe9 100644 --- a/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd_386.go +++ b/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd_386.go @@ -14,6 +14,7 @@ const ( KernProcProc = 8 KernProcPathname = 12 KernProcArgs = 55 + KernProcCwd = 78 KernProcArgv = 1 KernProcEnv = 3 ) diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd_amd64.go b/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd_amd64.go index beb7c9b0b4daf..3229bb32c2877 100644 --- a/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd_amd64.go +++ b/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd_amd64.go @@ -12,6 +12,7 @@ const ( KernProcProc = 8 KernProcPathname = 12 KernProcArgs = 55 + KernProcCwd = 78 KernProcArgv = 1 KernProcEnv = 3 ) diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd_arm.go b/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd_arm.go index ff082f43f87df..6f74ce7563733 100644 --- a/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd_arm.go +++ b/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd_arm.go @@ -14,6 +14,7 @@ const ( KernProcProc = 8 KernProcPathname = 12 KernProcArgs = 55 + KernProcCwd = 78 KernProcArgv = 1 KernProcEnv = 3 ) diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd_arm64.go b/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd_arm64.go index e180ba359959d..910454562581f 100644 --- a/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd_arm64.go +++ b/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd_arm64.go @@ -14,6 +14,7 @@ const ( KernProcProc = 8 KernProcPathname = 12 KernProcArgs = 55 + KernProcCwd = 78 KernProcArgv = 1 KernProcEnv = 3 ) diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd_riscv64.go b/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd_riscv64.go index c53924b6f8241..e3e0d36a09e8e 100644 --- a/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd_riscv64.go +++ b/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd_riscv64.go @@ -14,6 +14,7 @@ const ( KernProcProc = 8 KernProcPathname = 12 KernProcArgs = 55 + KernProcCwd = 78 KernProcArgv = 1 KernProcEnv = 3 ) diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_plan9.go b/vendor/github.com/shirou/gopsutil/v4/process/process_plan9.go index 726758cae9582..c82e54a75bccc 100644 --- a/vendor/github.com/shirou/gopsutil/v4/process/process_plan9.go +++ b/vendor/github.com/shirou/gopsutil/v4/process/process_plan9.go @@ -166,7 +166,7 @@ func (p *Process) ConnectionsWithContext(ctx context.Context) ([]net.ConnectionS return nil, common.ErrNotImplementedError } -func (p *Process) ConnectionsMaxWithContext(ctx context.Context, max int) ([]net.ConnectionStat, error) { +func (p *Process) ConnectionsMaxWithContext(ctx context.Context, maxConn int) ([]net.ConnectionStat, error) { return nil, common.ErrNotImplementedError } diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_solaris.go b/vendor/github.com/shirou/gopsutil/v4/process/process_solaris.go index 04f86f16b5e1a..5c8d4d3b1efa9 100644 --- a/vendor/github.com/shirou/gopsutil/v4/process/process_solaris.go +++ b/vendor/github.com/shirou/gopsutil/v4/process/process_solaris.go @@ -181,7 +181,7 @@ func (p *Process) ConnectionsWithContext(ctx context.Context) ([]net.ConnectionS return nil, common.ErrNotImplementedError } -func (p *Process) ConnectionsMaxWithContext(ctx context.Context, max int) ([]net.ConnectionStat, error) { +func (p *Process) ConnectionsMaxWithContext(ctx context.Context, maxConn int) ([]net.ConnectionStat, error) { return nil, common.ErrNotImplementedError } diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_windows.go b/vendor/github.com/shirou/gopsutil/v4/process/process_windows.go index f3111649a6c7c..b00c671e9f325 100644 --- a/vendor/github.com/shirou/gopsutil/v4/process/process_windows.go +++ b/vendor/github.com/shirou/gopsutil/v4/process/process_windows.go @@ -43,6 +43,7 @@ var ( procGetPriorityClass = common.Modkernel32.NewProc("GetPriorityClass") procGetProcessIoCounters = common.Modkernel32.NewProc("GetProcessIoCounters") procGetNativeSystemInfo = common.Modkernel32.NewProc("GetNativeSystemInfo") + procGetProcessHandleCount = common.Modkernel32.NewProc("GetProcessHandleCount") processorArchitecture uint ) @@ -548,8 +549,21 @@ func (p *Process) NumCtxSwitchesWithContext(ctx context.Context) (*NumCtxSwitche return nil, common.ErrNotImplementedError } +// NumFDsWithContext returns the number of handles for a process on Windows, +// not the number of file descriptors (FDs). func (p *Process) NumFDsWithContext(ctx context.Context) (int32, error) { - return 0, common.ErrNotImplementedError + handle, err := windows.OpenProcess(processQueryInformation, false, uint32(p.Pid)) + if err != nil { + return 0, err + } + defer windows.CloseHandle(handle) + + var handleCount uint32 + ret, _, err := procGetProcessHandleCount.Call(uintptr(handle), uintptr(unsafe.Pointer(&handleCount))) + if ret == 0 { + return 0, err + } + return int32(handleCount), nil } func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) { @@ -744,7 +758,7 @@ func (p *Process) ConnectionsWithContext(ctx context.Context) ([]net.ConnectionS return net.ConnectionsPidWithContext(ctx, "all", p.Pid) } -func (p *Process) ConnectionsMaxWithContext(ctx context.Context, max int) ([]net.ConnectionStat, error) { +func (p *Process) ConnectionsMaxWithContext(ctx context.Context, maxConn int) ([]net.ConnectionStat, error) { return nil, common.ErrNotImplementedError } diff --git a/vendor/github.com/shoenig/go-m1cpu/.golangci.yaml b/vendor/github.com/shoenig/go-m1cpu/.golangci.yaml deleted file mode 100644 index dc6fefb979ec0..0000000000000 --- a/vendor/github.com/shoenig/go-m1cpu/.golangci.yaml +++ /dev/null @@ -1,12 +0,0 @@ -run: - timeout: 5m -linters: - enable: - - gofmt - - errcheck - - errname - - errorlint - - bodyclose - - durationcheck - - whitespace - diff --git a/vendor/github.com/shoenig/go-m1cpu/LICENSE b/vendor/github.com/shoenig/go-m1cpu/LICENSE deleted file mode 100644 index e87a115e462e1..0000000000000 --- a/vendor/github.com/shoenig/go-m1cpu/LICENSE +++ /dev/null @@ -1,363 +0,0 @@ -Mozilla Public License, version 2.0 - -1. Definitions - -1.1. "Contributor" - - means each individual or legal entity that creates, contributes to the - creation of, or owns Covered Software. - -1.2. "Contributor Version" - - means the combination of the Contributions of others (if any) used by a - Contributor and that particular Contributor's Contribution. - -1.3. "Contribution" - - means Covered Software of a particular Contributor. - -1.4. "Covered Software" - - means Source Code Form to which the initial Contributor has attached the - notice in Exhibit A, the Executable Form of such Source Code Form, and - Modifications of such Source Code Form, in each case including portions - thereof. - -1.5. "Incompatible With Secondary Licenses" - means - - a. that the initial Contributor has attached the notice described in - Exhibit B to the Covered Software; or - - b. that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the terms of - a Secondary License. - -1.6. "Executable Form" - - means any form of the work other than Source Code Form. - -1.7. "Larger Work" - - means a work that combines Covered Software with other material, in a - separate file or files, that is not Covered Software. - -1.8. "License" - - means this document. - -1.9. "Licensable" - - means having the right to grant, to the maximum extent possible, whether - at the time of the initial grant or subsequently, any and all of the - rights conveyed by this License. - -1.10. "Modifications" - - means any of the following: - - a. any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered Software; or - - b. any new file in Source Code Form that contains any Covered Software. - -1.11. "Patent Claims" of a Contributor - - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the License, - by the making, using, selling, offering for sale, having made, import, - or transfer of either its Contributions or its Contributor Version. - -1.12. "Secondary License" - - means either the GNU General Public License, Version 2.0, the GNU Lesser - General Public License, Version 2.1, the GNU Affero General Public - License, Version 3.0, or any later versions of those licenses. - -1.13. "Source Code Form" - - means the form of the work preferred for making modifications. - -1.14. "You" (or "Your") - - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that controls, is - controlled by, or is under common control with You. For purposes of this - definition, "control" means (a) the power, direct or indirect, to cause - the direction or management of such entity, whether by contract or - otherwise, or (b) ownership of more than fifty percent (50%) of the - outstanding shares or beneficial ownership of such entity. - - -2. License Grants and Conditions - -2.1. Grants - - Each Contributor hereby grants You a world-wide, royalty-free, - non-exclusive license: - - a. under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and - - b. under Patent Claims of such Contributor to make, use, sell, offer for - sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. - -2.2. Effective Date - - The licenses granted in Section 2.1 with respect to any Contribution - become effective for each Contribution on the date the Contributor first - distributes such Contribution. - -2.3. Limitations on Grant Scope - - The licenses granted in this Section 2 are the only rights granted under - this License. No additional rights or licenses will be implied from the - distribution or licensing of Covered Software under this License. - Notwithstanding Section 2.1(b) above, no patent license is granted by a - Contributor: - - a. for any code that a Contributor has removed from Covered Software; or - - b. for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - - c. under Patent Claims infringed by Covered Software in the absence of - its Contributions. - - This License does not grant any rights in the trademarks, service marks, - or logos of any Contributor (except as may be necessary to comply with - the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - - No Contributor makes additional grants as a result of Your choice to - distribute the Covered Software under a subsequent version of this - License (see Section 10.2) or under the terms of a Secondary License (if - permitted under the terms of Section 3.3). - -2.5. Representation - - Each Contributor represents that the Contributor believes its - Contributions are its original creation(s) or it has sufficient rights to - grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - - This License is not intended to limit any rights You have under - applicable copyright doctrines of fair use, fair dealing, or other - equivalents. - -2.7. Conditions - - Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in - Section 2.1. - - -3. Responsibilities - -3.1. Distribution of Source Form - - All distribution of Covered Software in Source Code Form, including any - Modifications that You create or to which You contribute, must be under - the terms of this License. You must inform recipients that the Source - Code Form of the Covered Software is governed by the terms of this - License, and how they can obtain a copy of this License. You may not - attempt to alter or restrict the recipients' rights in the Source Code - Form. - -3.2. Distribution of Executable Form - - If You distribute Covered Software in Executable Form then: - - a. such Covered Software must also be made available in Source Code Form, - as described in Section 3.1, and You must inform recipients of the - Executable Form how they can obtain a copy of such Source Code Form by - reasonable means in a timely manner, at a charge no more than the cost - of distribution to the recipient; and - - b. You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter the - recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - - You may create and distribute a Larger Work under terms of Your choice, - provided that You also comply with the requirements of this License for - the Covered Software. If the Larger Work is a combination of Covered - Software with a work governed by one or more Secondary Licenses, and the - Covered Software is not Incompatible With Secondary Licenses, this - License permits You to additionally distribute such Covered Software - under the terms of such Secondary License(s), so that the recipient of - the Larger Work may, at their option, further distribute the Covered - Software under the terms of either this License or such Secondary - License(s). - -3.4. Notices - - You may not remove or alter the substance of any license notices - (including copyright notices, patent notices, disclaimers of warranty, or - limitations of liability) contained within the Source Code Form of the - Covered Software, except that You may alter any license notices to the - extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - - You may choose to offer, and to charge a fee for, warranty, support, - indemnity or liability obligations to one or more recipients of Covered - Software. However, You may do so only on Your own behalf, and not on - behalf of any Contributor. You must make it absolutely clear that any - such warranty, support, indemnity, or liability obligation is offered by - You alone, and You hereby agree to indemnify every Contributor for any - liability incurred by such Contributor as a result of warranty, support, - indemnity or liability terms You offer. You may include additional - disclaimers of warranty and limitations of liability specific to any - jurisdiction. - -4. Inability to Comply Due to Statute or Regulation - - If it is impossible for You to comply with any of the terms of this License - with respect to some or all of the Covered Software due to statute, - judicial order, or regulation then You must: (a) comply with the terms of - this License to the maximum extent possible; and (b) describe the - limitations and the code they affect. Such description must be placed in a - text file included with all distributions of the Covered Software under - this License. Except to the extent prohibited by statute or regulation, - such description must be sufficiently detailed for a recipient of ordinary - skill to be able to understand it. - -5. Termination - -5.1. The rights granted under this License will terminate automatically if You - fail to comply with any of its terms. However, if You become compliant, - then the rights granted under this License from a particular Contributor - are reinstated (a) provisionally, unless and until such Contributor - explicitly and finally terminates Your grants, and (b) on an ongoing - basis, if such Contributor fails to notify You of the non-compliance by - some reasonable means prior to 60 days after You have come back into - compliance. Moreover, Your grants from a particular Contributor are - reinstated on an ongoing basis if such Contributor notifies You of the - non-compliance by some reasonable means, this is the first time You have - received notice of non-compliance with this License from such - Contributor, and You become compliant prior to 30 days after Your receipt - of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent - infringement claim (excluding declaratory judgment actions, - counter-claims, and cross-claims) alleging that a Contributor Version - directly or indirectly infringes any patent, then the rights granted to - You by any and all Contributors for the Covered Software under Section - 2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user - license agreements (excluding distributors and resellers) which have been - validly granted by You or Your distributors under this License prior to - termination shall survive termination. - -6. Disclaimer of Warranty - - Covered Software is provided under this License on an "as is" basis, - without warranty of any kind, either expressed, implied, or statutory, - including, without limitation, warranties that the Covered Software is free - of defects, merchantable, fit for a particular purpose or non-infringing. - The entire risk as to the quality and performance of the Covered Software - is with You. Should any Covered Software prove defective in any respect, - You (not any Contributor) assume the cost of any necessary servicing, - repair, or correction. This disclaimer of warranty constitutes an essential - part of this License. No use of any Covered Software is authorized under - this License except under this disclaimer. - -7. Limitation of Liability - - Under no circumstances and under no legal theory, whether tort (including - negligence), contract, or otherwise, shall any Contributor, or anyone who - distributes Covered Software as permitted above, be liable to You for any - direct, indirect, special, incidental, or consequential damages of any - character including, without limitation, damages for lost profits, loss of - goodwill, work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses, even if such party shall have been - informed of the possibility of such damages. This limitation of liability - shall not apply to liability for death or personal injury resulting from - such party's negligence to the extent applicable law prohibits such - limitation. Some jurisdictions do not allow the exclusion or limitation of - incidental or consequential damages, so this exclusion and limitation may - not apply to You. - -8. Litigation - - Any litigation relating to this License may be brought only in the courts - of a jurisdiction where the defendant maintains its principal place of - business and such litigation shall be governed by laws of that - jurisdiction, without reference to its conflict-of-law provisions. Nothing - in this Section shall prevent a party's ability to bring cross-claims or - counter-claims. - -9. Miscellaneous - - This License represents the complete agreement concerning the subject - matter hereof. If any provision of this License is held to be - unenforceable, such provision shall be reformed only to the extent - necessary to make it enforceable. Any law or regulation which provides that - the language of a contract shall be construed against the drafter shall not - be used to construe this License against a Contributor. - - -10. Versions of the License - -10.1. New Versions - - Mozilla Foundation is the license steward. Except as provided in Section - 10.3, no one other than the license steward has the right to modify or - publish new versions of this License. Each version will be given a - distinguishing version number. - -10.2. Effect of New Versions - - You may distribute the Covered Software under the terms of the version - of the License under which You originally received the Covered Software, - or under the terms of any subsequent version published by the license - steward. - -10.3. Modified Versions - - If you create software not governed by this License, and you want to - create a new license for such software, you may create and use a - modified version of this License if you rename the license and remove - any references to the name of the license steward (except to note that - such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary - Licenses If You choose to distribute Source Code Form that is - Incompatible With Secondary Licenses under the terms of this version of - the License, the notice described in Exhibit B of this License must be - attached. - -Exhibit A - Source Code Form License Notice - - This Source Code Form is subject to the - terms of the Mozilla Public License, v. - 2.0. If a copy of the MPL was not - distributed with this file, You can - obtain one at - http://mozilla.org/MPL/2.0/. - -If it is not possible or desirable to put the notice in a particular file, -then You may include the notice in a location (such as a LICENSE file in a -relevant directory) where a recipient would be likely to look for such a -notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice - - This Source Code Form is "Incompatible - With Secondary Licenses", as defined by - the Mozilla Public License, v. 2.0. - diff --git a/vendor/github.com/shoenig/go-m1cpu/Makefile b/vendor/github.com/shoenig/go-m1cpu/Makefile deleted file mode 100644 index 28d786397d4b4..0000000000000 --- a/vendor/github.com/shoenig/go-m1cpu/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -SHELL = bash - -default: test - -.PHONY: test -test: - @echo "--> Running Tests ..." - @go test -v -race ./... - -vet: - @echo "--> Vet Go sources ..." - @go vet ./... diff --git a/vendor/github.com/shoenig/go-m1cpu/README.md b/vendor/github.com/shoenig/go-m1cpu/README.md deleted file mode 100644 index 399657acf861c..0000000000000 --- a/vendor/github.com/shoenig/go-m1cpu/README.md +++ /dev/null @@ -1,66 +0,0 @@ -# m1cpu - -[![Go Reference](https://pkg.go.dev/badge/github.com/shoenig/go-m1cpu.svg)](https://pkg.go.dev/github.com/shoenig/go-m1cpu) -[![MPL License](https://img.shields.io/github/license/shoenig/go-m1cpu?color=g&style=flat-square)](https://github.com/shoenig/go-m1cpu/blob/main/LICENSE) -[![Run CI Tests](https://github.com/shoenig/go-m1cpu/actions/workflows/ci.yaml/badge.svg)](https://github.com/shoenig/go-m1cpu/actions/workflows/ci.yaml) - -The `go-m1cpu` module is a library for inspecting Apple Silicon CPUs in Go. - -Use the `m1cpu` Go package for looking up the CPU frequency for Apple M1 and M2 CPUs. - -# Install - -```shell -go get github.com/shoenig/go-m1cpu@latest -``` - -# CGO - -This package requires the use of [CGO](https://go.dev/blog/cgo). - -Extracting the CPU properties is done via Apple's [IOKit](https://developer.apple.com/documentation/iokit?language=objc) -framework, which is accessible only through system C libraries. - -# Example - -Simple Go program to print Apple Silicon M1/M2 CPU speeds. - -```go -package main - -import ( - "fmt" - - "github.com/shoenig/go-m1cpu" -) - -func main() { - fmt.Println("Apple Silicon", m1cpu.IsAppleSilicon()) - - fmt.Println("pCore GHz", m1cpu.PCoreGHz()) - fmt.Println("eCore GHz", m1cpu.ECoreGHz()) - - fmt.Println("pCore Hz", m1cpu.PCoreHz()) - fmt.Println("eCore Hz", m1cpu.ECoreHz()) -} -``` - -Using `go test` to print out available information. - -``` -➜ go test -v -run Show -=== RUN Test_Show - cpu_test.go:42: pCore Hz 3504000000 - cpu_test.go:43: eCore Hz 2424000000 - cpu_test.go:44: pCore GHz 3.504 - cpu_test.go:45: eCore GHz 2.424 - cpu_test.go:46: pCore count 8 - cpu_test.go:47: eCoreCount 4 - cpu_test.go:50: pCore Caches 196608 131072 16777216 - cpu_test.go:53: eCore Caches 131072 65536 4194304 ---- PASS: Test_Show (0.00s) -``` - -# License - -Open source under the [MPL](LICENSE) diff --git a/vendor/github.com/shoenig/go-m1cpu/cpu.go b/vendor/github.com/shoenig/go-m1cpu/cpu.go deleted file mode 100644 index 502a8cce92e67..0000000000000 --- a/vendor/github.com/shoenig/go-m1cpu/cpu.go +++ /dev/null @@ -1,213 +0,0 @@ -//go:build darwin && arm64 && cgo - -package m1cpu - -// #cgo LDFLAGS: -framework CoreFoundation -framework IOKit -// #include -// #include -// #include -// #include -// -// #if !defined(MAC_OS_VERSION_12_0) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_VERSION_12_0 -// #define kIOMainPortDefault kIOMasterPortDefault -// #endif -// -// #define HzToGHz(hz) ((hz) / 1000000000.0) -// -// UInt64 global_pCoreHz; -// UInt64 global_eCoreHz; -// int global_pCoreCount; -// int global_eCoreCount; -// int global_pCoreL1InstCacheSize; -// int global_eCoreL1InstCacheSize; -// int global_pCoreL1DataCacheSize; -// int global_eCoreL1DataCacheSize; -// int global_pCoreL2CacheSize; -// int global_eCoreL2CacheSize; -// char global_brand[32]; -// -// UInt64 getFrequency(CFTypeRef typeRef) { -// CFDataRef cfData = typeRef; -// -// CFIndex size = CFDataGetLength(cfData); -// UInt8 buf[size]; -// CFDataGetBytes(cfData, CFRangeMake(0, size), buf); -// -// UInt8 b1 = buf[size-5]; -// UInt8 b2 = buf[size-6]; -// UInt8 b3 = buf[size-7]; -// UInt8 b4 = buf[size-8]; -// -// UInt64 pCoreHz = 0x00000000FFFFFFFF & ((b1<<24) | (b2 << 16) | (b3 << 8) | (b4)); -// return pCoreHz; -// } -// -// int sysctl_int(const char * name) { -// int value = -1; -// size_t size = 8; -// sysctlbyname(name, &value, &size, NULL, 0); -// return value; -// } -// -// void sysctl_string(const char * name, char * dest) { -// size_t size = 32; -// sysctlbyname(name, dest, &size, NULL, 0); -// } -// -// void initialize() { -// global_pCoreCount = sysctl_int("hw.perflevel0.physicalcpu"); -// global_eCoreCount = sysctl_int("hw.perflevel1.physicalcpu"); -// global_pCoreL1InstCacheSize = sysctl_int("hw.perflevel0.l1icachesize"); -// global_eCoreL1InstCacheSize = sysctl_int("hw.perflevel1.l1icachesize"); -// global_pCoreL1DataCacheSize = sysctl_int("hw.perflevel0.l1dcachesize"); -// global_eCoreL1DataCacheSize = sysctl_int("hw.perflevel1.l1dcachesize"); -// global_pCoreL2CacheSize = sysctl_int("hw.perflevel0.l2cachesize"); -// global_eCoreL2CacheSize = sysctl_int("hw.perflevel1.l2cachesize"); -// sysctl_string("machdep.cpu.brand_string", global_brand); -// -// CFMutableDictionaryRef matching = IOServiceMatching("AppleARMIODevice"); -// io_iterator_t iter; -// IOServiceGetMatchingServices(kIOMainPortDefault, matching, &iter); -// -// const size_t bufsize = 512; -// io_object_t obj; -// while ((obj = IOIteratorNext(iter))) { -// char class[bufsize]; -// IOObjectGetClass(obj, class); -// char name[bufsize]; -// IORegistryEntryGetName(obj, name); -// -// if (strncmp(name, "pmgr", bufsize) == 0) { -// CFTypeRef pCoreRef = IORegistryEntryCreateCFProperty(obj, CFSTR("voltage-states5-sram"), kCFAllocatorDefault, 0); -// CFTypeRef eCoreRef = IORegistryEntryCreateCFProperty(obj, CFSTR("voltage-states1-sram"), kCFAllocatorDefault, 0); -// -// long long pCoreHz = getFrequency(pCoreRef); -// long long eCoreHz = getFrequency(eCoreRef); -// -// global_pCoreHz = pCoreHz; -// global_eCoreHz = eCoreHz; -// return; -// } -// } -// } -// -// UInt64 eCoreHz() { -// return global_eCoreHz; -// } -// -// UInt64 pCoreHz() { -// return global_pCoreHz; -// } -// -// Float64 eCoreGHz() { -// return HzToGHz(global_eCoreHz); -// } -// -// Float64 pCoreGHz() { -// return HzToGHz(global_pCoreHz); -// } -// -// int pCoreCount() { -// return global_pCoreCount; -// } -// -// int eCoreCount() { -// return global_eCoreCount; -// } -// -// int pCoreL1InstCacheSize() { -// return global_pCoreL1InstCacheSize; -// } -// -// int pCoreL1DataCacheSize() { -// return global_pCoreL1DataCacheSize; -// } -// -// int pCoreL2CacheSize() { -// return global_pCoreL2CacheSize; -// } -// -// int eCoreL1InstCacheSize() { -// return global_eCoreL1InstCacheSize; -// } -// -// int eCoreL1DataCacheSize() { -// return global_eCoreL1DataCacheSize; -// } -// -// int eCoreL2CacheSize() { -// return global_eCoreL2CacheSize; -// } -// -// char * modelName() { -// return global_brand; -// } -import "C" - -func init() { - C.initialize() -} - -// IsAppleSilicon returns true on this platform. -func IsAppleSilicon() bool { - return true -} - -// PCoreHZ returns the max frequency in Hertz of the P-Core of an Apple Silicon CPU. -func PCoreHz() uint64 { - return uint64(C.pCoreHz()) -} - -// ECoreHZ returns the max frequency in Hertz of the E-Core of an Apple Silicon CPU. -func ECoreHz() uint64 { - return uint64(C.eCoreHz()) -} - -// PCoreGHz returns the max frequency in Gigahertz of the P-Core of an Apple Silicon CPU. -func PCoreGHz() float64 { - return float64(C.pCoreGHz()) -} - -// ECoreGHz returns the max frequency in Gigahertz of the E-Core of an Apple Silicon CPU. -func ECoreGHz() float64 { - return float64(C.eCoreGHz()) -} - -// PCoreCount returns the number of physical P (performance) cores. -func PCoreCount() int { - return int(C.pCoreCount()) -} - -// ECoreCount returns the number of physical E (efficiency) cores. -func ECoreCount() int { - return int(C.eCoreCount()) -} - -// PCoreCacheSize returns the sizes of the P (performance) core cache sizes -// in the order of -// -// - L1 instruction cache -// - L1 data cache -// - L2 cache -func PCoreCache() (int, int, int) { - return int(C.pCoreL1InstCacheSize()), - int(C.pCoreL1DataCacheSize()), - int(C.pCoreL2CacheSize()) -} - -// ECoreCacheSize returns the sizes of the E (efficiency) core cache sizes -// in the order of -// -// - L1 instruction cache -// - L1 data cache -// - L2 cache -func ECoreCache() (int, int, int) { - return int(C.eCoreL1InstCacheSize()), - int(C.eCoreL1DataCacheSize()), - int(C.eCoreL2CacheSize()) -} - -// ModelName returns the model name of the CPU. -func ModelName() string { - return C.GoString(C.modelName()) -} diff --git a/vendor/github.com/shoenig/go-m1cpu/incompatible.go b/vendor/github.com/shoenig/go-m1cpu/incompatible.go deleted file mode 100644 index d425025aa84d5..0000000000000 --- a/vendor/github.com/shoenig/go-m1cpu/incompatible.go +++ /dev/null @@ -1,53 +0,0 @@ -//go:build !darwin || !arm64 || !cgo - -package m1cpu - -// IsAppleSilicon return false on this platform. -func IsAppleSilicon() bool { - return false -} - -// PCoreHZ requires darwin/arm64 -func PCoreHz() uint64 { - panic("m1cpu: not a darwin/arm64 system") -} - -// ECoreHZ requires darwin/arm64 -func ECoreHz() uint64 { - panic("m1cpu: not a darwin/arm64 system") -} - -// PCoreGHz requires darwin/arm64 -func PCoreGHz() float64 { - panic("m1cpu: not a darwin/arm64 system") -} - -// ECoreGHz requires darwin/arm64 -func ECoreGHz() float64 { - panic("m1cpu: not a darwin/arm64 system") -} - -// PCoreCount requires darwin/arm64 -func PCoreCount() int { - panic("m1cpu: not a darwin/arm64 system") -} - -// ECoreCount requires darwin/arm64 -func ECoreCount() int { - panic("m1cpu: not a darwin/arm64 system") -} - -// PCoreCacheSize requires darwin/arm64 -func PCoreCache() (int, int, int) { - panic("m1cpu: not a darwin/arm64 system") -} - -// ECoreCacheSize requires darwin/arm64 -func ECoreCache() (int, int, int) { - panic("m1cpu: not a darwin/arm64 system") -} - -// ModelName requires darwin/arm64 -func ModelName() string { - panic("m1cpu: not a darwin/arm64 system") -} diff --git a/vendor/modules.txt b/vendor/modules.txt index ff9365f2c4c99..3000b8f87255e 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -666,6 +666,12 @@ github.com/eapache/go-xerial-snappy # github.com/eapache/queue v1.1.0 ## explicit github.com/eapache/queue +# github.com/ebitengine/purego v0.8.0 +## explicit; go 1.18 +github.com/ebitengine/purego +github.com/ebitengine/purego/internal/cgo +github.com/ebitengine/purego/internal/fakecgo +github.com/ebitengine/purego/internal/strings # github.com/edsrzf/mmap-go v1.1.0 ## explicit; go 1.17 github.com/edsrzf/mmap-go @@ -1527,17 +1533,14 @@ github.com/segmentio/fasthash/fnv1a # github.com/sercand/kuberesolver/v5 v5.1.1 ## explicit; go 1.18 github.com/sercand/kuberesolver/v5 -# github.com/shirou/gopsutil/v4 v4.24.0-alpha.1 -## explicit; go 1.20 +# github.com/shirou/gopsutil/v4 v4.24.9 +## explicit; go 1.18 github.com/shirou/gopsutil/v4/common github.com/shirou/gopsutil/v4/cpu github.com/shirou/gopsutil/v4/internal/common github.com/shirou/gopsutil/v4/mem github.com/shirou/gopsutil/v4/net github.com/shirou/gopsutil/v4/process -# github.com/shoenig/go-m1cpu v0.1.6 -## explicit; go 1.20 -github.com/shoenig/go-m1cpu # github.com/shopspring/decimal v1.2.0 ## explicit; go 1.13 github.com/shopspring/decimal From 08c70cca2e7b3a7444b0ec9822a6d5fd58ae70d5 Mon Sep 17 00:00:00 2001 From: Nicolas Giard Date: Thu, 3 Oct 2024 14:04:41 -0400 Subject: [PATCH 03/26] fix(helm): add missing `loki.storage.azure.chunkDelimiter` parameter to Helm chart (#14011) Co-authored-by: Vladyslav Diachenko <82767850+vlad-diachenko@users.noreply.github.com> --- docs/sources/setup/install/helm/reference.md | 1 + production/helm/loki/CHANGELOG.md | 4 ++++ production/helm/loki/Chart.yaml | 2 +- production/helm/loki/README.md | 2 +- production/helm/loki/templates/_helpers.tpl | 3 +++ production/helm/loki/values.yaml | 1 + 6 files changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/sources/setup/install/helm/reference.md b/docs/sources/setup/install/helm/reference.md index c8d5f7bbbd107..43d246ec1fad1 100644 --- a/docs/sources/setup/install/helm/reference.md +++ b/docs/sources/setup/install/helm/reference.md @@ -6186,6 +6186,7 @@ null "azure": { "accountKey": null, "accountName": null, + "chunkDelimiter": null, "connectionString": null, "endpointSuffix": null, "requestTimeout": null, diff --git a/production/helm/loki/CHANGELOG.md b/production/helm/loki/CHANGELOG.md index 18d0aca93a3d6..55ed8d2ed6849 100644 --- a/production/helm/loki/CHANGELOG.md +++ b/production/helm/loki/CHANGELOG.md @@ -13,6 +13,10 @@ Entries should include a reference to the pull request that introduced the chang [//]: # ( : do not remove this line. This locator is used by the CI pipeline to automatically create a changelog entry for each new Loki release. Add other chart versions and respective changelog entries bellow this line.) +## 6.17.1 + +- [BUGFIX] Added missing `loki.storage.azure.chunkDelimiter` parameter to Helm chart. + ## 6.17.0 - [CHANGE] Changed version of Grafana Loki to 3.2.0 diff --git a/production/helm/loki/Chart.yaml b/production/helm/loki/Chart.yaml index 07941278dfa0a..2381bac048101 100644 --- a/production/helm/loki/Chart.yaml +++ b/production/helm/loki/Chart.yaml @@ -3,7 +3,7 @@ name: loki description: Helm chart for Grafana Loki and Grafana Enterprise Logs supporting both simple, scalable and distributed modes. type: application appVersion: 3.2.0 -version: 6.17.0 +version: 6.17.1 home: https://grafana.github.io/helm-charts sources: - https://github.com/grafana/loki diff --git a/production/helm/loki/README.md b/production/helm/loki/README.md index 12ebf95948e23..6f7566c606f9f 100644 --- a/production/helm/loki/README.md +++ b/production/helm/loki/README.md @@ -1,6 +1,6 @@ # loki -![Version: 6.17.0](https://img.shields.io/badge/Version-6.17.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 3.2.0](https://img.shields.io/badge/AppVersion-3.2.0-informational?style=flat-square) +![Version: 6.17.1](https://img.shields.io/badge/Version-6.17.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 3.2.0](https://img.shields.io/badge/AppVersion-3.2.0-informational?style=flat-square) Helm chart for Grafana Loki and Grafana Enterprise Logs supporting both simple, scalable and distributed modes. diff --git a/production/helm/loki/templates/_helpers.tpl b/production/helm/loki/templates/_helpers.tpl index 9a4ab135db922..f302bc5a621a3 100644 --- a/production/helm/loki/templates/_helpers.tpl +++ b/production/helm/loki/templates/_helpers.tpl @@ -284,6 +284,9 @@ azure: {{- with .endpointSuffix }} endpoint_suffix: {{ . }} {{- end }} + {{- with .chunkDelimiter }} + chunk_delimiter: {{ . }} + {{- end }} {{- end -}} {{- else if eq .Values.loki.storage.type "alibabacloud" -}} {{- with .Values.loki.storage.alibabacloud }} diff --git a/production/helm/loki/values.yaml b/production/helm/loki/values.yaml index 9640891480513..3185f780ccd29 100644 --- a/production/helm/loki/values.yaml +++ b/production/helm/loki/values.yaml @@ -351,6 +351,7 @@ loki: userAssignedId: null requestTimeout: null endpointSuffix: null + chunkDelimiter: null swift: auth_version: null auth_url: null From 9d7a6ea68053b576553e426d339961d50ee07080 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 3 Oct 2024 12:13:08 -0600 Subject: [PATCH 04/26] fix(deps): update github.com/grafana/dskit digest to b69ac1b (#14355) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- tools/lambda-promtail/go.mod | 2 +- tools/lambda-promtail/go.sum | 4 ++-- vendor/modules.txt | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index e63fbf945081b..8873bcba24e61 100644 --- a/go.mod +++ b/go.mod @@ -49,7 +49,7 @@ require ( github.com/gorilla/mux v1.8.1 github.com/gorilla/websocket v1.5.3 github.com/grafana/cloudflare-go v0.0.0-20230110200409-c627cf6792f2 - github.com/grafana/dskit v0.0.0-20240930165212-f52de24af9bc + github.com/grafana/dskit v0.0.0-20241002104024-b69ac1b95024 github.com/grafana/go-gelf/v2 v2.0.1 github.com/grafana/gomemcache v0.0.0-20240229205252-cd6a66d6fb56 github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc diff --git a/go.sum b/go.sum index 84a9caeb8034d..bca64f1bbbcce 100644 --- a/go.sum +++ b/go.sum @@ -1044,8 +1044,8 @@ github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aN github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grafana/cloudflare-go v0.0.0-20230110200409-c627cf6792f2 h1:qhugDMdQ4Vp68H0tp/0iN17DM2ehRo1rLEdOFe/gB8I= github.com/grafana/cloudflare-go v0.0.0-20230110200409-c627cf6792f2/go.mod h1:w/aiO1POVIeXUQyl0VQSZjl5OAGDTL5aX+4v0RA1tcw= -github.com/grafana/dskit v0.0.0-20240930165212-f52de24af9bc h1:OLRT3mpHjvTjq4Km7L36lipZ+hTOX1U3jct0DFMADdo= -github.com/grafana/dskit v0.0.0-20240930165212-f52de24af9bc/go.mod h1:SPLNCARd4xdjCkue0O6hvuoveuS1dGJjDnfxYe405YQ= +github.com/grafana/dskit v0.0.0-20241002104024-b69ac1b95024 h1:RflXv1xMlnqP0zr1apM3lJ0BK5SwvEOGLv980V+oGJ0= +github.com/grafana/dskit v0.0.0-20241002104024-b69ac1b95024/go.mod h1:SPLNCARd4xdjCkue0O6hvuoveuS1dGJjDnfxYe405YQ= github.com/grafana/go-gelf/v2 v2.0.1 h1:BOChP0h/jLeD+7F9mL7tq10xVkDG15he3T1zHuQaWak= github.com/grafana/go-gelf/v2 v2.0.1/go.mod h1:lexHie0xzYGwCgiRGcvZ723bSNyNI8ZRD4s0CLobh90= github.com/grafana/gocql v0.0.0-20200605141915-ba5dc39ece85 h1:xLuzPoOzdfNb/RF/IENCw+oLVdZB4G21VPhkHBgwSHY= diff --git a/tools/lambda-promtail/go.mod b/tools/lambda-promtail/go.mod index 96480efeb823b..1046188c1f118 100644 --- a/tools/lambda-promtail/go.mod +++ b/tools/lambda-promtail/go.mod @@ -10,7 +10,7 @@ require ( github.com/go-kit/log v0.2.1 github.com/gogo/protobuf v1.3.2 github.com/golang/snappy v0.0.4 - github.com/grafana/dskit v0.0.0-20240930165212-f52de24af9bc + github.com/grafana/dskit v0.0.0-20241002104024-b69ac1b95024 github.com/grafana/loki/v3 v3.0.0-20240809103847-9315b3d03d79 github.com/prometheus/common v0.55.0 github.com/stretchr/testify v1.9.0 diff --git a/tools/lambda-promtail/go.sum b/tools/lambda-promtail/go.sum index 024bef722f7ae..cf8c6d178524d 100644 --- a/tools/lambda-promtail/go.sum +++ b/tools/lambda-promtail/go.sum @@ -216,8 +216,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= -github.com/grafana/dskit v0.0.0-20240930165212-f52de24af9bc h1:OLRT3mpHjvTjq4Km7L36lipZ+hTOX1U3jct0DFMADdo= -github.com/grafana/dskit v0.0.0-20240930165212-f52de24af9bc/go.mod h1:SPLNCARd4xdjCkue0O6hvuoveuS1dGJjDnfxYe405YQ= +github.com/grafana/dskit v0.0.0-20241002104024-b69ac1b95024 h1:RflXv1xMlnqP0zr1apM3lJ0BK5SwvEOGLv980V+oGJ0= +github.com/grafana/dskit v0.0.0-20241002104024-b69ac1b95024/go.mod h1:SPLNCARd4xdjCkue0O6hvuoveuS1dGJjDnfxYe405YQ= github.com/grafana/gomemcache v0.0.0-20240229205252-cd6a66d6fb56 h1:X8IKQ0wu40wpvYcKfBcc5T4QnhdQjUhtUtB/1CY89lE= github.com/grafana/gomemcache v0.0.0-20240229205252-cd6a66d6fb56/go.mod h1:PGk3RjYHpxMM8HFPhKKo+vve3DdlPUELZLSDEFehPuU= github.com/grafana/jsonparser v0.0.0-20240425183733-ea80629e1a32 h1:NznuPwItog+rwdVg8hAuGKP29ndRSzJAwhxKldkP8oQ= diff --git a/vendor/modules.txt b/vendor/modules.txt index 3000b8f87255e..5cac5030511cf 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -986,7 +986,7 @@ github.com/gorilla/websocket # github.com/grafana/cloudflare-go v0.0.0-20230110200409-c627cf6792f2 ## explicit; go 1.17 github.com/grafana/cloudflare-go -# github.com/grafana/dskit v0.0.0-20240930165212-f52de24af9bc +# github.com/grafana/dskit v0.0.0-20241002104024-b69ac1b95024 ## explicit; go 1.21 github.com/grafana/dskit/aws github.com/grafana/dskit/backoff From b7bccfcec3275b1d6d76c7450415ac8744e4d7b0 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 3 Oct 2024 12:14:23 -0600 Subject: [PATCH 05/26] fix(deps): update module go.etcd.io/bbolt to v1.3.11 (#14358) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- go.mod | 6 ++-- go.sum | 4 +-- .../testdata/client_intermediate_cert.der | Bin 998 -> 0 bytes .../testdata/client_leaf_cert.der | Bin 1147 -> 0 bytes .../testdata/client_root_cert.der | Bin 1013 -> 0 bytes .../testdata/server_intermediate_cert.der | Bin 998 -> 0 bytes .../testdata/server_leaf_cert.der | Bin 1147 -> 0 bytes .../testdata/server_root_cert.der | Bin 1013 -> 0 bytes .../v2/remotesigner/testdata/client_cert.der | Bin 1013 -> 0 bytes .../v2/remotesigner/testdata/client_cert.pem | 24 --------------- .../v2/remotesigner/testdata/client_key.pem | 27 ----------------- .../v2/remotesigner/testdata/server_cert.der | Bin 1013 -> 0 bytes .../v2/remotesigner/testdata/server_cert.pem | 24 --------------- .../v2/remotesigner/testdata/server_key.pem | 27 ----------------- .../internal/v2/testdata/client_cert.pem | 24 --------------- .../internal/v2/testdata/client_key.pem | 27 ----------------- .../internal/v2/testdata/server_cert.pem | 24 --------------- .../internal/v2/testdata/server_key.pem | 27 ----------------- .../tlsconfigstore/testdata/client_cert.pem | 24 --------------- .../v2/tlsconfigstore/testdata/client_key.pem | 27 ----------------- .../tlsconfigstore/testdata/server_cert.pem | 24 --------------- .../v2/tlsconfigstore/testdata/server_key.pem | 27 ----------------- .../google/s2a-go/testdata/client_cert.pem | 24 --------------- .../google/s2a-go/testdata/client_key.pem | 27 ----------------- .../s2a-go/testdata/mds_client_cert.pem | 19 ------------ .../google/s2a-go/testdata/mds_client_key.pem | 28 ------------------ .../google/s2a-go/testdata/mds_root_cert.pem | 21 ------------- .../s2a-go/testdata/mds_server_cert.pem | 21 ------------- .../google/s2a-go/testdata/mds_server_key.pem | 28 ------------------ .../s2a-go/testdata/self_signed_cert.pem | 19 ------------ .../s2a-go/testdata/self_signed_key.pem | 28 ------------------ .../google/s2a-go/testdata/server_cert.pem | 24 --------------- .../google/s2a-go/testdata/server_key.pem | 27 ----------------- vendor/go.etcd.io/bbolt/.go-version | 2 +- vendor/go.etcd.io/bbolt/Makefile | 13 ++++++++ vendor/go.etcd.io/bbolt/db.go | 8 +++-- vendor/go.etcd.io/bbolt/freelist.go | 8 +++++ vendor/go.etcd.io/bbolt/tx.go | 7 +++++ vendor/modules.txt | 4 +-- 39 files changed, 42 insertions(+), 582 deletions(-) delete mode 100644 vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/client_intermediate_cert.der delete mode 100644 vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/client_leaf_cert.der delete mode 100644 vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/client_root_cert.der delete mode 100644 vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/server_intermediate_cert.der delete mode 100644 vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/server_leaf_cert.der delete mode 100644 vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/server_root_cert.der delete mode 100644 vendor/github.com/google/s2a-go/internal/v2/remotesigner/testdata/client_cert.der delete mode 100644 vendor/github.com/google/s2a-go/internal/v2/remotesigner/testdata/client_cert.pem delete mode 100644 vendor/github.com/google/s2a-go/internal/v2/remotesigner/testdata/client_key.pem delete mode 100644 vendor/github.com/google/s2a-go/internal/v2/remotesigner/testdata/server_cert.der delete mode 100644 vendor/github.com/google/s2a-go/internal/v2/remotesigner/testdata/server_cert.pem delete mode 100644 vendor/github.com/google/s2a-go/internal/v2/remotesigner/testdata/server_key.pem delete mode 100644 vendor/github.com/google/s2a-go/internal/v2/testdata/client_cert.pem delete mode 100644 vendor/github.com/google/s2a-go/internal/v2/testdata/client_key.pem delete mode 100644 vendor/github.com/google/s2a-go/internal/v2/testdata/server_cert.pem delete mode 100644 vendor/github.com/google/s2a-go/internal/v2/testdata/server_key.pem delete mode 100644 vendor/github.com/google/s2a-go/internal/v2/tlsconfigstore/testdata/client_cert.pem delete mode 100644 vendor/github.com/google/s2a-go/internal/v2/tlsconfigstore/testdata/client_key.pem delete mode 100644 vendor/github.com/google/s2a-go/internal/v2/tlsconfigstore/testdata/server_cert.pem delete mode 100644 vendor/github.com/google/s2a-go/internal/v2/tlsconfigstore/testdata/server_key.pem delete mode 100644 vendor/github.com/google/s2a-go/testdata/client_cert.pem delete mode 100644 vendor/github.com/google/s2a-go/testdata/client_key.pem delete mode 100644 vendor/github.com/google/s2a-go/testdata/mds_client_cert.pem delete mode 100644 vendor/github.com/google/s2a-go/testdata/mds_client_key.pem delete mode 100644 vendor/github.com/google/s2a-go/testdata/mds_root_cert.pem delete mode 100644 vendor/github.com/google/s2a-go/testdata/mds_server_cert.pem delete mode 100644 vendor/github.com/google/s2a-go/testdata/mds_server_key.pem delete mode 100644 vendor/github.com/google/s2a-go/testdata/self_signed_cert.pem delete mode 100644 vendor/github.com/google/s2a-go/testdata/self_signed_key.pem delete mode 100644 vendor/github.com/google/s2a-go/testdata/server_cert.pem delete mode 100644 vendor/github.com/google/s2a-go/testdata/server_key.pem diff --git a/go.mod b/go.mod index 8873bcba24e61..32cae2cba59dc 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,8 @@ module github.com/grafana/loki/v3 -go 1.21.8 +go 1.22 + +toolchain go1.23.2 require ( cloud.google.com/go/bigtable v1.29.0 @@ -93,7 +95,7 @@ require ( github.com/stretchr/testify v1.9.0 github.com/uber/jaeger-client-go v2.30.0+incompatible github.com/xdg-go/scram v1.1.2 - go.etcd.io/bbolt v1.3.10 + go.etcd.io/bbolt v1.3.11 go.uber.org/atomic v1.11.0 go.uber.org/goleak v1.3.0 golang.org/x/crypto v0.27.0 diff --git a/go.sum b/go.sum index bca64f1bbbcce..00afdeb6e1231 100644 --- a/go.sum +++ b/go.sum @@ -1889,8 +1889,8 @@ go.einride.tech/aip v0.67.1/go.mod h1:ZGX4/zKw8dcgzdLsrvpOOGxfxI2QSk12SlP7d6c0/X go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= -go.etcd.io/bbolt v1.3.10 h1:+BqfJTcCzTItrop8mq/lbzL8wSGtj94UO/3U31shqG0= -go.etcd.io/bbolt v1.3.10/go.mod h1:bK3UQLPJZly7IlNmV7uVHJDxfe5aK9Ll93e/74Y9oEQ= +go.etcd.io/bbolt v1.3.11 h1:yGEzV1wPz2yVCLsD8ZAiGHhHVlczyC9d1rP43/VCRJ0= +go.etcd.io/bbolt v1.3.11/go.mod h1:dksAq7YMXoljX0xu6VF5DMZGbhYYoLUalEiSySYAS4I= go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= go.etcd.io/etcd v0.5.0-alpha.5.0.20190917205325-a14579fbfb1a/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= go.etcd.io/etcd/api/v3 v3.5.4 h1:OHVyt3TopwtUQ2GKdd5wu3PmmipR4FTwCqoEjSyRdIc= diff --git a/vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/client_intermediate_cert.der b/vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/client_intermediate_cert.der deleted file mode 100644 index 958f3cfaddf3645fa6c0578b5b6955d65ac4c172..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 998 zcmXqLVt!=M#B^!_GZP~dlZfxTkgMw#Mx5CteAhsdS=K*t&xAY!UN%mxHjlRNyo`+8 ztPBQ??S|Y2oNUaYENsF|p}{Z?2M?38qoI(207!`V#>K<# zoS$2em{(~iXuuB=;pX9R$t=q(&dkp<6f+P32{H5V78@nTm!uY##3!c~l^9AHNWiV< zWEA7BsH}1TV!h=2Tmw0AULzv|Gec7&Lt`^z^C)p%6J+ina%mHz5^^vyvNA9?G4eAQ zG%<29H8CnfQWlH+MyjTjz z2Bjk+Ub9TzT(Z$!`+w1f9a{SYn?h^$U$mDJKK^KOurlxGlhf8coXvjW^}bgt-rFjD znHJ|Xo9Wew;}%JlW_Kjsthc+chb^XXpU3LOdy_KCS4OTntgUFd?YsGkV{8gPCrIUU z7xZ1<|6Oe5g44&3J$ODp>G5YKW=00a#V!U;2J*mEAgjzGVIbBZvce&_^W7!+r|T*d zavIkkZ(n>dQ`LY6q(GR3)qt6i@xOr}h$qOxWx&zImXe>Fn2DZTf#J-^uui3sYst!# z{ImS~I{#0uS#WDz%!i-3yIxOGkACKhN$DyM2L{LbrkL@xJCpY3crHP)J~LHEx;nsZlX$z1Na++S~*x&F8L zSHsIX`Pf;-7fz4f$yxWfRV}c$Te2$X#22gkrUlwjtNp9{IiD}~zjo}z)1J=iJoj~z zPFk$n)~eK8B%5+0@w1g$N8H(l+-H4!LOMmyS_+%b`$^TD`}g=z?!9=Gts-l=GE2@y HTP6bly#{pd diff --git a/vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/client_leaf_cert.der b/vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/client_leaf_cert.der deleted file mode 100644 index d2817641bafb022339926786ab85b545f40ac665..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1147 zcmXqLVktLhVvb+H%*4pVB*OPMYW498DSV5WgVNVW|Jr8oCgimNFB_*;n@8JsUPeZ4 zRtAH{c0+ChPB!LH7B*p~&|nycgNMo4(NM@h03^fC!x>zfmseSqn3HNKV890w6yxnyM_06xZQcZ?W@M4y!->Y40>Qzg1y0 z&gNQpqF{|c>D+ZZ(rFIKEL_n{%!~|-iyLnkG+s4m+z3nvvdS!tD-9Z#Eo|&v(%3b4 zVzNoZ_g%=<^$R1;>=M3fAjvH2AGv2jo&gWY$-*qG2F#3%{|y8|JV6#N1CA!Pl>FSp z%sk}C2j(GQ()!XwH^ngbB~t_{rh@w&h5|n>_#Tt3odjy zuPCdY_u)fF^#8=jc^^+Q{aqN5`$@Gm({I-q6VU_LtQOD6naL>j(`V|D&;QI6%^$Dc z@$uH$=blqSKTV1FFaEpmVP=>@vvi*Y`l|mqO|ORNA0oIS8nOI z?NiA8%5=ljL@D29-OKpueEYz|zv5rHb554&taa#n7142tpUKWU?R-O_r^0)6j>G3Y aOB;Xxy<$H9NT-Uzt(mu6i*GEf3IzZ)c%0q< diff --git a/vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/client_root_cert.der b/vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/client_root_cert.der deleted file mode 100644 index d8c3710c85f9ff41ddfc709924c866350a727a4f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1013 zcmXqLV*Y5*#B_53GZP~dlZa+?pWMd9xVH0Kw4Tf@Xyh=ks1AdSQHxGwPW?5!&W`3Tbn1KjLh?$4C*eEf+B(=CCJ~_3h#8ApW0&YDg zqZoHZWt9UE>m}#s8pw(B8W|aw8XFoJ7#JIxMv3#90J%nHQ0^ddX%nLoaxgNoGB7tW z@-rATF>*0AF)}hdZr#y6M}F(|x(>G^%gcAlKWcTb*S((Se#vIyuMojqJ6T@W9G$-N zZ|C3aC}V-ru$PA$a>||`V5!;WvLO9;#Z4xLTYkS~Q%%)mH+DGbsA<2rr@8F$Psyk! zC02_czBy5RY)XCG=Yl1DX=(>VSrdJ-C#|hK7^zn?b35awX)f$Ntvf$$ zcUg9sL1fPSDbXqWt6$VVZu~MYZrj`2y}fI?80UuXsujC8ao09pzReSEFH3&Hjk;!&j?yPw^7|NHlfMLseyY=TyHB}&&4U!T;kt&%Ic z-@@f=`1w!pGyVU%zJI$PWGYXZ;?Bg($iTQb*dWkA7MKcT`B=nQL{>NicfPwM|8!l2 zLQdoQtUFt($qvv(cdI=i6tz3tUW`|a0C z&5N-8^H(H$?psgMz!}^;s& z=?+d?)Hkg%emvc~QLj+DwRvTMu)Tl4_m}{_7kTC1{xNsF-p9krsM-B)Ge_#Kiu#~{ zd67^5U(N6lVcaug+5}Tw2V+f_-BCNQyG;7WAZ_<^`6QjCrOhu7&ztq4tdo7t^%&>) zTR0VF*I2Sr HHQW{e5x{wf diff --git a/vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/server_intermediate_cert.der b/vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/server_intermediate_cert.der deleted file mode 100644 index dae619c097512f20d09d2054c63fc0f715d7be24..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 998 zcmXqLVt!=M#B^!_GZP~dlZZk6mxvepr#-!NVoqOL*`yn*LOZ7#@Un4gwRyCC=VfH% zW@RvFY&YaK;ACSCWnmL$3Jr#FICz+x9SwyH1VA$EJeHTH8JZfJT11KSnjmurkxQExm5_sxk(GhDiIJbd zpox)-sfm%1VO{t`EzVyWX$3+}`kJnrGQY>^=jnZyz4d%;|IQeuB_Gcfo1a{_>B5Fg zXYbI=4K*7QZdjc*51-)~EjRzyir2SPA5Z@zcTLeXV*g^*2f0P(7p>c z?c<>#uh>H(ryKBq6bQ4h8Za|5{x=W=@dR183^XGxLzc8JJvw;mpWjp+5Pu z!*lq#5Sb^i@`a>klJNjzx%iu)2*?h3yy-gEL(;p^g~mZo#n!wzh9Qua5C+wfRd ztarh_l9E{Oro7&WNVTl@3-~vy&EDU;)-f|r-8<&mQ>C=;``&D2+5V0(pW(g3o1}Sj z^gY793Mi&+ntK1`1tm%ENt=U{rb%k1PtbRHEhYTylqR?8HqOeuvA1fBY>pc~NUFTR KZE!sDzAgX``fm0B diff --git a/vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/server_leaf_cert.der b/vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/server_leaf_cert.der deleted file mode 100644 index ce7f8d31d6802c7e68c188af8797c3a063894857..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1147 zcmXqLVktLhVvb+H%*4pVB%&$)xidhT`$ARBi)~L`p2_`@+!*`b5acj4ER7|Ts-W~ z`MCv&d6kBO2K*oqZXOPo%(Bel%=|nTUzhK>3dC_Z(le%bCn$9moio9jI@8{ zd;5%c{XT!(ig$;5K+$bpwI6ChVmse+UV1r`!RY5*U#A%ppFJxS>PX#w$sz7*X_R~A zg!|$g&z66XI$)aW-TrxDio@fp!U^sS#+*GdHMB|H?BTf!^g~J_=D$Y-Ot{~xpTg~G+{k6 Zdr{DieczoQDL-a%Ib3(Tsv+bGCjf+Ap-TV& diff --git a/vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/server_root_cert.der b/vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/server_root_cert.der deleted file mode 100644 index 04b0d73600b72f80a03943d41973b279db9e8b32..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1013 zcmXqLV*Y5*#B_53GZP~dlZb{E^N!s~snriRh?%)HJiGKl>CAisUN%mxHjlRNyo`+8 ztPBQ??S|Y2oNUaYENsF|p}{Z?2M?38qoI(207!`V#>K<# zoS$2em{(~iXuuB=;pX9R$t=q(&dkp<6f+P32{H5V78@nTm!uY##3!c~l^9AHNWiV< zWEA7BsH}1TV!h=2Tmw0AULzv|Q)5FT0|N^q(aL-(RkWjuO*nCZC(^b4{cp%V+e53*PfoZW)2DU5BJN^Jypf0+ z%dyqB7eAAEDfH_&Z*6C3aP8^9M)sYbgC^`~v;4F5#oepTLYl5+2bdY(i!-?My>4G) z&8u+L`?_9LxQB1$HP?fpd*5i(-|SJJ!`sZHa8UZu(QeP3Dc(Yr8?G#iY20z>);Fh$ zMQ>DZHkC%KUBdEb&cYv;1sHCx@Vv~#%*epFIM^W2Ko*z^WcgUcSVVXxICA%7?w=9J zwOIRjXviz}kjUu<@*rtt76}8f2J8wz2}@R(k?}tZs{u2RLJoFd>IDWnBZI}4y?mP{ zW+WALO{`uTY0T-O8uy=9`&z_;*e^$wYu3!Wz-Re-&a7vV%g_8h++q8CMf&zxTFdl~ zp5i+{-R9L&+mdUFEBoKr@u=5M->UQ>MNWJ7BRi)4^M4~B*uKhe`J%yAbG&-Thr?bk zCap+`USuL4V}qf=6kBV_EFAN zmIn*31Qb`P{oxd|=2o5l$|&AdTJ_-*k&5oDQvTTOiN8OjczyHyta?pWMd9xVH0Kw4Tf@Xyh=ks1AdSQHxGwPW?5!&W`3Tbn1KjLh?$4C*eEf+B(=CCJ~_3h#8ApW0&YDg zqZoHZWt9UE>m}#s8pw(B8W|aw8XFoJ7#JIxMv3#90J%nHQ0^ddX%nLoaxgNoGB7tW z@-rATF>*0AF)}hdZr#y6M}F(|x(>G^%gcAlKWcTb*S((Se#vIyuMojqJ6T@W9G$-N zZ|C3aC}V-ru$PA$a>||`V5!;WvLO9;#Z4xLTYkS~Q%%)mH+DGbsA<2rr@8F$Psyk! zC02_czBy5RY)XCG=Yl1DX=(>VSrdJ-C#|hK7^zn?b35awX)f$Ntvf$$ zcUg9sL1fPSDbXqWt6$VVZu~MYZrj`2y}fI?80UuXsujC8ao09pzReSEFH3&Hjk;!&j?yPw^7|NHlfMLseyY=TyHB}&&4U!T;kt&%Ic z-@@f=`1w!pGyVU%zJI$PWGYXZ;?Bg($iTQb*dWkA7MKcT`B=nQL{>NicfPwM|8!l2 zLQdoQtUFt($qvv(cdI=i6tz3tUW`|a0C z&5N-8^H(H$?psgMz!}^;s& z=?+d?)Hkg%emvc~QLj+DwRvTMu)Tl4_m}{_7kTC1{xNsF-p9krsM-B)Ge_#Kiu#~{ zd67^5U(N6lVcaug+5}Tw2V+f_-BCNQyG;7WAZ_<^`6QjCrOhu7&ztq4tdo7t^%&>) zTR0VF*I2Sr HHQW{e5x{wf diff --git a/vendor/github.com/google/s2a-go/internal/v2/remotesigner/testdata/client_cert.pem b/vendor/github.com/google/s2a-go/internal/v2/remotesigner/testdata/client_cert.pem deleted file mode 100644 index 493a5a2648101..0000000000000 --- a/vendor/github.com/google/s2a-go/internal/v2/remotesigner/testdata/client_cert.pem +++ /dev/null @@ -1,24 +0,0 @@ ------BEGIN CERTIFICATE----- -MIID8TCCAtmgAwIBAgIUKXNlBRVe6UepjQUijIFPZBd/4qYwDQYJKoZIhvcNAQEL -BQAwgYcxCzAJBgNVBAYTAlVTMQswCQYDVQQIDAJDQTESMBAGA1UEBwwJU3Vubnl2 -YWxlMRAwDgYDVQQKDAdDb21wYW55MREwDwYDVQQLDAhEaXZpc2lvbjEWMBQGA1UE -AwwNczJhX3Rlc3RfY2VydDEaMBgGCSqGSIb3DQEJARYLeHl6QHh5ei5jb20wHhcN -MjIwNTMxMjAwMzE1WhcNNDIwNTI2MjAwMzE1WjCBhzELMAkGA1UEBhMCVVMxCzAJ -BgNVBAgMAkNBMRIwEAYDVQQHDAlTdW5ueXZhbGUxEDAOBgNVBAoMB0NvbXBhbnkx -ETAPBgNVBAsMCERpdmlzaW9uMRYwFAYDVQQDDA1zMmFfdGVzdF9jZXJ0MRowGAYJ -KoZIhvcNAQkBFgt4eXpAeHl6LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC -AQoCggEBAOOFuIucH7XXfohGxKd3uR/ihUA/LdduR9I8kfpUEbq5BOt8xZe5/Yn9 -a1ozEHVW6cOAbHbnwAR8tkSgZ/t42QIA2k77HWU1Jh2xiEIsJivo3imm4/kZWuR0 -OqPh7MhzxpR/hvNwpI5mJsAVBWFMa5KtecFZLnyZtwHylrRN1QXzuLrOxuKFufK3 -RKbTABScn5RbZL976H/jgfSeXrbt242NrIoBnVe6fRbekbq2DQ6zFArbQMUgHjHK -P0UqBgdr1QmHfi9KytFyx9BTP3gXWnWIu+bY7/v7qKJMHFwGETo+dCLWYevJL316 -HnLfhApDMfP8U+Yv/y1N/YvgaSOSlEcCAwEAAaNTMFEwHQYDVR0OBBYEFKhAU4nu -0h/lrnggbIGvx4ej0WklMB8GA1UdIwQYMBaAFKhAU4nu0h/lrnggbIGvx4ej0Wkl -MA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAE/6NghzQ5fu6yR6 -EHKbj/YMrFdT7aGn5n2sAf7wJ33LIhiFHkpWBsVlm7rDtZtwhe891ZK/P60anlg9 -/P0Ua53tSRVRmCvTnEbXWOVMN4is6MsR7BlmzUxl4AtIn7jbeifEwRL7B4xDYmdA -QrQnsqoz45dLgS5xK4WDqXATP09Q91xQDuhud/b+A4jrvgwFASmL7rMIZbp4f1JQ -nlnl/9VoTBQBvJiWkDUtQDMpRLtauddEkv4AGz75p5IspXWD6cOemuh2iQec11xD -X20rs2WZbAcAiUa3nmy8OKYw435vmpj8gp39WYbX/Yx9TymrFFbVY92wYn+quTco -pKklVz0= ------END CERTIFICATE----- diff --git a/vendor/github.com/google/s2a-go/internal/v2/remotesigner/testdata/client_key.pem b/vendor/github.com/google/s2a-go/internal/v2/remotesigner/testdata/client_key.pem deleted file mode 100644 index 55a7f10c742db..0000000000000 --- a/vendor/github.com/google/s2a-go/internal/v2/remotesigner/testdata/client_key.pem +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEogIBAAKCAQEA44W4i5wftdd+iEbEp3e5H+KFQD8t125H0jyR+lQRurkE63zF -l7n9if1rWjMQdVbpw4BsdufABHy2RKBn+3jZAgDaTvsdZTUmHbGIQiwmK+jeKabj -+Rla5HQ6o+HsyHPGlH+G83CkjmYmwBUFYUxrkq15wVkufJm3AfKWtE3VBfO4us7G -4oW58rdEptMAFJyflFtkv3vof+OB9J5etu3bjY2sigGdV7p9Ft6RurYNDrMUCttA -xSAeMco/RSoGB2vVCYd+L0rK0XLH0FM/eBdadYi75tjv+/uookwcXAYROj50ItZh -68kvfXoect+ECkMx8/xT5i//LU39i+BpI5KURwIDAQABAoIBABgyjo/6iLzUMFbZ -/+w3pW6orrdIgN2akvTfED9pVYFgUA+jc3hRhY95bkNnjuaL2cy7Cc4Tk65mfRQL -Y0OxdJLr+EvSFSxAXM9npDA1ddHRsF8JqtFBSxNk8R+g1Yf0GDiO35Fgd3/ViWWA -VtQkRoSRApP3oiQKTRZd8H04keFR+PvmDk/Lq11l3Kc24A1PevKIPX1oI990ggw9 -9i4uSV+cnuMxmcI9xxJtgwdDFdjr39l2arLOHr4s6LGoV2IOdXHNlv5xRqWUZ0FH -MDHowkLgwDrdSTnNeaVNkce14Gqx+bd4hNaLCdKXMpedBTEmrut3f3hdV1kKjaKt -aqRYr8ECgYEA/YDGZY2jvFoHHBywlqmEMFrrCvQGH51m5R1Ntpkzr+Rh3YCmrpvq -xgwJXING0PUw3dz+xrH5lJICrfNE5Kt3fPu1rAEy+13mYsNowghtUq2Rtu0Hsjjx -2E3Bf8vEB6RNBMmGkUpTTIAroGF5tpJoRvfnWax+k4pFdrKYFtyZdNcCgYEA5cNv -EPltvOobjTXlUmtVP3n27KZN2aXexTcagLzRxE9CV4cYySENl3KuOMmccaZpIl6z -aHk6BT4X+M0LqElNUczrInfVqI+SGAFLGy7W6CJaqSr6cpyFUP/fosKpm6wKGgLq -udHfpvz5rckhKd8kJxFLvhGOK9yN5qpzih0gfhECgYAJfwRvk3G5wYmYpP58dlcs -VIuPenqsPoI3PPTHTU/hW+XKnWIhElgmGRdUrto9Q6IT/Y5RtSMLTLjq+Tzwb/fm -56rziYv2XJsfwgAvnI8z1Kqrto9ePsHYf3krJ1/thVsZPc9bq/QY3ohD1sLvcuaT -GgBBnLOVJU3a12/ZE2RwOwKBgF0csWMAoj8/5IB6if+3ral2xOGsl7oPZVMo/J2V -Z7EVqb4M6rd/pKFugTpUQgkwtkSOekhpcGD1hAN5HTNK2YG/+L5UMAsKe9sskwJm -HgOfAHy0BSDzW3ey6i9skg2bT9Cww+0gJ3Hl7U1HSCBO5LjMYpSZSrNtwzfqdb5Q -BX3xAoGARZdR28Ej3+/+0+fz47Yu2h4z0EI/EbrudLOWY936jIeAVwHckI3+BuqH -qR4poj1gfbnMxNuI9UzIXzjEmGewx9kDZ7IYnvloZKqoVQODO5GlKF2ja6IcMNlh -GCNdD6PSAS6HcmalmWo9sj+1YMkrl+GJikKZqVBHrHNwMGAG67w= ------END RSA PRIVATE KEY----- diff --git a/vendor/github.com/google/s2a-go/internal/v2/remotesigner/testdata/server_cert.der b/vendor/github.com/google/s2a-go/internal/v2/remotesigner/testdata/server_cert.der deleted file mode 100644 index 04b0d73600b72f80a03943d41973b279db9e8b32..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1013 zcmXqLV*Y5*#B_53GZP~dlZb{E^N!s~snriRh?%)HJiGKl>CAisUN%mxHjlRNyo`+8 ztPBQ??S|Y2oNUaYENsF|p}{Z?2M?38qoI(207!`V#>K<# zoS$2em{(~iXuuB=;pX9R$t=q(&dkp<6f+P32{H5V78@nTm!uY##3!c~l^9AHNWiV< zWEA7BsH}1TV!h=2Tmw0AULzv|Q)5FT0|N^q(aL-(RkWjuO*nCZC(^b4{cp%V+e53*PfoZW)2DU5BJN^Jypf0+ z%dyqB7eAAEDfH_&Z*6C3aP8^9M)sYbgC^`~v;4F5#oepTLYl5+2bdY(i!-?My>4G) z&8u+L`?_9LxQB1$HP?fpd*5i(-|SJJ!`sZHa8UZu(QeP3Dc(Yr8?G#iY20z>);Fh$ zMQ>DZHkC%KUBdEb&cYv;1sHCx@Vv~#%*epFIM^W2Ko*z^WcgUcSVVXxICA%7?w=9J zwOIRjXviz}kjUu<@*rtt76}8f2J8wz2}@R(k?}tZs{u2RLJoFd>IDWnBZI}4y?mP{ zW+WALO{`uTY0T-O8uy=9`&z_;*e^$wYu3!Wz-Re-&a7vV%g_8h++q8CMf&zxTFdl~ zp5i+{-R9L&+mdUFEBoKr@u=5M->UQ>MNWJ7BRi)4^M4~B*uKhe`J%yAbG&-Thr?bk zCap+`USuL4V}qf=6kBV_EFAN zmIn*31Qb`P{oxd|=2o5l$|&AdTJ_-*k&5oDQvTTOiN8OjczyHyta opgid { + _ = errors.New("") + // gofail: var lackOfDiskSpace string + // tx.rollback() + // return errors.New(lackOfDiskSpace) if err := tx.db.grow(int(tx.meta.pgid+1) * tx.db.pageSize); err != nil { tx.rollback() return err @@ -470,6 +475,7 @@ func (tx *Tx) write() error { // Ignore file sync if flag is set on DB. if !tx.db.NoSync || IgnoreNoSync { + // gofail: var beforeSyncDataPages struct{} if err := fdatasync(tx.db); err != nil { return err } @@ -507,6 +513,7 @@ func (tx *Tx) writeMeta() error { return err } if !tx.db.NoSync || IgnoreNoSync { + // gofail: var beforeSyncMetaPage struct{} if err := fdatasync(tx.db); err != nil { return err } diff --git a/vendor/modules.txt b/vendor/modules.txt index 5cac5030511cf..4e50c0c98bded 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1672,8 +1672,8 @@ github.com/yuin/gopher-lua/pm # github.com/yusufpapurcu/wmi v1.2.4 ## explicit; go 1.16 github.com/yusufpapurcu/wmi -# go.etcd.io/bbolt v1.3.10 -## explicit; go 1.21 +# go.etcd.io/bbolt v1.3.11 +## explicit; go 1.22 go.etcd.io/bbolt # go.etcd.io/etcd/api/v3 v3.5.4 ## explicit; go 1.16 From 3beb8ff9cfe7f765b5d5db87892981a223d72f50 Mon Sep 17 00:00:00 2001 From: Christian Haudum Date: Thu, 3 Oct 2024 20:30:20 +0200 Subject: [PATCH 06/26] fix(build): Use Debian Bullseye base image for build image (#14368) This change is necessary to allow the binaries built using the Loki build image to run on operating systems with older libc version. Signed-off-by: Christian Haudum --- .github/workflows/check.yml | 2 +- .github/workflows/images.yml | 2 +- .github/workflows/minor-release-pr.yml | 4 +- .github/workflows/patch-release-pr.yml | 4 +- .github/workflows/release.yml | 2 +- Makefile | 4 +- .../maintaining/release-loki-build-image.md | 28 ++----- loki-build-image/Dockerfile | 20 +++-- .../queryrangebase/queryrange.pb.go | 4 +- pkg/querier/stats/stats.pb.go | 4 +- pkg/ruler/base/ruler.pb.go | 6 +- pkg/ruler/rulespb/rules.pb.go | 6 +- pkg/storage/chunk/client/grpc/grpc.pb.go | 84 +++++++++---------- 13 files changed, 80 insertions(+), 90 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index b9f7b83d5f972..adf0c4277b10b 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -2,7 +2,7 @@ "check": "uses": "grafana/loki-release/.github/workflows/check.yml@main" "with": - "build_image": "grafana/loki-build-image:0.34.0" + "build_image": "grafana/loki-build-image:0.34.1" "golang_ci_lint_version": "v1.60.3" "release_lib_ref": "main" "skip_validation": false diff --git a/.github/workflows/images.yml b/.github/workflows/images.yml index 97b40cb2e05bc..bb2f50017d818 100644 --- a/.github/workflows/images.yml +++ b/.github/workflows/images.yml @@ -2,7 +2,7 @@ "check": "uses": "grafana/loki-release/.github/workflows/check.yml@main" "with": - "build_image": "grafana/loki-build-image:0.34.0" + "build_image": "grafana/loki-build-image:0.34.1" "golang_ci_lint_version": "v1.60.3" "release_lib_ref": "main" "skip_validation": false diff --git a/.github/workflows/minor-release-pr.yml b/.github/workflows/minor-release-pr.yml index a5c52d0fb2eec..de7880161a2bd 100644 --- a/.github/workflows/minor-release-pr.yml +++ b/.github/workflows/minor-release-pr.yml @@ -16,7 +16,7 @@ jobs: check: uses: "grafana/loki-release/.github/workflows/check.yml@main" with: - build_image: "grafana/loki-build-image:0.34.0" + build_image: "grafana/loki-build-image:0.34.1" golang_ci_lint_version: "v1.60.3" release_lib_ref: "main" skip_validation: false @@ -143,7 +143,7 @@ jobs: --env SKIP_ARM \ --volume .:/src/loki \ --workdir /src/loki \ - --entrypoint /bin/sh "grafana/loki-build-image:0.34.0" + --entrypoint /bin/sh "grafana/loki-build-image:0.34.1" git config --global --add safe.directory /src/loki echo "${NFPM_SIGNING_KEY}" > $NFPM_SIGNING_KEY_FILE make dist packages diff --git a/.github/workflows/patch-release-pr.yml b/.github/workflows/patch-release-pr.yml index 800f9afd71066..cf982bc70e239 100644 --- a/.github/workflows/patch-release-pr.yml +++ b/.github/workflows/patch-release-pr.yml @@ -16,7 +16,7 @@ jobs: check: uses: "grafana/loki-release/.github/workflows/check.yml@main" with: - build_image: "grafana/loki-build-image:0.34.0" + build_image: "grafana/loki-build-image:0.34.1" golang_ci_lint_version: "v1.60.3" release_lib_ref: "main" skip_validation: false @@ -143,7 +143,7 @@ jobs: --env SKIP_ARM \ --volume .:/src/loki \ --workdir /src/loki \ - --entrypoint /bin/sh "grafana/loki-build-image:0.34.0" + --entrypoint /bin/sh "grafana/loki-build-image:0.34.1" git config --global --add safe.directory /src/loki echo "${NFPM_SIGNING_KEY}" > $NFPM_SIGNING_KEY_FILE make dist packages diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1628a0b57dfb5..3d074be5ec592 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -219,4 +219,4 @@ name: "create release" permissions: contents: "write" id-token: "write" - pull-requests: "write" \ No newline at end of file + pull-requests: "write" diff --git a/Makefile b/Makefile index b75b4f5d5ced8..609a8190f00a4 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,7 @@ DOCKER_IMAGE_DIRS := $(patsubst %/Dockerfile,%,$(DOCKERFILES)) BUILD_IN_CONTAINER ?= true # ensure you run `make release-workflows` after changing this -BUILD_IMAGE_VERSION ?= 0.34.0 +BUILD_IMAGE_VERSION ?= 0.34.1 GO_VERSION := 1.23.1 # Docker image info @@ -664,7 +664,7 @@ else endif build-image: ensure-buildx-builder - $(SUDO) $(BUILD_OCI) --build-arg=GO_VERSION=$(GO_VERSION) -t $(IMAGE_PREFIX)/loki-build-image:$(IMAGE_TAG) ./loki-build-image + $(SUDO) $(BUILD_OCI) --build-arg=GO_VERSION=$(GO_VERSION) -t $(IMAGE_PREFIX)/loki-build-image:$(BUILD_IMAGE_VERSION) ./loki-build-image build-image-push: build-image ## push the docker build image ifneq (,$(findstring WIP,$(IMAGE_TAG))) @echo "Cannot push a WIP image, commit changes first"; \ diff --git a/docs/sources/community/maintaining/release-loki-build-image.md b/docs/sources/community/maintaining/release-loki-build-image.md index d6e1f15b1d817..45e98739324da 100644 --- a/docs/sources/community/maintaining/release-loki-build-image.md +++ b/docs/sources/community/maintaining/release-loki-build-image.md @@ -14,23 +14,11 @@ if any changes were made in the folder `./loki-build-image/`. **To build and use the `loki-build-image`:** -## Step 1 - -1. Create a branch with the desired changes to the Dockerfile. -2. Update the version tag of the `loki-build-image` pipeline defined in `.drone/drone.jsonnet` (search for `pipeline('loki-build-image')`) to a new version number (try to follow semver). -3. Run `DRONE_SERVER=https://drone.grafana.net/ DRONE_TOKEN= make drone` and commit the changes to the same branch. - 1. The `` is your personal drone token, which can be found by navigating to https://drone.grafana.net/account. -4. Create a PR. -5. Once approved and merged to `main`, the image with the new version is built and published. - {{% admonition type="note" %}} - Keep an eye on https://drone.grafana.net/grafana/loki for the build after merging ([example](https://drone.grafana.net/grafana/loki/17760/1/2)). - {{% /admonition %}} - -## Step 2 - -1. Create a branch. -2. Update the `BUILD_IMAGE_VERSION` variable in the `Makefile`. -3. Run `loki-build-image/version-updater.sh ` to update all the references. -4. Run `DRONE_SERVER=https://drone.grafana.net/ DRONE_TOKEN= make drone` to update the Drone config to use the new build image. -5. Create a new PR. - +1. Create a branch with the desired changes to the `./loki-build-image/Dockerfile`. +1. Update the `BUILD_IMAGE_VERSION` variable in the `Makefile`. +1. Commit your changes. +1. Run `make build-image-push` to build and publish the new version of the build image. +1. Run `make release-workflows` to update the Github workflows. +1. Commit your changes. +1. Push your changes to the remote branch. +1. Open a PR against the `main` branch. diff --git a/loki-build-image/Dockerfile b/loki-build-image/Dockerfile index ec35fbb249f4f..6c499c3ec26d0 100644 --- a/loki-build-image/Dockerfile +++ b/loki-build-image/Dockerfile @@ -5,8 +5,10 @@ # See ../docs/sources/community/maintaining/release-loki-build-image.md for instructions # on how to publish a new build image. ARG GO_VERSION=1.23 +ARG GOLANG_BASE_IMAGE=golang:${GO_VERSION}-bullseye + # Install helm (https://helm.sh/) and helm-docs (https://github.com/norwoodj/helm-docs) for generating Helm Chart reference. -FROM golang:${GO_VERSION}-bookworm AS helm +FROM ${GOLANG_BASE_IMAGE} AS helm ARG TARGETARCH ARG HELM_VER="v3.2.3" RUN curl -L "https://get.helm.sh/helm-${HELM_VER}-linux-$TARGETARCH.tar.gz" | tar zx && \ @@ -38,7 +40,7 @@ RUN apk add --no-cache curl && \ FROM alpine:3.20.3 AS docker RUN apk add --no-cache docker-cli docker-cli-buildx -FROM golang:${GO_VERSION}-bookworm AS drone +FROM ${GOLANG_BASE_IMAGE} AS drone ARG TARGETARCH RUN curl -L "https://github.com/drone/drone-cli/releases/download/v1.7.0/drone_linux_$TARGETARCH".tar.gz | tar zx && \ install -t /usr/local/bin drone @@ -48,35 +50,35 @@ RUN curl -L "https://github.com/drone/drone-cli/releases/download/v1.7.0/drone_l # Error: # github.com/fatih/faillint@v1.5.0 requires golang.org/x/tools@v0.0.0-20200207224406-61798d64f025 # (not golang.org/x/tools@v0.0.0-20190918214920-58d531046acd from golang.org/x/tools/cmd/goyacc@58d531046acdc757f177387bc1725bfa79895d69) -FROM golang:${GO_VERSION}-bookworm AS faillint +FROM ${GOLANG_BASE_IMAGE} AS faillint RUN GO111MODULE=on go install github.com/fatih/faillint@v1.12.0 RUN GO111MODULE=on go install golang.org/x/tools/cmd/goimports@v0.7.0 -FROM golang:${GO_VERSION}-bookworm AS delve +FROM ${GOLANG_BASE_IMAGE} AS delve RUN GO111MODULE=on go install github.com/go-delve/delve/cmd/dlv@latest # Install ghr used to push binaries and template the release # This collides with the version of go tools used in the base image, thus we install it in its own image and copy it over. -FROM golang:${GO_VERSION}-bookworm AS ghr +FROM ${GOLANG_BASE_IMAGE} AS ghr RUN GO111MODULE=on go install github.com/tcnksm/ghr@9349474 # Install nfpm (https://nfpm.goreleaser.com) for creating .deb and .rpm packages. -FROM golang:${GO_VERSION}-bookworm AS nfpm +FROM ${GOLANG_BASE_IMAGE} AS nfpm RUN GO111MODULE=on go install github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.11.3 # Install gotestsum -FROM golang:${GO_VERSION}-bookworm AS gotestsum +FROM ${GOLANG_BASE_IMAGE} AS gotestsum RUN GO111MODULE=on go install gotest.tools/gotestsum@v1.8.2 # Install tools used to compile jsonnet. -FROM golang:${GO_VERSION}-bookworm AS jsonnet +FROM ${GOLANG_BASE_IMAGE} AS jsonnet RUN GO111MODULE=on go install github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@v0.5.1 RUN GO111MODULE=on go install github.com/monitoring-mixins/mixtool/cmd/mixtool@16dc166166d91e93475b86b9355a4faed2400c18 RUN GO111MODULE=on go install github.com/google/go-jsonnet/cmd/jsonnet@v0.20.0 FROM aquasec/trivy AS trivy -FROM golang:${GO_VERSION}-bookworm +FROM ${GOLANG_BASE_IMAGE} RUN apt-get update && \ apt-get install -qy \ musl gnupg ragel \ diff --git a/pkg/querier/queryrange/queryrangebase/queryrange.pb.go b/pkg/querier/queryrange/queryrangebase/queryrange.pb.go index f376455df4c2e..2b1f7b9519034 100644 --- a/pkg/querier/queryrange/queryrangebase/queryrange.pb.go +++ b/pkg/querier/queryrange/queryrangebase/queryrange.pb.go @@ -9,11 +9,11 @@ import ( proto "github.com/gogo/protobuf/proto" _ "github.com/gogo/protobuf/types" github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" + _ "github.com/golang/protobuf/ptypes/duration" github_com_grafana_loki_v3_pkg_logproto "github.com/grafana/loki/v3/pkg/logproto" logproto "github.com/grafana/loki/v3/pkg/logproto" definitions "github.com/grafana/loki/v3/pkg/querier/queryrange/queryrangebase/definitions" resultscache "github.com/grafana/loki/v3/pkg/storage/chunk/cache/resultscache" - _ "google.golang.org/protobuf/types/known/durationpb" io "io" math "math" math_bits "math/bits" @@ -1022,7 +1022,7 @@ func (this *PrometheusRequest) String() string { `Start:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Start), "Timestamp", "types.Timestamp", 1), `&`, ``, 1) + `,`, `End:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.End), "Timestamp", "types.Timestamp", 1), `&`, ``, 1) + `,`, `Step:` + fmt.Sprintf("%v", this.Step) + `,`, - `Timeout:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Timeout), "Duration", "durationpb.Duration", 1), `&`, ``, 1) + `,`, + `Timeout:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Timeout), "Duration", "duration.Duration", 1), `&`, ``, 1) + `,`, `Query:` + fmt.Sprintf("%v", this.Query) + `,`, `CachingOptions:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.CachingOptions), "CachingOptions", "resultscache.CachingOptions", 1), `&`, ``, 1) + `,`, `Headers:` + repeatedStringForHeaders + `,`, diff --git a/pkg/querier/stats/stats.pb.go b/pkg/querier/stats/stats.pb.go index f4d7e4cc1d27a..bae01dd0eeed5 100644 --- a/pkg/querier/stats/stats.pb.go +++ b/pkg/querier/stats/stats.pb.go @@ -8,7 +8,7 @@ import ( _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" - _ "google.golang.org/protobuf/types/known/durationpb" + _ "github.com/golang/protobuf/ptypes/duration" io "io" math "math" math_bits "math/bits" @@ -251,7 +251,7 @@ func (this *Stats) String() string { return "nil" } s := strings.Join([]string{`&Stats{`, - `WallTime:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.WallTime), "Duration", "durationpb.Duration", 1), `&`, ``, 1) + `,`, + `WallTime:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.WallTime), "Duration", "duration.Duration", 1), `&`, ``, 1) + `,`, `FetchedSeriesCount:` + fmt.Sprintf("%v", this.FetchedSeriesCount) + `,`, `FetchedChunkBytes:` + fmt.Sprintf("%v", this.FetchedChunkBytes) + `,`, `}`, diff --git a/pkg/ruler/base/ruler.pb.go b/pkg/ruler/base/ruler.pb.go index 81ef01420b28f..5b3b1f1b4d5d8 100644 --- a/pkg/ruler/base/ruler.pb.go +++ b/pkg/ruler/base/ruler.pb.go @@ -11,13 +11,13 @@ import ( proto "github.com/gogo/protobuf/proto" _ "github.com/gogo/protobuf/types" github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" + _ "github.com/golang/protobuf/ptypes/duration" _ "github.com/grafana/loki/v3/pkg/logproto" github_com_grafana_loki_v3_pkg_logproto "github.com/grafana/loki/v3/pkg/logproto" rulespb "github.com/grafana/loki/v3/pkg/ruler/rulespb" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - _ "google.golang.org/protobuf/types/known/durationpb" io "io" math "math" math_bits "math/bits" @@ -1433,7 +1433,7 @@ func (this *GroupStateDesc) String() string { `Group:` + strings.Replace(fmt.Sprintf("%v", this.Group), "RuleGroupDesc", "rulespb.RuleGroupDesc", 1) + `,`, `ActiveRules:` + repeatedStringForActiveRules + `,`, `EvaluationTimestamp:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.EvaluationTimestamp), "Timestamp", "types.Timestamp", 1), `&`, ``, 1) + `,`, - `EvaluationDuration:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.EvaluationDuration), "Duration", "durationpb.Duration", 1), `&`, ``, 1) + `,`, + `EvaluationDuration:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.EvaluationDuration), "Duration", "duration.Duration", 1), `&`, ``, 1) + `,`, `}`, }, "") return s @@ -1454,7 +1454,7 @@ func (this *RuleStateDesc) String() string { `LastError:` + fmt.Sprintf("%v", this.LastError) + `,`, `Alerts:` + repeatedStringForAlerts + `,`, `EvaluationTimestamp:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.EvaluationTimestamp), "Timestamp", "types.Timestamp", 1), `&`, ``, 1) + `,`, - `EvaluationDuration:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.EvaluationDuration), "Duration", "durationpb.Duration", 1), `&`, ``, 1) + `,`, + `EvaluationDuration:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.EvaluationDuration), "Duration", "duration.Duration", 1), `&`, ``, 1) + `,`, `}`, }, "") return s diff --git a/pkg/ruler/rulespb/rules.pb.go b/pkg/ruler/rulespb/rules.pb.go index 3765e9dd88a7b..91afa25a655ef 100644 --- a/pkg/ruler/rulespb/rules.pb.go +++ b/pkg/ruler/rulespb/rules.pb.go @@ -9,9 +9,9 @@ import ( proto "github.com/gogo/protobuf/proto" github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" types "github.com/gogo/protobuf/types" + _ "github.com/golang/protobuf/ptypes/duration" _ "github.com/grafana/loki/v3/pkg/logproto" github_com_grafana_loki_v3_pkg_logproto "github.com/grafana/loki/v3/pkg/logproto" - _ "google.golang.org/protobuf/types/known/durationpb" io "io" math "math" math_bits "math/bits" @@ -657,7 +657,7 @@ func (this *RuleGroupDesc) String() string { s := strings.Join([]string{`&RuleGroupDesc{`, `Name:` + fmt.Sprintf("%v", this.Name) + `,`, `Namespace:` + fmt.Sprintf("%v", this.Namespace) + `,`, - `Interval:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Interval), "Duration", "durationpb.Duration", 1), `&`, ``, 1) + `,`, + `Interval:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Interval), "Duration", "duration.Duration", 1), `&`, ``, 1) + `,`, `Rules:` + repeatedStringForRules + `,`, `User:` + fmt.Sprintf("%v", this.User) + `,`, `Options:` + repeatedStringForOptions + `,`, @@ -674,7 +674,7 @@ func (this *RuleDesc) String() string { `Expr:` + fmt.Sprintf("%v", this.Expr) + `,`, `Record:` + fmt.Sprintf("%v", this.Record) + `,`, `Alert:` + fmt.Sprintf("%v", this.Alert) + `,`, - `For:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.For), "Duration", "durationpb.Duration", 1), `&`, ``, 1) + `,`, + `For:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.For), "Duration", "duration.Duration", 1), `&`, ``, 1) + `,`, `Labels:` + fmt.Sprintf("%v", this.Labels) + `,`, `Annotations:` + fmt.Sprintf("%v", this.Annotations) + `,`, `}`, diff --git a/pkg/storage/chunk/client/grpc/grpc.pb.go b/pkg/storage/chunk/client/grpc/grpc.pb.go index 6468535c2ab1e..d76002adfc384 100644 --- a/pkg/storage/chunk/client/grpc/grpc.pb.go +++ b/pkg/storage/chunk/client/grpc/grpc.pb.go @@ -9,10 +9,10 @@ import ( fmt "fmt" proto "github.com/gogo/protobuf/proto" github_com_gogo_protobuf_sortkeys "github.com/gogo/protobuf/sortkeys" + empty "github.com/golang/protobuf/ptypes/empty" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - emptypb "google.golang.org/protobuf/types/known/emptypb" io "io" math "math" math_bits "math/bits" @@ -1998,30 +1998,30 @@ const _ = grpc.SupportPackageIsVersion4 // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type GrpcStoreClient interface { // / WriteIndex writes batch of indexes to the index tables. - WriteIndex(ctx context.Context, in *WriteIndexRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) + WriteIndex(ctx context.Context, in *WriteIndexRequest, opts ...grpc.CallOption) (*empty.Empty, error) // / QueryIndex reads the indexes required for given query & sends back the batch of rows // / in rpc streams QueryIndex(ctx context.Context, in *QueryIndexRequest, opts ...grpc.CallOption) (GrpcStore_QueryIndexClient, error) // / DeleteIndex deletes the batch of index entries from the index tables - DeleteIndex(ctx context.Context, in *DeleteIndexRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) + DeleteIndex(ctx context.Context, in *DeleteIndexRequest, opts ...grpc.CallOption) (*empty.Empty, error) // / PutChunks saves the batch of chunks into the chunk tables. - PutChunks(ctx context.Context, in *PutChunksRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) + PutChunks(ctx context.Context, in *PutChunksRequest, opts ...grpc.CallOption) (*empty.Empty, error) // / GetChunks requests for batch of chunks and the batch of chunks are sent back in rpc streams // / batching needs to be performed at server level as per requirement instead of sending single chunk per stream. // / In GetChunks rpc request send buf as nil GetChunks(ctx context.Context, in *GetChunksRequest, opts ...grpc.CallOption) (GrpcStore_GetChunksClient, error) // / DeleteChunks deletes the chunks based on chunkID. - DeleteChunks(ctx context.Context, in *ChunkID, opts ...grpc.CallOption) (*emptypb.Empty, error) + DeleteChunks(ctx context.Context, in *ChunkID, opts ...grpc.CallOption) (*empty.Empty, error) // / Lists all the tables that exists in the database. - ListTables(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*ListTablesResponse, error) + ListTables(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*ListTablesResponse, error) // / Creates a table with provided name & attributes. - CreateTable(ctx context.Context, in *CreateTableRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) + CreateTable(ctx context.Context, in *CreateTableRequest, opts ...grpc.CallOption) (*empty.Empty, error) // Deletes a table using table name provided. - DeleteTable(ctx context.Context, in *DeleteTableRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) + DeleteTable(ctx context.Context, in *DeleteTableRequest, opts ...grpc.CallOption) (*empty.Empty, error) // Describes a table information for the provided table. DescribeTable(ctx context.Context, in *DescribeTableRequest, opts ...grpc.CallOption) (*DescribeTableResponse, error) // Update a table with newly provided table information. - UpdateTable(ctx context.Context, in *UpdateTableRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) + UpdateTable(ctx context.Context, in *UpdateTableRequest, opts ...grpc.CallOption) (*empty.Empty, error) } type grpcStoreClient struct { @@ -2032,8 +2032,8 @@ func NewGrpcStoreClient(cc *grpc.ClientConn) GrpcStoreClient { return &grpcStoreClient{cc} } -func (c *grpcStoreClient) WriteIndex(ctx context.Context, in *WriteIndexRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { - out := new(emptypb.Empty) +func (c *grpcStoreClient) WriteIndex(ctx context.Context, in *WriteIndexRequest, opts ...grpc.CallOption) (*empty.Empty, error) { + out := new(empty.Empty) err := c.cc.Invoke(ctx, "/grpc.grpc_store/WriteIndex", in, out, opts...) if err != nil { return nil, err @@ -2073,8 +2073,8 @@ func (x *grpcStoreQueryIndexClient) Recv() (*QueryIndexResponse, error) { return m, nil } -func (c *grpcStoreClient) DeleteIndex(ctx context.Context, in *DeleteIndexRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { - out := new(emptypb.Empty) +func (c *grpcStoreClient) DeleteIndex(ctx context.Context, in *DeleteIndexRequest, opts ...grpc.CallOption) (*empty.Empty, error) { + out := new(empty.Empty) err := c.cc.Invoke(ctx, "/grpc.grpc_store/DeleteIndex", in, out, opts...) if err != nil { return nil, err @@ -2082,8 +2082,8 @@ func (c *grpcStoreClient) DeleteIndex(ctx context.Context, in *DeleteIndexReques return out, nil } -func (c *grpcStoreClient) PutChunks(ctx context.Context, in *PutChunksRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { - out := new(emptypb.Empty) +func (c *grpcStoreClient) PutChunks(ctx context.Context, in *PutChunksRequest, opts ...grpc.CallOption) (*empty.Empty, error) { + out := new(empty.Empty) err := c.cc.Invoke(ctx, "/grpc.grpc_store/PutChunks", in, out, opts...) if err != nil { return nil, err @@ -2123,8 +2123,8 @@ func (x *grpcStoreGetChunksClient) Recv() (*GetChunksResponse, error) { return m, nil } -func (c *grpcStoreClient) DeleteChunks(ctx context.Context, in *ChunkID, opts ...grpc.CallOption) (*emptypb.Empty, error) { - out := new(emptypb.Empty) +func (c *grpcStoreClient) DeleteChunks(ctx context.Context, in *ChunkID, opts ...grpc.CallOption) (*empty.Empty, error) { + out := new(empty.Empty) err := c.cc.Invoke(ctx, "/grpc.grpc_store/DeleteChunks", in, out, opts...) if err != nil { return nil, err @@ -2132,7 +2132,7 @@ func (c *grpcStoreClient) DeleteChunks(ctx context.Context, in *ChunkID, opts .. return out, nil } -func (c *grpcStoreClient) ListTables(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*ListTablesResponse, error) { +func (c *grpcStoreClient) ListTables(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*ListTablesResponse, error) { out := new(ListTablesResponse) err := c.cc.Invoke(ctx, "/grpc.grpc_store/ListTables", in, out, opts...) if err != nil { @@ -2141,8 +2141,8 @@ func (c *grpcStoreClient) ListTables(ctx context.Context, in *emptypb.Empty, opt return out, nil } -func (c *grpcStoreClient) CreateTable(ctx context.Context, in *CreateTableRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { - out := new(emptypb.Empty) +func (c *grpcStoreClient) CreateTable(ctx context.Context, in *CreateTableRequest, opts ...grpc.CallOption) (*empty.Empty, error) { + out := new(empty.Empty) err := c.cc.Invoke(ctx, "/grpc.grpc_store/CreateTable", in, out, opts...) if err != nil { return nil, err @@ -2150,8 +2150,8 @@ func (c *grpcStoreClient) CreateTable(ctx context.Context, in *CreateTableReques return out, nil } -func (c *grpcStoreClient) DeleteTable(ctx context.Context, in *DeleteTableRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { - out := new(emptypb.Empty) +func (c *grpcStoreClient) DeleteTable(ctx context.Context, in *DeleteTableRequest, opts ...grpc.CallOption) (*empty.Empty, error) { + out := new(empty.Empty) err := c.cc.Invoke(ctx, "/grpc.grpc_store/DeleteTable", in, out, opts...) if err != nil { return nil, err @@ -2168,8 +2168,8 @@ func (c *grpcStoreClient) DescribeTable(ctx context.Context, in *DescribeTableRe return out, nil } -func (c *grpcStoreClient) UpdateTable(ctx context.Context, in *UpdateTableRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { - out := new(emptypb.Empty) +func (c *grpcStoreClient) UpdateTable(ctx context.Context, in *UpdateTableRequest, opts ...grpc.CallOption) (*empty.Empty, error) { + out := new(empty.Empty) err := c.cc.Invoke(ctx, "/grpc.grpc_store/UpdateTable", in, out, opts...) if err != nil { return nil, err @@ -2180,67 +2180,67 @@ func (c *grpcStoreClient) UpdateTable(ctx context.Context, in *UpdateTableReques // GrpcStoreServer is the server API for GrpcStore service. type GrpcStoreServer interface { // / WriteIndex writes batch of indexes to the index tables. - WriteIndex(context.Context, *WriteIndexRequest) (*emptypb.Empty, error) + WriteIndex(context.Context, *WriteIndexRequest) (*empty.Empty, error) // / QueryIndex reads the indexes required for given query & sends back the batch of rows // / in rpc streams QueryIndex(*QueryIndexRequest, GrpcStore_QueryIndexServer) error // / DeleteIndex deletes the batch of index entries from the index tables - DeleteIndex(context.Context, *DeleteIndexRequest) (*emptypb.Empty, error) + DeleteIndex(context.Context, *DeleteIndexRequest) (*empty.Empty, error) // / PutChunks saves the batch of chunks into the chunk tables. - PutChunks(context.Context, *PutChunksRequest) (*emptypb.Empty, error) + PutChunks(context.Context, *PutChunksRequest) (*empty.Empty, error) // / GetChunks requests for batch of chunks and the batch of chunks are sent back in rpc streams // / batching needs to be performed at server level as per requirement instead of sending single chunk per stream. // / In GetChunks rpc request send buf as nil GetChunks(*GetChunksRequest, GrpcStore_GetChunksServer) error // / DeleteChunks deletes the chunks based on chunkID. - DeleteChunks(context.Context, *ChunkID) (*emptypb.Empty, error) + DeleteChunks(context.Context, *ChunkID) (*empty.Empty, error) // / Lists all the tables that exists in the database. - ListTables(context.Context, *emptypb.Empty) (*ListTablesResponse, error) + ListTables(context.Context, *empty.Empty) (*ListTablesResponse, error) // / Creates a table with provided name & attributes. - CreateTable(context.Context, *CreateTableRequest) (*emptypb.Empty, error) + CreateTable(context.Context, *CreateTableRequest) (*empty.Empty, error) // Deletes a table using table name provided. - DeleteTable(context.Context, *DeleteTableRequest) (*emptypb.Empty, error) + DeleteTable(context.Context, *DeleteTableRequest) (*empty.Empty, error) // Describes a table information for the provided table. DescribeTable(context.Context, *DescribeTableRequest) (*DescribeTableResponse, error) // Update a table with newly provided table information. - UpdateTable(context.Context, *UpdateTableRequest) (*emptypb.Empty, error) + UpdateTable(context.Context, *UpdateTableRequest) (*empty.Empty, error) } // UnimplementedGrpcStoreServer can be embedded to have forward compatible implementations. type UnimplementedGrpcStoreServer struct { } -func (*UnimplementedGrpcStoreServer) WriteIndex(ctx context.Context, req *WriteIndexRequest) (*emptypb.Empty, error) { +func (*UnimplementedGrpcStoreServer) WriteIndex(ctx context.Context, req *WriteIndexRequest) (*empty.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method WriteIndex not implemented") } func (*UnimplementedGrpcStoreServer) QueryIndex(req *QueryIndexRequest, srv GrpcStore_QueryIndexServer) error { return status.Errorf(codes.Unimplemented, "method QueryIndex not implemented") } -func (*UnimplementedGrpcStoreServer) DeleteIndex(ctx context.Context, req *DeleteIndexRequest) (*emptypb.Empty, error) { +func (*UnimplementedGrpcStoreServer) DeleteIndex(ctx context.Context, req *DeleteIndexRequest) (*empty.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method DeleteIndex not implemented") } -func (*UnimplementedGrpcStoreServer) PutChunks(ctx context.Context, req *PutChunksRequest) (*emptypb.Empty, error) { +func (*UnimplementedGrpcStoreServer) PutChunks(ctx context.Context, req *PutChunksRequest) (*empty.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method PutChunks not implemented") } func (*UnimplementedGrpcStoreServer) GetChunks(req *GetChunksRequest, srv GrpcStore_GetChunksServer) error { return status.Errorf(codes.Unimplemented, "method GetChunks not implemented") } -func (*UnimplementedGrpcStoreServer) DeleteChunks(ctx context.Context, req *ChunkID) (*emptypb.Empty, error) { +func (*UnimplementedGrpcStoreServer) DeleteChunks(ctx context.Context, req *ChunkID) (*empty.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method DeleteChunks not implemented") } -func (*UnimplementedGrpcStoreServer) ListTables(ctx context.Context, req *emptypb.Empty) (*ListTablesResponse, error) { +func (*UnimplementedGrpcStoreServer) ListTables(ctx context.Context, req *empty.Empty) (*ListTablesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ListTables not implemented") } -func (*UnimplementedGrpcStoreServer) CreateTable(ctx context.Context, req *CreateTableRequest) (*emptypb.Empty, error) { +func (*UnimplementedGrpcStoreServer) CreateTable(ctx context.Context, req *CreateTableRequest) (*empty.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateTable not implemented") } -func (*UnimplementedGrpcStoreServer) DeleteTable(ctx context.Context, req *DeleteTableRequest) (*emptypb.Empty, error) { +func (*UnimplementedGrpcStoreServer) DeleteTable(ctx context.Context, req *DeleteTableRequest) (*empty.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method DeleteTable not implemented") } func (*UnimplementedGrpcStoreServer) DescribeTable(ctx context.Context, req *DescribeTableRequest) (*DescribeTableResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method DescribeTable not implemented") } -func (*UnimplementedGrpcStoreServer) UpdateTable(ctx context.Context, req *UpdateTableRequest) (*emptypb.Empty, error) { +func (*UnimplementedGrpcStoreServer) UpdateTable(ctx context.Context, req *UpdateTableRequest) (*empty.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateTable not implemented") } @@ -2363,7 +2363,7 @@ func _GrpcStore_DeleteChunks_Handler(srv interface{}, ctx context.Context, dec f } func _GrpcStore_ListTables_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(emptypb.Empty) + in := new(empty.Empty) if err := dec(in); err != nil { return nil, err } @@ -2375,7 +2375,7 @@ func _GrpcStore_ListTables_Handler(srv interface{}, ctx context.Context, dec fun FullMethod: "/grpc.grpc_store/ListTables", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GrpcStoreServer).ListTables(ctx, req.(*emptypb.Empty)) + return srv.(GrpcStoreServer).ListTables(ctx, req.(*empty.Empty)) } return interceptor(ctx, in, info, handler) } From f4d58ab40ca4c8449ea69cfaacc45713afae5b85 Mon Sep 17 00:00:00 2001 From: Jay Clifford <45856600+Jayclifford345@users.noreply.github.com> Date: Thu, 3 Oct 2024 19:56:36 +0100 Subject: [PATCH 07/26] docs: OpenTelemetry Collector Sandbox Tutorial (#13745) Co-authored-by: J Stickler --- .../otel/otel-collector-getting-started.md | 366 ++++++++++++++++++ 1 file changed, 366 insertions(+) create mode 100644 docs/sources/send-data/otel/otel-collector-getting-started.md diff --git a/docs/sources/send-data/otel/otel-collector-getting-started.md b/docs/sources/send-data/otel/otel-collector-getting-started.md new file mode 100644 index 0000000000000..08b374656d969 --- /dev/null +++ b/docs/sources/send-data/otel/otel-collector-getting-started.md @@ -0,0 +1,366 @@ +--- +title: Getting started with the OpenTelemetry Collector and Loki tutorial +menuTitle: OTel Collector tutorial +description: A Tutorial configuring the OpenTelemetry Collector to send OpenTelemetry logs to Loki +weight: 300 +killercoda: + title: Getting started with the OpenTelemetry Collector and Loki tutorial + description: A Tutorial configuring the OpenTelemetry Collector to send OpenTelemetry logs to Loki + preprocessing: + substitutions: + - regexp: loki-fundamentals-otel-collector-1 + replacement: loki-fundamentals_otel-collector_1 + backend: + imageid: ubuntu +--- + + + +# Getting started with the OpenTelemetry Collector and Loki tutorial + +The OpenTelemetry Collector offers a vendor-agnostic implementation of how to receive, process, and export telemetry data. With the introduction of the OTLP endpoint in Loki, you can now send logs from applications instrumented with OpenTelemetry to Loki using the OpenTelemetry Collector in native OTLP format. +In this example, we will teach you how to configure the OpenTelemetry Collector to receive logs in the OpenTelemetry format and send them to Loki using the OTLP HTTP protocol. This will involve configuring the following components in the OpenTelemetry Collector: +- **OpenTelemetry Receiver:** This component will receive logs in the OpenTelemetry format via HTTP and gRPC. +- **OpenTelemetry Processor:** This component will accept telemetry data from other `otelcol.*` components and place them into batches. Batching improves the compression of data and reduces the number of outgoing network requests required to transmit data. +- **OpenTelemetry Exporter:** This component will accept telemetry data from other `otelcol.*` components and write them over the network using the OTLP HTTP protocol. We will use this exporter to send the logs to the Loki native OTLP endpoint. + + + +## Dependencies + +Before you begin, ensure you have the following to run the demo: + +- Docker +- Docker Compose + +{{< admonition type="tip" >}} +Alternatively, you can try out this example in our interactive learning environment: [Getting started with the OpenTelemetry Collector and Loki tutorial](https://killercoda.com/grafana-labs/course/loki/otel-collector-getting-started). + +It's a fully configured environment with all the dependencies already installed. + +![Interactive](/media/docs/loki/loki-ile.svg) + +Provide feedback, report bugs, and raise issues for the tutorial in the [Grafana Killercoda repository](https://github.com/grafana/killercoda). +{{< /admonition >}} + + + +## Scenario + +In this scenario, we have a microservices application called the Carnivorous Greenhouse. This application consists of the following services: + +- **User Service:** Manages user data and authentication for the application. Such as creating users and logging in. +- **Plant Service:** Manages the creation of new plants and updates other services when a new plant is created. +- **Simulation Service:** Generates sensor data for each plant. +- **Websocket Service:** Manages the websocket connections for the application. +- **Bug Service:** A service that when enabled, randomly causes services to fail and generate additional logs. +- **Main App:** The main application that ties all the services together. +- **Database:** A database that stores user and plant data. + +Each service generates logs using the OpenTelemetry SDK and exports to the OpenTelemetry Collector in the OpenTelemetry format (OTLP). The Collector then ingests the logs and sends them to Loki. + + + + + +## Step 1: Environment setup + +In this step, we will set up our environment by cloning the repository that contains our demo application and spinning up our observability stack using Docker Compose. + +1. To get started, clone the repository that contains our demo application: + + ```bash + git clone -b microservice-otel-collector https://github.com/grafana/loki-fundamentals.git + ``` + +1. Next we will spin up our observability stack using Docker Compose: + + + ```bash + docker compose -f loki-fundamentals/docker-compose.yml up -d + ``` + + + {{< docs/ignore >}} + + + ```bash + docker-compose -f loki-fundamentals/docker-compose.yml up -d + ``` + + + {{< /docs/ignore >}} + + To check the status of services we can run the following command: + ```bash + docker ps -a + ``` + + {{< admonition type="note" >}} + The OpenTelemetry Collector container will show as `Stopped` or `Exited (1) About a minute ago`. This is expected as we have provided an empty configuration file. We will update this file in the next step. + {{< /admonition >}} + + + +After we've finished configuring the OpenTelemetry Collector and sending logs to Loki, we will be able to view the logs in Grafana. To check if Grafana is up and running, navigate to the following URL: [http://localhost:3000](http://localhost:3000) + + + + +## Step 2: Configuring the OpenTelemetry Collector + +To configure the Collector to ingest OpenTelemetry logs from our application, we need to provide a configuration file. This configuration file will define the components and their relationships. We will build the entire observability pipeline within this configuration file. + +### Open your code editor and locate the `otel-config.yaml` file + +The configuration file is written using **YAML** configuration syntax. To start, we will open the `otel-config.yaml` file in the code editor: + +{{< docs/ignore >}} +**Note: Killercoda has an inbuilt Code editor which can be accessed via the `Editor` tab.** +1. Expand the `loki-fundamentals` directory in the file explorer of the `Editor` tab. +2. Locate the `otel-config.yaml` file in the top level directory, `loki-fundamentals`. +3. Click on the `otel-config.yaml` file to open it in the code editor. +{{< /docs/ignore >}} + + +1. Open the `loki-fundamentals` directory in a code editor of your choice. +1. Locate the `otel-config.yaml` file in the `loki-fundamentals` directory (Top level directory). +1. Click on the `otel-config.yaml` file to open it in the code editor. + + +You will copy all three of the following configuration snippets into the `otel-config.yaml` file. + +### Receive OpenTelemetry logs via gRPC and HTTP + +First, we will configure the OpenTelemetry receiver. `otlp:` accepts logs in the OpenTelemetry format via HTTP and gRPC. We will use this receiver to receive logs from the Carnivorous Greenhouse application. + +Now add the following configuration to the `otel-config.yaml` file: +```yaml +# Receivers +receivers: + otlp: + protocols: + grpc: + endpoint: 0.0.0.0:4317 + http: + endpoint: 0.0.0.0:4318 +``` + +In this configuration: +- `receivers`: The list of receivers to receive telemetry data. In this case, we are using the `otlp` receiver. +- `otlp`: The OpenTelemetry receiver that accepts logs in the OpenTelemetry format. +- `protocols`: The list of protocols that the receiver supports. In this case, we are using `grpc` and `http`. +- `grpc`: The gRPC protocol configuration. The receiver will accept logs via gRPC on `4317`. +- `http`: The HTTP protocol configuration. The receiver will accept logs via HTTP on `4318`. +- `endpoint`: The IP address and port number to listen on. In this case, we are listening on all IP addresses on port `4317` for gRPC and port `4318` for HTTP. + +For more information on the `otlp` receiver configuration, see the [OpenTelemetry Receiver OTLP documentation](https://github.com/open-telemetry/opentelemetry-collector/blob/main/receiver/otlpreceiver/README.md). + + +### Create batches of logs using a OpenTelemetry Processor + +Next add the following configuration to the `otel-config.yaml` file: +```yaml +# Processors +processors: + batch: +``` + +In this configuration: +- `processors`: The list of processors to process telemetry data. In this case, we are using the `batch` processor. +- `batch`: The OpenTelemetry processor that accepts telemetry data from other `otelcol` components and places them into batches. + +For more information on the `batch` processor configuration, see the [OpenTelemetry Processor Batch documentation](https://github.com/open-telemetry/opentelemetry-collector/blob/main/processor/batchprocessor/README.md). + +### Export logs to Loki using a OpenTelemetry Exporter + +We will use the `otlphttp/logs` exporter to send the logs to the Loki native OTLP endpoint. Add the following configuration to the `otel-config.yaml` file: +```yaml +# Exporters +exporters: + otlphttp/logs: + endpoint: "http://loki:3100/otlp" + tls: + insecure: true +``` +In this configuration: +- `exporters`: The list of exporters to export telemetry data. In this case, we are using the `otlphttp/logs` exporter. +- `otlphttp/logs`: The OpenTelemetry exporter that accepts telemetry data from other `otelcol` components and writes them over the network using the OTLP HTTP protocol. +- `endpoint`: The URL to send the telemetry data to. In this case, we are sending the logs to the Loki native OTLP endpoint at `http://loki:3100/otlp`. +- `tls`: The TLS configuration for the exporter. In this case, we are setting `insecure` to `true` to disable TLS verification. +- `insecure`: Disables TLS verification. This is set to `true` as we are using an insecure connection. + +For more information on the `otlphttp/logs` exporter configuration, see the [OpenTelemetry Exporter OTLP HTTP documentation](https://github.com/open-telemetry/opentelemetry-collector/blob/main/exporter/otlphttpexporter/README.md) + +### Creating the Pipeline + +Now that we have configured the receiver, processor, and exporter, we need to create a pipeline to connect these components. Add the following configuration to the `otel-config.yaml` file: +```yaml +# Pipelines +service: + pipelines: + logs: + receivers: [otlp] + processors: [batch] + exporters: [otlphttp/logs] +``` + +In this configuration: +- `pipelines`: The list of pipelines to connect the receiver, processor, and exporter. In this case, we are using the `logs` pipeline but there is also pipelines for metrics, traces, and continuous profiling. +- `receivers`: The list of receivers to receive telemetry data. In this case, we are using the `otlp` receiver component we created earlier. +- `processors`: The list of processors to process telemetry data. In this case, we are using the `batch` processor component we created earlier. +- `exporters`: The list of exporters to export telemetry data. In this case, we are using the `otlphttp/logs` component exporter we created earlier. + + +### Load the Configuration + +Before you load the configuration into the OpenTelemetry Collector, compare your configuration with the completed configuration below: + +```yaml +# Receivers +receivers: + otlp: + protocols: + grpc: + endpoint: 0.0.0.0:4317 + http: + endpoint: 0.0.0.0:4318 + +# Processors +processors: + batch: + +# Exporters +exporters: + otlphttp/logs: + endpoint: "http://loki:3100/otlp" + tls: + insecure: true + +# Pipelines +service: + pipelines: + logs: + receivers: [otlp] + processors: [batch] + exporters: [otlphttp/logs] +``` +Next, we need apply the configuration to the OpenTelemetry Collector. To do this, we will restart the OpenTelemetry Collector container: + +```bash +docker restart loki-fundamentals-otel-collector-1 +``` + + +This will restart the OpenTelemetry Collector container with the new configuration. You can check the logs of the OpenTelemetry Collector container to see if the configuration was loaded successfully: + +```bash +docker logs loki-fundamentals-otel-collector-1 +``` + +Within the logs, you should see the following message: +```console +2024-08-02T13:10:25.136Z info service@v0.106.1/service.go:225 Everything is ready. Begin running and processing data. +``` + +## Stuck? Need help? + +If you get stuck or need help creating the configuration, you can copy and replace the entire `otel-config.yaml` using the completed configuration file: + + +```bash +cp loki-fundamentals/completed/otel-config.yaml loki-fundamentals/otel-config.yaml +docker restart loki-fundamentals-otel-collector-1 +``` + + + + + + +## Step 3: Start the Carnivorous Greenhouse + +In this step, we will start the Carnivorous Greenhouse application. To start the application, run the following command: + +{{< admonition type="note" >}} +This docker-compose file relies on the `loki-fundamentals_loki` docker network. If you have not started the observability stack, you will need to start it first. +{{< /admonition >}} + + +{{< docs/ignore >}} + +**Note: This docker-compose file relies on the `loki-fundamentals_loki` docker network. If you have not started the observability stack, you will need to start it first.** + +{{< /docs/ignore >}} + + +```bash +docker compose -f loki-fundamentals/greenhouse/docker-compose-micro.yml up -d --build +``` + + + +{{< docs/ignore >}} + + +```bash +docker-compose -f loki-fundamentals/greenhouse/docker-compose-micro.yml up -d --build +``` + + +{{< /docs/ignore >}} + +This will start the following services: +```console + ✔ Container greenhouse-db-1 Started + ✔ Container greenhouse-websocket_service-1 Started + ✔ Container greenhouse-bug_service-1 Started + ✔ Container greenhouse-user_service-1 Started + ✔ Container greenhouse-plant_service-1 Started + ✔ Container greenhouse-simulation_service-1 Started + ✔ Container greenhouse-main_app-1 Started +``` + +Once started, you can access the Carnivorous Greenhouse application at [http://localhost:5005](http://localhost:5005). Generate some logs by interacting with the application in the following ways: + +1. Create a user. +1. Log in. +1. Create a few plants to monitor. +1. Enable bug mode to activate the bug service. This will cause services to fail and generate additional logs. + +Finally to view the logs in Loki, navigate to the Loki Logs Explore view in Grafana at [http://localhost:3000/a/grafana-lokiexplore-app/explore](http://localhost:3000/a/grafana-lokiexplore-app/explore). + + + + + + +## Summary + +In this example, we configured the OpenTelemetry Collector to receive logs from an example application and send them to Loki using the native OTLP endpoint. Make sure to also consult the Loki configuration file `loki-config.yaml` to understand how we have configured Loki to receive logs from the OpenTelemetry Collector. + +{{< docs/ignore >}} + +### Back to Docs +Head back to where you started from to continue with the [Loki documentation](https://grafana.com/docs/loki/latest/send-data/otel). + +{{< /docs/ignore >}} + + +## Further reading + +For more information on the OpenTelemetry Collector and the native OTLP endpoint of Loki, refer to the following resources: + +- [Loki OTLP endpoint](https://grafana.com/docs/loki//send-data/otel/) +- [How is native OTLP endpoint different from Loki Exporter](https://grafana.com/docs/loki//send-data/otel/native_otlp_vs_loki_exporter) +- [OpenTelemetry Collector Configuration](https://opentelemetry.io/docs/collector/configuration/) + + +## Complete metrics, logs, traces, and profiling example + +If you would like to use a demo that includes Mimir, Loki, Tempo, and Grafana, you can use [Introduction to Metrics, Logs, Traces, and Profiling in Grafana](https://github.com/grafana/intro-to-mlt). `Intro-to-mltp` provides a self-contained environment for learning about Mimir, Loki, Tempo, and Grafana. + +The project includes detailed explanations of each component and annotated configurations for a single-instance deployment. Data from `intro-to-mltp` can also be pushed to Grafana Cloud. + + + From 0992d2adb5834a4f5e1f7eb252093f2f434e47f2 Mon Sep 17 00:00:00 2001 From: Joao Marcal Date: Fri, 4 Oct 2024 10:38:46 +0200 Subject: [PATCH 08/26] chore(operator): fix CI to use new Github app instead of PAT (#14328) --- .../operator-check-prepare-release-commit.yml | 10 +++++++++- .../operator-publish-operator-hub.yml | 4 ---- .github/workflows/operator-release-please.yml | 20 ++++++++++++++++--- .../operator-reusable-hub-release.yml | 19 +++++++++++------- 4 files changed, 38 insertions(+), 15 deletions(-) diff --git a/.github/workflows/operator-check-prepare-release-commit.yml b/.github/workflows/operator-check-prepare-release-commit.yml index 2099230718634..c8e900829580a 100644 --- a/.github/workflows/operator-check-prepare-release-commit.yml +++ b/.github/workflows/operator-check-prepare-release-commit.yml @@ -14,6 +14,14 @@ jobs: github.event.pull_request.head.ref == 'release-please--branches--main--components--operator' && contains(github.event.pull_request.title, 'chore( operator): community release') steps: + - id: "get_github_app_token" + name: Get GitHub Token + uses: "actions/create-github-app-token@v1" + with: + app-id: "${{ secrets.APP_ID }}" + owner: "${{ github.repository_owner }}" + private-key: "${{ secrets.APP_PRIVATE_KEY }}" + - name: Extract release version id: pr_semver env: @@ -31,7 +39,7 @@ jobs: - name: Check main commits for prepare release commit id: check_commit env: - GH_TOKEN: ${{ secrets.GH_TOKEN }} + GH_TOKEN: ${{ steps.get_github_app_token.outputs.token }} working-directory: "release" run: | COMMIT=$(gh search commits "chore(operator): prepare community release v${{ steps.pr_semver.outputs.semver }}") diff --git a/.github/workflows/operator-publish-operator-hub.yml b/.github/workflows/operator-publish-operator-hub.yml index c3fa69b466298..dd4d4c199af3e 100644 --- a/.github/workflows/operator-publish-operator-hub.yml +++ b/.github/workflows/operator-publish-operator-hub.yml @@ -10,8 +10,6 @@ jobs: with: org: redhat-openshift-ecosystem repo: community-operators-prod - secrets: - GRAFANABOT_GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} operator-hub-community-release: if: startsWith(github.event.release.tag_name, 'operator/') @@ -19,5 +17,3 @@ jobs: with: org: k8s-operatorhub repo: community-operators - secrets: - GRAFANABOT_GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} diff --git a/.github/workflows/operator-release-please.yml b/.github/workflows/operator-release-please.yml index 77be2bc58a237..266dfd26e3083 100644 --- a/.github/workflows/operator-release-please.yml +++ b/.github/workflows/operator-release-please.yml @@ -18,25 +18,39 @@ jobs: release_created: ${{ steps.release.outputs.operator--release_created }} release_name: ${{ steps.release.outputs.operator--tag_name }} steps: - - uses: google-github-actions/release-please-action@v4 + - id: "get_github_app_token" + name: Get GitHub App Token + uses: "actions/create-github-app-token@v1" + with: + app-id: "${{ secrets.APP_ID }}" + owner: "${{ github.repository_owner }}" + private-key: "${{ secrets.APP_PRIVATE_KEY }}" + - uses: googleapis/release-please-action@v4 id: release with: path: operator config-file: operator/release-please-config.json - token: ${{ secrets.GH_TOKEN }} + token: ${{ steps.get_github_app_token.outputs.token }} publishRelease: needs: - "releasePlease" runs-on: ubuntu-latest if: ${{ needs.releasePlease.outputs.release_created }} steps: + - id: "get_github_app_token" + name: Get GitHub App Token + uses: "actions/create-github-app-token@v1" + with: + app-id: "${{ secrets.APP_ID }}" + owner: "${{ github.repository_owner }}" + private-key: "${{ secrets.APP_PRIVATE_KEY }}" - name: "pull code to release" uses: "actions/checkout@v4" with: path: "release" - name: "publish release" env: - GH_TOKEN: ${{ secrets.GH_TOKEN }} + GH_TOKEN: ${{ steps.get_github_app_token.outputs.token }} working-directory: "release" run: | gh release edit "${{ needs.releasePlease.outputs.release_name }}" --draft=false --latest=false \ No newline at end of file diff --git a/.github/workflows/operator-reusable-hub-release.yml b/.github/workflows/operator-reusable-hub-release.yml index 862d072401dd3..ecf2794134172 100644 --- a/.github/workflows/operator-reusable-hub-release.yml +++ b/.github/workflows/operator-reusable-hub-release.yml @@ -9,14 +9,19 @@ on: repo: type: string required: true - secrets: - GRAFANABOT_GITHUB_TOKEN: - required: true jobs: create-operator-pull-request: runs-on: ubuntu-latest steps: + - id: "get_github_app_token" + name: Get GitHub App Token + uses: "actions/create-github-app-token@v1" + with: + app-id: "${{ secrets.APP_ID }}" + owner: "${{ github.repository_owner }}" + private-key: "${{ secrets.APP_PRIVATE_KEY }}" + - name: Set redhat-openshift-ecosystem specific variables if: ${{ inputs.org == 'redhat-openshift-ecosystem' }} env: @@ -36,7 +41,7 @@ jobs: - name: Sync fork env: - GH_TOKEN: ${{ secrets.GRAFANABOT_GITHUB_TOKEN }} + GH_TOKEN: ${{ steps.get_github_app_token.outputs.token }} run: | # synchronizing the fork is fast, and avoids the need to fetch the full upstream repo # (fetching the upstream repo with "--depth 1" would lead to "shallow update not allowed" @@ -49,13 +54,13 @@ jobs: uses: actions/checkout@v4 with: repository: grafanabot/${{ inputs.repo }} - token: ${{ secrets.GRAFANABOT_GITHUB_TOKEN }} + token: ${{ steps.get_github_app_token.outputs.token }} - name: Checkout loki to tmp/ directory uses: actions/checkout@v4 with: repository: grafana/loki - token: ${{ secrets.GRAFANABOT_GITHUB_TOKEN }} + token: ${{ steps.get_github_app_token.outputs.token }} path: tmp/ - name: Update version @@ -85,7 +90,7 @@ jobs: - name: Create pull request against ${{ inputs.org }}/${{ inputs.repo }} env: VERSION: ${{ env.version }} - GH_TOKEN: ${{ secrets.GRAFANABOT_GITHUB_TOKEN }} + GH_TOKEN: ${{ steps.get_github_app_token.outputs.token }} run: | message="Update the loki-operator to $VERSION" body="Release loki-operator \`$VERSION\`. From 6de64209547ec970cb27564be87fe2085307e183 Mon Sep 17 00:00:00 2001 From: Vladyslav Diachenko <82767850+vlad-diachenko@users.noreply.github.com> Date: Fri, 4 Oct 2024 11:45:55 +0300 Subject: [PATCH 09/26] fix(ci): fixed `Publish Rendered Helm Chart Diff` workflow (#14365) Signed-off-by: Vladyslav Diachenko --- .github/workflows/helm-loki-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/helm-loki-ci.yml b/.github/workflows/helm-loki-ci.yml index 7a28505791184..5902d9f0f9115 100644 --- a/.github/workflows/helm-loki-ci.yml +++ b/.github/workflows/helm-loki-ci.yml @@ -1,14 +1,14 @@ --- name: helm-loki-ci on: - pull_request: + # It runs with the configuration from base branch, so the changes of this file from the PR won't be taken into account until they are merged into main. see: https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request_target . + # This change is required to allow this CI to be run on Pull Requests opened from a fork repository + pull_request_target: paths: - "production/helm/loki/**" jobs: publish-diff: - # temporarily disable the workflow for the PRs where PRs branch is from fork. - if: github.event.pull_request.head.repo.full_name == github.repository name: Publish Rendered Helm Chart Diff runs-on: ubuntu-latest steps: From 39b57ec4eac3cbdc718aacae32ab8ff4e989709b Mon Sep 17 00:00:00 2001 From: benclive Date: Fri, 4 Oct 2024 09:59:40 +0100 Subject: [PATCH 10/26] feat(kafka): Replay kafka from last commit before allowing ingesters to become ready (#14330) --- docs/sources/shared/configuration.md | 14 ++ pkg/ingester/ingester.go | 2 +- pkg/ingester/kafka_consumer.go | 2 +- pkg/kafka/config.go | 21 +- pkg/kafka/partition/reader.go | 300 ++++++++++++++++++++++++++- pkg/kafka/partition/reader_test.go | 63 +++++- pkg/kafka/testkafka/cluster.go | 2 +- 7 files changed, 386 insertions(+), 18 deletions(-) diff --git a/docs/sources/shared/configuration.md b/docs/sources/shared/configuration.md index 64cfdf6d835a7..9ee288b493706 100644 --- a/docs/sources/shared/configuration.md +++ b/docs/sources/shared/configuration.md @@ -839,6 +839,20 @@ kafka_config: # CLI flag: -kafka.producer-max-buffered-bytes [producer_max_buffered_bytes: | default = 1073741824] + # The best-effort maximum lag a consumer tries to achieve at startup. Set both + # -kafka.target-consumer-lag-at-startup and -kafka.max-consumer-lag-at-startup + # to 0 to disable waiting for maximum consumer lag being honored at startup. + # CLI flag: -kafka.target-consumer-lag-at-startup + [target_consumer_lag_at_startup: | default = 2s] + + # The guaranteed maximum lag before a consumer is considered to have caught up + # reading from a partition at startup, becomes ACTIVE in the hash ring and + # passes the readiness check. Set both -kafka.target-consumer-lag-at-startup + # and -kafka.max-consumer-lag-at-startup to 0 to disable waiting for maximum + # consumer lag being honored at startup. + # CLI flag: -kafka.max-consumer-lag-at-startup + [max_consumer_lag_at_startup: | default = 15s] + # Configuration for 'runtime config' module, responsible for reloading runtime # configuration file. [runtime_config: ] diff --git a/pkg/ingester/ingester.go b/pkg/ingester/ingester.go index 1f3a39415fa3f..3e24d627c60ec 100644 --- a/pkg/ingester/ingester.go +++ b/pkg/ingester/ingester.go @@ -300,7 +300,7 @@ type Ingester struct { } // New makes a new Ingester. -func New(cfg Config, clientConfig client.Config, store Store, limits Limits, configs *runtime.TenantConfigs, registerer prometheus.Registerer, writeFailuresCfg writefailures.Cfg, metricsNamespace string, logger log.Logger, customStreamsTracker push.UsageTracker, readRing ring.ReadRing, partitionRingWatcher *ring.PartitionRingWatcher) (*Ingester, error) { +func New(cfg Config, clientConfig client.Config, store Store, limits Limits, configs *runtime.TenantConfigs, registerer prometheus.Registerer, writeFailuresCfg writefailures.Cfg, metricsNamespace string, logger log.Logger, customStreamsTracker push.UsageTracker, readRing ring.ReadRing, partitionRingWatcher ring.PartitionRingReader) (*Ingester, error) { if cfg.ingesterClientFactory == nil { cfg.ingesterClientFactory = client.New } diff --git a/pkg/ingester/kafka_consumer.go b/pkg/ingester/kafka_consumer.go index c2fe90ee052f6..0e6185fbe7968 100644 --- a/pkg/ingester/kafka_consumer.go +++ b/pkg/ingester/kafka_consumer.go @@ -3,7 +3,7 @@ package ingester import ( "context" "errors" - math "math" + "math" "sync" "time" diff --git a/pkg/kafka/config.go b/pkg/kafka/config.go index 7f981b7b5e739..13cfb618cfdb9 100644 --- a/pkg/kafka/config.go +++ b/pkg/kafka/config.go @@ -36,18 +36,14 @@ const ( // in the worst case scenario, which is expected to be way above the actual one. maxProducerRecordDataBytesLimit = producerBatchMaxBytes - 16384 minProducerRecordDataBytesLimit = 1024 * 1024 - - kafkaConfigFlagPrefix = "ingest-storage.kafka" - targetConsumerLagAtStartupFlag = kafkaConfigFlagPrefix + ".target-consumer-lag-at-startup" - maxConsumerLagAtStartupFlag = kafkaConfigFlagPrefix + ".max-consumer-lag-at-startup" ) var ( ErrMissingKafkaAddress = errors.New("the Kafka address has not been configured") ErrMissingKafkaTopic = errors.New("the Kafka topic has not been configured") + ErrInconsistentConsumerLagAtStartup = errors.New("the target and max consumer lag at startup must be either both set to 0 or to a value greater than 0") + ErrInvalidMaxConsumerLagAtStartup = errors.New("the configured max consumer lag at startup must greater or equal than the configured target consumer lag") ErrInvalidProducerMaxRecordSizeBytes = fmt.Errorf("the configured producer max record size bytes must be a value between %d and %d", minProducerRecordDataBytesLimit, maxProducerRecordDataBytesLimit) - - consumeFromPositionOptions = []string{consumeFromLastOffset, consumeFromStart, consumeFromEnd, consumeFromTimestamp} ) // Config holds the generic config for the Kafka backend. @@ -68,6 +64,9 @@ type Config struct { ProducerMaxRecordSizeBytes int `yaml:"producer_max_record_size_bytes"` ProducerMaxBufferedBytes int64 `yaml:"producer_max_buffered_bytes"` + + TargetConsumerLagAtStartup time.Duration `yaml:"target_consumer_lag_at_startup"` + MaxConsumerLagAtStartup time.Duration `yaml:"max_consumer_lag_at_startup"` } func (cfg *Config) RegisterFlags(f *flag.FlagSet) { @@ -91,6 +90,10 @@ func (cfg *Config) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) { f.IntVar(&cfg.ProducerMaxRecordSizeBytes, prefix+".producer-max-record-size-bytes", maxProducerRecordDataBytesLimit, "The maximum size of a Kafka record data that should be generated by the producer. An incoming write request larger than this size is split into multiple Kafka records. We strongly recommend to not change this setting unless for testing purposes.") f.Int64Var(&cfg.ProducerMaxBufferedBytes, prefix+".producer-max-buffered-bytes", 1024*1024*1024, "The maximum size of (uncompressed) buffered and unacknowledged produced records sent to Kafka. The produce request fails once this limit is reached. This limit is per Kafka client. 0 to disable the limit.") + + consumerLagUsage := fmt.Sprintf("Set both -%s and -%s to 0 to disable waiting for maximum consumer lag being honored at startup.", prefix+".target-consumer-lag-at-startup", prefix+".max-consumer-lag-at-startup") + f.DurationVar(&cfg.TargetConsumerLagAtStartup, prefix+".target-consumer-lag-at-startup", 2*time.Second, "The best-effort maximum lag a consumer tries to achieve at startup. "+consumerLagUsage) + f.DurationVar(&cfg.MaxConsumerLagAtStartup, prefix+".max-consumer-lag-at-startup", 15*time.Second, "The guaranteed maximum lag before a consumer is considered to have caught up reading from a partition at startup, becomes ACTIVE in the hash ring and passes the readiness check. "+consumerLagUsage) } func (cfg *Config) Validate() error { @@ -103,6 +106,12 @@ func (cfg *Config) Validate() error { if cfg.ProducerMaxRecordSizeBytes < minProducerRecordDataBytesLimit || cfg.ProducerMaxRecordSizeBytes > maxProducerRecordDataBytesLimit { return ErrInvalidProducerMaxRecordSizeBytes } + if (cfg.TargetConsumerLagAtStartup == 0 && cfg.MaxConsumerLagAtStartup != 0) || (cfg.TargetConsumerLagAtStartup != 0 && cfg.MaxConsumerLagAtStartup == 0) { + return ErrInconsistentConsumerLagAtStartup + } + if cfg.MaxConsumerLagAtStartup < cfg.TargetConsumerLagAtStartup { + return ErrInvalidMaxConsumerLagAtStartup + } return nil } diff --git a/pkg/kafka/partition/reader.go b/pkg/kafka/partition/reader.go index 9972d13307e8b..b2a98afa99ed4 100644 --- a/pkg/kafka/partition/reader.go +++ b/pkg/kafka/partition/reader.go @@ -6,20 +6,31 @@ import ( "math" "time" + "github.com/coder/quartz" "github.com/go-kit/log" "github.com/go-kit/log/level" + "github.com/grafana/dskit/backoff" "github.com/grafana/dskit/multierror" "github.com/grafana/dskit/services" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" "github.com/twmb/franz-go/pkg/kadm" + "github.com/twmb/franz-go/pkg/kerr" "github.com/twmb/franz-go/pkg/kgo" + "github.com/twmb/franz-go/pkg/kmsg" "github.com/twmb/franz-go/plugin/kprom" "github.com/grafana/loki/v3/pkg/kafka" ) +var errWaitTargetLagDeadlineExceeded = errors.New("waiting for target lag deadline exceeded") + +const ( + kafkaStartOffset = -2 + kafkaEndOffset = -1 +) + // Reader is responsible for reading data from a specific Kafka partition // and passing it to the consumer for processing. It is a core component of the // Loki ingester's Kafka-based ingestion pipeline. @@ -32,11 +43,13 @@ type Reader struct { consumerFactory ConsumerFactory committer *partitionCommitter lastProcessedOffset int64 + recordsChan chan []Record client *kgo.Client logger log.Logger metrics readerMetrics reg prometheus.Registerer + clock quartz.Clock } type Record struct { @@ -79,18 +92,45 @@ func NewReader( // start initializes the Kafka client and committer for the PartitionReader. // This method is called when the PartitionReader service starts. -func (p *Reader) start(_ context.Context) error { +func (p *Reader) start(ctx context.Context) error { var err error - p.client, err = kafka.NewReaderClient(p.kafkaCfg, p.metrics.kprom, p.logger, - kgo.ConsumePartitions(map[string]map[int32]kgo.Offset{ - p.kafkaCfg.Topic: {p.partitionID: kgo.NewOffset().AtStart()}, - }), - ) + p.client, err = kafka.NewReaderClient(p.kafkaCfg, p.metrics.kprom, p.logger) if err != nil { return errors.Wrap(err, "creating kafka reader client") } + + // We manage our commits manually, so we must fetch the last offset for our consumer group to find out where to read from. + lastCommittedOffset := p.fetchLastCommittedOffset(ctx) + p.client.AddConsumePartitions(map[string]map[int32]kgo.Offset{ + p.kafkaCfg.Topic: {p.partitionID: kgo.NewOffset().At(lastCommittedOffset)}, + }) + p.committer = newCommitter(p.kafkaCfg, kadm.NewClient(p.client), p.partitionID, p.consumerGroup, p.logger, p.reg) - // todo: attempt to ensure max lag timestamp on startup. + + if targetLag, maxLag := p.kafkaCfg.TargetConsumerLagAtStartup, p.kafkaCfg.MaxConsumerLagAtStartup; targetLag > 0 && maxLag > 0 { + consumer, err := p.consumerFactory(p.committer) + if err != nil { + return fmt.Errorf("creating consumer: %w", err) + } + + cancelCtx, cancel := context.WithCancel(ctx) + // Temporarily start a consumer to do the initial update + recordsChan := make(chan []Record) + wait := consumer.Start(cancelCtx, recordsChan) + // Shutdown the consumer after catching up. We start a new instance in the run method to tie the lifecycle to the run context. + defer func() { + close(recordsChan) + cancel() + wait() + }() + + err = p.processNextFetchesUntilTargetOrMaxLagHonored(ctx, p.kafkaCfg.MaxConsumerLagAtStartup, p.kafkaCfg.TargetConsumerLagAtStartup, recordsChan) + if err != nil { + level.Error(p.logger).Log("msg", "failed to catch up to max lag", "partition", p.partitionID, "consumer_group", p.consumerGroup, "err", err) + return err + } + } + return nil } @@ -114,7 +154,251 @@ func (p *Reader) run(ctx context.Context) error { return nil } -func (p *Reader) startFetchLoop(ctx context.Context) <-chan []Record { +func (p *Reader) fetchLastCommittedOffset(ctx context.Context) int64 { + // We manually create a request so that we can request the offset for a single partition + // only, which is more performant than requesting the offsets for all partitions. + req := kmsg.NewPtrOffsetFetchRequest() + req.Topics = []kmsg.OffsetFetchRequestTopic{{Topic: p.kafkaCfg.Topic, Partitions: []int32{p.partitionID}}} + req.Group = p.consumerGroup + + resps := p.client.RequestSharded(ctx, req) + + // Since we issued a request for only 1 partition, we expect exactly 1 response. + if expected, actual := 1, len(resps); actual != expected { + level.Error(p.logger).Log("msg", fmt.Sprintf("unexpected number of responses (expected: %d, got: %d)", expected, actual), "expected", expected, "actual", len(resps)) + return kafkaStartOffset + } + // Ensure no error occurred. + res := resps[0] + if res.Err != nil { + level.Error(p.logger).Log("msg", "error fetching group offset for partition", "err", res.Err) + return kafkaStartOffset + } + + // Parse the response. + fetchRes, ok := res.Resp.(*kmsg.OffsetFetchResponse) + if !ok { + level.Error(p.logger).Log("msg", "unexpected response type") + return kafkaStartOffset + } + if expected, actual := 1, len(fetchRes.Groups); actual != expected { + level.Error(p.logger).Log("msg", fmt.Sprintf("unexpected number of groups in the response (expected: %d, got: %d)", expected, actual)) + return kafkaStartOffset + } + if expected, actual := 1, len(fetchRes.Groups[0].Topics); actual != expected { + level.Error(p.logger).Log("msg", fmt.Sprintf("unexpected number of topics in the response (expected: %d, got: %d)", expected, actual)) + return kafkaStartOffset + } + if expected, actual := p.kafkaCfg.Topic, fetchRes.Groups[0].Topics[0].Topic; expected != actual { + level.Error(p.logger).Log("msg", fmt.Sprintf("unexpected topic in the response (expected: %s, got: %s)", expected, actual)) + return kafkaStartOffset + } + if expected, actual := 1, len(fetchRes.Groups[0].Topics[0].Partitions); actual != expected { + level.Error(p.logger).Log("msg", fmt.Sprintf("unexpected number of partitions in the response (expected: %d, got: %d)", expected, actual)) + return kafkaStartOffset + } + if expected, actual := p.partitionID, fetchRes.Groups[0].Topics[0].Partitions[0].Partition; actual != expected { + level.Error(p.logger).Log("msg", fmt.Sprintf("unexpected partition in the response (expected: %d, got: %d)", expected, actual)) + return kafkaStartOffset + } + if err := kerr.ErrorForCode(fetchRes.Groups[0].Topics[0].Partitions[0].ErrorCode); err != nil { + level.Error(p.logger).Log("msg", "unexpected error in the response", "err", err) + return kafkaStartOffset + } + + return fetchRes.Groups[0].Topics[0].Partitions[0].Offset +} + +func (p *Reader) fetchPartitionOffset(ctx context.Context, position int64) (int64, error) { + // Create a custom request to fetch the latest offset of a specific partition. + // We manually create a request so that we can request the offset for a single partition + // only, which is more performant than requesting the offsets for all partitions. + partitionReq := kmsg.NewListOffsetsRequestTopicPartition() + partitionReq.Partition = p.partitionID + partitionReq.Timestamp = position + + topicReq := kmsg.NewListOffsetsRequestTopic() + topicReq.Topic = p.kafkaCfg.Topic + topicReq.Partitions = []kmsg.ListOffsetsRequestTopicPartition{partitionReq} + + req := kmsg.NewPtrListOffsetsRequest() + req.IsolationLevel = 0 // 0 means READ_UNCOMMITTED. + req.Topics = []kmsg.ListOffsetsRequestTopic{topicReq} + + // Even if we share the same client, other in-flight requests are not canceled once this context is canceled + // (or its deadline is exceeded). We've verified it with a unit test. + resps := p.client.RequestSharded(ctx, req) + + // Since we issued a request for only 1 partition, we expect exactly 1 response. + if expected := 1; len(resps) != 1 { + return 0, fmt.Errorf("unexpected number of responses (expected: %d, got: %d)", expected, len(resps)) + } + + // Ensure no error occurred. + res := resps[0] + if res.Err != nil { + return 0, res.Err + } + + // Parse the response. + listRes, ok := res.Resp.(*kmsg.ListOffsetsResponse) + if !ok { + return 0, errors.New("unexpected response type") + } + if expected, actual := 1, len(listRes.Topics); actual != expected { + return 0, fmt.Errorf("unexpected number of topics in the response (expected: %d, got: %d)", expected, actual) + } + if expected, actual := p.kafkaCfg.Topic, listRes.Topics[0].Topic; expected != actual { + return 0, fmt.Errorf("unexpected topic in the response (expected: %s, got: %s)", expected, actual) + } + if expected, actual := 1, len(listRes.Topics[0].Partitions); actual != expected { + return 0, fmt.Errorf("unexpected number of partitions in the response (expected: %d, got: %d)", expected, actual) + } + if expected, actual := p.partitionID, listRes.Topics[0].Partitions[0].Partition; actual != expected { + return 0, fmt.Errorf("unexpected partition in the response (expected: %d, got: %d)", expected, actual) + } + if err := kerr.ErrorForCode(listRes.Topics[0].Partitions[0].ErrorCode); err != nil { + return 0, err + } + + return listRes.Topics[0].Partitions[0].Offset, nil +} + +// processNextFetchesUntilTargetOrMaxLagHonored process records from Kafka until at least the maxLag is honored. +// This function does a best-effort to get lag below targetLag, but it's not guaranteed that it will be +// reached once this function successfully returns (only maxLag is guaranteed). +func (p *Reader) processNextFetchesUntilTargetOrMaxLagHonored(ctx context.Context, targetLag, maxLag time.Duration, recordsChan chan<- []Record) error { + logger := log.With(p.logger, "target_lag", targetLag, "max_lag", maxLag) + level.Info(logger).Log("msg", "partition reader is starting to consume partition until target and max consumer lag is honored") + + attempts := []func() (time.Duration, error){ + // First process fetches until at least the max lag is honored. + func() (time.Duration, error) { + return p.processNextFetchesUntilLagHonored(ctx, maxLag, logger, recordsChan) + }, + + // If the target lag hasn't been reached with the first attempt (which stops once at least the max lag + // is honored) then we try to reach the (lower) target lag within a fixed time (best-effort). + // The timeout is equal to the max lag. This is done because we expect at least a 2x replay speed + // from Kafka (which means at most it takes 1s to ingest 2s of data): assuming new data is continuously + // written to the partition, we give the reader maxLag time to replay the backlog + ingest the new data + // written in the meanwhile. + func() (time.Duration, error) { + timedCtx, cancel := context.WithTimeoutCause(ctx, maxLag, errWaitTargetLagDeadlineExceeded) + defer cancel() + + return p.processNextFetchesUntilLagHonored(timedCtx, targetLag, logger, recordsChan) + }, + + // If the target lag hasn't been reached with the previous attempt then we'll move on. However, + // we still need to guarantee that in the meanwhile the lag didn't increase and max lag is still honored. + func() (time.Duration, error) { + return p.processNextFetchesUntilLagHonored(ctx, maxLag, logger, recordsChan) + }, + } + + var currLag time.Duration + for _, attempt := range attempts { + var err error + + currLag, err = attempt() + if errors.Is(err, errWaitTargetLagDeadlineExceeded) { + continue + } + if err != nil { + return err + } + if currLag <= targetLag { + level.Info(logger).Log( + "msg", "partition reader consumed partition and current lag is lower or equal to configured target consumer lag", + "last_consumed_offset", p.committer.lastCommittedOffset, + "current_lag", currLag, + ) + return nil + } + } + + level.Warn(logger).Log( + "msg", "partition reader consumed partition and current lag is lower than configured max consumer lag but higher than target consumer lag", + "last_consumed_offset", p.committer.lastCommittedOffset, + "current_lag", currLag, + ) + return nil +} + +func (p *Reader) processNextFetchesUntilLagHonored(ctx context.Context, maxLag time.Duration, logger log.Logger, recordsChan chan<- []Record) (time.Duration, error) { + boff := backoff.New(ctx, backoff.Config{ + MinBackoff: 100 * time.Millisecond, + MaxBackoff: time.Second, + MaxRetries: 0, // Retry forever (unless context is canceled / deadline exceeded). + }) + currLag := time.Duration(0) + + for boff.Ongoing() { + // Send a direct request to the Kafka backend to fetch the partition start offset. + partitionStartOffset, err := p.fetchPartitionOffset(ctx, kafkaStartOffset) + if err != nil { + level.Warn(logger).Log("msg", "partition reader failed to fetch partition start offset", "err", err) + boff.Wait() + continue + } + + // Send a direct request to the Kafka backend to fetch the last produced offset. + // We intentionally don't use WaitNextFetchLastProducedOffset() to not introduce further + // latency. + lastProducedOffsetRequestedAt := time.Now() + lastProducedOffset, err := p.fetchPartitionOffset(ctx, kafkaEndOffset) + if err != nil { + level.Warn(logger).Log("msg", "partition reader failed to fetch last produced offset", "err", err) + boff.Wait() + continue + } + lastProducedOffset = lastProducedOffset - 1 // Kafka returns the next empty offset so we must subtract 1 to get the oldest written offset. + + // Ensure there are some records to consume. For example, if the partition has been inactive for a long + // time and all its records have been deleted, the partition start offset may be > 0 but there are no + // records to actually consume. + if partitionStartOffset > lastProducedOffset { + level.Info(logger).Log("msg", "partition reader found no records to consume because partition is empty", "partition_start_offset", partitionStartOffset, "last_produced_offset", lastProducedOffset) + return 0, nil + } + + // This message is NOT expected to be logged with a very high rate. In this log we display the last measured + // lag. If we don't have it (lag is zero value), then it will not be logged. + level.Info(loggerWithCurrentLagIfSet(logger, currLag)).Log("msg", "partition reader is consuming records to honor target and max consumer lag", "partition_start_offset", partitionStartOffset, "last_produced_offset", lastProducedOffset) + + for boff.Ongoing() { + // Continue reading until we reached the desired offset. + if lastProducedOffset <= p.lastProcessedOffset { + break + } + + records := p.poll(ctx) + recordsChan <- records + } + if boff.Err() != nil { + return 0, boff.ErrCause() + } + + // If it took less than the max desired lag to replay the partition + // then we can stop here, otherwise we'll have to redo it. + if currLag = time.Since(lastProducedOffsetRequestedAt); currLag <= maxLag { + return currLag, nil + } + } + + return 0, boff.ErrCause() +} + +func loggerWithCurrentLagIfSet(logger log.Logger, currLag time.Duration) log.Logger { + if currLag <= 0 { + return logger + } + + return log.With(logger, "current_lag", currLag) +} + +func (p *Reader) startFetchLoop(ctx context.Context) chan []Record { records := make(chan []Record) go func() { for { diff --git a/pkg/kafka/partition/reader_test.go b/pkg/kafka/partition/reader_test.go index addc5779bb6a8..b68c9a0622704 100644 --- a/pkg/kafka/partition/reader_test.go +++ b/pkg/kafka/partition/reader_test.go @@ -39,7 +39,10 @@ func (m *mockConsumer) Start(ctx context.Context, recordsChan <-chan []Record) f select { case <-ctx.Done(): return - case records := <-recordsChan: + case records, ok := <-recordsChan: + if !ok { + return + } m.recordsChan <- records } } @@ -100,3 +103,61 @@ func TestPartitionReader_BasicFunctionality(t *testing.T) { err = services.StopAndAwaitTerminated(context.Background(), partitionReader) require.NoError(t, err) } + +func TestPartitionReader_ProcessCatchUpAtStartup(t *testing.T) { + _, kafkaCfg := testkafka.CreateCluster(t, 1, "test-topic") + var consumerStarting *mockConsumer + + consumerFactory := func(_ Committer) (Consumer, error) { + // Return two consumers to ensure we are processing requests during service `start()` and not during `run()`. + if consumerStarting == nil { + consumerStarting = newMockConsumer() + return consumerStarting, nil + } + return newMockConsumer(), nil + } + + partitionReader, err := NewReader(kafkaCfg, 0, "test-consumer-group", consumerFactory, log.NewNopLogger(), prometheus.NewRegistry()) + require.NoError(t, err) + producer, err := kafka.NewWriterClient(kafkaCfg, 100, log.NewNopLogger(), prometheus.NewRegistry()) + require.NoError(t, err) + + stream := logproto.Stream{ + Labels: labels.FromStrings("foo", "bar").String(), + Entries: []logproto.Entry{{Timestamp: time.Now(), Line: "test"}}, + } + + records, err := kafka.Encode(0, "test-tenant", stream, 10<<20) + require.NoError(t, err) + require.Len(t, records, 1) + + producer.ProduceSync(context.Background(), records...) + producer.ProduceSync(context.Background(), records...) + + // Enable the catch up logic so starting the reader will read any existing records. + kafkaCfg.TargetConsumerLagAtStartup = time.Second * 1 + kafkaCfg.MaxConsumerLagAtStartup = time.Second * 2 + + err = services.StartAndAwaitRunning(context.Background(), partitionReader) + require.NoError(t, err) + + // This message should not be processed by the startingConsumer + producer.ProduceSync(context.Background(), records...) + + // Wait for records to be processed + require.Eventually(t, func() bool { + return len(consumerStarting.recordsChan) == 1 // All pending messages will be received in one batch + }, 10*time.Second, 10*time.Millisecond) + + receivedRecords := <-consumerStarting.recordsChan + require.Len(t, receivedRecords, 2) + assert.Equal(t, "test-tenant", receivedRecords[0].TenantID) + assert.Equal(t, records[0].Value, receivedRecords[0].Content) + assert.Equal(t, "test-tenant", receivedRecords[1].TenantID) + assert.Equal(t, records[0].Value, receivedRecords[1].Content) + + assert.Equal(t, 0, len(consumerStarting.recordsChan)) + + err = services.StopAndAwaitTerminated(context.Background(), partitionReader) + require.NoError(t, err) +} diff --git a/pkg/kafka/testkafka/cluster.go b/pkg/kafka/testkafka/cluster.go index fc00e7272e7aa..cc5847c2bfd35 100644 --- a/pkg/kafka/testkafka/cluster.go +++ b/pkg/kafka/testkafka/cluster.go @@ -102,7 +102,7 @@ func addSupportForConsumerGroups(t testing.TB, cluster *kfake.Cluster, topicName partitionID = allPartitions } else { partitionID = req.Groups[0].Topics[0].Partitions[0] - assert.Len(t, req.Groups[0], 1, "test only has support for one partition per request") + assert.Len(t, req.Groups[0].Topics, 1, "test only has support for one partition per request") assert.Len(t, req.Groups[0].Topics[0].Partitions, 1, "test only has support for one partition per request") } From 5cbb23994beb3494e238fccecbb3f7c5ed5c1d0b Mon Sep 17 00:00:00 2001 From: benclive Date: Fri, 4 Oct 2024 13:05:06 +0100 Subject: [PATCH 11/26] feat(kafka): Implement limiter using partition ring for Kafka (#14359) --- pkg/ingester/checkpoint_test.go | 5 +- pkg/ingester/ingester.go | 10 +- pkg/ingester/instance_test.go | 18 +-- pkg/ingester/limiter.go | 75 +++++++-- pkg/ingester/limiter_test.go | 148 ++++++++++++------ pkg/ingester/owned_streams_test.go | 2 +- .../recalculate_owned_streams_test.go | 2 +- pkg/ingester/stream_test.go | 20 +-- pkg/ingester/streams_map_test.go | 2 +- 9 files changed, 191 insertions(+), 91 deletions(-) diff --git a/pkg/ingester/checkpoint_test.go b/pkg/ingester/checkpoint_test.go index 9f1db601bb72d..402768988bb52 100644 --- a/pkg/ingester/checkpoint_test.go +++ b/pkg/ingester/checkpoint_test.go @@ -458,7 +458,8 @@ func Test_SeriesIterator(t *testing.T) { limits, err := validation.NewOverrides(l, nil) require.NoError(t, err) - limiter := NewLimiter(limits, NilMetrics, &ringCountMock{count: 1}, 1) + + limiter := NewLimiter(limits, NilMetrics, newIngesterRingLimiterStrategy(&ringCountMock{count: 1}, 1)) for i := 0; i < 3; i++ { inst, err := newInstance(defaultConfig(), defaultPeriodConfigs, fmt.Sprintf("%d", i), limiter, runtime.DefaultTenantConfigs(), noopWAL{}, NilMetrics, nil, nil, nil, nil, NewStreamRateCalculator(), nil, nil) @@ -505,7 +506,7 @@ func Benchmark_SeriesIterator(b *testing.B) { limits, err := validation.NewOverrides(defaultLimitsTestConfig(), nil) require.NoError(b, err) - limiter := NewLimiter(limits, NilMetrics, &ringCountMock{count: 1}, 1) + limiter := NewLimiter(limits, NilMetrics, newIngesterRingLimiterStrategy(&ringCountMock{count: 1}, 1)) for i := range instances { inst, _ := newInstance(defaultConfig(), defaultPeriodConfigs, fmt.Sprintf("instance %d", i), limiter, runtime.DefaultTenantConfigs(), noopWAL{}, NilMetrics, nil, nil, nil, nil, NewStreamRateCalculator(), nil, nil) diff --git a/pkg/ingester/ingester.go b/pkg/ingester/ingester.go index 3e24d627c60ec..40028cfcd528a 100644 --- a/pkg/ingester/ingester.go +++ b/pkg/ingester/ingester.go @@ -388,10 +388,6 @@ func New(cfg Config, clientConfig client.Config, store Store, limits Limits, con i.lifecyclerWatcher.WatchService(i.partitionReader) } - // Now that the lifecycler has been created, we can create the limiter - // which depends on it. - i.limiter = NewLimiter(limits, metrics, i.lifecycler, cfg.LifecyclerConfig.RingConfig.ReplicationFactor) - i.Service = services.NewBasicService(i.starting, i.running, i.stopping) i.setupAutoForget() @@ -408,12 +404,18 @@ func New(cfg Config, clientConfig client.Config, store Store, limits Limits, con i.SetExtractorWrapper(i.cfg.SampleExtractorWrapper) } + var limiterStrategy limiterRingStrategy var ownedStreamsStrategy ownershipStrategy if i.cfg.KafkaIngestion.Enabled { + limiterStrategy = newPartitionRingLimiterStrategy(partitionRingWatcher, limits.IngestionPartitionsTenantShardSize) ownedStreamsStrategy = newOwnedStreamsPartitionStrategy(i.ingestPartitionID, partitionRingWatcher, limits.IngestionPartitionsTenantShardSize, util_log.Logger) } else { + limiterStrategy = newIngesterRingLimiterStrategy(i.lifecycler, cfg.LifecyclerConfig.RingConfig.ReplicationFactor) ownedStreamsStrategy = newOwnedStreamsIngesterStrategy(i.lifecycler.ID, i.readRing, util_log.Logger) } + // Now that the lifecycler has been created, we can create the limiter + // which depends on it. + i.limiter = NewLimiter(limits, metrics, limiterStrategy) i.recalculateOwnedStreams = newRecalculateOwnedStreamsSvc(i.getInstances, ownedStreamsStrategy, cfg.OwnedStreamsCheckInterval, util_log.Logger) return i, nil diff --git a/pkg/ingester/instance_test.go b/pkg/ingester/instance_test.go index 4086831bb33fb..819577540f664 100644 --- a/pkg/ingester/instance_test.go +++ b/pkg/ingester/instance_test.go @@ -78,7 +78,7 @@ var NilMetrics = newIngesterMetrics(nil, constants.Loki) func TestLabelsCollisions(t *testing.T) { limits, err := validation.NewOverrides(defaultLimitsTestConfig(), nil) require.NoError(t, err) - limiter := NewLimiter(limits, NilMetrics, &ringCountMock{count: 1}, 1) + limiter := NewLimiter(limits, NilMetrics, newIngesterRingLimiterStrategy(&ringCountMock{count: 1}, 1)) i, err := newInstance(defaultConfig(), defaultPeriodConfigs, "test", limiter, loki_runtime.DefaultTenantConfigs(), noopWAL{}, NilMetrics, &OnceSwitch{}, nil, nil, nil, NewStreamRateCalculator(), nil, nil) require.Nil(t, err) @@ -106,7 +106,7 @@ func TestLabelsCollisions(t *testing.T) { func TestConcurrentPushes(t *testing.T) { limits, err := validation.NewOverrides(defaultLimitsTestConfig(), nil) require.NoError(t, err) - limiter := NewLimiter(limits, NilMetrics, &ringCountMock{count: 1}, 1) + limiter := NewLimiter(limits, NilMetrics, newIngesterRingLimiterStrategy(&ringCountMock{count: 1}, 1)) inst, err := newInstance(defaultConfig(), defaultPeriodConfigs, "test", limiter, loki_runtime.DefaultTenantConfigs(), noopWAL{}, NilMetrics, &OnceSwitch{}, nil, nil, nil, NewStreamRateCalculator(), nil, nil) require.Nil(t, err) @@ -158,7 +158,7 @@ func TestConcurrentPushes(t *testing.T) { func TestGetStreamRates(t *testing.T) { limits, err := validation.NewOverrides(defaultLimitsTestConfig(), nil) require.NoError(t, err) - limiter := NewLimiter(limits, NilMetrics, &ringCountMock{count: 1}, 1) + limiter := NewLimiter(limits, NilMetrics, newIngesterRingLimiterStrategy(&ringCountMock{count: 1}, 1)) inst, err := newInstance(defaultConfig(), defaultPeriodConfigs, "test", limiter, loki_runtime.DefaultTenantConfigs(), noopWAL{}, NilMetrics, &OnceSwitch{}, nil, nil, nil, NewStreamRateCalculator(), nil, nil) require.NoError(t, err) @@ -245,7 +245,7 @@ func labelHashNoShard(l labels.Labels) uint64 { func TestSyncPeriod(t *testing.T) { limits, err := validation.NewOverrides(defaultLimitsTestConfig(), nil) require.NoError(t, err) - limiter := NewLimiter(limits, NilMetrics, &ringCountMock{count: 1}, 1) + limiter := NewLimiter(limits, NilMetrics, newIngesterRingLimiterStrategy(&ringCountMock{count: 1}, 1)) const ( syncPeriod = 1 * time.Minute @@ -290,7 +290,7 @@ func setupTestStreams(t *testing.T) (*instance, time.Time, int) { t.Helper() limits, err := validation.NewOverrides(defaultLimitsTestConfig(), nil) require.NoError(t, err) - limiter := NewLimiter(limits, NilMetrics, &ringCountMock{count: 1}, 1) + limiter := NewLimiter(limits, NilMetrics, newIngesterRingLimiterStrategy(&ringCountMock{count: 1}, 1)) indexShards := 2 // just some random values @@ -507,7 +507,7 @@ func makeRandomLabels() labels.Labels { func Benchmark_PushInstance(b *testing.B) { limits, err := validation.NewOverrides(defaultLimitsTestConfig(), nil) require.NoError(b, err) - limiter := NewLimiter(limits, NilMetrics, &ringCountMock{count: 1}, 1) + limiter := NewLimiter(limits, NilMetrics, newIngesterRingLimiterStrategy(&ringCountMock{count: 1}, 1)) i, _ := newInstance(&Config{IndexShards: 1}, defaultPeriodConfigs, "test", limiter, loki_runtime.DefaultTenantConfigs(), noopWAL{}, NilMetrics, &OnceSwitch{}, nil, nil, nil, NewStreamRateCalculator(), nil, nil) ctx := context.Background() @@ -549,7 +549,7 @@ func Benchmark_instance_addNewTailer(b *testing.B) { l.MaxLocalStreamsPerUser = 100000 limits, err := validation.NewOverrides(l, nil) require.NoError(b, err) - limiter := NewLimiter(limits, NilMetrics, &ringCountMock{count: 1}, 1) + limiter := NewLimiter(limits, NilMetrics, newIngesterRingLimiterStrategy(&ringCountMock{count: 1}, 1)) ctx := context.Background() @@ -1089,7 +1089,7 @@ func TestStreamShardingUsage(t *testing.T) { limits, err := validation.NewOverrides(defaultLimitsTestConfig(), limitsDefinition) require.NoError(t, err) - limiter := NewLimiter(limits, NilMetrics, &ringCountMock{count: 1}, 1) + limiter := NewLimiter(limits, NilMetrics, newIngesterRingLimiterStrategy(&ringCountMock{count: 1}, 1)) defaultShardStreamsCfg := limiter.limits.ShardStreams("fake") tenantShardStreamsCfg := limiter.limits.ShardStreams(customTenant1) @@ -1454,7 +1454,7 @@ func defaultInstance(t *testing.T) *instance { &ingesterConfig, defaultPeriodConfigs, "fake", - NewLimiter(overrides, NilMetrics, &ringCountMock{count: 1}, 1), + NewLimiter(overrides, NilMetrics, newIngesterRingLimiterStrategy(&ringCountMock{count: 1}, 1)), loki_runtime.DefaultTenantConfigs(), noopWAL{}, NilMetrics, diff --git a/pkg/ingester/limiter.go b/pkg/ingester/limiter.go index a9ddd2ba3ba3c..fd3a5c7c1b9bb 100644 --- a/pkg/ingester/limiter.go +++ b/pkg/ingester/limiter.go @@ -6,6 +6,7 @@ import ( "sync" "time" + "github.com/grafana/dskit/ring" "golang.org/x/time/rate" "github.com/grafana/loki/v3/pkg/distributor/shardstreams" @@ -13,7 +14,7 @@ import ( ) const ( - errMaxStreamsPerUserLimitExceeded = "tenant '%v' per-user streams limit exceeded, streams: %d exceeds calculated limit: %d (local limit: %d, global limit: %d, global/ingesters: %d)" + errMaxStreamsPerUserLimitExceeded = "tenant '%v' per-user streams limit exceeded, streams: %d exceeds calculated limit: %d (local limit: %d, global limit: %d, local share: %d)" ) // RingCount is the interface exposed by a ring implementation which allows @@ -37,10 +38,9 @@ type Limits interface { // Limiter implements primitives to get the maximum number of streams // an ingester can handle for a specific tenant type Limiter struct { - limits Limits - ring RingCount - replicationFactor int - metrics *ingesterMetrics + limits Limits + ringStrategy limiterRingStrategy + metrics *ingesterMetrics mtx sync.RWMutex disabled bool @@ -60,13 +60,16 @@ func (l *Limiter) Enable() { l.metrics.limiterEnabled.Set(1) } +type limiterRingStrategy interface { + convertGlobalToLocalLimit(int, string) int +} + // NewLimiter makes a new limiter -func NewLimiter(limits Limits, metrics *ingesterMetrics, ring RingCount, replicationFactor int) *Limiter { +func NewLimiter(limits Limits, metrics *ingesterMetrics, ingesterRingLimiterStrategy limiterRingStrategy) *Limiter { return &Limiter{ - limits: limits, - ring: ring, - replicationFactor: replicationFactor, - metrics: metrics, + limits: limits, + ringStrategy: ingesterRingLimiterStrategy, + metrics: metrics, } } @@ -87,7 +90,7 @@ func (l *Limiter) GetStreamCountLimit(tenantID string) (calculatedLimit, localLi // We can assume that streams are evenly distributed across ingesters // so we do convert the global limit into a local limit globalLimit = l.limits.MaxGlobalStreamsPerUser(tenantID) - adjustedGlobalLimit = l.convertGlobalToLocalLimit(globalLimit) + adjustedGlobalLimit = l.ringStrategy.convertGlobalToLocalLimit(globalLimit, tenantID) // Set the calculated limit to the lesser of the local limit or the new calculated global limit calculatedLimit = l.minNonZero(localLimit, adjustedGlobalLimit) @@ -108,20 +111,32 @@ func (l *Limiter) minNonZero(first, second int) int { return first } -func (l *Limiter) convertGlobalToLocalLimit(globalLimit int) int { +type ingesterRingLimiterStrategy struct { + ring RingCount + replicationFactor int +} + +func newIngesterRingLimiterStrategy(ring RingCount, replicationFactor int) *ingesterRingLimiterStrategy { + return &ingesterRingLimiterStrategy{ + ring: ring, + replicationFactor: replicationFactor, + } +} + +func (l *ingesterRingLimiterStrategy) convertGlobalToLocalLimit(globalLimit int, _ string) int { if globalLimit == 0 || l.replicationFactor == 0 { return 0 } zonesCount := l.ring.ZonesCount() if zonesCount <= 1 { - return calculateLimitForSingleZone(globalLimit, l) + return l.calculateLimitForSingleZone(globalLimit) } - return calculateLimitForMultipleZones(globalLimit, zonesCount, l) + return l.calculateLimitForMultipleZones(globalLimit, zonesCount) } -func calculateLimitForSingleZone(globalLimit int, l *Limiter) int { +func (l *ingesterRingLimiterStrategy) calculateLimitForSingleZone(globalLimit int) int { numIngesters := l.ring.HealthyInstancesCount() if numIngesters > 0 { return int((float64(globalLimit) / float64(numIngesters)) * float64(l.replicationFactor)) @@ -129,7 +144,7 @@ func calculateLimitForSingleZone(globalLimit int, l *Limiter) int { return 0 } -func calculateLimitForMultipleZones(globalLimit, zonesCount int, l *Limiter) int { +func (l *ingesterRingLimiterStrategy) calculateLimitForMultipleZones(globalLimit, zonesCount int) int { ingestersInZone := l.ring.HealthyInstancesInZoneCount() if ingestersInZone > 0 { return int((float64(globalLimit) * float64(l.replicationFactor)) / float64(zonesCount) / float64(ingestersInZone)) @@ -137,6 +152,34 @@ func calculateLimitForMultipleZones(globalLimit, zonesCount int, l *Limiter) int return 0 } +type partitionRingLimiterStrategy struct { + ring ring.PartitionRingReader + getPartitionShardSize func(user string) int +} + +func newPartitionRingLimiterStrategy(ring ring.PartitionRingReader, getPartitionShardSize func(user string) int) *partitionRingLimiterStrategy { + return &partitionRingLimiterStrategy{ + ring: ring, + getPartitionShardSize: getPartitionShardSize, + } +} + +func (l *partitionRingLimiterStrategy) convertGlobalToLocalLimit(globalLimit int, tenantID string) int { + if globalLimit == 0 { + return 0 + } + + userShardSize := l.getPartitionShardSize(tenantID) + + // ShuffleShardSize correctly handles cases when user has no shard config or more shards than number of active partitions in the ring. + activePartitionsForUser := l.ring.PartitionRing().ShuffleShardSize(userShardSize) + + if activePartitionsForUser == 0 { + return 0 + } + return int(float64(globalLimit) / float64(activePartitionsForUser)) +} + type supplier[T any] func() T type streamCountLimiter struct { diff --git a/pkg/ingester/limiter_test.go b/pkg/ingester/limiter_test.go index 0d0055d0a0afb..bb87efe9555e5 100644 --- a/pkg/ingester/limiter_test.go +++ b/pkg/ingester/limiter_test.go @@ -6,6 +6,7 @@ import ( "testing" "time" + "github.com/grafana/dskit/ring" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.uber.org/atomic" @@ -14,12 +15,18 @@ import ( "github.com/grafana/loki/v3/pkg/validation" ) +type fixedStrategy struct { + localLimit int +} + +func (strategy *fixedStrategy) convertGlobalToLocalLimit(_ int, _ string) int { + return strategy.localLimit +} func TestStreamCountLimiter_AssertNewStreamAllowed(t *testing.T) { tests := map[string]struct { maxLocalStreamsPerUser int maxGlobalStreamsPerUser int - ringReplicationFactor int - ringIngesterCount int + calculatedLocalLimit int streams int expected error useOwnedStreamService bool @@ -29,80 +36,63 @@ func TestStreamCountLimiter_AssertNewStreamAllowed(t *testing.T) { "both local and global limit are disabled": { maxLocalStreamsPerUser: 0, maxGlobalStreamsPerUser: 0, - ringReplicationFactor: 1, - ringIngesterCount: 1, + calculatedLocalLimit: 0, streams: 100, expected: nil, }, "current number of streams is below the limit": { maxLocalStreamsPerUser: 0, maxGlobalStreamsPerUser: 1000, - ringReplicationFactor: 3, - ringIngesterCount: 10, + calculatedLocalLimit: 300, streams: 299, expected: nil, }, "current number of streams is above the limit": { maxLocalStreamsPerUser: 0, maxGlobalStreamsPerUser: 1000, - ringReplicationFactor: 3, - ringIngesterCount: 10, + calculatedLocalLimit: 300, streams: 300, expected: fmt.Errorf(errMaxStreamsPerUserLimitExceeded, "test", 300, 300, 0, 1000, 300), }, "both local and global limits are disabled": { maxLocalStreamsPerUser: 0, maxGlobalStreamsPerUser: 0, - ringReplicationFactor: 1, - ringIngesterCount: 1, + calculatedLocalLimit: 0, streams: math.MaxInt32 - 1, expected: nil, }, "only local limit is enabled": { maxLocalStreamsPerUser: 1000, maxGlobalStreamsPerUser: 0, - ringReplicationFactor: 1, - ringIngesterCount: 1, + calculatedLocalLimit: 1000, streams: 3000, - expected: fmt.Errorf(errMaxStreamsPerUserLimitExceeded, "test", 3000, 1000, 1000, 0, 0), + expected: fmt.Errorf(errMaxStreamsPerUserLimitExceeded, "test", 3000, 1000, 1000, 0, 1000), }, - "only global limit is enabled with replication-factor=1": { + "only global limit is enabled": { maxLocalStreamsPerUser: 0, maxGlobalStreamsPerUser: 1000, - ringReplicationFactor: 1, - ringIngesterCount: 10, + calculatedLocalLimit: 100, streams: 3000, expected: fmt.Errorf(errMaxStreamsPerUserLimitExceeded, "test", 3000, 100, 0, 1000, 100), }, - "only global limit is enabled with replication-factor=3": { - maxLocalStreamsPerUser: 0, - maxGlobalStreamsPerUser: 1000, - ringReplicationFactor: 3, - ringIngesterCount: 10, - streams: 3000, - expected: fmt.Errorf(errMaxStreamsPerUserLimitExceeded, "test", 3000, 300, 0, 1000, 300), - }, "both local and global limits are set with local limit < global limit": { maxLocalStreamsPerUser: 150, maxGlobalStreamsPerUser: 1000, - ringReplicationFactor: 3, - ringIngesterCount: 10, + calculatedLocalLimit: 150, streams: 3000, - expected: fmt.Errorf(errMaxStreamsPerUserLimitExceeded, "test", 3000, 150, 150, 1000, 300), + expected: fmt.Errorf(errMaxStreamsPerUserLimitExceeded, "test", 3000, 150, 150, 1000, 150), }, "both local and global limits are set with local limit > global limit": { maxLocalStreamsPerUser: 500, maxGlobalStreamsPerUser: 1000, - ringReplicationFactor: 3, - ringIngesterCount: 10, + calculatedLocalLimit: 300, streams: 3000, expected: fmt.Errorf(errMaxStreamsPerUserLimitExceeded, "test", 3000, 300, 500, 1000, 300), }, "actual limit must be used if it's greater than fixed limit": { maxLocalStreamsPerUser: 500, maxGlobalStreamsPerUser: 1000, - ringReplicationFactor: 3, - ringIngesterCount: 10, + calculatedLocalLimit: 300, useOwnedStreamService: true, fixedLimit: 20, ownedStreamCount: 3000, @@ -111,18 +101,16 @@ func TestStreamCountLimiter_AssertNewStreamAllowed(t *testing.T) { "fixed limit must be used if it's greater than actual limit": { maxLocalStreamsPerUser: 500, maxGlobalStreamsPerUser: 1000, - ringReplicationFactor: 3, - ringIngesterCount: 10, + calculatedLocalLimit: 500, useOwnedStreamService: true, fixedLimit: 2000, ownedStreamCount: 2001, - expected: fmt.Errorf(errMaxStreamsPerUserLimitExceeded, "test", 2001, 2000, 500, 1000, 300), + expected: fmt.Errorf(errMaxStreamsPerUserLimitExceeded, "test", 2001, 2000, 500, 1000, 500), }, "fixed limit must not be used if both limits are disabled": { maxLocalStreamsPerUser: 0, maxGlobalStreamsPerUser: 0, - ringReplicationFactor: 3, - ringIngesterCount: 10, + calculatedLocalLimit: 0, useOwnedStreamService: true, fixedLimit: 2000, ownedStreamCount: 2001, @@ -134,9 +122,6 @@ func TestStreamCountLimiter_AssertNewStreamAllowed(t *testing.T) { testData := testData t.Run(testName, func(t *testing.T) { - // Mock the ring - ring := &ringCountMock{count: testData.ringIngesterCount} - // Mock limits limits, err := validation.NewOverrides(validation.Limits{ MaxLocalStreamsPerUser: testData.maxLocalStreamsPerUser, @@ -149,7 +134,8 @@ func TestStreamCountLimiter_AssertNewStreamAllowed(t *testing.T) { fixedLimit: atomic.NewInt32(testData.fixedLimit), ownedStreamCount: testData.ownedStreamCount, } - limiter := NewLimiter(limits, NilMetrics, ring, testData.ringReplicationFactor) + strategy := &fixedStrategy{localLimit: testData.calculatedLocalLimit} + limiter := NewLimiter(limits, NilMetrics, strategy) defaultCountSupplier := func() int { return testData.streams } @@ -200,7 +186,7 @@ func TestLimiter_minNonZero(t *testing.T) { testData := testData t.Run(testName, func(t *testing.T) { - limiter := NewLimiter(nil, NilMetrics, nil, 0) + limiter := NewLimiter(nil, NilMetrics, nil) assert.Equal(t, testData.expected, limiter.minNonZero(testData.first, testData.second)) }) } @@ -281,7 +267,7 @@ func (m *MockRing) HealthyInstancesInZoneCount() int { return m.healthyInstancesInZoneCount } -func TestConvertGlobalToLocalLimit(t *testing.T) { +func TestConvertGlobalToLocalLimit_IngesterRing(t *testing.T) { tests := []struct { name string globalLimit int @@ -299,19 +285,87 @@ func TestConvertGlobalToLocalLimit(t *testing.T) { } for _, tc := range tests { - t.Run(tc.name, func(t *testing.T) { + t.Run(tc.name+"_ingesterStrategy", func(t *testing.T) { mockRing := &MockRing{ zonesCount: tc.zonesCount, healthyInstancesCount: tc.healthyInstancesCount, healthyInstancesInZoneCount: tc.healthyInstancesInZoneCount, } - limiter := &Limiter{ - ring: mockRing, - replicationFactor: tc.replicationFactor, + strategy := newIngesterRingLimiterStrategy(mockRing, tc.replicationFactor) + + localLimit := strategy.convertGlobalToLocalLimit(tc.globalLimit, "test") + if localLimit != tc.expectedLocalLimit { + t.Errorf("expected %d, got %d", tc.expectedLocalLimit, localLimit) + } + }) + } +} + +func newMockPartitionRingWithPartitions(activeCount int, inactiveCount int) *ring.PartitionRing { + partitionRing := ring.PartitionRingDesc{ + Partitions: map[int32]ring.PartitionDesc{}, + Owners: map[string]ring.OwnerDesc{}, + } + + for i := 0; i < activeCount; i++ { + id := int32(i) + + partitionRing.Partitions[id] = ring.PartitionDesc{ + Id: id, + Tokens: []uint32{uint32(id)}, + State: ring.PartitionActive, + } + partitionRing.Owners[fmt.Sprintf("test%d", id)] = ring.OwnerDesc{ + OwnedPartition: id, + State: ring.OwnerActive, + } + } + for i := activeCount; i < activeCount+inactiveCount; i++ { + id := int32(i) + + partitionRing.Partitions[id] = ring.PartitionDesc{ + Id: id, + Tokens: []uint32{uint32(id)}, + State: ring.PartitionInactive, + } + } + return ring.NewPartitionRing(partitionRing) +} + +func TestConvertGlobalToLocalLimit_PartitionRing(t *testing.T) { + tests := []struct { + name string + globalLimit int + activePartitions int + inactivePartitions int + shardsPerUser int + expectedLocalLimit int + }{ + {"GlobalLimitZero", 0, 1, 0, 0, 0}, + {"SinglePartition", 100, 1, 0, 0, 100}, + {"MultiplePartitions", 200, 3, 0, 0, 66}, + {"NoActivePartitions", 200, 0, 3, 0, 0}, + {"PartialActivePartitions", 60, 3, 3, 0, 20}, + {"LimitLessThanActivePartitions", 3, 10, 0, 0, 0}, + {"LimitLessThanActivePartitions", 3, 10, 0, 0, 0}, + {"MultiplePartitionsWithLimitedShardsPerUser", 200, 3, 0, 2, 100}, + {"MultiplePartitionsWithMoreShardsPerUserThanPartitions", 200, 3, 0, 10, 66}, + } + + for _, tc := range tests { + t.Run(tc.name+"_partitionStrategy", func(t *testing.T) { + ringReader := &mockPartitionRingReader{ + ring: newMockPartitionRingWithPartitions(tc.activePartitions, tc.inactivePartitions), + } + + getPartitionsForUser := func(_ string) int { + return tc.shardsPerUser } - localLimit := limiter.convertGlobalToLocalLimit(tc.globalLimit) + strategy := newPartitionRingLimiterStrategy(ringReader, getPartitionsForUser) + + localLimit := strategy.convertGlobalToLocalLimit(tc.globalLimit, "test") if localLimit != tc.expectedLocalLimit { t.Errorf("expected %d, got %d", tc.expectedLocalLimit, localLimit) } diff --git a/pkg/ingester/owned_streams_test.go b/pkg/ingester/owned_streams_test.go index 7f114922fa447..373d37a5f62e6 100644 --- a/pkg/ingester/owned_streams_test.go +++ b/pkg/ingester/owned_streams_test.go @@ -17,7 +17,7 @@ func Test_OwnedStreamService(t *testing.T) { require.NoError(t, err) // Mock the ring ring := &ringCountMock{count: 30} - limiter := NewLimiter(limits, NilMetrics, ring, 3) + limiter := NewLimiter(limits, NilMetrics, newIngesterRingLimiterStrategy(ring, 3)) service := newOwnedStreamService("test", limiter) require.Equal(t, 0, service.getOwnedStreamCount()) diff --git a/pkg/ingester/recalculate_owned_streams_test.go b/pkg/ingester/recalculate_owned_streams_test.go index d5dce8599287b..d2d3583095b02 100644 --- a/pkg/ingester/recalculate_owned_streams_test.go +++ b/pkg/ingester/recalculate_owned_streams_test.go @@ -70,7 +70,7 @@ func Test_recalculateOwnedStreams_recalculateWithIngesterStrategy(t *testing.T) UseOwnedStreamCount: testData.featureEnabled, }, nil) require.NoError(t, err) - limiter := NewLimiter(limits, NilMetrics, mockRing, 1) + limiter := NewLimiter(limits, NilMetrics, newIngesterRingLimiterStrategy(mockRing, 1)) tenant, err := newInstance( defaultConfig(), diff --git a/pkg/ingester/stream_test.go b/pkg/ingester/stream_test.go index 03e0ca976628f..fcad6558b21de 100644 --- a/pkg/ingester/stream_test.go +++ b/pkg/ingester/stream_test.go @@ -56,7 +56,7 @@ func TestMaxReturnedStreamsErrors(t *testing.T) { limits, err := validation.NewOverrides(defaultLimitsTestConfig(), nil) require.NoError(t, err) - limiter := NewLimiter(limits, NilMetrics, &ringCountMock{count: 1}, 1) + limiter := NewLimiter(limits, NilMetrics, newIngesterRingLimiterStrategy(&ringCountMock{count: 1}, 1)) for _, tc := range tt { t.Run(tc.name, func(t *testing.T) { @@ -114,7 +114,7 @@ func TestMaxReturnedStreamsErrors(t *testing.T) { func TestPushDeduplication(t *testing.T) { limits, err := validation.NewOverrides(defaultLimitsTestConfig(), nil) require.NoError(t, err) - limiter := NewLimiter(limits, NilMetrics, &ringCountMock{count: 1}, 1) + limiter := NewLimiter(limits, NilMetrics, newIngesterRingLimiterStrategy(&ringCountMock{count: 1}, 1)) chunkfmt, headfmt := defaultChunkFormat(t) @@ -150,7 +150,7 @@ func TestPushDeduplication(t *testing.T) { func TestPushDeduplicationExtraMetrics(t *testing.T) { limits, err := validation.NewOverrides(defaultLimitsTestConfig(), nil) require.NoError(t, err) - limiter := NewLimiter(limits, NilMetrics, &ringCountMock{count: 1}, 1) + limiter := NewLimiter(limits, NilMetrics, newIngesterRingLimiterStrategy(&ringCountMock{count: 1}, 1)) chunkfmt, headfmt := defaultChunkFormat(t) @@ -220,7 +220,7 @@ func TestPushDeduplicationExtraMetrics(t *testing.T) { func TestPushRejectOldCounter(t *testing.T) { limits, err := validation.NewOverrides(defaultLimitsTestConfig(), nil) require.NoError(t, err) - limiter := NewLimiter(limits, NilMetrics, &ringCountMock{count: 1}, 1) + limiter := NewLimiter(limits, NilMetrics, newIngesterRingLimiterStrategy(&ringCountMock{count: 1}, 1)) chunkfmt, headfmt := defaultChunkFormat(t) @@ -328,7 +328,7 @@ func TestEntryErrorCorrectlyReported(t *testing.T) { } limits, err := validation.NewOverrides(l, nil) require.NoError(t, err) - limiter := NewLimiter(limits, NilMetrics, &ringCountMock{count: 1}, 1) + limiter := NewLimiter(limits, NilMetrics, newIngesterRingLimiterStrategy(&ringCountMock{count: 1}, 1)) chunkfmt, headfmt := defaultChunkFormat(t) @@ -367,7 +367,7 @@ func TestUnorderedPush(t *testing.T) { cfg.MaxChunkAge = 10 * time.Second limits, err := validation.NewOverrides(defaultLimitsTestConfig(), nil) require.NoError(t, err) - limiter := NewLimiter(limits, NilMetrics, &ringCountMock{count: 1}, 1) + limiter := NewLimiter(limits, NilMetrics, newIngesterRingLimiterStrategy(&ringCountMock{count: 1}, 1)) chunkfmt, headfmt := defaultChunkFormat(t) @@ -470,7 +470,7 @@ func TestPushRateLimit(t *testing.T) { } limits, err := validation.NewOverrides(l, nil) require.NoError(t, err) - limiter := NewLimiter(limits, NilMetrics, &ringCountMock{count: 1}, 1) + limiter := NewLimiter(limits, NilMetrics, newIngesterRingLimiterStrategy(&ringCountMock{count: 1}, 1)) chunkfmt, headfmt := defaultChunkFormat(t) @@ -510,7 +510,7 @@ func TestPushRateLimitAllOrNothing(t *testing.T) { } limits, err := validation.NewOverrides(l, nil) require.NoError(t, err) - limiter := NewLimiter(limits, NilMetrics, &ringCountMock{count: 1}, 1) + limiter := NewLimiter(limits, NilMetrics, newIngesterRingLimiterStrategy(&ringCountMock{count: 1}, 1)) cfg := defaultConfig() chunkfmt, headfmt := defaultChunkFormat(t) @@ -549,7 +549,7 @@ func TestPushRateLimitAllOrNothing(t *testing.T) { func TestReplayAppendIgnoresValidityWindow(t *testing.T) { limits, err := validation.NewOverrides(defaultLimitsTestConfig(), nil) require.NoError(t, err) - limiter := NewLimiter(limits, NilMetrics, &ringCountMock{count: 1}, 1) + limiter := NewLimiter(limits, NilMetrics, newIngesterRingLimiterStrategy(&ringCountMock{count: 1}, 1)) cfg := defaultConfig() cfg.MaxChunkAge = time.Minute @@ -617,7 +617,7 @@ func Benchmark_PushStream(b *testing.B) { limits, err := validation.NewOverrides(defaultLimitsTestConfig(), nil) require.NoError(b, err) - limiter := NewLimiter(limits, NilMetrics, &ringCountMock{count: 1}, 1) + limiter := NewLimiter(limits, NilMetrics, newIngesterRingLimiterStrategy(&ringCountMock{count: 1}, 1)) chunkfmt, headfmt := defaultChunkFormat(b) s := newStream(chunkfmt, headfmt, &Config{MaxChunkAge: 24 * time.Hour}, limiter, "fake", model.Fingerprint(0), ls, true, NewStreamRateCalculator(), NilMetrics, nil, nil) diff --git a/pkg/ingester/streams_map_test.go b/pkg/ingester/streams_map_test.go index b14b3e07e497f..87e8332eddd45 100644 --- a/pkg/ingester/streams_map_test.go +++ b/pkg/ingester/streams_map_test.go @@ -13,7 +13,7 @@ import ( func TestStreamsMap(t *testing.T) { limits, err := validation.NewOverrides(defaultLimitsTestConfig(), nil) require.NoError(t, err) - limiter := NewLimiter(limits, NilMetrics, &ringCountMock{count: 1}, 1) + limiter := NewLimiter(limits, NilMetrics, newIngesterRingLimiterStrategy(&ringCountMock{count: 1}, 1)) chunkfmt, headfmt := defaultChunkFormat(t) ss := []*stream{ From c76ff146769d5e063475df825c07211167fd1711 Mon Sep 17 00:00:00 2001 From: benclive Date: Fri, 4 Oct 2024 13:16:00 +0100 Subject: [PATCH 12/26] test(kafka): Added additional test for kafka startup logic (#14391) --- pkg/kafka/partition/reader.go | 10 ++--- pkg/kafka/partition/reader_test.go | 70 ++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 5 deletions(-) diff --git a/pkg/kafka/partition/reader.go b/pkg/kafka/partition/reader.go index b2a98afa99ed4..74f18b02057f3 100644 --- a/pkg/kafka/partition/reader.go +++ b/pkg/kafka/partition/reader.go @@ -274,7 +274,7 @@ func (p *Reader) processNextFetchesUntilTargetOrMaxLagHonored(ctx context.Contex attempts := []func() (time.Duration, error){ // First process fetches until at least the max lag is honored. func() (time.Duration, error) { - return p.processNextFetchesUntilLagHonored(ctx, maxLag, logger, recordsChan) + return p.processNextFetchesUntilLagHonored(ctx, maxLag, logger, recordsChan, time.Since) }, // If the target lag hasn't been reached with the first attempt (which stops once at least the max lag @@ -287,13 +287,13 @@ func (p *Reader) processNextFetchesUntilTargetOrMaxLagHonored(ctx context.Contex timedCtx, cancel := context.WithTimeoutCause(ctx, maxLag, errWaitTargetLagDeadlineExceeded) defer cancel() - return p.processNextFetchesUntilLagHonored(timedCtx, targetLag, logger, recordsChan) + return p.processNextFetchesUntilLagHonored(timedCtx, targetLag, logger, recordsChan, time.Since) }, // If the target lag hasn't been reached with the previous attempt then we'll move on. However, // we still need to guarantee that in the meanwhile the lag didn't increase and max lag is still honored. func() (time.Duration, error) { - return p.processNextFetchesUntilLagHonored(ctx, maxLag, logger, recordsChan) + return p.processNextFetchesUntilLagHonored(ctx, maxLag, logger, recordsChan, time.Since) }, } @@ -326,7 +326,7 @@ func (p *Reader) processNextFetchesUntilTargetOrMaxLagHonored(ctx context.Contex return nil } -func (p *Reader) processNextFetchesUntilLagHonored(ctx context.Context, maxLag time.Duration, logger log.Logger, recordsChan chan<- []Record) (time.Duration, error) { +func (p *Reader) processNextFetchesUntilLagHonored(ctx context.Context, maxLag time.Duration, logger log.Logger, recordsChan chan<- []Record, timeSince func(time.Time) time.Duration) (time.Duration, error) { boff := backoff.New(ctx, backoff.Config{ MinBackoff: 100 * time.Millisecond, MaxBackoff: time.Second, @@ -382,7 +382,7 @@ func (p *Reader) processNextFetchesUntilLagHonored(ctx context.Context, maxLag t // If it took less than the max desired lag to replay the partition // then we can stop here, otherwise we'll have to redo it. - if currLag = time.Since(lastProducedOffsetRequestedAt); currLag <= maxLag { + if currLag = timeSince(lastProducedOffsetRequestedAt); currLag <= maxLag { return currLag, nil } } diff --git a/pkg/kafka/partition/reader_test.go b/pkg/kafka/partition/reader_test.go index b68c9a0622704..8d548c8312411 100644 --- a/pkg/kafka/partition/reader_test.go +++ b/pkg/kafka/partition/reader_test.go @@ -2,6 +2,7 @@ package partition import ( "context" + "fmt" "sync" "testing" "time" @@ -13,6 +14,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + "github.com/twmb/franz-go/pkg/kgo" "github.com/grafana/loki/v3/pkg/kafka" "github.com/grafana/loki/v3/pkg/kafka/testkafka" @@ -161,3 +163,71 @@ func TestPartitionReader_ProcessCatchUpAtStartup(t *testing.T) { err = services.StopAndAwaitTerminated(context.Background(), partitionReader) require.NoError(t, err) } + +func TestPartitionReader_ProcessCommits(t *testing.T) { + _, kafkaCfg := testkafka.CreateCluster(t, 1, "test-topic") + consumer := newMockConsumer() + + consumerFactory := func(_ Committer) (Consumer, error) { + return consumer, nil + } + + partitionID := int32(0) + partitionReader, err := NewReader(kafkaCfg, partitionID, "test-consumer-group", consumerFactory, log.NewNopLogger(), prometheus.NewRegistry()) + require.NoError(t, err) + producer, err := kafka.NewWriterClient(kafkaCfg, 100, log.NewNopLogger(), prometheus.NewRegistry()) + require.NoError(t, err) + + // Init the client: This usually happens in "start" but we want to manage our own lifecycle for this test. + partitionReader.client, err = kafka.NewReaderClient(kafkaCfg, nil, log.NewNopLogger(), + kgo.ConsumePartitions(map[string]map[int32]kgo.Offset{ + kafkaCfg.Topic: {partitionID: kgo.NewOffset().AtStart()}, + }), + ) + require.NoError(t, err) + + stream := logproto.Stream{ + Labels: labels.FromStrings("foo", "bar").String(), + Entries: []logproto.Entry{{Timestamp: time.Now(), Line: "test"}}, + } + + records, err := kafka.Encode(partitionID, "test-tenant", stream, 10<<20) + require.NoError(t, err) + require.Len(t, records, 1) + + ctx, cancel := context.WithDeadlineCause(context.Background(), time.Now().Add(10*time.Second), fmt.Errorf("test unexpectedly deadlocked")) + recordsChan := make(chan []Record) + wait := consumer.Start(ctx, recordsChan) + + targetLag := time.Second + + i := -1 + iterations := 5 + producer.ProduceSync(context.Background(), records...) + // timeSince acts as a hook for when we check if we've honoured the lag or not. We modify it to respond "no" initially, to force a re-loop, and then "yes" after `iterations`. + // We also inject a new kafka record each time so there is more to consume. + timeSince := func(time.Time) time.Duration { + i++ + if i < iterations { + producer.ProduceSync(context.Background(), records...) + return targetLag + 1 + } + return targetLag - 1 + } + + _, err = partitionReader.processNextFetchesUntilLagHonored(ctx, targetLag, log.NewNopLogger(), recordsChan, timeSince) + assert.NoError(t, err) + + // Wait to process all the records + cancel() + wait() + + close(recordsChan) + close(consumer.recordsChan) + recordsCount := 0 + for receivedRecords := range consumer.recordsChan { + recordsCount += len(receivedRecords) + } + // We expect to have processed all the records, including initial + one per iteration. + assert.Equal(t, iterations+1, recordsCount) +} From 8438d415931f0a3763d551eb36c3d9f476f70713 Mon Sep 17 00:00:00 2001 From: Cyril Tovena Date: Fri, 4 Oct 2024 15:07:17 +0200 Subject: [PATCH 13/26] fix(distributor): validate partition ring is kafka is enabled (#14303) --- pkg/loki/modules.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/loki/modules.go b/pkg/loki/modules.go index 4c718722a509f..d9c111cc86493 100644 --- a/pkg/loki/modules.go +++ b/pkg/loki/modules.go @@ -322,6 +322,10 @@ func (t *Loki) initTenantConfigs() (_ services.Service, err error) { func (t *Loki) initDistributor() (services.Service, error) { t.Cfg.Distributor.KafkaConfig = t.Cfg.KafkaConfig + if t.Cfg.Distributor.KafkaEnabled && !t.Cfg.Ingester.KafkaIngestion.Enabled { + return nil, errors.New("kafka is enabled in distributor but not in ingester") + } + var err error logger := log.With(util_log.Logger, "component", "distributor") t.distributor, err = distributor.New( From 833bf0def6a07e2f58996f54b4b983858750e3e3 Mon Sep 17 00:00:00 2001 From: Christian Haudum Date: Fri, 4 Oct 2024 17:44:27 +0200 Subject: [PATCH 14/26] fix(logql): Fix panic in json parsing when using empty array index (#14393) This commit fixes a panic that occurs with the following json parser expression: ``` | json keys[""] ``` when the log line is the following: ```json {"keys": ["a", "b", "c"]} ``` Signed-off-by: Christian Haudum --- go.mod | 2 +- go.sum | 4 ++-- pkg/logql/log/parser_test.go | 20 +++++++++++++++++++ .../github.com/grafana/jsonparser/parser.go | 8 ++------ vendor/modules.txt | 2 +- 5 files changed, 26 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index 32cae2cba59dc..c003fd8813f93 100644 --- a/go.mod +++ b/go.mod @@ -125,7 +125,7 @@ require ( github.com/efficientgo/core v1.0.0-rc.3 github.com/fsnotify/fsnotify v1.7.0 github.com/gogo/googleapis v1.4.1 - github.com/grafana/jsonparser v0.0.0-20240425183733-ea80629e1a32 + github.com/grafana/jsonparser v0.0.0-20241004153430-023329977675 github.com/grafana/loki/pkg/push v0.0.0-20240924133635-758364c7775f github.com/hashicorp/golang-lru/v2 v2.0.7 github.com/hashicorp/raft v1.7.1 diff --git a/go.sum b/go.sum index 00afdeb6e1231..ce616ba23be67 100644 --- a/go.sum +++ b/go.sum @@ -1052,8 +1052,8 @@ github.com/grafana/gocql v0.0.0-20200605141915-ba5dc39ece85 h1:xLuzPoOzdfNb/RF/I github.com/grafana/gocql v0.0.0-20200605141915-ba5dc39ece85/go.mod h1:crI9WX6p0IhrqB+DqIUHulRW853PaNFf7o4UprV//3I= github.com/grafana/gomemcache v0.0.0-20240229205252-cd6a66d6fb56 h1:X8IKQ0wu40wpvYcKfBcc5T4QnhdQjUhtUtB/1CY89lE= github.com/grafana/gomemcache v0.0.0-20240229205252-cd6a66d6fb56/go.mod h1:PGk3RjYHpxMM8HFPhKKo+vve3DdlPUELZLSDEFehPuU= -github.com/grafana/jsonparser v0.0.0-20240425183733-ea80629e1a32 h1:NznuPwItog+rwdVg8hAuGKP29ndRSzJAwhxKldkP8oQ= -github.com/grafana/jsonparser v0.0.0-20240425183733-ea80629e1a32/go.mod h1:796sq+UcONnSlzA3RtlBZ+b/hrerkZXiEmO8oMjyRwY= +github.com/grafana/jsonparser v0.0.0-20241004153430-023329977675 h1:U94jQ2TQr1m3HNyE8efSdyaBbDrdPaWImXyenuKZ/nw= +github.com/grafana/jsonparser v0.0.0-20241004153430-023329977675/go.mod h1:796sq+UcONnSlzA3RtlBZ+b/hrerkZXiEmO8oMjyRwY= github.com/grafana/memberlist v0.3.1-0.20220714140823-09ffed8adbbe h1:yIXAAbLswn7VNWBIvM71O2QsgfgW9fRXZNR0DXe6pDU= github.com/grafana/memberlist v0.3.1-0.20220714140823-09ffed8adbbe/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= github.com/grafana/pyroscope-go/godeltaprof v0.1.8 h1:iwOtYXeeVSAeYefJNaxDytgjKtUuKQbJqgAIjlnicKg= diff --git a/pkg/logql/log/parser_test.go b/pkg/logql/log/parser_test.go index 28989b7cb5fe8..fd08467af8586 100644 --- a/pkg/logql/log/parser_test.go +++ b/pkg/logql/log/parser_test.go @@ -368,6 +368,26 @@ func TestJSONExpressionParser(t *testing.T) { labels.FromStrings("param", "1"), NoParserHints(), }, + { + "object element not present", + testLine, + []LabelExtractionExpr{ + NewLabelExtractionExpr("undefined", `pod[""]`), + }, + labels.EmptyLabels(), + labels.FromStrings("undefined", ""), + NoParserHints(), + }, + { + "accessing invalid array index", + testLine, + []LabelExtractionExpr{ + NewLabelExtractionExpr("param", `pod.deployment.params[""]`), + }, + labels.EmptyLabels(), + labels.FromStrings("param", ""), + NoParserHints(), + }, { "array string element", testLine, diff --git a/vendor/github.com/grafana/jsonparser/parser.go b/vendor/github.com/grafana/jsonparser/parser.go index 5df2a463dcee3..9958ab4ee531d 100644 --- a/vendor/github.com/grafana/jsonparser/parser.go +++ b/vendor/github.com/grafana/jsonparser/parser.go @@ -512,10 +512,10 @@ func EachKey(data []byte, cb func(int, []byte, ValueType, error), paths ...[]str } for pi, p := range paths { - if len(p) < level+1 || pathFlags[pi] || p[level][0] != '[' || !sameTree(p, pathsBuf[:level]) { + if len(p) < level+1 || pathFlags[pi] || p[level] == "" || p[level][0] != '[' || !sameTree(p, pathsBuf[:level]) { continue } - if len(p[level]) >= 2 { + if len(p[level]) > 2 { aIdx, _ := strconv.Atoi(p[level][1 : len(p[level])-1]) arrIdxFlags[aIdx] = x pIdxFlags[pi] = true @@ -712,12 +712,10 @@ func WriteToBuffer(buffer []byte, str string) int { } /* - Del - Receives existing data structure, path to delete. Returns: `data` - return modified data - */ func Delete(data []byte, keys ...string) []byte { lk := len(keys) @@ -798,13 +796,11 @@ func Delete(data []byte, keys ...string) []byte { } /* - Set - Receives existing data structure, path to set, and data to set at that key. Returns: `value` - modified byte array `err` - On any parsing error - */ func Set(data []byte, setValue []byte, keys ...string) (value []byte, err error) { // ensure keys are set diff --git a/vendor/modules.txt b/vendor/modules.txt index 4e50c0c98bded..bc92b7462c8e2 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1037,7 +1037,7 @@ github.com/grafana/go-gelf/v2/gelf # github.com/grafana/gomemcache v0.0.0-20240229205252-cd6a66d6fb56 ## explicit; go 1.18 github.com/grafana/gomemcache/memcache -# github.com/grafana/jsonparser v0.0.0-20240425183733-ea80629e1a32 +# github.com/grafana/jsonparser v0.0.0-20241004153430-023329977675 ## explicit; go 1.13 github.com/grafana/jsonparser # github.com/grafana/loki/pkg/push v0.0.0-20240924133635-758364c7775f => ./pkg/push From b5462b66395ec165a8583f1ea879835dd6894804 Mon Sep 17 00:00:00 2001 From: Trevor Whitney Date: Fri, 4 Oct 2024 10:38:36 -0600 Subject: [PATCH 15/26] chore: remove copied loop vars (#14383) --- .golangci.yml | 2 +- clients/pkg/logentry/metric/counters_test.go | 1 - clients/pkg/logentry/stages/decolorize_test.go | 2 -- clients/pkg/logentry/stages/eventlogmessage_test.go | 4 ---- clients/pkg/logentry/stages/extensions_test.go | 2 -- clients/pkg/logentry/stages/json_test.go | 4 ---- clients/pkg/logentry/stages/labels_test.go | 2 -- clients/pkg/logentry/stages/logfmt_test.go | 4 ---- clients/pkg/logentry/stages/metrics_test.go | 1 - clients/pkg/logentry/stages/output_test.go | 2 -- clients/pkg/logentry/stages/pipeline_test.go | 3 --- clients/pkg/logentry/stages/regex_test.go | 4 ---- clients/pkg/logentry/stages/replace_test.go | 3 --- clients/pkg/logentry/stages/template_test.go | 2 -- clients/pkg/logentry/stages/tenant_test.go | 4 ---- clients/pkg/logentry/stages/timestamp_test.go | 4 ---- clients/pkg/logentry/stages/util_test.go | 4 ---- clients/pkg/promtail/client/batch_test.go | 4 ---- clients/pkg/promtail/client/config_test.go | 1 - clients/pkg/promtail/config/config_test.go | 1 - .../promtail/targets/kafka/target_syncer_test.go | 1 - clients/pkg/promtail/targets/kafka/topics_test.go | 2 -- .../promtail/targets/syslog/syslogtarget_test.go | 3 --- pkg/bloombuild/builder/batch_test.go | 2 -- pkg/chunkenc/memchunk_test.go | 13 ------------- pkg/compactor/retention/retention_test.go | 2 -- pkg/compactor/table_test.go | 1 - pkg/compression/pool_test.go | 1 - pkg/distributor/distributor_test.go | 4 ---- pkg/distributor/ingestion_rate_strategy_test.go | 2 -- pkg/ingester/index/bitprefix_test.go | 1 - pkg/ingester/index/index_test.go | 1 - pkg/ingester/limiter_test.go | 4 ---- pkg/iter/entry_iterator_test.go | 2 -- pkg/logcli/output/default_test.go | 4 ---- pkg/logcli/output/jsonl_test.go | 2 -- pkg/logcli/output/raw_test.go | 2 -- pkg/logcli/query/query_test.go | 2 -- pkg/loghttp/params.go | 2 +- pkg/loghttp/params_test.go | 6 ------ pkg/loghttp/query_test.go | 1 - pkg/logql/engine_test.go | 4 ---- pkg/logql/log/parser_hints_test.go | 1 - pkg/logql/log/parser_test.go | 1 - pkg/logql/log/pattern/lexer_test.go | 1 - pkg/logql/log/pattern/parser_test.go | 1 - pkg/logql/log/pattern/pattern_test.go | 1 - pkg/logql/rangemapper_test.go | 3 --- pkg/logql/sketch/topk_slow_test.go | 1 - pkg/logql/syntax/ast_test.go | 2 -- pkg/logql/syntax/walk_test.go | 2 -- pkg/loki/modules.go | 2 -- pkg/pattern/drain/drain_test.go | 3 --- pkg/pattern/ingester_querier.go | 2 -- pkg/pattern/iter/iterator_test.go | 1 - pkg/pattern/iter/merge_test.go | 1 - pkg/querier-rf1/wal/chunks.go | 2 -- pkg/querier-rf1/wal/querier.go | 2 -- pkg/querier/ingester_querier_test.go | 4 ---- pkg/querier/querier_test.go | 2 -- pkg/querier/queryrange/codec_test.go | 1 - pkg/querier/queryrange/prometheus_test.go | 1 - .../queryrange/queryrangebase/promql_test.go | 1 - pkg/querier/queryrange/split_by_range_test.go | 2 -- pkg/queue/queue_test.go | 2 -- pkg/ruler/base/ruler_test.go | 1 - pkg/storage/batch_test.go | 3 --- pkg/storage/bucket/azure/config_test.go | 2 -- pkg/storage/bucket/client_test.go | 2 -- pkg/storage/bucket/http/config_test.go | 2 -- pkg/storage/bucket/s3/config_test.go | 2 -- .../chunk/client/aws/dynamodb_index_reader.go | 3 +-- .../chunk/client/aws/s3_storage_client_test.go | 1 - .../chunk/client/azure/blob_storage_client_test.go | 1 - .../chunk/client/gcp/gcs_object_client_test.go | 1 - .../client/openstack/swift_object_client_test.go | 1 - pkg/storage/config/schema_config_test.go | 2 -- pkg/storage/lazy_chunk_test.go | 2 -- pkg/storage/store.go | 1 - pkg/storage/store_test.go | 1 - .../stores/shipper/bloomshipper/fetcher_test.go | 1 - .../boltdb/compactor/compacted_index_test.go | 1 - .../indexshipper/boltdb/compactor/iterator_test.go | 2 -- .../boltdb/compactor/table_compactor_test.go | 1 - .../indexshipper/downloads/table_manager_test.go | 1 - pkg/storage/wal/segment.go | 2 -- pkg/storage/wal/segment_test.go | 1 - pkg/util/marshal/marshal_test.go | 1 - pkg/util/query_string_builder_test.go | 2 -- pkg/util/string_test.go | 2 -- tools/querytee/proxy_endpoint.go | 3 --- tools/querytee/proxy_endpoint_test.go | 2 -- 92 files changed, 3 insertions(+), 196 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index ae10a6ba210b9..bc607cd1bbc1a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -63,7 +63,7 @@ linters: - govet - typecheck - depguard - - exportloopref + - copyloopvar - gofmt - goimports - gosimple diff --git a/clients/pkg/logentry/metric/counters_test.go b/clients/pkg/logentry/metric/counters_test.go index 49b38737d5684..375f8fbd835b5 100644 --- a/clients/pkg/logentry/metric/counters_test.go +++ b/clients/pkg/logentry/metric/counters_test.go @@ -78,7 +78,6 @@ func Test_validateCounterConfig(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() err := validateCounterConfig(&tt.config) diff --git a/clients/pkg/logentry/stages/decolorize_test.go b/clients/pkg/logentry/stages/decolorize_test.go index 029cd74c1c1e3..7e7d0c88062b5 100644 --- a/clients/pkg/logentry/stages/decolorize_test.go +++ b/clients/pkg/logentry/stages/decolorize_test.go @@ -36,8 +36,6 @@ func TestPipeline_Decolorize(t *testing.T) { } for testName, testData := range tests { - testData := testData - t.Run(testName, func(t *testing.T) { t.Parallel() diff --git a/clients/pkg/logentry/stages/eventlogmessage_test.go b/clients/pkg/logentry/stages/eventlogmessage_test.go index ed4bedccfc70c..99ab571699340 100644 --- a/clients/pkg/logentry/stages/eventlogmessage_test.go +++ b/clients/pkg/logentry/stages/eventlogmessage_test.go @@ -106,7 +106,6 @@ func TestEventLogMessage_simple(t *testing.T) { } for testName, testData := range tests { - testData := testData testData.extractedValues[testData.sourcekey] = testData.msgdata t.Run(testName, func(t *testing.T) { @@ -151,7 +150,6 @@ func TestEventLogMessageConfig_validate(t *testing.T) { }, } for tName, tt := range tests { - tt := tt t.Run(tName, func(t *testing.T) { _, err := newEventLogMessageStage(util_log.Logger, tt.config) if tt.err != nil { @@ -262,7 +260,6 @@ func TestEventLogMessage_Real(t *testing.T) { } for testName, testData := range tests { - testData := testData testData.extractedValues[testData.sourcekey] = testData.msgdata t.Run(testName, func(t *testing.T) { @@ -318,7 +315,6 @@ func TestEventLogMessage_invalid(t *testing.T) { } for testName, testData := range tests { - testData := testData testData.extractedValues[testData.sourcekey] = testData.msgdata t.Run(testName, func(t *testing.T) { diff --git a/clients/pkg/logentry/stages/extensions_test.go b/clients/pkg/logentry/stages/extensions_test.go index 0d03acd3fe3dd..2cbe411c2a032 100644 --- a/clients/pkg/logentry/stages/extensions_test.go +++ b/clients/pkg/logentry/stages/extensions_test.go @@ -65,7 +65,6 @@ func TestNewDocker(t *testing.T) { } for tName, tt := range tests { - tt := tt t.Run(tName, func(t *testing.T) { t.Parallel() p, err := NewDocker(util_log.Logger, prometheus.DefaultRegisterer) @@ -268,7 +267,6 @@ func TestNewCri(t *testing.T) { } for tName, tt := range tests { - tt := tt t.Run(tName, func(t *testing.T) { t.Parallel() cfg := map[string]interface{}{} diff --git a/clients/pkg/logentry/stages/json_test.go b/clients/pkg/logentry/stages/json_test.go index 1764387253fb1..9e0d2dffaea4c 100644 --- a/clients/pkg/logentry/stages/json_test.go +++ b/clients/pkg/logentry/stages/json_test.go @@ -78,8 +78,6 @@ func TestPipeline_JSON(t *testing.T) { } for testName, testData := range tests { - testData := testData - t.Run(testName, func(t *testing.T) { t.Parallel() @@ -179,7 +177,6 @@ func TestJSONConfig_validate(t *testing.T) { }, } for tName, tt := range tests { - tt := tt t.Run(tName, func(t *testing.T) { c, err := parseJSONConfig(tt.config) assert.NoError(t, err, "failed to create config: %s", err) @@ -339,7 +336,6 @@ func TestJSONParser_Parse(t *testing.T) { }, } for tName, tt := range tests { - tt := tt t.Run(tName, func(t *testing.T) { t.Parallel() p, err := New(util_log.Logger, nil, StageTypeJSON, tt.config, nil) diff --git a/clients/pkg/logentry/stages/labels_test.go b/clients/pkg/logentry/stages/labels_test.go index 27747d8032edd..f422632115245 100644 --- a/clients/pkg/logentry/stages/labels_test.go +++ b/clients/pkg/logentry/stages/labels_test.go @@ -115,7 +115,6 @@ func TestLabels(t *testing.T) { }, } for name, test := range tests { - test := test t.Run(name, func(t *testing.T) { t.Parallel() err := validateLabelsConfig(test.config) @@ -176,7 +175,6 @@ func TestLabelStage_Process(t *testing.T) { }, } for name, test := range tests { - test := test t.Run(name, func(t *testing.T) { t.Parallel() st, err := newLabelStage(util_log.Logger, test.config) diff --git a/clients/pkg/logentry/stages/logfmt_test.go b/clients/pkg/logentry/stages/logfmt_test.go index ed60d8770d014..1406aa080cf88 100644 --- a/clients/pkg/logentry/stages/logfmt_test.go +++ b/clients/pkg/logentry/stages/logfmt_test.go @@ -64,8 +64,6 @@ func TestPipeline_Logfmt(t *testing.T) { } for testName, testData := range tests { - testData := testData - t.Run(testName, func(t *testing.T) { t.Parallel() @@ -153,7 +151,6 @@ func TestLogfmtConfig_validate(t *testing.T) { }, } for tName, tt := range tests { - tt := tt t.Run(tName, func(t *testing.T) { c, err := parseLogfmtConfig(tt.config) assert.NoError(t, err) @@ -281,7 +278,6 @@ func TestLogfmtParser_Parse(t *testing.T) { }, } for tName, tt := range tests { - tt := tt t.Run(tName, func(t *testing.T) { t.Parallel() p, err := New(util_log.Logger, nil, StageTypeLogfmt, tt.config, nil) diff --git a/clients/pkg/logentry/stages/metrics_test.go b/clients/pkg/logentry/stages/metrics_test.go index 563ee9eab6643..133220ea6d5d8 100644 --- a/clients/pkg/logentry/stages/metrics_test.go +++ b/clients/pkg/logentry/stages/metrics_test.go @@ -415,7 +415,6 @@ func TestValidateMetricsConfig(t *testing.T) { } for name, test := range tests { - test := test t.Run(name, func(t *testing.T) { t.Parallel() err := validateMetricsConfig(test.config) diff --git a/clients/pkg/logentry/stages/output_test.go b/clients/pkg/logentry/stages/output_test.go index dc6aac54f0b93..b69399e1dbce1 100644 --- a/clients/pkg/logentry/stages/output_test.go +++ b/clients/pkg/logentry/stages/output_test.go @@ -86,7 +86,6 @@ func TestOutputValidation(t *testing.T) { }, } for name, test := range tests { - test := test t.Run(name, func(t *testing.T) { t.Parallel() err := validateOutputConfig(test.config) @@ -120,7 +119,6 @@ func TestOutputStage_Process(t *testing.T) { }, } for name, test := range tests { - test := test t.Run(name, func(t *testing.T) { t.Parallel() st, err := newOutputStage(util_log.Logger, test.config) diff --git a/clients/pkg/logentry/stages/pipeline_test.go b/clients/pkg/logentry/stages/pipeline_test.go index 2649de6a83441..356955be032c3 100644 --- a/clients/pkg/logentry/stages/pipeline_test.go +++ b/clients/pkg/logentry/stages/pipeline_test.go @@ -194,8 +194,6 @@ func TestPipeline_Process(t *testing.T) { } for tName, tt := range tests { - tt := tt - t.Run(tName, func(t *testing.T) { var config map[string]interface{} @@ -304,7 +302,6 @@ func TestPipeline_Wrap(t *testing.T) { } for tName, tt := range tests { - tt := tt t.Run(tName, func(t *testing.T) { t.Parallel() c := fake.New(func() {}) diff --git a/clients/pkg/logentry/stages/regex_test.go b/clients/pkg/logentry/stages/regex_test.go index f7fa5390a1959..362c5990575cb 100644 --- a/clients/pkg/logentry/stages/regex_test.go +++ b/clients/pkg/logentry/stages/regex_test.go @@ -102,8 +102,6 @@ func TestPipeline_Regex(t *testing.T) { } for testName, testData := range tests { - testData := testData - t.Run(testName, func(t *testing.T) { t.Parallel() @@ -204,7 +202,6 @@ func TestRegexConfig_validate(t *testing.T) { }, } for tName, tt := range tests { - tt := tt t.Run(tName, func(t *testing.T) { c, err := parseRegexConfig(tt.config) if err != nil { @@ -322,7 +319,6 @@ func TestRegexParser_Parse(t *testing.T) { }, } for tName, tt := range tests { - tt := tt t.Run(tName, func(t *testing.T) { t.Parallel() p, err := New(util_log.Logger, nil, StageTypeRegex, tt.config, nil) diff --git a/clients/pkg/logentry/stages/replace_test.go b/clients/pkg/logentry/stages/replace_test.go index 87bb3eecb898a..6e583f19b8b06 100644 --- a/clients/pkg/logentry/stages/replace_test.go +++ b/clients/pkg/logentry/stages/replace_test.go @@ -161,8 +161,6 @@ func TestPipeline_Replace(t *testing.T) { } for testName, testData := range tests { - testData := testData - t.Run(testName, func(t *testing.T) { t.Parallel() @@ -252,7 +250,6 @@ func TestReplaceConfig_validate(t *testing.T) { }, } for tName, tt := range tests { - tt := tt t.Run(tName, func(t *testing.T) { c, err := parseReplaceConfig(tt.config) if err != nil { diff --git a/clients/pkg/logentry/stages/template_test.go b/clients/pkg/logentry/stages/template_test.go index 7977c87ffee66..15a0a2a1f78fb 100644 --- a/clients/pkg/logentry/stages/template_test.go +++ b/clients/pkg/logentry/stages/template_test.go @@ -105,7 +105,6 @@ func TestTemplateValidation(t *testing.T) { }, } for name, test := range tests { - test := test t.Run(name, func(t *testing.T) { t.Parallel() _, err := validateTemplateConfig(test.config) @@ -375,7 +374,6 @@ func TestTemplateStage_Process(t *testing.T) { }, } for name, test := range tests { - test := test t.Run(name, func(t *testing.T) { t.Parallel() st, err := newTemplateStage(util_log.Logger, test.config) diff --git a/clients/pkg/logentry/stages/tenant_test.go b/clients/pkg/logentry/stages/tenant_test.go index 8eee783d47ddf..e524315818068 100644 --- a/clients/pkg/logentry/stages/tenant_test.go +++ b/clients/pkg/logentry/stages/tenant_test.go @@ -126,8 +126,6 @@ func TestTenantStage_Validation(t *testing.T) { } for testName, testData := range tests { - testData := testData - t.Run(testName, func(t *testing.T) { stage, err := newTenantStage(util_log.Logger, testData.config) @@ -202,8 +200,6 @@ func TestTenantStage_Process(t *testing.T) { } for testName, testData := range tests { - testData := testData - t.Run(testName, func(t *testing.T) { stage, err := newTenantStage(util_log.Logger, testData.config) require.NoError(t, err) diff --git a/clients/pkg/logentry/stages/timestamp_test.go b/clients/pkg/logentry/stages/timestamp_test.go index f3f23dcfcebab..2e0ea0c054da3 100644 --- a/clients/pkg/logentry/stages/timestamp_test.go +++ b/clients/pkg/logentry/stages/timestamp_test.go @@ -174,7 +174,6 @@ func TestTimestampValidation(t *testing.T) { }, } for name, test := range tests { - test := test t.Run(name, func(t *testing.T) { t.Parallel() parser, err := validateTimestampConfig(test.config) @@ -295,7 +294,6 @@ func TestTimestampStage_Process(t *testing.T) { }, } for name, test := range tests { - test := test t.Run(name, func(t *testing.T) { t.Parallel() st, err := newTimestampStage(util_log.Logger, test.config) @@ -431,8 +429,6 @@ func TestTimestampStage_ProcessActionOnFailure(t *testing.T) { } for testName, testData := range tests { - testData := testData - t.Run(testName, func(t *testing.T) { t.Parallel() diff --git a/clients/pkg/logentry/stages/util_test.go b/clients/pkg/logentry/stages/util_test.go index 5ce0ae9a7f93a..863b43533975b 100644 --- a/clients/pkg/logentry/stages/util_test.go +++ b/clients/pkg/logentry/stages/util_test.go @@ -145,8 +145,6 @@ func TestConvertDateLayout(t *testing.T) { } for testName, testData := range tests { - testData := testData - t.Run(testName, func(t *testing.T) { t.Parallel() @@ -224,8 +222,6 @@ func TestParseTimestampWithoutYear(t *testing.T) { } for testName, testData := range tests { - testData := testData - t.Run(testName, func(t *testing.T) { t.Parallel() diff --git a/clients/pkg/promtail/client/batch_test.go b/clients/pkg/promtail/client/batch_test.go index ec92fbc1c4225..9afbe4e457ce7 100644 --- a/clients/pkg/promtail/client/batch_test.go +++ b/clients/pkg/promtail/client/batch_test.go @@ -73,8 +73,6 @@ func TestBatch_add(t *testing.T) { } for testName, testData := range tests { - testData := testData - t.Run(testName, func(t *testing.T) { b := newBatch(0) @@ -123,8 +121,6 @@ func TestBatch_encode(t *testing.T) { } for testName, testData := range tests { - testData := testData - t.Run(testName, func(t *testing.T) { t.Parallel() diff --git a/clients/pkg/promtail/client/config_test.go b/clients/pkg/promtail/client/config_test.go index 7a1a3fb518b5f..cb1476f1a2a0a 100644 --- a/clients/pkg/promtail/client/config_test.go +++ b/clients/pkg/promtail/client/config_test.go @@ -97,7 +97,6 @@ func Test_Config(t *testing.T) { }, } for _, tc := range tests { - tc := tc err := yaml.Unmarshal([]byte(tc.configValues), &clientConfig) if tc.expectedErr != nil { diff --git a/clients/pkg/promtail/config/config_test.go b/clients/pkg/promtail/config/config_test.go index a812dd984abc7..fe197044b683f 100644 --- a/clients/pkg/promtail/config/config_test.go +++ b/clients/pkg/promtail/config/config_test.go @@ -175,7 +175,6 @@ func TestConfig_Setup(t *testing.T) { }, }, } { - tt := tt t.Run(fmt.Sprintf("%d", i), func(t *testing.T) { tt.in.Setup(log.NewNopLogger()) require.Equal(t, tt.expected, tt.in) diff --git a/clients/pkg/promtail/targets/kafka/target_syncer_test.go b/clients/pkg/promtail/targets/kafka/target_syncer_test.go index f450a10d67f36..9a279c2a3670b 100644 --- a/clients/pkg/promtail/targets/kafka/target_syncer_test.go +++ b/clients/pkg/promtail/targets/kafka/target_syncer_test.go @@ -195,7 +195,6 @@ func Test_validateConfig(t *testing.T) { } for i, tt := range tests { - tt := tt t.Run(fmt.Sprintf("%d", i), func(t *testing.T) { err := validateConfig(tt.cfg) if (err != nil) != tt.wantErr { diff --git a/clients/pkg/promtail/targets/kafka/topics_test.go b/clients/pkg/promtail/targets/kafka/topics_test.go index 447a8a0a65afc..2bc9b4637146e 100644 --- a/clients/pkg/promtail/targets/kafka/topics_test.go +++ b/clients/pkg/promtail/targets/kafka/topics_test.go @@ -49,7 +49,6 @@ func Test_NewTopicManager(t *testing.T) { false, }, } { - tt := tt t.Run(strings.Join(tt.in, ","), func(t *testing.T) { t.Parallel() _, err := newTopicManager(&mockKafkaClient{}, tt.in) @@ -86,7 +85,6 @@ func Test_Topics(t *testing.T) { false, }, } { - tt := tt t.Run("", func(t *testing.T) { t.Parallel() diff --git a/clients/pkg/promtail/targets/syslog/syslogtarget_test.go b/clients/pkg/promtail/targets/syslog/syslogtarget_test.go index aedb78d6979d2..7f379320f0c61 100644 --- a/clients/pkg/promtail/targets/syslog/syslogtarget_test.go +++ b/clients/pkg/promtail/targets/syslog/syslogtarget_test.go @@ -305,7 +305,6 @@ func Benchmark_SyslogTarget(b *testing.B) { {"tcp", protocolTCP, fmtOctetCounting}, {"udp", protocolUDP, fmtOctetCounting}, } { - tt := tt b.Run(tt.name, func(b *testing.B) { client := fake.New(func() {}) @@ -366,7 +365,6 @@ func TestSyslogTarget(t *testing.T) { {"udp newline separated", protocolUDP, fmtNewline}, {"udp octetcounting", protocolUDP, fmtOctetCounting}, } { - tt := tt t.Run(tt.name, func(t *testing.T) { w := log.NewSyncWriter(os.Stderr) logger := log.NewLogfmtLogger(w) @@ -481,7 +479,6 @@ func TestSyslogTarget_RFC5424Messages(t *testing.T) { {"tcp newline separated", protocolTCP, fmtNewline}, {"tcp octetcounting", protocolTCP, fmtOctetCounting}, } { - tt := tt t.Run(tt.name, func(t *testing.T) { w := log.NewSyncWriter(os.Stderr) logger := log.NewLogfmtLogger(w) diff --git a/pkg/bloombuild/builder/batch_test.go b/pkg/bloombuild/builder/batch_test.go index e0fe37a0e448f..608ab0807c9ec 100644 --- a/pkg/bloombuild/builder/batch_test.go +++ b/pkg/bloombuild/builder/batch_test.go @@ -106,7 +106,6 @@ func TestBatchedLoader(t *testing.T) { inputs: [][]int{{0}}, }, } { - tc := tc t.Run(tc.desc, func(t *testing.T) { fetchers := make([]Fetcher[int, int], 0, len(tc.inputs)) for range tc.inputs { @@ -193,7 +192,6 @@ func TestOverlappingBlocksIter(t *testing.T) { exp: 2, }, } { - tc := tc t.Run(tc.desc, func(t *testing.T) { it := overlappingBlocksIter(tc.inp) var overlapping [][]bloomshipper.BlockRef diff --git a/pkg/chunkenc/memchunk_test.go b/pkg/chunkenc/memchunk_test.go index 24d4ab2d2c2cd..c8795fa190bba 100644 --- a/pkg/chunkenc/memchunk_test.go +++ b/pkg/chunkenc/memchunk_test.go @@ -86,7 +86,6 @@ const ( func TestBlocksInclusive(t *testing.T) { for _, enc := range testEncodings { - enc := enc for _, format := range allPossibleFormats { chunkfmt, headfmt := format.chunkFormat, format.headBlockFmt chk := NewMemChunk(chunkfmt, enc, headfmt, testBlockSize, testTargetSize) @@ -105,7 +104,6 @@ func TestBlocksInclusive(t *testing.T) { func TestBlock(t *testing.T) { for _, enc := range testEncodings { - enc := enc for _, format := range allPossibleFormats { chunkFormat, headBlockFmt := format.chunkFormat, format.headBlockFmt t.Run(fmt.Sprintf("encoding:%v chunkFormat:%v headBlockFmt:%v", enc, chunkFormat, headBlockFmt), func(t *testing.T) { @@ -260,7 +258,6 @@ func TestBlock(t *testing.T) { func TestCorruptChunk(t *testing.T) { for _, enc := range testEncodings { - enc := enc for _, format := range allPossibleFormats { chunkfmt, headfmt := format.chunkFormat, format.headBlockFmt @@ -337,7 +334,6 @@ func TestReadFormatV1(t *testing.T) { func TestRoundtripV2(t *testing.T) { for _, testData := range allPossibleFormats { for _, enc := range testEncodings { - enc := enc t.Run(testNameWithFormats(enc, testData.chunkFormat, testData.headBlockFmt), func(t *testing.T) { t.Parallel() @@ -397,7 +393,6 @@ func testNameWithFormats(enc compression.Codec, chunkFormat byte, headBlockFmt H func TestRoundtripV3(t *testing.T) { for _, enc := range testEncodings { - enc := enc for _, format := range allPossibleFormats { chunkfmt, headfmt := format.chunkFormat, format.headBlockFmt t.Run(fmt.Sprintf("%v-%v", format, enc), func(t *testing.T) { @@ -422,10 +417,8 @@ func TestRoundtripV3(t *testing.T) { func TestSerialization(t *testing.T) { for _, testData := range allPossibleFormats { for _, enc := range testEncodings { - enc := enc // run tests with and without structured metadata since it is optional for _, appendWithStructuredMetadata := range []bool{false, true} { - appendWithStructuredMetadata := appendWithStructuredMetadata testName := testNameWithFormats(enc, testData.chunkFormat, testData.headBlockFmt) if appendWithStructuredMetadata { testName = fmt.Sprintf("%s - append structured metadata", testName) @@ -511,7 +504,6 @@ func TestSerialization(t *testing.T) { func TestChunkFilling(t *testing.T) { for _, testData := range allPossibleFormats { for _, enc := range testEncodings { - enc := enc t.Run(testNameWithFormats(enc, testData.chunkFormat, testData.headBlockFmt), func(t *testing.T) { t.Parallel() @@ -676,8 +668,6 @@ func TestMemChunk_AppendOutOfOrder(t *testing.T) { for _, f := range HeadBlockFmts { for testName, tester := range tests { - tester := tester - t.Run(testName, func(t *testing.T) { t.Parallel() @@ -1117,7 +1107,6 @@ func TestMemChunk_IteratorBounds(t *testing.T) { t.Run( fmt.Sprintf("mint:%d,maxt:%d,direction:%s", tt.mint.UnixNano(), tt.maxt.UnixNano(), tt.direction), func(t *testing.T) { - tt := tt c := createChunk() noopStreamPipeline := log.NewNoopPipeline().ForStream(labels.Labels{}) @@ -1143,7 +1132,6 @@ func TestMemChunk_IteratorBounds(t *testing.T) { func TestMemchunkLongLine(t *testing.T) { for _, enc := range testEncodings { - enc := enc t.Run(enc.String(), func(t *testing.T) { t.Parallel() @@ -1777,7 +1765,6 @@ func TestMemChunk_SpaceFor(t *testing.T) { func TestMemChunk_IteratorWithStructuredMetadata(t *testing.T) { for _, enc := range testEncodings { - enc := enc t.Run(enc.String(), func(t *testing.T) { streamLabels := labels.Labels{ {Name: "job", Value: "fake"}, diff --git a/pkg/compactor/retention/retention_test.go b/pkg/compactor/retention/retention_test.go index b68d9e39f42c8..cdc7ef61dbc9c 100644 --- a/pkg/compactor/retention/retention_test.go +++ b/pkg/compactor/retention/retention_test.go @@ -154,7 +154,6 @@ func Test_Retention(t *testing.T) { }, }, } { - tt := tt t.Run(tt.name, func(t *testing.T) { // insert in the store. var ( @@ -566,7 +565,6 @@ func TestChunkRewriter(t *testing.T) { }, }, } { - tt := tt t.Run(tt.name, func(t *testing.T) { store := newTestStore(t) require.NoError(t, store.Put(context.TODO(), []chunk.Chunk{tt.chunk})) diff --git a/pkg/compactor/table_test.go b/pkg/compactor/table_test.go index b4f71bbc93956..c659bda051f31 100644 --- a/pkg/compactor/table_test.go +++ b/pkg/compactor/table_test.go @@ -350,7 +350,6 @@ func TestTable_CompactionRetention(t *testing.T) { }), }, } { - tt := tt commonDBsConfig := IndexesConfig{ NumCompactedFiles: tt.dbsSetup.numCompactedDBs, NumUnCompactedFiles: tt.dbsSetup.numUnCompactedCommonDBs, diff --git a/pkg/compression/pool_test.go b/pkg/compression/pool_test.go index fc5ba08a0d484..4d7d7ee154002 100644 --- a/pkg/compression/pool_test.go +++ b/pkg/compression/pool_test.go @@ -16,7 +16,6 @@ import ( func TestPool(t *testing.T) { for _, enc := range supportedCodecs { - enc := enc t.Run(enc.String(), func(t *testing.T) { var wg sync.WaitGroup diff --git a/pkg/distributor/distributor_test.go b/pkg/distributor/distributor_test.go index cebd46858e177..86afd0b1d659e 100644 --- a/pkg/distributor/distributor_test.go +++ b/pkg/distributor/distributor_test.go @@ -401,8 +401,6 @@ func Test_IncrementTimestamp(t *testing.T) { } for testName, testData := range tests { - testData := testData - t.Run(testName, func(t *testing.T) { ing := &mockIngester{} distributors, _ := prepare(t, 1, 3, testData.limits, func(_ string) (ring_client.PoolClient, error) { return ing, nil }) @@ -1216,8 +1214,6 @@ func TestDistributor_PushIngestionRateLimiter(t *testing.T) { } for testName, testData := range tests { - testData := testData - t.Run(testName, func(t *testing.T) { limits := &validation.Limits{} flagext.DefaultValues(limits) diff --git a/pkg/distributor/ingestion_rate_strategy_test.go b/pkg/distributor/ingestion_rate_strategy_test.go index 657d34290984a..02463264cd0dd 100644 --- a/pkg/distributor/ingestion_rate_strategy_test.go +++ b/pkg/distributor/ingestion_rate_strategy_test.go @@ -63,8 +63,6 @@ func TestIngestionRateStrategy(t *testing.T) { } for testName, testData := range tests { - testData := testData - t.Run(testName, func(t *testing.T) { var strategy limiter.RateLimiterStrategy diff --git a/pkg/ingester/index/bitprefix_test.go b/pkg/ingester/index/bitprefix_test.go index 9832e15ed60c7..8bf524c1a2e37 100644 --- a/pkg/ingester/index/bitprefix_test.go +++ b/pkg/ingester/index/bitprefix_test.go @@ -38,7 +38,6 @@ func Test_BitPrefixGetShards(t *testing.T) { {8, true, logql.NewPowerOfTwoShard(index.ShardAnnotation{Shard: 4, Of: 16}).Ptr(), []uint32{2}}, {8, true, logql.NewPowerOfTwoShard(index.ShardAnnotation{Shard: 15, Of: 16}).Ptr(), []uint32{7}}, } { - tt := tt t.Run(tt.shard.String()+fmt.Sprintf("_total_%d", tt.total), func(t *testing.T) { ii, err := NewBitPrefixWithShards(tt.total) require.Nil(t, err) diff --git a/pkg/ingester/index/index_test.go b/pkg/ingester/index/index_test.go index 23873cbfc3fdf..2e5413bd9b979 100644 --- a/pkg/ingester/index/index_test.go +++ b/pkg/ingester/index/index_test.go @@ -32,7 +32,6 @@ func Test_GetShards(t *testing.T) { {32, &index.ShardAnnotation{Shard: 15, Of: 16}, []uint32{15, 31}}, {64, &index.ShardAnnotation{Shard: 15, Of: 16}, []uint32{15, 31, 47, 63}}, } { - tt := tt t.Run(tt.shard.String()+fmt.Sprintf("_total_%d", tt.total), func(t *testing.T) { ii := NewWithShards(tt.total) res := ii.getShards(tt.shard) diff --git a/pkg/ingester/limiter_test.go b/pkg/ingester/limiter_test.go index bb87efe9555e5..b8c7fe72e3597 100644 --- a/pkg/ingester/limiter_test.go +++ b/pkg/ingester/limiter_test.go @@ -119,8 +119,6 @@ func TestStreamCountLimiter_AssertNewStreamAllowed(t *testing.T) { } for testName, testData := range tests { - testData := testData - t.Run(testName, func(t *testing.T) { // Mock limits limits, err := validation.NewOverrides(validation.Limits{ @@ -183,8 +181,6 @@ func TestLimiter_minNonZero(t *testing.T) { } for testName, testData := range tests { - testData := testData - t.Run(testName, func(t *testing.T) { limiter := NewLimiter(nil, NilMetrics, nil) assert.Equal(t, testData.expected, limiter.minNonZero(testData.first, testData.second)) diff --git a/pkg/iter/entry_iterator_test.go b/pkg/iter/entry_iterator_test.go index fb1548ddc35d0..2ef128bf62d88 100644 --- a/pkg/iter/entry_iterator_test.go +++ b/pkg/iter/entry_iterator_test.go @@ -178,8 +178,6 @@ func TestMergeIteratorPrefetch(t *testing.T) { } for testName, testFunc := range tests { - testFunc := testFunc - t.Run(testName, func(t *testing.T) { t.Parallel() diff --git a/pkg/logcli/output/default_test.go b/pkg/logcli/output/default_test.go index 121b6d4816007..e55627f75a20a 100644 --- a/pkg/logcli/output/default_test.go +++ b/pkg/logcli/output/default_test.go @@ -79,8 +79,6 @@ func TestDefaultOutput_Format(t *testing.T) { } for testName, testData := range tests { - testData := testData - t.Run(testName, func(t *testing.T) { t.Parallel() writer := &bytes.Buffer{} @@ -168,8 +166,6 @@ func TestColorForLabels(t *testing.T) { } for testName, testData := range tests { - testData := testData - t.Run(testName, func(t *testing.T) { t.Parallel() labelsColor := getColor(testData.labels.String()) diff --git a/pkg/logcli/output/jsonl_test.go b/pkg/logcli/output/jsonl_test.go index 22e81fd29ea9a..68e52294441fb 100644 --- a/pkg/logcli/output/jsonl_test.go +++ b/pkg/logcli/output/jsonl_test.go @@ -63,8 +63,6 @@ func TestJSONLOutput_Format(t *testing.T) { } for testName, testData := range tests { - testData := testData - t.Run(testName, func(t *testing.T) { t.Parallel() writer := &bytes.Buffer{} diff --git a/pkg/logcli/output/raw_test.go b/pkg/logcli/output/raw_test.go index 844e8e811afc5..6e000296a1a2b 100644 --- a/pkg/logcli/output/raw_test.go +++ b/pkg/logcli/output/raw_test.go @@ -61,8 +61,6 @@ func TestRawOutput_Format(t *testing.T) { } for testName, testData := range tests { - testData := testData - t.Run(testName, func(t *testing.T) { t.Parallel() diff --git a/pkg/logcli/query/query_test.go b/pkg/logcli/query/query_test.go index 35077968a1176..000c96a3ee0a0 100644 --- a/pkg/logcli/query/query_test.go +++ b/pkg/logcli/query/query_test.go @@ -887,8 +887,6 @@ func TestParallelJobs(t *testing.T) { } for _, tt := range tests { - tt := tt - t.Run( tt.name, func(t *testing.T) { diff --git a/pkg/loghttp/params.go b/pkg/loghttp/params.go index c32161d5bf5ec..6b289f445885f 100644 --- a/pkg/loghttp/params.go +++ b/pkg/loghttp/params.go @@ -49,7 +49,7 @@ func lineLimit(r *http.Request) (uint32, error) { func detectedFieldsLimit(r *http.Request) (uint32, error) { limit := r.Form.Get("limit") if limit == "" { - // for backwards compatability + // for backwards compatibility limit = r.Form.Get("field_limit") } diff --git a/pkg/loghttp/params_test.go b/pkg/loghttp/params_test.go index 3456fdc2ed802..e1c695167e55c 100644 --- a/pkg/loghttp/params_test.go +++ b/pkg/loghttp/params_test.go @@ -39,8 +39,6 @@ func TestHttp_defaultQueryRangeStep(t *testing.T) { } for testName, testData := range tests { - testData := testData - t.Run(testName, func(t *testing.T) { assert.Equal(t, testData.expected, defaultQueryRangeStep(testData.start, testData.end)) }) @@ -123,8 +121,6 @@ func TestHttp_ParseRangeQuery_Step(t *testing.T) { } for testName, testData := range tests { - testData := testData - t.Run(testName, func(t *testing.T) { req := httptest.NewRequest("GET", testData.reqPath, nil) err := req.ParseForm() @@ -176,8 +172,6 @@ func Test_interval(t *testing.T) { }, } for _, testData := range tests { - testData := testData - t.Run(testData.name, func(t *testing.T) { req := httptest.NewRequest("GET", testData.reqPath, nil) err := req.ParseForm() diff --git a/pkg/loghttp/query_test.go b/pkg/loghttp/query_test.go index 889a8900eac76..47b61622e4bd4 100644 --- a/pkg/loghttp/query_test.go +++ b/pkg/loghttp/query_test.go @@ -280,7 +280,6 @@ func Test_QueryResponseUnmarshal(t *testing.T) { }, }, } { - tt := tt t.Run("", func(t *testing.T) { b, err := jsoniter.Marshal(tt) require.Nil(t, err) diff --git a/pkg/logql/engine_test.go b/pkg/logql/engine_test.go index fd534ac046e8c..889d06344ddbe 100644 --- a/pkg/logql/engine_test.go +++ b/pkg/logql/engine_test.go @@ -147,7 +147,6 @@ func TestEngine_LogsRateUnwrap(t *testing.T) { promql.Vector{promql.Sample{T: 60 * 1000, F: 0.46666766666666665, Metric: labels.FromStrings("app", "foo")}}, }, } { - test := test t.Run(fmt.Sprintf("%s %s", test.qs, test.direction), func(t *testing.T) { t.Parallel() @@ -954,7 +953,6 @@ func TestEngine_InstantQuery(t *testing.T) { }, }, } { - test := test t.Run(fmt.Sprintf("%s %s", test.qs, test.direction), func(t *testing.T) { eng := NewEngine(EngineOpts{}, newQuerierRecorder(t, test.data, test.params), NoLimits, log.NewNopLogger()) @@ -2256,7 +2254,6 @@ func TestEngine_RangeQuery(t *testing.T) { }, }, } { - test := test t.Run(fmt.Sprintf("%s %s", test.qs, test.direction), func(t *testing.T) { t.Parallel() @@ -2425,7 +2422,6 @@ func TestStepEvaluator_Error(t *testing.T) { } for _, tc := range tests { - tc := tc t.Run(tc.name, func(t *testing.T) { eng := NewEngine(EngineOpts{}, tc.querier, NoLimits, log.NewNopLogger()) diff --git a/pkg/logql/log/parser_hints_test.go b/pkg/logql/log/parser_hints_test.go index 96bfc15b38639..d41a597501b0c 100644 --- a/pkg/logql/log/parser_hints_test.go +++ b/pkg/logql/log/parser_hints_test.go @@ -225,7 +225,6 @@ func Test_ParserHints(t *testing.T) { `{app="nginx", message_message="foo"}`, }, } { - tt := tt t.Run(tt.expr, func(t *testing.T) { t.Parallel() expr, err := syntax.ParseSampleExpr(tt.expr) diff --git a/pkg/logql/log/parser_test.go b/pkg/logql/log/parser_test.go index fd08467af8586..5ac57b9ef0540 100644 --- a/pkg/logql/log/parser_test.go +++ b/pkg/logql/log/parser_test.go @@ -1406,7 +1406,6 @@ func Test_PatternParser(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.pattern, func(t *testing.T) { t.Parallel() b := NewBaseLabelsBuilder().ForLabels(tt.lbs, tt.lbs.Hash()) diff --git a/pkg/logql/log/pattern/lexer_test.go b/pkg/logql/log/pattern/lexer_test.go index 3e6bcf1b12e97..30638f4e8a3cf 100644 --- a/pkg/logql/log/pattern/lexer_test.go +++ b/pkg/logql/log/pattern/lexer_test.go @@ -20,7 +20,6 @@ func Test_Lex(t *testing.T) { {`<1foo>`, []int{LITERAL, LITERAL, LITERAL, LITERAL, LITERAL, LITERAL}}, {`▶`, []int{LITERAL}}, } { - tc := tc t.Run(tc.input, func(t *testing.T) { actual := []int{} l := newLexer() diff --git a/pkg/logql/log/pattern/parser_test.go b/pkg/logql/log/pattern/parser_test.go index dbcb418fd382b..0f1166aa2681d 100644 --- a/pkg/logql/log/pattern/parser_test.go +++ b/pkg/logql/log/pattern/parser_test.go @@ -53,7 +53,6 @@ func Test_Parse(t *testing.T) { nil, }, } { - tc := tc actual, err := parseExpr(tc.input) if tc.err != nil || err != nil { require.Equal(t, tc.err, err) diff --git a/pkg/logql/log/pattern/pattern_test.go b/pkg/logql/log/pattern/pattern_test.go index ca4f3ea47d96c..449843a28e07f 100644 --- a/pkg/logql/log/pattern/pattern_test.go +++ b/pkg/logql/log/pattern/pattern_test.go @@ -176,7 +176,6 @@ func Test_BytesIndexUnicode(t *testing.T) { func Test_matcher_Matches(t *testing.T) { for _, tt := range fixtures { - tt := tt t.Run(tt.expr, func(t *testing.T) { t.Parallel() m, err := New(tt.expr) diff --git a/pkg/logql/rangemapper_test.go b/pkg/logql/rangemapper_test.go index 5365c7b2b73f0..cd6ad68c1bec3 100644 --- a/pkg/logql/rangemapper_test.go +++ b/pkg/logql/rangemapper_test.go @@ -75,7 +75,6 @@ func Test_SplitRangeInterval(t *testing.T) { 2, }, } { - tc := tc t.Run(tc.expr, func(t *testing.T) { t.Parallel() @@ -1811,7 +1810,6 @@ func Test_SplitRangeVectorMapping(t *testing.T) { 3, }, } { - tc := tc t.Run(tc.expr, func(t *testing.T) { t.Parallel() @@ -2002,7 +2000,6 @@ func Test_SplitRangeVectorMapping_Noop(t *testing.T) { `vector(0.000000)`, }, } { - tc := tc t.Run(tc.expr, func(t *testing.T) { t.Parallel() diff --git a/pkg/logql/sketch/topk_slow_test.go b/pkg/logql/sketch/topk_slow_test.go index 8f2095d987de6..fe5105562b73a 100644 --- a/pkg/logql/sketch/topk_slow_test.go +++ b/pkg/logql/sketch/topk_slow_test.go @@ -135,7 +135,6 @@ func TestCMSTopk(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(fmt.Sprintf("num_streams/%d_k/%d_iterations/%d", tc.numStreams, tc.k, tc.iterations), func(t *testing.T) { t.Parallel() missing := 0 diff --git a/pkg/logql/syntax/ast_test.go b/pkg/logql/syntax/ast_test.go index 98987e38c4bed..88fc0021eb33f 100644 --- a/pkg/logql/syntax/ast_test.go +++ b/pkg/logql/syntax/ast_test.go @@ -53,7 +53,6 @@ func Test_logSelectorExpr_String(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.selector, func(t *testing.T) { t.Parallel() expr, err := ParseLogSelector(tt.selector, true) @@ -588,7 +587,6 @@ func Test_FilterMatcher(t *testing.T) { []linecheck{{"counter=1", false}, {"counter=0", false}, {"counter=-1", true}, {"counter=-2", true}}, }, } { - tt := tt t.Run(tt.q, func(t *testing.T) { t.Parallel() expr, err := ParseLogSelector(tt.q, true) diff --git a/pkg/logql/syntax/walk_test.go b/pkg/logql/syntax/walk_test.go index 3350515b9c461..ee536e969471f 100644 --- a/pkg/logql/syntax/walk_test.go +++ b/pkg/logql/syntax/walk_test.go @@ -26,7 +26,6 @@ func Test_Walkable(t *testing.T) { }, } for _, test := range tests { - test := test t.Run(test.desc, func(t *testing.T) { expr, err := ParseExpr(test.expr) require.Nil(t, err) @@ -72,7 +71,6 @@ func Test_AppendMatchers(t *testing.T) { }, } for _, test := range tests { - test := test t.Run(test.desc, func(t *testing.T) { expr, err := ParseExpr(test.expr) require.NoError(t, err) diff --git a/pkg/loki/modules.go b/pkg/loki/modules.go index d9c111cc86493..54c6d574f6e51 100644 --- a/pkg/loki/modules.go +++ b/pkg/loki/modules.go @@ -1484,8 +1484,6 @@ func (t *Loki) initIndexGateway() (services.Service, error) { var indexClients []indexgateway.IndexClientWithRange for i, period := range t.Cfg.SchemaConfig.Configs { - period := period - if period.IndexType != types.BoltDBShipperType { continue } diff --git a/pkg/pattern/drain/drain_test.go b/pkg/pattern/drain/drain_test.go index 1aabea548aed6..9359feb8dd343 100644 --- a/pkg/pattern/drain/drain_test.go +++ b/pkg/pattern/drain/drain_test.go @@ -426,7 +426,6 @@ func TestDrain_TrainExtractsPatterns(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.inputFile, func(t *testing.T) { file, err := os.Open(tt.inputFile) require.NoError(t, err) @@ -529,7 +528,6 @@ func TestDrain_TrainGeneratesPatternsMatchableByLokiPatternFilter(t *testing.T) }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { for _, line := range tt.inputLines { tt.drain.Train(line, 0) @@ -630,7 +628,6 @@ func TestDrain_PruneTreeClearsOldBranches(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { now := time.Now() for i, line := range tt.inputLines { diff --git a/pkg/pattern/ingester_querier.go b/pkg/pattern/ingester_querier.go index 3a275ffd46445..185a35b0463db 100644 --- a/pkg/pattern/ingester_querier.go +++ b/pkg/pattern/ingester_querier.go @@ -146,8 +146,6 @@ func (q *IngesterQuerier) forGivenIngesters(ctx context.Context, replicationSet responses := make([]ResponseFromIngesters, len(replicationSet.Instances)) for i, ingester := range replicationSet.Instances { - ingester := ingester - i := i g.Go(func() error { client, err := q.ringClient.GetClientFor(ingester.Addr) if err != nil { diff --git a/pkg/pattern/iter/iterator_test.go b/pkg/pattern/iter/iterator_test.go index 3d14b2550c4be..12506dac0b4bf 100644 --- a/pkg/pattern/iter/iterator_test.go +++ b/pkg/pattern/iter/iterator_test.go @@ -48,7 +48,6 @@ func TestSliceIterator(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { got := slice(NewSlice(tt.pattern, tt.samples)) require.Equal(t, tt.want, got) diff --git a/pkg/pattern/iter/merge_test.go b/pkg/pattern/iter/merge_test.go index a1d643a5a01c1..be9069c9ed72c 100644 --- a/pkg/pattern/iter/merge_test.go +++ b/pkg/pattern/iter/merge_test.go @@ -62,7 +62,6 @@ func TestMerge(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { it := NewMerge(tt.iterators...) defer it.Close() diff --git a/pkg/querier-rf1/wal/chunks.go b/pkg/querier-rf1/wal/chunks.go index bfe565ff6134b..732180b8742f5 100644 --- a/pkg/querier-rf1/wal/chunks.go +++ b/pkg/querier-rf1/wal/chunks.go @@ -285,8 +285,6 @@ func downloadChunks(ctx context.Context, storage BlockStorage, chks []ChunkData) g, ctx := errgroup.WithContext(ctx) g.SetLimit(64) for i, chunk := range chks { - chunk := chunk - i := i g.Go(func() error { chunkData, err := readChunkData(ctx, storage, chunk) if err != nil { diff --git a/pkg/querier-rf1/wal/querier.go b/pkg/querier-rf1/wal/querier.go index 0fb2cc23dc525..e43f3fc1041f9 100644 --- a/pkg/querier-rf1/wal/querier.go +++ b/pkg/querier-rf1/wal/querier.go @@ -178,8 +178,6 @@ func (q *Querier) forIndices(ctx context.Context, req *metastorepb.ListBlocksFor g, ctx := errgroup.WithContext(ctx) g.SetLimit(32) for _, meta := range metas { - - meta := meta g.Go(func() error { reader, err := q.blockStorage.GetObjectRange(ctx, wal.Dir+meta.Id, meta.IndexRef.Offset, meta.IndexRef.Length) if err != nil { diff --git a/pkg/querier/ingester_querier_test.go b/pkg/querier/ingester_querier_test.go index 713c170f7dea2..dbc37350f038a 100644 --- a/pkg/querier/ingester_querier_test.go +++ b/pkg/querier/ingester_querier_test.go @@ -72,7 +72,6 @@ func TestIngesterQuerier_earlyExitOnQuorum(t *testing.T) { for testName, testData := range tests { for _, retErr := range []bool{true, false} { - testName, testData, retErr := testName, testData, retErr if retErr { testName += " call should return early on breaching max errors" } else { @@ -168,7 +167,6 @@ func TestIngesterQuerier_earlyExitOnQuorum(t *testing.T) { for testName, testData := range tests { for _, retErr := range []bool{true, false} { - testName, testData, retErr := testName, testData, retErr if retErr { testName += " call should not return early on breaching max errors" } else { @@ -277,8 +275,6 @@ func TestQuerier_tailDisconnectedIngesters(t *testing.T) { } for testName, testData := range tests { - testData := testData - t.Run(testName, func(t *testing.T) { req := logproto.TailRequest{ Query: "{type=\"test\"}", diff --git a/pkg/querier/querier_test.go b/pkg/querier/querier_test.go index 9b4928ee34c25..b24491b87f6ba 100644 --- a/pkg/querier/querier_test.go +++ b/pkg/querier/querier_test.go @@ -529,8 +529,6 @@ func TestQuerier_concurrentTailLimits(t *testing.T) { } for testName, testData := range tests { - testData := testData - t.Run(testName, func(t *testing.T) { // For this test's purpose, whenever a new ingester client needs to // be created, the factory will always return the same mock instance diff --git a/pkg/querier/queryrange/codec_test.go b/pkg/querier/queryrange/codec_test.go index e52bb1ec50a0a..a116e0f4f7d7b 100644 --- a/pkg/querier/queryrange/codec_test.go +++ b/pkg/querier/queryrange/codec_test.go @@ -837,7 +837,6 @@ func Test_codec_DecodeProtobufResponseParity(t *testing.T) { } codec := RequestProtobufCodec{} for i, queryTest := range queryTests { - i := i t.Run(queryTest.name, func(t *testing.T) { params := url.Values{ "query": []string{`{app="foo"}`}, diff --git a/pkg/querier/queryrange/prometheus_test.go b/pkg/querier/queryrange/prometheus_test.go index 2888fbfdd6ace..e6f00b127d025 100644 --- a/pkg/querier/queryrange/prometheus_test.go +++ b/pkg/querier/queryrange/prometheus_test.go @@ -269,7 +269,6 @@ func Test_encodePromResponse(t *testing.T) { }`, }, } { - tt := tt t.Run(tt.name, func(t *testing.T) { r, err := tt.resp.encode(context.Background()) require.NoError(t, err) diff --git a/pkg/querier/queryrange/queryrangebase/promql_test.go b/pkg/querier/queryrange/queryrangebase/promql_test.go index edc7a0e5829a0..ee0309112e14b 100644 --- a/pkg/querier/queryrange/queryrangebase/promql_test.go +++ b/pkg/querier/queryrange/queryrangebase/promql_test.go @@ -314,7 +314,6 @@ func Test_PromQL(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.normalQuery, func(t *testing.T) { baseQuery, err := engine.NewRangeQuery(context.Background(), shardAwareQueryable, nil, tt.normalQuery, start, end, step) diff --git a/pkg/querier/queryrange/split_by_range_test.go b/pkg/querier/queryrange/split_by_range_test.go index e3c30c66cc54c..257c04e37795e 100644 --- a/pkg/querier/queryrange/split_by_range_test.go +++ b/pkg/querier/queryrange/split_by_range_test.go @@ -256,7 +256,6 @@ func Test_RangeVectorSplitAlign(t *testing.T) { expected: expectedMergedResponseWithTime(1+2+3+4, twelve34), }, } { - tc := tc t.Run(tc.name, func(t *testing.T) { srm := NewSplitByRangeMiddleware(log.NewNopLogger(), testEngineOpts, fakeLimits{ maxSeries: 10000, @@ -408,7 +407,6 @@ func Test_RangeVectorSplit(t *testing.T) { expected: expectedMergedResponse(1 + 2 + 3), }, } { - tc := tc t.Run(tc.in.GetQuery(), func(t *testing.T) { resp, err := srm.Wrap(queryrangebase.HandlerFunc( func(_ context.Context, req queryrangebase.Request) (queryrangebase.Response, error) { diff --git a/pkg/queue/queue_test.go b/pkg/queue/queue_test.go index 9b4aca8481c72..d7f59cb3b4a5a 100644 --- a/pkg/queue/queue_test.go +++ b/pkg/queue/queue_test.go @@ -44,8 +44,6 @@ func BenchmarkGetNextRequest(b *testing.B) { } for _, benchCase := range benchCases { - benchCase := benchCase - b.Run(benchCase.name, func(b *testing.B) { queues := make([]*RequestQueue, 0, b.N) diff --git a/pkg/ruler/base/ruler_test.go b/pkg/ruler/base/ruler_test.go index b180c559d8d3b..bdb437ed9279d 100644 --- a/pkg/ruler/base/ruler_test.go +++ b/pkg/ruler/base/ruler_test.go @@ -1763,7 +1763,6 @@ func TestSendAlerts(t *testing.T) { } for i, tc := range testCases { - tc := tc t.Run(fmt.Sprintf("%d", i), func(t *testing.T) { senderFunc := senderFunc(func(alerts ...*notifier.Alert) { if len(tc.in) == 0 { diff --git a/pkg/storage/batch_test.go b/pkg/storage/batch_test.go index 34d8e350045a5..115e625a28af7 100644 --- a/pkg/storage/batch_test.go +++ b/pkg/storage/batch_test.go @@ -100,7 +100,6 @@ func Test_newLogBatchChunkIterator(t *testing.T) { var tests map[string]testCase for _, periodConfig := range periodConfigs { - periodConfig := periodConfig chunkfmt, headfmt, err := periodConfig.ChunkFormat() require.NoError(t, err) @@ -1000,7 +999,6 @@ func Test_newLogBatchChunkIterator(t *testing.T) { for _, schemaConfig := range schemaConfigs { s := schemaConfig for name, tt := range tests { - tt := tt t.Run(name, func(t *testing.T) { it, err := newLogBatchIterator(context.Background(), s, NilMetrics, tt.chunks, tt.batchSize, newMatchers(tt.matchers), log.NewNoopPipeline(), tt.direction, tt.start, tt.end, nil) require.NoError(t, err) @@ -1416,7 +1414,6 @@ func Test_newSampleBatchChunkIterator(t *testing.T) { } for name, tt := range tests { - tt := tt t.Run(name, func(t *testing.T) { ex, err := log.NewLineSampleExtractor(log.CountExtractor, nil, nil, false, false) require.NoError(t, err) diff --git a/pkg/storage/bucket/azure/config_test.go b/pkg/storage/bucket/azure/config_test.go index 756ae298b65cb..82357faa147e4 100644 --- a/pkg/storage/bucket/azure/config_test.go +++ b/pkg/storage/bucket/azure/config_test.go @@ -86,8 +86,6 @@ http: } for testName, testData := range tests { - testData := testData - t.Run(testName, func(t *testing.T) { cfg := Config{} flagext.DefaultValues(&cfg) diff --git a/pkg/storage/bucket/client_test.go b/pkg/storage/bucket/client_test.go index 489f7d2f1f269..fb7acec91089a 100644 --- a/pkg/storage/bucket/client_test.go +++ b/pkg/storage/bucket/client_test.go @@ -69,8 +69,6 @@ func TestNewClient(t *testing.T) { } for testName, testData := range tests { - testData := testData - t.Run(testName, func(t *testing.T) { // Load config cfg := Config{} diff --git a/pkg/storage/bucket/http/config_test.go b/pkg/storage/bucket/http/config_test.go index d7da35e581af3..6ac47eb4a2572 100644 --- a/pkg/storage/bucket/http/config_test.go +++ b/pkg/storage/bucket/http/config_test.go @@ -65,8 +65,6 @@ max_connections_per_host: 8 } for testName, testData := range tests { - testData := testData - t.Run(testName, func(t *testing.T) { cfg := Config{} flagext.DefaultValues(&cfg) diff --git a/pkg/storage/bucket/s3/config_test.go b/pkg/storage/bucket/s3/config_test.go index 214b2f6ff0cd9..3f32e8f847936 100644 --- a/pkg/storage/bucket/s3/config_test.go +++ b/pkg/storage/bucket/s3/config_test.go @@ -111,8 +111,6 @@ http: } for testName, testData := range tests { - testData := testData - t.Run(testName, func(t *testing.T) { cfg := Config{} flagext.DefaultValues(&cfg) diff --git a/pkg/storage/chunk/client/aws/dynamodb_index_reader.go b/pkg/storage/chunk/client/aws/dynamodb_index_reader.go index 19ea676451a9e..73c1cb74c75a7 100644 --- a/pkg/storage/chunk/client/aws/dynamodb_index_reader.go +++ b/pkg/storage/chunk/client/aws/dynamodb_index_reader.go @@ -80,8 +80,7 @@ func (r *dynamodbIndexReader) ReadIndexEntries(ctx context.Context, tableName st var readerGroup errgroup.Group // Start a goroutine for each processor - for i, processor := range processors { - segment, processor := i, processor // https://golang.org/doc/faq#closures_and_goroutines + for segment, processor := range processors { readerGroup.Go(func() error { input := &dynamodb.ScanInput{ TableName: aws.String(tableName), diff --git a/pkg/storage/chunk/client/aws/s3_storage_client_test.go b/pkg/storage/chunk/client/aws/s3_storage_client_test.go index 5647934e1afa7..c582d9a4cab51 100644 --- a/pkg/storage/chunk/client/aws/s3_storage_client_test.go +++ b/pkg/storage/chunk/client/aws/s3_storage_client_test.go @@ -272,7 +272,6 @@ func Test_Hedging(t *testing.T) { }, }, } { - tc := tc t.Run(tc.name, func(t *testing.T) { count := atomic.NewInt32(0) diff --git a/pkg/storage/chunk/client/azure/blob_storage_client_test.go b/pkg/storage/chunk/client/azure/blob_storage_client_test.go index cedc5057e85bc..8a3362d4a7c7d 100644 --- a/pkg/storage/chunk/client/azure/blob_storage_client_test.go +++ b/pkg/storage/chunk/client/azure/blob_storage_client_test.go @@ -118,7 +118,6 @@ func Test_Hedging(t *testing.T) { }, }, } { - tc := tc t.Run(tc.name, func(t *testing.T) { count := atomic.NewInt32(0) // hijack the client to count the number of calls diff --git a/pkg/storage/chunk/client/gcp/gcs_object_client_test.go b/pkg/storage/chunk/client/gcp/gcs_object_client_test.go index 5bece14a18dbb..c885c4c1d780c 100644 --- a/pkg/storage/chunk/client/gcp/gcs_object_client_test.go +++ b/pkg/storage/chunk/client/gcp/gcs_object_client_test.go @@ -55,7 +55,6 @@ func Test_Hedging(t *testing.T) { }, }, } { - tc := tc t.Run(tc.name, func(t *testing.T) { count := atomic.NewInt32(0) server := fakeServer(t, 200*time.Millisecond, count) diff --git a/pkg/storage/chunk/client/openstack/swift_object_client_test.go b/pkg/storage/chunk/client/openstack/swift_object_client_test.go index ce2f130f1bfca..efcd2807fdc90 100644 --- a/pkg/storage/chunk/client/openstack/swift_object_client_test.go +++ b/pkg/storage/chunk/client/openstack/swift_object_client_test.go @@ -58,7 +58,6 @@ func Test_Hedging(t *testing.T) { }, }, } { - tc := tc t.Run(tc.name, func(t *testing.T) { count := atomic.NewInt32(0) // hijack the transport to count the number of calls diff --git a/pkg/storage/config/schema_config_test.go b/pkg/storage/config/schema_config_test.go index 74980ad513aae..8a8de6077e447 100644 --- a/pkg/storage/config/schema_config_test.go +++ b/pkg/storage/config/schema_config_test.go @@ -384,8 +384,6 @@ func TestSchemaConfig_Validate(t *testing.T) { } for testName, testData := range tests { - testData := testData - t.Run(testName, func(t *testing.T) { actual := testData.config.Validate() assert.ErrorIs(t, actual, testData.err) diff --git a/pkg/storage/lazy_chunk_test.go b/pkg/storage/lazy_chunk_test.go index 6757e94e1e958..986358f6aea79 100644 --- a/pkg/storage/lazy_chunk_test.go +++ b/pkg/storage/lazy_chunk_test.go @@ -38,8 +38,6 @@ func TestLazyChunkIterator(t *testing.T) { } for _, periodConfig := range periodConfigs { - periodConfig := periodConfig - chunkfmt, headfmt, err := periodConfig.ChunkFormat() require.NoError(t, err) diff --git a/pkg/storage/store.go b/pkg/storage/store.go index db4a0a498e17d..768708a24f34c 100644 --- a/pkg/storage/store.go +++ b/pkg/storage/store.go @@ -194,7 +194,6 @@ func NewStore(cfg Config, storeCfg config.ChunkStoreConfig, schemaCfg config.Sch func (s *LokiStore) init() error { for i, p := range s.schemaCfg.Configs { - p := p chunkClient, err := s.chunkClientForPeriod(p) if err != nil { return err diff --git a/pkg/storage/store_test.go b/pkg/storage/store_test.go index 197fcfa6f1e90..cc17cd0a92ef3 100644 --- a/pkg/storage/store_test.go +++ b/pkg/storage/store_test.go @@ -1771,7 +1771,6 @@ func Test_GetSeries(t *testing.T) { []logproto.SeriesIdentifier{}, }, } { - tt := tt t.Run(tt.name, func(t *testing.T) { if tt.req.Selector != "" { tt.req.Plan = &plan.QueryPlan{ diff --git a/pkg/storage/stores/shipper/bloomshipper/fetcher_test.go b/pkg/storage/stores/shipper/bloomshipper/fetcher_test.go index 6c60c64b5f2df..e330fd41c1fbb 100644 --- a/pkg/storage/stores/shipper/bloomshipper/fetcher_test.go +++ b/pkg/storage/stores/shipper/bloomshipper/fetcher_test.go @@ -176,7 +176,6 @@ func TestFetcher_DownloadQueue(t *testing.T) { size: 1, workers: 0, err: "queue requires at least 1 worker", }, } { - tc := tc t.Run(tc.err, func(t *testing.T) { _, err := newDownloadQueue[bool, bool]( tc.size, diff --git a/pkg/storage/stores/shipper/indexshipper/boltdb/compactor/compacted_index_test.go b/pkg/storage/stores/shipper/indexshipper/boltdb/compactor/compacted_index_test.go index 043d36d00401e..433835e0ff7e9 100644 --- a/pkg/storage/stores/shipper/indexshipper/boltdb/compactor/compacted_index_test.go +++ b/pkg/storage/stores/shipper/indexshipper/boltdb/compactor/compacted_index_test.go @@ -23,7 +23,6 @@ import ( func TestCompactedIndex_IndexProcessor(t *testing.T) { for _, tt := range allSchemas { - tt := tt t.Run(tt.schema, func(t *testing.T) { cm := storage.NewClientMetrics() defer cm.Unregister() diff --git a/pkg/storage/stores/shipper/indexshipper/boltdb/compactor/iterator_test.go b/pkg/storage/stores/shipper/indexshipper/boltdb/compactor/iterator_test.go index 26e9aef596bf4..c4acfd33b67ac 100644 --- a/pkg/storage/stores/shipper/indexshipper/boltdb/compactor/iterator_test.go +++ b/pkg/storage/stores/shipper/indexshipper/boltdb/compactor/iterator_test.go @@ -24,7 +24,6 @@ import ( func Test_ChunkIterator(t *testing.T) { for _, tt := range allSchemas { - tt := tt t.Run(tt.schema, func(t *testing.T) { cm := storage.NewClientMetrics() defer cm.Unregister() @@ -108,7 +107,6 @@ func Test_ChunkIteratorContextCancelation(t *testing.T) { func Test_SeriesCleaner(t *testing.T) { for _, tt := range allSchemas { - tt := tt t.Run(tt.schema, func(t *testing.T) { cm := storage.NewClientMetrics() defer cm.Unregister() diff --git a/pkg/storage/stores/shipper/indexshipper/boltdb/compactor/table_compactor_test.go b/pkg/storage/stores/shipper/indexshipper/boltdb/compactor/table_compactor_test.go index 4fa6d598c8e36..9bd76e22c6c9c 100644 --- a/pkg/storage/stores/shipper/indexshipper/boltdb/compactor/table_compactor_test.go +++ b/pkg/storage/stores/shipper/indexshipper/boltdb/compactor/table_compactor_test.go @@ -368,7 +368,6 @@ func TestTable_RecreateCompactedDB(t *testing.T) { shouldRecreateCompactedDB: true, }, } { - tt := tt t.Run(name, func(t *testing.T) { if !tt.compactedDBMtime.IsZero() { require.Equal(t, 1, tt.dbCount) diff --git a/pkg/storage/stores/shipper/indexshipper/downloads/table_manager_test.go b/pkg/storage/stores/shipper/indexshipper/downloads/table_manager_test.go index e8d9e3efcc8d3..ea360dbd3cf4d 100644 --- a/pkg/storage/stores/shipper/indexshipper/downloads/table_manager_test.go +++ b/pkg/storage/stores/shipper/indexshipper/downloads/table_manager_test.go @@ -319,7 +319,6 @@ func TestTableManager_ensureQueryReadiness(t *testing.T) { }, } { t.Run(tc.name, func(t *testing.T) { - tc := tc // just to make the linter happy resetTables() tableManager.cfg.QueryReadyNumDays = tc.queryReadyNumDaysCfg tableManager.cfg.Limits = &tc.queryReadinessLimits diff --git a/pkg/storage/wal/segment.go b/pkg/storage/wal/segment.go index 83841aab1697e..da656888f55f8 100644 --- a/pkg/storage/wal/segment.go +++ b/pkg/storage/wal/segment.go @@ -231,7 +231,6 @@ func (b *SegmentWriter) Meta(id string) *metastorepb.BlockMeta { } result := make([]*metastorepb.TenantStreams, 0, len(tenants)) for _, tenant := range tenants { - tenant := tenant result = append(result, tenant) } sort.Slice(result, func(i, j int) bool { @@ -379,7 +378,6 @@ func (b *SegmentWriter) Reset() { b.firstAppend = time.Time{} b.lastAppend = time.Time{} for _, s := range b.streams { - s := s s.Reset() streamSegmentPool.Put(s) } diff --git a/pkg/storage/wal/segment_test.go b/pkg/storage/wal/segment_test.go index cbe42587bf7a2..52e50e9e2f88e 100644 --- a/pkg/storage/wal/segment_test.go +++ b/pkg/storage/wal/segment_test.go @@ -101,7 +101,6 @@ func TestWalSegmentWriter_Append(t *testing.T) { // Run the test cases for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() // Create a new WalSegmentWriter diff --git a/pkg/util/marshal/marshal_test.go b/pkg/util/marshal/marshal_test.go index 0e08239b20ad5..cc581a0cd8c7e 100644 --- a/pkg/util/marshal/marshal_test.go +++ b/pkg/util/marshal/marshal_test.go @@ -1125,7 +1125,6 @@ func Test_WriteQueryPatternsResponseJSON(t *testing.T) { `{"status":"success","data":[{"pattern":"foo <*> bar","samples":[]},{"pattern":"foo <*> buzz","samples":[]}]}`, }, } { - tc := tc t.Run(fmt.Sprintf("%d", i), func(t *testing.T) { var b bytes.Buffer err := WriteQueryPatternsResponseJSON(tc.input, &b) diff --git a/pkg/util/query_string_builder_test.go b/pkg/util/query_string_builder_test.go index a97d5971557d3..aed48a467d942 100644 --- a/pkg/util/query_string_builder_test.go +++ b/pkg/util/query_string_builder_test.go @@ -33,8 +33,6 @@ func TestQueryStringBuilder(t *testing.T) { } for testName, testData := range tests { - testData := testData - t.Run(testName, func(t *testing.T) { params := NewQueryStringBuilder() diff --git a/pkg/util/string_test.go b/pkg/util/string_test.go index b58bc1ee91453..03cc69c7f599c 100644 --- a/pkg/util/string_test.go +++ b/pkg/util/string_test.go @@ -27,8 +27,6 @@ func TestStringsContain(t *testing.T) { } for testName, testData := range tests { - testData := testData - t.Run(testName, func(t *testing.T) { t.Parallel() diff --git a/tools/querytee/proxy_endpoint.go b/tools/querytee/proxy_endpoint.go index 3bcaa3be24405..7a6779b6ad880 100644 --- a/tools/querytee/proxy_endpoint.go +++ b/tools/querytee/proxy_endpoint.go @@ -109,9 +109,6 @@ func (p *ProxyEndpoint) executeBackendRequests(r *http.Request, resCh chan *back wg.Add(len(p.backends)) for i, b := range p.backends { - i := i - b := b - go func() { defer wg.Done() var ( diff --git a/tools/querytee/proxy_endpoint_test.go b/tools/querytee/proxy_endpoint_test.go index 728f8fec415c9..5cfee42b504dd 100644 --- a/tools/querytee/proxy_endpoint_test.go +++ b/tools/querytee/proxy_endpoint_test.go @@ -95,8 +95,6 @@ func Test_ProxyEndpoint_waitBackendResponseForDownstream(t *testing.T) { } for testName, testData := range tests { - testData := testData - t.Run(testName, func(t *testing.T) { endpoint := NewProxyEndpoint(testData.backends, "test", NewProxyMetrics(nil), log.NewNopLogger(), nil, false) From c2f38e18c6b8dd134b8f3da164afc9c8625f2f2b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 4 Oct 2024 13:10:50 -0600 Subject: [PATCH 16/26] fix(deps): update github.com/grafana/dskit digest to 687ec48 (#14395) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- tools/lambda-promtail/go.mod | 2 +- tools/lambda-promtail/go.sum | 4 ++-- vendor/modules.txt | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index c003fd8813f93..b1ff86617ebe1 100644 --- a/go.mod +++ b/go.mod @@ -51,7 +51,7 @@ require ( github.com/gorilla/mux v1.8.1 github.com/gorilla/websocket v1.5.3 github.com/grafana/cloudflare-go v0.0.0-20230110200409-c627cf6792f2 - github.com/grafana/dskit v0.0.0-20241002104024-b69ac1b95024 + github.com/grafana/dskit v0.0.0-20241004175247-687ec485facf github.com/grafana/go-gelf/v2 v2.0.1 github.com/grafana/gomemcache v0.0.0-20240229205252-cd6a66d6fb56 github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc diff --git a/go.sum b/go.sum index ce616ba23be67..c1129b0ba29a0 100644 --- a/go.sum +++ b/go.sum @@ -1044,8 +1044,8 @@ github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aN github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grafana/cloudflare-go v0.0.0-20230110200409-c627cf6792f2 h1:qhugDMdQ4Vp68H0tp/0iN17DM2ehRo1rLEdOFe/gB8I= github.com/grafana/cloudflare-go v0.0.0-20230110200409-c627cf6792f2/go.mod h1:w/aiO1POVIeXUQyl0VQSZjl5OAGDTL5aX+4v0RA1tcw= -github.com/grafana/dskit v0.0.0-20241002104024-b69ac1b95024 h1:RflXv1xMlnqP0zr1apM3lJ0BK5SwvEOGLv980V+oGJ0= -github.com/grafana/dskit v0.0.0-20241002104024-b69ac1b95024/go.mod h1:SPLNCARd4xdjCkue0O6hvuoveuS1dGJjDnfxYe405YQ= +github.com/grafana/dskit v0.0.0-20241004175247-687ec485facf h1:ZafqZwIpdCCMifH9Ok6C98rYaCh5OZeyyHLbU0FPedg= +github.com/grafana/dskit v0.0.0-20241004175247-687ec485facf/go.mod h1:SPLNCARd4xdjCkue0O6hvuoveuS1dGJjDnfxYe405YQ= github.com/grafana/go-gelf/v2 v2.0.1 h1:BOChP0h/jLeD+7F9mL7tq10xVkDG15he3T1zHuQaWak= github.com/grafana/go-gelf/v2 v2.0.1/go.mod h1:lexHie0xzYGwCgiRGcvZ723bSNyNI8ZRD4s0CLobh90= github.com/grafana/gocql v0.0.0-20200605141915-ba5dc39ece85 h1:xLuzPoOzdfNb/RF/IENCw+oLVdZB4G21VPhkHBgwSHY= diff --git a/tools/lambda-promtail/go.mod b/tools/lambda-promtail/go.mod index 1046188c1f118..961038477cdfb 100644 --- a/tools/lambda-promtail/go.mod +++ b/tools/lambda-promtail/go.mod @@ -10,7 +10,7 @@ require ( github.com/go-kit/log v0.2.1 github.com/gogo/protobuf v1.3.2 github.com/golang/snappy v0.0.4 - github.com/grafana/dskit v0.0.0-20241002104024-b69ac1b95024 + github.com/grafana/dskit v0.0.0-20241004175247-687ec485facf github.com/grafana/loki/v3 v3.0.0-20240809103847-9315b3d03d79 github.com/prometheus/common v0.55.0 github.com/stretchr/testify v1.9.0 diff --git a/tools/lambda-promtail/go.sum b/tools/lambda-promtail/go.sum index cf8c6d178524d..f7251a0d33709 100644 --- a/tools/lambda-promtail/go.sum +++ b/tools/lambda-promtail/go.sum @@ -216,8 +216,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= -github.com/grafana/dskit v0.0.0-20241002104024-b69ac1b95024 h1:RflXv1xMlnqP0zr1apM3lJ0BK5SwvEOGLv980V+oGJ0= -github.com/grafana/dskit v0.0.0-20241002104024-b69ac1b95024/go.mod h1:SPLNCARd4xdjCkue0O6hvuoveuS1dGJjDnfxYe405YQ= +github.com/grafana/dskit v0.0.0-20241004175247-687ec485facf h1:ZafqZwIpdCCMifH9Ok6C98rYaCh5OZeyyHLbU0FPedg= +github.com/grafana/dskit v0.0.0-20241004175247-687ec485facf/go.mod h1:SPLNCARd4xdjCkue0O6hvuoveuS1dGJjDnfxYe405YQ= github.com/grafana/gomemcache v0.0.0-20240229205252-cd6a66d6fb56 h1:X8IKQ0wu40wpvYcKfBcc5T4QnhdQjUhtUtB/1CY89lE= github.com/grafana/gomemcache v0.0.0-20240229205252-cd6a66d6fb56/go.mod h1:PGk3RjYHpxMM8HFPhKKo+vve3DdlPUELZLSDEFehPuU= github.com/grafana/jsonparser v0.0.0-20240425183733-ea80629e1a32 h1:NznuPwItog+rwdVg8hAuGKP29ndRSzJAwhxKldkP8oQ= diff --git a/vendor/modules.txt b/vendor/modules.txt index bc92b7462c8e2..73779f49f47d7 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -986,7 +986,7 @@ github.com/gorilla/websocket # github.com/grafana/cloudflare-go v0.0.0-20230110200409-c627cf6792f2 ## explicit; go 1.17 github.com/grafana/cloudflare-go -# github.com/grafana/dskit v0.0.0-20241002104024-b69ac1b95024 +# github.com/grafana/dskit v0.0.0-20241004175247-687ec485facf ## explicit; go 1.21 github.com/grafana/dskit/aws github.com/grafana/dskit/backoff From a05431f879a8c29fac6356b6c46be62133c3e93c Mon Sep 17 00:00:00 2001 From: Callum Styan Date: Mon, 7 Oct 2024 10:01:28 -0700 Subject: [PATCH 17/26] fix: promtail config unmarshalling (#14408) Signed-off-by: Callum Styan --- clients/pkg/promtail/config/config.go | 1 - 1 file changed, 1 deletion(-) diff --git a/clients/pkg/promtail/config/config.go b/clients/pkg/promtail/config/config.go index 0454a8facf494..7e0e2b63fe173 100644 --- a/clients/pkg/promtail/config/config.go +++ b/clients/pkg/promtail/config/config.go @@ -42,7 +42,6 @@ type Config struct { // UnmarshalYAML implements the yaml.Unmarshaler interface. func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { - *c = Config{} // We want to set c to the defaults and then overwrite it with the input. // To make unmarshal fill the plain data struct rather than calling UnmarshalYAML // again, we have to hide it using a type indirection. From 1f3089282a2b4139e4b04a98ccb246f81b4a7cde Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 7 Oct 2024 13:43:34 -0400 Subject: [PATCH 18/26] chore(deps): update dependency fluent-plugin-multi-format-parser to '~>1.1.0' (#14396) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- clients/cmd/fluentd/docker/Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cmd/fluentd/docker/Gemfile b/clients/cmd/fluentd/docker/Gemfile index 981d6e701e63b..f52d506bc3bf9 100644 --- a/clients/cmd/fluentd/docker/Gemfile +++ b/clients/cmd/fluentd/docker/Gemfile @@ -3,4 +3,4 @@ source 'https://rubygems.org' gem 'fluentd', '1.15.3' -gem 'fluent-plugin-multi-format-parser', '~>1.0.0' +gem 'fluent-plugin-multi-format-parser', '~>1.1.0' From 91c7d344fe244471ba4eda2c33c6027663445371 Mon Sep 17 00:00:00 2001 From: Christian Haudum Date: Tue, 8 Oct 2024 09:48:36 +0200 Subject: [PATCH 19/26] chore: Make metric for dequeued tasks in bloom-gateway a Histogram (#14413) This change allows to observe the distribution of how many tasks are dequeued at once over time. Signed-off-by: Christian Haudum --- pkg/bloomgateway/metrics.go | 9 +++++---- pkg/bloomgateway/worker.go | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pkg/bloomgateway/metrics.go b/pkg/bloomgateway/metrics.go index 9fe096eec2ac4..4eeffbf8ad682 100644 --- a/pkg/bloomgateway/metrics.go +++ b/pkg/bloomgateway/metrics.go @@ -119,7 +119,7 @@ type workerMetrics struct { dequeueDuration *prometheus.HistogramVec queueDuration *prometheus.HistogramVec processDuration *prometheus.HistogramVec - tasksDequeued *prometheus.CounterVec + tasksDequeued *prometheus.HistogramVec tasksProcessed *prometheus.CounterVec blocksNotAvailable *prometheus.CounterVec blockQueryLatency *prometheus.HistogramVec @@ -147,11 +147,12 @@ func newWorkerMetrics(registerer prometheus.Registerer, namespace, subsystem str Name: "process_duration_seconds", Help: "Time spent processing tasks in seconds", }, append(labels, "status")), - tasksDequeued: r.NewCounterVec(prometheus.CounterOpts{ + tasksDequeued: r.NewHistogramVec(prometheus.HistogramOpts{ Namespace: namespace, Subsystem: subsystem, - Name: "tasks_dequeued_total", - Help: "Total amount of tasks that the worker dequeued from the queue", + Name: "tasks_dequeued", + Help: "Total amount of tasks that the worker dequeued from the queue at once", + Buckets: prometheus.ExponentialBuckets(1, 2, 8), // [1, 2, ..., 128] }, append(labels, "status")), tasksProcessed: r.NewCounterVec(prometheus.CounterOpts{ Namespace: namespace, diff --git a/pkg/bloomgateway/worker.go b/pkg/bloomgateway/worker.go index 6aa1082b89334..81092448ab52f 100644 --- a/pkg/bloomgateway/worker.go +++ b/pkg/bloomgateway/worker.go @@ -76,7 +76,7 @@ func (w *worker) running(_ context.Context) error { if err == queue.ErrStopped && len(items) == 0 { return err } - w.metrics.tasksDequeued.WithLabelValues(w.id, labelFailure).Inc() + w.metrics.tasksDequeued.WithLabelValues(w.id, labelFailure).Observe(1) level.Error(w.logger).Log("msg", "failed to dequeue tasks", "err", err, "items", len(items)) } idx = newIdx @@ -86,7 +86,7 @@ func (w *worker) running(_ context.Context) error { continue } - w.metrics.tasksDequeued.WithLabelValues(w.id, labelSuccess).Add(float64(len(items))) + w.metrics.tasksDequeued.WithLabelValues(w.id, labelSuccess).Observe(float64(len(items))) tasks := make([]Task, 0, len(items)) for _, item := range items { From 5f325aac56e41848979e9e33a4a443e31ea525d0 Mon Sep 17 00:00:00 2001 From: Robert Fratto Date: Tue, 8 Oct 2024 08:59:47 -0400 Subject: [PATCH 20/26] fix(storage/chunk/client/aws): have GetObject check for canceled context (#14420) --- .../chunk/client/aws/s3_storage_client.go | 2 +- .../client/aws/s3_storage_client_test.go | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/pkg/storage/chunk/client/aws/s3_storage_client.go b/pkg/storage/chunk/client/aws/s3_storage_client.go index 7747f27618008..9ab8c9116339f 100644 --- a/pkg/storage/chunk/client/aws/s3_storage_client.go +++ b/pkg/storage/chunk/client/aws/s3_storage_client.go @@ -393,7 +393,7 @@ func (a *S3ObjectClient) GetObject(ctx context.Context, objectKey string) (io.Re // Map the key into a bucket bucket := a.bucketFromKey(objectKey) - var lastErr error + lastErr := ctx.Err() retries := backoff.New(ctx, a.cfg.BackoffConfig) for retries.Ongoing() { diff --git a/pkg/storage/chunk/client/aws/s3_storage_client_test.go b/pkg/storage/chunk/client/aws/s3_storage_client_test.go index c582d9a4cab51..38b0215b79136 100644 --- a/pkg/storage/chunk/client/aws/s3_storage_client_test.go +++ b/pkg/storage/chunk/client/aws/s3_storage_client_test.go @@ -234,6 +234,31 @@ func TestRequestMiddleware(t *testing.T) { } } +func TestS3ObjectClient_GetObject_CanceledContext(t *testing.T) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + fmt.Fprintln(w, r.Header.Get("echo-me")) + })) + defer ts.Close() + + cfg := S3Config{ + Endpoint: ts.URL, + BucketNames: "buck-o", + S3ForcePathStyle: true, + Insecure: true, + AccessKeyID: "key", + SecretAccessKey: flagext.SecretWithValue("secret"), + } + + client, err := NewS3ObjectClient(cfg, hedging.Config{}) + require.NoError(t, err) + + ctx, cancel := context.WithCancel(context.Background()) + cancel() + + _, _, err = client.GetObject(ctx, "key") + require.Error(t, err, "GetObject should fail when given a canceled context") +} + func Test_Hedging(t *testing.T) { for _, tc := range []struct { name string From 8aa8a2bb0e766da4d64313d17337fa54ab84f8a4 Mon Sep 17 00:00:00 2001 From: benclive Date: Tue, 8 Oct 2024 15:05:10 +0100 Subject: [PATCH 21/26] fix(kafka): Set namespace for Loki kafka metrics (#14426) --- pkg/distributor/distributor.go | 20 ++++++++++++-------- pkg/kafka/writer_client.go | 18 ++++++++++++------ 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/pkg/distributor/distributor.go b/pkg/distributor/distributor.go index 01dae3ee6e0cf..ac815cbe82cdb 100644 --- a/pkg/distributor/distributor.go +++ b/pkg/distributor/distributor.go @@ -279,11 +279,13 @@ func New( Help: "Total number of times the distributor has sharded streams", }), kafkaAppends: promauto.With(registerer).NewCounterVec(prometheus.CounterOpts{ - Name: "kafka_appends_total", - Help: "The total number of appends sent to kafka ingest path.", + Namespace: constants.Loki, + Name: "distributor_kafka_appends_total", + Help: "The total number of appends sent to kafka ingest path.", }, []string{"partition", "status"}), kafkaWriteLatency: promauto.With(registerer).NewHistogram(prometheus.HistogramOpts{ - Name: "kafka_latency_seconds", + Namespace: constants.Loki, + Name: "distributor_kafka_latency_seconds", Help: "Latency to write an incoming request to the ingest storage.", NativeHistogramBucketFactor: 1.1, NativeHistogramMinResetDuration: 1 * time.Hour, @@ -291,13 +293,15 @@ func New( Buckets: prometheus.DefBuckets, }), kafkaWriteBytesTotal: promauto.With(registerer).NewCounter(prometheus.CounterOpts{ - Name: "kafka_sent_bytes_total", - Help: "Total number of bytes sent to the ingest storage.", + Namespace: constants.Loki, + Name: "distributor_kafka_sent_bytes_total", + Help: "Total number of bytes sent to the ingest storage.", }), kafkaRecordsPerRequest: promauto.With(registerer).NewHistogram(prometheus.HistogramOpts{ - Name: "kafka_records_per_write_request", - Help: "The number of records a single per-partition write request has been split into.", - Buckets: prometheus.ExponentialBuckets(1, 2, 8), + Namespace: constants.Loki, + Name: "distributor_kafka_records_per_write_request", + Help: "The number of records a single per-partition write request has been split into.", + Buckets: prometheus.ExponentialBuckets(1, 2, 8), }), writeFailuresManager: writefailures.NewManager(logger, registerer, cfg.WriteFailuresLogging, configs, "distributor"), kafkaWriter: kafkaWriter, diff --git a/pkg/kafka/writer_client.go b/pkg/kafka/writer_client.go index ddd12a646d692..59fefda31d19b 100644 --- a/pkg/kafka/writer_client.go +++ b/pkg/kafka/writer_client.go @@ -18,6 +18,8 @@ import ( "go.opentelemetry.io/otel/propagation" "go.opentelemetry.io/otel/trace" "go.uber.org/atomic" + + "github.com/grafana/loki/v3/pkg/util/constants" ) // NewWriterClient returns the kgo.Client that should be used by the Writer. @@ -189,6 +191,7 @@ func NewProducer(client *kgo.Client, maxBufferedBytes int64, reg prometheus.Regi // Metrics. bufferedProduceBytes: promauto.With(reg).NewSummary( prometheus.SummaryOpts{ + Namespace: constants.Loki, Name: "buffered_produce_bytes", Help: "The buffered produce records in bytes. Quantile buckets keep track of buffered records size over the last 60s.", Objectives: map[float64]float64{0.5: 0.05, 0.99: 0.001, 1: 0.001}, @@ -197,16 +200,19 @@ func NewProducer(client *kgo.Client, maxBufferedBytes int64, reg prometheus.Regi }), bufferedProduceBytesLimit: promauto.With(reg).NewGauge( prometheus.GaugeOpts{ - Name: "buffered_produce_bytes_limit", - Help: "The bytes limit on buffered produce records. Produce requests fail once this limit is reached.", + Namespace: constants.Loki, + Name: "buffered_produce_bytes_limit", + Help: "The bytes limit on buffered produce records. Produce requests fail once this limit is reached.", }), produceRequestsTotal: promauto.With(reg).NewCounter(prometheus.CounterOpts{ - Name: "produce_requests_total", - Help: "Total number of produce requests issued to Kafka.", + Namespace: constants.Loki, + Name: "produce_requests_total", + Help: "Total number of produce requests issued to Kafka.", }), produceFailuresTotal: promauto.With(reg).NewCounterVec(prometheus.CounterOpts{ - Name: "produce_failures_total", - Help: "Total number of failed produce requests issued to Kafka.", + Namespace: constants.Loki, + Name: "produce_failures_total", + Help: "Total number of failed produce requests issued to Kafka.", }, []string{"reason"}), } From 8ec8cfb2c3546dd43b56dd2a603809c367c1d88f Mon Sep 17 00:00:00 2001 From: Jay Clifford <45856600+Jayclifford345@users.noreply.github.com> Date: Tue, 8 Oct 2024 17:32:35 +0100 Subject: [PATCH 22/26] docs: Updated Promtail to Alloy (#14404) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- docs/sources/setup/install/_index.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/sources/setup/install/_index.md b/docs/sources/setup/install/_index.md index 2b56cba78cb69..67356a44d4d91 100644 --- a/docs/sources/setup/install/_index.md +++ b/docs/sources/setup/install/_index.md @@ -9,7 +9,7 @@ weight: 200 # Install Loki -There are several methods of installing Loki and Promtail: +There are several methods of installing Loki: - [Install using Helm (recommended)]({{< relref "./helm" >}}) - [Install using Tanka]({{< relref "./tanka" >}}) @@ -17,12 +17,16 @@ There are several methods of installing Loki and Promtail: - [Install and run locally]({{< relref "./local" >}}) - [Install from source]({{< relref "./install-from-source" >}}) +Alloy: +- [Install Alloy](https://grafana.com/docs/alloy/latest/set-up/install/) +- [Ingest Logs with Alloy]({{< relref "../../send-data/alloy" >}}) + ## General process In order to run Loki, you must: -1. Download and install both Loki and Promtail. +1. Download and install both Loki and Alloy. 1. Download config files for both programs. 1. Start Loki. -1. Update the Promtail config file to get your logs into Loki. -1. Start Promtail. +1. Update the Alloy config file to get your logs into Loki. +1. Start Alloy. From 633bb5eb7e0717c3e1eafaab32f0ba2dacb4f5cd Mon Sep 17 00:00:00 2001 From: benclive Date: Wed, 9 Oct 2024 11:04:05 +0100 Subject: [PATCH 23/26] feat(kafka): Enable querier to optionally query partition ingesters (#14418) --- .golangci.yml | 2 +- docs/sources/shared/configuration.md | 5 + go.mod | 2 +- go.sum | 4 +- pkg/loki/loki.go | 2 +- pkg/loki/modules.go | 7 +- pkg/querier/ingester_querier.go | 75 +++++++--- pkg/querier/ingester_querier_test.go | 141 +++++++++++++++++- pkg/querier/querier.go | 2 + pkg/querier/querier_mock_test.go | 57 ++++++- pkg/querier/querier_test.go | 2 +- .../dskit/ring/partition_instance_ring.go | 16 +- vendor/modules.txt | 2 +- 13 files changed, 283 insertions(+), 34 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index bc607cd1bbc1a..9a3e34b7754bf 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -24,7 +24,7 @@ run: - cgo - promtail_journal_enabled - integration - + # output configuration options output: formats: diff --git a/docs/sources/shared/configuration.md b/docs/sources/shared/configuration.md index 9ee288b493706..b7a10bd142f98 100644 --- a/docs/sources/shared/configuration.md +++ b/docs/sources/shared/configuration.md @@ -4228,6 +4228,11 @@ engine: # When true, querier limits sent via a header are enforced. # CLI flag: -querier.per-request-limits-enabled [per_request_limits_enabled: | default = false] + +# When true, querier directs ingester queries to the partition-ingesters instead +# of the normal ingesters. +# CLI flag: -querier.query_partition_ingesters +[query_partition_ingesters: | default = false] ``` ### query_range diff --git a/go.mod b/go.mod index b1ff86617ebe1..0c577c967130a 100644 --- a/go.mod +++ b/go.mod @@ -51,7 +51,7 @@ require ( github.com/gorilla/mux v1.8.1 github.com/gorilla/websocket v1.5.3 github.com/grafana/cloudflare-go v0.0.0-20230110200409-c627cf6792f2 - github.com/grafana/dskit v0.0.0-20241004175247-687ec485facf + github.com/grafana/dskit v0.0.0-20241007172036-53283a0f6b41 github.com/grafana/go-gelf/v2 v2.0.1 github.com/grafana/gomemcache v0.0.0-20240229205252-cd6a66d6fb56 github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc diff --git a/go.sum b/go.sum index c1129b0ba29a0..13a0bae65536a 100644 --- a/go.sum +++ b/go.sum @@ -1044,8 +1044,8 @@ github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aN github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grafana/cloudflare-go v0.0.0-20230110200409-c627cf6792f2 h1:qhugDMdQ4Vp68H0tp/0iN17DM2ehRo1rLEdOFe/gB8I= github.com/grafana/cloudflare-go v0.0.0-20230110200409-c627cf6792f2/go.mod h1:w/aiO1POVIeXUQyl0VQSZjl5OAGDTL5aX+4v0RA1tcw= -github.com/grafana/dskit v0.0.0-20241004175247-687ec485facf h1:ZafqZwIpdCCMifH9Ok6C98rYaCh5OZeyyHLbU0FPedg= -github.com/grafana/dskit v0.0.0-20241004175247-687ec485facf/go.mod h1:SPLNCARd4xdjCkue0O6hvuoveuS1dGJjDnfxYe405YQ= +github.com/grafana/dskit v0.0.0-20241007172036-53283a0f6b41 h1:a4O59OU3FJZ+EJUVnlvvNTvdAc4uRN1P6EaGwqL9CnA= +github.com/grafana/dskit v0.0.0-20241007172036-53283a0f6b41/go.mod h1:SPLNCARd4xdjCkue0O6hvuoveuS1dGJjDnfxYe405YQ= github.com/grafana/go-gelf/v2 v2.0.1 h1:BOChP0h/jLeD+7F9mL7tq10xVkDG15he3T1zHuQaWak= github.com/grafana/go-gelf/v2 v2.0.1/go.mod h1:lexHie0xzYGwCgiRGcvZ723bSNyNI8ZRD4s0CLobh90= github.com/grafana/gocql v0.0.0-20200605141915-ba5dc39ece85 h1:xLuzPoOzdfNb/RF/IENCw+oLVdZB4G21VPhkHBgwSHY= diff --git a/pkg/loki/loki.go b/pkg/loki/loki.go index 84af0a73504f8..f59218307e7d7 100644 --- a/pkg/loki/loki.go +++ b/pkg/loki/loki.go @@ -736,7 +736,7 @@ func (t *Loki) setupModuleManager() error { PatternRingClient: {Server, MemberlistKV, Analytics}, PatternIngesterTee: {Server, MemberlistKV, Analytics, PatternRingClient}, PatternIngester: {Server, MemberlistKV, Analytics, PatternRingClient, PatternIngesterTee}, - IngesterQuerier: {Ring}, + IngesterQuerier: {Ring, PartitionRing, Overrides}, QuerySchedulerRing: {Overrides, MemberlistKV}, IndexGatewayRing: {Overrides, MemberlistKV}, PartitionRing: {MemberlistKV, Server, Ring}, diff --git a/pkg/loki/modules.go b/pkg/loki/modules.go index 54c6d574f6e51..24e19d7c58e05 100644 --- a/pkg/loki/modules.go +++ b/pkg/loki/modules.go @@ -975,8 +975,9 @@ func (t *Loki) setupAsyncStore() error { } func (t *Loki) initIngesterQuerier() (_ services.Service, err error) { - logger := log.With(util_log.Logger, "component", "querier") - t.ingesterQuerier, err = querier.NewIngesterQuerier(t.Cfg.IngesterClient, t.ring, t.Cfg.Querier.ExtraQueryDelay, t.Cfg.MetricsNamespace, logger) + logger := log.With(util_log.Logger, "component", "ingester-querier") + + t.ingesterQuerier, err = querier.NewIngesterQuerier(t.Cfg.Querier, t.Cfg.IngesterClient, t.ring, t.partitionRing, t.Overrides.IngestionPartitionsTenantShardSize, t.Cfg.MetricsNamespace, logger) if err != nil { return nil, err } @@ -1756,7 +1757,7 @@ func (t *Loki) initAnalytics() (services.Service, error) { // The Ingest Partition Ring is responsible for watching the available ingesters and assigning partitions to incoming requests. func (t *Loki) initPartitionRing() (services.Service, error) { - if !t.Cfg.Ingester.KafkaIngestion.Enabled { + if !t.Cfg.Ingester.KafkaIngestion.Enabled && !t.Cfg.Querier.QueryPartitionIngesters { return nil, nil } diff --git a/pkg/querier/ingester_querier.go b/pkg/querier/ingester_querier.go index c18ca77930667..cc076be1faefd 100644 --- a/pkg/querier/ingester_querier.go +++ b/pkg/querier/ingester_querier.go @@ -8,6 +8,8 @@ import ( "github.com/go-kit/log" "github.com/go-kit/log/level" + "github.com/grafana/dskit/concurrency" + "github.com/grafana/dskit/user" "golang.org/x/exp/slices" "github.com/grafana/loki/v3/pkg/storage/stores/index/seriesvolume" @@ -40,28 +42,32 @@ type responseFromIngesters struct { // IngesterQuerier helps with querying the ingesters. type IngesterQuerier struct { - ring ring.ReadRing - pool *ring_client.Pool - extraQueryDelay time.Duration - logger log.Logger + querierConfig Config + ring ring.ReadRing + partitionRing *ring.PartitionInstanceRing + getShardCountForTenant func(string) int + pool *ring_client.Pool + logger log.Logger } -func NewIngesterQuerier(clientCfg client.Config, ring ring.ReadRing, extraQueryDelay time.Duration, metricsNamespace string, logger log.Logger) (*IngesterQuerier, error) { +func NewIngesterQuerier(querierConfig Config, clientCfg client.Config, ring ring.ReadRing, partitionRing *ring.PartitionInstanceRing, getShardCountForTenant func(string) int, metricsNamespace string, logger log.Logger) (*IngesterQuerier, error) { factory := func(addr string) (ring_client.PoolClient, error) { return client.New(clientCfg, addr) } - return newIngesterQuerier(clientCfg, ring, extraQueryDelay, ring_client.PoolAddrFunc(factory), metricsNamespace, logger) + return newIngesterQuerier(querierConfig, clientCfg, ring, partitionRing, getShardCountForTenant, ring_client.PoolAddrFunc(factory), metricsNamespace, logger) } // newIngesterQuerier creates a new IngesterQuerier and allows to pass a custom ingester client factory // used for testing purposes -func newIngesterQuerier(clientCfg client.Config, ring ring.ReadRing, extraQueryDelay time.Duration, clientFactory ring_client.PoolFactory, metricsNamespace string, logger log.Logger) (*IngesterQuerier, error) { +func newIngesterQuerier(querierConfig Config, clientCfg client.Config, ring ring.ReadRing, partitionRing *ring.PartitionInstanceRing, getShardCountForTenant func(string) int, clientFactory ring_client.PoolFactory, metricsNamespace string, logger log.Logger) (*IngesterQuerier, error) { iq := IngesterQuerier{ - ring: ring, - pool: clientpool.NewPool("ingester", clientCfg.PoolConfig, ring, clientFactory, util_log.Logger, metricsNamespace), - extraQueryDelay: extraQueryDelay, - logger: logger, + querierConfig: querierConfig, + ring: ring, + partitionRing: partitionRing, + getShardCountForTenant: getShardCountForTenant, // limits? + pool: clientpool.NewPool("ingester", clientCfg.PoolConfig, ring, clientFactory, util_log.Logger, metricsNamespace), + logger: logger, } err := services.StartAndAwaitRunning(context.Background(), iq.pool) @@ -73,22 +79,53 @@ func newIngesterQuerier(clientCfg client.Config, ring ring.ReadRing, extraQueryD } // forAllIngesters runs f, in parallel, for all ingesters -// TODO taken from Cortex, see if we can refactor out an usable interface. func (q *IngesterQuerier) forAllIngesters(ctx context.Context, f func(context.Context, logproto.QuerierClient) (interface{}, error)) ([]responseFromIngesters, error) { + if q.querierConfig.QueryPartitionIngesters { + tenantID, err := user.ExtractOrgID(ctx) + if err != nil { + return nil, err + } + tenantShards := q.getShardCountForTenant(tenantID) + subring, err := q.partitionRing.ShuffleShardWithLookback(tenantID, tenantShards, q.querierConfig.QueryIngestersWithin, time.Now()) + if err != nil { + return nil, err + } + replicationSets, err := subring.GetReplicationSetsForOperation(ring.Read) + if err != nil { + return nil, err + } + return q.forGivenIngesterSets(ctx, replicationSets, f) + } + replicationSet, err := q.ring.GetReplicationSetForOperation(ring.Read) if err != nil { return nil, err } - return q.forGivenIngesters(ctx, replicationSet, f) + return q.forGivenIngesters(ctx, replicationSet, defaultQuorumConfig(), f) } -// forGivenIngesters runs f, in parallel, for given ingesters -func (q *IngesterQuerier) forGivenIngesters(ctx context.Context, replicationSet ring.ReplicationSet, f func(context.Context, logproto.QuerierClient) (interface{}, error)) ([]responseFromIngesters, error) { - cfg := ring.DoUntilQuorumConfig{ +// forGivenIngesterSets runs f, in parallel, for given ingester sets +func (q *IngesterQuerier) forGivenIngesterSets(ctx context.Context, replicationSet []ring.ReplicationSet, f func(context.Context, logproto.QuerierClient) (interface{}, error)) ([]responseFromIngesters, error) { + // Enable minimize requests so we initially query a single ingester per replication set, as each replication-set is one partition. + // Ingesters must supply zone information for this to have an effect. + config := ring.DoUntilQuorumConfig{ + MinimizeRequests: true, + } + return concurrency.ForEachJobMergeResults[ring.ReplicationSet, responseFromIngesters](ctx, replicationSet, 0, func(ctx context.Context, set ring.ReplicationSet) ([]responseFromIngesters, error) { + return q.forGivenIngesters(ctx, set, config, f) + }) +} + +func defaultQuorumConfig() ring.DoUntilQuorumConfig { + return ring.DoUntilQuorumConfig{ // Nothing here } - results, err := ring.DoUntilQuorum(ctx, replicationSet, cfg, func(ctx context.Context, ingester *ring.InstanceDesc) (responseFromIngesters, error) { +} + +// forGivenIngesters runs f, in parallel, for given ingesters +func (q *IngesterQuerier) forGivenIngesters(ctx context.Context, replicationSet ring.ReplicationSet, quorumConfig ring.DoUntilQuorumConfig, f func(context.Context, logproto.QuerierClient) (interface{}, error)) ([]responseFromIngesters, error) { + results, err := ring.DoUntilQuorum(ctx, replicationSet, quorumConfig, func(ctx context.Context, ingester *ring.InstanceDesc) (responseFromIngesters, error) { client, err := q.pool.GetClientFor(ingester.Addr) if err != nil { return responseFromIngesters{addr: ingester.Addr}, err @@ -212,7 +249,7 @@ func (q *IngesterQuerier) TailDisconnectedIngesters(ctx context.Context, req *lo } // Instance a tail client for each ingester to re(connect) - reconnectClients, err := q.forGivenIngesters(ctx, ring.ReplicationSet{Instances: reconnectIngesters}, func(_ context.Context, client logproto.QuerierClient) (interface{}, error) { + reconnectClients, err := q.forGivenIngesters(ctx, ring.ReplicationSet{Instances: reconnectIngesters}, defaultQuorumConfig(), func(_ context.Context, client logproto.QuerierClient) (interface{}, error) { return client.Tail(ctx, req) }) if err != nil { @@ -260,7 +297,7 @@ func (q *IngesterQuerier) TailersCount(ctx context.Context) ([]uint32, error) { return nil, httpgrpc.Errorf(http.StatusInternalServerError, "no active ingester found") } - responses, err := q.forGivenIngesters(ctx, replicationSet, func(ctx context.Context, querierClient logproto.QuerierClient) (interface{}, error) { + responses, err := q.forGivenIngesters(ctx, replicationSet, defaultQuorumConfig(), func(ctx context.Context, querierClient logproto.QuerierClient) (interface{}, error) { resp, err := querierClient.TailersCount(ctx, &logproto.TailersCountRequest{}) if err != nil { return nil, err diff --git a/pkg/querier/ingester_querier_test.go b/pkg/querier/ingester_querier_test.go index dbc37350f038a..788902c2624ed 100644 --- a/pkg/querier/ingester_querier_test.go +++ b/pkg/querier/ingester_querier_test.go @@ -8,6 +8,7 @@ import ( "time" "github.com/go-kit/log" + "github.com/grafana/dskit/user" "go.uber.org/atomic" "google.golang.org/grpc/codes" @@ -224,6 +225,129 @@ func TestIngesterQuerier_earlyExitOnQuorum(t *testing.T) { } } +func TestIngesterQuerierFetchesResponsesFromPartitionIngesters(t *testing.T) { + t.Parallel() + ctx := user.InjectOrgID(context.Background(), "test-user") + ctx, cancel := context.WithTimeout(ctx, time.Second*10) + defer cancel() + + ingesters := []ring.InstanceDesc{ + mockInstanceDescWithZone("1.1.1.1", ring.ACTIVE, "A"), + mockInstanceDescWithZone("2.2.2.2", ring.ACTIVE, "B"), + mockInstanceDescWithZone("3.3.3.3", ring.ACTIVE, "A"), + mockInstanceDescWithZone("4.4.4.4", ring.ACTIVE, "B"), + mockInstanceDescWithZone("5.5.5.5", ring.ACTIVE, "A"), + mockInstanceDescWithZone("6.6.6.6", ring.ACTIVE, "B"), + } + + tests := map[string]struct { + method string + testFn func(*IngesterQuerier) error + retVal interface{} + shards int + }{ + "label": { + method: "Label", + testFn: func(ingesterQuerier *IngesterQuerier) error { + _, err := ingesterQuerier.Label(ctx, nil) + return err + }, + retVal: new(logproto.LabelResponse), + }, + "series": { + method: "Series", + testFn: func(ingesterQuerier *IngesterQuerier) error { + _, err := ingesterQuerier.Series(ctx, nil) + return err + }, + retVal: new(logproto.SeriesResponse), + }, + "get_chunk_ids": { + method: "GetChunkIDs", + testFn: func(ingesterQuerier *IngesterQuerier) error { + _, err := ingesterQuerier.GetChunkIDs(ctx, model.Time(0), model.Time(0)) + return err + }, + retVal: new(logproto.GetChunkIDsResponse), + }, + "select_logs": { + method: "Query", + testFn: func(ingesterQuerier *IngesterQuerier) error { + _, err := ingesterQuerier.SelectLogs(ctx, logql.SelectLogParams{ + QueryRequest: new(logproto.QueryRequest), + }) + return err + }, + retVal: newQueryClientMock(), + }, + "select_sample": { + method: "QuerySample", + testFn: func(ingesterQuerier *IngesterQuerier) error { + _, err := ingesterQuerier.SelectSample(ctx, logql.SelectSampleParams{ + SampleQueryRequest: new(logproto.SampleQueryRequest), + }) + return err + }, + retVal: newQuerySampleClientMock(), + }, + "select_logs_shuffle_sharded": { + method: "Query", + testFn: func(ingesterQuerier *IngesterQuerier) error { + _, err := ingesterQuerier.SelectLogs(ctx, logql.SelectLogParams{ + QueryRequest: new(logproto.QueryRequest), + }) + return err + }, + retVal: newQueryClientMock(), + shards: 2, // Must be less than number of partitions + }, + } + + for testName, testData := range tests { + cnt := atomic.NewInt32(0) + + t.Run(testName, func(t *testing.T) { + cnt.Store(0) + runFn := func(args mock.Arguments) { + ctx := args[0].(context.Context) + + select { + case <-ctx.Done(): + // should not be cancelled by the tracker + require.NoError(t, ctx.Err()) + default: + cnt.Add(1) + } + } + + instanceRing := newReadRingMock(ingesters, 0) + ingesterClient := newQuerierClientMock() + ingesterClient.On(testData.method, mock.Anything, mock.Anything, mock.Anything).Return(testData.retVal, nil).Run(runFn) + + partitions := 3 + ingestersPerPartition := len(ingesters) / partitions + assert.Greaterf(t, ingestersPerPartition, 1, "must have more than one ingester per partition") + + ingesterQuerier, err := newTestPartitionIngesterQuerier(ingesterClient, instanceRing, newPartitionInstanceRingMock(instanceRing, ingesters, partitions, ingestersPerPartition), testData.shards) + require.NoError(t, err) + + ingesterQuerier.querierConfig.QueryPartitionIngesters = true + + err = testData.testFn(ingesterQuerier) + require.NoError(t, err) + + if testData.shards == 0 { + testData.shards = partitions + } + expectedCalls := min(testData.shards, partitions) + // Wait for responses: We expect one request per queried partition because we have request minimization enabled & ingesters are in multiple zones. + // If shuffle sharding is enabled, we expect one query per shard as we write to a subset of partitions. + require.Eventually(t, func() bool { return cnt.Load() >= int32(expectedCalls) }, time.Millisecond*100, time.Millisecond*1, "expected all ingesters to respond") + ingesterClient.AssertNumberOfCalls(t, testData.method, expectedCalls) + }) + } +} + func TestQuerier_tailDisconnectedIngesters(t *testing.T) { t.Parallel() @@ -400,9 +524,24 @@ func TestIngesterQuerier_DetectedLabels(t *testing.T) { func newTestIngesterQuerier(readRingMock *readRingMock, ingesterClient *querierClientMock) (*IngesterQuerier, error) { return newIngesterQuerier( + mockQuerierConfig(), mockIngesterClientConfig(), readRingMock, - mockQuerierConfig().ExtraQueryDelay, + nil, + func(string) int { return 0 }, + newIngesterClientMockFactory(ingesterClient), + constants.Loki, + log.NewNopLogger(), + ) +} + +func newTestPartitionIngesterQuerier(ingesterClient *querierClientMock, instanceRing *readRingMock, partitionRing *ring.PartitionInstanceRing, tenantShards int) (*IngesterQuerier, error) { + return newIngesterQuerier( + mockQuerierConfig(), + mockIngesterClientConfig(), + instanceRing, + partitionRing, + func(string) int { return tenantShards }, newIngesterClientMockFactory(ingesterClient), constants.Loki, log.NewNopLogger(), diff --git a/pkg/querier/querier.go b/pkg/querier/querier.go index 7c7f973b8c90c..a3a8309829f40 100644 --- a/pkg/querier/querier.go +++ b/pkg/querier/querier.go @@ -72,6 +72,7 @@ type Config struct { QueryIngesterOnly bool `yaml:"query_ingester_only"` MultiTenantQueriesEnabled bool `yaml:"multi_tenant_queries_enabled"` PerRequestLimitsEnabled bool `yaml:"per_request_limits_enabled"` + QueryPartitionIngesters bool `yaml:"query_partition_ingesters" category:"experimental"` } // RegisterFlags register flags. @@ -85,6 +86,7 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) { f.BoolVar(&cfg.QueryIngesterOnly, "querier.query-ingester-only", false, "When true, queriers only query the ingesters, and not stored data. This is useful when the object store is unavailable.") f.BoolVar(&cfg.MultiTenantQueriesEnabled, "querier.multi-tenant-queries-enabled", false, "When true, allow queries to span multiple tenants.") f.BoolVar(&cfg.PerRequestLimitsEnabled, "querier.per-request-limits-enabled", false, "When true, querier limits sent via a header are enforced.") + f.BoolVar(&cfg.QueryPartitionIngesters, "querier.query_partition_ingesters", false, "When true, querier directs ingester queries to the partition-ingesters instead of the normal ingesters.") } // Validate validates the config. diff --git a/pkg/querier/querier_mock_test.go b/pkg/querier/querier_mock_test.go index df89d6b695611..ab70de4baacea 100644 --- a/pkg/querier/querier_mock_test.go +++ b/pkg/querier/querier_mock_test.go @@ -17,7 +17,6 @@ import ( "github.com/grafana/dskit/grpcclient" "github.com/grafana/dskit/ring" ring_client "github.com/grafana/dskit/ring/client" - logql_log "github.com/grafana/loki/v3/pkg/logql/log" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/model" "github.com/prometheus/prometheus/model/labels" @@ -25,6 +24,8 @@ import ( "google.golang.org/grpc/health/grpc_health_v1" grpc_metadata "google.golang.org/grpc/metadata" + logql_log "github.com/grafana/loki/v3/pkg/logql/log" + "github.com/grafana/loki/v3/pkg/distributor/clientpool" "github.com/grafana/loki/v3/pkg/ingester/client" "github.com/grafana/loki/v3/pkg/iter" @@ -419,6 +420,54 @@ func newReadRingMock(ingesters []ring.InstanceDesc, maxErrors int) *readRingMock } } +func (r *readRingMock) GetInstance(addr string) (ring.InstanceDesc, error) { + for _, ing := range r.replicationSet.Instances { + if ing.Addr == addr { + return ing, nil + } + } + return ring.InstanceDesc{}, errors.New("instance not found") +} + +// partitionRingMock is a mocked version of a ReadRing, used in querier unit tests +// to control the pool of ingesters available +type partitionRingMock struct { + ring *ring.PartitionRing +} + +func (p partitionRingMock) PartitionRing() *ring.PartitionRing { + return p.ring +} + +func newPartitionInstanceRingMock(ingesterRing ring.InstanceRingReader, ingesters []ring.InstanceDesc, numPartitions int, ingestersPerPartition int) *ring.PartitionInstanceRing { + partitions := make(map[int32]ring.PartitionDesc) + owners := make(map[string]ring.OwnerDesc) + for i := 0; i < numPartitions; i++ { + partitions[int32(i)] = ring.PartitionDesc{ + Id: int32(i), + State: ring.PartitionActive, + Tokens: []uint32{uint32(i)}, + } + + for j := 0; j < ingestersPerPartition; j++ { + ingesterIdx := i*ingestersPerPartition + j + if ingesterIdx < len(ingesters) { + owners[ingesters[ingesterIdx].Id] = ring.OwnerDesc{ + OwnedPartition: int32(i), + State: ring.OwnerActive, + } + } + } + } + partitionRing := partitionRingMock{ + ring: ring.NewPartitionRing(ring.PartitionRingDesc{ + Partitions: partitions, + Owners: owners, + }), + } + return ring.NewPartitionInstanceRing(partitionRing, ingesterRing, time.Hour) +} + func (r *readRingMock) Describe(_ chan<- *prometheus.Desc) { } @@ -518,11 +567,17 @@ func mockReadRingWithOneActiveIngester() *readRingMock { } func mockInstanceDesc(addr string, state ring.InstanceState) ring.InstanceDesc { + return mockInstanceDescWithZone(addr, state, "") +} + +func mockInstanceDescWithZone(addr string, state ring.InstanceState, zone string) ring.InstanceDesc { return ring.InstanceDesc{ + Id: addr, Addr: addr, Timestamp: time.Now().UnixNano(), State: state, Tokens: []uint32{1, 2, 3}, + Zone: zone, } } diff --git a/pkg/querier/querier_test.go b/pkg/querier/querier_test.go index b24491b87f6ba..41265e00df59f 100644 --- a/pkg/querier/querier_test.go +++ b/pkg/querier/querier_test.go @@ -1360,7 +1360,7 @@ func TestQuerier_SelectSamplesWithDeletes(t *testing.T) { } func newQuerier(cfg Config, clientCfg client.Config, clientFactory ring_client.PoolFactory, ring ring.ReadRing, dg *mockDeleteGettter, store storage.Store, limits *validation.Overrides) (*SingleTenantQuerier, error) { - iq, err := newIngesterQuerier(clientCfg, ring, cfg.ExtraQueryDelay, clientFactory, constants.Loki, util_log.Logger) + iq, err := newIngesterQuerier(cfg, clientCfg, ring, nil, nil, clientFactory, constants.Loki, util_log.Logger) if err != nil { return nil, err } diff --git a/vendor/github.com/grafana/dskit/ring/partition_instance_ring.go b/vendor/github.com/grafana/dskit/ring/partition_instance_ring.go index 2fb15d8af98d7..cffa4b2fcc5d7 100644 --- a/vendor/github.com/grafana/dskit/ring/partition_instance_ring.go +++ b/vendor/github.com/grafana/dskit/ring/partition_instance_ring.go @@ -13,15 +13,25 @@ type PartitionRingReader interface { PartitionRing() *PartitionRing } +type InstanceRingReader interface { + // GetInstance return the InstanceDesc for the given instanceID or an error + // if the instance doesn't exist in the ring. The returned InstanceDesc is NOT a + // deep copy, so the caller should never modify it. + GetInstance(string) (InstanceDesc, error) + + // InstancesCount returns the number of instances in the ring. + InstancesCount() int +} + // PartitionInstanceRing holds a partitions ring and a instances ring, and provide functions // to look up the intersection of the two (e.g. healthy instances by partition). type PartitionInstanceRing struct { partitionsRingReader PartitionRingReader - instancesRing *Ring + instancesRing InstanceRingReader heartbeatTimeout time.Duration } -func NewPartitionInstanceRing(partitionsRingWatcher PartitionRingReader, instancesRing *Ring, heartbeatTimeout time.Duration) *PartitionInstanceRing { +func NewPartitionInstanceRing(partitionsRingWatcher PartitionRingReader, instancesRing InstanceRingReader, heartbeatTimeout time.Duration) *PartitionInstanceRing { return &PartitionInstanceRing{ partitionsRingReader: partitionsRingWatcher, instancesRing: instancesRing, @@ -33,7 +43,7 @@ func (r *PartitionInstanceRing) PartitionRing() *PartitionRing { return r.partitionsRingReader.PartitionRing() } -func (r *PartitionInstanceRing) InstanceRing() *Ring { +func (r *PartitionInstanceRing) InstanceRing() InstanceRingReader { return r.instancesRing } diff --git a/vendor/modules.txt b/vendor/modules.txt index 73779f49f47d7..81d67b023fca7 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -986,7 +986,7 @@ github.com/gorilla/websocket # github.com/grafana/cloudflare-go v0.0.0-20230110200409-c627cf6792f2 ## explicit; go 1.17 github.com/grafana/cloudflare-go -# github.com/grafana/dskit v0.0.0-20241004175247-687ec485facf +# github.com/grafana/dskit v0.0.0-20241007172036-53283a0f6b41 ## explicit; go 1.21 github.com/grafana/dskit/aws github.com/grafana/dskit/backoff From fdeec618f0098bc56e03e5a4a530c44703bedd94 Mon Sep 17 00:00:00 2001 From: Christian Haudum Date: Wed, 9 Oct 2024 13:43:02 +0200 Subject: [PATCH 24/26] chore: Log errors when processing a download task fails (#14436) At the moment, errors are silently ignored when asynchronous blocks downloading fails. Signed-off-by: Christian Haudum --- pkg/storage/stores/shipper/bloomshipper/fetcher.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/storage/stores/shipper/bloomshipper/fetcher.go b/pkg/storage/stores/shipper/bloomshipper/fetcher.go index 053078180547a..e49852d777b01 100644 --- a/pkg/storage/stores/shipper/bloomshipper/fetcher.go +++ b/pkg/storage/stores/shipper/bloomshipper/fetcher.go @@ -316,7 +316,10 @@ func (f *Fetcher) FetchBlocks(ctx context.Context, refs []BlockRef, opts ...Fetc } func (f *Fetcher) processTask(ctx context.Context, task downloadRequest[BlockRef, BlockDirectory]) { + errLogger := log.With(f.logger, "task", task.key, "msg", "failed to process download request") + if ctx.Err() != nil { + level.Error(errLogger).Log("err", ctx.Err()) task.errors <- ctx.Err() return } @@ -324,6 +327,7 @@ func (f *Fetcher) processTask(ctx context.Context, task downloadRequest[BlockRef // check if block was fetched while task was waiting in queue result, exists, err := f.fromCache(ctx, task.key) if err != nil { + level.Error(errLogger).Log("err", err) task.errors <- err return } @@ -341,6 +345,7 @@ func (f *Fetcher) processTask(ctx context.Context, task downloadRequest[BlockRef // fetch from storage result, err = f.fetchBlock(ctx, task.item) if err != nil { + level.Error(errLogger).Log("err", err) task.errors <- err return } @@ -354,6 +359,7 @@ func (f *Fetcher) processTask(ctx context.Context, task downloadRequest[BlockRef err = f.blocksCache.PutInc(ctx, key, result) } if err != nil { + level.Error(errLogger).Log("err", err) task.errors <- err return } From d53955bbff5abae63a166099cef1f26b450a31f1 Mon Sep 17 00:00:00 2001 From: Trevor Whitney Date: Wed, 9 Oct 2024 09:46:47 -0600 Subject: [PATCH 25/26] fix: Revert "fix(deps): update module github.com/shirou/gopsutil/v4 to v4.24.9 (#14357)" (#14437) --- go.mod | 4 +- go.sum | 10 +- .../github.com/ebitengine/purego/.gitignore | 1 - vendor/github.com/ebitengine/purego/LICENSE | 201 - vendor/github.com/ebitengine/purego/README.md | 97 - .../github.com/ebitengine/purego/abi_amd64.h | 99 - .../github.com/ebitengine/purego/abi_arm64.h | 39 - vendor/github.com/ebitengine/purego/cgo.go | 19 - .../github.com/ebitengine/purego/dlerror.go | 17 - vendor/github.com/ebitengine/purego/dlfcn.go | 99 - .../ebitengine/purego/dlfcn_android.go | 34 - .../ebitengine/purego/dlfcn_darwin.go | 24 - .../ebitengine/purego/dlfcn_freebsd.go | 14 - .../ebitengine/purego/dlfcn_linux.go | 16 - .../ebitengine/purego/dlfcn_nocgo_freebsd.go | 11 - .../ebitengine/purego/dlfcn_nocgo_linux.go | 19 - .../ebitengine/purego/dlfcn_playground.go | 24 - .../ebitengine/purego/dlfcn_stubs.s | 26 - vendor/github.com/ebitengine/purego/func.go | 436 -- .../ebitengine/purego/go_runtime.go | 13 - .../purego/internal/cgo/dlfcn_cgo_unix.go | 56 - .../ebitengine/purego/internal/cgo/empty.go | 6 - .../purego/internal/cgo/syscall_cgo_unix.go | 55 - .../purego/internal/fakecgo/abi_amd64.h | 99 - .../purego/internal/fakecgo/abi_arm64.h | 39 - .../purego/internal/fakecgo/asm_amd64.s | 39 - .../purego/internal/fakecgo/asm_arm64.s | 36 - .../purego/internal/fakecgo/callbacks.go | 93 - .../ebitengine/purego/internal/fakecgo/doc.go | 32 - .../purego/internal/fakecgo/freebsd.go | 27 - .../internal/fakecgo/go_darwin_amd64.go | 73 - .../internal/fakecgo/go_darwin_arm64.go | 88 - .../internal/fakecgo/go_freebsd_amd64.go | 95 - .../internal/fakecgo/go_freebsd_arm64.go | 98 - .../purego/internal/fakecgo/go_libinit.go | 66 - .../purego/internal/fakecgo/go_linux_amd64.go | 95 - .../purego/internal/fakecgo/go_linux_arm64.go | 98 - .../purego/internal/fakecgo/go_setenv.go | 18 - .../purego/internal/fakecgo/go_util.go | 37 - .../purego/internal/fakecgo/iscgo.go | 19 - .../purego/internal/fakecgo/libcgo.go | 35 - .../purego/internal/fakecgo/libcgo_darwin.go | 22 - .../purego/internal/fakecgo/libcgo_freebsd.go | 16 - .../purego/internal/fakecgo/libcgo_linux.go | 16 - .../purego/internal/fakecgo/setenv.go | 19 - .../purego/internal/fakecgo/symbols.go | 181 - .../purego/internal/fakecgo/symbols_darwin.go | 29 - .../internal/fakecgo/symbols_freebsd.go | 29 - .../purego/internal/fakecgo/symbols_linux.go | 29 - .../internal/fakecgo/trampolines_amd64.s | 104 - .../internal/fakecgo/trampolines_arm64.s | 72 - .../internal/fakecgo/trampolines_stubs.s | 90 - .../purego/internal/strings/strings.go | 40 - vendor/github.com/ebitengine/purego/is_ios.go | 13 - vendor/github.com/ebitengine/purego/nocgo.go | 25 - .../ebitengine/purego/struct_amd64.go | 272 -- .../ebitengine/purego/struct_arm64.go | 274 -- .../ebitengine/purego/struct_other.go | 16 - .../github.com/ebitengine/purego/sys_amd64.s | 164 - .../github.com/ebitengine/purego/sys_arm64.s | 92 - .../ebitengine/purego/sys_unix_arm64.s | 70 - .../github.com/ebitengine/purego/syscall.go | 53 - .../ebitengine/purego/syscall_cgo_linux.go | 21 - .../ebitengine/purego/syscall_sysv.go | 223 - .../ebitengine/purego/syscall_windows.go | 46 - .../ebitengine/purego/zcallback_amd64.s | 2014 --------- .../ebitengine/purego/zcallback_arm64.s | 4014 ----------------- .../shirou/gopsutil/v4/common/env.go | 15 +- .../shirou/gopsutil/v4/cpu/cpu_darwin.go | 105 +- .../gopsutil/v4/cpu/cpu_darwin_arm64.go | 80 - .../shirou/gopsutil/v4/cpu/cpu_darwin_cgo.go | 111 + .../gopsutil/v4/cpu/cpu_darwin_fallback.go | 13 - .../gopsutil/v4/cpu/cpu_darwin_nocgo.go | 14 + .../v4/internal/common/common_darwin.go | 298 -- .../v4/internal/common/common_unix.go | 20 + .../shirou/gopsutil/v4/mem/mem_darwin.go | 58 - .../shirou/gopsutil/v4/mem/mem_darwin_cgo.go | 58 + .../gopsutil/v4/mem/mem_darwin_nocgo.go | 89 + .../shirou/gopsutil/v4/process/process.go | 2 +- .../gopsutil/v4/process/process_darwin.go | 283 +- .../v4/process/process_darwin_amd64.go | 21 - .../v4/process/process_darwin_arm64.go | 21 - .../gopsutil/v4/process/process_darwin_cgo.go | 222 + .../v4/process/process_darwin_nocgo.go | 134 + .../gopsutil/v4/process/process_freebsd.go | 18 +- .../gopsutil/v4/process/process_linux.go | 35 +- .../gopsutil/v4/process/process_openbsd.go | 18 +- .../gopsutil/v4/process/process_windows.go | 16 +- .../shoenig/go-m1cpu/.golangci.yaml | 12 + vendor/github.com/shoenig/go-m1cpu/LICENSE | 363 ++ vendor/github.com/shoenig/go-m1cpu/Makefile | 12 + vendor/github.com/shoenig/go-m1cpu/README.md | 66 + vendor/github.com/shoenig/go-m1cpu/cpu.go | 213 + .../shoenig/go-m1cpu/incompatible.go | 53 + vendor/modules.txt | 11 +- 95 files changed, 1489 insertions(+), 11223 deletions(-) delete mode 100644 vendor/github.com/ebitengine/purego/.gitignore delete mode 100644 vendor/github.com/ebitengine/purego/LICENSE delete mode 100644 vendor/github.com/ebitengine/purego/README.md delete mode 100644 vendor/github.com/ebitengine/purego/abi_amd64.h delete mode 100644 vendor/github.com/ebitengine/purego/abi_arm64.h delete mode 100644 vendor/github.com/ebitengine/purego/cgo.go delete mode 100644 vendor/github.com/ebitengine/purego/dlerror.go delete mode 100644 vendor/github.com/ebitengine/purego/dlfcn.go delete mode 100644 vendor/github.com/ebitengine/purego/dlfcn_android.go delete mode 100644 vendor/github.com/ebitengine/purego/dlfcn_darwin.go delete mode 100644 vendor/github.com/ebitengine/purego/dlfcn_freebsd.go delete mode 100644 vendor/github.com/ebitengine/purego/dlfcn_linux.go delete mode 100644 vendor/github.com/ebitengine/purego/dlfcn_nocgo_freebsd.go delete mode 100644 vendor/github.com/ebitengine/purego/dlfcn_nocgo_linux.go delete mode 100644 vendor/github.com/ebitengine/purego/dlfcn_playground.go delete mode 100644 vendor/github.com/ebitengine/purego/dlfcn_stubs.s delete mode 100644 vendor/github.com/ebitengine/purego/func.go delete mode 100644 vendor/github.com/ebitengine/purego/go_runtime.go delete mode 100644 vendor/github.com/ebitengine/purego/internal/cgo/dlfcn_cgo_unix.go delete mode 100644 vendor/github.com/ebitengine/purego/internal/cgo/empty.go delete mode 100644 vendor/github.com/ebitengine/purego/internal/cgo/syscall_cgo_unix.go delete mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/abi_amd64.h delete mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/abi_arm64.h delete mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/asm_amd64.s delete mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/asm_arm64.s delete mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/callbacks.go delete mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/doc.go delete mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/freebsd.go delete mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/go_darwin_amd64.go delete mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/go_darwin_arm64.go delete mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/go_freebsd_amd64.go delete mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/go_freebsd_arm64.go delete mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/go_libinit.go delete mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/go_linux_amd64.go delete mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/go_linux_arm64.go delete mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/go_setenv.go delete mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/go_util.go delete mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/iscgo.go delete mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo.go delete mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_darwin.go delete mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_freebsd.go delete mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_linux.go delete mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/setenv.go delete mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/symbols.go delete mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/symbols_darwin.go delete mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/symbols_freebsd.go delete mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/symbols_linux.go delete mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_amd64.s delete mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_arm64.s delete mode 100644 vendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_stubs.s delete mode 100644 vendor/github.com/ebitengine/purego/internal/strings/strings.go delete mode 100644 vendor/github.com/ebitengine/purego/is_ios.go delete mode 100644 vendor/github.com/ebitengine/purego/nocgo.go delete mode 100644 vendor/github.com/ebitengine/purego/struct_amd64.go delete mode 100644 vendor/github.com/ebitengine/purego/struct_arm64.go delete mode 100644 vendor/github.com/ebitengine/purego/struct_other.go delete mode 100644 vendor/github.com/ebitengine/purego/sys_amd64.s delete mode 100644 vendor/github.com/ebitengine/purego/sys_arm64.s delete mode 100644 vendor/github.com/ebitengine/purego/sys_unix_arm64.s delete mode 100644 vendor/github.com/ebitengine/purego/syscall.go delete mode 100644 vendor/github.com/ebitengine/purego/syscall_cgo_linux.go delete mode 100644 vendor/github.com/ebitengine/purego/syscall_sysv.go delete mode 100644 vendor/github.com/ebitengine/purego/syscall_windows.go delete mode 100644 vendor/github.com/ebitengine/purego/zcallback_amd64.s delete mode 100644 vendor/github.com/ebitengine/purego/zcallback_arm64.s delete mode 100644 vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin_arm64.go create mode 100644 vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin_cgo.go delete mode 100644 vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin_fallback.go create mode 100644 vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin_nocgo.go create mode 100644 vendor/github.com/shirou/gopsutil/v4/mem/mem_darwin_cgo.go create mode 100644 vendor/github.com/shirou/gopsutil/v4/mem/mem_darwin_nocgo.go create mode 100644 vendor/github.com/shirou/gopsutil/v4/process/process_darwin_cgo.go create mode 100644 vendor/github.com/shirou/gopsutil/v4/process/process_darwin_nocgo.go create mode 100644 vendor/github.com/shoenig/go-m1cpu/.golangci.yaml create mode 100644 vendor/github.com/shoenig/go-m1cpu/LICENSE create mode 100644 vendor/github.com/shoenig/go-m1cpu/Makefile create mode 100644 vendor/github.com/shoenig/go-m1cpu/README.md create mode 100644 vendor/github.com/shoenig/go-m1cpu/cpu.go create mode 100644 vendor/github.com/shoenig/go-m1cpu/incompatible.go diff --git a/go.mod b/go.mod index 0c577c967130a..bfccc98c18c0d 100644 --- a/go.mod +++ b/go.mod @@ -138,7 +138,7 @@ require ( github.com/prometheus/common/sigv4 v0.1.0 github.com/richardartoul/molecule v1.0.0 github.com/schollz/progressbar/v3 v3.14.6 - github.com/shirou/gopsutil/v4 v4.24.9 + github.com/shirou/gopsutil/v4 v4.24.8 github.com/thanos-io/objstore v0.0.0-20240818203309-0363dadfdfb1 github.com/twmb/franz-go v1.17.1 github.com/twmb/franz-go/pkg/kadm v1.13.0 @@ -168,7 +168,6 @@ require ( github.com/coreos/etcd v3.3.27+incompatible // indirect github.com/coreos/pkg v0.0.0-20220810130054-c7d1c02cb6cf // indirect github.com/dlclark/regexp2 v1.4.0 // indirect - github.com/ebitengine/purego v0.8.0 // indirect github.com/gabriel-vasile/mimetype v1.4.3 // indirect github.com/go-ini/ini v1.67.0 // indirect github.com/go-ole/go-ole v1.2.6 // indirect @@ -182,6 +181,7 @@ require ( github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect github.com/rivo/uniseg v0.4.7 // indirect + github.com/shoenig/go-m1cpu v0.1.6 // indirect github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/numcpus v0.6.1 // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect diff --git a/go.sum b/go.sum index 13a0bae65536a..62b957a7ce01c 100644 --- a/go.sum +++ b/go.sum @@ -578,8 +578,6 @@ github.com/eapache/go-xerial-snappy v0.0.0-20230111030713-bf00bc1b83b6 h1:8yY/I9 github.com/eapache/go-xerial-snappy v0.0.0-20230111030713-bf00bc1b83b6/go.mod h1:YvSRo5mw33fLEx1+DlK6L2VV43tJt5Eyel9n9XBcR+0= github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= -github.com/ebitengine/purego v0.8.0 h1:JbqvnEzRvPpxhCJzJJ2y0RbiZ8nyjccVUrSM3q+GvvE= -github.com/ebitengine/purego v0.8.0/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ= github.com/eclipse/paho.mqtt.golang v1.2.0/go.mod h1:H9keYFcgq3Qr5OUJm/JZI/i6U7joQ8SYLhZwfeOo6Ts= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/edsrzf/mmap-go v1.1.0 h1:6EUwBLQ/Mcr1EYLE4Tn1VdW1A4ckqCQWZBw8Hr0kjpQ= @@ -1711,8 +1709,12 @@ github.com/sercand/kuberesolver/v5 v5.1.1/go.mod h1:Fs1KbKhVRnB2aDWN12NjKCB+RgYM github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/shirou/gopsutil v2.20.9+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil/v3 v3.22.8/go.mod h1:s648gW4IywYzUfE/KjXxUsqrqx/T2xO5VqOXxONeRfI= -github.com/shirou/gopsutil/v4 v4.24.9 h1:KIV+/HaHD5ka5f570RZq+2SaeFsb/pq+fp2DGNWYoOI= -github.com/shirou/gopsutil/v4 v4.24.9/go.mod h1:3fkaHNeYsUFCGZ8+9vZVWtbyM1k2eRnlL+bWO8Bxa/Q= +github.com/shirou/gopsutil/v4 v4.24.8 h1:pVQjIenQkIhqO81mwTaXjTzOMT7d3TZkf43PlVFHENI= +github.com/shirou/gopsutil/v4 v4.24.8/go.mod h1:wE0OrJtj4dG+hYkxqDH3QiBICdKSf04/npcvLLc/oRg= +github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= +github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= +github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= +github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k= github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= github.com/shopspring/decimal v0.0.0-20200105231215-408a2507e114/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= diff --git a/vendor/github.com/ebitengine/purego/.gitignore b/vendor/github.com/ebitengine/purego/.gitignore deleted file mode 100644 index b25c15b81fae0..0000000000000 --- a/vendor/github.com/ebitengine/purego/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*~ diff --git a/vendor/github.com/ebitengine/purego/LICENSE b/vendor/github.com/ebitengine/purego/LICENSE deleted file mode 100644 index 8dada3edaf50d..0000000000000 --- a/vendor/github.com/ebitengine/purego/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/github.com/ebitengine/purego/README.md b/vendor/github.com/ebitengine/purego/README.md deleted file mode 100644 index f1ff9053aceeb..0000000000000 --- a/vendor/github.com/ebitengine/purego/README.md +++ /dev/null @@ -1,97 +0,0 @@ -# purego -[![Go Reference](https://pkg.go.dev/badge/github.com/ebitengine/purego?GOOS=darwin.svg)](https://pkg.go.dev/github.com/ebitengine/purego?GOOS=darwin) - -A library for calling C functions from Go without Cgo. - -> This is beta software so expect bugs and potentially API breaking changes -> but each release will be tagged to avoid breaking people's code. -> Bug reports are encouraged. - -## Motivation - -The [Ebitengine](https://github.com/hajimehoshi/ebiten) game engine was ported to use only Go on Windows. This enabled -cross-compiling to Windows from any other operating system simply by setting `GOOS=windows`. The purego project was -born to bring that same vision to the other platforms supported by Ebitengine. - -## Benefits - -- **Simple Cross-Compilation**: No C means you can build for other platforms easily without a C compiler. -- **Faster Compilation**: Efficiently cache your entirely Go builds. -- **Smaller Binaries**: Using Cgo generates a C wrapper function for each C function called. Purego doesn't! -- **Dynamic Linking**: Load symbols at runtime and use it as a plugin system. -- **Foreign Function Interface**: Call into other languages that are compiled into shared objects. -- **Cgo Fallback**: Works even with CGO_ENABLED=1 so incremental porting is possible. -This also means unsupported GOARCHs (freebsd/riscv64, linux/mips, etc.) will still work -except for float arguments and return values. - -## Supported Platforms - -- **FreeBSD**: amd64, arm64 -- **Linux**: amd64, arm64 -- **macOS / iOS**: amd64, arm64 -- **Windows**: 386*, amd64, arm*, arm64 - -`*` These architectures only support SyscallN and NewCallback - -## Example - -The example below only showcases purego use for macOS and Linux. The other platforms require special handling which can -be seen in the complete example at [examples/libc](https://github.com/ebitengine/purego/tree/main/examples/libc) which supports Windows and FreeBSD. - -```go -package main - -import ( - "fmt" - "runtime" - - "github.com/ebitengine/purego" -) - -func getSystemLibrary() string { - switch runtime.GOOS { - case "darwin": - return "/usr/lib/libSystem.B.dylib" - case "linux": - return "libc.so.6" - default: - panic(fmt.Errorf("GOOS=%s is not supported", runtime.GOOS)) - } -} - -func main() { - libc, err := purego.Dlopen(getSystemLibrary(), purego.RTLD_NOW|purego.RTLD_GLOBAL) - if err != nil { - panic(err) - } - var puts func(string) - purego.RegisterLibFunc(&puts, libc, "puts") - puts("Calling C from Go without Cgo!") -} -``` - -Then to run: `CGO_ENABLED=0 go run main.go` - -## Questions - -If you have questions about how to incorporate purego in your project or want to discuss -how it works join the [Discord](https://discord.gg/HzGZVD6BkY)! - -### External Code - -Purego uses code that originates from the Go runtime. These files are under the BSD-3 -License that can be found [in the Go Source](https://github.com/golang/go/blob/master/LICENSE). -This is a list of the copied files: - -* `abi_*.h` from package `runtime/cgo` -* `zcallback_darwin_*.s` from package `runtime` -* `internal/fakecgo/abi_*.h` from package `runtime/cgo` -* `internal/fakecgo/asm_GOARCH.s` from package `runtime/cgo` -* `internal/fakecgo/callbacks.go` from package `runtime/cgo` -* `internal/fakecgo/go_GOOS_GOARCH.go` from package `runtime/cgo` -* `internal/fakecgo/iscgo.go` from package `runtime/cgo` -* `internal/fakecgo/setenv.go` from package `runtime/cgo` -* `internal/fakecgo/freebsd.go` from package `runtime/cgo` - -The files `abi_*.h` and `internal/fakecgo/abi_*.h` are the same because Bazel does not support cross-package use of -`#include` so we need each one once per package. (cf. [issue](https://github.com/bazelbuild/rules_go/issues/3636)) diff --git a/vendor/github.com/ebitengine/purego/abi_amd64.h b/vendor/github.com/ebitengine/purego/abi_amd64.h deleted file mode 100644 index 9949435fe9e0a..0000000000000 --- a/vendor/github.com/ebitengine/purego/abi_amd64.h +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright 2021 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Macros for transitioning from the host ABI to Go ABI0. -// -// These save the frame pointer, so in general, functions that use -// these should have zero frame size to suppress the automatic frame -// pointer, though it's harmless to not do this. - -#ifdef GOOS_windows - -// REGS_HOST_TO_ABI0_STACK is the stack bytes used by -// PUSH_REGS_HOST_TO_ABI0. -#define REGS_HOST_TO_ABI0_STACK (28*8 + 8) - -// PUSH_REGS_HOST_TO_ABI0 prepares for transitioning from -// the host ABI to Go ABI0 code. It saves all registers that are -// callee-save in the host ABI and caller-save in Go ABI0 and prepares -// for entry to Go. -// -// Save DI SI BP BX R12 R13 R14 R15 X6-X15 registers and the DF flag. -// Clear the DF flag for the Go ABI. -// MXCSR matches the Go ABI, so we don't have to set that, -// and Go doesn't modify it, so we don't have to save it. -#define PUSH_REGS_HOST_TO_ABI0() \ - PUSHFQ \ - CLD \ - ADJSP $(REGS_HOST_TO_ABI0_STACK - 8) \ - MOVQ DI, (0*0)(SP) \ - MOVQ SI, (1*8)(SP) \ - MOVQ BP, (2*8)(SP) \ - MOVQ BX, (3*8)(SP) \ - MOVQ R12, (4*8)(SP) \ - MOVQ R13, (5*8)(SP) \ - MOVQ R14, (6*8)(SP) \ - MOVQ R15, (7*8)(SP) \ - MOVUPS X6, (8*8)(SP) \ - MOVUPS X7, (10*8)(SP) \ - MOVUPS X8, (12*8)(SP) \ - MOVUPS X9, (14*8)(SP) \ - MOVUPS X10, (16*8)(SP) \ - MOVUPS X11, (18*8)(SP) \ - MOVUPS X12, (20*8)(SP) \ - MOVUPS X13, (22*8)(SP) \ - MOVUPS X14, (24*8)(SP) \ - MOVUPS X15, (26*8)(SP) - -#define POP_REGS_HOST_TO_ABI0() \ - MOVQ (0*0)(SP), DI \ - MOVQ (1*8)(SP), SI \ - MOVQ (2*8)(SP), BP \ - MOVQ (3*8)(SP), BX \ - MOVQ (4*8)(SP), R12 \ - MOVQ (5*8)(SP), R13 \ - MOVQ (6*8)(SP), R14 \ - MOVQ (7*8)(SP), R15 \ - MOVUPS (8*8)(SP), X6 \ - MOVUPS (10*8)(SP), X7 \ - MOVUPS (12*8)(SP), X8 \ - MOVUPS (14*8)(SP), X9 \ - MOVUPS (16*8)(SP), X10 \ - MOVUPS (18*8)(SP), X11 \ - MOVUPS (20*8)(SP), X12 \ - MOVUPS (22*8)(SP), X13 \ - MOVUPS (24*8)(SP), X14 \ - MOVUPS (26*8)(SP), X15 \ - ADJSP $-(REGS_HOST_TO_ABI0_STACK - 8) \ - POPFQ - -#else -// SysV ABI - -#define REGS_HOST_TO_ABI0_STACK (6*8) - -// SysV MXCSR matches the Go ABI, so we don't have to set that, -// and Go doesn't modify it, so we don't have to save it. -// Both SysV and Go require DF to be cleared, so that's already clear. -// The SysV and Go frame pointer conventions are compatible. -#define PUSH_REGS_HOST_TO_ABI0() \ - ADJSP $(REGS_HOST_TO_ABI0_STACK) \ - MOVQ BP, (5*8)(SP) \ - LEAQ (5*8)(SP), BP \ - MOVQ BX, (0*8)(SP) \ - MOVQ R12, (1*8)(SP) \ - MOVQ R13, (2*8)(SP) \ - MOVQ R14, (3*8)(SP) \ - MOVQ R15, (4*8)(SP) - -#define POP_REGS_HOST_TO_ABI0() \ - MOVQ (0*8)(SP), BX \ - MOVQ (1*8)(SP), R12 \ - MOVQ (2*8)(SP), R13 \ - MOVQ (3*8)(SP), R14 \ - MOVQ (4*8)(SP), R15 \ - MOVQ (5*8)(SP), BP \ - ADJSP $-(REGS_HOST_TO_ABI0_STACK) - -#endif diff --git a/vendor/github.com/ebitengine/purego/abi_arm64.h b/vendor/github.com/ebitengine/purego/abi_arm64.h deleted file mode 100644 index 5d5061ec1dbf8..0000000000000 --- a/vendor/github.com/ebitengine/purego/abi_arm64.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2021 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Macros for transitioning from the host ABI to Go ABI0. -// -// These macros save and restore the callee-saved registers -// from the stack, but they don't adjust stack pointer, so -// the user should prepare stack space in advance. -// SAVE_R19_TO_R28(offset) saves R19 ~ R28 to the stack space -// of ((offset)+0*8)(RSP) ~ ((offset)+9*8)(RSP). -// -// SAVE_F8_TO_F15(offset) saves F8 ~ F15 to the stack space -// of ((offset)+0*8)(RSP) ~ ((offset)+7*8)(RSP). -// -// R29 is not saved because Go will save and restore it. - -#define SAVE_R19_TO_R28(offset) \ - STP (R19, R20), ((offset)+0*8)(RSP) \ - STP (R21, R22), ((offset)+2*8)(RSP) \ - STP (R23, R24), ((offset)+4*8)(RSP) \ - STP (R25, R26), ((offset)+6*8)(RSP) \ - STP (R27, g), ((offset)+8*8)(RSP) -#define RESTORE_R19_TO_R28(offset) \ - LDP ((offset)+0*8)(RSP), (R19, R20) \ - LDP ((offset)+2*8)(RSP), (R21, R22) \ - LDP ((offset)+4*8)(RSP), (R23, R24) \ - LDP ((offset)+6*8)(RSP), (R25, R26) \ - LDP ((offset)+8*8)(RSP), (R27, g) /* R28 */ -#define SAVE_F8_TO_F15(offset) \ - FSTPD (F8, F9), ((offset)+0*8)(RSP) \ - FSTPD (F10, F11), ((offset)+2*8)(RSP) \ - FSTPD (F12, F13), ((offset)+4*8)(RSP) \ - FSTPD (F14, F15), ((offset)+6*8)(RSP) -#define RESTORE_F8_TO_F15(offset) \ - FLDPD ((offset)+0*8)(RSP), (F8, F9) \ - FLDPD ((offset)+2*8)(RSP), (F10, F11) \ - FLDPD ((offset)+4*8)(RSP), (F12, F13) \ - FLDPD ((offset)+6*8)(RSP), (F14, F15) diff --git a/vendor/github.com/ebitengine/purego/cgo.go b/vendor/github.com/ebitengine/purego/cgo.go deleted file mode 100644 index 7d5abef349983..0000000000000 --- a/vendor/github.com/ebitengine/purego/cgo.go +++ /dev/null @@ -1,19 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2022 The Ebitengine Authors - -//go:build cgo && (darwin || freebsd || linux) - -package purego - -// if CGO_ENABLED=1 import the Cgo runtime to ensure that it is set up properly. -// This is required since some frameworks need TLS setup the C way which Go doesn't do. -// We currently don't support ios in fakecgo mode so force Cgo or fail -// Even if CGO_ENABLED=1 the Cgo runtime is not imported unless `import "C"` is used. -// which will import this package automatically. Normally this isn't an issue since it -// usually isn't possible to call into C without using that import. However, with purego -// it is since we don't use `import "C"`! -import ( - _ "runtime/cgo" - - _ "github.com/ebitengine/purego/internal/cgo" -) diff --git a/vendor/github.com/ebitengine/purego/dlerror.go b/vendor/github.com/ebitengine/purego/dlerror.go deleted file mode 100644 index 95cdfe16f2488..0000000000000 --- a/vendor/github.com/ebitengine/purego/dlerror.go +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2023 The Ebitengine Authors - -//go:build darwin || freebsd || linux - -package purego - -// Dlerror represents an error value returned from Dlopen, Dlsym, or Dlclose. -// -// This type is not available on Windows as there is no counterpart to it on Windows. -type Dlerror struct { - s string -} - -func (e Dlerror) Error() string { - return e.s -} diff --git a/vendor/github.com/ebitengine/purego/dlfcn.go b/vendor/github.com/ebitengine/purego/dlfcn.go deleted file mode 100644 index f70a24584d659..0000000000000 --- a/vendor/github.com/ebitengine/purego/dlfcn.go +++ /dev/null @@ -1,99 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2022 The Ebitengine Authors - -//go:build (darwin || freebsd || linux) && !android && !faketime - -package purego - -import ( - "unsafe" -) - -// Unix Specification for dlfcn.h: https://pubs.opengroup.org/onlinepubs/7908799/xsh/dlfcn.h.html - -var ( - fnDlopen func(path string, mode int) uintptr - fnDlsym func(handle uintptr, name string) uintptr - fnDlerror func() string - fnDlclose func(handle uintptr) bool -) - -func init() { - RegisterFunc(&fnDlopen, dlopenABI0) - RegisterFunc(&fnDlsym, dlsymABI0) - RegisterFunc(&fnDlerror, dlerrorABI0) - RegisterFunc(&fnDlclose, dlcloseABI0) -} - -// Dlopen examines the dynamic library or bundle file specified by path. If the file is compatible -// with the current process and has not already been loaded into the -// current process, it is loaded and linked. After being linked, if it contains -// any initializer functions, they are called, before Dlopen -// returns. It returns a handle that can be used with Dlsym and Dlclose. -// A second call to Dlopen with the same path will return the same handle, but the internal -// reference count for the handle will be incremented. Therefore, all -// Dlopen calls should be balanced with a Dlclose call. -// -// This function is not available on Windows. -// Use [golang.org/x/sys/windows.LoadLibrary], [golang.org/x/sys/windows.LoadLibraryEx], -// [golang.org/x/sys/windows.NewLazyDLL], or [golang.org/x/sys/windows.NewLazySystemDLL] for Windows instead. -func Dlopen(path string, mode int) (uintptr, error) { - u := fnDlopen(path, mode) - if u == 0 { - return 0, Dlerror{fnDlerror()} - } - return u, nil -} - -// Dlsym takes a "handle" of a dynamic library returned by Dlopen and the symbol name. -// It returns the address where that symbol is loaded into memory. If the symbol is not found, -// in the specified library or any of the libraries that were automatically loaded by Dlopen -// when that library was loaded, Dlsym returns zero. -// -// This function is not available on Windows. -// Use [golang.org/x/sys/windows.GetProcAddress] for Windows instead. -func Dlsym(handle uintptr, name string) (uintptr, error) { - u := fnDlsym(handle, name) - if u == 0 { - return 0, Dlerror{fnDlerror()} - } - return u, nil -} - -// Dlclose decrements the reference count on the dynamic library handle. -// If the reference count drops to zero and no other loaded libraries -// use symbols in it, then the dynamic library is unloaded. -// -// This function is not available on Windows. -// Use [golang.org/x/sys/windows.FreeLibrary] for Windows instead. -func Dlclose(handle uintptr) error { - if fnDlclose(handle) { - return Dlerror{fnDlerror()} - } - return nil -} - -func loadSymbol(handle uintptr, name string) (uintptr, error) { - return Dlsym(handle, name) -} - -// these functions exist in dlfcn_stubs.s and are calling C functions linked to in dlfcn_GOOS.go -// the indirection is necessary because a function is actually a pointer to the pointer to the code. -// sadly, I do not know of anyway to remove the assembly stubs entirely because //go:linkname doesn't -// appear to work if you link directly to the C function on darwin arm64. - -//go:linkname dlopen dlopen -var dlopen uintptr -var dlopenABI0 = uintptr(unsafe.Pointer(&dlopen)) - -//go:linkname dlsym dlsym -var dlsym uintptr -var dlsymABI0 = uintptr(unsafe.Pointer(&dlsym)) - -//go:linkname dlclose dlclose -var dlclose uintptr -var dlcloseABI0 = uintptr(unsafe.Pointer(&dlclose)) - -//go:linkname dlerror dlerror -var dlerror uintptr -var dlerrorABI0 = uintptr(unsafe.Pointer(&dlerror)) diff --git a/vendor/github.com/ebitengine/purego/dlfcn_android.go b/vendor/github.com/ebitengine/purego/dlfcn_android.go deleted file mode 100644 index 0d5341764edef..0000000000000 --- a/vendor/github.com/ebitengine/purego/dlfcn_android.go +++ /dev/null @@ -1,34 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2024 The Ebitengine Authors - -package purego - -import "github.com/ebitengine/purego/internal/cgo" - -// Source for constants: https://android.googlesource.com/platform/bionic/+/refs/heads/main/libc/include/dlfcn.h - -const ( - is64bit = 1 << (^uintptr(0) >> 63) / 2 - is32bit = 1 - is64bit - RTLD_DEFAULT = is32bit * 0xffffffff - RTLD_LAZY = 0x00000001 - RTLD_NOW = is64bit * 0x00000002 - RTLD_LOCAL = 0x00000000 - RTLD_GLOBAL = is64bit*0x00100 | is32bit*0x00000002 -) - -func Dlopen(path string, mode int) (uintptr, error) { - return cgo.Dlopen(path, mode) -} - -func Dlsym(handle uintptr, name string) (uintptr, error) { - return cgo.Dlsym(handle, name) -} - -func Dlclose(handle uintptr) error { - return cgo.Dlclose(handle) -} - -func loadSymbol(handle uintptr, name string) (uintptr, error) { - return Dlsym(handle, name) -} diff --git a/vendor/github.com/ebitengine/purego/dlfcn_darwin.go b/vendor/github.com/ebitengine/purego/dlfcn_darwin.go deleted file mode 100644 index 5f876278a3e66..0000000000000 --- a/vendor/github.com/ebitengine/purego/dlfcn_darwin.go +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2022 The Ebitengine Authors - -package purego - -// Source for constants: https://opensource.apple.com/source/dyld/dyld-360.14/include/dlfcn.h.auto.html - -const ( - RTLD_DEFAULT = 1<<64 - 2 // Pseudo-handle for dlsym so search for any loaded symbol - RTLD_LAZY = 0x1 // Relocations are performed at an implementation-dependent time. - RTLD_NOW = 0x2 // Relocations are performed when the object is loaded. - RTLD_LOCAL = 0x4 // All symbols are not made available for relocation processing by other modules. - RTLD_GLOBAL = 0x8 // All symbols are available for relocation processing of other modules. -) - -//go:cgo_import_dynamic purego_dlopen dlopen "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_dlsym dlsym "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_dlerror dlerror "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_dlclose dlclose "/usr/lib/libSystem.B.dylib" - -//go:cgo_import_dynamic purego_dlopen dlopen "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_dlsym dlsym "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_dlerror dlerror "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_dlclose dlclose "/usr/lib/libSystem.B.dylib" diff --git a/vendor/github.com/ebitengine/purego/dlfcn_freebsd.go b/vendor/github.com/ebitengine/purego/dlfcn_freebsd.go deleted file mode 100644 index 6b371620d969d..0000000000000 --- a/vendor/github.com/ebitengine/purego/dlfcn_freebsd.go +++ /dev/null @@ -1,14 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2022 The Ebitengine Authors - -package purego - -// Constants as defined in https://github.com/freebsd/freebsd-src/blob/main/include/dlfcn.h -const ( - intSize = 32 << (^uint(0) >> 63) // 32 or 64 - RTLD_DEFAULT = 1< C) -// -// string <=> char* -// bool <=> _Bool -// uintptr <=> uintptr_t -// uint <=> uint32_t or uint64_t -// uint8 <=> uint8_t -// uint16 <=> uint16_t -// uint32 <=> uint32_t -// uint64 <=> uint64_t -// int <=> int32_t or int64_t -// int8 <=> int8_t -// int16 <=> int16_t -// int32 <=> int32_t -// int64 <=> int64_t -// float32 <=> float -// float64 <=> double -// struct <=> struct (WIP - darwin only) -// func <=> C function -// unsafe.Pointer, *T <=> void* -// []T => void* -// -// There is a special case when the last argument of fptr is a variadic interface (or []interface} -// it will be expanded into a call to the C function as if it had the arguments in that slice. -// This means that using arg ...interface{} is like a cast to the function with the arguments inside arg. -// This is not the same as C variadic. -// -// # Memory -// -// In general it is not possible for purego to guarantee the lifetimes of objects returned or received from -// calling functions using RegisterFunc. For arguments to a C function it is important that the C function doesn't -// hold onto a reference to Go memory. This is the same as the [Cgo rules]. -// -// However, there are some special cases. When passing a string as an argument if the string does not end in a null -// terminated byte (\x00) then the string will be copied into memory maintained by purego. The memory is only valid for -// that specific call. Therefore, if the C code keeps a reference to that string it may become invalid at some -// undefined time. However, if the string does already contain a null-terminated byte then no copy is done. -// It is then the responsibility of the caller to ensure the string stays alive as long as it's needed in C memory. -// This can be done using runtime.KeepAlive or allocating the string in C memory using malloc. When a C function -// returns a null-terminated pointer to char a Go string can be used. Purego will allocate a new string in Go memory -// and copy the data over. This string will be garbage collected whenever Go decides it's no longer referenced. -// This C created string will not be freed by purego. If the pointer to char is not null-terminated or must continue -// to point to C memory (because it's a buffer for example) then use a pointer to byte and then convert that to a slice -// using unsafe.Slice. Doing this means that it becomes the responsibility of the caller to care about the lifetime -// of the pointer -// -// # Structs -// -// Purego can handle the most common structs that have fields of builtin types like int8, uint16, float32, etc. However, -// it does not support aligning fields properly. It is therefore the responsibility of the caller to ensure -// that all padding is added to the Go struct to match the C one. See `BoolStructFn` in struct_test.go for an example. -// -// # Example -// -// All functions below call this C function: -// -// char *foo(char *str); -// -// // Let purego convert types -// var foo func(s string) string -// goString := foo("copied") -// // Go will garbage collect this string -// -// // Manually, handle allocations -// var foo2 func(b string) *byte -// mustFree := foo2("not copied\x00") -// defer free(mustFree) -// -// [Cgo rules]: https://pkg.go.dev/cmd/cgo#hdr-Go_references_to_C -func RegisterFunc(fptr interface{}, cfn uintptr) { - fn := reflect.ValueOf(fptr).Elem() - ty := fn.Type() - if ty.Kind() != reflect.Func { - panic("purego: fptr must be a function pointer") - } - if ty.NumOut() > 1 { - panic("purego: function can only return zero or one values") - } - if cfn == 0 { - panic("purego: cfn is nil") - } - if ty.NumOut() == 1 && (ty.Out(0).Kind() == reflect.Float32 || ty.Out(0).Kind() == reflect.Float64) && - runtime.GOARCH != "arm64" && runtime.GOARCH != "amd64" { - panic("purego: float returns are not supported") - } - { - // this code checks how many registers and stack this function will use - // to avoid crashing with too many arguments - var ints int - var floats int - var stack int - for i := 0; i < ty.NumIn(); i++ { - arg := ty.In(i) - switch arg.Kind() { - case reflect.Func: - // This only does preliminary testing to ensure the CDecl argument - // is the first argument. Full testing is done when the callback is actually - // created in NewCallback. - for j := 0; j < arg.NumIn(); j++ { - in := arg.In(j) - if !in.AssignableTo(reflect.TypeOf(CDecl{})) { - continue - } - if j != 0 { - panic("purego: CDecl must be the first argument") - } - } - case reflect.String, reflect.Uintptr, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, - reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Ptr, reflect.UnsafePointer, - reflect.Slice, reflect.Bool: - if ints < numOfIntegerRegisters() { - ints++ - } else { - stack++ - } - case reflect.Float32, reflect.Float64: - const is32bit = unsafe.Sizeof(uintptr(0)) == 4 - if is32bit { - panic("purego: floats only supported on 64bit platforms") - } - if floats < numOfFloats { - floats++ - } else { - stack++ - } - case reflect.Struct: - if runtime.GOOS != "darwin" || (runtime.GOARCH != "amd64" && runtime.GOARCH != "arm64") { - panic("purego: struct arguments are only supported on darwin amd64 & arm64") - } - if arg.Size() == 0 { - continue - } - addInt := func(u uintptr) { - ints++ - } - addFloat := func(u uintptr) { - floats++ - } - addStack := func(u uintptr) { - stack++ - } - _ = addStruct(reflect.New(arg).Elem(), &ints, &floats, &stack, addInt, addFloat, addStack, nil) - default: - panic("purego: unsupported kind " + arg.Kind().String()) - } - } - if ty.NumOut() == 1 && ty.Out(0).Kind() == reflect.Struct { - if runtime.GOOS != "darwin" { - panic("purego: struct return values only supported on darwin arm64 & amd64") - } - outType := ty.Out(0) - checkStructFieldsSupported(outType) - if runtime.GOARCH == "amd64" && outType.Size() > maxRegAllocStructSize { - // on amd64 if struct is bigger than 16 bytes allocate the return struct - // and pass it in as a hidden first argument. - ints++ - } - } - sizeOfStack := maxArgs - numOfIntegerRegisters() - if stack > sizeOfStack { - panic("purego: too many arguments") - } - } - v := reflect.MakeFunc(ty, func(args []reflect.Value) (results []reflect.Value) { - if len(args) > 0 { - if variadic, ok := args[len(args)-1].Interface().([]interface{}); ok { - // subtract one from args bc the last argument in args is []interface{} - // which we are currently expanding - tmp := make([]reflect.Value, len(args)-1+len(variadic)) - n := copy(tmp, args[:len(args)-1]) - for i, v := range variadic { - tmp[n+i] = reflect.ValueOf(v) - } - args = tmp - } - } - var sysargs [maxArgs]uintptr - stack := sysargs[numOfIntegerRegisters():] - var floats [numOfFloats]uintptr - var numInts int - var numFloats int - var numStack int - var addStack, addInt, addFloat func(x uintptr) - if runtime.GOARCH == "arm64" || runtime.GOOS != "windows" { - // Windows arm64 uses the same calling convention as macOS and Linux - addStack = func(x uintptr) { - stack[numStack] = x - numStack++ - } - addInt = func(x uintptr) { - if numInts >= numOfIntegerRegisters() { - addStack(x) - } else { - sysargs[numInts] = x - numInts++ - } - } - addFloat = func(x uintptr) { - if numFloats < len(floats) { - floats[numFloats] = x - numFloats++ - } else { - addStack(x) - } - } - } else { - // On Windows amd64 the arguments are passed in the numbered registered. - // So the first int is in the first integer register and the first float - // is in the second floating register if there is already a first int. - // This is in contrast to how macOS and Linux pass arguments which - // tries to use as many registers as possible in the calling convention. - addStack = func(x uintptr) { - sysargs[numStack] = x - numStack++ - } - addInt = addStack - addFloat = addStack - } - - var keepAlive []interface{} - defer func() { - runtime.KeepAlive(keepAlive) - runtime.KeepAlive(args) - }() - var syscall syscall15Args - if ty.NumOut() == 1 && ty.Out(0).Kind() == reflect.Struct { - outType := ty.Out(0) - if runtime.GOARCH == "amd64" && outType.Size() > maxRegAllocStructSize { - val := reflect.New(outType) - keepAlive = append(keepAlive, val) - addInt(val.Pointer()) - } else if runtime.GOARCH == "arm64" && outType.Size() > maxRegAllocStructSize { - isAllFloats, numFields := isAllSameFloat(outType) - if !isAllFloats || numFields > 4 { - val := reflect.New(outType) - keepAlive = append(keepAlive, val) - syscall.arm64_r8 = val.Pointer() - } - } - } - for _, v := range args { - switch v.Kind() { - case reflect.String: - ptr := strings.CString(v.String()) - keepAlive = append(keepAlive, ptr) - addInt(uintptr(unsafe.Pointer(ptr))) - case reflect.Uintptr, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - addInt(uintptr(v.Uint())) - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - addInt(uintptr(v.Int())) - case reflect.Ptr, reflect.UnsafePointer, reflect.Slice: - // There is no need to keepAlive this pointer separately because it is kept alive in the args variable - addInt(v.Pointer()) - case reflect.Func: - addInt(NewCallback(v.Interface())) - case reflect.Bool: - if v.Bool() { - addInt(1) - } else { - addInt(0) - } - case reflect.Float32: - addFloat(uintptr(math.Float32bits(float32(v.Float())))) - case reflect.Float64: - addFloat(uintptr(math.Float64bits(v.Float()))) - case reflect.Struct: - keepAlive = addStruct(v, &numInts, &numFloats, &numStack, addInt, addFloat, addStack, keepAlive) - default: - panic("purego: unsupported kind: " + v.Kind().String()) - } - } - if runtime.GOARCH == "arm64" || runtime.GOOS != "windows" { - // Use the normal arm64 calling convention even on Windows - syscall = syscall15Args{ - cfn, - sysargs[0], sysargs[1], sysargs[2], sysargs[3], sysargs[4], sysargs[5], - sysargs[6], sysargs[7], sysargs[8], sysargs[9], sysargs[10], sysargs[11], - sysargs[12], sysargs[13], sysargs[14], - floats[0], floats[1], floats[2], floats[3], floats[4], floats[5], floats[6], floats[7], - syscall.arm64_r8, - } - runtime_cgocall(syscall15XABI0, unsafe.Pointer(&syscall)) - } else { - // This is a fallback for Windows amd64, 386, and arm. Note this may not support floats - syscall.a1, syscall.a2, _ = syscall_syscall15X(cfn, sysargs[0], sysargs[1], sysargs[2], sysargs[3], sysargs[4], - sysargs[5], sysargs[6], sysargs[7], sysargs[8], sysargs[9], sysargs[10], sysargs[11], - sysargs[12], sysargs[13], sysargs[14]) - syscall.f1 = syscall.a2 // on amd64 a2 stores the float return. On 32bit platforms floats aren't support - } - if ty.NumOut() == 0 { - return nil - } - outType := ty.Out(0) - v := reflect.New(outType).Elem() - switch outType.Kind() { - case reflect.Uintptr, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - v.SetUint(uint64(syscall.a1)) - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - v.SetInt(int64(syscall.a1)) - case reflect.Bool: - v.SetBool(byte(syscall.a1) != 0) - case reflect.UnsafePointer: - // We take the address and then dereference it to trick go vet from creating a possible miss-use of unsafe.Pointer - v.SetPointer(*(*unsafe.Pointer)(unsafe.Pointer(&syscall.a1))) - case reflect.Ptr: - v = reflect.NewAt(outType, unsafe.Pointer(&syscall.a1)).Elem() - case reflect.Func: - // wrap this C function in a nicely typed Go function - v = reflect.New(outType) - RegisterFunc(v.Interface(), syscall.a1) - case reflect.String: - v.SetString(strings.GoString(syscall.a1)) - case reflect.Float32: - // NOTE: syscall.r2 is only the floating return value on 64bit platforms. - // On 32bit platforms syscall.r2 is the upper part of a 64bit return. - v.SetFloat(float64(math.Float32frombits(uint32(syscall.f1)))) - case reflect.Float64: - // NOTE: syscall.r2 is only the floating return value on 64bit platforms. - // On 32bit platforms syscall.r2 is the upper part of a 64bit return. - v.SetFloat(math.Float64frombits(uint64(syscall.f1))) - case reflect.Struct: - v = getStruct(outType, syscall) - default: - panic("purego: unsupported return kind: " + outType.Kind().String()) - } - return []reflect.Value{v} - }) - fn.Set(v) -} - -// maxRegAllocStructSize is the biggest a struct can be while still fitting in registers. -// if it is bigger than this than enough space must be allocated on the heap and then passed into -// the function as the first parameter on amd64 or in R8 on arm64. -// -// If you change this make sure to update it in objc_runtime_darwin.go -const maxRegAllocStructSize = 16 - -func isAllSameFloat(ty reflect.Type) (allFloats bool, numFields int) { - allFloats = true - root := ty.Field(0).Type - for root.Kind() == reflect.Struct { - root = root.Field(0).Type - } - first := root.Kind() - if first != reflect.Float32 && first != reflect.Float64 { - allFloats = false - } - for i := 0; i < ty.NumField(); i++ { - f := ty.Field(i).Type - if f.Kind() == reflect.Struct { - var structNumFields int - allFloats, structNumFields = isAllSameFloat(f) - numFields += structNumFields - continue - } - numFields++ - if f.Kind() != first { - allFloats = false - } - } - return allFloats, numFields -} - -func checkStructFieldsSupported(ty reflect.Type) { - for i := 0; i < ty.NumField(); i++ { - f := ty.Field(i).Type - if f.Kind() == reflect.Array { - f = f.Elem() - } else if f.Kind() == reflect.Struct { - checkStructFieldsSupported(f) - continue - } - switch f.Kind() { - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, - reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, - reflect.Uintptr, reflect.Ptr, reflect.UnsafePointer, reflect.Float64, reflect.Float32: - default: - panic(fmt.Sprintf("purego: struct field type %s is not supported", f)) - } - } -} - -func roundUpTo8(val uintptr) uintptr { - return (val + 7) &^ 7 -} - -func numOfIntegerRegisters() int { - switch runtime.GOARCH { - case "arm64": - return 8 - case "amd64": - return 6 - default: - // since this platform isn't supported and can therefore only access - // integer registers it is fine to return the maxArgs - return maxArgs - } -} diff --git a/vendor/github.com/ebitengine/purego/go_runtime.go b/vendor/github.com/ebitengine/purego/go_runtime.go deleted file mode 100644 index 13671ff23f270..0000000000000 --- a/vendor/github.com/ebitengine/purego/go_runtime.go +++ /dev/null @@ -1,13 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2022 The Ebitengine Authors - -//go:build darwin || freebsd || linux || windows - -package purego - -import ( - "unsafe" -) - -//go:linkname runtime_cgocall runtime.cgocall -func runtime_cgocall(fn uintptr, arg unsafe.Pointer) int32 // from runtime/sys_libc.go diff --git a/vendor/github.com/ebitengine/purego/internal/cgo/dlfcn_cgo_unix.go b/vendor/github.com/ebitengine/purego/internal/cgo/dlfcn_cgo_unix.go deleted file mode 100644 index b09ecac1cfebb..0000000000000 --- a/vendor/github.com/ebitengine/purego/internal/cgo/dlfcn_cgo_unix.go +++ /dev/null @@ -1,56 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2024 The Ebitengine Authors - -//go:build freebsd || linux - -package cgo - -/* - #cgo LDFLAGS: -ldl - -#include -#include -*/ -import "C" - -import ( - "errors" - "unsafe" -) - -func Dlopen(filename string, flag int) (uintptr, error) { - cfilename := C.CString(filename) - defer C.free(unsafe.Pointer(cfilename)) - handle := C.dlopen(cfilename, C.int(flag)) - if handle == nil { - return 0, errors.New(C.GoString(C.dlerror())) - } - return uintptr(handle), nil -} - -func Dlsym(handle uintptr, symbol string) (uintptr, error) { - csymbol := C.CString(symbol) - defer C.free(unsafe.Pointer(csymbol)) - symbolAddr := C.dlsym(*(*unsafe.Pointer)(unsafe.Pointer(&handle)), csymbol) - if symbolAddr == nil { - return 0, errors.New(C.GoString(C.dlerror())) - } - return uintptr(symbolAddr), nil -} - -func Dlclose(handle uintptr) error { - result := C.dlclose(*(*unsafe.Pointer)(unsafe.Pointer(&handle))) - if result != 0 { - return errors.New(C.GoString(C.dlerror())) - } - return nil -} - -// all that is needed is to assign each dl function because then its -// symbol will then be made available to the linker and linked to inside dlfcn.go -var ( - _ = C.dlopen - _ = C.dlsym - _ = C.dlerror - _ = C.dlclose -) diff --git a/vendor/github.com/ebitengine/purego/internal/cgo/empty.go b/vendor/github.com/ebitengine/purego/internal/cgo/empty.go deleted file mode 100644 index 1d7cffe2a7e5f..0000000000000 --- a/vendor/github.com/ebitengine/purego/internal/cgo/empty.go +++ /dev/null @@ -1,6 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2024 The Ebitengine Authors - -package cgo - -// Empty so that importing this package doesn't cause issue for certain platforms. diff --git a/vendor/github.com/ebitengine/purego/internal/cgo/syscall_cgo_unix.go b/vendor/github.com/ebitengine/purego/internal/cgo/syscall_cgo_unix.go deleted file mode 100644 index 37ff24d5c1de7..0000000000000 --- a/vendor/github.com/ebitengine/purego/internal/cgo/syscall_cgo_unix.go +++ /dev/null @@ -1,55 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2022 The Ebitengine Authors - -//go:build freebsd || (linux && !(arm64 || amd64)) - -package cgo - -// this file is placed inside internal/cgo and not package purego -// because Cgo and assembly files can't be in the same package. - -/* - #cgo LDFLAGS: -ldl - -#include -#include -#include -#include - -typedef struct syscall15Args { - uintptr_t fn; - uintptr_t a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15; - uintptr_t f1, f2, f3, f4, f5, f6, f7, f8; - uintptr_t err; -} syscall15Args; - -void syscall15(struct syscall15Args *args) { - assert((args->f1|args->f2|args->f3|args->f4|args->f5|args->f6|args->f7|args->f8) == 0); - uintptr_t (*func_name)(uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, - uintptr_t a7, uintptr_t a8, uintptr_t a9, uintptr_t a10, uintptr_t a11, uintptr_t a12, - uintptr_t a13, uintptr_t a14, uintptr_t a15); - *(void**)(&func_name) = (void*)(args->fn); - uintptr_t r1 = func_name(args->a1,args->a2,args->a3,args->a4,args->a5,args->a6,args->a7,args->a8,args->a9, - args->a10,args->a11,args->a12,args->a13,args->a14,args->a15); - args->a1 = r1; - args->err = errno; -} - -*/ -import "C" -import "unsafe" - -// assign purego.syscall15XABI0 to the C version of this function. -var Syscall15XABI0 = unsafe.Pointer(C.syscall15) - -//go:nosplit -func Syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15 uintptr) (r1, r2, err uintptr) { - args := C.syscall15Args{ - C.uintptr_t(fn), C.uintptr_t(a1), C.uintptr_t(a2), C.uintptr_t(a3), - C.uintptr_t(a4), C.uintptr_t(a5), C.uintptr_t(a6), - C.uintptr_t(a7), C.uintptr_t(a8), C.uintptr_t(a9), C.uintptr_t(a10), C.uintptr_t(a11), C.uintptr_t(a12), - C.uintptr_t(a13), C.uintptr_t(a14), C.uintptr_t(a15), 0, 0, 0, 0, 0, 0, 0, 0, 0, - } - C.syscall15(&args) - return uintptr(args.a1), 0, uintptr(args.err) -} diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/abi_amd64.h b/vendor/github.com/ebitengine/purego/internal/fakecgo/abi_amd64.h deleted file mode 100644 index 9949435fe9e0a..0000000000000 --- a/vendor/github.com/ebitengine/purego/internal/fakecgo/abi_amd64.h +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright 2021 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Macros for transitioning from the host ABI to Go ABI0. -// -// These save the frame pointer, so in general, functions that use -// these should have zero frame size to suppress the automatic frame -// pointer, though it's harmless to not do this. - -#ifdef GOOS_windows - -// REGS_HOST_TO_ABI0_STACK is the stack bytes used by -// PUSH_REGS_HOST_TO_ABI0. -#define REGS_HOST_TO_ABI0_STACK (28*8 + 8) - -// PUSH_REGS_HOST_TO_ABI0 prepares for transitioning from -// the host ABI to Go ABI0 code. It saves all registers that are -// callee-save in the host ABI and caller-save in Go ABI0 and prepares -// for entry to Go. -// -// Save DI SI BP BX R12 R13 R14 R15 X6-X15 registers and the DF flag. -// Clear the DF flag for the Go ABI. -// MXCSR matches the Go ABI, so we don't have to set that, -// and Go doesn't modify it, so we don't have to save it. -#define PUSH_REGS_HOST_TO_ABI0() \ - PUSHFQ \ - CLD \ - ADJSP $(REGS_HOST_TO_ABI0_STACK - 8) \ - MOVQ DI, (0*0)(SP) \ - MOVQ SI, (1*8)(SP) \ - MOVQ BP, (2*8)(SP) \ - MOVQ BX, (3*8)(SP) \ - MOVQ R12, (4*8)(SP) \ - MOVQ R13, (5*8)(SP) \ - MOVQ R14, (6*8)(SP) \ - MOVQ R15, (7*8)(SP) \ - MOVUPS X6, (8*8)(SP) \ - MOVUPS X7, (10*8)(SP) \ - MOVUPS X8, (12*8)(SP) \ - MOVUPS X9, (14*8)(SP) \ - MOVUPS X10, (16*8)(SP) \ - MOVUPS X11, (18*8)(SP) \ - MOVUPS X12, (20*8)(SP) \ - MOVUPS X13, (22*8)(SP) \ - MOVUPS X14, (24*8)(SP) \ - MOVUPS X15, (26*8)(SP) - -#define POP_REGS_HOST_TO_ABI0() \ - MOVQ (0*0)(SP), DI \ - MOVQ (1*8)(SP), SI \ - MOVQ (2*8)(SP), BP \ - MOVQ (3*8)(SP), BX \ - MOVQ (4*8)(SP), R12 \ - MOVQ (5*8)(SP), R13 \ - MOVQ (6*8)(SP), R14 \ - MOVQ (7*8)(SP), R15 \ - MOVUPS (8*8)(SP), X6 \ - MOVUPS (10*8)(SP), X7 \ - MOVUPS (12*8)(SP), X8 \ - MOVUPS (14*8)(SP), X9 \ - MOVUPS (16*8)(SP), X10 \ - MOVUPS (18*8)(SP), X11 \ - MOVUPS (20*8)(SP), X12 \ - MOVUPS (22*8)(SP), X13 \ - MOVUPS (24*8)(SP), X14 \ - MOVUPS (26*8)(SP), X15 \ - ADJSP $-(REGS_HOST_TO_ABI0_STACK - 8) \ - POPFQ - -#else -// SysV ABI - -#define REGS_HOST_TO_ABI0_STACK (6*8) - -// SysV MXCSR matches the Go ABI, so we don't have to set that, -// and Go doesn't modify it, so we don't have to save it. -// Both SysV and Go require DF to be cleared, so that's already clear. -// The SysV and Go frame pointer conventions are compatible. -#define PUSH_REGS_HOST_TO_ABI0() \ - ADJSP $(REGS_HOST_TO_ABI0_STACK) \ - MOVQ BP, (5*8)(SP) \ - LEAQ (5*8)(SP), BP \ - MOVQ BX, (0*8)(SP) \ - MOVQ R12, (1*8)(SP) \ - MOVQ R13, (2*8)(SP) \ - MOVQ R14, (3*8)(SP) \ - MOVQ R15, (4*8)(SP) - -#define POP_REGS_HOST_TO_ABI0() \ - MOVQ (0*8)(SP), BX \ - MOVQ (1*8)(SP), R12 \ - MOVQ (2*8)(SP), R13 \ - MOVQ (3*8)(SP), R14 \ - MOVQ (4*8)(SP), R15 \ - MOVQ (5*8)(SP), BP \ - ADJSP $-(REGS_HOST_TO_ABI0_STACK) - -#endif diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/abi_arm64.h b/vendor/github.com/ebitengine/purego/internal/fakecgo/abi_arm64.h deleted file mode 100644 index 5d5061ec1dbf8..0000000000000 --- a/vendor/github.com/ebitengine/purego/internal/fakecgo/abi_arm64.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2021 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Macros for transitioning from the host ABI to Go ABI0. -// -// These macros save and restore the callee-saved registers -// from the stack, but they don't adjust stack pointer, so -// the user should prepare stack space in advance. -// SAVE_R19_TO_R28(offset) saves R19 ~ R28 to the stack space -// of ((offset)+0*8)(RSP) ~ ((offset)+9*8)(RSP). -// -// SAVE_F8_TO_F15(offset) saves F8 ~ F15 to the stack space -// of ((offset)+0*8)(RSP) ~ ((offset)+7*8)(RSP). -// -// R29 is not saved because Go will save and restore it. - -#define SAVE_R19_TO_R28(offset) \ - STP (R19, R20), ((offset)+0*8)(RSP) \ - STP (R21, R22), ((offset)+2*8)(RSP) \ - STP (R23, R24), ((offset)+4*8)(RSP) \ - STP (R25, R26), ((offset)+6*8)(RSP) \ - STP (R27, g), ((offset)+8*8)(RSP) -#define RESTORE_R19_TO_R28(offset) \ - LDP ((offset)+0*8)(RSP), (R19, R20) \ - LDP ((offset)+2*8)(RSP), (R21, R22) \ - LDP ((offset)+4*8)(RSP), (R23, R24) \ - LDP ((offset)+6*8)(RSP), (R25, R26) \ - LDP ((offset)+8*8)(RSP), (R27, g) /* R28 */ -#define SAVE_F8_TO_F15(offset) \ - FSTPD (F8, F9), ((offset)+0*8)(RSP) \ - FSTPD (F10, F11), ((offset)+2*8)(RSP) \ - FSTPD (F12, F13), ((offset)+4*8)(RSP) \ - FSTPD (F14, F15), ((offset)+6*8)(RSP) -#define RESTORE_F8_TO_F15(offset) \ - FLDPD ((offset)+0*8)(RSP), (F8, F9) \ - FLDPD ((offset)+2*8)(RSP), (F10, F11) \ - FLDPD ((offset)+4*8)(RSP), (F12, F13) \ - FLDPD ((offset)+6*8)(RSP), (F14, F15) diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/asm_amd64.s b/vendor/github.com/ebitengine/purego/internal/fakecgo/asm_amd64.s deleted file mode 100644 index 2b7eb57f8ae78..0000000000000 --- a/vendor/github.com/ebitengine/purego/internal/fakecgo/asm_amd64.s +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -#include "textflag.h" -#include "abi_amd64.h" - -// Called by C code generated by cmd/cgo. -// func crosscall2(fn, a unsafe.Pointer, n int32, ctxt uintptr) -// Saves C callee-saved registers and calls cgocallback with three arguments. -// fn is the PC of a func(a unsafe.Pointer) function. -// This signature is known to SWIG, so we can't change it. -TEXT crosscall2(SB), NOSPLIT, $0-0 - PUSH_REGS_HOST_TO_ABI0() - - // Make room for arguments to cgocallback. - ADJSP $0x18 - -#ifndef GOOS_windows - MOVQ DI, 0x0(SP) // fn - MOVQ SI, 0x8(SP) // arg - - // Skip n in DX. - MOVQ CX, 0x10(SP) // ctxt - -#else - MOVQ CX, 0x0(SP) // fn - MOVQ DX, 0x8(SP) // arg - - // Skip n in R8. - MOVQ R9, 0x10(SP) // ctxt - -#endif - - CALL runtime·cgocallback(SB) - - ADJSP $-0x18 - POP_REGS_HOST_TO_ABI0() - RET diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/asm_arm64.s b/vendor/github.com/ebitengine/purego/internal/fakecgo/asm_arm64.s deleted file mode 100644 index 50e5261d922c5..0000000000000 --- a/vendor/github.com/ebitengine/purego/internal/fakecgo/asm_arm64.s +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -#include "textflag.h" -#include "abi_arm64.h" - -// Called by C code generated by cmd/cgo. -// func crosscall2(fn, a unsafe.Pointer, n int32, ctxt uintptr) -// Saves C callee-saved registers and calls cgocallback with three arguments. -// fn is the PC of a func(a unsafe.Pointer) function. -TEXT crosscall2(SB), NOSPLIT|NOFRAME, $0 -/* - * We still need to save all callee save register as before, and then - * push 3 args for fn (R0, R1, R3), skipping R2. - * Also note that at procedure entry in gc world, 8(RSP) will be the - * first arg. - */ - SUB $(8*24), RSP - STP (R0, R1), (8*1)(RSP) - MOVD R3, (8*3)(RSP) - - SAVE_R19_TO_R28(8*4) - SAVE_F8_TO_F15(8*14) - STP (R29, R30), (8*22)(RSP) - - // Initialize Go ABI environment - BL runtime·load_g(SB) - BL runtime·cgocallback(SB) - - RESTORE_R19_TO_R28(8*4) - RESTORE_F8_TO_F15(8*14) - LDP (8*22)(RSP), (R29, R30) - - ADD $(8*24), RSP - RET diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/callbacks.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/callbacks.go deleted file mode 100644 index f29e690cc15b3..0000000000000 --- a/vendor/github.com/ebitengine/purego/internal/fakecgo/callbacks.go +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build !cgo && (darwin || freebsd || linux) - -package fakecgo - -import ( - _ "unsafe" -) - -// TODO: decide if we need _runtime_cgo_panic_internal - -//go:linkname x_cgo_init_trampoline x_cgo_init_trampoline -//go:linkname _cgo_init _cgo_init -var x_cgo_init_trampoline byte -var _cgo_init = &x_cgo_init_trampoline - -// Creates a new system thread without updating any Go state. -// -// This method is invoked during shared library loading to create a new OS -// thread to perform the runtime initialization. This method is similar to -// _cgo_sys_thread_start except that it doesn't update any Go state. - -//go:linkname x_cgo_thread_start_trampoline x_cgo_thread_start_trampoline -//go:linkname _cgo_thread_start _cgo_thread_start -var x_cgo_thread_start_trampoline byte -var _cgo_thread_start = &x_cgo_thread_start_trampoline - -// Notifies that the runtime has been initialized. -// -// We currently block at every CGO entry point (via _cgo_wait_runtime_init_done) -// to ensure that the runtime has been initialized before the CGO call is -// executed. This is necessary for shared libraries where we kickoff runtime -// initialization in a separate thread and return without waiting for this -// thread to complete the init. - -//go:linkname x_cgo_notify_runtime_init_done_trampoline x_cgo_notify_runtime_init_done_trampoline -//go:linkname _cgo_notify_runtime_init_done _cgo_notify_runtime_init_done -var x_cgo_notify_runtime_init_done_trampoline byte -var _cgo_notify_runtime_init_done = &x_cgo_notify_runtime_init_done_trampoline - -// Indicates whether a dummy thread key has been created or not. -// -// When calling go exported function from C, we register a destructor -// callback, for a dummy thread key, by using pthread_key_create. - -//go:linkname _cgo_pthread_key_created _cgo_pthread_key_created -var x_cgo_pthread_key_created uintptr -var _cgo_pthread_key_created = &x_cgo_pthread_key_created - -// Set the x_crosscall2_ptr C function pointer variable point to crosscall2. -// It's for the runtime package to call at init time. -func set_crosscall2() { - // nothing needs to be done here for fakecgo - // because it's possible to just call cgocallback directly -} - -//go:linkname _set_crosscall2 runtime.set_crosscall2 -var _set_crosscall2 = set_crosscall2 - -// Store the g into the thread-specific value. -// So that pthread_key_destructor will dropm when the thread is exiting. - -//go:linkname x_cgo_bindm_trampoline x_cgo_bindm_trampoline -//go:linkname _cgo_bindm _cgo_bindm -var x_cgo_bindm_trampoline byte -var _cgo_bindm = &x_cgo_bindm_trampoline - -// TODO: decide if we need x_cgo_set_context_function -// TODO: decide if we need _cgo_yield - -var ( - // In Go 1.20 the race detector was rewritten to pure Go - // on darwin. This means that when CGO_ENABLED=0 is set - // fakecgo is built with race detector code. This is not - // good since this code is pretending to be C. The go:norace - // pragma is not enough, since it only applies to the native - // ABIInternal function. The ABIO wrapper (which is necessary, - // since all references to text symbols from assembly will use it) - // does not inherit the go:norace pragma, so it will still be - // instrumented by the race detector. - // - // To circumvent this issue, using closure calls in the - // assembly, which forces the compiler to use the ABIInternal - // native implementation (which has go:norace) instead. - threadentry_call = threadentry - x_cgo_init_call = x_cgo_init - x_cgo_setenv_call = x_cgo_setenv - x_cgo_unsetenv_call = x_cgo_unsetenv - x_cgo_thread_start_call = x_cgo_thread_start -) diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/doc.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/doc.go deleted file mode 100644 index be82f7dfca90f..0000000000000 --- a/vendor/github.com/ebitengine/purego/internal/fakecgo/doc.go +++ /dev/null @@ -1,32 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2022 The Ebitengine Authors - -//go:build !cgo && (darwin || freebsd || linux) - -// Package fakecgo implements the Cgo runtime (runtime/cgo) entirely in Go. -// This allows code that calls into C to function properly when CGO_ENABLED=0. -// -// # Goals -// -// fakecgo attempts to replicate the same naming structure as in the runtime. -// For example, functions that have the prefix "gcc_*" are named "go_*". -// This makes it easier to port other GOOSs and GOARCHs as well as to keep -// it in sync with runtime/cgo. -// -// # Support -// -// Currently, fakecgo only supports macOS on amd64 & arm64. It also cannot -// be used with -buildmode=c-archive because that requires special initialization -// that fakecgo does not implement at the moment. -// -// # Usage -// -// Using fakecgo is easy just import _ "github.com/ebitengine/purego" and then -// set the environment variable CGO_ENABLED=0. -// The recommended usage for fakecgo is to prefer using runtime/cgo if possible -// but if cross-compiling or fast build times are important fakecgo is available. -// Purego will pick which ever Cgo runtime is available and prefer the one that -// comes with Go (runtime/cgo). -package fakecgo - -//go:generate go run gen.go diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/freebsd.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/freebsd.go deleted file mode 100644 index bb73a709e6918..0000000000000 --- a/vendor/github.com/ebitengine/purego/internal/fakecgo/freebsd.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2010 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build freebsd && !cgo - -package fakecgo - -import _ "unsafe" // for go:linkname - -// Supply environ and __progname, because we don't -// link against the standard FreeBSD crt0.o and the -// libc dynamic library needs them. - -// Note: when building with cross-compiling or CGO_ENABLED=0, add -// the following argument to `go` so that these symbols are defined by -// making fakecgo the Cgo. -// -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" - -//go:linkname _environ environ -//go:linkname _progname __progname - -//go:cgo_export_dynamic environ -//go:cgo_export_dynamic __progname - -var _environ uintptr -var _progname uintptr diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/go_darwin_amd64.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/go_darwin_amd64.go deleted file mode 100644 index 39f5ff1f06a0e..0000000000000 --- a/vendor/github.com/ebitengine/purego/internal/fakecgo/go_darwin_amd64.go +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build !cgo - -package fakecgo - -import "unsafe" - -//go:nosplit -//go:norace -func _cgo_sys_thread_start(ts *ThreadStart) { - var attr pthread_attr_t - var ign, oset sigset_t - var p pthread_t - var size size_t - var err int - - sigfillset(&ign) - pthread_sigmask(SIG_SETMASK, &ign, &oset) - - size = pthread_get_stacksize_np(pthread_self()) - pthread_attr_init(&attr) - pthread_attr_setstacksize(&attr, size) - // Leave stacklo=0 and set stackhi=size; mstart will do the rest. - ts.g.stackhi = uintptr(size) - - err = _cgo_try_pthread_create(&p, &attr, unsafe.Pointer(threadentry_trampolineABI0), ts) - - pthread_sigmask(SIG_SETMASK, &oset, nil) - - if err != 0 { - print("fakecgo: pthread_create failed: ") - println(err) - abort() - } -} - -// threadentry_trampolineABI0 maps the C ABI to Go ABI then calls the Go function -// -//go:linkname x_threadentry_trampoline threadentry_trampoline -var x_threadentry_trampoline byte -var threadentry_trampolineABI0 = &x_threadentry_trampoline - -//go:nosplit -//go:norace -func threadentry(v unsafe.Pointer) unsafe.Pointer { - ts := *(*ThreadStart)(v) - free(v) - - setg_trampoline(setg_func, uintptr(unsafe.Pointer(ts.g))) - - // faking funcs in go is a bit a... involved - but the following works :) - fn := uintptr(unsafe.Pointer(&ts.fn)) - (*(*func())(unsafe.Pointer(&fn)))() - - return nil -} - -// here we will store a pointer to the provided setg func -var setg_func uintptr - -//go:nosplit -//go:norace -func x_cgo_init(g *G, setg uintptr) { - var size size_t - - setg_func = setg - - size = pthread_get_stacksize_np(pthread_self()) - g.stacklo = uintptr(unsafe.Add(unsafe.Pointer(&size), -size+4096)) -} diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/go_darwin_arm64.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/go_darwin_arm64.go deleted file mode 100644 index d0868f0f79035..0000000000000 --- a/vendor/github.com/ebitengine/purego/internal/fakecgo/go_darwin_arm64.go +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build !cgo - -package fakecgo - -import "unsafe" - -//go:nosplit -//go:norace -func _cgo_sys_thread_start(ts *ThreadStart) { - var attr pthread_attr_t - var ign, oset sigset_t - var p pthread_t - var size size_t - var err int - - sigfillset(&ign) - pthread_sigmask(SIG_SETMASK, &ign, &oset) - - size = pthread_get_stacksize_np(pthread_self()) - pthread_attr_init(&attr) - pthread_attr_setstacksize(&attr, size) - // Leave stacklo=0 and set stackhi=size; mstart will do the rest. - ts.g.stackhi = uintptr(size) - - err = _cgo_try_pthread_create(&p, &attr, unsafe.Pointer(threadentry_trampolineABI0), ts) - - pthread_sigmask(SIG_SETMASK, &oset, nil) - - if err != 0 { - print("fakecgo: pthread_create failed: ") - println(err) - abort() - } -} - -// threadentry_trampolineABI0 maps the C ABI to Go ABI then calls the Go function -// -//go:linkname x_threadentry_trampoline threadentry_trampoline -var x_threadentry_trampoline byte -var threadentry_trampolineABI0 = &x_threadentry_trampoline - -//go:nosplit -//go:norace -func threadentry(v unsafe.Pointer) unsafe.Pointer { - ts := *(*ThreadStart)(v) - free(v) - - // TODO: support ios - //#if TARGET_OS_IPHONE - // darwin_arm_init_thread_exception_port(); - //#endif - setg_trampoline(setg_func, uintptr(unsafe.Pointer(ts.g))) - - // faking funcs in go is a bit a... involved - but the following works :) - fn := uintptr(unsafe.Pointer(&ts.fn)) - (*(*func())(unsafe.Pointer(&fn)))() - - return nil -} - -// here we will store a pointer to the provided setg func -var setg_func uintptr - -// x_cgo_init(G *g, void (*setg)(void*)) (runtime/cgo/gcc_linux_amd64.c) -// This get's called during startup, adjusts stacklo, and provides a pointer to setg_gcc for us -// Additionally, if we set _cgo_init to non-null, go won't do it's own TLS setup -// This function can't be go:systemstack since go is not in a state where the systemcheck would work. -// -//go:nosplit -//go:norace -func x_cgo_init(g *G, setg uintptr) { - var size size_t - - setg_func = setg - size = pthread_get_stacksize_np(pthread_self()) - g.stacklo = uintptr(unsafe.Add(unsafe.Pointer(&size), -size+4096)) - - //TODO: support ios - //#if TARGET_OS_IPHONE - // darwin_arm_init_mach_exception_handler(); - // darwin_arm_init_thread_exception_port(); - // init_working_dir(); - //#endif -} diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/go_freebsd_amd64.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/go_freebsd_amd64.go deleted file mode 100644 index c9ff7156a8974..0000000000000 --- a/vendor/github.com/ebitengine/purego/internal/fakecgo/go_freebsd_amd64.go +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build !cgo - -package fakecgo - -import "unsafe" - -//go:nosplit -func _cgo_sys_thread_start(ts *ThreadStart) { - var attr pthread_attr_t - var ign, oset sigset_t - var p pthread_t - var size size_t - var err int - - //fprintf(stderr, "runtime/cgo: _cgo_sys_thread_start: fn=%p, g=%p\n", ts->fn, ts->g); // debug - sigfillset(&ign) - pthread_sigmask(SIG_SETMASK, &ign, &oset) - - pthread_attr_init(&attr) - pthread_attr_getstacksize(&attr, &size) - // Leave stacklo=0 and set stackhi=size; mstart will do the rest. - ts.g.stackhi = uintptr(size) - - err = _cgo_try_pthread_create(&p, &attr, unsafe.Pointer(threadentry_trampolineABI0), ts) - - pthread_sigmask(SIG_SETMASK, &oset, nil) - - if err != 0 { - print("fakecgo: pthread_create failed: ") - println(err) - abort() - } -} - -// threadentry_trampolineABI0 maps the C ABI to Go ABI then calls the Go function -// -//go:linkname x_threadentry_trampoline threadentry_trampoline -var x_threadentry_trampoline byte -var threadentry_trampolineABI0 = &x_threadentry_trampoline - -//go:nosplit -func threadentry(v unsafe.Pointer) unsafe.Pointer { - ts := *(*ThreadStart)(v) - free(v) - - setg_trampoline(setg_func, uintptr(unsafe.Pointer(ts.g))) - - // faking funcs in go is a bit a... involved - but the following works :) - fn := uintptr(unsafe.Pointer(&ts.fn)) - (*(*func())(unsafe.Pointer(&fn)))() - - return nil -} - -// here we will store a pointer to the provided setg func -var setg_func uintptr - -//go:nosplit -func x_cgo_init(g *G, setg uintptr) { - var size size_t - var attr *pthread_attr_t - - /* The memory sanitizer distributed with versions of clang - before 3.8 has a bug: if you call mmap before malloc, mmap - may return an address that is later overwritten by the msan - library. Avoid this problem by forcing a call to malloc - here, before we ever call malloc. - - This is only required for the memory sanitizer, so it's - unfortunate that we always run it. It should be possible - to remove this when we no longer care about versions of - clang before 3.8. The test for this is - misc/cgo/testsanitizers. - - GCC works hard to eliminate a seemingly unnecessary call to - malloc, so we actually use the memory we allocate. */ - - setg_func = setg - attr = (*pthread_attr_t)(malloc(unsafe.Sizeof(*attr))) - if attr == nil { - println("fakecgo: malloc failed") - abort() - } - pthread_attr_init(attr) - pthread_attr_getstacksize(attr, &size) - // runtime/cgo uses __builtin_frame_address(0) instead of `uintptr(unsafe.Pointer(&size))` - // but this should be OK since we are taking the address of the first variable in this function. - g.stacklo = uintptr(unsafe.Pointer(&size)) - uintptr(size) + 4096 - pthread_attr_destroy(attr) - free(unsafe.Pointer(attr)) -} diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/go_freebsd_arm64.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/go_freebsd_arm64.go deleted file mode 100644 index e3a060b93506a..0000000000000 --- a/vendor/github.com/ebitengine/purego/internal/fakecgo/go_freebsd_arm64.go +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build !cgo - -package fakecgo - -import "unsafe" - -//go:nosplit -func _cgo_sys_thread_start(ts *ThreadStart) { - var attr pthread_attr_t - var ign, oset sigset_t - var p pthread_t - var size size_t - var err int - - // fprintf(stderr, "runtime/cgo: _cgo_sys_thread_start: fn=%p, g=%p\n", ts->fn, ts->g); // debug - sigfillset(&ign) - pthread_sigmask(SIG_SETMASK, &ign, &oset) - - pthread_attr_init(&attr) - pthread_attr_getstacksize(&attr, &size) - // Leave stacklo=0 and set stackhi=size; mstart will do the rest. - ts.g.stackhi = uintptr(size) - - err = _cgo_try_pthread_create(&p, &attr, unsafe.Pointer(threadentry_trampolineABI0), ts) - - pthread_sigmask(SIG_SETMASK, &oset, nil) - - if err != 0 { - print("fakecgo: pthread_create failed: ") - println(err) - abort() - } -} - -// threadentry_trampolineABI0 maps the C ABI to Go ABI then calls the Go function -// -//go:linkname x_threadentry_trampoline threadentry_trampoline -var x_threadentry_trampoline byte -var threadentry_trampolineABI0 = &x_threadentry_trampoline - -//go:nosplit -func threadentry(v unsafe.Pointer) unsafe.Pointer { - ts := *(*ThreadStart)(v) - free(v) - - setg_trampoline(setg_func, uintptr(unsafe.Pointer(ts.g))) - - // faking funcs in go is a bit a... involved - but the following works :) - fn := uintptr(unsafe.Pointer(&ts.fn)) - (*(*func())(unsafe.Pointer(&fn)))() - - return nil -} - -// here we will store a pointer to the provided setg func -var setg_func uintptr - -// x_cgo_init(G *g, void (*setg)(void*)) (runtime/cgo/gcc_linux_amd64.c) -// This get's called during startup, adjusts stacklo, and provides a pointer to setg_gcc for us -// Additionally, if we set _cgo_init to non-null, go won't do it's own TLS setup -// This function can't be go:systemstack since go is not in a state where the systemcheck would work. -// -//go:nosplit -func x_cgo_init(g *G, setg uintptr) { - var size size_t - var attr *pthread_attr_t - - /* The memory sanitizer distributed with versions of clang - before 3.8 has a bug: if you call mmap before malloc, mmap - may return an address that is later overwritten by the msan - library. Avoid this problem by forcing a call to malloc - here, before we ever call malloc. - - This is only required for the memory sanitizer, so it's - unfortunate that we always run it. It should be possible - to remove this when we no longer care about versions of - clang before 3.8. The test for this is - misc/cgo/testsanitizers. - - GCC works hard to eliminate a seemingly unnecessary call to - malloc, so we actually use the memory we allocate. */ - - setg_func = setg - attr = (*pthread_attr_t)(malloc(unsafe.Sizeof(*attr))) - if attr == nil { - println("fakecgo: malloc failed") - abort() - } - pthread_attr_init(attr) - pthread_attr_getstacksize(attr, &size) - g.stacklo = uintptr(unsafe.Pointer(&size)) - uintptr(size) + 4096 - pthread_attr_destroy(attr) - free(unsafe.Pointer(attr)) -} diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/go_libinit.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/go_libinit.go deleted file mode 100644 index e5cb46be4557c..0000000000000 --- a/vendor/github.com/ebitengine/purego/internal/fakecgo/go_libinit.go +++ /dev/null @@ -1,66 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2022 The Ebitengine Authors - -//go:build !cgo && (darwin || freebsd || linux) - -package fakecgo - -import ( - "syscall" - "unsafe" -) - -var ( - pthread_g pthread_key_t - - runtime_init_cond = PTHREAD_COND_INITIALIZER - runtime_init_mu = PTHREAD_MUTEX_INITIALIZER - runtime_init_done int -) - -//go:nosplit -func x_cgo_notify_runtime_init_done() { - pthread_mutex_lock(&runtime_init_mu) - runtime_init_done = 1 - pthread_cond_broadcast(&runtime_init_cond) - pthread_mutex_unlock(&runtime_init_mu) -} - -// Store the g into a thread-specific value associated with the pthread key pthread_g. -// And pthread_key_destructor will dropm when the thread is exiting. -func x_cgo_bindm(g unsafe.Pointer) { - // We assume this will always succeed, otherwise, there might be extra M leaking, - // when a C thread exits after a cgo call. - // We only invoke this function once per thread in runtime.needAndBindM, - // and the next calls just reuse the bound m. - pthread_setspecific(pthread_g, g) -} - -// _cgo_try_pthread_create retries pthread_create if it fails with -// EAGAIN. -// -//go:nosplit -//go:norace -func _cgo_try_pthread_create(thread *pthread_t, attr *pthread_attr_t, pfn unsafe.Pointer, arg *ThreadStart) int { - var ts syscall.Timespec - // tries needs to be the same type as syscall.Timespec.Nsec - // but the fields are int32 on 32bit and int64 on 64bit. - // tries is assigned to syscall.Timespec.Nsec in order to match its type. - tries := ts.Nsec - var err int - - for tries = 0; tries < 20; tries++ { - err = int(pthread_create(thread, attr, pfn, unsafe.Pointer(arg))) - if err == 0 { - pthread_detach(*thread) - return 0 - } - if err != int(syscall.EAGAIN) { - return err - } - ts.Sec = 0 - ts.Nsec = (tries + 1) * 1000 * 1000 // Milliseconds. - nanosleep(&ts, nil) - } - return int(syscall.EAGAIN) -} diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/go_linux_amd64.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/go_linux_amd64.go deleted file mode 100644 index c9ff7156a8974..0000000000000 --- a/vendor/github.com/ebitengine/purego/internal/fakecgo/go_linux_amd64.go +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build !cgo - -package fakecgo - -import "unsafe" - -//go:nosplit -func _cgo_sys_thread_start(ts *ThreadStart) { - var attr pthread_attr_t - var ign, oset sigset_t - var p pthread_t - var size size_t - var err int - - //fprintf(stderr, "runtime/cgo: _cgo_sys_thread_start: fn=%p, g=%p\n", ts->fn, ts->g); // debug - sigfillset(&ign) - pthread_sigmask(SIG_SETMASK, &ign, &oset) - - pthread_attr_init(&attr) - pthread_attr_getstacksize(&attr, &size) - // Leave stacklo=0 and set stackhi=size; mstart will do the rest. - ts.g.stackhi = uintptr(size) - - err = _cgo_try_pthread_create(&p, &attr, unsafe.Pointer(threadentry_trampolineABI0), ts) - - pthread_sigmask(SIG_SETMASK, &oset, nil) - - if err != 0 { - print("fakecgo: pthread_create failed: ") - println(err) - abort() - } -} - -// threadentry_trampolineABI0 maps the C ABI to Go ABI then calls the Go function -// -//go:linkname x_threadentry_trampoline threadentry_trampoline -var x_threadentry_trampoline byte -var threadentry_trampolineABI0 = &x_threadentry_trampoline - -//go:nosplit -func threadentry(v unsafe.Pointer) unsafe.Pointer { - ts := *(*ThreadStart)(v) - free(v) - - setg_trampoline(setg_func, uintptr(unsafe.Pointer(ts.g))) - - // faking funcs in go is a bit a... involved - but the following works :) - fn := uintptr(unsafe.Pointer(&ts.fn)) - (*(*func())(unsafe.Pointer(&fn)))() - - return nil -} - -// here we will store a pointer to the provided setg func -var setg_func uintptr - -//go:nosplit -func x_cgo_init(g *G, setg uintptr) { - var size size_t - var attr *pthread_attr_t - - /* The memory sanitizer distributed with versions of clang - before 3.8 has a bug: if you call mmap before malloc, mmap - may return an address that is later overwritten by the msan - library. Avoid this problem by forcing a call to malloc - here, before we ever call malloc. - - This is only required for the memory sanitizer, so it's - unfortunate that we always run it. It should be possible - to remove this when we no longer care about versions of - clang before 3.8. The test for this is - misc/cgo/testsanitizers. - - GCC works hard to eliminate a seemingly unnecessary call to - malloc, so we actually use the memory we allocate. */ - - setg_func = setg - attr = (*pthread_attr_t)(malloc(unsafe.Sizeof(*attr))) - if attr == nil { - println("fakecgo: malloc failed") - abort() - } - pthread_attr_init(attr) - pthread_attr_getstacksize(attr, &size) - // runtime/cgo uses __builtin_frame_address(0) instead of `uintptr(unsafe.Pointer(&size))` - // but this should be OK since we are taking the address of the first variable in this function. - g.stacklo = uintptr(unsafe.Pointer(&size)) - uintptr(size) + 4096 - pthread_attr_destroy(attr) - free(unsafe.Pointer(attr)) -} diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/go_linux_arm64.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/go_linux_arm64.go deleted file mode 100644 index a3b1cca59a086..0000000000000 --- a/vendor/github.com/ebitengine/purego/internal/fakecgo/go_linux_arm64.go +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build !cgo - -package fakecgo - -import "unsafe" - -//go:nosplit -func _cgo_sys_thread_start(ts *ThreadStart) { - var attr pthread_attr_t - var ign, oset sigset_t - var p pthread_t - var size size_t - var err int - - //fprintf(stderr, "runtime/cgo: _cgo_sys_thread_start: fn=%p, g=%p\n", ts->fn, ts->g); // debug - sigfillset(&ign) - pthread_sigmask(SIG_SETMASK, &ign, &oset) - - pthread_attr_init(&attr) - pthread_attr_getstacksize(&attr, &size) - // Leave stacklo=0 and set stackhi=size; mstart will do the rest. - ts.g.stackhi = uintptr(size) - - err = _cgo_try_pthread_create(&p, &attr, unsafe.Pointer(threadentry_trampolineABI0), ts) - - pthread_sigmask(SIG_SETMASK, &oset, nil) - - if err != 0 { - print("fakecgo: pthread_create failed: ") - println(err) - abort() - } -} - -// threadentry_trampolineABI0 maps the C ABI to Go ABI then calls the Go function -// -//go:linkname x_threadentry_trampoline threadentry_trampoline -var x_threadentry_trampoline byte -var threadentry_trampolineABI0 = &x_threadentry_trampoline - -//go:nosplit -func threadentry(v unsafe.Pointer) unsafe.Pointer { - ts := *(*ThreadStart)(v) - free(v) - - setg_trampoline(setg_func, uintptr(unsafe.Pointer(ts.g))) - - // faking funcs in go is a bit a... involved - but the following works :) - fn := uintptr(unsafe.Pointer(&ts.fn)) - (*(*func())(unsafe.Pointer(&fn)))() - - return nil -} - -// here we will store a pointer to the provided setg func -var setg_func uintptr - -// x_cgo_init(G *g, void (*setg)(void*)) (runtime/cgo/gcc_linux_amd64.c) -// This get's called during startup, adjusts stacklo, and provides a pointer to setg_gcc for us -// Additionally, if we set _cgo_init to non-null, go won't do it's own TLS setup -// This function can't be go:systemstack since go is not in a state where the systemcheck would work. -// -//go:nosplit -func x_cgo_init(g *G, setg uintptr) { - var size size_t - var attr *pthread_attr_t - - /* The memory sanitizer distributed with versions of clang - before 3.8 has a bug: if you call mmap before malloc, mmap - may return an address that is later overwritten by the msan - library. Avoid this problem by forcing a call to malloc - here, before we ever call malloc. - - This is only required for the memory sanitizer, so it's - unfortunate that we always run it. It should be possible - to remove this when we no longer care about versions of - clang before 3.8. The test for this is - misc/cgo/testsanitizers. - - GCC works hard to eliminate a seemingly unnecessary call to - malloc, so we actually use the memory we allocate. */ - - setg_func = setg - attr = (*pthread_attr_t)(malloc(unsafe.Sizeof(*attr))) - if attr == nil { - println("fakecgo: malloc failed") - abort() - } - pthread_attr_init(attr) - pthread_attr_getstacksize(attr, &size) - g.stacklo = uintptr(unsafe.Pointer(&size)) - uintptr(size) + 4096 - pthread_attr_destroy(attr) - free(unsafe.Pointer(attr)) -} diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/go_setenv.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/go_setenv.go deleted file mode 100644 index e42d84f0b75ea..0000000000000 --- a/vendor/github.com/ebitengine/purego/internal/fakecgo/go_setenv.go +++ /dev/null @@ -1,18 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2022 The Ebitengine Authors - -//go:build !cgo && (darwin || freebsd || linux) - -package fakecgo - -//go:nosplit -//go:norace -func x_cgo_setenv(arg *[2]*byte) { - setenv(arg[0], arg[1], 1) -} - -//go:nosplit -//go:norace -func x_cgo_unsetenv(arg *[1]*byte) { - unsetenv(arg[0]) -} diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/go_util.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/go_util.go deleted file mode 100644 index 0ac10d1f1578d..0000000000000 --- a/vendor/github.com/ebitengine/purego/internal/fakecgo/go_util.go +++ /dev/null @@ -1,37 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2022 The Ebitengine Authors - -//go:build !cgo && (darwin || freebsd || linux) - -package fakecgo - -import "unsafe" - -// _cgo_thread_start is split into three parts in cgo since only one part is system dependent (keep it here for easier handling) - -// _cgo_thread_start(ThreadStart *arg) (runtime/cgo/gcc_util.c) -// This get's called instead of the go code for creating new threads -// -> pthread_* stuff is used, so threads are setup correctly for C -// If this is missing, TLS is only setup correctly on thread 1! -// This function should be go:systemstack instead of go:nosplit (but that requires runtime) -// -//go:nosplit -//go:norace -func x_cgo_thread_start(arg *ThreadStart) { - var ts *ThreadStart - // Make our own copy that can persist after we return. - // _cgo_tsan_acquire(); - ts = (*ThreadStart)(malloc(unsafe.Sizeof(*ts))) - // _cgo_tsan_release(); - if ts == nil { - println("fakecgo: out of memory in thread_start") - abort() - } - // *ts = *arg would cause a writebarrier so copy using slices - s1 := unsafe.Slice((*uintptr)(unsafe.Pointer(ts)), unsafe.Sizeof(*ts)/8) - s2 := unsafe.Slice((*uintptr)(unsafe.Pointer(arg)), unsafe.Sizeof(*arg)/8) - for i := range s2 { - s1[i] = s2[i] - } - _cgo_sys_thread_start(ts) // OS-dependent half -} diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/iscgo.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/iscgo.go deleted file mode 100644 index 28af41cc64072..0000000000000 --- a/vendor/github.com/ebitengine/purego/internal/fakecgo/iscgo.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2010 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 !cgo && (darwin || freebsd || linux) - -// The runtime package contains an uninitialized definition -// for runtime·iscgo. Override it to tell the runtime we're here. -// There are various function pointers that should be set too, -// but those depend on dynamic linker magic to get initialized -// correctly, and sometimes they break. This variable is a -// backup: it depends only on old C style static linking rules. - -package fakecgo - -import _ "unsafe" // for go:linkname - -//go:linkname _iscgo runtime.iscgo -var _iscgo bool = true diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo.go deleted file mode 100644 index 74626c64a0e9a..0000000000000 --- a/vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo.go +++ /dev/null @@ -1,35 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2022 The Ebitengine Authors - -//go:build !cgo && (darwin || freebsd || linux) - -package fakecgo - -type ( - size_t uintptr - sigset_t [128]byte - pthread_attr_t [64]byte - pthread_t int - pthread_key_t uint64 -) - -// for pthread_sigmask: - -type sighow int32 - -const ( - SIG_BLOCK sighow = 0 - SIG_UNBLOCK sighow = 1 - SIG_SETMASK sighow = 2 -) - -type G struct { - stacklo uintptr - stackhi uintptr -} - -type ThreadStart struct { - g *G - tls *uintptr - fn uintptr -} diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_darwin.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_darwin.go deleted file mode 100644 index af148333f6d9c..0000000000000 --- a/vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_darwin.go +++ /dev/null @@ -1,22 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2022 The Ebitengine Authors - -//go:build !cgo - -package fakecgo - -type ( - pthread_mutex_t struct { - sig int64 - opaque [56]byte - } - pthread_cond_t struct { - sig int64 - opaque [40]byte - } -) - -var ( - PTHREAD_COND_INITIALIZER = pthread_cond_t{sig: 0x3CB0B1BB} - PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t{sig: 0x32AAABA7} -) diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_freebsd.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_freebsd.go deleted file mode 100644 index ca1f722c93989..0000000000000 --- a/vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_freebsd.go +++ /dev/null @@ -1,16 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2022 The Ebitengine Authors - -//go:build !cgo - -package fakecgo - -type ( - pthread_cond_t uintptr - pthread_mutex_t uintptr -) - -var ( - PTHREAD_COND_INITIALIZER = pthread_cond_t(0) - PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t(0) -) diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_linux.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_linux.go deleted file mode 100644 index c4b6e9ea5a4cf..0000000000000 --- a/vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_linux.go +++ /dev/null @@ -1,16 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2022 The Ebitengine Authors - -//go:build !cgo - -package fakecgo - -type ( - pthread_cond_t [48]byte - pthread_mutex_t [48]byte -) - -var ( - PTHREAD_COND_INITIALIZER = pthread_cond_t{} - PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t{} -) diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/setenv.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/setenv.go deleted file mode 100644 index f30af0e151569..0000000000000 --- a/vendor/github.com/ebitengine/purego/internal/fakecgo/setenv.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build !cgo && (darwin || freebsd || linux) - -package fakecgo - -import _ "unsafe" // for go:linkname - -//go:linkname x_cgo_setenv_trampoline x_cgo_setenv_trampoline -//go:linkname _cgo_setenv runtime._cgo_setenv -var x_cgo_setenv_trampoline byte -var _cgo_setenv = &x_cgo_setenv_trampoline - -//go:linkname x_cgo_unsetenv_trampoline x_cgo_unsetenv_trampoline -//go:linkname _cgo_unsetenv runtime._cgo_unsetenv -var x_cgo_unsetenv_trampoline byte -var _cgo_unsetenv = &x_cgo_unsetenv_trampoline diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols.go deleted file mode 100644 index 3d19fd822a73e..0000000000000 --- a/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols.go +++ /dev/null @@ -1,181 +0,0 @@ -// Code generated by 'go generate' with gen.go. DO NOT EDIT. - -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2022 The Ebitengine Authors - -//go:build !cgo && (darwin || freebsd || linux) - -package fakecgo - -import ( - "syscall" - "unsafe" -) - -// setg_trampoline calls setg with the G provided -func setg_trampoline(setg uintptr, G uintptr) - -// call5 takes fn the C function and 5 arguments and calls the function with those arguments -func call5(fn, a1, a2, a3, a4, a5 uintptr) uintptr - -func malloc(size uintptr) unsafe.Pointer { - ret := call5(mallocABI0, uintptr(size), 0, 0, 0, 0) - // this indirection is to avoid go vet complaining about possible misuse of unsafe.Pointer - return *(*unsafe.Pointer)(unsafe.Pointer(&ret)) -} - -func free(ptr unsafe.Pointer) { - call5(freeABI0, uintptr(ptr), 0, 0, 0, 0) -} - -func setenv(name *byte, value *byte, overwrite int32) int32 { - return int32(call5(setenvABI0, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(value)), uintptr(overwrite), 0, 0)) -} - -func unsetenv(name *byte) int32 { - return int32(call5(unsetenvABI0, uintptr(unsafe.Pointer(name)), 0, 0, 0, 0)) -} - -func sigfillset(set *sigset_t) int32 { - return int32(call5(sigfillsetABI0, uintptr(unsafe.Pointer(set)), 0, 0, 0, 0)) -} - -func nanosleep(ts *syscall.Timespec, rem *syscall.Timespec) int32 { - return int32(call5(nanosleepABI0, uintptr(unsafe.Pointer(ts)), uintptr(unsafe.Pointer(rem)), 0, 0, 0)) -} - -func abort() { - call5(abortABI0, 0, 0, 0, 0, 0) -} - -func pthread_attr_init(attr *pthread_attr_t) int32 { - return int32(call5(pthread_attr_initABI0, uintptr(unsafe.Pointer(attr)), 0, 0, 0, 0)) -} - -func pthread_create(thread *pthread_t, attr *pthread_attr_t, start unsafe.Pointer, arg unsafe.Pointer) int32 { - return int32(call5(pthread_createABI0, uintptr(unsafe.Pointer(thread)), uintptr(unsafe.Pointer(attr)), uintptr(start), uintptr(arg), 0)) -} - -func pthread_detach(thread pthread_t) int32 { - return int32(call5(pthread_detachABI0, uintptr(thread), 0, 0, 0, 0)) -} - -func pthread_sigmask(how sighow, ign *sigset_t, oset *sigset_t) int32 { - return int32(call5(pthread_sigmaskABI0, uintptr(how), uintptr(unsafe.Pointer(ign)), uintptr(unsafe.Pointer(oset)), 0, 0)) -} - -func pthread_self() pthread_t { - return pthread_t(call5(pthread_selfABI0, 0, 0, 0, 0, 0)) -} - -func pthread_get_stacksize_np(thread pthread_t) size_t { - return size_t(call5(pthread_get_stacksize_npABI0, uintptr(thread), 0, 0, 0, 0)) -} - -func pthread_attr_getstacksize(attr *pthread_attr_t, stacksize *size_t) int32 { - return int32(call5(pthread_attr_getstacksizeABI0, uintptr(unsafe.Pointer(attr)), uintptr(unsafe.Pointer(stacksize)), 0, 0, 0)) -} - -func pthread_attr_setstacksize(attr *pthread_attr_t, size size_t) int32 { - return int32(call5(pthread_attr_setstacksizeABI0, uintptr(unsafe.Pointer(attr)), uintptr(size), 0, 0, 0)) -} - -func pthread_attr_destroy(attr *pthread_attr_t) int32 { - return int32(call5(pthread_attr_destroyABI0, uintptr(unsafe.Pointer(attr)), 0, 0, 0, 0)) -} - -func pthread_mutex_lock(mutex *pthread_mutex_t) int32 { - return int32(call5(pthread_mutex_lockABI0, uintptr(unsafe.Pointer(mutex)), 0, 0, 0, 0)) -} - -func pthread_mutex_unlock(mutex *pthread_mutex_t) int32 { - return int32(call5(pthread_mutex_unlockABI0, uintptr(unsafe.Pointer(mutex)), 0, 0, 0, 0)) -} - -func pthread_cond_broadcast(cond *pthread_cond_t) int32 { - return int32(call5(pthread_cond_broadcastABI0, uintptr(unsafe.Pointer(cond)), 0, 0, 0, 0)) -} - -func pthread_setspecific(key pthread_key_t, value unsafe.Pointer) int32 { - return int32(call5(pthread_setspecificABI0, uintptr(key), uintptr(value), 0, 0, 0)) -} - -//go:linkname _malloc _malloc -var _malloc uintptr -var mallocABI0 = uintptr(unsafe.Pointer(&_malloc)) - -//go:linkname _free _free -var _free uintptr -var freeABI0 = uintptr(unsafe.Pointer(&_free)) - -//go:linkname _setenv _setenv -var _setenv uintptr -var setenvABI0 = uintptr(unsafe.Pointer(&_setenv)) - -//go:linkname _unsetenv _unsetenv -var _unsetenv uintptr -var unsetenvABI0 = uintptr(unsafe.Pointer(&_unsetenv)) - -//go:linkname _sigfillset _sigfillset -var _sigfillset uintptr -var sigfillsetABI0 = uintptr(unsafe.Pointer(&_sigfillset)) - -//go:linkname _nanosleep _nanosleep -var _nanosleep uintptr -var nanosleepABI0 = uintptr(unsafe.Pointer(&_nanosleep)) - -//go:linkname _abort _abort -var _abort uintptr -var abortABI0 = uintptr(unsafe.Pointer(&_abort)) - -//go:linkname _pthread_attr_init _pthread_attr_init -var _pthread_attr_init uintptr -var pthread_attr_initABI0 = uintptr(unsafe.Pointer(&_pthread_attr_init)) - -//go:linkname _pthread_create _pthread_create -var _pthread_create uintptr -var pthread_createABI0 = uintptr(unsafe.Pointer(&_pthread_create)) - -//go:linkname _pthread_detach _pthread_detach -var _pthread_detach uintptr -var pthread_detachABI0 = uintptr(unsafe.Pointer(&_pthread_detach)) - -//go:linkname _pthread_sigmask _pthread_sigmask -var _pthread_sigmask uintptr -var pthread_sigmaskABI0 = uintptr(unsafe.Pointer(&_pthread_sigmask)) - -//go:linkname _pthread_self _pthread_self -var _pthread_self uintptr -var pthread_selfABI0 = uintptr(unsafe.Pointer(&_pthread_self)) - -//go:linkname _pthread_get_stacksize_np _pthread_get_stacksize_np -var _pthread_get_stacksize_np uintptr -var pthread_get_stacksize_npABI0 = uintptr(unsafe.Pointer(&_pthread_get_stacksize_np)) - -//go:linkname _pthread_attr_getstacksize _pthread_attr_getstacksize -var _pthread_attr_getstacksize uintptr -var pthread_attr_getstacksizeABI0 = uintptr(unsafe.Pointer(&_pthread_attr_getstacksize)) - -//go:linkname _pthread_attr_setstacksize _pthread_attr_setstacksize -var _pthread_attr_setstacksize uintptr -var pthread_attr_setstacksizeABI0 = uintptr(unsafe.Pointer(&_pthread_attr_setstacksize)) - -//go:linkname _pthread_attr_destroy _pthread_attr_destroy -var _pthread_attr_destroy uintptr -var pthread_attr_destroyABI0 = uintptr(unsafe.Pointer(&_pthread_attr_destroy)) - -//go:linkname _pthread_mutex_lock _pthread_mutex_lock -var _pthread_mutex_lock uintptr -var pthread_mutex_lockABI0 = uintptr(unsafe.Pointer(&_pthread_mutex_lock)) - -//go:linkname _pthread_mutex_unlock _pthread_mutex_unlock -var _pthread_mutex_unlock uintptr -var pthread_mutex_unlockABI0 = uintptr(unsafe.Pointer(&_pthread_mutex_unlock)) - -//go:linkname _pthread_cond_broadcast _pthread_cond_broadcast -var _pthread_cond_broadcast uintptr -var pthread_cond_broadcastABI0 = uintptr(unsafe.Pointer(&_pthread_cond_broadcast)) - -//go:linkname _pthread_setspecific _pthread_setspecific -var _pthread_setspecific uintptr -var pthread_setspecificABI0 = uintptr(unsafe.Pointer(&_pthread_setspecific)) diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols_darwin.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols_darwin.go deleted file mode 100644 index 54aaa46285c86..0000000000000 --- a/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols_darwin.go +++ /dev/null @@ -1,29 +0,0 @@ -// Code generated by 'go generate' with gen.go. DO NOT EDIT. - -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2022 The Ebitengine Authors - -//go:build !cgo - -package fakecgo - -//go:cgo_import_dynamic purego_malloc malloc "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_free free "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_setenv setenv "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_unsetenv unsetenv "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_sigfillset sigfillset "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_nanosleep nanosleep "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_abort abort "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_pthread_attr_init pthread_attr_init "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_pthread_create pthread_create "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_pthread_detach pthread_detach "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_pthread_sigmask pthread_sigmask "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_pthread_self pthread_self "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_pthread_get_stacksize_np pthread_get_stacksize_np "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_pthread_attr_getstacksize pthread_attr_getstacksize "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_pthread_attr_setstacksize pthread_attr_setstacksize "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_pthread_attr_destroy pthread_attr_destroy "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_pthread_mutex_lock pthread_mutex_lock "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_pthread_mutex_unlock pthread_mutex_unlock "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_pthread_cond_broadcast pthread_cond_broadcast "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_pthread_setspecific pthread_setspecific "/usr/lib/libSystem.B.dylib" diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols_freebsd.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols_freebsd.go deleted file mode 100644 index 81538119799f5..0000000000000 --- a/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols_freebsd.go +++ /dev/null @@ -1,29 +0,0 @@ -// Code generated by 'go generate' with gen.go. DO NOT EDIT. - -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2022 The Ebitengine Authors - -//go:build !cgo - -package fakecgo - -//go:cgo_import_dynamic purego_malloc malloc "libc.so.7" -//go:cgo_import_dynamic purego_free free "libc.so.7" -//go:cgo_import_dynamic purego_setenv setenv "libc.so.7" -//go:cgo_import_dynamic purego_unsetenv unsetenv "libc.so.7" -//go:cgo_import_dynamic purego_sigfillset sigfillset "libc.so.7" -//go:cgo_import_dynamic purego_nanosleep nanosleep "libc.so.7" -//go:cgo_import_dynamic purego_abort abort "libc.so.7" -//go:cgo_import_dynamic purego_pthread_attr_init pthread_attr_init "libpthread.so" -//go:cgo_import_dynamic purego_pthread_create pthread_create "libpthread.so" -//go:cgo_import_dynamic purego_pthread_detach pthread_detach "libpthread.so" -//go:cgo_import_dynamic purego_pthread_sigmask pthread_sigmask "libpthread.so" -//go:cgo_import_dynamic purego_pthread_self pthread_self "libpthread.so" -//go:cgo_import_dynamic purego_pthread_get_stacksize_np pthread_get_stacksize_np "libpthread.so" -//go:cgo_import_dynamic purego_pthread_attr_getstacksize pthread_attr_getstacksize "libpthread.so" -//go:cgo_import_dynamic purego_pthread_attr_setstacksize pthread_attr_setstacksize "libpthread.so" -//go:cgo_import_dynamic purego_pthread_attr_destroy pthread_attr_destroy "libpthread.so" -//go:cgo_import_dynamic purego_pthread_mutex_lock pthread_mutex_lock "libpthread.so" -//go:cgo_import_dynamic purego_pthread_mutex_unlock pthread_mutex_unlock "libpthread.so" -//go:cgo_import_dynamic purego_pthread_cond_broadcast pthread_cond_broadcast "libpthread.so" -//go:cgo_import_dynamic purego_pthread_setspecific pthread_setspecific "libpthread.so" diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols_linux.go b/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols_linux.go deleted file mode 100644 index 180057d0156d8..0000000000000 --- a/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols_linux.go +++ /dev/null @@ -1,29 +0,0 @@ -// Code generated by 'go generate' with gen.go. DO NOT EDIT. - -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2022 The Ebitengine Authors - -//go:build !cgo - -package fakecgo - -//go:cgo_import_dynamic purego_malloc malloc "libc.so.6" -//go:cgo_import_dynamic purego_free free "libc.so.6" -//go:cgo_import_dynamic purego_setenv setenv "libc.so.6" -//go:cgo_import_dynamic purego_unsetenv unsetenv "libc.so.6" -//go:cgo_import_dynamic purego_sigfillset sigfillset "libc.so.6" -//go:cgo_import_dynamic purego_nanosleep nanosleep "libc.so.6" -//go:cgo_import_dynamic purego_abort abort "libc.so.6" -//go:cgo_import_dynamic purego_pthread_attr_init pthread_attr_init "libpthread.so.0" -//go:cgo_import_dynamic purego_pthread_create pthread_create "libpthread.so.0" -//go:cgo_import_dynamic purego_pthread_detach pthread_detach "libpthread.so.0" -//go:cgo_import_dynamic purego_pthread_sigmask pthread_sigmask "libpthread.so.0" -//go:cgo_import_dynamic purego_pthread_self pthread_self "libpthread.so.0" -//go:cgo_import_dynamic purego_pthread_get_stacksize_np pthread_get_stacksize_np "libpthread.so.0" -//go:cgo_import_dynamic purego_pthread_attr_getstacksize pthread_attr_getstacksize "libpthread.so.0" -//go:cgo_import_dynamic purego_pthread_attr_setstacksize pthread_attr_setstacksize "libpthread.so.0" -//go:cgo_import_dynamic purego_pthread_attr_destroy pthread_attr_destroy "libpthread.so.0" -//go:cgo_import_dynamic purego_pthread_mutex_lock pthread_mutex_lock "libpthread.so.0" -//go:cgo_import_dynamic purego_pthread_mutex_unlock pthread_mutex_unlock "libpthread.so.0" -//go:cgo_import_dynamic purego_pthread_cond_broadcast pthread_cond_broadcast "libpthread.so.0" -//go:cgo_import_dynamic purego_pthread_setspecific pthread_setspecific "libpthread.so.0" diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_amd64.s b/vendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_amd64.s deleted file mode 100644 index c9a3cc09eb318..0000000000000 --- a/vendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_amd64.s +++ /dev/null @@ -1,104 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2022 The Ebitengine Authors - -//go:build !cgo && (darwin || linux || freebsd) - -/* -trampoline for emulating required C functions for cgo in go (see cgo.go) -(we convert cdecl calling convention to go and vice-versa) - -Since we're called from go and call into C we can cheat a bit with the calling conventions: - - in go all the registers are caller saved - - in C we have a couple of callee saved registers - -=> we can use BX, R12, R13, R14, R15 instead of the stack - -C Calling convention cdecl used here (we only need integer args): -1. arg: DI -2. arg: SI -3. arg: DX -4. arg: CX -5. arg: R8 -6. arg: R9 -We don't need floats with these functions -> AX=0 -return value will be in AX -*/ -#include "textflag.h" -#include "go_asm.h" - -// these trampolines map the gcc ABI to Go ABI and then calls into the Go equivalent functions. - -TEXT x_cgo_init_trampoline(SB), NOSPLIT, $16 - MOVQ DI, AX - MOVQ SI, BX - MOVQ ·x_cgo_init_call(SB), DX - MOVQ (DX), CX - CALL CX - RET - -TEXT x_cgo_thread_start_trampoline(SB), NOSPLIT, $8 - MOVQ DI, AX - MOVQ ·x_cgo_thread_start_call(SB), DX - MOVQ (DX), CX - CALL CX - RET - -TEXT x_cgo_setenv_trampoline(SB), NOSPLIT, $8 - MOVQ DI, AX - MOVQ ·x_cgo_setenv_call(SB), DX - MOVQ (DX), CX - CALL CX - RET - -TEXT x_cgo_unsetenv_trampoline(SB), NOSPLIT, $8 - MOVQ DI, AX - MOVQ ·x_cgo_unsetenv_call(SB), DX - MOVQ (DX), CX - CALL CX - RET - -TEXT x_cgo_notify_runtime_init_done_trampoline(SB), NOSPLIT, $0 - CALL ·x_cgo_notify_runtime_init_done(SB) - RET - -TEXT x_cgo_bindm_trampoline(SB), NOSPLIT, $0 - CALL ·x_cgo_bindm(SB) - RET - -// func setg_trampoline(setg uintptr, g uintptr) -TEXT ·setg_trampoline(SB), NOSPLIT, $0-16 - MOVQ G+8(FP), DI - MOVQ setg+0(FP), BX - XORL AX, AX - CALL BX - RET - -TEXT threadentry_trampoline(SB), NOSPLIT, $16 - MOVQ DI, AX - MOVQ ·threadentry_call(SB), DX - MOVQ (DX), CX - CALL CX - RET - -TEXT ·call5(SB), NOSPLIT, $0-56 - MOVQ fn+0(FP), BX - MOVQ a1+8(FP), DI - MOVQ a2+16(FP), SI - MOVQ a3+24(FP), DX - MOVQ a4+32(FP), CX - MOVQ a5+40(FP), R8 - - XORL AX, AX // no floats - - PUSHQ BP // save BP - MOVQ SP, BP // save SP inside BP bc BP is callee-saved - SUBQ $16, SP // allocate space for alignment - ANDQ $-16, SP // align on 16 bytes for SSE - - CALL BX - - MOVQ BP, SP // get SP back - POPQ BP // restore BP - - MOVQ AX, ret+48(FP) - RET diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_arm64.s b/vendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_arm64.s deleted file mode 100644 index 9dbdbc0139db4..0000000000000 --- a/vendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_arm64.s +++ /dev/null @@ -1,72 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2022 The Ebitengine Authors - -//go:build !cgo && (darwin || freebsd || linux) - -#include "textflag.h" -#include "go_asm.h" - -// these trampolines map the gcc ABI to Go ABI and then calls into the Go equivalent functions. - -TEXT x_cgo_init_trampoline(SB), NOSPLIT, $0-0 - MOVD R0, 8(RSP) - MOVD R1, 16(RSP) - MOVD ·x_cgo_init_call(SB), R26 - MOVD (R26), R2 - CALL (R2) - RET - -TEXT x_cgo_thread_start_trampoline(SB), NOSPLIT, $0-0 - MOVD R0, 8(RSP) - MOVD ·x_cgo_thread_start_call(SB), R26 - MOVD (R26), R2 - CALL (R2) - RET - -TEXT x_cgo_setenv_trampoline(SB), NOSPLIT, $0-0 - MOVD R0, 8(RSP) - MOVD ·x_cgo_setenv_call(SB), R26 - MOVD (R26), R2 - CALL (R2) - RET - -TEXT x_cgo_unsetenv_trampoline(SB), NOSPLIT, $0-0 - MOVD R0, 8(RSP) - MOVD ·x_cgo_unsetenv_call(SB), R26 - MOVD (R26), R2 - CALL (R2) - RET - -TEXT x_cgo_notify_runtime_init_done_trampoline(SB), NOSPLIT, $0-0 - CALL ·x_cgo_notify_runtime_init_done(SB) - RET - -TEXT x_cgo_bindm_trampoline(SB), NOSPLIT, $0 - CALL ·x_cgo_bindm(SB) - RET - -// func setg_trampoline(setg uintptr, g uintptr) -TEXT ·setg_trampoline(SB), NOSPLIT, $0-16 - MOVD G+8(FP), R0 - MOVD setg+0(FP), R1 - CALL R1 - RET - -TEXT threadentry_trampoline(SB), NOSPLIT, $0-0 - MOVD R0, 8(RSP) - MOVD ·threadentry_call(SB), R26 - MOVD (R26), R2 - CALL (R2) - MOVD $0, R0 // TODO: get the return value from threadentry - RET - -TEXT ·call5(SB), NOSPLIT, $0-0 - MOVD fn+0(FP), R6 - MOVD a1+8(FP), R0 - MOVD a2+16(FP), R1 - MOVD a3+24(FP), R2 - MOVD a4+32(FP), R3 - MOVD a5+40(FP), R4 - CALL R6 - MOVD R0, ret+48(FP) - RET diff --git a/vendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_stubs.s b/vendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_stubs.s deleted file mode 100644 index a65b2012c1b40..0000000000000 --- a/vendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_stubs.s +++ /dev/null @@ -1,90 +0,0 @@ -// Code generated by 'go generate' with gen.go. DO NOT EDIT. - -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2022 The Ebitengine Authors - -//go:build !cgo && (darwin || freebsd || linux) - -#include "textflag.h" - -// these stubs are here because it is not possible to go:linkname directly the C functions on darwin arm64 - -TEXT _malloc(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_malloc(SB) - RET - -TEXT _free(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_free(SB) - RET - -TEXT _setenv(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_setenv(SB) - RET - -TEXT _unsetenv(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_unsetenv(SB) - RET - -TEXT _sigfillset(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_sigfillset(SB) - RET - -TEXT _nanosleep(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_nanosleep(SB) - RET - -TEXT _abort(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_abort(SB) - RET - -TEXT _pthread_attr_init(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_pthread_attr_init(SB) - RET - -TEXT _pthread_create(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_pthread_create(SB) - RET - -TEXT _pthread_detach(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_pthread_detach(SB) - RET - -TEXT _pthread_sigmask(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_pthread_sigmask(SB) - RET - -TEXT _pthread_self(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_pthread_self(SB) - RET - -TEXT _pthread_get_stacksize_np(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_pthread_get_stacksize_np(SB) - RET - -TEXT _pthread_attr_getstacksize(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_pthread_attr_getstacksize(SB) - RET - -TEXT _pthread_attr_setstacksize(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_pthread_attr_setstacksize(SB) - RET - -TEXT _pthread_attr_destroy(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_pthread_attr_destroy(SB) - RET - -TEXT _pthread_mutex_lock(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_pthread_mutex_lock(SB) - RET - -TEXT _pthread_mutex_unlock(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_pthread_mutex_unlock(SB) - RET - -TEXT _pthread_cond_broadcast(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_pthread_cond_broadcast(SB) - RET - -TEXT _pthread_setspecific(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_pthread_setspecific(SB) - RET diff --git a/vendor/github.com/ebitengine/purego/internal/strings/strings.go b/vendor/github.com/ebitengine/purego/internal/strings/strings.go deleted file mode 100644 index 5b0d252255477..0000000000000 --- a/vendor/github.com/ebitengine/purego/internal/strings/strings.go +++ /dev/null @@ -1,40 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2022 The Ebitengine Authors - -package strings - -import ( - "unsafe" -) - -// hasSuffix tests whether the string s ends with suffix. -func hasSuffix(s, suffix string) bool { - return len(s) >= len(suffix) && s[len(s)-len(suffix):] == suffix -} - -// CString converts a go string to *byte that can be passed to C code. -func CString(name string) *byte { - if hasSuffix(name, "\x00") { - return &(*(*[]byte)(unsafe.Pointer(&name)))[0] - } - b := make([]byte, len(name)+1) - copy(b, name) - return &b[0] -} - -// GoString copies a null-terminated char* to a Go string. -func GoString(c uintptr) string { - // We take the address and then dereference it to trick go vet from creating a possible misuse of unsafe.Pointer - ptr := *(*unsafe.Pointer)(unsafe.Pointer(&c)) - if ptr == nil { - return "" - } - var length int - for { - if *(*byte)(unsafe.Add(ptr, uintptr(length))) == '\x00' { - break - } - length++ - } - return string(unsafe.Slice((*byte)(ptr), length)) -} diff --git a/vendor/github.com/ebitengine/purego/is_ios.go b/vendor/github.com/ebitengine/purego/is_ios.go deleted file mode 100644 index ed31da9782401..0000000000000 --- a/vendor/github.com/ebitengine/purego/is_ios.go +++ /dev/null @@ -1,13 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2022 The Ebitengine Authors - -//go:build !cgo - -package purego - -// if you are getting this error it means that you have -// CGO_ENABLED=0 while trying to build for ios. -// purego does not support this mode yet. -// the fix is to set CGO_ENABLED=1 which will require -// a C compiler. -var _ = _PUREGO_REQUIRES_CGO_ON_IOS diff --git a/vendor/github.com/ebitengine/purego/nocgo.go b/vendor/github.com/ebitengine/purego/nocgo.go deleted file mode 100644 index 5b989ea814e70..0000000000000 --- a/vendor/github.com/ebitengine/purego/nocgo.go +++ /dev/null @@ -1,25 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2022 The Ebitengine Authors - -//go:build !cgo && (darwin || freebsd || linux) - -package purego - -// if CGO_ENABLED=0 import fakecgo to setup the Cgo runtime correctly. -// This is required since some frameworks need TLS setup the C way which Go doesn't do. -// We currently don't support ios in fakecgo mode so force Cgo or fail -// -// The way that the Cgo runtime (runtime/cgo) works is by setting some variables found -// in runtime with non-null GCC compiled functions. The variables that are replaced are -// var ( -// iscgo bool // in runtime/cgo.go -// _cgo_init unsafe.Pointer // in runtime/cgo.go -// _cgo_thread_start unsafe.Pointer // in runtime/cgo.go -// _cgo_notify_runtime_init_done unsafe.Pointer // in runtime/cgo.go -// _cgo_setenv unsafe.Pointer // in runtime/env_posix.go -// _cgo_unsetenv unsafe.Pointer // in runtime/env_posix.go -// ) -// importing fakecgo will set these (using //go:linkname) with functions written -// entirely in Go (except for some assembly trampolines to change GCC ABI to Go ABI). -// Doing so makes it possible to build applications that call into C without CGO_ENABLED=1. -import _ "github.com/ebitengine/purego/internal/fakecgo" diff --git a/vendor/github.com/ebitengine/purego/struct_amd64.go b/vendor/github.com/ebitengine/purego/struct_amd64.go deleted file mode 100644 index 06a82dd8c5b4b..0000000000000 --- a/vendor/github.com/ebitengine/purego/struct_amd64.go +++ /dev/null @@ -1,272 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2024 The Ebitengine Authors - -package purego - -import ( - "math" - "reflect" - "unsafe" -) - -func getStruct(outType reflect.Type, syscall syscall15Args) (v reflect.Value) { - outSize := outType.Size() - switch { - case outSize == 0: - return reflect.New(outType).Elem() - case outSize <= 8: - if isAllFloats(outType) { - // 2 float32s or 1 float64s are return in the float register - return reflect.NewAt(outType, unsafe.Pointer(&struct{ a uintptr }{syscall.f1})).Elem() - } - // up to 8 bytes is returned in RAX - return reflect.NewAt(outType, unsafe.Pointer(&struct{ a uintptr }{syscall.a1})).Elem() - case outSize <= 16: - r1, r2 := syscall.a1, syscall.a2 - if isAllFloats(outType) { - r1 = syscall.f1 - r2 = syscall.f2 - } else { - // check first 8 bytes if it's floats - hasFirstFloat := false - f1 := outType.Field(0).Type - if f1.Kind() == reflect.Float64 || f1.Kind() == reflect.Float32 && outType.Field(1).Type.Kind() == reflect.Float32 { - r1 = syscall.f1 - hasFirstFloat = true - } - - // find index of the field that starts the second 8 bytes - var i int - for i = 0; i < outType.NumField(); i++ { - if outType.Field(i).Offset == 8 { - break - } - } - - // check last 8 bytes if they are floats - f1 = outType.Field(i).Type - if f1.Kind() == reflect.Float64 || f1.Kind() == reflect.Float32 && i+1 == outType.NumField() { - r2 = syscall.f1 - } else if hasFirstFloat { - // if the first field was a float then that means the second integer field - // comes from the first integer register - r2 = syscall.a1 - } - } - return reflect.NewAt(outType, unsafe.Pointer(&struct{ a, b uintptr }{r1, r2})).Elem() - default: - // create struct from the Go pointer created above - // weird pointer dereference to circumvent go vet - return reflect.NewAt(outType, *(*unsafe.Pointer)(unsafe.Pointer(&syscall.a1))).Elem() - } -} - -func isAllFloats(ty reflect.Type) bool { - for i := 0; i < ty.NumField(); i++ { - f := ty.Field(i) - switch f.Type.Kind() { - case reflect.Float64, reflect.Float32: - default: - return false - } - } - return true -} - -// https://refspecs.linuxbase.org/elf/x86_64-abi-0.99.pdf -// https://gitlab.com/x86-psABIs/x86-64-ABI -// Class determines where the 8 byte value goes. -// Higher value classes win over lower value classes -const ( - _NO_CLASS = 0b0000 - _SSE = 0b0001 - _X87 = 0b0011 // long double not used in Go - _INTEGER = 0b0111 - _MEMORY = 0b1111 -) - -func addStruct(v reflect.Value, numInts, numFloats, numStack *int, addInt, addFloat, addStack func(uintptr), keepAlive []interface{}) []interface{} { - if v.Type().Size() == 0 { - return keepAlive - } - - // if greater than 64 bytes place on stack - if v.Type().Size() > 8*8 { - placeStack(v, addStack) - return keepAlive - } - var ( - savedNumFloats = *numFloats - savedNumInts = *numInts - savedNumStack = *numStack - ) - placeOnStack := postMerger(v.Type()) || !tryPlaceRegister(v, addFloat, addInt) - if placeOnStack { - // reset any values placed in registers - *numFloats = savedNumFloats - *numInts = savedNumInts - *numStack = savedNumStack - placeStack(v, addStack) - } - return keepAlive -} - -func postMerger(t reflect.Type) bool { - // (c) If the size of the aggregate exceeds two eightbytes and the first eight- byte isn’t SSE or any other - // eightbyte isn’t SSEUP, the whole argument is passed in memory. - if t.Kind() != reflect.Struct { - return false - } - if t.Size() <= 2*8 { - return false - } - first := getFirst(t).Kind() - if first != reflect.Float32 && first != reflect.Float64 { - return false - } - return true -} - -func getFirst(t reflect.Type) reflect.Type { - first := t.Field(0).Type - if first.Kind() == reflect.Struct { - return getFirst(first) - } - return first -} - -func tryPlaceRegister(v reflect.Value, addFloat func(uintptr), addInt func(uintptr)) (ok bool) { - ok = true - var val uint64 - var shift byte // # of bits to shift - var flushed bool - class := _NO_CLASS - flushIfNeeded := func() { - if flushed { - return - } - flushed = true - if class == _SSE { - addFloat(uintptr(val)) - } else { - addInt(uintptr(val)) - } - val = 0 - shift = 0 - class = _NO_CLASS - } - var place func(v reflect.Value) - place = func(v reflect.Value) { - var numFields int - if v.Kind() == reflect.Struct { - numFields = v.Type().NumField() - } else { - numFields = v.Type().Len() - } - - for i := 0; i < numFields; i++ { - flushed = false - var f reflect.Value - if v.Kind() == reflect.Struct { - f = v.Field(i) - } else { - f = v.Index(i) - } - switch f.Kind() { - case reflect.Struct: - place(f) - case reflect.Bool: - if f.Bool() { - val |= 1 - } - shift += 8 - class |= _INTEGER - case reflect.Pointer: - ok = false - return - case reflect.Int8: - val |= uint64(f.Int()&0xFF) << shift - shift += 8 - class |= _INTEGER - case reflect.Int16: - val |= uint64(f.Int()&0xFFFF) << shift - shift += 16 - class |= _INTEGER - case reflect.Int32: - val |= uint64(f.Int()&0xFFFF_FFFF) << shift - shift += 32 - class |= _INTEGER - case reflect.Int64: - val = uint64(f.Int()) - shift = 64 - class = _INTEGER - case reflect.Uint8: - val |= f.Uint() << shift - shift += 8 - class |= _INTEGER - case reflect.Uint16: - val |= f.Uint() << shift - shift += 16 - class |= _INTEGER - case reflect.Uint32: - val |= f.Uint() << shift - shift += 32 - class |= _INTEGER - case reflect.Uint64: - val = f.Uint() - shift = 64 - class = _INTEGER - case reflect.Float32: - val |= uint64(math.Float32bits(float32(f.Float()))) << shift - shift += 32 - class |= _SSE - case reflect.Float64: - if v.Type().Size() > 16 { - ok = false - return - } - val = uint64(math.Float64bits(f.Float())) - shift = 64 - class = _SSE - case reflect.Array: - place(f) - default: - panic("purego: unsupported kind " + f.Kind().String()) - } - - if shift == 64 { - flushIfNeeded() - } else if shift > 64 { - // Should never happen, but may if we forget to reset shift after flush (or forget to flush), - // better fall apart here, than corrupt arguments. - panic("purego: tryPlaceRegisters shift > 64") - } - } - } - - place(v) - flushIfNeeded() - return ok -} - -func placeStack(v reflect.Value, addStack func(uintptr)) { - for i := 0; i < v.Type().NumField(); i++ { - f := v.Field(i) - switch f.Kind() { - case reflect.Pointer: - addStack(f.Pointer()) - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - addStack(uintptr(f.Int())) - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - addStack(uintptr(f.Uint())) - case reflect.Float32: - addStack(uintptr(math.Float32bits(float32(f.Float())))) - case reflect.Float64: - addStack(uintptr(math.Float64bits(f.Float()))) - case reflect.Struct: - placeStack(f, addStack) - default: - panic("purego: unsupported kind " + f.Kind().String()) - } - } -} diff --git a/vendor/github.com/ebitengine/purego/struct_arm64.go b/vendor/github.com/ebitengine/purego/struct_arm64.go deleted file mode 100644 index 11c36bd6e47b9..0000000000000 --- a/vendor/github.com/ebitengine/purego/struct_arm64.go +++ /dev/null @@ -1,274 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2024 The Ebitengine Authors - -package purego - -import ( - "math" - "reflect" - "unsafe" -) - -func getStruct(outType reflect.Type, syscall syscall15Args) (v reflect.Value) { - outSize := outType.Size() - switch { - case outSize == 0: - return reflect.New(outType).Elem() - case outSize <= 8: - r1 := syscall.a1 - if isAllFloats, numFields := isAllSameFloat(outType); isAllFloats { - r1 = syscall.f1 - if numFields == 2 { - r1 = syscall.f2<<32 | syscall.f1 - } - } - return reflect.NewAt(outType, unsafe.Pointer(&struct{ a uintptr }{r1})).Elem() - case outSize <= 16: - r1, r2 := syscall.a1, syscall.a2 - if isAllFloats, numFields := isAllSameFloat(outType); isAllFloats { - switch numFields { - case 4: - r1 = syscall.f2<<32 | syscall.f1 - r2 = syscall.f4<<32 | syscall.f3 - case 3: - r1 = syscall.f2<<32 | syscall.f1 - r2 = syscall.f3 - case 2: - r1 = syscall.f1 - r2 = syscall.f2 - default: - panic("unreachable") - } - } - return reflect.NewAt(outType, unsafe.Pointer(&struct{ a, b uintptr }{r1, r2})).Elem() - default: - if isAllFloats, numFields := isAllSameFloat(outType); isAllFloats && numFields <= 4 { - switch numFields { - case 4: - return reflect.NewAt(outType, unsafe.Pointer(&struct{ a, b, c, d uintptr }{syscall.f1, syscall.f2, syscall.f3, syscall.f4})).Elem() - case 3: - return reflect.NewAt(outType, unsafe.Pointer(&struct{ a, b, c uintptr }{syscall.f1, syscall.f2, syscall.f3})).Elem() - default: - panic("unreachable") - } - } - // create struct from the Go pointer created in arm64_r8 - // weird pointer dereference to circumvent go vet - return reflect.NewAt(outType, *(*unsafe.Pointer)(unsafe.Pointer(&syscall.arm64_r8))).Elem() - } -} - -// https://github.com/ARM-software/abi-aa/blob/main/sysvabi64/sysvabi64.rst -const ( - _NO_CLASS = 0b00 - _FLOAT = 0b01 - _INT = 0b11 -) - -func addStruct(v reflect.Value, numInts, numFloats, numStack *int, addInt, addFloat, addStack func(uintptr), keepAlive []interface{}) []interface{} { - if v.Type().Size() == 0 { - return keepAlive - } - - if hva, hfa, size := isHVA(v.Type()), isHFA(v.Type()), v.Type().Size(); hva || hfa || size <= 16 { - // if this doesn't fit entirely in registers then - // each element goes onto the stack - if hfa && *numFloats+v.NumField() > numOfFloats { - *numFloats = numOfFloats - } else if hva && *numInts+v.NumField() > numOfIntegerRegisters() { - *numInts = numOfIntegerRegisters() - } - - placeRegisters(v, addFloat, addInt) - } else { - keepAlive = placeStack(v, keepAlive, addInt) - } - return keepAlive // the struct was allocated so don't panic -} - -func placeRegisters(v reflect.Value, addFloat func(uintptr), addInt func(uintptr)) { - var val uint64 - var shift byte - var flushed bool - class := _NO_CLASS - var place func(v reflect.Value) - place = func(v reflect.Value) { - var numFields int - if v.Kind() == reflect.Struct { - numFields = v.Type().NumField() - } else { - numFields = v.Type().Len() - } - for k := 0; k < numFields; k++ { - flushed = false - var f reflect.Value - if v.Kind() == reflect.Struct { - f = v.Field(k) - } else { - f = v.Index(k) - } - if shift >= 64 { - shift = 0 - flushed = true - if class == _FLOAT { - addFloat(uintptr(val)) - } else { - addInt(uintptr(val)) - } - } - switch f.Type().Kind() { - case reflect.Struct: - place(f) - case reflect.Bool: - if f.Bool() { - val |= 1 - } - shift += 8 - class |= _INT - case reflect.Uint8: - val |= f.Uint() << shift - shift += 8 - class |= _INT - case reflect.Uint16: - val |= f.Uint() << shift - shift += 16 - class |= _INT - case reflect.Uint32: - val |= f.Uint() << shift - shift += 32 - class |= _INT - case reflect.Uint64: - addInt(uintptr(f.Uint())) - shift = 0 - flushed = true - case reflect.Int8: - val |= uint64(f.Int()&0xFF) << shift - shift += 8 - class |= _INT - case reflect.Int16: - val |= uint64(f.Int()&0xFFFF) << shift - shift += 16 - class |= _INT - case reflect.Int32: - val |= uint64(f.Int()&0xFFFF_FFFF) << shift - shift += 32 - class |= _INT - case reflect.Int64: - addInt(uintptr(f.Int())) - shift = 0 - flushed = true - case reflect.Float32: - if class == _FLOAT { - addFloat(uintptr(val)) - val = 0 - shift = 0 - } - val |= uint64(math.Float32bits(float32(f.Float()))) << shift - shift += 32 - class |= _FLOAT - case reflect.Float64: - addFloat(uintptr(math.Float64bits(float64(f.Float())))) - shift = 0 - flushed = true - case reflect.Array: - place(f) - default: - panic("purego: unsupported kind " + f.Kind().String()) - } - } - } - place(v) - if !flushed { - if class == _FLOAT { - addFloat(uintptr(val)) - } else { - addInt(uintptr(val)) - } - } -} - -func placeStack(v reflect.Value, keepAlive []interface{}, addInt func(uintptr)) []interface{} { - // Struct is too big to be placed in registers. - // Copy to heap and place the pointer in register - ptrStruct := reflect.New(v.Type()) - ptrStruct.Elem().Set(v) - ptr := ptrStruct.Elem().Addr().UnsafePointer() - keepAlive = append(keepAlive, ptr) - addInt(uintptr(ptr)) - return keepAlive -} - -// isHFA reports a Homogeneous Floating-point Aggregate (HFA) which is a Fundamental Data Type that is a -// Floating-Point type and at most four uniquely addressable members (5.9.5.1 in [Arm64 Calling Convention]). -// This type of struct will be placed more compactly than the individual fields. -// -// [Arm64 Calling Convention]: https://github.com/ARM-software/abi-aa/blob/main/sysvabi64/sysvabi64.rst -func isHFA(t reflect.Type) bool { - // round up struct size to nearest 8 see section B.4 - structSize := roundUpTo8(t.Size()) - if structSize == 0 || t.NumField() > 4 { - return false - } - first := t.Field(0) - switch first.Type.Kind() { - case reflect.Float32, reflect.Float64: - firstKind := first.Type.Kind() - for i := 0; i < t.NumField(); i++ { - if t.Field(i).Type.Kind() != firstKind { - return false - } - } - return true - case reflect.Array: - switch first.Type.Elem().Kind() { - case reflect.Float32, reflect.Float64: - return true - default: - return false - } - case reflect.Struct: - for i := 0; i < first.Type.NumField(); i++ { - if !isHFA(first.Type) { - return false - } - } - return true - default: - return false - } -} - -// isHVA reports a Homogeneous Aggregate with a Fundamental Data Type that is a Short-Vector type -// and at most four uniquely addressable members (5.9.5.2 in [Arm64 Calling Convention]). -// A short vector is a machine type that is composed of repeated instances of one fundamental integral or -// floating-point type. It may be 8 or 16 bytes in total size (5.4 in [Arm64 Calling Convention]). -// This type of struct will be placed more compactly than the individual fields. -// -// [Arm64 Calling Convention]: https://github.com/ARM-software/abi-aa/blob/main/sysvabi64/sysvabi64.rst -func isHVA(t reflect.Type) bool { - // round up struct size to nearest 8 see section B.4 - structSize := roundUpTo8(t.Size()) - if structSize == 0 || (structSize != 8 && structSize != 16) { - return false - } - first := t.Field(0) - switch first.Type.Kind() { - case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Int8, reflect.Int16, reflect.Int32: - firstKind := first.Type.Kind() - for i := 0; i < t.NumField(); i++ { - if t.Field(i).Type.Kind() != firstKind { - return false - } - } - return true - case reflect.Array: - switch first.Type.Elem().Kind() { - case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Int8, reflect.Int16, reflect.Int32: - return true - default: - return false - } - default: - return false - } -} diff --git a/vendor/github.com/ebitengine/purego/struct_other.go b/vendor/github.com/ebitengine/purego/struct_other.go deleted file mode 100644 index 9d42adac898e5..0000000000000 --- a/vendor/github.com/ebitengine/purego/struct_other.go +++ /dev/null @@ -1,16 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2024 The Ebitengine Authors - -//go:build !amd64 && !arm64 - -package purego - -import "reflect" - -func addStruct(v reflect.Value, numInts, numFloats, numStack *int, addInt, addFloat, addStack func(uintptr), keepAlive []interface{}) []interface{} { - panic("purego: struct arguments are not supported") -} - -func getStruct(outType reflect.Type, syscall syscall15Args) (v reflect.Value) { - panic("purego: struct returns are not supported") -} diff --git a/vendor/github.com/ebitengine/purego/sys_amd64.s b/vendor/github.com/ebitengine/purego/sys_amd64.s deleted file mode 100644 index cabde1a584e98..0000000000000 --- a/vendor/github.com/ebitengine/purego/sys_amd64.s +++ /dev/null @@ -1,164 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2022 The Ebitengine Authors - -//go:build darwin || freebsd || linux - -#include "textflag.h" -#include "abi_amd64.h" -#include "go_asm.h" -#include "funcdata.h" - -#define STACK_SIZE 80 -#define PTR_ADDRESS (STACK_SIZE - 8) - -// syscall15X calls a function in libc on behalf of the syscall package. -// syscall15X takes a pointer to a struct like: -// struct { -// fn uintptr -// a1 uintptr -// a2 uintptr -// a3 uintptr -// a4 uintptr -// a5 uintptr -// a6 uintptr -// a7 uintptr -// a8 uintptr -// a9 uintptr -// a10 uintptr -// a11 uintptr -// a12 uintptr -// a13 uintptr -// a14 uintptr -// a15 uintptr -// r1 uintptr -// r2 uintptr -// err uintptr -// } -// syscall15X must be called on the g0 stack with the -// C calling convention (use libcCall). -GLOBL ·syscall15XABI0(SB), NOPTR|RODATA, $8 -DATA ·syscall15XABI0(SB)/8, $syscall15X(SB) -TEXT syscall15X(SB), NOSPLIT|NOFRAME, $0 - PUSHQ BP - MOVQ SP, BP - SUBQ $STACK_SIZE, SP - MOVQ DI, PTR_ADDRESS(BP) // save the pointer - MOVQ DI, R11 - - MOVQ syscall15Args_f1(R11), X0 // f1 - MOVQ syscall15Args_f2(R11), X1 // f2 - MOVQ syscall15Args_f3(R11), X2 // f3 - MOVQ syscall15Args_f4(R11), X3 // f4 - MOVQ syscall15Args_f5(R11), X4 // f5 - MOVQ syscall15Args_f6(R11), X5 // f6 - MOVQ syscall15Args_f7(R11), X6 // f7 - MOVQ syscall15Args_f8(R11), X7 // f8 - - MOVQ syscall15Args_a1(R11), DI // a1 - MOVQ syscall15Args_a2(R11), SI // a2 - MOVQ syscall15Args_a3(R11), DX // a3 - MOVQ syscall15Args_a4(R11), CX // a4 - MOVQ syscall15Args_a5(R11), R8 // a5 - MOVQ syscall15Args_a6(R11), R9 // a6 - - // push the remaining paramters onto the stack - MOVQ syscall15Args_a7(R11), R12 - MOVQ R12, 0(SP) // push a7 - MOVQ syscall15Args_a8(R11), R12 - MOVQ R12, 8(SP) // push a8 - MOVQ syscall15Args_a9(R11), R12 - MOVQ R12, 16(SP) // push a9 - MOVQ syscall15Args_a10(R11), R12 - MOVQ R12, 24(SP) // push a10 - MOVQ syscall15Args_a11(R11), R12 - MOVQ R12, 32(SP) // push a11 - MOVQ syscall15Args_a12(R11), R12 - MOVQ R12, 40(SP) // push a12 - MOVQ syscall15Args_a13(R11), R12 - MOVQ R12, 48(SP) // push a13 - MOVQ syscall15Args_a14(R11), R12 - MOVQ R12, 56(SP) // push a14 - MOVQ syscall15Args_a15(R11), R12 - MOVQ R12, 64(SP) // push a15 - XORL AX, AX // vararg: say "no float args" - - MOVQ syscall15Args_fn(R11), R10 // fn - CALL R10 - - MOVQ PTR_ADDRESS(BP), DI // get the pointer back - MOVQ AX, syscall15Args_a1(DI) // r1 - MOVQ DX, syscall15Args_a2(DI) // r3 - MOVQ X0, syscall15Args_f1(DI) // f1 - MOVQ X1, syscall15Args_f2(DI) // f2 - - XORL AX, AX // no error (it's ignored anyway) - ADDQ $STACK_SIZE, SP - MOVQ BP, SP - POPQ BP - RET - -TEXT callbackasm1(SB), NOSPLIT|NOFRAME, $0 - MOVQ 0(SP), AX // save the return address to calculate the cb index - MOVQ 8(SP), R10 // get the return SP so that we can align register args with stack args - ADDQ $8, SP // remove return address from stack, we are not returning to callbackasm, but to its caller. - - // make space for first six int and 8 float arguments below the frame - ADJSP $14*8, SP - MOVSD X0, (1*8)(SP) - MOVSD X1, (2*8)(SP) - MOVSD X2, (3*8)(SP) - MOVSD X3, (4*8)(SP) - MOVSD X4, (5*8)(SP) - MOVSD X5, (6*8)(SP) - MOVSD X6, (7*8)(SP) - MOVSD X7, (8*8)(SP) - MOVQ DI, (9*8)(SP) - MOVQ SI, (10*8)(SP) - MOVQ DX, (11*8)(SP) - MOVQ CX, (12*8)(SP) - MOVQ R8, (13*8)(SP) - MOVQ R9, (14*8)(SP) - LEAQ 8(SP), R8 // R8 = address of args vector - - PUSHQ R10 // push the stack pointer below registers - - // Switch from the host ABI to the Go ABI. - PUSH_REGS_HOST_TO_ABI0() - - // determine index into runtime·cbs table - MOVQ $callbackasm(SB), DX - SUBQ DX, AX - MOVQ $0, DX - MOVQ $5, CX // divide by 5 because each call instruction in ·callbacks is 5 bytes long - DIVL CX - SUBQ $1, AX // subtract 1 because return PC is to the next slot - - // Create a struct callbackArgs on our stack to be passed as - // the "frame" to cgocallback and on to callbackWrap. - // $24 to make enough room for the arguments to runtime.cgocallback - SUBQ $(24+callbackArgs__size), SP - MOVQ AX, (24+callbackArgs_index)(SP) // callback index - MOVQ R8, (24+callbackArgs_args)(SP) // address of args vector - MOVQ $0, (24+callbackArgs_result)(SP) // result - LEAQ 24(SP), AX // take the address of callbackArgs - - // Call cgocallback, which will call callbackWrap(frame). - MOVQ ·callbackWrap_call(SB), DI // Get the ABIInternal function pointer - MOVQ (DI), DI // without by using a closure. - MOVQ AX, SI // frame (address of callbackArgs) - MOVQ $0, CX // context - - CALL crosscall2(SB) // runtime.cgocallback(fn, frame, ctxt uintptr) - - // Get callback result. - MOVQ (24+callbackArgs_result)(SP), AX - ADDQ $(24+callbackArgs__size), SP // remove callbackArgs struct - - POP_REGS_HOST_TO_ABI0() - - POPQ R10 // get the SP back - ADJSP $-14*8, SP // remove arguments - - MOVQ R10, 0(SP) - - RET diff --git a/vendor/github.com/ebitengine/purego/sys_arm64.s b/vendor/github.com/ebitengine/purego/sys_arm64.s deleted file mode 100644 index a68fdb99ba7aa..0000000000000 --- a/vendor/github.com/ebitengine/purego/sys_arm64.s +++ /dev/null @@ -1,92 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2022 The Ebitengine Authors - -//go:build darwin || freebsd || linux || windows - -#include "textflag.h" -#include "go_asm.h" -#include "funcdata.h" - -#define STACK_SIZE 64 -#define PTR_ADDRESS (STACK_SIZE - 8) - -// syscall15X calls a function in libc on behalf of the syscall package. -// syscall15X takes a pointer to a struct like: -// struct { -// fn uintptr -// a1 uintptr -// a2 uintptr -// a3 uintptr -// a4 uintptr -// a5 uintptr -// a6 uintptr -// a7 uintptr -// a8 uintptr -// a9 uintptr -// a10 uintptr -// a11 uintptr -// a12 uintptr -// a13 uintptr -// a14 uintptr -// a15 uintptr -// r1 uintptr -// r2 uintptr -// err uintptr -// } -// syscall15X must be called on the g0 stack with the -// C calling convention (use libcCall). -GLOBL ·syscall15XABI0(SB), NOPTR|RODATA, $8 -DATA ·syscall15XABI0(SB)/8, $syscall15X(SB) -TEXT syscall15X(SB), NOSPLIT, $0 - SUB $STACK_SIZE, RSP // push structure pointer - MOVD R0, PTR_ADDRESS(RSP) - MOVD R0, R9 - - FMOVD syscall15Args_f1(R9), F0 // f1 - FMOVD syscall15Args_f2(R9), F1 // f2 - FMOVD syscall15Args_f3(R9), F2 // f3 - FMOVD syscall15Args_f4(R9), F3 // f4 - FMOVD syscall15Args_f5(R9), F4 // f5 - FMOVD syscall15Args_f6(R9), F5 // f6 - FMOVD syscall15Args_f7(R9), F6 // f7 - FMOVD syscall15Args_f8(R9), F7 // f8 - - MOVD syscall15Args_a1(R9), R0 // a1 - MOVD syscall15Args_a2(R9), R1 // a2 - MOVD syscall15Args_a3(R9), R2 // a3 - MOVD syscall15Args_a4(R9), R3 // a4 - MOVD syscall15Args_a5(R9), R4 // a5 - MOVD syscall15Args_a6(R9), R5 // a6 - MOVD syscall15Args_a7(R9), R6 // a7 - MOVD syscall15Args_a8(R9), R7 // a8 - MOVD syscall15Args_arm64_r8(R9), R8 // r8 - - MOVD syscall15Args_a9(R9), R10 - MOVD R10, 0(RSP) // push a9 onto stack - MOVD syscall15Args_a10(R9), R10 - MOVD R10, 8(RSP) // push a10 onto stack - MOVD syscall15Args_a11(R9), R10 - MOVD R10, 16(RSP) // push a11 onto stack - MOVD syscall15Args_a12(R9), R10 - MOVD R10, 24(RSP) // push a12 onto stack - MOVD syscall15Args_a13(R9), R10 - MOVD R10, 32(RSP) // push a13 onto stack - MOVD syscall15Args_a14(R9), R10 - MOVD R10, 40(RSP) // push a14 onto stack - MOVD syscall15Args_a15(R9), R10 - MOVD R10, 48(RSP) // push a15 onto stack - - MOVD syscall15Args_fn(R9), R10 // fn - BL (R10) - - MOVD PTR_ADDRESS(RSP), R2 // pop structure pointer - ADD $STACK_SIZE, RSP - - MOVD R0, syscall15Args_a1(R2) // save r1 - MOVD R1, syscall15Args_a2(R2) // save r3 - FMOVD F0, syscall15Args_f1(R2) // save f0 - FMOVD F1, syscall15Args_f2(R2) // save f1 - FMOVD F2, syscall15Args_f3(R2) // save f2 - FMOVD F3, syscall15Args_f4(R2) // save f3 - - RET diff --git a/vendor/github.com/ebitengine/purego/sys_unix_arm64.s b/vendor/github.com/ebitengine/purego/sys_unix_arm64.s deleted file mode 100644 index 6da06b4d18826..0000000000000 --- a/vendor/github.com/ebitengine/purego/sys_unix_arm64.s +++ /dev/null @@ -1,70 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2023 The Ebitengine Authors - -//go:build darwin || freebsd || linux - -#include "textflag.h" -#include "go_asm.h" -#include "funcdata.h" -#include "abi_arm64.h" - -TEXT callbackasm1(SB), NOSPLIT|NOFRAME, $0 - NO_LOCAL_POINTERS - - // On entry, the trampoline in zcallback_darwin_arm64.s left - // the callback index in R12 (which is volatile in the C ABI). - - // Save callback register arguments R0-R7 and F0-F7. - // We do this at the top of the frame so they're contiguous with stack arguments. - SUB $(16*8), RSP, R14 - FSTPD (F0, F1), (0*8)(R14) - FSTPD (F2, F3), (2*8)(R14) - FSTPD (F4, F5), (4*8)(R14) - FSTPD (F6, F7), (6*8)(R14) - STP (R0, R1), (8*8)(R14) - STP (R2, R3), (10*8)(R14) - STP (R4, R5), (12*8)(R14) - STP (R6, R7), (14*8)(R14) - - // Adjust SP by frame size. - SUB $(26*8), RSP - - // It is important to save R27 because the go assembler - // uses it for move instructions for a variable. - // This line: - // MOVD ·callbackWrap_call(SB), R0 - // Creates the instructions: - // ADRP 14335(PC), R27 - // MOVD 388(27), R0 - // R27 is a callee saved register so we are responsible - // for ensuring its value doesn't change. So save it and - // restore it at the end of this function. - // R30 is the link register. crosscall2 doesn't save it - // so it's saved here. - STP (R27, R30), 0(RSP) - - // Create a struct callbackArgs on our stack. - MOVD $(callbackArgs__size)(RSP), R13 - MOVD R12, callbackArgs_index(R13) // callback index - MOVD R14, callbackArgs_args(R13) // address of args vector - MOVD ZR, callbackArgs_result(R13) // result - - // Move parameters into registers - // Get the ABIInternal function pointer - // without by using a closure. - MOVD ·callbackWrap_call(SB), R0 - MOVD (R0), R0 // fn unsafe.Pointer - MOVD R13, R1 // frame (&callbackArgs{...}) - MOVD $0, R3 // ctxt uintptr - - BL crosscall2(SB) - - // Get callback result. - MOVD $(callbackArgs__size)(RSP), R13 - MOVD callbackArgs_result(R13), R0 - - // Restore LR and R27 - LDP 0(RSP), (R27, R30) - ADD $(26*8), RSP - - RET diff --git a/vendor/github.com/ebitengine/purego/syscall.go b/vendor/github.com/ebitengine/purego/syscall.go deleted file mode 100644 index c30688dda130e..0000000000000 --- a/vendor/github.com/ebitengine/purego/syscall.go +++ /dev/null @@ -1,53 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2022 The Ebitengine Authors - -//go:build darwin || freebsd || linux || windows - -package purego - -// CDecl marks a function as being called using the __cdecl calling convention as defined in -// the [MSDocs] when passed to NewCallback. It must be the first argument to the function. -// This is only useful on 386 Windows, but it is safe to use on other platforms. -// -// [MSDocs]: https://learn.microsoft.com/en-us/cpp/cpp/cdecl?view=msvc-170 -type CDecl struct{} - -const ( - maxArgs = 15 - numOfFloats = 8 // arm64 and amd64 both have 8 float registers -) - -type syscall15Args struct { - fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15 uintptr - f1, f2, f3, f4, f5, f6, f7, f8 uintptr - arm64_r8 uintptr -} - -// SyscallN takes fn, a C function pointer and a list of arguments as uintptr. -// There is an internal maximum number of arguments that SyscallN can take. It panics -// when the maximum is exceeded. It returns the result and the libc error code if there is one. -// -// NOTE: SyscallN does not properly call functions that have both integer and float parameters. -// See discussion comment https://github.com/ebiten/purego/pull/1#issuecomment-1128057607 -// for an explanation of why that is. -// -// On amd64, if there are more than 8 floats the 9th and so on will be placed incorrectly on the -// stack. -// -// The pragma go:nosplit is not needed at this function declaration because it uses go:uintptrescapes -// which forces all the objects that the uintptrs point to onto the heap where a stack split won't affect -// their memory location. -// -//go:uintptrescapes -func SyscallN(fn uintptr, args ...uintptr) (r1, r2, err uintptr) { - if fn == 0 { - panic("purego: fn is nil") - } - if len(args) > maxArgs { - panic("purego: too many arguments to SyscallN") - } - // add padding so there is no out-of-bounds slicing - var tmp [maxArgs]uintptr - copy(tmp[:], args) - return syscall_syscall15X(fn, tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5], tmp[6], tmp[7], tmp[8], tmp[9], tmp[10], tmp[11], tmp[12], tmp[13], tmp[14]) -} diff --git a/vendor/github.com/ebitengine/purego/syscall_cgo_linux.go b/vendor/github.com/ebitengine/purego/syscall_cgo_linux.go deleted file mode 100644 index 36ee14e3b732a..0000000000000 --- a/vendor/github.com/ebitengine/purego/syscall_cgo_linux.go +++ /dev/null @@ -1,21 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2022 The Ebitengine Authors - -//go:build cgo && !(amd64 || arm64) - -package purego - -import ( - "github.com/ebitengine/purego/internal/cgo" -) - -var syscall15XABI0 = uintptr(cgo.Syscall15XABI0) - -//go:nosplit -func syscall_syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15 uintptr) (r1, r2, err uintptr) { - return cgo.Syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) -} - -func NewCallback(_ interface{}) uintptr { - panic("purego: NewCallback on Linux is only supported on amd64/arm64") -} diff --git a/vendor/github.com/ebitengine/purego/syscall_sysv.go b/vendor/github.com/ebitengine/purego/syscall_sysv.go deleted file mode 100644 index cce171c8f609a..0000000000000 --- a/vendor/github.com/ebitengine/purego/syscall_sysv.go +++ /dev/null @@ -1,223 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2022 The Ebitengine Authors - -//go:build darwin || freebsd || (linux && (amd64 || arm64)) - -package purego - -import ( - "reflect" - "runtime" - "sync" - "unsafe" -) - -var syscall15XABI0 uintptr - -//go:nosplit -func syscall_syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15 uintptr) (r1, r2, err uintptr) { - args := syscall15Args{ - fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, - a1, a2, a3, a4, a5, a6, a7, a8, - 0, - } - runtime_cgocall(syscall15XABI0, unsafe.Pointer(&args)) - return args.a1, args.a2, 0 -} - -// NewCallback converts a Go function to a function pointer conforming to the C calling convention. -// This is useful when interoperating with C code requiring callbacks. The argument is expected to be a -// function with zero or one uintptr-sized result. The function must not have arguments with size larger than the size -// of uintptr. Only a limited number of callbacks may be created in a single Go process, and any memory allocated -// for these callbacks is never released. At least 2000 callbacks can always be created. Although this function -// provides similar functionality to windows.NewCallback it is distinct. -func NewCallback(fn interface{}) uintptr { - ty := reflect.TypeOf(fn) - for i := 0; i < ty.NumIn(); i++ { - in := ty.In(i) - if !in.AssignableTo(reflect.TypeOf(CDecl{})) { - continue - } - if i != 0 { - panic("purego: CDecl must be the first argument") - } - } - return compileCallback(fn) -} - -// maxCb is the maximum number of callbacks -// only increase this if you have added more to the callbackasm function -const maxCB = 2000 - -var cbs struct { - lock sync.Mutex - numFn int // the number of functions currently in cbs.funcs - funcs [maxCB]reflect.Value // the saved callbacks -} - -type callbackArgs struct { - index uintptr - // args points to the argument block. - // - // The structure of the arguments goes - // float registers followed by the - // integer registers followed by the stack. - // - // This variable is treated as a continuous - // block of memory containing all of the arguments - // for this callback. - args unsafe.Pointer - // Below are out-args from callbackWrap - result uintptr -} - -func compileCallback(fn interface{}) uintptr { - val := reflect.ValueOf(fn) - if val.Kind() != reflect.Func { - panic("purego: the type must be a function but was not") - } - if val.IsNil() { - panic("purego: function must not be nil") - } - ty := val.Type() - for i := 0; i < ty.NumIn(); i++ { - in := ty.In(i) - switch in.Kind() { - case reflect.Struct: - if i == 0 && in.AssignableTo(reflect.TypeOf(CDecl{})) { - continue - } - fallthrough - case reflect.Interface, reflect.Func, reflect.Slice, - reflect.Chan, reflect.Complex64, reflect.Complex128, - reflect.String, reflect.Map, reflect.Invalid: - panic("purego: unsupported argument type: " + in.Kind().String()) - } - } -output: - switch { - case ty.NumOut() == 1: - switch ty.Out(0).Kind() { - case reflect.Pointer, reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, - reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr, - reflect.Bool, reflect.UnsafePointer: - break output - } - panic("purego: unsupported return type: " + ty.String()) - case ty.NumOut() > 1: - panic("purego: callbacks can only have one return") - } - cbs.lock.Lock() - defer cbs.lock.Unlock() - if cbs.numFn >= maxCB { - panic("purego: the maximum number of callbacks has been reached") - } - cbs.funcs[cbs.numFn] = val - cbs.numFn++ - return callbackasmAddr(cbs.numFn - 1) -} - -const ptrSize = unsafe.Sizeof((*int)(nil)) - -const callbackMaxFrame = 64 * ptrSize - -// callbackasm is implemented in zcallback_GOOS_GOARCH.s -// -//go:linkname __callbackasm callbackasm -var __callbackasm byte -var callbackasmABI0 = uintptr(unsafe.Pointer(&__callbackasm)) - -// callbackWrap_call allows the calling of the ABIInternal wrapper -// which is required for runtime.cgocallback without the -// tag which is only allowed in the runtime. -// This closure is used inside sys_darwin_GOARCH.s -var callbackWrap_call = callbackWrap - -// callbackWrap is called by assembly code which determines which Go function to call. -// This function takes the arguments and passes them to the Go function and returns the result. -func callbackWrap(a *callbackArgs) { - cbs.lock.Lock() - fn := cbs.funcs[a.index] - cbs.lock.Unlock() - fnType := fn.Type() - args := make([]reflect.Value, fnType.NumIn()) - frame := (*[callbackMaxFrame]uintptr)(a.args) - var floatsN int // floatsN represents the number of float arguments processed - var intsN int // intsN represents the number of integer arguments processed - // stack points to the index into frame of the current stack element. - // The stack begins after the float and integer registers. - stack := numOfIntegerRegisters() + numOfFloats - for i := range args { - var pos int - switch fnType.In(i).Kind() { - case reflect.Float32, reflect.Float64: - if floatsN >= numOfFloats { - pos = stack - stack++ - } else { - pos = floatsN - } - floatsN++ - case reflect.Struct: - // This is the CDecl field - args[i] = reflect.Zero(fnType.In(i)) - continue - default: - - if intsN >= numOfIntegerRegisters() { - pos = stack - stack++ - } else { - // the integers begin after the floats in frame - pos = intsN + numOfFloats - } - intsN++ - } - args[i] = reflect.NewAt(fnType.In(i), unsafe.Pointer(&frame[pos])).Elem() - } - ret := fn.Call(args) - if len(ret) > 0 { - switch k := ret[0].Kind(); k { - case reflect.Uint, reflect.Uint64, reflect.Uint32, reflect.Uint16, reflect.Uint8, reflect.Uintptr: - a.result = uintptr(ret[0].Uint()) - case reflect.Int, reflect.Int64, reflect.Int32, reflect.Int16, reflect.Int8: - a.result = uintptr(ret[0].Int()) - case reflect.Bool: - if ret[0].Bool() { - a.result = 1 - } else { - a.result = 0 - } - case reflect.Pointer: - a.result = ret[0].Pointer() - case reflect.UnsafePointer: - a.result = ret[0].Pointer() - default: - panic("purego: unsupported kind: " + k.String()) - } - } -} - -// callbackasmAddr returns address of runtime.callbackasm -// function adjusted by i. -// On x86 and amd64, runtime.callbackasm is a series of CALL instructions, -// and we want callback to arrive at -// correspondent call instruction instead of start of -// runtime.callbackasm. -// On ARM, runtime.callbackasm is a series of mov and branch instructions. -// R12 is loaded with the callback index. Each entry is two instructions, -// hence 8 bytes. -func callbackasmAddr(i int) uintptr { - var entrySize int - switch runtime.GOARCH { - default: - panic("purego: unsupported architecture") - case "386", "amd64": - entrySize = 5 - case "arm", "arm64": - // On ARM and ARM64, each entry is a MOV instruction - // followed by a branch instruction - entrySize = 8 - } - return callbackasmABI0 + uintptr(i*entrySize) -} diff --git a/vendor/github.com/ebitengine/purego/syscall_windows.go b/vendor/github.com/ebitengine/purego/syscall_windows.go deleted file mode 100644 index 5fbfcabfdc930..0000000000000 --- a/vendor/github.com/ebitengine/purego/syscall_windows.go +++ /dev/null @@ -1,46 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2022 The Ebitengine Authors - -package purego - -import ( - "reflect" - "syscall" -) - -var syscall15XABI0 uintptr - -func syscall_syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15 uintptr) (r1, r2, err uintptr) { - r1, r2, errno := syscall.Syscall15(fn, 15, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) - return r1, r2, uintptr(errno) -} - -// NewCallback converts a Go function to a function pointer conforming to the stdcall calling convention. -// This is useful when interoperating with Windows code requiring callbacks. The argument is expected to be a -// function with one uintptr-sized result. The function must not have arguments with size larger than the -// size of uintptr. Only a limited number of callbacks may be created in a single Go process, and any memory -// allocated for these callbacks is never released. Between NewCallback and NewCallbackCDecl, at least 1024 -// callbacks can always be created. Although this function is similiar to the darwin version it may act -// differently. -func NewCallback(fn interface{}) uintptr { - isCDecl := false - ty := reflect.TypeOf(fn) - for i := 0; i < ty.NumIn(); i++ { - in := ty.In(i) - if !in.AssignableTo(reflect.TypeOf(CDecl{})) { - continue - } - if i != 0 { - panic("purego: CDecl must be the first argument") - } - isCDecl = true - } - if isCDecl { - return syscall.NewCallbackCDecl(fn) - } - return syscall.NewCallback(fn) -} - -func loadSymbol(handle uintptr, name string) (uintptr, error) { - return syscall.GetProcAddress(syscall.Handle(handle), name) -} diff --git a/vendor/github.com/ebitengine/purego/zcallback_amd64.s b/vendor/github.com/ebitengine/purego/zcallback_amd64.s deleted file mode 100644 index 6a778bfcad177..0000000000000 --- a/vendor/github.com/ebitengine/purego/zcallback_amd64.s +++ /dev/null @@ -1,2014 +0,0 @@ -// Code generated by wincallback.go using 'go generate'. DO NOT EDIT. - -//go:build darwin || freebsd || linux - -// runtime·callbackasm is called by external code to -// execute Go implemented callback function. It is not -// called from the start, instead runtime·compilecallback -// always returns address into runtime·callbackasm offset -// appropriately so different callbacks start with different -// CALL instruction in runtime·callbackasm. This determines -// which Go callback function is executed later on. -#include "textflag.h" - -TEXT callbackasm(SB), NOSPLIT|NOFRAME, $0 - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) - CALL callbackasm1(SB) diff --git a/vendor/github.com/ebitengine/purego/zcallback_arm64.s b/vendor/github.com/ebitengine/purego/zcallback_arm64.s deleted file mode 100644 index c079b8038e377..0000000000000 --- a/vendor/github.com/ebitengine/purego/zcallback_arm64.s +++ /dev/null @@ -1,4014 +0,0 @@ -// Code generated by wincallback.go using 'go generate'. DO NOT EDIT. - -//go:build darwin || freebsd || linux - -// External code calls into callbackasm at an offset corresponding -// to the callback index. Callbackasm is a table of MOV and B instructions. -// The MOV instruction loads R12 with the callback index, and the -// B instruction branches to callbackasm1. -// callbackasm1 takes the callback index from R12 and -// indexes into an array that stores information about each callback. -// It then calls the Go implementation for that callback. -#include "textflag.h" - -TEXT callbackasm(SB), NOSPLIT|NOFRAME, $0 - MOVD $0, R12 - B callbackasm1(SB) - MOVD $1, R12 - B callbackasm1(SB) - MOVD $2, R12 - B callbackasm1(SB) - MOVD $3, R12 - B callbackasm1(SB) - MOVD $4, R12 - B callbackasm1(SB) - MOVD $5, R12 - B callbackasm1(SB) - MOVD $6, R12 - B callbackasm1(SB) - MOVD $7, R12 - B callbackasm1(SB) - MOVD $8, R12 - B callbackasm1(SB) - MOVD $9, R12 - B callbackasm1(SB) - MOVD $10, R12 - B callbackasm1(SB) - MOVD $11, R12 - B callbackasm1(SB) - MOVD $12, R12 - B callbackasm1(SB) - MOVD $13, R12 - B callbackasm1(SB) - MOVD $14, R12 - B callbackasm1(SB) - MOVD $15, R12 - B callbackasm1(SB) - MOVD $16, R12 - B callbackasm1(SB) - MOVD $17, R12 - B callbackasm1(SB) - MOVD $18, R12 - B callbackasm1(SB) - MOVD $19, R12 - B callbackasm1(SB) - MOVD $20, R12 - B callbackasm1(SB) - MOVD $21, R12 - B callbackasm1(SB) - MOVD $22, R12 - B callbackasm1(SB) - MOVD $23, R12 - B callbackasm1(SB) - MOVD $24, R12 - B callbackasm1(SB) - MOVD $25, R12 - B callbackasm1(SB) - MOVD $26, R12 - B callbackasm1(SB) - MOVD $27, R12 - B callbackasm1(SB) - MOVD $28, R12 - B callbackasm1(SB) - MOVD $29, R12 - B callbackasm1(SB) - MOVD $30, R12 - B callbackasm1(SB) - MOVD $31, R12 - B callbackasm1(SB) - MOVD $32, R12 - B callbackasm1(SB) - MOVD $33, R12 - B callbackasm1(SB) - MOVD $34, R12 - B callbackasm1(SB) - MOVD $35, R12 - B callbackasm1(SB) - MOVD $36, R12 - B callbackasm1(SB) - MOVD $37, R12 - B callbackasm1(SB) - MOVD $38, R12 - B callbackasm1(SB) - MOVD $39, R12 - B callbackasm1(SB) - MOVD $40, R12 - B callbackasm1(SB) - MOVD $41, R12 - B callbackasm1(SB) - MOVD $42, R12 - B callbackasm1(SB) - MOVD $43, R12 - B callbackasm1(SB) - MOVD $44, R12 - B callbackasm1(SB) - MOVD $45, R12 - B callbackasm1(SB) - MOVD $46, R12 - B callbackasm1(SB) - MOVD $47, R12 - B callbackasm1(SB) - MOVD $48, R12 - B callbackasm1(SB) - MOVD $49, R12 - B callbackasm1(SB) - MOVD $50, R12 - B callbackasm1(SB) - MOVD $51, R12 - B callbackasm1(SB) - MOVD $52, R12 - B callbackasm1(SB) - MOVD $53, R12 - B callbackasm1(SB) - MOVD $54, R12 - B callbackasm1(SB) - MOVD $55, R12 - B callbackasm1(SB) - MOVD $56, R12 - B callbackasm1(SB) - MOVD $57, R12 - B callbackasm1(SB) - MOVD $58, R12 - B callbackasm1(SB) - MOVD $59, R12 - B callbackasm1(SB) - MOVD $60, R12 - B callbackasm1(SB) - MOVD $61, R12 - B callbackasm1(SB) - MOVD $62, R12 - B callbackasm1(SB) - MOVD $63, R12 - B callbackasm1(SB) - MOVD $64, R12 - B callbackasm1(SB) - MOVD $65, R12 - B callbackasm1(SB) - MOVD $66, R12 - B callbackasm1(SB) - MOVD $67, R12 - B callbackasm1(SB) - MOVD $68, R12 - B callbackasm1(SB) - MOVD $69, R12 - B callbackasm1(SB) - MOVD $70, R12 - B callbackasm1(SB) - MOVD $71, R12 - B callbackasm1(SB) - MOVD $72, R12 - B callbackasm1(SB) - MOVD $73, R12 - B callbackasm1(SB) - MOVD $74, R12 - B callbackasm1(SB) - MOVD $75, R12 - B callbackasm1(SB) - MOVD $76, R12 - B callbackasm1(SB) - MOVD $77, R12 - B callbackasm1(SB) - MOVD $78, R12 - B callbackasm1(SB) - MOVD $79, R12 - B callbackasm1(SB) - MOVD $80, R12 - B callbackasm1(SB) - MOVD $81, R12 - B callbackasm1(SB) - MOVD $82, R12 - B callbackasm1(SB) - MOVD $83, R12 - B callbackasm1(SB) - MOVD $84, R12 - B callbackasm1(SB) - MOVD $85, R12 - B callbackasm1(SB) - MOVD $86, R12 - B callbackasm1(SB) - MOVD $87, R12 - B callbackasm1(SB) - MOVD $88, R12 - B callbackasm1(SB) - MOVD $89, R12 - B callbackasm1(SB) - MOVD $90, R12 - B callbackasm1(SB) - MOVD $91, R12 - B callbackasm1(SB) - MOVD $92, R12 - B callbackasm1(SB) - MOVD $93, R12 - B callbackasm1(SB) - MOVD $94, R12 - B callbackasm1(SB) - MOVD $95, R12 - B callbackasm1(SB) - MOVD $96, R12 - B callbackasm1(SB) - MOVD $97, R12 - B callbackasm1(SB) - MOVD $98, R12 - B callbackasm1(SB) - MOVD $99, R12 - B callbackasm1(SB) - MOVD $100, R12 - B callbackasm1(SB) - MOVD $101, R12 - B callbackasm1(SB) - MOVD $102, R12 - B callbackasm1(SB) - MOVD $103, R12 - B callbackasm1(SB) - MOVD $104, R12 - B callbackasm1(SB) - MOVD $105, R12 - B callbackasm1(SB) - MOVD $106, R12 - B callbackasm1(SB) - MOVD $107, R12 - B callbackasm1(SB) - MOVD $108, R12 - B callbackasm1(SB) - MOVD $109, R12 - B callbackasm1(SB) - MOVD $110, R12 - B callbackasm1(SB) - MOVD $111, R12 - B callbackasm1(SB) - MOVD $112, R12 - B callbackasm1(SB) - MOVD $113, R12 - B callbackasm1(SB) - MOVD $114, R12 - B callbackasm1(SB) - MOVD $115, R12 - B callbackasm1(SB) - MOVD $116, R12 - B callbackasm1(SB) - MOVD $117, R12 - B callbackasm1(SB) - MOVD $118, R12 - B callbackasm1(SB) - MOVD $119, R12 - B callbackasm1(SB) - MOVD $120, R12 - B callbackasm1(SB) - MOVD $121, R12 - B callbackasm1(SB) - MOVD $122, R12 - B callbackasm1(SB) - MOVD $123, R12 - B callbackasm1(SB) - MOVD $124, R12 - B callbackasm1(SB) - MOVD $125, R12 - B callbackasm1(SB) - MOVD $126, R12 - B callbackasm1(SB) - MOVD $127, R12 - B callbackasm1(SB) - MOVD $128, R12 - B callbackasm1(SB) - MOVD $129, R12 - B callbackasm1(SB) - MOVD $130, R12 - B callbackasm1(SB) - MOVD $131, R12 - B callbackasm1(SB) - MOVD $132, R12 - B callbackasm1(SB) - MOVD $133, R12 - B callbackasm1(SB) - MOVD $134, R12 - B callbackasm1(SB) - MOVD $135, R12 - B callbackasm1(SB) - MOVD $136, R12 - B callbackasm1(SB) - MOVD $137, R12 - B callbackasm1(SB) - MOVD $138, R12 - B callbackasm1(SB) - MOVD $139, R12 - B callbackasm1(SB) - MOVD $140, R12 - B callbackasm1(SB) - MOVD $141, R12 - B callbackasm1(SB) - MOVD $142, R12 - B callbackasm1(SB) - MOVD $143, R12 - B callbackasm1(SB) - MOVD $144, R12 - B callbackasm1(SB) - MOVD $145, R12 - B callbackasm1(SB) - MOVD $146, R12 - B callbackasm1(SB) - MOVD $147, R12 - B callbackasm1(SB) - MOVD $148, R12 - B callbackasm1(SB) - MOVD $149, R12 - B callbackasm1(SB) - MOVD $150, R12 - B callbackasm1(SB) - MOVD $151, R12 - B callbackasm1(SB) - MOVD $152, R12 - B callbackasm1(SB) - MOVD $153, R12 - B callbackasm1(SB) - MOVD $154, R12 - B callbackasm1(SB) - MOVD $155, R12 - B callbackasm1(SB) - MOVD $156, R12 - B callbackasm1(SB) - MOVD $157, R12 - B callbackasm1(SB) - MOVD $158, R12 - B callbackasm1(SB) - MOVD $159, R12 - B callbackasm1(SB) - MOVD $160, R12 - B callbackasm1(SB) - MOVD $161, R12 - B callbackasm1(SB) - MOVD $162, R12 - B callbackasm1(SB) - MOVD $163, R12 - B callbackasm1(SB) - MOVD $164, R12 - B callbackasm1(SB) - MOVD $165, R12 - B callbackasm1(SB) - MOVD $166, R12 - B callbackasm1(SB) - MOVD $167, R12 - B callbackasm1(SB) - MOVD $168, R12 - B callbackasm1(SB) - MOVD $169, R12 - B callbackasm1(SB) - MOVD $170, R12 - B callbackasm1(SB) - MOVD $171, R12 - B callbackasm1(SB) - MOVD $172, R12 - B callbackasm1(SB) - MOVD $173, R12 - B callbackasm1(SB) - MOVD $174, R12 - B callbackasm1(SB) - MOVD $175, R12 - B callbackasm1(SB) - MOVD $176, R12 - B callbackasm1(SB) - MOVD $177, R12 - B callbackasm1(SB) - MOVD $178, R12 - B callbackasm1(SB) - MOVD $179, R12 - B callbackasm1(SB) - MOVD $180, R12 - B callbackasm1(SB) - MOVD $181, R12 - B callbackasm1(SB) - MOVD $182, R12 - B callbackasm1(SB) - MOVD $183, R12 - B callbackasm1(SB) - MOVD $184, R12 - B callbackasm1(SB) - MOVD $185, R12 - B callbackasm1(SB) - MOVD $186, R12 - B callbackasm1(SB) - MOVD $187, R12 - B callbackasm1(SB) - MOVD $188, R12 - B callbackasm1(SB) - MOVD $189, R12 - B callbackasm1(SB) - MOVD $190, R12 - B callbackasm1(SB) - MOVD $191, R12 - B callbackasm1(SB) - MOVD $192, R12 - B callbackasm1(SB) - MOVD $193, R12 - B callbackasm1(SB) - MOVD $194, R12 - B callbackasm1(SB) - MOVD $195, R12 - B callbackasm1(SB) - MOVD $196, R12 - B callbackasm1(SB) - MOVD $197, R12 - B callbackasm1(SB) - MOVD $198, R12 - B callbackasm1(SB) - MOVD $199, R12 - B callbackasm1(SB) - MOVD $200, R12 - B callbackasm1(SB) - MOVD $201, R12 - B callbackasm1(SB) - MOVD $202, R12 - B callbackasm1(SB) - MOVD $203, R12 - B callbackasm1(SB) - MOVD $204, R12 - B callbackasm1(SB) - MOVD $205, R12 - B callbackasm1(SB) - MOVD $206, R12 - B callbackasm1(SB) - MOVD $207, R12 - B callbackasm1(SB) - MOVD $208, R12 - B callbackasm1(SB) - MOVD $209, R12 - B callbackasm1(SB) - MOVD $210, R12 - B callbackasm1(SB) - MOVD $211, R12 - B callbackasm1(SB) - MOVD $212, R12 - B callbackasm1(SB) - MOVD $213, R12 - B callbackasm1(SB) - MOVD $214, R12 - B callbackasm1(SB) - MOVD $215, R12 - B callbackasm1(SB) - MOVD $216, R12 - B callbackasm1(SB) - MOVD $217, R12 - B callbackasm1(SB) - MOVD $218, R12 - B callbackasm1(SB) - MOVD $219, R12 - B callbackasm1(SB) - MOVD $220, R12 - B callbackasm1(SB) - MOVD $221, R12 - B callbackasm1(SB) - MOVD $222, R12 - B callbackasm1(SB) - MOVD $223, R12 - B callbackasm1(SB) - MOVD $224, R12 - B callbackasm1(SB) - MOVD $225, R12 - B callbackasm1(SB) - MOVD $226, R12 - B callbackasm1(SB) - MOVD $227, R12 - B callbackasm1(SB) - MOVD $228, R12 - B callbackasm1(SB) - MOVD $229, R12 - B callbackasm1(SB) - MOVD $230, R12 - B callbackasm1(SB) - MOVD $231, R12 - B callbackasm1(SB) - MOVD $232, R12 - B callbackasm1(SB) - MOVD $233, R12 - B callbackasm1(SB) - MOVD $234, R12 - B callbackasm1(SB) - MOVD $235, R12 - B callbackasm1(SB) - MOVD $236, R12 - B callbackasm1(SB) - MOVD $237, R12 - B callbackasm1(SB) - MOVD $238, R12 - B callbackasm1(SB) - MOVD $239, R12 - B callbackasm1(SB) - MOVD $240, R12 - B callbackasm1(SB) - MOVD $241, R12 - B callbackasm1(SB) - MOVD $242, R12 - B callbackasm1(SB) - MOVD $243, R12 - B callbackasm1(SB) - MOVD $244, R12 - B callbackasm1(SB) - MOVD $245, R12 - B callbackasm1(SB) - MOVD $246, R12 - B callbackasm1(SB) - MOVD $247, R12 - B callbackasm1(SB) - MOVD $248, R12 - B callbackasm1(SB) - MOVD $249, R12 - B callbackasm1(SB) - MOVD $250, R12 - B callbackasm1(SB) - MOVD $251, R12 - B callbackasm1(SB) - MOVD $252, R12 - B callbackasm1(SB) - MOVD $253, R12 - B callbackasm1(SB) - MOVD $254, R12 - B callbackasm1(SB) - MOVD $255, R12 - B callbackasm1(SB) - MOVD $256, R12 - B callbackasm1(SB) - MOVD $257, R12 - B callbackasm1(SB) - MOVD $258, R12 - B callbackasm1(SB) - MOVD $259, R12 - B callbackasm1(SB) - MOVD $260, R12 - B callbackasm1(SB) - MOVD $261, R12 - B callbackasm1(SB) - MOVD $262, R12 - B callbackasm1(SB) - MOVD $263, R12 - B callbackasm1(SB) - MOVD $264, R12 - B callbackasm1(SB) - MOVD $265, R12 - B callbackasm1(SB) - MOVD $266, R12 - B callbackasm1(SB) - MOVD $267, R12 - B callbackasm1(SB) - MOVD $268, R12 - B callbackasm1(SB) - MOVD $269, R12 - B callbackasm1(SB) - MOVD $270, R12 - B callbackasm1(SB) - MOVD $271, R12 - B callbackasm1(SB) - MOVD $272, R12 - B callbackasm1(SB) - MOVD $273, R12 - B callbackasm1(SB) - MOVD $274, R12 - B callbackasm1(SB) - MOVD $275, R12 - B callbackasm1(SB) - MOVD $276, R12 - B callbackasm1(SB) - MOVD $277, R12 - B callbackasm1(SB) - MOVD $278, R12 - B callbackasm1(SB) - MOVD $279, R12 - B callbackasm1(SB) - MOVD $280, R12 - B callbackasm1(SB) - MOVD $281, R12 - B callbackasm1(SB) - MOVD $282, R12 - B callbackasm1(SB) - MOVD $283, R12 - B callbackasm1(SB) - MOVD $284, R12 - B callbackasm1(SB) - MOVD $285, R12 - B callbackasm1(SB) - MOVD $286, R12 - B callbackasm1(SB) - MOVD $287, R12 - B callbackasm1(SB) - MOVD $288, R12 - B callbackasm1(SB) - MOVD $289, R12 - B callbackasm1(SB) - MOVD $290, R12 - B callbackasm1(SB) - MOVD $291, R12 - B callbackasm1(SB) - MOVD $292, R12 - B callbackasm1(SB) - MOVD $293, R12 - B callbackasm1(SB) - MOVD $294, R12 - B callbackasm1(SB) - MOVD $295, R12 - B callbackasm1(SB) - MOVD $296, R12 - B callbackasm1(SB) - MOVD $297, R12 - B callbackasm1(SB) - MOVD $298, R12 - B callbackasm1(SB) - MOVD $299, R12 - B callbackasm1(SB) - MOVD $300, R12 - B callbackasm1(SB) - MOVD $301, R12 - B callbackasm1(SB) - MOVD $302, R12 - B callbackasm1(SB) - MOVD $303, R12 - B callbackasm1(SB) - MOVD $304, R12 - B callbackasm1(SB) - MOVD $305, R12 - B callbackasm1(SB) - MOVD $306, R12 - B callbackasm1(SB) - MOVD $307, R12 - B callbackasm1(SB) - MOVD $308, R12 - B callbackasm1(SB) - MOVD $309, R12 - B callbackasm1(SB) - MOVD $310, R12 - B callbackasm1(SB) - MOVD $311, R12 - B callbackasm1(SB) - MOVD $312, R12 - B callbackasm1(SB) - MOVD $313, R12 - B callbackasm1(SB) - MOVD $314, R12 - B callbackasm1(SB) - MOVD $315, R12 - B callbackasm1(SB) - MOVD $316, R12 - B callbackasm1(SB) - MOVD $317, R12 - B callbackasm1(SB) - MOVD $318, R12 - B callbackasm1(SB) - MOVD $319, R12 - B callbackasm1(SB) - MOVD $320, R12 - B callbackasm1(SB) - MOVD $321, R12 - B callbackasm1(SB) - MOVD $322, R12 - B callbackasm1(SB) - MOVD $323, R12 - B callbackasm1(SB) - MOVD $324, R12 - B callbackasm1(SB) - MOVD $325, R12 - B callbackasm1(SB) - MOVD $326, R12 - B callbackasm1(SB) - MOVD $327, R12 - B callbackasm1(SB) - MOVD $328, R12 - B callbackasm1(SB) - MOVD $329, R12 - B callbackasm1(SB) - MOVD $330, R12 - B callbackasm1(SB) - MOVD $331, R12 - B callbackasm1(SB) - MOVD $332, R12 - B callbackasm1(SB) - MOVD $333, R12 - B callbackasm1(SB) - MOVD $334, R12 - B callbackasm1(SB) - MOVD $335, R12 - B callbackasm1(SB) - MOVD $336, R12 - B callbackasm1(SB) - MOVD $337, R12 - B callbackasm1(SB) - MOVD $338, R12 - B callbackasm1(SB) - MOVD $339, R12 - B callbackasm1(SB) - MOVD $340, R12 - B callbackasm1(SB) - MOVD $341, R12 - B callbackasm1(SB) - MOVD $342, R12 - B callbackasm1(SB) - MOVD $343, R12 - B callbackasm1(SB) - MOVD $344, R12 - B callbackasm1(SB) - MOVD $345, R12 - B callbackasm1(SB) - MOVD $346, R12 - B callbackasm1(SB) - MOVD $347, R12 - B callbackasm1(SB) - MOVD $348, R12 - B callbackasm1(SB) - MOVD $349, R12 - B callbackasm1(SB) - MOVD $350, R12 - B callbackasm1(SB) - MOVD $351, R12 - B callbackasm1(SB) - MOVD $352, R12 - B callbackasm1(SB) - MOVD $353, R12 - B callbackasm1(SB) - MOVD $354, R12 - B callbackasm1(SB) - MOVD $355, R12 - B callbackasm1(SB) - MOVD $356, R12 - B callbackasm1(SB) - MOVD $357, R12 - B callbackasm1(SB) - MOVD $358, R12 - B callbackasm1(SB) - MOVD $359, R12 - B callbackasm1(SB) - MOVD $360, R12 - B callbackasm1(SB) - MOVD $361, R12 - B callbackasm1(SB) - MOVD $362, R12 - B callbackasm1(SB) - MOVD $363, R12 - B callbackasm1(SB) - MOVD $364, R12 - B callbackasm1(SB) - MOVD $365, R12 - B callbackasm1(SB) - MOVD $366, R12 - B callbackasm1(SB) - MOVD $367, R12 - B callbackasm1(SB) - MOVD $368, R12 - B callbackasm1(SB) - MOVD $369, R12 - B callbackasm1(SB) - MOVD $370, R12 - B callbackasm1(SB) - MOVD $371, R12 - B callbackasm1(SB) - MOVD $372, R12 - B callbackasm1(SB) - MOVD $373, R12 - B callbackasm1(SB) - MOVD $374, R12 - B callbackasm1(SB) - MOVD $375, R12 - B callbackasm1(SB) - MOVD $376, R12 - B callbackasm1(SB) - MOVD $377, R12 - B callbackasm1(SB) - MOVD $378, R12 - B callbackasm1(SB) - MOVD $379, R12 - B callbackasm1(SB) - MOVD $380, R12 - B callbackasm1(SB) - MOVD $381, R12 - B callbackasm1(SB) - MOVD $382, R12 - B callbackasm1(SB) - MOVD $383, R12 - B callbackasm1(SB) - MOVD $384, R12 - B callbackasm1(SB) - MOVD $385, R12 - B callbackasm1(SB) - MOVD $386, R12 - B callbackasm1(SB) - MOVD $387, R12 - B callbackasm1(SB) - MOVD $388, R12 - B callbackasm1(SB) - MOVD $389, R12 - B callbackasm1(SB) - MOVD $390, R12 - B callbackasm1(SB) - MOVD $391, R12 - B callbackasm1(SB) - MOVD $392, R12 - B callbackasm1(SB) - MOVD $393, R12 - B callbackasm1(SB) - MOVD $394, R12 - B callbackasm1(SB) - MOVD $395, R12 - B callbackasm1(SB) - MOVD $396, R12 - B callbackasm1(SB) - MOVD $397, R12 - B callbackasm1(SB) - MOVD $398, R12 - B callbackasm1(SB) - MOVD $399, R12 - B callbackasm1(SB) - MOVD $400, R12 - B callbackasm1(SB) - MOVD $401, R12 - B callbackasm1(SB) - MOVD $402, R12 - B callbackasm1(SB) - MOVD $403, R12 - B callbackasm1(SB) - MOVD $404, R12 - B callbackasm1(SB) - MOVD $405, R12 - B callbackasm1(SB) - MOVD $406, R12 - B callbackasm1(SB) - MOVD $407, R12 - B callbackasm1(SB) - MOVD $408, R12 - B callbackasm1(SB) - MOVD $409, R12 - B callbackasm1(SB) - MOVD $410, R12 - B callbackasm1(SB) - MOVD $411, R12 - B callbackasm1(SB) - MOVD $412, R12 - B callbackasm1(SB) - MOVD $413, R12 - B callbackasm1(SB) - MOVD $414, R12 - B callbackasm1(SB) - MOVD $415, R12 - B callbackasm1(SB) - MOVD $416, R12 - B callbackasm1(SB) - MOVD $417, R12 - B callbackasm1(SB) - MOVD $418, R12 - B callbackasm1(SB) - MOVD $419, R12 - B callbackasm1(SB) - MOVD $420, R12 - B callbackasm1(SB) - MOVD $421, R12 - B callbackasm1(SB) - MOVD $422, R12 - B callbackasm1(SB) - MOVD $423, R12 - B callbackasm1(SB) - MOVD $424, R12 - B callbackasm1(SB) - MOVD $425, R12 - B callbackasm1(SB) - MOVD $426, R12 - B callbackasm1(SB) - MOVD $427, R12 - B callbackasm1(SB) - MOVD $428, R12 - B callbackasm1(SB) - MOVD $429, R12 - B callbackasm1(SB) - MOVD $430, R12 - B callbackasm1(SB) - MOVD $431, R12 - B callbackasm1(SB) - MOVD $432, R12 - B callbackasm1(SB) - MOVD $433, R12 - B callbackasm1(SB) - MOVD $434, R12 - B callbackasm1(SB) - MOVD $435, R12 - B callbackasm1(SB) - MOVD $436, R12 - B callbackasm1(SB) - MOVD $437, R12 - B callbackasm1(SB) - MOVD $438, R12 - B callbackasm1(SB) - MOVD $439, R12 - B callbackasm1(SB) - MOVD $440, R12 - B callbackasm1(SB) - MOVD $441, R12 - B callbackasm1(SB) - MOVD $442, R12 - B callbackasm1(SB) - MOVD $443, R12 - B callbackasm1(SB) - MOVD $444, R12 - B callbackasm1(SB) - MOVD $445, R12 - B callbackasm1(SB) - MOVD $446, R12 - B callbackasm1(SB) - MOVD $447, R12 - B callbackasm1(SB) - MOVD $448, R12 - B callbackasm1(SB) - MOVD $449, R12 - B callbackasm1(SB) - MOVD $450, R12 - B callbackasm1(SB) - MOVD $451, R12 - B callbackasm1(SB) - MOVD $452, R12 - B callbackasm1(SB) - MOVD $453, R12 - B callbackasm1(SB) - MOVD $454, R12 - B callbackasm1(SB) - MOVD $455, R12 - B callbackasm1(SB) - MOVD $456, R12 - B callbackasm1(SB) - MOVD $457, R12 - B callbackasm1(SB) - MOVD $458, R12 - B callbackasm1(SB) - MOVD $459, R12 - B callbackasm1(SB) - MOVD $460, R12 - B callbackasm1(SB) - MOVD $461, R12 - B callbackasm1(SB) - MOVD $462, R12 - B callbackasm1(SB) - MOVD $463, R12 - B callbackasm1(SB) - MOVD $464, R12 - B callbackasm1(SB) - MOVD $465, R12 - B callbackasm1(SB) - MOVD $466, R12 - B callbackasm1(SB) - MOVD $467, R12 - B callbackasm1(SB) - MOVD $468, R12 - B callbackasm1(SB) - MOVD $469, R12 - B callbackasm1(SB) - MOVD $470, R12 - B callbackasm1(SB) - MOVD $471, R12 - B callbackasm1(SB) - MOVD $472, R12 - B callbackasm1(SB) - MOVD $473, R12 - B callbackasm1(SB) - MOVD $474, R12 - B callbackasm1(SB) - MOVD $475, R12 - B callbackasm1(SB) - MOVD $476, R12 - B callbackasm1(SB) - MOVD $477, R12 - B callbackasm1(SB) - MOVD $478, R12 - B callbackasm1(SB) - MOVD $479, R12 - B callbackasm1(SB) - MOVD $480, R12 - B callbackasm1(SB) - MOVD $481, R12 - B callbackasm1(SB) - MOVD $482, R12 - B callbackasm1(SB) - MOVD $483, R12 - B callbackasm1(SB) - MOVD $484, R12 - B callbackasm1(SB) - MOVD $485, R12 - B callbackasm1(SB) - MOVD $486, R12 - B callbackasm1(SB) - MOVD $487, R12 - B callbackasm1(SB) - MOVD $488, R12 - B callbackasm1(SB) - MOVD $489, R12 - B callbackasm1(SB) - MOVD $490, R12 - B callbackasm1(SB) - MOVD $491, R12 - B callbackasm1(SB) - MOVD $492, R12 - B callbackasm1(SB) - MOVD $493, R12 - B callbackasm1(SB) - MOVD $494, R12 - B callbackasm1(SB) - MOVD $495, R12 - B callbackasm1(SB) - MOVD $496, R12 - B callbackasm1(SB) - MOVD $497, R12 - B callbackasm1(SB) - MOVD $498, R12 - B callbackasm1(SB) - MOVD $499, R12 - B callbackasm1(SB) - MOVD $500, R12 - B callbackasm1(SB) - MOVD $501, R12 - B callbackasm1(SB) - MOVD $502, R12 - B callbackasm1(SB) - MOVD $503, R12 - B callbackasm1(SB) - MOVD $504, R12 - B callbackasm1(SB) - MOVD $505, R12 - B callbackasm1(SB) - MOVD $506, R12 - B callbackasm1(SB) - MOVD $507, R12 - B callbackasm1(SB) - MOVD $508, R12 - B callbackasm1(SB) - MOVD $509, R12 - B callbackasm1(SB) - MOVD $510, R12 - B callbackasm1(SB) - MOVD $511, R12 - B callbackasm1(SB) - MOVD $512, R12 - B callbackasm1(SB) - MOVD $513, R12 - B callbackasm1(SB) - MOVD $514, R12 - B callbackasm1(SB) - MOVD $515, R12 - B callbackasm1(SB) - MOVD $516, R12 - B callbackasm1(SB) - MOVD $517, R12 - B callbackasm1(SB) - MOVD $518, R12 - B callbackasm1(SB) - MOVD $519, R12 - B callbackasm1(SB) - MOVD $520, R12 - B callbackasm1(SB) - MOVD $521, R12 - B callbackasm1(SB) - MOVD $522, R12 - B callbackasm1(SB) - MOVD $523, R12 - B callbackasm1(SB) - MOVD $524, R12 - B callbackasm1(SB) - MOVD $525, R12 - B callbackasm1(SB) - MOVD $526, R12 - B callbackasm1(SB) - MOVD $527, R12 - B callbackasm1(SB) - MOVD $528, R12 - B callbackasm1(SB) - MOVD $529, R12 - B callbackasm1(SB) - MOVD $530, R12 - B callbackasm1(SB) - MOVD $531, R12 - B callbackasm1(SB) - MOVD $532, R12 - B callbackasm1(SB) - MOVD $533, R12 - B callbackasm1(SB) - MOVD $534, R12 - B callbackasm1(SB) - MOVD $535, R12 - B callbackasm1(SB) - MOVD $536, R12 - B callbackasm1(SB) - MOVD $537, R12 - B callbackasm1(SB) - MOVD $538, R12 - B callbackasm1(SB) - MOVD $539, R12 - B callbackasm1(SB) - MOVD $540, R12 - B callbackasm1(SB) - MOVD $541, R12 - B callbackasm1(SB) - MOVD $542, R12 - B callbackasm1(SB) - MOVD $543, R12 - B callbackasm1(SB) - MOVD $544, R12 - B callbackasm1(SB) - MOVD $545, R12 - B callbackasm1(SB) - MOVD $546, R12 - B callbackasm1(SB) - MOVD $547, R12 - B callbackasm1(SB) - MOVD $548, R12 - B callbackasm1(SB) - MOVD $549, R12 - B callbackasm1(SB) - MOVD $550, R12 - B callbackasm1(SB) - MOVD $551, R12 - B callbackasm1(SB) - MOVD $552, R12 - B callbackasm1(SB) - MOVD $553, R12 - B callbackasm1(SB) - MOVD $554, R12 - B callbackasm1(SB) - MOVD $555, R12 - B callbackasm1(SB) - MOVD $556, R12 - B callbackasm1(SB) - MOVD $557, R12 - B callbackasm1(SB) - MOVD $558, R12 - B callbackasm1(SB) - MOVD $559, R12 - B callbackasm1(SB) - MOVD $560, R12 - B callbackasm1(SB) - MOVD $561, R12 - B callbackasm1(SB) - MOVD $562, R12 - B callbackasm1(SB) - MOVD $563, R12 - B callbackasm1(SB) - MOVD $564, R12 - B callbackasm1(SB) - MOVD $565, R12 - B callbackasm1(SB) - MOVD $566, R12 - B callbackasm1(SB) - MOVD $567, R12 - B callbackasm1(SB) - MOVD $568, R12 - B callbackasm1(SB) - MOVD $569, R12 - B callbackasm1(SB) - MOVD $570, R12 - B callbackasm1(SB) - MOVD $571, R12 - B callbackasm1(SB) - MOVD $572, R12 - B callbackasm1(SB) - MOVD $573, R12 - B callbackasm1(SB) - MOVD $574, R12 - B callbackasm1(SB) - MOVD $575, R12 - B callbackasm1(SB) - MOVD $576, R12 - B callbackasm1(SB) - MOVD $577, R12 - B callbackasm1(SB) - MOVD $578, R12 - B callbackasm1(SB) - MOVD $579, R12 - B callbackasm1(SB) - MOVD $580, R12 - B callbackasm1(SB) - MOVD $581, R12 - B callbackasm1(SB) - MOVD $582, R12 - B callbackasm1(SB) - MOVD $583, R12 - B callbackasm1(SB) - MOVD $584, R12 - B callbackasm1(SB) - MOVD $585, R12 - B callbackasm1(SB) - MOVD $586, R12 - B callbackasm1(SB) - MOVD $587, R12 - B callbackasm1(SB) - MOVD $588, R12 - B callbackasm1(SB) - MOVD $589, R12 - B callbackasm1(SB) - MOVD $590, R12 - B callbackasm1(SB) - MOVD $591, R12 - B callbackasm1(SB) - MOVD $592, R12 - B callbackasm1(SB) - MOVD $593, R12 - B callbackasm1(SB) - MOVD $594, R12 - B callbackasm1(SB) - MOVD $595, R12 - B callbackasm1(SB) - MOVD $596, R12 - B callbackasm1(SB) - MOVD $597, R12 - B callbackasm1(SB) - MOVD $598, R12 - B callbackasm1(SB) - MOVD $599, R12 - B callbackasm1(SB) - MOVD $600, R12 - B callbackasm1(SB) - MOVD $601, R12 - B callbackasm1(SB) - MOVD $602, R12 - B callbackasm1(SB) - MOVD $603, R12 - B callbackasm1(SB) - MOVD $604, R12 - B callbackasm1(SB) - MOVD $605, R12 - B callbackasm1(SB) - MOVD $606, R12 - B callbackasm1(SB) - MOVD $607, R12 - B callbackasm1(SB) - MOVD $608, R12 - B callbackasm1(SB) - MOVD $609, R12 - B callbackasm1(SB) - MOVD $610, R12 - B callbackasm1(SB) - MOVD $611, R12 - B callbackasm1(SB) - MOVD $612, R12 - B callbackasm1(SB) - MOVD $613, R12 - B callbackasm1(SB) - MOVD $614, R12 - B callbackasm1(SB) - MOVD $615, R12 - B callbackasm1(SB) - MOVD $616, R12 - B callbackasm1(SB) - MOVD $617, R12 - B callbackasm1(SB) - MOVD $618, R12 - B callbackasm1(SB) - MOVD $619, R12 - B callbackasm1(SB) - MOVD $620, R12 - B callbackasm1(SB) - MOVD $621, R12 - B callbackasm1(SB) - MOVD $622, R12 - B callbackasm1(SB) - MOVD $623, R12 - B callbackasm1(SB) - MOVD $624, R12 - B callbackasm1(SB) - MOVD $625, R12 - B callbackasm1(SB) - MOVD $626, R12 - B callbackasm1(SB) - MOVD $627, R12 - B callbackasm1(SB) - MOVD $628, R12 - B callbackasm1(SB) - MOVD $629, R12 - B callbackasm1(SB) - MOVD $630, R12 - B callbackasm1(SB) - MOVD $631, R12 - B callbackasm1(SB) - MOVD $632, R12 - B callbackasm1(SB) - MOVD $633, R12 - B callbackasm1(SB) - MOVD $634, R12 - B callbackasm1(SB) - MOVD $635, R12 - B callbackasm1(SB) - MOVD $636, R12 - B callbackasm1(SB) - MOVD $637, R12 - B callbackasm1(SB) - MOVD $638, R12 - B callbackasm1(SB) - MOVD $639, R12 - B callbackasm1(SB) - MOVD $640, R12 - B callbackasm1(SB) - MOVD $641, R12 - B callbackasm1(SB) - MOVD $642, R12 - B callbackasm1(SB) - MOVD $643, R12 - B callbackasm1(SB) - MOVD $644, R12 - B callbackasm1(SB) - MOVD $645, R12 - B callbackasm1(SB) - MOVD $646, R12 - B callbackasm1(SB) - MOVD $647, R12 - B callbackasm1(SB) - MOVD $648, R12 - B callbackasm1(SB) - MOVD $649, R12 - B callbackasm1(SB) - MOVD $650, R12 - B callbackasm1(SB) - MOVD $651, R12 - B callbackasm1(SB) - MOVD $652, R12 - B callbackasm1(SB) - MOVD $653, R12 - B callbackasm1(SB) - MOVD $654, R12 - B callbackasm1(SB) - MOVD $655, R12 - B callbackasm1(SB) - MOVD $656, R12 - B callbackasm1(SB) - MOVD $657, R12 - B callbackasm1(SB) - MOVD $658, R12 - B callbackasm1(SB) - MOVD $659, R12 - B callbackasm1(SB) - MOVD $660, R12 - B callbackasm1(SB) - MOVD $661, R12 - B callbackasm1(SB) - MOVD $662, R12 - B callbackasm1(SB) - MOVD $663, R12 - B callbackasm1(SB) - MOVD $664, R12 - B callbackasm1(SB) - MOVD $665, R12 - B callbackasm1(SB) - MOVD $666, R12 - B callbackasm1(SB) - MOVD $667, R12 - B callbackasm1(SB) - MOVD $668, R12 - B callbackasm1(SB) - MOVD $669, R12 - B callbackasm1(SB) - MOVD $670, R12 - B callbackasm1(SB) - MOVD $671, R12 - B callbackasm1(SB) - MOVD $672, R12 - B callbackasm1(SB) - MOVD $673, R12 - B callbackasm1(SB) - MOVD $674, R12 - B callbackasm1(SB) - MOVD $675, R12 - B callbackasm1(SB) - MOVD $676, R12 - B callbackasm1(SB) - MOVD $677, R12 - B callbackasm1(SB) - MOVD $678, R12 - B callbackasm1(SB) - MOVD $679, R12 - B callbackasm1(SB) - MOVD $680, R12 - B callbackasm1(SB) - MOVD $681, R12 - B callbackasm1(SB) - MOVD $682, R12 - B callbackasm1(SB) - MOVD $683, R12 - B callbackasm1(SB) - MOVD $684, R12 - B callbackasm1(SB) - MOVD $685, R12 - B callbackasm1(SB) - MOVD $686, R12 - B callbackasm1(SB) - MOVD $687, R12 - B callbackasm1(SB) - MOVD $688, R12 - B callbackasm1(SB) - MOVD $689, R12 - B callbackasm1(SB) - MOVD $690, R12 - B callbackasm1(SB) - MOVD $691, R12 - B callbackasm1(SB) - MOVD $692, R12 - B callbackasm1(SB) - MOVD $693, R12 - B callbackasm1(SB) - MOVD $694, R12 - B callbackasm1(SB) - MOVD $695, R12 - B callbackasm1(SB) - MOVD $696, R12 - B callbackasm1(SB) - MOVD $697, R12 - B callbackasm1(SB) - MOVD $698, R12 - B callbackasm1(SB) - MOVD $699, R12 - B callbackasm1(SB) - MOVD $700, R12 - B callbackasm1(SB) - MOVD $701, R12 - B callbackasm1(SB) - MOVD $702, R12 - B callbackasm1(SB) - MOVD $703, R12 - B callbackasm1(SB) - MOVD $704, R12 - B callbackasm1(SB) - MOVD $705, R12 - B callbackasm1(SB) - MOVD $706, R12 - B callbackasm1(SB) - MOVD $707, R12 - B callbackasm1(SB) - MOVD $708, R12 - B callbackasm1(SB) - MOVD $709, R12 - B callbackasm1(SB) - MOVD $710, R12 - B callbackasm1(SB) - MOVD $711, R12 - B callbackasm1(SB) - MOVD $712, R12 - B callbackasm1(SB) - MOVD $713, R12 - B callbackasm1(SB) - MOVD $714, R12 - B callbackasm1(SB) - MOVD $715, R12 - B callbackasm1(SB) - MOVD $716, R12 - B callbackasm1(SB) - MOVD $717, R12 - B callbackasm1(SB) - MOVD $718, R12 - B callbackasm1(SB) - MOVD $719, R12 - B callbackasm1(SB) - MOVD $720, R12 - B callbackasm1(SB) - MOVD $721, R12 - B callbackasm1(SB) - MOVD $722, R12 - B callbackasm1(SB) - MOVD $723, R12 - B callbackasm1(SB) - MOVD $724, R12 - B callbackasm1(SB) - MOVD $725, R12 - B callbackasm1(SB) - MOVD $726, R12 - B callbackasm1(SB) - MOVD $727, R12 - B callbackasm1(SB) - MOVD $728, R12 - B callbackasm1(SB) - MOVD $729, R12 - B callbackasm1(SB) - MOVD $730, R12 - B callbackasm1(SB) - MOVD $731, R12 - B callbackasm1(SB) - MOVD $732, R12 - B callbackasm1(SB) - MOVD $733, R12 - B callbackasm1(SB) - MOVD $734, R12 - B callbackasm1(SB) - MOVD $735, R12 - B callbackasm1(SB) - MOVD $736, R12 - B callbackasm1(SB) - MOVD $737, R12 - B callbackasm1(SB) - MOVD $738, R12 - B callbackasm1(SB) - MOVD $739, R12 - B callbackasm1(SB) - MOVD $740, R12 - B callbackasm1(SB) - MOVD $741, R12 - B callbackasm1(SB) - MOVD $742, R12 - B callbackasm1(SB) - MOVD $743, R12 - B callbackasm1(SB) - MOVD $744, R12 - B callbackasm1(SB) - MOVD $745, R12 - B callbackasm1(SB) - MOVD $746, R12 - B callbackasm1(SB) - MOVD $747, R12 - B callbackasm1(SB) - MOVD $748, R12 - B callbackasm1(SB) - MOVD $749, R12 - B callbackasm1(SB) - MOVD $750, R12 - B callbackasm1(SB) - MOVD $751, R12 - B callbackasm1(SB) - MOVD $752, R12 - B callbackasm1(SB) - MOVD $753, R12 - B callbackasm1(SB) - MOVD $754, R12 - B callbackasm1(SB) - MOVD $755, R12 - B callbackasm1(SB) - MOVD $756, R12 - B callbackasm1(SB) - MOVD $757, R12 - B callbackasm1(SB) - MOVD $758, R12 - B callbackasm1(SB) - MOVD $759, R12 - B callbackasm1(SB) - MOVD $760, R12 - B callbackasm1(SB) - MOVD $761, R12 - B callbackasm1(SB) - MOVD $762, R12 - B callbackasm1(SB) - MOVD $763, R12 - B callbackasm1(SB) - MOVD $764, R12 - B callbackasm1(SB) - MOVD $765, R12 - B callbackasm1(SB) - MOVD $766, R12 - B callbackasm1(SB) - MOVD $767, R12 - B callbackasm1(SB) - MOVD $768, R12 - B callbackasm1(SB) - MOVD $769, R12 - B callbackasm1(SB) - MOVD $770, R12 - B callbackasm1(SB) - MOVD $771, R12 - B callbackasm1(SB) - MOVD $772, R12 - B callbackasm1(SB) - MOVD $773, R12 - B callbackasm1(SB) - MOVD $774, R12 - B callbackasm1(SB) - MOVD $775, R12 - B callbackasm1(SB) - MOVD $776, R12 - B callbackasm1(SB) - MOVD $777, R12 - B callbackasm1(SB) - MOVD $778, R12 - B callbackasm1(SB) - MOVD $779, R12 - B callbackasm1(SB) - MOVD $780, R12 - B callbackasm1(SB) - MOVD $781, R12 - B callbackasm1(SB) - MOVD $782, R12 - B callbackasm1(SB) - MOVD $783, R12 - B callbackasm1(SB) - MOVD $784, R12 - B callbackasm1(SB) - MOVD $785, R12 - B callbackasm1(SB) - MOVD $786, R12 - B callbackasm1(SB) - MOVD $787, R12 - B callbackasm1(SB) - MOVD $788, R12 - B callbackasm1(SB) - MOVD $789, R12 - B callbackasm1(SB) - MOVD $790, R12 - B callbackasm1(SB) - MOVD $791, R12 - B callbackasm1(SB) - MOVD $792, R12 - B callbackasm1(SB) - MOVD $793, R12 - B callbackasm1(SB) - MOVD $794, R12 - B callbackasm1(SB) - MOVD $795, R12 - B callbackasm1(SB) - MOVD $796, R12 - B callbackasm1(SB) - MOVD $797, R12 - B callbackasm1(SB) - MOVD $798, R12 - B callbackasm1(SB) - MOVD $799, R12 - B callbackasm1(SB) - MOVD $800, R12 - B callbackasm1(SB) - MOVD $801, R12 - B callbackasm1(SB) - MOVD $802, R12 - B callbackasm1(SB) - MOVD $803, R12 - B callbackasm1(SB) - MOVD $804, R12 - B callbackasm1(SB) - MOVD $805, R12 - B callbackasm1(SB) - MOVD $806, R12 - B callbackasm1(SB) - MOVD $807, R12 - B callbackasm1(SB) - MOVD $808, R12 - B callbackasm1(SB) - MOVD $809, R12 - B callbackasm1(SB) - MOVD $810, R12 - B callbackasm1(SB) - MOVD $811, R12 - B callbackasm1(SB) - MOVD $812, R12 - B callbackasm1(SB) - MOVD $813, R12 - B callbackasm1(SB) - MOVD $814, R12 - B callbackasm1(SB) - MOVD $815, R12 - B callbackasm1(SB) - MOVD $816, R12 - B callbackasm1(SB) - MOVD $817, R12 - B callbackasm1(SB) - MOVD $818, R12 - B callbackasm1(SB) - MOVD $819, R12 - B callbackasm1(SB) - MOVD $820, R12 - B callbackasm1(SB) - MOVD $821, R12 - B callbackasm1(SB) - MOVD $822, R12 - B callbackasm1(SB) - MOVD $823, R12 - B callbackasm1(SB) - MOVD $824, R12 - B callbackasm1(SB) - MOVD $825, R12 - B callbackasm1(SB) - MOVD $826, R12 - B callbackasm1(SB) - MOVD $827, R12 - B callbackasm1(SB) - MOVD $828, R12 - B callbackasm1(SB) - MOVD $829, R12 - B callbackasm1(SB) - MOVD $830, R12 - B callbackasm1(SB) - MOVD $831, R12 - B callbackasm1(SB) - MOVD $832, R12 - B callbackasm1(SB) - MOVD $833, R12 - B callbackasm1(SB) - MOVD $834, R12 - B callbackasm1(SB) - MOVD $835, R12 - B callbackasm1(SB) - MOVD $836, R12 - B callbackasm1(SB) - MOVD $837, R12 - B callbackasm1(SB) - MOVD $838, R12 - B callbackasm1(SB) - MOVD $839, R12 - B callbackasm1(SB) - MOVD $840, R12 - B callbackasm1(SB) - MOVD $841, R12 - B callbackasm1(SB) - MOVD $842, R12 - B callbackasm1(SB) - MOVD $843, R12 - B callbackasm1(SB) - MOVD $844, R12 - B callbackasm1(SB) - MOVD $845, R12 - B callbackasm1(SB) - MOVD $846, R12 - B callbackasm1(SB) - MOVD $847, R12 - B callbackasm1(SB) - MOVD $848, R12 - B callbackasm1(SB) - MOVD $849, R12 - B callbackasm1(SB) - MOVD $850, R12 - B callbackasm1(SB) - MOVD $851, R12 - B callbackasm1(SB) - MOVD $852, R12 - B callbackasm1(SB) - MOVD $853, R12 - B callbackasm1(SB) - MOVD $854, R12 - B callbackasm1(SB) - MOVD $855, R12 - B callbackasm1(SB) - MOVD $856, R12 - B callbackasm1(SB) - MOVD $857, R12 - B callbackasm1(SB) - MOVD $858, R12 - B callbackasm1(SB) - MOVD $859, R12 - B callbackasm1(SB) - MOVD $860, R12 - B callbackasm1(SB) - MOVD $861, R12 - B callbackasm1(SB) - MOVD $862, R12 - B callbackasm1(SB) - MOVD $863, R12 - B callbackasm1(SB) - MOVD $864, R12 - B callbackasm1(SB) - MOVD $865, R12 - B callbackasm1(SB) - MOVD $866, R12 - B callbackasm1(SB) - MOVD $867, R12 - B callbackasm1(SB) - MOVD $868, R12 - B callbackasm1(SB) - MOVD $869, R12 - B callbackasm1(SB) - MOVD $870, R12 - B callbackasm1(SB) - MOVD $871, R12 - B callbackasm1(SB) - MOVD $872, R12 - B callbackasm1(SB) - MOVD $873, R12 - B callbackasm1(SB) - MOVD $874, R12 - B callbackasm1(SB) - MOVD $875, R12 - B callbackasm1(SB) - MOVD $876, R12 - B callbackasm1(SB) - MOVD $877, R12 - B callbackasm1(SB) - MOVD $878, R12 - B callbackasm1(SB) - MOVD $879, R12 - B callbackasm1(SB) - MOVD $880, R12 - B callbackasm1(SB) - MOVD $881, R12 - B callbackasm1(SB) - MOVD $882, R12 - B callbackasm1(SB) - MOVD $883, R12 - B callbackasm1(SB) - MOVD $884, R12 - B callbackasm1(SB) - MOVD $885, R12 - B callbackasm1(SB) - MOVD $886, R12 - B callbackasm1(SB) - MOVD $887, R12 - B callbackasm1(SB) - MOVD $888, R12 - B callbackasm1(SB) - MOVD $889, R12 - B callbackasm1(SB) - MOVD $890, R12 - B callbackasm1(SB) - MOVD $891, R12 - B callbackasm1(SB) - MOVD $892, R12 - B callbackasm1(SB) - MOVD $893, R12 - B callbackasm1(SB) - MOVD $894, R12 - B callbackasm1(SB) - MOVD $895, R12 - B callbackasm1(SB) - MOVD $896, R12 - B callbackasm1(SB) - MOVD $897, R12 - B callbackasm1(SB) - MOVD $898, R12 - B callbackasm1(SB) - MOVD $899, R12 - B callbackasm1(SB) - MOVD $900, R12 - B callbackasm1(SB) - MOVD $901, R12 - B callbackasm1(SB) - MOVD $902, R12 - B callbackasm1(SB) - MOVD $903, R12 - B callbackasm1(SB) - MOVD $904, R12 - B callbackasm1(SB) - MOVD $905, R12 - B callbackasm1(SB) - MOVD $906, R12 - B callbackasm1(SB) - MOVD $907, R12 - B callbackasm1(SB) - MOVD $908, R12 - B callbackasm1(SB) - MOVD $909, R12 - B callbackasm1(SB) - MOVD $910, R12 - B callbackasm1(SB) - MOVD $911, R12 - B callbackasm1(SB) - MOVD $912, R12 - B callbackasm1(SB) - MOVD $913, R12 - B callbackasm1(SB) - MOVD $914, R12 - B callbackasm1(SB) - MOVD $915, R12 - B callbackasm1(SB) - MOVD $916, R12 - B callbackasm1(SB) - MOVD $917, R12 - B callbackasm1(SB) - MOVD $918, R12 - B callbackasm1(SB) - MOVD $919, R12 - B callbackasm1(SB) - MOVD $920, R12 - B callbackasm1(SB) - MOVD $921, R12 - B callbackasm1(SB) - MOVD $922, R12 - B callbackasm1(SB) - MOVD $923, R12 - B callbackasm1(SB) - MOVD $924, R12 - B callbackasm1(SB) - MOVD $925, R12 - B callbackasm1(SB) - MOVD $926, R12 - B callbackasm1(SB) - MOVD $927, R12 - B callbackasm1(SB) - MOVD $928, R12 - B callbackasm1(SB) - MOVD $929, R12 - B callbackasm1(SB) - MOVD $930, R12 - B callbackasm1(SB) - MOVD $931, R12 - B callbackasm1(SB) - MOVD $932, R12 - B callbackasm1(SB) - MOVD $933, R12 - B callbackasm1(SB) - MOVD $934, R12 - B callbackasm1(SB) - MOVD $935, R12 - B callbackasm1(SB) - MOVD $936, R12 - B callbackasm1(SB) - MOVD $937, R12 - B callbackasm1(SB) - MOVD $938, R12 - B callbackasm1(SB) - MOVD $939, R12 - B callbackasm1(SB) - MOVD $940, R12 - B callbackasm1(SB) - MOVD $941, R12 - B callbackasm1(SB) - MOVD $942, R12 - B callbackasm1(SB) - MOVD $943, R12 - B callbackasm1(SB) - MOVD $944, R12 - B callbackasm1(SB) - MOVD $945, R12 - B callbackasm1(SB) - MOVD $946, R12 - B callbackasm1(SB) - MOVD $947, R12 - B callbackasm1(SB) - MOVD $948, R12 - B callbackasm1(SB) - MOVD $949, R12 - B callbackasm1(SB) - MOVD $950, R12 - B callbackasm1(SB) - MOVD $951, R12 - B callbackasm1(SB) - MOVD $952, R12 - B callbackasm1(SB) - MOVD $953, R12 - B callbackasm1(SB) - MOVD $954, R12 - B callbackasm1(SB) - MOVD $955, R12 - B callbackasm1(SB) - MOVD $956, R12 - B callbackasm1(SB) - MOVD $957, R12 - B callbackasm1(SB) - MOVD $958, R12 - B callbackasm1(SB) - MOVD $959, R12 - B callbackasm1(SB) - MOVD $960, R12 - B callbackasm1(SB) - MOVD $961, R12 - B callbackasm1(SB) - MOVD $962, R12 - B callbackasm1(SB) - MOVD $963, R12 - B callbackasm1(SB) - MOVD $964, R12 - B callbackasm1(SB) - MOVD $965, R12 - B callbackasm1(SB) - MOVD $966, R12 - B callbackasm1(SB) - MOVD $967, R12 - B callbackasm1(SB) - MOVD $968, R12 - B callbackasm1(SB) - MOVD $969, R12 - B callbackasm1(SB) - MOVD $970, R12 - B callbackasm1(SB) - MOVD $971, R12 - B callbackasm1(SB) - MOVD $972, R12 - B callbackasm1(SB) - MOVD $973, R12 - B callbackasm1(SB) - MOVD $974, R12 - B callbackasm1(SB) - MOVD $975, R12 - B callbackasm1(SB) - MOVD $976, R12 - B callbackasm1(SB) - MOVD $977, R12 - B callbackasm1(SB) - MOVD $978, R12 - B callbackasm1(SB) - MOVD $979, R12 - B callbackasm1(SB) - MOVD $980, R12 - B callbackasm1(SB) - MOVD $981, R12 - B callbackasm1(SB) - MOVD $982, R12 - B callbackasm1(SB) - MOVD $983, R12 - B callbackasm1(SB) - MOVD $984, R12 - B callbackasm1(SB) - MOVD $985, R12 - B callbackasm1(SB) - MOVD $986, R12 - B callbackasm1(SB) - MOVD $987, R12 - B callbackasm1(SB) - MOVD $988, R12 - B callbackasm1(SB) - MOVD $989, R12 - B callbackasm1(SB) - MOVD $990, R12 - B callbackasm1(SB) - MOVD $991, R12 - B callbackasm1(SB) - MOVD $992, R12 - B callbackasm1(SB) - MOVD $993, R12 - B callbackasm1(SB) - MOVD $994, R12 - B callbackasm1(SB) - MOVD $995, R12 - B callbackasm1(SB) - MOVD $996, R12 - B callbackasm1(SB) - MOVD $997, R12 - B callbackasm1(SB) - MOVD $998, R12 - B callbackasm1(SB) - MOVD $999, R12 - B callbackasm1(SB) - MOVD $1000, R12 - B callbackasm1(SB) - MOVD $1001, R12 - B callbackasm1(SB) - MOVD $1002, R12 - B callbackasm1(SB) - MOVD $1003, R12 - B callbackasm1(SB) - MOVD $1004, R12 - B callbackasm1(SB) - MOVD $1005, R12 - B callbackasm1(SB) - MOVD $1006, R12 - B callbackasm1(SB) - MOVD $1007, R12 - B callbackasm1(SB) - MOVD $1008, R12 - B callbackasm1(SB) - MOVD $1009, R12 - B callbackasm1(SB) - MOVD $1010, R12 - B callbackasm1(SB) - MOVD $1011, R12 - B callbackasm1(SB) - MOVD $1012, R12 - B callbackasm1(SB) - MOVD $1013, R12 - B callbackasm1(SB) - MOVD $1014, R12 - B callbackasm1(SB) - MOVD $1015, R12 - B callbackasm1(SB) - MOVD $1016, R12 - B callbackasm1(SB) - MOVD $1017, R12 - B callbackasm1(SB) - MOVD $1018, R12 - B callbackasm1(SB) - MOVD $1019, R12 - B callbackasm1(SB) - MOVD $1020, R12 - B callbackasm1(SB) - MOVD $1021, R12 - B callbackasm1(SB) - MOVD $1022, R12 - B callbackasm1(SB) - MOVD $1023, R12 - B callbackasm1(SB) - MOVD $1024, R12 - B callbackasm1(SB) - MOVD $1025, R12 - B callbackasm1(SB) - MOVD $1026, R12 - B callbackasm1(SB) - MOVD $1027, R12 - B callbackasm1(SB) - MOVD $1028, R12 - B callbackasm1(SB) - MOVD $1029, R12 - B callbackasm1(SB) - MOVD $1030, R12 - B callbackasm1(SB) - MOVD $1031, R12 - B callbackasm1(SB) - MOVD $1032, R12 - B callbackasm1(SB) - MOVD $1033, R12 - B callbackasm1(SB) - MOVD $1034, R12 - B callbackasm1(SB) - MOVD $1035, R12 - B callbackasm1(SB) - MOVD $1036, R12 - B callbackasm1(SB) - MOVD $1037, R12 - B callbackasm1(SB) - MOVD $1038, R12 - B callbackasm1(SB) - MOVD $1039, R12 - B callbackasm1(SB) - MOVD $1040, R12 - B callbackasm1(SB) - MOVD $1041, R12 - B callbackasm1(SB) - MOVD $1042, R12 - B callbackasm1(SB) - MOVD $1043, R12 - B callbackasm1(SB) - MOVD $1044, R12 - B callbackasm1(SB) - MOVD $1045, R12 - B callbackasm1(SB) - MOVD $1046, R12 - B callbackasm1(SB) - MOVD $1047, R12 - B callbackasm1(SB) - MOVD $1048, R12 - B callbackasm1(SB) - MOVD $1049, R12 - B callbackasm1(SB) - MOVD $1050, R12 - B callbackasm1(SB) - MOVD $1051, R12 - B callbackasm1(SB) - MOVD $1052, R12 - B callbackasm1(SB) - MOVD $1053, R12 - B callbackasm1(SB) - MOVD $1054, R12 - B callbackasm1(SB) - MOVD $1055, R12 - B callbackasm1(SB) - MOVD $1056, R12 - B callbackasm1(SB) - MOVD $1057, R12 - B callbackasm1(SB) - MOVD $1058, R12 - B callbackasm1(SB) - MOVD $1059, R12 - B callbackasm1(SB) - MOVD $1060, R12 - B callbackasm1(SB) - MOVD $1061, R12 - B callbackasm1(SB) - MOVD $1062, R12 - B callbackasm1(SB) - MOVD $1063, R12 - B callbackasm1(SB) - MOVD $1064, R12 - B callbackasm1(SB) - MOVD $1065, R12 - B callbackasm1(SB) - MOVD $1066, R12 - B callbackasm1(SB) - MOVD $1067, R12 - B callbackasm1(SB) - MOVD $1068, R12 - B callbackasm1(SB) - MOVD $1069, R12 - B callbackasm1(SB) - MOVD $1070, R12 - B callbackasm1(SB) - MOVD $1071, R12 - B callbackasm1(SB) - MOVD $1072, R12 - B callbackasm1(SB) - MOVD $1073, R12 - B callbackasm1(SB) - MOVD $1074, R12 - B callbackasm1(SB) - MOVD $1075, R12 - B callbackasm1(SB) - MOVD $1076, R12 - B callbackasm1(SB) - MOVD $1077, R12 - B callbackasm1(SB) - MOVD $1078, R12 - B callbackasm1(SB) - MOVD $1079, R12 - B callbackasm1(SB) - MOVD $1080, R12 - B callbackasm1(SB) - MOVD $1081, R12 - B callbackasm1(SB) - MOVD $1082, R12 - B callbackasm1(SB) - MOVD $1083, R12 - B callbackasm1(SB) - MOVD $1084, R12 - B callbackasm1(SB) - MOVD $1085, R12 - B callbackasm1(SB) - MOVD $1086, R12 - B callbackasm1(SB) - MOVD $1087, R12 - B callbackasm1(SB) - MOVD $1088, R12 - B callbackasm1(SB) - MOVD $1089, R12 - B callbackasm1(SB) - MOVD $1090, R12 - B callbackasm1(SB) - MOVD $1091, R12 - B callbackasm1(SB) - MOVD $1092, R12 - B callbackasm1(SB) - MOVD $1093, R12 - B callbackasm1(SB) - MOVD $1094, R12 - B callbackasm1(SB) - MOVD $1095, R12 - B callbackasm1(SB) - MOVD $1096, R12 - B callbackasm1(SB) - MOVD $1097, R12 - B callbackasm1(SB) - MOVD $1098, R12 - B callbackasm1(SB) - MOVD $1099, R12 - B callbackasm1(SB) - MOVD $1100, R12 - B callbackasm1(SB) - MOVD $1101, R12 - B callbackasm1(SB) - MOVD $1102, R12 - B callbackasm1(SB) - MOVD $1103, R12 - B callbackasm1(SB) - MOVD $1104, R12 - B callbackasm1(SB) - MOVD $1105, R12 - B callbackasm1(SB) - MOVD $1106, R12 - B callbackasm1(SB) - MOVD $1107, R12 - B callbackasm1(SB) - MOVD $1108, R12 - B callbackasm1(SB) - MOVD $1109, R12 - B callbackasm1(SB) - MOVD $1110, R12 - B callbackasm1(SB) - MOVD $1111, R12 - B callbackasm1(SB) - MOVD $1112, R12 - B callbackasm1(SB) - MOVD $1113, R12 - B callbackasm1(SB) - MOVD $1114, R12 - B callbackasm1(SB) - MOVD $1115, R12 - B callbackasm1(SB) - MOVD $1116, R12 - B callbackasm1(SB) - MOVD $1117, R12 - B callbackasm1(SB) - MOVD $1118, R12 - B callbackasm1(SB) - MOVD $1119, R12 - B callbackasm1(SB) - MOVD $1120, R12 - B callbackasm1(SB) - MOVD $1121, R12 - B callbackasm1(SB) - MOVD $1122, R12 - B callbackasm1(SB) - MOVD $1123, R12 - B callbackasm1(SB) - MOVD $1124, R12 - B callbackasm1(SB) - MOVD $1125, R12 - B callbackasm1(SB) - MOVD $1126, R12 - B callbackasm1(SB) - MOVD $1127, R12 - B callbackasm1(SB) - MOVD $1128, R12 - B callbackasm1(SB) - MOVD $1129, R12 - B callbackasm1(SB) - MOVD $1130, R12 - B callbackasm1(SB) - MOVD $1131, R12 - B callbackasm1(SB) - MOVD $1132, R12 - B callbackasm1(SB) - MOVD $1133, R12 - B callbackasm1(SB) - MOVD $1134, R12 - B callbackasm1(SB) - MOVD $1135, R12 - B callbackasm1(SB) - MOVD $1136, R12 - B callbackasm1(SB) - MOVD $1137, R12 - B callbackasm1(SB) - MOVD $1138, R12 - B callbackasm1(SB) - MOVD $1139, R12 - B callbackasm1(SB) - MOVD $1140, R12 - B callbackasm1(SB) - MOVD $1141, R12 - B callbackasm1(SB) - MOVD $1142, R12 - B callbackasm1(SB) - MOVD $1143, R12 - B callbackasm1(SB) - MOVD $1144, R12 - B callbackasm1(SB) - MOVD $1145, R12 - B callbackasm1(SB) - MOVD $1146, R12 - B callbackasm1(SB) - MOVD $1147, R12 - B callbackasm1(SB) - MOVD $1148, R12 - B callbackasm1(SB) - MOVD $1149, R12 - B callbackasm1(SB) - MOVD $1150, R12 - B callbackasm1(SB) - MOVD $1151, R12 - B callbackasm1(SB) - MOVD $1152, R12 - B callbackasm1(SB) - MOVD $1153, R12 - B callbackasm1(SB) - MOVD $1154, R12 - B callbackasm1(SB) - MOVD $1155, R12 - B callbackasm1(SB) - MOVD $1156, R12 - B callbackasm1(SB) - MOVD $1157, R12 - B callbackasm1(SB) - MOVD $1158, R12 - B callbackasm1(SB) - MOVD $1159, R12 - B callbackasm1(SB) - MOVD $1160, R12 - B callbackasm1(SB) - MOVD $1161, R12 - B callbackasm1(SB) - MOVD $1162, R12 - B callbackasm1(SB) - MOVD $1163, R12 - B callbackasm1(SB) - MOVD $1164, R12 - B callbackasm1(SB) - MOVD $1165, R12 - B callbackasm1(SB) - MOVD $1166, R12 - B callbackasm1(SB) - MOVD $1167, R12 - B callbackasm1(SB) - MOVD $1168, R12 - B callbackasm1(SB) - MOVD $1169, R12 - B callbackasm1(SB) - MOVD $1170, R12 - B callbackasm1(SB) - MOVD $1171, R12 - B callbackasm1(SB) - MOVD $1172, R12 - B callbackasm1(SB) - MOVD $1173, R12 - B callbackasm1(SB) - MOVD $1174, R12 - B callbackasm1(SB) - MOVD $1175, R12 - B callbackasm1(SB) - MOVD $1176, R12 - B callbackasm1(SB) - MOVD $1177, R12 - B callbackasm1(SB) - MOVD $1178, R12 - B callbackasm1(SB) - MOVD $1179, R12 - B callbackasm1(SB) - MOVD $1180, R12 - B callbackasm1(SB) - MOVD $1181, R12 - B callbackasm1(SB) - MOVD $1182, R12 - B callbackasm1(SB) - MOVD $1183, R12 - B callbackasm1(SB) - MOVD $1184, R12 - B callbackasm1(SB) - MOVD $1185, R12 - B callbackasm1(SB) - MOVD $1186, R12 - B callbackasm1(SB) - MOVD $1187, R12 - B callbackasm1(SB) - MOVD $1188, R12 - B callbackasm1(SB) - MOVD $1189, R12 - B callbackasm1(SB) - MOVD $1190, R12 - B callbackasm1(SB) - MOVD $1191, R12 - B callbackasm1(SB) - MOVD $1192, R12 - B callbackasm1(SB) - MOVD $1193, R12 - B callbackasm1(SB) - MOVD $1194, R12 - B callbackasm1(SB) - MOVD $1195, R12 - B callbackasm1(SB) - MOVD $1196, R12 - B callbackasm1(SB) - MOVD $1197, R12 - B callbackasm1(SB) - MOVD $1198, R12 - B callbackasm1(SB) - MOVD $1199, R12 - B callbackasm1(SB) - MOVD $1200, R12 - B callbackasm1(SB) - MOVD $1201, R12 - B callbackasm1(SB) - MOVD $1202, R12 - B callbackasm1(SB) - MOVD $1203, R12 - B callbackasm1(SB) - MOVD $1204, R12 - B callbackasm1(SB) - MOVD $1205, R12 - B callbackasm1(SB) - MOVD $1206, R12 - B callbackasm1(SB) - MOVD $1207, R12 - B callbackasm1(SB) - MOVD $1208, R12 - B callbackasm1(SB) - MOVD $1209, R12 - B callbackasm1(SB) - MOVD $1210, R12 - B callbackasm1(SB) - MOVD $1211, R12 - B callbackasm1(SB) - MOVD $1212, R12 - B callbackasm1(SB) - MOVD $1213, R12 - B callbackasm1(SB) - MOVD $1214, R12 - B callbackasm1(SB) - MOVD $1215, R12 - B callbackasm1(SB) - MOVD $1216, R12 - B callbackasm1(SB) - MOVD $1217, R12 - B callbackasm1(SB) - MOVD $1218, R12 - B callbackasm1(SB) - MOVD $1219, R12 - B callbackasm1(SB) - MOVD $1220, R12 - B callbackasm1(SB) - MOVD $1221, R12 - B callbackasm1(SB) - MOVD $1222, R12 - B callbackasm1(SB) - MOVD $1223, R12 - B callbackasm1(SB) - MOVD $1224, R12 - B callbackasm1(SB) - MOVD $1225, R12 - B callbackasm1(SB) - MOVD $1226, R12 - B callbackasm1(SB) - MOVD $1227, R12 - B callbackasm1(SB) - MOVD $1228, R12 - B callbackasm1(SB) - MOVD $1229, R12 - B callbackasm1(SB) - MOVD $1230, R12 - B callbackasm1(SB) - MOVD $1231, R12 - B callbackasm1(SB) - MOVD $1232, R12 - B callbackasm1(SB) - MOVD $1233, R12 - B callbackasm1(SB) - MOVD $1234, R12 - B callbackasm1(SB) - MOVD $1235, R12 - B callbackasm1(SB) - MOVD $1236, R12 - B callbackasm1(SB) - MOVD $1237, R12 - B callbackasm1(SB) - MOVD $1238, R12 - B callbackasm1(SB) - MOVD $1239, R12 - B callbackasm1(SB) - MOVD $1240, R12 - B callbackasm1(SB) - MOVD $1241, R12 - B callbackasm1(SB) - MOVD $1242, R12 - B callbackasm1(SB) - MOVD $1243, R12 - B callbackasm1(SB) - MOVD $1244, R12 - B callbackasm1(SB) - MOVD $1245, R12 - B callbackasm1(SB) - MOVD $1246, R12 - B callbackasm1(SB) - MOVD $1247, R12 - B callbackasm1(SB) - MOVD $1248, R12 - B callbackasm1(SB) - MOVD $1249, R12 - B callbackasm1(SB) - MOVD $1250, R12 - B callbackasm1(SB) - MOVD $1251, R12 - B callbackasm1(SB) - MOVD $1252, R12 - B callbackasm1(SB) - MOVD $1253, R12 - B callbackasm1(SB) - MOVD $1254, R12 - B callbackasm1(SB) - MOVD $1255, R12 - B callbackasm1(SB) - MOVD $1256, R12 - B callbackasm1(SB) - MOVD $1257, R12 - B callbackasm1(SB) - MOVD $1258, R12 - B callbackasm1(SB) - MOVD $1259, R12 - B callbackasm1(SB) - MOVD $1260, R12 - B callbackasm1(SB) - MOVD $1261, R12 - B callbackasm1(SB) - MOVD $1262, R12 - B callbackasm1(SB) - MOVD $1263, R12 - B callbackasm1(SB) - MOVD $1264, R12 - B callbackasm1(SB) - MOVD $1265, R12 - B callbackasm1(SB) - MOVD $1266, R12 - B callbackasm1(SB) - MOVD $1267, R12 - B callbackasm1(SB) - MOVD $1268, R12 - B callbackasm1(SB) - MOVD $1269, R12 - B callbackasm1(SB) - MOVD $1270, R12 - B callbackasm1(SB) - MOVD $1271, R12 - B callbackasm1(SB) - MOVD $1272, R12 - B callbackasm1(SB) - MOVD $1273, R12 - B callbackasm1(SB) - MOVD $1274, R12 - B callbackasm1(SB) - MOVD $1275, R12 - B callbackasm1(SB) - MOVD $1276, R12 - B callbackasm1(SB) - MOVD $1277, R12 - B callbackasm1(SB) - MOVD $1278, R12 - B callbackasm1(SB) - MOVD $1279, R12 - B callbackasm1(SB) - MOVD $1280, R12 - B callbackasm1(SB) - MOVD $1281, R12 - B callbackasm1(SB) - MOVD $1282, R12 - B callbackasm1(SB) - MOVD $1283, R12 - B callbackasm1(SB) - MOVD $1284, R12 - B callbackasm1(SB) - MOVD $1285, R12 - B callbackasm1(SB) - MOVD $1286, R12 - B callbackasm1(SB) - MOVD $1287, R12 - B callbackasm1(SB) - MOVD $1288, R12 - B callbackasm1(SB) - MOVD $1289, R12 - B callbackasm1(SB) - MOVD $1290, R12 - B callbackasm1(SB) - MOVD $1291, R12 - B callbackasm1(SB) - MOVD $1292, R12 - B callbackasm1(SB) - MOVD $1293, R12 - B callbackasm1(SB) - MOVD $1294, R12 - B callbackasm1(SB) - MOVD $1295, R12 - B callbackasm1(SB) - MOVD $1296, R12 - B callbackasm1(SB) - MOVD $1297, R12 - B callbackasm1(SB) - MOVD $1298, R12 - B callbackasm1(SB) - MOVD $1299, R12 - B callbackasm1(SB) - MOVD $1300, R12 - B callbackasm1(SB) - MOVD $1301, R12 - B callbackasm1(SB) - MOVD $1302, R12 - B callbackasm1(SB) - MOVD $1303, R12 - B callbackasm1(SB) - MOVD $1304, R12 - B callbackasm1(SB) - MOVD $1305, R12 - B callbackasm1(SB) - MOVD $1306, R12 - B callbackasm1(SB) - MOVD $1307, R12 - B callbackasm1(SB) - MOVD $1308, R12 - B callbackasm1(SB) - MOVD $1309, R12 - B callbackasm1(SB) - MOVD $1310, R12 - B callbackasm1(SB) - MOVD $1311, R12 - B callbackasm1(SB) - MOVD $1312, R12 - B callbackasm1(SB) - MOVD $1313, R12 - B callbackasm1(SB) - MOVD $1314, R12 - B callbackasm1(SB) - MOVD $1315, R12 - B callbackasm1(SB) - MOVD $1316, R12 - B callbackasm1(SB) - MOVD $1317, R12 - B callbackasm1(SB) - MOVD $1318, R12 - B callbackasm1(SB) - MOVD $1319, R12 - B callbackasm1(SB) - MOVD $1320, R12 - B callbackasm1(SB) - MOVD $1321, R12 - B callbackasm1(SB) - MOVD $1322, R12 - B callbackasm1(SB) - MOVD $1323, R12 - B callbackasm1(SB) - MOVD $1324, R12 - B callbackasm1(SB) - MOVD $1325, R12 - B callbackasm1(SB) - MOVD $1326, R12 - B callbackasm1(SB) - MOVD $1327, R12 - B callbackasm1(SB) - MOVD $1328, R12 - B callbackasm1(SB) - MOVD $1329, R12 - B callbackasm1(SB) - MOVD $1330, R12 - B callbackasm1(SB) - MOVD $1331, R12 - B callbackasm1(SB) - MOVD $1332, R12 - B callbackasm1(SB) - MOVD $1333, R12 - B callbackasm1(SB) - MOVD $1334, R12 - B callbackasm1(SB) - MOVD $1335, R12 - B callbackasm1(SB) - MOVD $1336, R12 - B callbackasm1(SB) - MOVD $1337, R12 - B callbackasm1(SB) - MOVD $1338, R12 - B callbackasm1(SB) - MOVD $1339, R12 - B callbackasm1(SB) - MOVD $1340, R12 - B callbackasm1(SB) - MOVD $1341, R12 - B callbackasm1(SB) - MOVD $1342, R12 - B callbackasm1(SB) - MOVD $1343, R12 - B callbackasm1(SB) - MOVD $1344, R12 - B callbackasm1(SB) - MOVD $1345, R12 - B callbackasm1(SB) - MOVD $1346, R12 - B callbackasm1(SB) - MOVD $1347, R12 - B callbackasm1(SB) - MOVD $1348, R12 - B callbackasm1(SB) - MOVD $1349, R12 - B callbackasm1(SB) - MOVD $1350, R12 - B callbackasm1(SB) - MOVD $1351, R12 - B callbackasm1(SB) - MOVD $1352, R12 - B callbackasm1(SB) - MOVD $1353, R12 - B callbackasm1(SB) - MOVD $1354, R12 - B callbackasm1(SB) - MOVD $1355, R12 - B callbackasm1(SB) - MOVD $1356, R12 - B callbackasm1(SB) - MOVD $1357, R12 - B callbackasm1(SB) - MOVD $1358, R12 - B callbackasm1(SB) - MOVD $1359, R12 - B callbackasm1(SB) - MOVD $1360, R12 - B callbackasm1(SB) - MOVD $1361, R12 - B callbackasm1(SB) - MOVD $1362, R12 - B callbackasm1(SB) - MOVD $1363, R12 - B callbackasm1(SB) - MOVD $1364, R12 - B callbackasm1(SB) - MOVD $1365, R12 - B callbackasm1(SB) - MOVD $1366, R12 - B callbackasm1(SB) - MOVD $1367, R12 - B callbackasm1(SB) - MOVD $1368, R12 - B callbackasm1(SB) - MOVD $1369, R12 - B callbackasm1(SB) - MOVD $1370, R12 - B callbackasm1(SB) - MOVD $1371, R12 - B callbackasm1(SB) - MOVD $1372, R12 - B callbackasm1(SB) - MOVD $1373, R12 - B callbackasm1(SB) - MOVD $1374, R12 - B callbackasm1(SB) - MOVD $1375, R12 - B callbackasm1(SB) - MOVD $1376, R12 - B callbackasm1(SB) - MOVD $1377, R12 - B callbackasm1(SB) - MOVD $1378, R12 - B callbackasm1(SB) - MOVD $1379, R12 - B callbackasm1(SB) - MOVD $1380, R12 - B callbackasm1(SB) - MOVD $1381, R12 - B callbackasm1(SB) - MOVD $1382, R12 - B callbackasm1(SB) - MOVD $1383, R12 - B callbackasm1(SB) - MOVD $1384, R12 - B callbackasm1(SB) - MOVD $1385, R12 - B callbackasm1(SB) - MOVD $1386, R12 - B callbackasm1(SB) - MOVD $1387, R12 - B callbackasm1(SB) - MOVD $1388, R12 - B callbackasm1(SB) - MOVD $1389, R12 - B callbackasm1(SB) - MOVD $1390, R12 - B callbackasm1(SB) - MOVD $1391, R12 - B callbackasm1(SB) - MOVD $1392, R12 - B callbackasm1(SB) - MOVD $1393, R12 - B callbackasm1(SB) - MOVD $1394, R12 - B callbackasm1(SB) - MOVD $1395, R12 - B callbackasm1(SB) - MOVD $1396, R12 - B callbackasm1(SB) - MOVD $1397, R12 - B callbackasm1(SB) - MOVD $1398, R12 - B callbackasm1(SB) - MOVD $1399, R12 - B callbackasm1(SB) - MOVD $1400, R12 - B callbackasm1(SB) - MOVD $1401, R12 - B callbackasm1(SB) - MOVD $1402, R12 - B callbackasm1(SB) - MOVD $1403, R12 - B callbackasm1(SB) - MOVD $1404, R12 - B callbackasm1(SB) - MOVD $1405, R12 - B callbackasm1(SB) - MOVD $1406, R12 - B callbackasm1(SB) - MOVD $1407, R12 - B callbackasm1(SB) - MOVD $1408, R12 - B callbackasm1(SB) - MOVD $1409, R12 - B callbackasm1(SB) - MOVD $1410, R12 - B callbackasm1(SB) - MOVD $1411, R12 - B callbackasm1(SB) - MOVD $1412, R12 - B callbackasm1(SB) - MOVD $1413, R12 - B callbackasm1(SB) - MOVD $1414, R12 - B callbackasm1(SB) - MOVD $1415, R12 - B callbackasm1(SB) - MOVD $1416, R12 - B callbackasm1(SB) - MOVD $1417, R12 - B callbackasm1(SB) - MOVD $1418, R12 - B callbackasm1(SB) - MOVD $1419, R12 - B callbackasm1(SB) - MOVD $1420, R12 - B callbackasm1(SB) - MOVD $1421, R12 - B callbackasm1(SB) - MOVD $1422, R12 - B callbackasm1(SB) - MOVD $1423, R12 - B callbackasm1(SB) - MOVD $1424, R12 - B callbackasm1(SB) - MOVD $1425, R12 - B callbackasm1(SB) - MOVD $1426, R12 - B callbackasm1(SB) - MOVD $1427, R12 - B callbackasm1(SB) - MOVD $1428, R12 - B callbackasm1(SB) - MOVD $1429, R12 - B callbackasm1(SB) - MOVD $1430, R12 - B callbackasm1(SB) - MOVD $1431, R12 - B callbackasm1(SB) - MOVD $1432, R12 - B callbackasm1(SB) - MOVD $1433, R12 - B callbackasm1(SB) - MOVD $1434, R12 - B callbackasm1(SB) - MOVD $1435, R12 - B callbackasm1(SB) - MOVD $1436, R12 - B callbackasm1(SB) - MOVD $1437, R12 - B callbackasm1(SB) - MOVD $1438, R12 - B callbackasm1(SB) - MOVD $1439, R12 - B callbackasm1(SB) - MOVD $1440, R12 - B callbackasm1(SB) - MOVD $1441, R12 - B callbackasm1(SB) - MOVD $1442, R12 - B callbackasm1(SB) - MOVD $1443, R12 - B callbackasm1(SB) - MOVD $1444, R12 - B callbackasm1(SB) - MOVD $1445, R12 - B callbackasm1(SB) - MOVD $1446, R12 - B callbackasm1(SB) - MOVD $1447, R12 - B callbackasm1(SB) - MOVD $1448, R12 - B callbackasm1(SB) - MOVD $1449, R12 - B callbackasm1(SB) - MOVD $1450, R12 - B callbackasm1(SB) - MOVD $1451, R12 - B callbackasm1(SB) - MOVD $1452, R12 - B callbackasm1(SB) - MOVD $1453, R12 - B callbackasm1(SB) - MOVD $1454, R12 - B callbackasm1(SB) - MOVD $1455, R12 - B callbackasm1(SB) - MOVD $1456, R12 - B callbackasm1(SB) - MOVD $1457, R12 - B callbackasm1(SB) - MOVD $1458, R12 - B callbackasm1(SB) - MOVD $1459, R12 - B callbackasm1(SB) - MOVD $1460, R12 - B callbackasm1(SB) - MOVD $1461, R12 - B callbackasm1(SB) - MOVD $1462, R12 - B callbackasm1(SB) - MOVD $1463, R12 - B callbackasm1(SB) - MOVD $1464, R12 - B callbackasm1(SB) - MOVD $1465, R12 - B callbackasm1(SB) - MOVD $1466, R12 - B callbackasm1(SB) - MOVD $1467, R12 - B callbackasm1(SB) - MOVD $1468, R12 - B callbackasm1(SB) - MOVD $1469, R12 - B callbackasm1(SB) - MOVD $1470, R12 - B callbackasm1(SB) - MOVD $1471, R12 - B callbackasm1(SB) - MOVD $1472, R12 - B callbackasm1(SB) - MOVD $1473, R12 - B callbackasm1(SB) - MOVD $1474, R12 - B callbackasm1(SB) - MOVD $1475, R12 - B callbackasm1(SB) - MOVD $1476, R12 - B callbackasm1(SB) - MOVD $1477, R12 - B callbackasm1(SB) - MOVD $1478, R12 - B callbackasm1(SB) - MOVD $1479, R12 - B callbackasm1(SB) - MOVD $1480, R12 - B callbackasm1(SB) - MOVD $1481, R12 - B callbackasm1(SB) - MOVD $1482, R12 - B callbackasm1(SB) - MOVD $1483, R12 - B callbackasm1(SB) - MOVD $1484, R12 - B callbackasm1(SB) - MOVD $1485, R12 - B callbackasm1(SB) - MOVD $1486, R12 - B callbackasm1(SB) - MOVD $1487, R12 - B callbackasm1(SB) - MOVD $1488, R12 - B callbackasm1(SB) - MOVD $1489, R12 - B callbackasm1(SB) - MOVD $1490, R12 - B callbackasm1(SB) - MOVD $1491, R12 - B callbackasm1(SB) - MOVD $1492, R12 - B callbackasm1(SB) - MOVD $1493, R12 - B callbackasm1(SB) - MOVD $1494, R12 - B callbackasm1(SB) - MOVD $1495, R12 - B callbackasm1(SB) - MOVD $1496, R12 - B callbackasm1(SB) - MOVD $1497, R12 - B callbackasm1(SB) - MOVD $1498, R12 - B callbackasm1(SB) - MOVD $1499, R12 - B callbackasm1(SB) - MOVD $1500, R12 - B callbackasm1(SB) - MOVD $1501, R12 - B callbackasm1(SB) - MOVD $1502, R12 - B callbackasm1(SB) - MOVD $1503, R12 - B callbackasm1(SB) - MOVD $1504, R12 - B callbackasm1(SB) - MOVD $1505, R12 - B callbackasm1(SB) - MOVD $1506, R12 - B callbackasm1(SB) - MOVD $1507, R12 - B callbackasm1(SB) - MOVD $1508, R12 - B callbackasm1(SB) - MOVD $1509, R12 - B callbackasm1(SB) - MOVD $1510, R12 - B callbackasm1(SB) - MOVD $1511, R12 - B callbackasm1(SB) - MOVD $1512, R12 - B callbackasm1(SB) - MOVD $1513, R12 - B callbackasm1(SB) - MOVD $1514, R12 - B callbackasm1(SB) - MOVD $1515, R12 - B callbackasm1(SB) - MOVD $1516, R12 - B callbackasm1(SB) - MOVD $1517, R12 - B callbackasm1(SB) - MOVD $1518, R12 - B callbackasm1(SB) - MOVD $1519, R12 - B callbackasm1(SB) - MOVD $1520, R12 - B callbackasm1(SB) - MOVD $1521, R12 - B callbackasm1(SB) - MOVD $1522, R12 - B callbackasm1(SB) - MOVD $1523, R12 - B callbackasm1(SB) - MOVD $1524, R12 - B callbackasm1(SB) - MOVD $1525, R12 - B callbackasm1(SB) - MOVD $1526, R12 - B callbackasm1(SB) - MOVD $1527, R12 - B callbackasm1(SB) - MOVD $1528, R12 - B callbackasm1(SB) - MOVD $1529, R12 - B callbackasm1(SB) - MOVD $1530, R12 - B callbackasm1(SB) - MOVD $1531, R12 - B callbackasm1(SB) - MOVD $1532, R12 - B callbackasm1(SB) - MOVD $1533, R12 - B callbackasm1(SB) - MOVD $1534, R12 - B callbackasm1(SB) - MOVD $1535, R12 - B callbackasm1(SB) - MOVD $1536, R12 - B callbackasm1(SB) - MOVD $1537, R12 - B callbackasm1(SB) - MOVD $1538, R12 - B callbackasm1(SB) - MOVD $1539, R12 - B callbackasm1(SB) - MOVD $1540, R12 - B callbackasm1(SB) - MOVD $1541, R12 - B callbackasm1(SB) - MOVD $1542, R12 - B callbackasm1(SB) - MOVD $1543, R12 - B callbackasm1(SB) - MOVD $1544, R12 - B callbackasm1(SB) - MOVD $1545, R12 - B callbackasm1(SB) - MOVD $1546, R12 - B callbackasm1(SB) - MOVD $1547, R12 - B callbackasm1(SB) - MOVD $1548, R12 - B callbackasm1(SB) - MOVD $1549, R12 - B callbackasm1(SB) - MOVD $1550, R12 - B callbackasm1(SB) - MOVD $1551, R12 - B callbackasm1(SB) - MOVD $1552, R12 - B callbackasm1(SB) - MOVD $1553, R12 - B callbackasm1(SB) - MOVD $1554, R12 - B callbackasm1(SB) - MOVD $1555, R12 - B callbackasm1(SB) - MOVD $1556, R12 - B callbackasm1(SB) - MOVD $1557, R12 - B callbackasm1(SB) - MOVD $1558, R12 - B callbackasm1(SB) - MOVD $1559, R12 - B callbackasm1(SB) - MOVD $1560, R12 - B callbackasm1(SB) - MOVD $1561, R12 - B callbackasm1(SB) - MOVD $1562, R12 - B callbackasm1(SB) - MOVD $1563, R12 - B callbackasm1(SB) - MOVD $1564, R12 - B callbackasm1(SB) - MOVD $1565, R12 - B callbackasm1(SB) - MOVD $1566, R12 - B callbackasm1(SB) - MOVD $1567, R12 - B callbackasm1(SB) - MOVD $1568, R12 - B callbackasm1(SB) - MOVD $1569, R12 - B callbackasm1(SB) - MOVD $1570, R12 - B callbackasm1(SB) - MOVD $1571, R12 - B callbackasm1(SB) - MOVD $1572, R12 - B callbackasm1(SB) - MOVD $1573, R12 - B callbackasm1(SB) - MOVD $1574, R12 - B callbackasm1(SB) - MOVD $1575, R12 - B callbackasm1(SB) - MOVD $1576, R12 - B callbackasm1(SB) - MOVD $1577, R12 - B callbackasm1(SB) - MOVD $1578, R12 - B callbackasm1(SB) - MOVD $1579, R12 - B callbackasm1(SB) - MOVD $1580, R12 - B callbackasm1(SB) - MOVD $1581, R12 - B callbackasm1(SB) - MOVD $1582, R12 - B callbackasm1(SB) - MOVD $1583, R12 - B callbackasm1(SB) - MOVD $1584, R12 - B callbackasm1(SB) - MOVD $1585, R12 - B callbackasm1(SB) - MOVD $1586, R12 - B callbackasm1(SB) - MOVD $1587, R12 - B callbackasm1(SB) - MOVD $1588, R12 - B callbackasm1(SB) - MOVD $1589, R12 - B callbackasm1(SB) - MOVD $1590, R12 - B callbackasm1(SB) - MOVD $1591, R12 - B callbackasm1(SB) - MOVD $1592, R12 - B callbackasm1(SB) - MOVD $1593, R12 - B callbackasm1(SB) - MOVD $1594, R12 - B callbackasm1(SB) - MOVD $1595, R12 - B callbackasm1(SB) - MOVD $1596, R12 - B callbackasm1(SB) - MOVD $1597, R12 - B callbackasm1(SB) - MOVD $1598, R12 - B callbackasm1(SB) - MOVD $1599, R12 - B callbackasm1(SB) - MOVD $1600, R12 - B callbackasm1(SB) - MOVD $1601, R12 - B callbackasm1(SB) - MOVD $1602, R12 - B callbackasm1(SB) - MOVD $1603, R12 - B callbackasm1(SB) - MOVD $1604, R12 - B callbackasm1(SB) - MOVD $1605, R12 - B callbackasm1(SB) - MOVD $1606, R12 - B callbackasm1(SB) - MOVD $1607, R12 - B callbackasm1(SB) - MOVD $1608, R12 - B callbackasm1(SB) - MOVD $1609, R12 - B callbackasm1(SB) - MOVD $1610, R12 - B callbackasm1(SB) - MOVD $1611, R12 - B callbackasm1(SB) - MOVD $1612, R12 - B callbackasm1(SB) - MOVD $1613, R12 - B callbackasm1(SB) - MOVD $1614, R12 - B callbackasm1(SB) - MOVD $1615, R12 - B callbackasm1(SB) - MOVD $1616, R12 - B callbackasm1(SB) - MOVD $1617, R12 - B callbackasm1(SB) - MOVD $1618, R12 - B callbackasm1(SB) - MOVD $1619, R12 - B callbackasm1(SB) - MOVD $1620, R12 - B callbackasm1(SB) - MOVD $1621, R12 - B callbackasm1(SB) - MOVD $1622, R12 - B callbackasm1(SB) - MOVD $1623, R12 - B callbackasm1(SB) - MOVD $1624, R12 - B callbackasm1(SB) - MOVD $1625, R12 - B callbackasm1(SB) - MOVD $1626, R12 - B callbackasm1(SB) - MOVD $1627, R12 - B callbackasm1(SB) - MOVD $1628, R12 - B callbackasm1(SB) - MOVD $1629, R12 - B callbackasm1(SB) - MOVD $1630, R12 - B callbackasm1(SB) - MOVD $1631, R12 - B callbackasm1(SB) - MOVD $1632, R12 - B callbackasm1(SB) - MOVD $1633, R12 - B callbackasm1(SB) - MOVD $1634, R12 - B callbackasm1(SB) - MOVD $1635, R12 - B callbackasm1(SB) - MOVD $1636, R12 - B callbackasm1(SB) - MOVD $1637, R12 - B callbackasm1(SB) - MOVD $1638, R12 - B callbackasm1(SB) - MOVD $1639, R12 - B callbackasm1(SB) - MOVD $1640, R12 - B callbackasm1(SB) - MOVD $1641, R12 - B callbackasm1(SB) - MOVD $1642, R12 - B callbackasm1(SB) - MOVD $1643, R12 - B callbackasm1(SB) - MOVD $1644, R12 - B callbackasm1(SB) - MOVD $1645, R12 - B callbackasm1(SB) - MOVD $1646, R12 - B callbackasm1(SB) - MOVD $1647, R12 - B callbackasm1(SB) - MOVD $1648, R12 - B callbackasm1(SB) - MOVD $1649, R12 - B callbackasm1(SB) - MOVD $1650, R12 - B callbackasm1(SB) - MOVD $1651, R12 - B callbackasm1(SB) - MOVD $1652, R12 - B callbackasm1(SB) - MOVD $1653, R12 - B callbackasm1(SB) - MOVD $1654, R12 - B callbackasm1(SB) - MOVD $1655, R12 - B callbackasm1(SB) - MOVD $1656, R12 - B callbackasm1(SB) - MOVD $1657, R12 - B callbackasm1(SB) - MOVD $1658, R12 - B callbackasm1(SB) - MOVD $1659, R12 - B callbackasm1(SB) - MOVD $1660, R12 - B callbackasm1(SB) - MOVD $1661, R12 - B callbackasm1(SB) - MOVD $1662, R12 - B callbackasm1(SB) - MOVD $1663, R12 - B callbackasm1(SB) - MOVD $1664, R12 - B callbackasm1(SB) - MOVD $1665, R12 - B callbackasm1(SB) - MOVD $1666, R12 - B callbackasm1(SB) - MOVD $1667, R12 - B callbackasm1(SB) - MOVD $1668, R12 - B callbackasm1(SB) - MOVD $1669, R12 - B callbackasm1(SB) - MOVD $1670, R12 - B callbackasm1(SB) - MOVD $1671, R12 - B callbackasm1(SB) - MOVD $1672, R12 - B callbackasm1(SB) - MOVD $1673, R12 - B callbackasm1(SB) - MOVD $1674, R12 - B callbackasm1(SB) - MOVD $1675, R12 - B callbackasm1(SB) - MOVD $1676, R12 - B callbackasm1(SB) - MOVD $1677, R12 - B callbackasm1(SB) - MOVD $1678, R12 - B callbackasm1(SB) - MOVD $1679, R12 - B callbackasm1(SB) - MOVD $1680, R12 - B callbackasm1(SB) - MOVD $1681, R12 - B callbackasm1(SB) - MOVD $1682, R12 - B callbackasm1(SB) - MOVD $1683, R12 - B callbackasm1(SB) - MOVD $1684, R12 - B callbackasm1(SB) - MOVD $1685, R12 - B callbackasm1(SB) - MOVD $1686, R12 - B callbackasm1(SB) - MOVD $1687, R12 - B callbackasm1(SB) - MOVD $1688, R12 - B callbackasm1(SB) - MOVD $1689, R12 - B callbackasm1(SB) - MOVD $1690, R12 - B callbackasm1(SB) - MOVD $1691, R12 - B callbackasm1(SB) - MOVD $1692, R12 - B callbackasm1(SB) - MOVD $1693, R12 - B callbackasm1(SB) - MOVD $1694, R12 - B callbackasm1(SB) - MOVD $1695, R12 - B callbackasm1(SB) - MOVD $1696, R12 - B callbackasm1(SB) - MOVD $1697, R12 - B callbackasm1(SB) - MOVD $1698, R12 - B callbackasm1(SB) - MOVD $1699, R12 - B callbackasm1(SB) - MOVD $1700, R12 - B callbackasm1(SB) - MOVD $1701, R12 - B callbackasm1(SB) - MOVD $1702, R12 - B callbackasm1(SB) - MOVD $1703, R12 - B callbackasm1(SB) - MOVD $1704, R12 - B callbackasm1(SB) - MOVD $1705, R12 - B callbackasm1(SB) - MOVD $1706, R12 - B callbackasm1(SB) - MOVD $1707, R12 - B callbackasm1(SB) - MOVD $1708, R12 - B callbackasm1(SB) - MOVD $1709, R12 - B callbackasm1(SB) - MOVD $1710, R12 - B callbackasm1(SB) - MOVD $1711, R12 - B callbackasm1(SB) - MOVD $1712, R12 - B callbackasm1(SB) - MOVD $1713, R12 - B callbackasm1(SB) - MOVD $1714, R12 - B callbackasm1(SB) - MOVD $1715, R12 - B callbackasm1(SB) - MOVD $1716, R12 - B callbackasm1(SB) - MOVD $1717, R12 - B callbackasm1(SB) - MOVD $1718, R12 - B callbackasm1(SB) - MOVD $1719, R12 - B callbackasm1(SB) - MOVD $1720, R12 - B callbackasm1(SB) - MOVD $1721, R12 - B callbackasm1(SB) - MOVD $1722, R12 - B callbackasm1(SB) - MOVD $1723, R12 - B callbackasm1(SB) - MOVD $1724, R12 - B callbackasm1(SB) - MOVD $1725, R12 - B callbackasm1(SB) - MOVD $1726, R12 - B callbackasm1(SB) - MOVD $1727, R12 - B callbackasm1(SB) - MOVD $1728, R12 - B callbackasm1(SB) - MOVD $1729, R12 - B callbackasm1(SB) - MOVD $1730, R12 - B callbackasm1(SB) - MOVD $1731, R12 - B callbackasm1(SB) - MOVD $1732, R12 - B callbackasm1(SB) - MOVD $1733, R12 - B callbackasm1(SB) - MOVD $1734, R12 - B callbackasm1(SB) - MOVD $1735, R12 - B callbackasm1(SB) - MOVD $1736, R12 - B callbackasm1(SB) - MOVD $1737, R12 - B callbackasm1(SB) - MOVD $1738, R12 - B callbackasm1(SB) - MOVD $1739, R12 - B callbackasm1(SB) - MOVD $1740, R12 - B callbackasm1(SB) - MOVD $1741, R12 - B callbackasm1(SB) - MOVD $1742, R12 - B callbackasm1(SB) - MOVD $1743, R12 - B callbackasm1(SB) - MOVD $1744, R12 - B callbackasm1(SB) - MOVD $1745, R12 - B callbackasm1(SB) - MOVD $1746, R12 - B callbackasm1(SB) - MOVD $1747, R12 - B callbackasm1(SB) - MOVD $1748, R12 - B callbackasm1(SB) - MOVD $1749, R12 - B callbackasm1(SB) - MOVD $1750, R12 - B callbackasm1(SB) - MOVD $1751, R12 - B callbackasm1(SB) - MOVD $1752, R12 - B callbackasm1(SB) - MOVD $1753, R12 - B callbackasm1(SB) - MOVD $1754, R12 - B callbackasm1(SB) - MOVD $1755, R12 - B callbackasm1(SB) - MOVD $1756, R12 - B callbackasm1(SB) - MOVD $1757, R12 - B callbackasm1(SB) - MOVD $1758, R12 - B callbackasm1(SB) - MOVD $1759, R12 - B callbackasm1(SB) - MOVD $1760, R12 - B callbackasm1(SB) - MOVD $1761, R12 - B callbackasm1(SB) - MOVD $1762, R12 - B callbackasm1(SB) - MOVD $1763, R12 - B callbackasm1(SB) - MOVD $1764, R12 - B callbackasm1(SB) - MOVD $1765, R12 - B callbackasm1(SB) - MOVD $1766, R12 - B callbackasm1(SB) - MOVD $1767, R12 - B callbackasm1(SB) - MOVD $1768, R12 - B callbackasm1(SB) - MOVD $1769, R12 - B callbackasm1(SB) - MOVD $1770, R12 - B callbackasm1(SB) - MOVD $1771, R12 - B callbackasm1(SB) - MOVD $1772, R12 - B callbackasm1(SB) - MOVD $1773, R12 - B callbackasm1(SB) - MOVD $1774, R12 - B callbackasm1(SB) - MOVD $1775, R12 - B callbackasm1(SB) - MOVD $1776, R12 - B callbackasm1(SB) - MOVD $1777, R12 - B callbackasm1(SB) - MOVD $1778, R12 - B callbackasm1(SB) - MOVD $1779, R12 - B callbackasm1(SB) - MOVD $1780, R12 - B callbackasm1(SB) - MOVD $1781, R12 - B callbackasm1(SB) - MOVD $1782, R12 - B callbackasm1(SB) - MOVD $1783, R12 - B callbackasm1(SB) - MOVD $1784, R12 - B callbackasm1(SB) - MOVD $1785, R12 - B callbackasm1(SB) - MOVD $1786, R12 - B callbackasm1(SB) - MOVD $1787, R12 - B callbackasm1(SB) - MOVD $1788, R12 - B callbackasm1(SB) - MOVD $1789, R12 - B callbackasm1(SB) - MOVD $1790, R12 - B callbackasm1(SB) - MOVD $1791, R12 - B callbackasm1(SB) - MOVD $1792, R12 - B callbackasm1(SB) - MOVD $1793, R12 - B callbackasm1(SB) - MOVD $1794, R12 - B callbackasm1(SB) - MOVD $1795, R12 - B callbackasm1(SB) - MOVD $1796, R12 - B callbackasm1(SB) - MOVD $1797, R12 - B callbackasm1(SB) - MOVD $1798, R12 - B callbackasm1(SB) - MOVD $1799, R12 - B callbackasm1(SB) - MOVD $1800, R12 - B callbackasm1(SB) - MOVD $1801, R12 - B callbackasm1(SB) - MOVD $1802, R12 - B callbackasm1(SB) - MOVD $1803, R12 - B callbackasm1(SB) - MOVD $1804, R12 - B callbackasm1(SB) - MOVD $1805, R12 - B callbackasm1(SB) - MOVD $1806, R12 - B callbackasm1(SB) - MOVD $1807, R12 - B callbackasm1(SB) - MOVD $1808, R12 - B callbackasm1(SB) - MOVD $1809, R12 - B callbackasm1(SB) - MOVD $1810, R12 - B callbackasm1(SB) - MOVD $1811, R12 - B callbackasm1(SB) - MOVD $1812, R12 - B callbackasm1(SB) - MOVD $1813, R12 - B callbackasm1(SB) - MOVD $1814, R12 - B callbackasm1(SB) - MOVD $1815, R12 - B callbackasm1(SB) - MOVD $1816, R12 - B callbackasm1(SB) - MOVD $1817, R12 - B callbackasm1(SB) - MOVD $1818, R12 - B callbackasm1(SB) - MOVD $1819, R12 - B callbackasm1(SB) - MOVD $1820, R12 - B callbackasm1(SB) - MOVD $1821, R12 - B callbackasm1(SB) - MOVD $1822, R12 - B callbackasm1(SB) - MOVD $1823, R12 - B callbackasm1(SB) - MOVD $1824, R12 - B callbackasm1(SB) - MOVD $1825, R12 - B callbackasm1(SB) - MOVD $1826, R12 - B callbackasm1(SB) - MOVD $1827, R12 - B callbackasm1(SB) - MOVD $1828, R12 - B callbackasm1(SB) - MOVD $1829, R12 - B callbackasm1(SB) - MOVD $1830, R12 - B callbackasm1(SB) - MOVD $1831, R12 - B callbackasm1(SB) - MOVD $1832, R12 - B callbackasm1(SB) - MOVD $1833, R12 - B callbackasm1(SB) - MOVD $1834, R12 - B callbackasm1(SB) - MOVD $1835, R12 - B callbackasm1(SB) - MOVD $1836, R12 - B callbackasm1(SB) - MOVD $1837, R12 - B callbackasm1(SB) - MOVD $1838, R12 - B callbackasm1(SB) - MOVD $1839, R12 - B callbackasm1(SB) - MOVD $1840, R12 - B callbackasm1(SB) - MOVD $1841, R12 - B callbackasm1(SB) - MOVD $1842, R12 - B callbackasm1(SB) - MOVD $1843, R12 - B callbackasm1(SB) - MOVD $1844, R12 - B callbackasm1(SB) - MOVD $1845, R12 - B callbackasm1(SB) - MOVD $1846, R12 - B callbackasm1(SB) - MOVD $1847, R12 - B callbackasm1(SB) - MOVD $1848, R12 - B callbackasm1(SB) - MOVD $1849, R12 - B callbackasm1(SB) - MOVD $1850, R12 - B callbackasm1(SB) - MOVD $1851, R12 - B callbackasm1(SB) - MOVD $1852, R12 - B callbackasm1(SB) - MOVD $1853, R12 - B callbackasm1(SB) - MOVD $1854, R12 - B callbackasm1(SB) - MOVD $1855, R12 - B callbackasm1(SB) - MOVD $1856, R12 - B callbackasm1(SB) - MOVD $1857, R12 - B callbackasm1(SB) - MOVD $1858, R12 - B callbackasm1(SB) - MOVD $1859, R12 - B callbackasm1(SB) - MOVD $1860, R12 - B callbackasm1(SB) - MOVD $1861, R12 - B callbackasm1(SB) - MOVD $1862, R12 - B callbackasm1(SB) - MOVD $1863, R12 - B callbackasm1(SB) - MOVD $1864, R12 - B callbackasm1(SB) - MOVD $1865, R12 - B callbackasm1(SB) - MOVD $1866, R12 - B callbackasm1(SB) - MOVD $1867, R12 - B callbackasm1(SB) - MOVD $1868, R12 - B callbackasm1(SB) - MOVD $1869, R12 - B callbackasm1(SB) - MOVD $1870, R12 - B callbackasm1(SB) - MOVD $1871, R12 - B callbackasm1(SB) - MOVD $1872, R12 - B callbackasm1(SB) - MOVD $1873, R12 - B callbackasm1(SB) - MOVD $1874, R12 - B callbackasm1(SB) - MOVD $1875, R12 - B callbackasm1(SB) - MOVD $1876, R12 - B callbackasm1(SB) - MOVD $1877, R12 - B callbackasm1(SB) - MOVD $1878, R12 - B callbackasm1(SB) - MOVD $1879, R12 - B callbackasm1(SB) - MOVD $1880, R12 - B callbackasm1(SB) - MOVD $1881, R12 - B callbackasm1(SB) - MOVD $1882, R12 - B callbackasm1(SB) - MOVD $1883, R12 - B callbackasm1(SB) - MOVD $1884, R12 - B callbackasm1(SB) - MOVD $1885, R12 - B callbackasm1(SB) - MOVD $1886, R12 - B callbackasm1(SB) - MOVD $1887, R12 - B callbackasm1(SB) - MOVD $1888, R12 - B callbackasm1(SB) - MOVD $1889, R12 - B callbackasm1(SB) - MOVD $1890, R12 - B callbackasm1(SB) - MOVD $1891, R12 - B callbackasm1(SB) - MOVD $1892, R12 - B callbackasm1(SB) - MOVD $1893, R12 - B callbackasm1(SB) - MOVD $1894, R12 - B callbackasm1(SB) - MOVD $1895, R12 - B callbackasm1(SB) - MOVD $1896, R12 - B callbackasm1(SB) - MOVD $1897, R12 - B callbackasm1(SB) - MOVD $1898, R12 - B callbackasm1(SB) - MOVD $1899, R12 - B callbackasm1(SB) - MOVD $1900, R12 - B callbackasm1(SB) - MOVD $1901, R12 - B callbackasm1(SB) - MOVD $1902, R12 - B callbackasm1(SB) - MOVD $1903, R12 - B callbackasm1(SB) - MOVD $1904, R12 - B callbackasm1(SB) - MOVD $1905, R12 - B callbackasm1(SB) - MOVD $1906, R12 - B callbackasm1(SB) - MOVD $1907, R12 - B callbackasm1(SB) - MOVD $1908, R12 - B callbackasm1(SB) - MOVD $1909, R12 - B callbackasm1(SB) - MOVD $1910, R12 - B callbackasm1(SB) - MOVD $1911, R12 - B callbackasm1(SB) - MOVD $1912, R12 - B callbackasm1(SB) - MOVD $1913, R12 - B callbackasm1(SB) - MOVD $1914, R12 - B callbackasm1(SB) - MOVD $1915, R12 - B callbackasm1(SB) - MOVD $1916, R12 - B callbackasm1(SB) - MOVD $1917, R12 - B callbackasm1(SB) - MOVD $1918, R12 - B callbackasm1(SB) - MOVD $1919, R12 - B callbackasm1(SB) - MOVD $1920, R12 - B callbackasm1(SB) - MOVD $1921, R12 - B callbackasm1(SB) - MOVD $1922, R12 - B callbackasm1(SB) - MOVD $1923, R12 - B callbackasm1(SB) - MOVD $1924, R12 - B callbackasm1(SB) - MOVD $1925, R12 - B callbackasm1(SB) - MOVD $1926, R12 - B callbackasm1(SB) - MOVD $1927, R12 - B callbackasm1(SB) - MOVD $1928, R12 - B callbackasm1(SB) - MOVD $1929, R12 - B callbackasm1(SB) - MOVD $1930, R12 - B callbackasm1(SB) - MOVD $1931, R12 - B callbackasm1(SB) - MOVD $1932, R12 - B callbackasm1(SB) - MOVD $1933, R12 - B callbackasm1(SB) - MOVD $1934, R12 - B callbackasm1(SB) - MOVD $1935, R12 - B callbackasm1(SB) - MOVD $1936, R12 - B callbackasm1(SB) - MOVD $1937, R12 - B callbackasm1(SB) - MOVD $1938, R12 - B callbackasm1(SB) - MOVD $1939, R12 - B callbackasm1(SB) - MOVD $1940, R12 - B callbackasm1(SB) - MOVD $1941, R12 - B callbackasm1(SB) - MOVD $1942, R12 - B callbackasm1(SB) - MOVD $1943, R12 - B callbackasm1(SB) - MOVD $1944, R12 - B callbackasm1(SB) - MOVD $1945, R12 - B callbackasm1(SB) - MOVD $1946, R12 - B callbackasm1(SB) - MOVD $1947, R12 - B callbackasm1(SB) - MOVD $1948, R12 - B callbackasm1(SB) - MOVD $1949, R12 - B callbackasm1(SB) - MOVD $1950, R12 - B callbackasm1(SB) - MOVD $1951, R12 - B callbackasm1(SB) - MOVD $1952, R12 - B callbackasm1(SB) - MOVD $1953, R12 - B callbackasm1(SB) - MOVD $1954, R12 - B callbackasm1(SB) - MOVD $1955, R12 - B callbackasm1(SB) - MOVD $1956, R12 - B callbackasm1(SB) - MOVD $1957, R12 - B callbackasm1(SB) - MOVD $1958, R12 - B callbackasm1(SB) - MOVD $1959, R12 - B callbackasm1(SB) - MOVD $1960, R12 - B callbackasm1(SB) - MOVD $1961, R12 - B callbackasm1(SB) - MOVD $1962, R12 - B callbackasm1(SB) - MOVD $1963, R12 - B callbackasm1(SB) - MOVD $1964, R12 - B callbackasm1(SB) - MOVD $1965, R12 - B callbackasm1(SB) - MOVD $1966, R12 - B callbackasm1(SB) - MOVD $1967, R12 - B callbackasm1(SB) - MOVD $1968, R12 - B callbackasm1(SB) - MOVD $1969, R12 - B callbackasm1(SB) - MOVD $1970, R12 - B callbackasm1(SB) - MOVD $1971, R12 - B callbackasm1(SB) - MOVD $1972, R12 - B callbackasm1(SB) - MOVD $1973, R12 - B callbackasm1(SB) - MOVD $1974, R12 - B callbackasm1(SB) - MOVD $1975, R12 - B callbackasm1(SB) - MOVD $1976, R12 - B callbackasm1(SB) - MOVD $1977, R12 - B callbackasm1(SB) - MOVD $1978, R12 - B callbackasm1(SB) - MOVD $1979, R12 - B callbackasm1(SB) - MOVD $1980, R12 - B callbackasm1(SB) - MOVD $1981, R12 - B callbackasm1(SB) - MOVD $1982, R12 - B callbackasm1(SB) - MOVD $1983, R12 - B callbackasm1(SB) - MOVD $1984, R12 - B callbackasm1(SB) - MOVD $1985, R12 - B callbackasm1(SB) - MOVD $1986, R12 - B callbackasm1(SB) - MOVD $1987, R12 - B callbackasm1(SB) - MOVD $1988, R12 - B callbackasm1(SB) - MOVD $1989, R12 - B callbackasm1(SB) - MOVD $1990, R12 - B callbackasm1(SB) - MOVD $1991, R12 - B callbackasm1(SB) - MOVD $1992, R12 - B callbackasm1(SB) - MOVD $1993, R12 - B callbackasm1(SB) - MOVD $1994, R12 - B callbackasm1(SB) - MOVD $1995, R12 - B callbackasm1(SB) - MOVD $1996, R12 - B callbackasm1(SB) - MOVD $1997, R12 - B callbackasm1(SB) - MOVD $1998, R12 - B callbackasm1(SB) - MOVD $1999, R12 - B callbackasm1(SB) diff --git a/vendor/github.com/shirou/gopsutil/v4/common/env.go b/vendor/github.com/shirou/gopsutil/v4/common/env.go index 47e471c402f7e..4acad1fd1e8a4 100644 --- a/vendor/github.com/shirou/gopsutil/v4/common/env.go +++ b/vendor/github.com/shirou/gopsutil/v4/common/env.go @@ -12,14 +12,13 @@ type EnvKeyType string var EnvKey = EnvKeyType("env") const ( - HostProcEnvKey EnvKeyType = "HOST_PROC" - HostSysEnvKey EnvKeyType = "HOST_SYS" - HostEtcEnvKey EnvKeyType = "HOST_ETC" - HostVarEnvKey EnvKeyType = "HOST_VAR" - HostRunEnvKey EnvKeyType = "HOST_RUN" - HostDevEnvKey EnvKeyType = "HOST_DEV" - HostRootEnvKey EnvKeyType = "HOST_ROOT" - HostProcMountinfo EnvKeyType = "HOST_PROC_MOUNTINFO" + HostProcEnvKey EnvKeyType = "HOST_PROC" + HostSysEnvKey EnvKeyType = "HOST_SYS" + HostEtcEnvKey EnvKeyType = "HOST_ETC" + HostVarEnvKey EnvKeyType = "HOST_VAR" + HostRunEnvKey EnvKeyType = "HOST_RUN" + HostDevEnvKey EnvKeyType = "HOST_DEV" + HostRootEnvKey EnvKeyType = "HOST_ROOT" ) type EnvMap map[EnvKeyType]string diff --git a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin.go b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin.go index b3e3a668de133..79a458b8e21cc 100644 --- a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin.go +++ b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin.go @@ -5,15 +5,12 @@ package cpu import ( "context" - "fmt" "strconv" "strings" - "unsafe" + "github.com/shoenig/go-m1cpu" "github.com/tklauser/go-sysconf" "golang.org/x/sys/unix" - - "github.com/shirou/gopsutil/v4/internal/common" ) // sys/resource.h @@ -26,24 +23,6 @@ const ( cpUStates = 5 ) -// mach/machine.h -const ( - cpuStateUser = 0 - cpuStateSystem = 1 - cpuStateIdle = 2 - cpuStateNice = 3 - cpuStateMax = 4 -) - -// mach/processor_info.h -const ( - processorCpuLoadInfo = 2 -) - -type hostCpuLoadInfoData struct { - cpuTicks [cpuStateMax]uint32 -} - // default value. from time.h var ClocksPerSec = float64(128) @@ -60,17 +39,11 @@ func Times(percpu bool) ([]TimesStat, error) { } func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) { - lib, err := common.NewLibrary(common.System) - if err != nil { - return nil, err - } - defer lib.Close() - if percpu { - return perCPUTimes(lib) + return perCPUTimes() } - return allCPUTimes(lib) + return allCPUTimes() } // Returns only one CPUInfoStat on FreeBSD @@ -113,9 +86,15 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) { c.CacheSize = int32(cacheSize) c.VendorID, _ = unix.Sysctl("machdep.cpu.vendor") - v, err := getFrequency() - if err == nil { - c.Mhz = v + if m1cpu.IsAppleSilicon() { + c.Mhz = float64(m1cpu.PCoreHz() / 1_000_000) + } else { + // Use the rated frequency of the CPU. This is a static value and does not + // account for low power or Turbo Boost modes. + cpuFrequency, err := unix.SysctlUint64("hw.cpufrequency") + if err == nil { + c.Mhz = float64(cpuFrequency) / 1000000.0 + } } return append(ret, c), nil @@ -136,63 +115,3 @@ func CountsWithContext(ctx context.Context, logical bool) (int, error) { return int(count), nil } - -func perCPUTimes(machLib *common.Library) ([]TimesStat, error) { - machHostSelf := common.GetFunc[common.MachHostSelfFunc](machLib, common.MachHostSelfSym) - machTaskSelf := common.GetFunc[common.MachTaskSelfFunc](machLib, common.MachTaskSelfSym) - hostProcessorInfo := common.GetFunc[common.HostProcessorInfoFunc](machLib, common.HostProcessorInfoSym) - vmDeallocate := common.GetFunc[common.VMDeallocateFunc](machLib, common.VMDeallocateSym) - - var count, ncpu uint32 - var cpuload *hostCpuLoadInfoData - - status := hostProcessorInfo(machHostSelf(), processorCpuLoadInfo, &ncpu, uintptr(unsafe.Pointer(&cpuload)), &count) - - if status != common.KERN_SUCCESS { - return nil, fmt.Errorf("host_processor_info error=%d", status) - } - - defer vmDeallocate(machTaskSelf(), uintptr(unsafe.Pointer(cpuload)), uintptr(ncpu)) - - ret := []TimesStat{} - loads := unsafe.Slice(cpuload, ncpu) - - for i := 0; i < int(ncpu); i++ { - c := TimesStat{ - CPU: fmt.Sprintf("cpu%d", i), - User: float64(loads[i].cpuTicks[cpuStateUser]) / ClocksPerSec, - System: float64(loads[i].cpuTicks[cpuStateSystem]) / ClocksPerSec, - Nice: float64(loads[i].cpuTicks[cpuStateNice]) / ClocksPerSec, - Idle: float64(loads[i].cpuTicks[cpuStateIdle]) / ClocksPerSec, - } - - ret = append(ret, c) - } - - return ret, nil -} - -func allCPUTimes(machLib *common.Library) ([]TimesStat, error) { - machHostSelf := common.GetFunc[common.MachHostSelfFunc](machLib, common.MachHostSelfSym) - hostStatistics := common.GetFunc[common.HostStatisticsFunc](machLib, common.HostStatisticsSym) - - var cpuload hostCpuLoadInfoData - count := uint32(cpuStateMax) - - status := hostStatistics(machHostSelf(), common.HOST_CPU_LOAD_INFO, - uintptr(unsafe.Pointer(&cpuload)), &count) - - if status != common.KERN_SUCCESS { - return nil, fmt.Errorf("host_statistics error=%d", status) - } - - c := TimesStat{ - CPU: "cpu-total", - User: float64(cpuload.cpuTicks[cpuStateUser]) / ClocksPerSec, - System: float64(cpuload.cpuTicks[cpuStateSystem]) / ClocksPerSec, - Nice: float64(cpuload.cpuTicks[cpuStateNice]) / ClocksPerSec, - Idle: float64(cpuload.cpuTicks[cpuStateIdle]) / ClocksPerSec, - } - - return []TimesStat{c}, nil -} diff --git a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin_arm64.go b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin_arm64.go deleted file mode 100644 index 5031842439092..0000000000000 --- a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin_arm64.go +++ /dev/null @@ -1,80 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -//go:build darwin && arm64 - -package cpu - -import ( - "encoding/binary" - "fmt" - "unsafe" - - "github.com/shirou/gopsutil/v4/internal/common" -) - -// https://github.com/shoenig/go-m1cpu/blob/v0.1.6/cpu.go -func getFrequency() (float64, error) { - ioKit, err := common.NewLibrary(common.IOKit) - if err != nil { - return 0, err - } - defer ioKit.Close() - - coreFoundation, err := common.NewLibrary(common.CoreFoundation) - if err != nil { - return 0, err - } - defer coreFoundation.Close() - - ioServiceMatching := common.GetFunc[common.IOServiceMatchingFunc](ioKit, common.IOServiceMatchingSym) - ioServiceGetMatchingServices := common.GetFunc[common.IOServiceGetMatchingServicesFunc](ioKit, common.IOServiceGetMatchingServicesSym) - ioIteratorNext := common.GetFunc[common.IOIteratorNextFunc](ioKit, common.IOIteratorNextSym) - ioRegistryEntryGetName := common.GetFunc[common.IORegistryEntryGetNameFunc](ioKit, common.IORegistryEntryGetNameSym) - ioRegistryEntryCreateCFProperty := common.GetFunc[common.IORegistryEntryCreateCFPropertyFunc](ioKit, common.IORegistryEntryCreateCFPropertySym) - ioObjectRelease := common.GetFunc[common.IOObjectReleaseFunc](ioKit, common.IOObjectReleaseSym) - - cfStringCreateWithCString := common.GetFunc[common.CFStringCreateWithCStringFunc](coreFoundation, common.CFStringCreateWithCStringSym) - cfDataGetLength := common.GetFunc[common.CFDataGetLengthFunc](coreFoundation, common.CFDataGetLengthSym) - cfDataGetBytePtr := common.GetFunc[common.CFDataGetBytePtrFunc](coreFoundation, common.CFDataGetBytePtrSym) - cfRelease := common.GetFunc[common.CFReleaseFunc](coreFoundation, common.CFReleaseSym) - - matching := ioServiceMatching("AppleARMIODevice") - - var iterator uint32 - if status := ioServiceGetMatchingServices(common.KIOMainPortDefault, uintptr(matching), &iterator); status != common.KERN_SUCCESS { - return 0.0, fmt.Errorf("IOServiceGetMatchingServices error=%d", status) - } - defer ioObjectRelease(iterator) - - pCorekey := cfStringCreateWithCString(common.KCFAllocatorDefault, "voltage-states5-sram", common.KCFStringEncodingUTF8) - defer cfRelease(uintptr(pCorekey)) - - var pCoreHz uint32 - for { - service := ioIteratorNext(iterator) - if !(service > 0) { - break - } - - buf := make([]byte, 512) - ioRegistryEntryGetName(service, &buf[0]) - - if common.GoString(&buf[0]) == "pmgr" { - pCoreRef := ioRegistryEntryCreateCFProperty(service, uintptr(pCorekey), common.KCFAllocatorDefault, common.KNilOptions) - length := cfDataGetLength(uintptr(pCoreRef)) - data := cfDataGetBytePtr(uintptr(pCoreRef)) - - // composite uint32 from the byte array - buf := unsafe.Slice((*byte)(data), length) - - // combine the bytes into a uint32 value - b := buf[length-8 : length-4] - pCoreHz = binary.LittleEndian.Uint32(b) - ioObjectRelease(service) - break - } - - ioObjectRelease(service) - } - - return float64(pCoreHz / 1_000_000), nil -} diff --git a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin_cgo.go b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin_cgo.go new file mode 100644 index 0000000000000..3a02024c5be46 --- /dev/null +++ b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin_cgo.go @@ -0,0 +1,111 @@ +// SPDX-License-Identifier: BSD-3-Clause +//go:build darwin && cgo + +package cpu + +/* +#include +#include +#include +#include +#include +#include +#include +#if TARGET_OS_MAC +#include +#endif +#include +#include +*/ +import "C" + +import ( + "bytes" + "encoding/binary" + "fmt" + "unsafe" +) + +// these CPU times for darwin is borrowed from influxdb/telegraf. + +func perCPUTimes() ([]TimesStat, error) { + var ( + count C.mach_msg_type_number_t + cpuload *C.processor_cpu_load_info_data_t + ncpu C.natural_t + ) + + status := C.host_processor_info(C.host_t(C.mach_host_self()), + C.PROCESSOR_CPU_LOAD_INFO, + &ncpu, + (*C.processor_info_array_t)(unsafe.Pointer(&cpuload)), + &count) + + if status != C.KERN_SUCCESS { + return nil, fmt.Errorf("host_processor_info error=%d", status) + } + + // jump through some cgo casting hoops and ensure we properly free + // the memory that cpuload points to + target := C.vm_map_t(C.mach_task_self_) + address := C.vm_address_t(uintptr(unsafe.Pointer(cpuload))) + defer C.vm_deallocate(target, address, C.vm_size_t(ncpu)) + + // the body of struct processor_cpu_load_info + // aka processor_cpu_load_info_data_t + var cpu_ticks [C.CPU_STATE_MAX]uint32 + + // copy the cpuload array to a []byte buffer + // where we can binary.Read the data + size := int(ncpu) * binary.Size(cpu_ticks) + buf := (*[1 << 30]byte)(unsafe.Pointer(cpuload))[:size:size] + + bbuf := bytes.NewBuffer(buf) + + var ret []TimesStat + + for i := 0; i < int(ncpu); i++ { + err := binary.Read(bbuf, binary.LittleEndian, &cpu_ticks) + if err != nil { + return nil, err + } + + c := TimesStat{ + CPU: fmt.Sprintf("cpu%d", i), + User: float64(cpu_ticks[C.CPU_STATE_USER]) / ClocksPerSec, + System: float64(cpu_ticks[C.CPU_STATE_SYSTEM]) / ClocksPerSec, + Nice: float64(cpu_ticks[C.CPU_STATE_NICE]) / ClocksPerSec, + Idle: float64(cpu_ticks[C.CPU_STATE_IDLE]) / ClocksPerSec, + } + + ret = append(ret, c) + } + + return ret, nil +} + +func allCPUTimes() ([]TimesStat, error) { + var count C.mach_msg_type_number_t + var cpuload C.host_cpu_load_info_data_t + + count = C.HOST_CPU_LOAD_INFO_COUNT + + status := C.host_statistics(C.host_t(C.mach_host_self()), + C.HOST_CPU_LOAD_INFO, + C.host_info_t(unsafe.Pointer(&cpuload)), + &count) + + if status != C.KERN_SUCCESS { + return nil, fmt.Errorf("host_statistics error=%d", status) + } + + c := TimesStat{ + CPU: "cpu-total", + User: float64(cpuload.cpu_ticks[C.CPU_STATE_USER]) / ClocksPerSec, + System: float64(cpuload.cpu_ticks[C.CPU_STATE_SYSTEM]) / ClocksPerSec, + Nice: float64(cpuload.cpu_ticks[C.CPU_STATE_NICE]) / ClocksPerSec, + Idle: float64(cpuload.cpu_ticks[C.CPU_STATE_IDLE]) / ClocksPerSec, + } + + return []TimesStat{c}, nil +} diff --git a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin_fallback.go b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin_fallback.go deleted file mode 100644 index b9e52aba1762c..0000000000000 --- a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin_fallback.go +++ /dev/null @@ -1,13 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -//go:build darwin && !arm64 - -package cpu - -import "golang.org/x/sys/unix" - -func getFrequency() (float64, error) { - // Use the rated frequency of the CPU. This is a static value and does not - // account for low power or Turbo Boost modes. - cpuFrequency, err := unix.SysctlUint64("hw.cpufrequency") - return float64(cpuFrequency) / 1000000.0, err -} diff --git a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin_nocgo.go b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin_nocgo.go new file mode 100644 index 0000000000000..1af8566a67bef --- /dev/null +++ b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin_nocgo.go @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: BSD-3-Clause +//go:build darwin && !cgo + +package cpu + +import "github.com/shirou/gopsutil/v4/internal/common" + +func perCPUTimes() ([]TimesStat, error) { + return []TimesStat{}, common.ErrNotImplementedError +} + +func allCPUTimes() ([]TimesStat, error) { + return []TimesStat{}, common.ErrNotImplementedError +} diff --git a/vendor/github.com/shirou/gopsutil/v4/internal/common/common_darwin.go b/vendor/github.com/shirou/gopsutil/v4/internal/common/common_darwin.go index b473f88666eba..53f9ae8d9a5a4 100644 --- a/vendor/github.com/shirou/gopsutil/v4/internal/common/common_darwin.go +++ b/vendor/github.com/shirou/gopsutil/v4/internal/common/common_darwin.go @@ -5,13 +5,11 @@ package common import ( "context" - "fmt" "os" "os/exec" "strings" "unsafe" - "github.com/ebitengine/purego" "golang.org/x/sys/unix" ) @@ -66,299 +64,3 @@ func CallSyscall(mib []int32) ([]byte, uint64, error) { return buf, length, nil } - -// Library represents a dynamic library loaded by purego. -type Library struct { - addr uintptr - path string - close func() -} - -// library paths -const ( - IOKit = "/System/Library/Frameworks/IOKit.framework/IOKit" - CoreFoundation = "/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation" - System = "/usr/lib/libSystem.B.dylib" -) - -func NewLibrary(path string) (*Library, error) { - lib, err := purego.Dlopen(path, purego.RTLD_LAZY|purego.RTLD_GLOBAL) - if err != nil { - return nil, err - } - - closeFunc := func() { - purego.Dlclose(lib) - } - - return &Library{ - addr: lib, - path: path, - close: closeFunc, - }, nil -} - -func (lib *Library) Dlsym(symbol string) (uintptr, error) { - return purego.Dlsym(lib.addr, symbol) -} - -func GetFunc[T any](lib *Library, symbol string) T { - var fptr T - purego.RegisterLibFunc(&fptr, lib.addr, symbol) - return fptr -} - -func (lib *Library) Close() { - lib.close() -} - -// status codes -const ( - KERN_SUCCESS = 0 -) - -// IOKit functions and symbols. -type ( - IOServiceGetMatchingServiceFunc func(mainPort uint32, matching uintptr) uint32 - IOServiceGetMatchingServicesFunc func(mainPort uint32, matching uintptr, existing *uint32) int - IOServiceMatchingFunc func(name string) unsafe.Pointer - IOServiceOpenFunc func(service, owningTask, connType uint32, connect *uint32) int - IOServiceCloseFunc func(connect uint32) int - IOIteratorNextFunc func(iterator uint32) uint32 - IORegistryEntryGetNameFunc func(entry uint32, name *byte) int - IORegistryEntryGetParentEntryFunc func(entry uint32, plane string, parent *uint32) int - IORegistryEntryCreateCFPropertyFunc func(entry uint32, key, allocator uintptr, options uint32) unsafe.Pointer - IORegistryEntryCreateCFPropertiesFunc func(entry uint32, properties unsafe.Pointer, allocator uintptr, options uint32) int - IOObjectConformsToFunc func(object uint32, className string) bool - IOObjectReleaseFunc func(object uint32) int - IOConnectCallStructMethodFunc func(connection, selector uint32, inputStruct, inputStructCnt, outputStruct uintptr, outputStructCnt *uintptr) int - - IOHIDEventSystemClientCreateFunc func(allocator uintptr) unsafe.Pointer - IOHIDEventSystemClientSetMatchingFunc func(client, match uintptr) int - IOHIDServiceClientCopyEventFunc func(service uintptr, eventType int64, - options int32, timeout int64) unsafe.Pointer - IOHIDServiceClientCopyPropertyFunc func(service, property uintptr) unsafe.Pointer - IOHIDEventGetFloatValueFunc func(event uintptr, field int32) float64 - IOHIDEventSystemClientCopyServicesFunc func(client uintptr) unsafe.Pointer -) - -const ( - IOServiceGetMatchingServiceSym = "IOServiceGetMatchingService" - IOServiceGetMatchingServicesSym = "IOServiceGetMatchingServices" - IOServiceMatchingSym = "IOServiceMatching" - IOServiceOpenSym = "IOServiceOpen" - IOServiceCloseSym = "IOServiceClose" - IOIteratorNextSym = "IOIteratorNext" - IORegistryEntryGetNameSym = "IORegistryEntryGetName" - IORegistryEntryGetParentEntrySym = "IORegistryEntryGetParentEntry" - IORegistryEntryCreateCFPropertySym = "IORegistryEntryCreateCFProperty" - IORegistryEntryCreateCFPropertiesSym = "IORegistryEntryCreateCFProperties" - IOObjectConformsToSym = "IOObjectConformsTo" - IOObjectReleaseSym = "IOObjectRelease" - IOConnectCallStructMethodSym = "IOConnectCallStructMethod" - - IOHIDEventSystemClientCreateSym = "IOHIDEventSystemClientCreate" - IOHIDEventSystemClientSetMatchingSym = "IOHIDEventSystemClientSetMatching" - IOHIDServiceClientCopyEventSym = "IOHIDServiceClientCopyEvent" - IOHIDServiceClientCopyPropertySym = "IOHIDServiceClientCopyProperty" - IOHIDEventGetFloatValueSym = "IOHIDEventGetFloatValue" - IOHIDEventSystemClientCopyServicesSym = "IOHIDEventSystemClientCopyServices" -) - -const ( - KIOMainPortDefault = 0 - - KIOHIDEventTypeTemperature = 15 - - KNilOptions = 0 -) - -const ( - KIOMediaWholeKey = "Media" - KIOServicePlane = "IOService" -) - -// CoreFoundation functions and symbols. -type ( - CFGetTypeIDFunc func(cf uintptr) int32 - CFNumberCreateFunc func(allocator uintptr, theType int32, valuePtr uintptr) unsafe.Pointer - CFNumberGetValueFunc func(num uintptr, theType int32, valuePtr uintptr) bool - CFDictionaryCreateFunc func(allocator uintptr, keys, values *unsafe.Pointer, numValues int32, - keyCallBacks, valueCallBacks uintptr) unsafe.Pointer - CFDictionaryAddValueFunc func(theDict, key, value uintptr) - CFDictionaryGetValueFunc func(theDict, key uintptr) unsafe.Pointer - CFArrayGetCountFunc func(theArray uintptr) int32 - CFArrayGetValueAtIndexFunc func(theArray uintptr, index int32) unsafe.Pointer - CFStringCreateMutableFunc func(alloc uintptr, maxLength int32) unsafe.Pointer - CFStringGetLengthFunc func(theString uintptr) int32 - CFStringGetCStringFunc func(theString uintptr, buffer *byte, bufferSize int32, encoding uint32) - CFStringCreateWithCStringFunc func(alloc uintptr, cStr string, encoding uint32) unsafe.Pointer - CFDataGetLengthFunc func(theData uintptr) int32 - CFDataGetBytePtrFunc func(theData uintptr) unsafe.Pointer - CFReleaseFunc func(cf uintptr) -) - -const ( - CFGetTypeIDSym = "CFGetTypeID" - CFNumberCreateSym = "CFNumberCreate" - CFNumberGetValueSym = "CFNumberGetValue" - CFDictionaryCreateSym = "CFDictionaryCreate" - CFDictionaryAddValueSym = "CFDictionaryAddValue" - CFDictionaryGetValueSym = "CFDictionaryGetValue" - CFArrayGetCountSym = "CFArrayGetCount" - CFArrayGetValueAtIndexSym = "CFArrayGetValueAtIndex" - CFStringCreateMutableSym = "CFStringCreateMutable" - CFStringGetLengthSym = "CFStringGetLength" - CFStringGetCStringSym = "CFStringGetCString" - CFStringCreateWithCStringSym = "CFStringCreateWithCString" - CFDataGetLengthSym = "CFDataGetLength" - CFDataGetBytePtrSym = "CFDataGetBytePtr" - CFReleaseSym = "CFRelease" -) - -const ( - KCFStringEncodingUTF8 = 0x08000100 - KCFNumberSInt64Type = 4 - KCFNumberIntType = 9 - KCFAllocatorDefault = 0 -) - -// Kernel functions and symbols. -type MachTimeBaseInfo struct { - Numer uint32 - Denom uint32 -} - -type ( - HostProcessorInfoFunc func(host uint32, flavor int32, outProcessorCount *uint32, outProcessorInfo uintptr, - outProcessorInfoCnt *uint32) int - HostStatisticsFunc func(host uint32, flavor int32, hostInfoOut uintptr, hostInfoOutCnt *uint32) int - MachHostSelfFunc func() uint32 - MachTaskSelfFunc func() uint32 - MachTimeBaseInfoFunc func(info uintptr) int - VMDeallocateFunc func(targetTask uint32, vmAddress, vmSize uintptr) int -) - -const ( - HostProcessorInfoSym = "host_processor_info" - HostStatisticsSym = "host_statistics" - MachHostSelfSym = "mach_host_self" - MachTaskSelfSym = "mach_task_self" - MachTimeBaseInfoSym = "mach_timebase_info" - VMDeallocateSym = "vm_deallocate" -) - -const ( - CTL_KERN = 1 - KERN_ARGMAX = 8 - KERN_PROCARGS2 = 49 - - HOST_VM_INFO = 2 - HOST_CPU_LOAD_INFO = 3 - - HOST_VM_INFO_COUNT = 0xf -) - -// System functions and symbols. -type ( - ProcPidPathFunc func(pid int32, buffer uintptr, bufferSize uint32) int32 - ProcPidInfoFunc func(pid, flavor int32, arg uint64, buffer uintptr, bufferSize int32) int32 -) - -const ( - SysctlSym = "sysctl" - ProcPidPathSym = "proc_pidpath" - ProcPidInfoSym = "proc_pidinfo" -) - -const ( - MAXPATHLEN = 1024 - PROC_PIDPATHINFO_MAXSIZE = 4 * MAXPATHLEN - PROC_PIDTASKINFO = 4 - PROC_PIDVNODEPATHINFO = 9 -) - -// SMC represents a SMC instance. -type SMC struct { - lib *Library - conn uint32 - callStruct IOConnectCallStructMethodFunc -} - -const ioServiceSMC = "AppleSMC" - -const ( - KSMCUserClientOpen = 0 - KSMCUserClientClose = 1 - KSMCHandleYPCEvent = 2 - KSMCReadKey = 5 - KSMCWriteKey = 6 - KSMCGetKeyCount = 7 - KSMCGetKeyFromIndex = 8 - KSMCGetKeyInfo = 9 -) - -const ( - KSMCSuccess = 0 - KSMCError = 1 - KSMCKeyNotFound = 132 -) - -func NewSMC(ioKit *Library) (*SMC, error) { - if ioKit.path != IOKit { - return nil, fmt.Errorf("library is not IOKit") - } - - ioServiceGetMatchingService := GetFunc[IOServiceGetMatchingServiceFunc](ioKit, IOServiceGetMatchingServiceSym) - ioServiceMatching := GetFunc[IOServiceMatchingFunc](ioKit, IOServiceMatchingSym) - ioServiceOpen := GetFunc[IOServiceOpenFunc](ioKit, IOServiceOpenSym) - ioObjectRelease := GetFunc[IOObjectReleaseFunc](ioKit, IOObjectReleaseSym) - machTaskSelf := GetFunc[MachTaskSelfFunc](ioKit, MachTaskSelfSym) - - ioConnectCallStructMethod := GetFunc[IOConnectCallStructMethodFunc](ioKit, IOConnectCallStructMethodSym) - - service := ioServiceGetMatchingService(0, uintptr(ioServiceMatching(ioServiceSMC))) - if service == 0 { - return nil, fmt.Errorf("ERROR: %s NOT FOUND", ioServiceSMC) - } - - var conn uint32 - if result := ioServiceOpen(service, machTaskSelf(), 0, &conn); result != 0 { - return nil, fmt.Errorf("ERROR: IOServiceOpen failed") - } - - ioObjectRelease(service) - return &SMC{ - lib: ioKit, - conn: conn, - callStruct: ioConnectCallStructMethod, - }, nil -} - -func (s *SMC) CallStruct(selector uint32, inputStruct, inputStructCnt, outputStruct uintptr, outputStructCnt *uintptr) int { - return s.callStruct(s.conn, selector, inputStruct, inputStructCnt, outputStruct, outputStructCnt) -} - -func (s *SMC) Close() error { - ioServiceClose := GetFunc[IOServiceCloseFunc](s.lib, IOServiceCloseSym) - - if result := ioServiceClose(s.conn); result != 0 { - return fmt.Errorf("ERROR: IOServiceClose failed") - } - return nil -} - -// https://github.com/ebitengine/purego/blob/main/internal/strings/strings.go#L26 -func GoString(cStr *byte) string { - if cStr == nil { - return "" - } - var length int - for { - if *(*byte)(unsafe.Add(unsafe.Pointer(cStr), uintptr(length))) == '\x00' { - break - } - length++ - } - return string(unsafe.Slice(cStr, length)) -} diff --git a/vendor/github.com/shirou/gopsutil/v4/internal/common/common_unix.go b/vendor/github.com/shirou/gopsutil/v4/internal/common/common_unix.go index c9f91b1698ae1..2715b890bef70 100644 --- a/vendor/github.com/shirou/gopsutil/v4/internal/common/common_unix.go +++ b/vendor/github.com/shirou/gopsutil/v4/internal/common/common_unix.go @@ -40,3 +40,23 @@ func CallLsofWithContext(ctx context.Context, invoke Invoker, pid int32, args .. } return ret, nil } + +func CallPgrepWithContext(ctx context.Context, invoke Invoker, pid int32) ([]int32, error) { + out, err := invoke.CommandWithContext(ctx, "pgrep", "-P", strconv.Itoa(int(pid))) + if err != nil { + return []int32{}, err + } + lines := strings.Split(string(out), "\n") + ret := make([]int32, 0, len(lines)) + for _, l := range lines { + if len(l) == 0 { + continue + } + i, err := strconv.ParseInt(l, 10, 32) + if err != nil { + continue + } + ret = append(ret, int32(i)) + } + return ret, nil +} diff --git a/vendor/github.com/shirou/gopsutil/v4/mem/mem_darwin.go b/vendor/github.com/shirou/gopsutil/v4/mem/mem_darwin.go index a4c15f6915d97..a33c5f125a2b0 100644 --- a/vendor/github.com/shirou/gopsutil/v4/mem/mem_darwin.go +++ b/vendor/github.com/shirou/gopsutil/v4/mem/mem_darwin.go @@ -70,61 +70,3 @@ func SwapDevices() ([]*SwapDevice, error) { func SwapDevicesWithContext(ctx context.Context) ([]*SwapDevice, error) { return nil, common.ErrNotImplementedError } - -type vmStatisticsData struct { - freeCount uint32 - activeCount uint32 - inactiveCount uint32 - wireCount uint32 - _ [44]byte // Not used here -} - -// VirtualMemory returns VirtualmemoryStat. -func VirtualMemory() (*VirtualMemoryStat, error) { - return VirtualMemoryWithContext(context.Background()) -} - -func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) { - machLib, err := common.NewLibrary(common.System) - if err != nil { - return nil, err - } - defer machLib.Close() - - hostStatistics := common.GetFunc[common.HostStatisticsFunc](machLib, common.HostStatisticsSym) - machHostSelf := common.GetFunc[common.MachHostSelfFunc](machLib, common.MachHostSelfSym) - - count := uint32(common.HOST_VM_INFO_COUNT) - var vmstat vmStatisticsData - - status := hostStatistics(machHostSelf(), common.HOST_VM_INFO, - uintptr(unsafe.Pointer(&vmstat)), &count) - - if status != common.KERN_SUCCESS { - return nil, fmt.Errorf("host_statistics error=%d", status) - } - - pageSizeAddr, _ := machLib.Dlsym("vm_kernel_page_size") - pageSize := **(**uint64)(unsafe.Pointer(&pageSizeAddr)) - total, err := getHwMemsize() - if err != nil { - return nil, err - } - totalCount := uint32(total / pageSize) - - availableCount := vmstat.inactiveCount + vmstat.freeCount - usedPercent := 100 * float64(totalCount-availableCount) / float64(totalCount) - - usedCount := totalCount - availableCount - - return &VirtualMemoryStat{ - Total: total, - Available: pageSize * uint64(availableCount), - Used: pageSize * uint64(usedCount), - UsedPercent: usedPercent, - Free: pageSize * uint64(vmstat.freeCount), - Active: pageSize * uint64(vmstat.activeCount), - Inactive: pageSize * uint64(vmstat.inactiveCount), - Wired: pageSize * uint64(vmstat.wireCount), - }, nil -} diff --git a/vendor/github.com/shirou/gopsutil/v4/mem/mem_darwin_cgo.go b/vendor/github.com/shirou/gopsutil/v4/mem/mem_darwin_cgo.go new file mode 100644 index 0000000000000..cc6657d045c13 --- /dev/null +++ b/vendor/github.com/shirou/gopsutil/v4/mem/mem_darwin_cgo.go @@ -0,0 +1,58 @@ +// SPDX-License-Identifier: BSD-3-Clause +//go:build darwin && cgo + +package mem + +/* +#include +#include +*/ +import "C" + +import ( + "context" + "fmt" + "unsafe" +) + +// VirtualMemory returns VirtualmemoryStat. +func VirtualMemory() (*VirtualMemoryStat, error) { + return VirtualMemoryWithContext(context.Background()) +} + +func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) { + count := C.mach_msg_type_number_t(C.HOST_VM_INFO_COUNT) + var vmstat C.vm_statistics_data_t + + status := C.host_statistics(C.host_t(C.mach_host_self()), + C.HOST_VM_INFO, + C.host_info_t(unsafe.Pointer(&vmstat)), + &count) + + if status != C.KERN_SUCCESS { + return nil, fmt.Errorf("host_statistics error=%d", status) + } + + pageSize := uint64(C.vm_kernel_page_size) + total, err := getHwMemsize() + if err != nil { + return nil, err + } + totalCount := C.natural_t(total / pageSize) + + availableCount := vmstat.inactive_count + vmstat.free_count + usedPercent := 100 * float64(totalCount-availableCount) / float64(totalCount) + + usedCount := totalCount - availableCount + + return &VirtualMemoryStat{ + Total: total, + Available: pageSize * uint64(availableCount), + Used: pageSize * uint64(usedCount), + UsedPercent: usedPercent, + Free: pageSize * uint64(vmstat.free_count), + Active: pageSize * uint64(vmstat.active_count), + Inactive: pageSize * uint64(vmstat.inactive_count), + Wired: pageSize * uint64(vmstat.wire_count), + }, nil +} diff --git a/vendor/github.com/shirou/gopsutil/v4/mem/mem_darwin_nocgo.go b/vendor/github.com/shirou/gopsutil/v4/mem/mem_darwin_nocgo.go new file mode 100644 index 0000000000000..097a93e63e4cc --- /dev/null +++ b/vendor/github.com/shirou/gopsutil/v4/mem/mem_darwin_nocgo.go @@ -0,0 +1,89 @@ +// SPDX-License-Identifier: BSD-3-Clause +//go:build darwin && !cgo + +package mem + +import ( + "context" + "strconv" + "strings" + + "golang.org/x/sys/unix" +) + +// Runs vm_stat and returns Free and inactive pages +func getVMStat(vms *VirtualMemoryStat) error { + out, err := invoke.Command("vm_stat") + if err != nil { + return err + } + return parseVMStat(string(out), vms) +} + +func parseVMStat(out string, vms *VirtualMemoryStat) error { + var err error + + lines := strings.Split(out, "\n") + pagesize := uint64(unix.Getpagesize()) + for _, line := range lines { + fields := strings.Split(line, ":") + if len(fields) < 2 { + continue + } + key := strings.TrimSpace(fields[0]) + value := strings.Trim(fields[1], " .") + switch key { + case "Pages free": + free, e := strconv.ParseUint(value, 10, 64) + if e != nil { + err = e + } + vms.Free = free * pagesize + case "Pages inactive": + inactive, e := strconv.ParseUint(value, 10, 64) + if e != nil { + err = e + } + vms.Inactive = inactive * pagesize + case "Pages active": + active, e := strconv.ParseUint(value, 10, 64) + if e != nil { + err = e + } + vms.Active = active * pagesize + case "Pages wired down": + wired, e := strconv.ParseUint(value, 10, 64) + if e != nil { + err = e + } + vms.Wired = wired * pagesize + } + } + return err +} + +// VirtualMemory returns VirtualmemoryStat. +func VirtualMemory() (*VirtualMemoryStat, error) { + return VirtualMemoryWithContext(context.Background()) +} + +func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) { + ret := &VirtualMemoryStat{} + + total, err := getHwMemsize() + if err != nil { + return nil, err + } + err = getVMStat(ret) + if err != nil { + return nil, err + } + + ret.Available = ret.Free + ret.Inactive + ret.Total = total + + ret.Used = ret.Total - ret.Available + ret.UsedPercent = 100 * float64(ret.Used) / float64(ret.Total) + + return ret, nil +} diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process.go b/vendor/github.com/shirou/gopsutil/v4/process/process.go index 70411c61644db..d73f1f972fa99 100644 --- a/vendor/github.com/shirou/gopsutil/v4/process/process.go +++ b/vendor/github.com/shirou/gopsutil/v4/process/process.go @@ -18,7 +18,7 @@ import ( var ( invoke common.Invoker = common.Invoke{} - ErrorNoChildren = errors.New("process does not have children") // Deprecated: ErrorNoChildren is never returned by process.Children(), check its returned []*Process slice length instead + ErrorNoChildren = errors.New("process does not have children") ErrorProcessNotRunning = errors.New("process does not exist") ErrorNotPermitted = errors.New("operation not permitted") ) diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_darwin.go b/vendor/github.com/shirou/gopsutil/v4/process/process_darwin.go index 05c7562b767c1..66b3684eae4af 100644 --- a/vendor/github.com/shirou/gopsutil/v4/process/process_darwin.go +++ b/vendor/github.com/shirou/gopsutil/v4/process/process_darwin.go @@ -4,20 +4,15 @@ package process import ( - "bytes" "context" - "encoding/binary" "fmt" "path/filepath" - "runtime" - "sort" "strconv" "strings" - "unsafe" + "github.com/tklauser/go-sysconf" "golang.org/x/sys/unix" - "github.com/shirou/gopsutil/v4/cpu" "github.com/shirou/gopsutil/v4/internal/common" "github.com/shirou/gopsutil/v4/net" ) @@ -32,6 +27,16 @@ const ( KernProcPathname = 12 // path to executable ) +var clockTicks = 100 // default value + +func init() { + clkTck, err := sysconf.Sysconf(sysconf.SC_CLK_TCK) + // ignore errors + if err == nil { + clockTicks = int(clkTck) + } +} + type _Ctype_struct___0 struct { Pad uint64 } @@ -181,22 +186,65 @@ func (p *Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, e return nil, common.ErrNotImplementedError } +func convertCPUTimes(s string) (ret float64, err error) { + var t int + var _tmp string + if strings.Contains(s, ":") { + _t := strings.Split(s, ":") + switch len(_t) { + case 3: + hour, err := strconv.ParseInt(_t[0], 10, 32) + if err != nil { + return ret, err + } + t += int(hour) * 60 * 60 * clockTicks + + mins, err := strconv.ParseInt(_t[1], 10, 32) + if err != nil { + return ret, err + } + t += int(mins) * 60 * clockTicks + _tmp = _t[2] + case 2: + mins, err := strconv.ParseInt(_t[0], 10, 32) + if err != nil { + return ret, err + } + t += int(mins) * 60 * clockTicks + _tmp = _t[1] + case 1, 0: + _tmp = s + default: + return ret, fmt.Errorf("wrong cpu time string") + } + } else { + _tmp = s + } + + _t := strings.Split(_tmp, ".") + if err != nil { + return ret, err + } + h, err := strconv.ParseInt(_t[0], 10, 32) + t += int(h) * clockTicks + h, err = strconv.ParseInt(_t[1], 10, 32) + t += int(h) + return float64(t) / float64(clockTicks), nil +} + func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) { - procs, err := ProcessesWithContext(ctx) + pids, err := common.CallPgrepWithContext(ctx, invoke, p.Pid) if err != nil { - return nil, nil + return nil, err } - ret := make([]*Process, 0, len(procs)) - for _, proc := range procs { - ppid, err := proc.PpidWithContext(ctx) + ret := make([]*Process, 0, len(pids)) + for _, pid := range pids { + np, err := NewProcessWithContext(ctx, pid) if err != nil { - continue - } - if ppid == p.Pid { - ret = append(ret, proc) + return nil, err } + ret = append(ret, np) } - sort.Slice(ret, func(i, j int) bool { return ret[i].Pid < ret[j].Pid }) return ret, nil } @@ -275,206 +323,3 @@ func callPsWithContext(ctx context.Context, arg string, pid int32, threadOption return ret, nil } - -var ( - procPidPath common.ProcPidPathFunc - procPidInfo common.ProcPidInfoFunc - machTimeBaseInfo common.MachTimeBaseInfoFunc -) - -func registerFuncs() (*common.Library, error) { - lib, err := common.NewLibrary(common.System) - if err != nil { - return nil, err - } - - procPidPath = common.GetFunc[common.ProcPidPathFunc](lib, common.ProcPidPathSym) - procPidInfo = common.GetFunc[common.ProcPidInfoFunc](lib, common.ProcPidInfoSym) - machTimeBaseInfo = common.GetFunc[common.MachTimeBaseInfoFunc](lib, common.MachTimeBaseInfoSym) - - return lib, nil -} - -func getTimeScaleToNanoSeconds() float64 { - var timeBaseInfo common.MachTimeBaseInfo - - machTimeBaseInfo(uintptr(unsafe.Pointer(&timeBaseInfo))) - - return float64(timeBaseInfo.Numer) / float64(timeBaseInfo.Denom) -} - -func (p *Process) ExeWithContext(ctx context.Context) (string, error) { - lib, err := registerFuncs() - if err != nil { - return "", err - } - defer lib.Close() - - buf := make([]byte, common.PROC_PIDPATHINFO_MAXSIZE) - ret := procPidPath(p.Pid, uintptr(unsafe.Pointer(&buf[0])), common.PROC_PIDPATHINFO_MAXSIZE) - - if ret <= 0 { - return "", fmt.Errorf("unknown error: proc_pidpath returned %d", ret) - } - - return common.GoString(&buf[0]), nil -} - -// sys/proc_info.h -type vnodePathInfo struct { - _ [152]byte - vipPath [common.MAXPATHLEN]byte - _ [1176]byte -} - -// CwdWithContext retrieves the Current Working Directory for the given process. -// It uses the proc_pidinfo from libproc and will only work for processes the -// EUID can access. Otherwise "operation not permitted" will be returned as the -// error. -// Note: This might also work for other *BSD OSs. -func (p *Process) CwdWithContext(ctx context.Context) (string, error) { - lib, err := registerFuncs() - if err != nil { - return "", err - } - defer lib.Close() - - runtime.LockOSThread() - defer runtime.UnlockOSThread() - - var vpi vnodePathInfo - const vpiSize = int32(unsafe.Sizeof(vpi)) - ret := procPidInfo(p.Pid, common.PROC_PIDVNODEPATHINFO, 0, uintptr(unsafe.Pointer(&vpi)), vpiSize) - errno, _ := lib.Dlsym("errno") - err = *(**unix.Errno)(unsafe.Pointer(&errno)) - if err == unix.EPERM { - return "", ErrorNotPermitted - } - - if ret <= 0 { - return "", fmt.Errorf("unknown error: proc_pidinfo returned %d", ret) - } - - if ret != vpiSize { - return "", fmt.Errorf("too few bytes; expected %d, got %d", vpiSize, ret) - } - return common.GoString(&vpi.vipPath[0]), nil -} - -func procArgs(pid int32) ([]byte, int, error) { - procargs, _, err := common.CallSyscall([]int32{common.CTL_KERN, common.KERN_PROCARGS2, pid}) - if err != nil { - return nil, 0, err - } - nargs := procargs[:4] - return procargs, int(binary.LittleEndian.Uint32(nargs)), nil -} - -func (p *Process) CmdlineSliceWithContext(ctx context.Context) ([]string, error) { - return p.cmdlineSliceWithContext(ctx, true) -} - -func (p *Process) cmdlineSliceWithContext(ctx context.Context, fallback bool) ([]string, error) { - pargs, nargs, err := procArgs(p.Pid) - if err != nil { - return nil, err - } - // The first bytes hold the nargs int, skip it. - args := bytes.Split((pargs)[unsafe.Sizeof(int(0)):], []byte{0}) - var argStr string - // The first element is the actual binary/command path. - // command := args[0] - var argSlice []string - // var envSlice []string - // All other, non-zero elements are arguments. The first "nargs" elements - // are the arguments. Everything else in the slice is then the environment - // of the process. - for _, arg := range args[1:] { - argStr = string(arg[:]) - if len(argStr) > 0 { - if nargs > 0 { - argSlice = append(argSlice, argStr) - nargs-- - continue - } - break - // envSlice = append(envSlice, argStr) - } - } - return argSlice, err -} - -// cmdNameWithContext returns the command name (including spaces) without any arguments -func (p *Process) cmdNameWithContext(ctx context.Context) (string, error) { - r, err := p.cmdlineSliceWithContext(ctx, false) - if err != nil { - return "", err - } - - if len(r) == 0 { - return "", nil - } - - return r[0], err -} - -func (p *Process) CmdlineWithContext(ctx context.Context) (string, error) { - r, err := p.CmdlineSliceWithContext(ctx) - if err != nil { - return "", err - } - return strings.Join(r, " "), err -} - -func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) { - lib, err := registerFuncs() - if err != nil { - return 0, err - } - defer lib.Close() - - var ti ProcTaskInfo - const tiSize = int32(unsafe.Sizeof(ti)) - procPidInfo(p.Pid, common.PROC_PIDTASKINFO, 0, uintptr(unsafe.Pointer(&ti)), tiSize) - - return int32(ti.Threadnum), nil -} - -func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error) { - lib, err := registerFuncs() - if err != nil { - return nil, err - } - defer lib.Close() - - var ti ProcTaskInfo - const tiSize = int32(unsafe.Sizeof(ti)) - procPidInfo(p.Pid, common.PROC_PIDTASKINFO, 0, uintptr(unsafe.Pointer(&ti)), tiSize) - - timescaleToNanoSeconds := getTimeScaleToNanoSeconds() - ret := &cpu.TimesStat{ - CPU: "cpu", - User: float64(ti.Total_user) * timescaleToNanoSeconds / 1e9, - System: float64(ti.Total_system) * timescaleToNanoSeconds / 1e9, - } - return ret, nil -} - -func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, error) { - lib, err := registerFuncs() - if err != nil { - return nil, err - } - defer lib.Close() - - var ti ProcTaskInfo - const tiSize = int32(unsafe.Sizeof(ti)) - procPidInfo(p.Pid, common.PROC_PIDTASKINFO, 0, uintptr(unsafe.Pointer(&ti)), tiSize) - - ret := &MemoryInfoStat{ - RSS: uint64(ti.Resident_size), - VMS: uint64(ti.Virtual_size), - Swap: uint64(ti.Pageins), - } - return ret, nil -} diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_darwin_amd64.go b/vendor/github.com/shirou/gopsutil/v4/process/process_darwin_amd64.go index 890a5d5331a49..a13522473a1c3 100644 --- a/vendor/github.com/shirou/gopsutil/v4/process/process_darwin_amd64.go +++ b/vendor/github.com/shirou/gopsutil/v4/process/process_darwin_amd64.go @@ -212,27 +212,6 @@ type Posix_cred struct { type Label struct{} -type ProcTaskInfo struct { - Virtual_size uint64 - Resident_size uint64 - Total_user uint64 - Total_system uint64 - Threads_user uint64 - Threads_system uint64 - Policy int32 - Faults int32 - Pageins int32 - Cow_faults int32 - Messages_sent int32 - Messages_received int32 - Syscalls_mach int32 - Syscalls_unix int32 - Csw int32 - Threadnum int32 - Numrunning int32 - Priority int32 -} - type AuditinfoAddr struct { Auid uint32 Mask AuMask diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_darwin_arm64.go b/vendor/github.com/shirou/gopsutil/v4/process/process_darwin_arm64.go index 8075cf227d19a..f1f3df365d919 100644 --- a/vendor/github.com/shirou/gopsutil/v4/process/process_darwin_arm64.go +++ b/vendor/github.com/shirou/gopsutil/v4/process/process_darwin_arm64.go @@ -190,27 +190,6 @@ type Posix_cred struct{} type Label struct{} -type ProcTaskInfo struct { - Virtual_size uint64 - Resident_size uint64 - Total_user uint64 - Total_system uint64 - Threads_user uint64 - Threads_system uint64 - Policy int32 - Faults int32 - Pageins int32 - Cow_faults int32 - Messages_sent int32 - Messages_received int32 - Syscalls_mach int32 - Syscalls_unix int32 - Csw int32 - Threadnum int32 - Numrunning int32 - Priority int32 -} - type AuditinfoAddr struct { Auid uint32 Mask AuMask diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_darwin_cgo.go b/vendor/github.com/shirou/gopsutil/v4/process/process_darwin_cgo.go new file mode 100644 index 0000000000000..bbdfc963ebbee --- /dev/null +++ b/vendor/github.com/shirou/gopsutil/v4/process/process_darwin_cgo.go @@ -0,0 +1,222 @@ +// SPDX-License-Identifier: BSD-3-Clause +//go:build darwin && cgo + +package process + +// #include +// #include +// #include +// #include +// #include +// #include +// #include +import "C" + +import ( + "bytes" + "context" + "fmt" + "strings" + "syscall" + "unsafe" + + "github.com/shirou/gopsutil/v4/cpu" +) + +var ( + argMax int + timescaleToNanoSeconds float64 +) + +func init() { + argMax = getArgMax() + timescaleToNanoSeconds = getTimeScaleToNanoSeconds() +} + +func getArgMax() int { + var ( + mib = [...]C.int{C.CTL_KERN, C.KERN_ARGMAX} + argmax C.int + size C.size_t = C.ulong(unsafe.Sizeof(argmax)) + ) + retval := C.sysctl(&mib[0], 2, unsafe.Pointer(&argmax), &size, C.NULL, 0) + if retval == 0 { + return int(argmax) + } + return 0 +} + +func getTimeScaleToNanoSeconds() float64 { + var timeBaseInfo C.struct_mach_timebase_info + + C.mach_timebase_info(&timeBaseInfo) + + return float64(timeBaseInfo.numer) / float64(timeBaseInfo.denom) +} + +func (p *Process) ExeWithContext(ctx context.Context) (string, error) { + var c C.char // need a var for unsafe.Sizeof need a var + const bufsize = C.PROC_PIDPATHINFO_MAXSIZE * unsafe.Sizeof(c) + buffer := (*C.char)(C.malloc(C.size_t(bufsize))) + defer C.free(unsafe.Pointer(buffer)) + + ret, err := C.proc_pidpath(C.int(p.Pid), unsafe.Pointer(buffer), C.uint32_t(bufsize)) + if err != nil { + return "", err + } + if ret <= 0 { + return "", fmt.Errorf("unknown error: proc_pidpath returned %d", ret) + } + + return C.GoString(buffer), nil +} + +// CwdWithContext retrieves the Current Working Directory for the given process. +// It uses the proc_pidinfo from libproc and will only work for processes the +// EUID can access. Otherwise "operation not permitted" will be returned as the +// error. +// Note: This might also work for other *BSD OSs. +func (p *Process) CwdWithContext(ctx context.Context) (string, error) { + const vpiSize = C.sizeof_struct_proc_vnodepathinfo + vpi := (*C.struct_proc_vnodepathinfo)(C.malloc(vpiSize)) + defer C.free(unsafe.Pointer(vpi)) + ret, err := C.proc_pidinfo(C.int(p.Pid), C.PROC_PIDVNODEPATHINFO, 0, unsafe.Pointer(vpi), vpiSize) + if err != nil { + // fmt.Printf("ret: %d %T\n", ret, err) + if err == syscall.EPERM { + return "", ErrorNotPermitted + } + return "", err + } + if ret <= 0 { + return "", fmt.Errorf("unknown error: proc_pidinfo returned %d", ret) + } + if ret != C.sizeof_struct_proc_vnodepathinfo { + return "", fmt.Errorf("too few bytes; expected %d, got %d", vpiSize, ret) + } + return C.GoString(&vpi.pvi_cdir.vip_path[0]), err +} + +func procArgs(pid int32) ([]byte, int, error) { + var ( + mib = [...]C.int{C.CTL_KERN, C.KERN_PROCARGS2, C.int(pid)} + size C.size_t = C.ulong(argMax) + nargs C.int + result []byte + ) + procargs := (*C.char)(C.malloc(C.ulong(argMax))) + defer C.free(unsafe.Pointer(procargs)) + retval, err := C.sysctl(&mib[0], 3, unsafe.Pointer(procargs), &size, C.NULL, 0) + if retval == 0 { + C.memcpy(unsafe.Pointer(&nargs), unsafe.Pointer(procargs), C.sizeof_int) + result = C.GoBytes(unsafe.Pointer(procargs), C.int(size)) + // fmt.Printf("size: %d %d\n%s\n", size, nargs, hex.Dump(result)) + return result, int(nargs), nil + } + return nil, 0, err +} + +func (p *Process) CmdlineSliceWithContext(ctx context.Context) ([]string, error) { + return p.cmdlineSliceWithContext(ctx, true) +} + +func (p *Process) cmdlineSliceWithContext(ctx context.Context, fallback bool) ([]string, error) { + pargs, nargs, err := procArgs(p.Pid) + if err != nil { + return nil, err + } + // The first bytes hold the nargs int, skip it. + args := bytes.Split((pargs)[C.sizeof_int:], []byte{0}) + var argStr string + // The first element is the actual binary/command path. + // command := args[0] + var argSlice []string + // var envSlice []string + // All other, non-zero elements are arguments. The first "nargs" elements + // are the arguments. Everything else in the slice is then the environment + // of the process. + for _, arg := range args[1:] { + argStr = string(arg[:]) + if len(argStr) > 0 { + if nargs > 0 { + argSlice = append(argSlice, argStr) + nargs-- + continue + } + break + // envSlice = append(envSlice, argStr) + } + } + return argSlice, err +} + +// cmdNameWithContext returns the command name (including spaces) without any arguments +func (p *Process) cmdNameWithContext(ctx context.Context) (string, error) { + r, err := p.cmdlineSliceWithContext(ctx, false) + if err != nil { + return "", err + } + + if len(r) == 0 { + return "", nil + } + + return r[0], err +} + +func (p *Process) CmdlineWithContext(ctx context.Context) (string, error) { + r, err := p.CmdlineSliceWithContext(ctx) + if err != nil { + return "", err + } + return strings.Join(r, " "), err +} + +func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) { + const tiSize = C.sizeof_struct_proc_taskinfo + ti := (*C.struct_proc_taskinfo)(C.malloc(tiSize)) + defer C.free(unsafe.Pointer(ti)) + + _, err := C.proc_pidinfo(C.int(p.Pid), C.PROC_PIDTASKINFO, 0, unsafe.Pointer(ti), tiSize) + if err != nil { + return 0, err + } + + return int32(ti.pti_threadnum), nil +} + +func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error) { + const tiSize = C.sizeof_struct_proc_taskinfo + ti := (*C.struct_proc_taskinfo)(C.malloc(tiSize)) + defer C.free(unsafe.Pointer(ti)) + + _, err := C.proc_pidinfo(C.int(p.Pid), C.PROC_PIDTASKINFO, 0, unsafe.Pointer(ti), tiSize) + if err != nil { + return nil, err + } + + ret := &cpu.TimesStat{ + CPU: "cpu", + User: float64(ti.pti_total_user) * timescaleToNanoSeconds / 1e9, + System: float64(ti.pti_total_system) * timescaleToNanoSeconds / 1e9, + } + return ret, nil +} + +func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, error) { + const tiSize = C.sizeof_struct_proc_taskinfo + ti := (*C.struct_proc_taskinfo)(C.malloc(tiSize)) + defer C.free(unsafe.Pointer(ti)) + + _, err := C.proc_pidinfo(C.int(p.Pid), C.PROC_PIDTASKINFO, 0, unsafe.Pointer(ti), tiSize) + if err != nil { + return nil, err + } + + ret := &MemoryInfoStat{ + RSS: uint64(ti.pti_resident_size), + VMS: uint64(ti.pti_virtual_size), + Swap: uint64(ti.pti_pageins), + } + return ret, nil +} diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_darwin_nocgo.go b/vendor/github.com/shirou/gopsutil/v4/process/process_darwin_nocgo.go new file mode 100644 index 0000000000000..d498c9377a060 --- /dev/null +++ b/vendor/github.com/shirou/gopsutil/v4/process/process_darwin_nocgo.go @@ -0,0 +1,134 @@ +// SPDX-License-Identifier: BSD-3-Clause +//go:build darwin && !cgo + +package process + +import ( + "context" + "fmt" + "strconv" + "strings" + + "github.com/shirou/gopsutil/v4/cpu" + "github.com/shirou/gopsutil/v4/internal/common" +) + +func (p *Process) CwdWithContext(ctx context.Context) (string, error) { + return "", common.ErrNotImplementedError +} + +func (p *Process) ExeWithContext(ctx context.Context) (string, error) { + out, err := invoke.CommandWithContext(ctx, "lsof", "-p", strconv.Itoa(int(p.Pid)), "-Fpfn") + if err != nil { + return "", fmt.Errorf("bad call to lsof: %w", err) + } + txtFound := 0 + lines := strings.Split(string(out), "\n") + fallback := "" + for i := 1; i < len(lines); i++ { + if lines[i] == "ftxt" { + txtFound++ + if txtFound == 1 { + fallback = lines[i-1][1:] + } + if txtFound == 2 { + return lines[i-1][1:], nil + } + } + } + if fallback != "" { + return fallback, nil + } + return "", fmt.Errorf("missing txt data returned by lsof") +} + +func (p *Process) CmdlineWithContext(ctx context.Context) (string, error) { + r, err := callPsWithContext(ctx, "command", p.Pid, false, false) + if err != nil { + return "", err + } + return strings.Join(r[0], " "), err +} + +func (p *Process) cmdNameWithContext(ctx context.Context) (string, error) { + r, err := callPsWithContext(ctx, "command", p.Pid, false, true) + if err != nil { + return "", err + } + if len(r) > 0 && len(r[0]) > 0 { + return r[0][0], err + } + + return "", err +} + +// CmdlineSliceWithContext returns the command line arguments of the process as a slice with each +// element being an argument. Because of current deficiencies in the way that the command +// line arguments are found, single arguments that have spaces in the will actually be +// reported as two separate items. In order to do something better CGO would be needed +// to use the native darwin functions. +func (p *Process) CmdlineSliceWithContext(ctx context.Context) ([]string, error) { + r, err := callPsWithContext(ctx, "command", p.Pid, false, false) + if err != nil { + return nil, err + } + return r[0], err +} + +func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) { + r, err := callPsWithContext(ctx, "utime,stime", p.Pid, true, false) + if err != nil { + return 0, err + } + return int32(len(r)), nil +} + +func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error) { + r, err := callPsWithContext(ctx, "utime,stime", p.Pid, false, false) + if err != nil { + return nil, err + } + + utime, err := convertCPUTimes(r[0][0]) + if err != nil { + return nil, err + } + stime, err := convertCPUTimes(r[0][1]) + if err != nil { + return nil, err + } + + ret := &cpu.TimesStat{ + CPU: "cpu", + User: utime, + System: stime, + } + return ret, nil +} + +func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, error) { + r, err := callPsWithContext(ctx, "rss,vsize,pagein", p.Pid, false, false) + if err != nil { + return nil, err + } + rss, err := strconv.ParseInt(r[0][0], 10, 64) + if err != nil { + return nil, err + } + vms, err := strconv.ParseInt(r[0][1], 10, 64) + if err != nil { + return nil, err + } + pagein, err := strconv.ParseInt(r[0][2], 10, 64) + if err != nil { + return nil, err + } + + ret := &MemoryInfoStat{ + RSS: uint64(rss) * 1024, + VMS: uint64(vms) * 1024, + Swap: uint64(pagein), + } + + return ret, nil +} diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_freebsd.go b/vendor/github.com/shirou/gopsutil/v4/process/process_freebsd.go index 76373736bfc5b..436dcf0300531 100644 --- a/vendor/github.com/shirou/gopsutil/v4/process/process_freebsd.go +++ b/vendor/github.com/shirou/gopsutil/v4/process/process_freebsd.go @@ -8,7 +8,6 @@ import ( "context" "errors" "path/filepath" - "sort" "strconv" "strings" @@ -270,21 +269,18 @@ func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, e } func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) { - procs, err := ProcessesWithContext(ctx) + pids, err := common.CallPgrepWithContext(ctx, invoke, p.Pid) if err != nil { - return nil, nil + return nil, err } - ret := make([]*Process, 0, len(procs)) - for _, proc := range procs { - ppid, err := proc.PpidWithContext(ctx) + ret := make([]*Process, 0, len(pids)) + for _, pid := range pids { + np, err := NewProcessWithContext(ctx, pid) if err != nil { - continue - } - if ppid == p.Pid { - ret = append(ret, proc) + return nil, err } + ret = append(ret, np) } - sort.Slice(ret, func(i, j int) bool { return ret[i].Pid < ret[j].Pid }) return ret, nil } diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_linux.go b/vendor/github.com/shirou/gopsutil/v4/process/process_linux.go index 68a8c88c4a904..7aff0448dfedf 100644 --- a/vendor/github.com/shirou/gopsutil/v4/process/process_linux.go +++ b/vendor/github.com/shirou/gopsutil/v4/process/process_linux.go @@ -12,7 +12,6 @@ import ( "math" "os" "path/filepath" - "sort" "strconv" "strings" @@ -339,34 +338,21 @@ func (p *Process) PageFaultsWithContext(ctx context.Context) (*PageFaultsStat, e } func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) { - statFiles, err := filepath.Glob(common.HostProcWithContext(ctx, "[0-9]*/stat")) + pids, err := common.CallPgrepWithContext(ctx, invoke, p.Pid) if err != nil { return nil, err } - ret := make([]*Process, 0, len(statFiles)) - for _, statFile := range statFiles { - statContents, err := os.ReadFile(statFile) - if err != nil { - continue - } - fields := splitProcStat(statContents) - pid, err := strconv.ParseInt(fields[1], 10, 32) - if err != nil { - continue - } - ppid, err := strconv.ParseInt(fields[4], 10, 32) + if len(pids) == 0 { + return nil, ErrorNoChildren + } + ret := make([]*Process, 0, len(pids)) + for _, pid := range pids { + np, err := NewProcessWithContext(ctx, pid) if err != nil { - continue - } - if int32(ppid) == p.Pid { - np, err := NewProcessWithContext(ctx, int32(pid)) - if err != nil { - continue - } - ret = append(ret, np) + return nil, err } + ret = append(ret, np) } - sort.Slice(ret, func(i, j int) bool { return ret[i].Pid < ret[j].Pid }) return ret, nil } @@ -1096,7 +1082,8 @@ func (p *Process) fillFromTIDStatWithContext(ctx context.Context, tid int32) (ui if err != nil { return 0, 0, nil, 0, 0, 0, nil, err } - createTime := int64((t * 1000 / uint64(clockTicks)) + uint64(bootTime*1000)) + ctime := (t / uint64(clockTicks)) + uint64(bootTime) + createTime := int64(ctime * 1000) rtpriority, err := strconv.ParseInt(fields[18], 10, 32) if err != nil { diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd.go b/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd.go index 5e8a9e0b45ee4..e2d0ab462263d 100644 --- a/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd.go +++ b/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd.go @@ -11,7 +11,6 @@ import ( "fmt" "io" "path/filepath" - "sort" "strconv" "strings" "unsafe" @@ -287,21 +286,18 @@ func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, e } func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) { - procs, err := ProcessesWithContext(ctx) + pids, err := common.CallPgrepWithContext(ctx, invoke, p.Pid) if err != nil { - return nil, nil + return nil, err } - ret := make([]*Process, 0, len(procs)) - for _, proc := range procs { - ppid, err := proc.PpidWithContext(ctx) + ret := make([]*Process, 0, len(pids)) + for _, pid := range pids { + np, err := NewProcessWithContext(ctx, pid) if err != nil { - continue - } - if ppid == p.Pid { - ret = append(ret, proc) + return nil, err } + ret = append(ret, np) } - sort.Slice(ret, func(i, j int) bool { return ret[i].Pid < ret[j].Pid }) return ret, nil } diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_windows.go b/vendor/github.com/shirou/gopsutil/v4/process/process_windows.go index b00c671e9f325..52e1086f7805d 100644 --- a/vendor/github.com/shirou/gopsutil/v4/process/process_windows.go +++ b/vendor/github.com/shirou/gopsutil/v4/process/process_windows.go @@ -43,7 +43,6 @@ var ( procGetPriorityClass = common.Modkernel32.NewProc("GetPriorityClass") procGetProcessIoCounters = common.Modkernel32.NewProc("GetProcessIoCounters") procGetNativeSystemInfo = common.Modkernel32.NewProc("GetNativeSystemInfo") - procGetProcessHandleCount = common.Modkernel32.NewProc("GetProcessHandleCount") processorArchitecture uint ) @@ -549,21 +548,8 @@ func (p *Process) NumCtxSwitchesWithContext(ctx context.Context) (*NumCtxSwitche return nil, common.ErrNotImplementedError } -// NumFDsWithContext returns the number of handles for a process on Windows, -// not the number of file descriptors (FDs). func (p *Process) NumFDsWithContext(ctx context.Context) (int32, error) { - handle, err := windows.OpenProcess(processQueryInformation, false, uint32(p.Pid)) - if err != nil { - return 0, err - } - defer windows.CloseHandle(handle) - - var handleCount uint32 - ret, _, err := procGetProcessHandleCount.Call(uintptr(handle), uintptr(unsafe.Pointer(&handleCount))) - if ret == 0 { - return 0, err - } - return int32(handleCount), nil + return 0, common.ErrNotImplementedError } func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) { diff --git a/vendor/github.com/shoenig/go-m1cpu/.golangci.yaml b/vendor/github.com/shoenig/go-m1cpu/.golangci.yaml new file mode 100644 index 0000000000000..dc6fefb979ec0 --- /dev/null +++ b/vendor/github.com/shoenig/go-m1cpu/.golangci.yaml @@ -0,0 +1,12 @@ +run: + timeout: 5m +linters: + enable: + - gofmt + - errcheck + - errname + - errorlint + - bodyclose + - durationcheck + - whitespace + diff --git a/vendor/github.com/shoenig/go-m1cpu/LICENSE b/vendor/github.com/shoenig/go-m1cpu/LICENSE new file mode 100644 index 0000000000000..e87a115e462e1 --- /dev/null +++ b/vendor/github.com/shoenig/go-m1cpu/LICENSE @@ -0,0 +1,363 @@ +Mozilla Public License, version 2.0 + +1. Definitions + +1.1. "Contributor" + + means each individual or legal entity that creates, contributes to the + creation of, or owns Covered Software. + +1.2. "Contributor Version" + + means the combination of the Contributions of others (if any) used by a + Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + + means Source Code Form to which the initial Contributor has attached the + notice in Exhibit A, the Executable Form of such Source Code Form, and + Modifications of such Source Code Form, in each case including portions + thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + a. that the initial Contributor has attached the notice described in + Exhibit B to the Covered Software; or + + b. that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the terms of + a Secondary License. + +1.6. "Executable Form" + + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + + means a work that combines Covered Software with other material, in a + separate file or files, that is not Covered Software. + +1.8. "License" + + means this document. + +1.9. "Licensable" + + means having the right to grant, to the maximum extent possible, whether + at the time of the initial grant or subsequently, any and all of the + rights conveyed by this License. + +1.10. "Modifications" + + means any of the following: + + a. any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered Software; or + + b. any new file in Source Code Form that contains any Covered Software. + +1.11. "Patent Claims" of a Contributor + + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the License, + by the making, using, selling, offering for sale, having made, import, + or transfer of either its Contributions or its Contributor Version. + +1.12. "Secondary License" + + means either the GNU General Public License, Version 2.0, the GNU Lesser + General Public License, Version 2.1, the GNU Affero General Public + License, Version 3.0, or any later versions of those licenses. + +1.13. "Source Code Form" + + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that controls, is + controlled by, or is under common control with You. For purposes of this + definition, "control" means (a) the power, direct or indirect, to cause + the direction or management of such entity, whether by contract or + otherwise, or (b) ownership of more than fifty percent (50%) of the + outstanding shares or beneficial ownership of such entity. + + +2. License Grants and Conditions + +2.1. Grants + + Each Contributor hereby grants You a world-wide, royalty-free, + non-exclusive license: + + a. under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + + b. under Patent Claims of such Contributor to make, use, sell, offer for + sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + + The licenses granted in Section 2.1 with respect to any Contribution + become effective for each Contribution on the date the Contributor first + distributes such Contribution. + +2.3. Limitations on Grant Scope + + The licenses granted in this Section 2 are the only rights granted under + this License. No additional rights or licenses will be implied from the + distribution or licensing of Covered Software under this License. + Notwithstanding Section 2.1(b) above, no patent license is granted by a + Contributor: + + a. for any code that a Contributor has removed from Covered Software; or + + b. for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + + c. under Patent Claims infringed by Covered Software in the absence of + its Contributions. + + This License does not grant any rights in the trademarks, service marks, + or logos of any Contributor (except as may be necessary to comply with + the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + + No Contributor makes additional grants as a result of Your choice to + distribute the Covered Software under a subsequent version of this + License (see Section 10.2) or under the terms of a Secondary License (if + permitted under the terms of Section 3.3). + +2.5. Representation + + Each Contributor represents that the Contributor believes its + Contributions are its original creation(s) or it has sufficient rights to + grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + + This License is not intended to limit any rights You have under + applicable copyright doctrines of fair use, fair dealing, or other + equivalents. + +2.7. Conditions + + Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in + Section 2.1. + + +3. Responsibilities + +3.1. Distribution of Source Form + + All distribution of Covered Software in Source Code Form, including any + Modifications that You create or to which You contribute, must be under + the terms of this License. You must inform recipients that the Source + Code Form of the Covered Software is governed by the terms of this + License, and how they can obtain a copy of this License. You may not + attempt to alter or restrict the recipients' rights in the Source Code + Form. + +3.2. Distribution of Executable Form + + If You distribute Covered Software in Executable Form then: + + a. such Covered Software must also be made available in Source Code Form, + as described in Section 3.1, and You must inform recipients of the + Executable Form how they can obtain a copy of such Source Code Form by + reasonable means in a timely manner, at a charge no more than the cost + of distribution to the recipient; and + + b. You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter the + recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + + You may create and distribute a Larger Work under terms of Your choice, + provided that You also comply with the requirements of this License for + the Covered Software. If the Larger Work is a combination of Covered + Software with a work governed by one or more Secondary Licenses, and the + Covered Software is not Incompatible With Secondary Licenses, this + License permits You to additionally distribute such Covered Software + under the terms of such Secondary License(s), so that the recipient of + the Larger Work may, at their option, further distribute the Covered + Software under the terms of either this License or such Secondary + License(s). + +3.4. Notices + + You may not remove or alter the substance of any license notices + (including copyright notices, patent notices, disclaimers of warranty, or + limitations of liability) contained within the Source Code Form of the + Covered Software, except that You may alter any license notices to the + extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + + You may choose to offer, and to charge a fee for, warranty, support, + indemnity or liability obligations to one or more recipients of Covered + Software. However, You may do so only on Your own behalf, and not on + behalf of any Contributor. You must make it absolutely clear that any + such warranty, support, indemnity, or liability obligation is offered by + You alone, and You hereby agree to indemnify every Contributor for any + liability incurred by such Contributor as a result of warranty, support, + indemnity or liability terms You offer. You may include additional + disclaimers of warranty and limitations of liability specific to any + jurisdiction. + +4. Inability to Comply Due to Statute or Regulation + + If it is impossible for You to comply with any of the terms of this License + with respect to some or all of the Covered Software due to statute, + judicial order, or regulation then You must: (a) comply with the terms of + this License to the maximum extent possible; and (b) describe the + limitations and the code they affect. Such description must be placed in a + text file included with all distributions of the Covered Software under + this License. Except to the extent prohibited by statute or regulation, + such description must be sufficiently detailed for a recipient of ordinary + skill to be able to understand it. + +5. Termination + +5.1. The rights granted under this License will terminate automatically if You + fail to comply with any of its terms. However, if You become compliant, + then the rights granted under this License from a particular Contributor + are reinstated (a) provisionally, unless and until such Contributor + explicitly and finally terminates Your grants, and (b) on an ongoing + basis, if such Contributor fails to notify You of the non-compliance by + some reasonable means prior to 60 days after You have come back into + compliance. Moreover, Your grants from a particular Contributor are + reinstated on an ongoing basis if such Contributor notifies You of the + non-compliance by some reasonable means, this is the first time You have + received notice of non-compliance with this License from such + Contributor, and You become compliant prior to 30 days after Your receipt + of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent + infringement claim (excluding declaratory judgment actions, + counter-claims, and cross-claims) alleging that a Contributor Version + directly or indirectly infringes any patent, then the rights granted to + You by any and all Contributors for the Covered Software under Section + 2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user + license agreements (excluding distributors and resellers) which have been + validly granted by You or Your distributors under this License prior to + termination shall survive termination. + +6. Disclaimer of Warranty + + Covered Software is provided under this License on an "as is" basis, + without warranty of any kind, either expressed, implied, or statutory, + including, without limitation, warranties that the Covered Software is free + of defects, merchantable, fit for a particular purpose or non-infringing. + The entire risk as to the quality and performance of the Covered Software + is with You. Should any Covered Software prove defective in any respect, + You (not any Contributor) assume the cost of any necessary servicing, + repair, or correction. This disclaimer of warranty constitutes an essential + part of this License. No use of any Covered Software is authorized under + this License except under this disclaimer. + +7. Limitation of Liability + + Under no circumstances and under no legal theory, whether tort (including + negligence), contract, or otherwise, shall any Contributor, or anyone who + distributes Covered Software as permitted above, be liable to You for any + direct, indirect, special, incidental, or consequential damages of any + character including, without limitation, damages for lost profits, loss of + goodwill, work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses, even if such party shall have been + informed of the possibility of such damages. This limitation of liability + shall not apply to liability for death or personal injury resulting from + such party's negligence to the extent applicable law prohibits such + limitation. Some jurisdictions do not allow the exclusion or limitation of + incidental or consequential damages, so this exclusion and limitation may + not apply to You. + +8. Litigation + + Any litigation relating to this License may be brought only in the courts + of a jurisdiction where the defendant maintains its principal place of + business and such litigation shall be governed by laws of that + jurisdiction, without reference to its conflict-of-law provisions. Nothing + in this Section shall prevent a party's ability to bring cross-claims or + counter-claims. + +9. Miscellaneous + + This License represents the complete agreement concerning the subject + matter hereof. If any provision of this License is held to be + unenforceable, such provision shall be reformed only to the extent + necessary to make it enforceable. Any law or regulation which provides that + the language of a contract shall be construed against the drafter shall not + be used to construe this License against a Contributor. + + +10. Versions of the License + +10.1. New Versions + + Mozilla Foundation is the license steward. Except as provided in Section + 10.3, no one other than the license steward has the right to modify or + publish new versions of this License. Each version will be given a + distinguishing version number. + +10.2. Effect of New Versions + + You may distribute the Covered Software under the terms of the version + of the License under which You originally received the Covered Software, + or under the terms of any subsequent version published by the license + steward. + +10.3. Modified Versions + + If you create software not governed by this License, and you want to + create a new license for such software, you may create and use a + modified version of this License if you rename the license and remove + any references to the name of the license steward (except to note that + such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary + Licenses If You choose to distribute Source Code Form that is + Incompatible With Secondary Licenses under the terms of this version of + the License, the notice described in Exhibit B of this License must be + attached. + +Exhibit A - Source Code Form License Notice + + This Source Code Form is subject to the + terms of the Mozilla Public License, v. + 2.0. If a copy of the MPL was not + distributed with this file, You can + obtain one at + http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular file, +then You may include the notice in a location (such as a LICENSE file in a +relevant directory) where a recipient would be likely to look for such a +notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice + + This Source Code Form is "Incompatible + With Secondary Licenses", as defined by + the Mozilla Public License, v. 2.0. + diff --git a/vendor/github.com/shoenig/go-m1cpu/Makefile b/vendor/github.com/shoenig/go-m1cpu/Makefile new file mode 100644 index 0000000000000..28d786397d4b4 --- /dev/null +++ b/vendor/github.com/shoenig/go-m1cpu/Makefile @@ -0,0 +1,12 @@ +SHELL = bash + +default: test + +.PHONY: test +test: + @echo "--> Running Tests ..." + @go test -v -race ./... + +vet: + @echo "--> Vet Go sources ..." + @go vet ./... diff --git a/vendor/github.com/shoenig/go-m1cpu/README.md b/vendor/github.com/shoenig/go-m1cpu/README.md new file mode 100644 index 0000000000000..399657acf861c --- /dev/null +++ b/vendor/github.com/shoenig/go-m1cpu/README.md @@ -0,0 +1,66 @@ +# m1cpu + +[![Go Reference](https://pkg.go.dev/badge/github.com/shoenig/go-m1cpu.svg)](https://pkg.go.dev/github.com/shoenig/go-m1cpu) +[![MPL License](https://img.shields.io/github/license/shoenig/go-m1cpu?color=g&style=flat-square)](https://github.com/shoenig/go-m1cpu/blob/main/LICENSE) +[![Run CI Tests](https://github.com/shoenig/go-m1cpu/actions/workflows/ci.yaml/badge.svg)](https://github.com/shoenig/go-m1cpu/actions/workflows/ci.yaml) + +The `go-m1cpu` module is a library for inspecting Apple Silicon CPUs in Go. + +Use the `m1cpu` Go package for looking up the CPU frequency for Apple M1 and M2 CPUs. + +# Install + +```shell +go get github.com/shoenig/go-m1cpu@latest +``` + +# CGO + +This package requires the use of [CGO](https://go.dev/blog/cgo). + +Extracting the CPU properties is done via Apple's [IOKit](https://developer.apple.com/documentation/iokit?language=objc) +framework, which is accessible only through system C libraries. + +# Example + +Simple Go program to print Apple Silicon M1/M2 CPU speeds. + +```go +package main + +import ( + "fmt" + + "github.com/shoenig/go-m1cpu" +) + +func main() { + fmt.Println("Apple Silicon", m1cpu.IsAppleSilicon()) + + fmt.Println("pCore GHz", m1cpu.PCoreGHz()) + fmt.Println("eCore GHz", m1cpu.ECoreGHz()) + + fmt.Println("pCore Hz", m1cpu.PCoreHz()) + fmt.Println("eCore Hz", m1cpu.ECoreHz()) +} +``` + +Using `go test` to print out available information. + +``` +➜ go test -v -run Show +=== RUN Test_Show + cpu_test.go:42: pCore Hz 3504000000 + cpu_test.go:43: eCore Hz 2424000000 + cpu_test.go:44: pCore GHz 3.504 + cpu_test.go:45: eCore GHz 2.424 + cpu_test.go:46: pCore count 8 + cpu_test.go:47: eCoreCount 4 + cpu_test.go:50: pCore Caches 196608 131072 16777216 + cpu_test.go:53: eCore Caches 131072 65536 4194304 +--- PASS: Test_Show (0.00s) +``` + +# License + +Open source under the [MPL](LICENSE) diff --git a/vendor/github.com/shoenig/go-m1cpu/cpu.go b/vendor/github.com/shoenig/go-m1cpu/cpu.go new file mode 100644 index 0000000000000..502a8cce92e67 --- /dev/null +++ b/vendor/github.com/shoenig/go-m1cpu/cpu.go @@ -0,0 +1,213 @@ +//go:build darwin && arm64 && cgo + +package m1cpu + +// #cgo LDFLAGS: -framework CoreFoundation -framework IOKit +// #include +// #include +// #include +// #include +// +// #if !defined(MAC_OS_VERSION_12_0) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_VERSION_12_0 +// #define kIOMainPortDefault kIOMasterPortDefault +// #endif +// +// #define HzToGHz(hz) ((hz) / 1000000000.0) +// +// UInt64 global_pCoreHz; +// UInt64 global_eCoreHz; +// int global_pCoreCount; +// int global_eCoreCount; +// int global_pCoreL1InstCacheSize; +// int global_eCoreL1InstCacheSize; +// int global_pCoreL1DataCacheSize; +// int global_eCoreL1DataCacheSize; +// int global_pCoreL2CacheSize; +// int global_eCoreL2CacheSize; +// char global_brand[32]; +// +// UInt64 getFrequency(CFTypeRef typeRef) { +// CFDataRef cfData = typeRef; +// +// CFIndex size = CFDataGetLength(cfData); +// UInt8 buf[size]; +// CFDataGetBytes(cfData, CFRangeMake(0, size), buf); +// +// UInt8 b1 = buf[size-5]; +// UInt8 b2 = buf[size-6]; +// UInt8 b3 = buf[size-7]; +// UInt8 b4 = buf[size-8]; +// +// UInt64 pCoreHz = 0x00000000FFFFFFFF & ((b1<<24) | (b2 << 16) | (b3 << 8) | (b4)); +// return pCoreHz; +// } +// +// int sysctl_int(const char * name) { +// int value = -1; +// size_t size = 8; +// sysctlbyname(name, &value, &size, NULL, 0); +// return value; +// } +// +// void sysctl_string(const char * name, char * dest) { +// size_t size = 32; +// sysctlbyname(name, dest, &size, NULL, 0); +// } +// +// void initialize() { +// global_pCoreCount = sysctl_int("hw.perflevel0.physicalcpu"); +// global_eCoreCount = sysctl_int("hw.perflevel1.physicalcpu"); +// global_pCoreL1InstCacheSize = sysctl_int("hw.perflevel0.l1icachesize"); +// global_eCoreL1InstCacheSize = sysctl_int("hw.perflevel1.l1icachesize"); +// global_pCoreL1DataCacheSize = sysctl_int("hw.perflevel0.l1dcachesize"); +// global_eCoreL1DataCacheSize = sysctl_int("hw.perflevel1.l1dcachesize"); +// global_pCoreL2CacheSize = sysctl_int("hw.perflevel0.l2cachesize"); +// global_eCoreL2CacheSize = sysctl_int("hw.perflevel1.l2cachesize"); +// sysctl_string("machdep.cpu.brand_string", global_brand); +// +// CFMutableDictionaryRef matching = IOServiceMatching("AppleARMIODevice"); +// io_iterator_t iter; +// IOServiceGetMatchingServices(kIOMainPortDefault, matching, &iter); +// +// const size_t bufsize = 512; +// io_object_t obj; +// while ((obj = IOIteratorNext(iter))) { +// char class[bufsize]; +// IOObjectGetClass(obj, class); +// char name[bufsize]; +// IORegistryEntryGetName(obj, name); +// +// if (strncmp(name, "pmgr", bufsize) == 0) { +// CFTypeRef pCoreRef = IORegistryEntryCreateCFProperty(obj, CFSTR("voltage-states5-sram"), kCFAllocatorDefault, 0); +// CFTypeRef eCoreRef = IORegistryEntryCreateCFProperty(obj, CFSTR("voltage-states1-sram"), kCFAllocatorDefault, 0); +// +// long long pCoreHz = getFrequency(pCoreRef); +// long long eCoreHz = getFrequency(eCoreRef); +// +// global_pCoreHz = pCoreHz; +// global_eCoreHz = eCoreHz; +// return; +// } +// } +// } +// +// UInt64 eCoreHz() { +// return global_eCoreHz; +// } +// +// UInt64 pCoreHz() { +// return global_pCoreHz; +// } +// +// Float64 eCoreGHz() { +// return HzToGHz(global_eCoreHz); +// } +// +// Float64 pCoreGHz() { +// return HzToGHz(global_pCoreHz); +// } +// +// int pCoreCount() { +// return global_pCoreCount; +// } +// +// int eCoreCount() { +// return global_eCoreCount; +// } +// +// int pCoreL1InstCacheSize() { +// return global_pCoreL1InstCacheSize; +// } +// +// int pCoreL1DataCacheSize() { +// return global_pCoreL1DataCacheSize; +// } +// +// int pCoreL2CacheSize() { +// return global_pCoreL2CacheSize; +// } +// +// int eCoreL1InstCacheSize() { +// return global_eCoreL1InstCacheSize; +// } +// +// int eCoreL1DataCacheSize() { +// return global_eCoreL1DataCacheSize; +// } +// +// int eCoreL2CacheSize() { +// return global_eCoreL2CacheSize; +// } +// +// char * modelName() { +// return global_brand; +// } +import "C" + +func init() { + C.initialize() +} + +// IsAppleSilicon returns true on this platform. +func IsAppleSilicon() bool { + return true +} + +// PCoreHZ returns the max frequency in Hertz of the P-Core of an Apple Silicon CPU. +func PCoreHz() uint64 { + return uint64(C.pCoreHz()) +} + +// ECoreHZ returns the max frequency in Hertz of the E-Core of an Apple Silicon CPU. +func ECoreHz() uint64 { + return uint64(C.eCoreHz()) +} + +// PCoreGHz returns the max frequency in Gigahertz of the P-Core of an Apple Silicon CPU. +func PCoreGHz() float64 { + return float64(C.pCoreGHz()) +} + +// ECoreGHz returns the max frequency in Gigahertz of the E-Core of an Apple Silicon CPU. +func ECoreGHz() float64 { + return float64(C.eCoreGHz()) +} + +// PCoreCount returns the number of physical P (performance) cores. +func PCoreCount() int { + return int(C.pCoreCount()) +} + +// ECoreCount returns the number of physical E (efficiency) cores. +func ECoreCount() int { + return int(C.eCoreCount()) +} + +// PCoreCacheSize returns the sizes of the P (performance) core cache sizes +// in the order of +// +// - L1 instruction cache +// - L1 data cache +// - L2 cache +func PCoreCache() (int, int, int) { + return int(C.pCoreL1InstCacheSize()), + int(C.pCoreL1DataCacheSize()), + int(C.pCoreL2CacheSize()) +} + +// ECoreCacheSize returns the sizes of the E (efficiency) core cache sizes +// in the order of +// +// - L1 instruction cache +// - L1 data cache +// - L2 cache +func ECoreCache() (int, int, int) { + return int(C.eCoreL1InstCacheSize()), + int(C.eCoreL1DataCacheSize()), + int(C.eCoreL2CacheSize()) +} + +// ModelName returns the model name of the CPU. +func ModelName() string { + return C.GoString(C.modelName()) +} diff --git a/vendor/github.com/shoenig/go-m1cpu/incompatible.go b/vendor/github.com/shoenig/go-m1cpu/incompatible.go new file mode 100644 index 0000000000000..d425025aa84d5 --- /dev/null +++ b/vendor/github.com/shoenig/go-m1cpu/incompatible.go @@ -0,0 +1,53 @@ +//go:build !darwin || !arm64 || !cgo + +package m1cpu + +// IsAppleSilicon return false on this platform. +func IsAppleSilicon() bool { + return false +} + +// PCoreHZ requires darwin/arm64 +func PCoreHz() uint64 { + panic("m1cpu: not a darwin/arm64 system") +} + +// ECoreHZ requires darwin/arm64 +func ECoreHz() uint64 { + panic("m1cpu: not a darwin/arm64 system") +} + +// PCoreGHz requires darwin/arm64 +func PCoreGHz() float64 { + panic("m1cpu: not a darwin/arm64 system") +} + +// ECoreGHz requires darwin/arm64 +func ECoreGHz() float64 { + panic("m1cpu: not a darwin/arm64 system") +} + +// PCoreCount requires darwin/arm64 +func PCoreCount() int { + panic("m1cpu: not a darwin/arm64 system") +} + +// ECoreCount requires darwin/arm64 +func ECoreCount() int { + panic("m1cpu: not a darwin/arm64 system") +} + +// PCoreCacheSize requires darwin/arm64 +func PCoreCache() (int, int, int) { + panic("m1cpu: not a darwin/arm64 system") +} + +// ECoreCacheSize requires darwin/arm64 +func ECoreCache() (int, int, int) { + panic("m1cpu: not a darwin/arm64 system") +} + +// ModelName requires darwin/arm64 +func ModelName() string { + panic("m1cpu: not a darwin/arm64 system") +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 81d67b023fca7..49e7bb611899f 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -666,12 +666,6 @@ github.com/eapache/go-xerial-snappy # github.com/eapache/queue v1.1.0 ## explicit github.com/eapache/queue -# github.com/ebitengine/purego v0.8.0 -## explicit; go 1.18 -github.com/ebitengine/purego -github.com/ebitengine/purego/internal/cgo -github.com/ebitengine/purego/internal/fakecgo -github.com/ebitengine/purego/internal/strings # github.com/edsrzf/mmap-go v1.1.0 ## explicit; go 1.17 github.com/edsrzf/mmap-go @@ -1533,7 +1527,7 @@ github.com/segmentio/fasthash/fnv1a # github.com/sercand/kuberesolver/v5 v5.1.1 ## explicit; go 1.18 github.com/sercand/kuberesolver/v5 -# github.com/shirou/gopsutil/v4 v4.24.9 +# github.com/shirou/gopsutil/v4 v4.24.8 ## explicit; go 1.18 github.com/shirou/gopsutil/v4/common github.com/shirou/gopsutil/v4/cpu @@ -1541,6 +1535,9 @@ github.com/shirou/gopsutil/v4/internal/common github.com/shirou/gopsutil/v4/mem github.com/shirou/gopsutil/v4/net github.com/shirou/gopsutil/v4/process +# github.com/shoenig/go-m1cpu v0.1.6 +## explicit; go 1.20 +github.com/shoenig/go-m1cpu # github.com/shopspring/decimal v1.2.0 ## explicit; go 1.13 github.com/shopspring/decimal From 61aa418bb52891ce4f6e14a6395bcd3d65c04d09 Mon Sep 17 00:00:00 2001 From: benclive Date: Wed, 9 Oct 2024 17:28:51 +0100 Subject: [PATCH 26/26] chore: Rename new querier flag to use dashes (#14438) --- docs/sources/shared/configuration.md | 2 +- pkg/querier/querier.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/sources/shared/configuration.md b/docs/sources/shared/configuration.md index b7a10bd142f98..132de42b81075 100644 --- a/docs/sources/shared/configuration.md +++ b/docs/sources/shared/configuration.md @@ -4231,7 +4231,7 @@ engine: # When true, querier directs ingester queries to the partition-ingesters instead # of the normal ingesters. -# CLI flag: -querier.query_partition_ingesters +# CLI flag: -querier.query-partition-ingesters [query_partition_ingesters: | default = false] ``` diff --git a/pkg/querier/querier.go b/pkg/querier/querier.go index a3a8309829f40..cdc4175f9fb0a 100644 --- a/pkg/querier/querier.go +++ b/pkg/querier/querier.go @@ -86,7 +86,7 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) { f.BoolVar(&cfg.QueryIngesterOnly, "querier.query-ingester-only", false, "When true, queriers only query the ingesters, and not stored data. This is useful when the object store is unavailable.") f.BoolVar(&cfg.MultiTenantQueriesEnabled, "querier.multi-tenant-queries-enabled", false, "When true, allow queries to span multiple tenants.") f.BoolVar(&cfg.PerRequestLimitsEnabled, "querier.per-request-limits-enabled", false, "When true, querier limits sent via a header are enforced.") - f.BoolVar(&cfg.QueryPartitionIngesters, "querier.query_partition_ingesters", false, "When true, querier directs ingester queries to the partition-ingesters instead of the normal ingesters.") + f.BoolVar(&cfg.QueryPartitionIngesters, "querier.query-partition-ingesters", false, "When true, querier directs ingester queries to the partition-ingesters instead of the normal ingesters.") } // Validate validates the config.