Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a4007e280b | ||
|
|
31e1c9ee74 | ||
|
|
c236c124fc | ||
|
|
0197ab199d |
No files matched your search
@@ -10,7 +10,7 @@ require (
|
||||
github.com/MicahParks/keyfunc/v2 v2.1.0
|
||||
github.com/Nerzal/gocloak/v13 v13.9.0
|
||||
github.com/bbalet/stopwords v1.0.0
|
||||
github.com/beevik/etree v1.7.1
|
||||
github.com/beevik/etree v1.8.1
|
||||
github.com/blevesearch/bleve/v2 v2.6.0
|
||||
github.com/cenkalti/backoff v2.2.1+incompatible
|
||||
github.com/cenkalti/backoff/v5 v5.0.3
|
||||
@@ -35,7 +35,7 @@ require (
|
||||
github.com/go-micro/plugins/v4/store/nats-js-kv v0.0.0-20240726082623-6831adfdcdc4
|
||||
github.com/go-micro/plugins/v4/wrapper/monitoring/prometheus v1.2.0
|
||||
github.com/go-micro/plugins/v4/wrapper/trace/opentelemetry v1.2.0
|
||||
github.com/go-playground/validator/v10 v10.30.4
|
||||
github.com/go-playground/validator/v10 v10.30.5
|
||||
github.com/gofrs/uuid v4.4.0+incompatible
|
||||
github.com/golang-jwt/jwt/v5 v5.3.1
|
||||
github.com/golang/protobuf v1.5.4
|
||||
@@ -58,16 +58,16 @@ require (
|
||||
github.com/mitchellh/mapstructure v1.5.0
|
||||
github.com/mna/pigeon v1.3.0
|
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826
|
||||
github.com/nats-io/nats-server/v2 v2.14.6
|
||||
github.com/nats-io/nats.go v1.53.1
|
||||
github.com/nats-io/nats-server/v2 v2.15.0
|
||||
github.com/nats-io/nats.go v1.54.0
|
||||
github.com/olekukonko/tablewriter v1.1.4
|
||||
github.com/onsi/ginkgo v1.16.5
|
||||
github.com/onsi/ginkgo/v2 v2.32.1
|
||||
github.com/onsi/gomega v1.43.0
|
||||
github.com/onsi/ginkgo/v2 v2.33.0
|
||||
github.com/onsi/gomega v1.44.0
|
||||
github.com/open-policy-agent/opa v1.19.0
|
||||
github.com/orcaman/concurrent-map v1.0.0
|
||||
github.com/owncloud/libre-graph-api-go v1.0.5-0.20260216101009-eeac018af245
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260917145219-ba14a94a3c7a
|
||||
github.com/owncloud/reva/v2 v2.0.0-20261006130333-e8a7c20b6b93
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/pkg/xattr v0.4.12
|
||||
github.com/prometheus/client_golang v1.24.1
|
||||
@@ -83,7 +83,7 @@ require (
|
||||
github.com/test-go/testify v1.1.4
|
||||
github.com/thejerf/suture/v4 v4.0.6
|
||||
github.com/tidwall/gjson v1.19.0
|
||||
github.com/tus/tusd/v2 v2.10.0
|
||||
github.com/tus/tusd/v2 v2.10.1
|
||||
github.com/unrolled/secure v1.17.0
|
||||
github.com/urfave/cli/v2 v2.27.7
|
||||
github.com/xhit/go-simple-mail/v2 v2.16.0
|
||||
@@ -97,16 +97,16 @@ require (
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.46.0
|
||||
go.opentelemetry.io/otel/sdk v1.46.0
|
||||
go.opentelemetry.io/otel/trace v1.46.0
|
||||
golang.org/x/crypto v0.56.0
|
||||
golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f
|
||||
golang.org/x/crypto v0.57.0
|
||||
golang.org/x/exp v0.0.0-20260611194520-c48552f49976
|
||||
golang.org/x/image v0.45.0
|
||||
golang.org/x/net v0.58.0
|
||||
golang.org/x/oauth2 v0.36.0
|
||||
golang.org/x/sync v0.22.0
|
||||
golang.org/x/term v0.45.0
|
||||
golang.org/x/text v0.41.0
|
||||
golang.org/x/oauth2 v0.37.0
|
||||
golang.org/x/sync v0.23.0
|
||||
golang.org/x/term v0.46.0
|
||||
golang.org/x/text v0.42.0
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260819154853-08b0e4226688
|
||||
google.golang.org/grpc v1.83.2
|
||||
google.golang.org/grpc v1.84.0
|
||||
google.golang.org/protobuf v1.36.12
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
gotest.tools/v3 v3.5.2
|
||||
@@ -128,7 +128,7 @@ require (
|
||||
github.com/ajg/form v1.5.1 // indirect
|
||||
github.com/alexedwards/argon2id v1.0.0 // indirect
|
||||
github.com/amoghe/go-crypt v0.0.0-20220222110647-20eada5f5964 // indirect
|
||||
github.com/antithesishq/antithesis-sdk-go v0.7.2-default-no-op // indirect
|
||||
github.com/antithesishq/antithesis-sdk-go v0.8.0-default-no-op // indirect
|
||||
github.com/armon/go-radix v1.0.0 // indirect
|
||||
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
|
||||
github.com/aws/aws-sdk-go v1.55.8 // indirect
|
||||
@@ -199,7 +199,7 @@ require (
|
||||
github.com/go-micro/plugins/v4/store/nats-js v1.2.1 // indirect
|
||||
github.com/go-micro/plugins/v4/store/redis v1.2.1 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.2 // indirect
|
||||
github.com/go-redis/redis/v8 v8.11.5 // indirect
|
||||
github.com/go-resty/resty/v2 v2.17.2 // indirect
|
||||
github.com/go-sql-driver/mysql v1.10.1 // indirect
|
||||
@@ -220,7 +220,7 @@ require (
|
||||
github.com/gomodule/redigo v1.9.3 // indirect
|
||||
github.com/google/go-querystring v1.2.0 // indirect
|
||||
github.com/google/go-tpm v0.9.8 // indirect
|
||||
github.com/google/pprof v0.0.0-20260402051712-545e8a4df936 // indirect
|
||||
github.com/google/pprof v0.0.0-20260604005048-7023385849c0 // indirect
|
||||
github.com/google/renameio/v2 v2.0.2 // indirect
|
||||
github.com/gookit/goutil v0.8.0 // indirect
|
||||
github.com/gorilla/handlers v1.5.1 // indirect
|
||||
@@ -228,7 +228,7 @@ require (
|
||||
github.com/hashicorp/go-hclog v1.6.3 // indirect
|
||||
github.com/hashicorp/go-plugin v1.8.0 // indirect
|
||||
github.com/hashicorp/yamux v0.1.2 // indirect
|
||||
github.com/huandu/xstrings v1.5.0 // indirect
|
||||
github.com/huandu/xstrings v1.6.1 // indirect
|
||||
github.com/iancoleman/strcase v0.3.0 // indirect
|
||||
github.com/imdario/mergo v0.3.15 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
@@ -238,7 +238,7 @@ require (
|
||||
github.com/json-iterator/go v1.1.13-0.20220915233716-71ac16282d12 // indirect
|
||||
github.com/juliangruber/go-intersect v1.1.0 // indirect
|
||||
github.com/kevinburke/ssh_config v1.2.0 // indirect
|
||||
github.com/klauspost/compress v1.19.2 // indirect
|
||||
github.com/klauspost/compress v1.20.0 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.4.0 // indirect
|
||||
github.com/klauspost/crc32 v1.3.0 // indirect
|
||||
github.com/kovidgoyal/go-parallel v1.1.1 // indirect
|
||||
@@ -255,10 +255,10 @@ require (
|
||||
github.com/longsleep/go-metrics v1.0.0 // indirect
|
||||
github.com/longsleep/rndm v1.2.0 // indirect
|
||||
github.com/mattermost/xml-roundtrip-validator v0.1.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.14 // indirect
|
||||
github.com/mattn/go-isatty v0.0.21 // indirect
|
||||
github.com/mattn/go-colorable v0.1.15 // indirect
|
||||
github.com/mattn/go-isatty v0.0.22 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.23 // indirect
|
||||
github.com/mattn/go-sqlite3 v1.14.50 // indirect
|
||||
github.com/mattn/go-sqlite3 v1.14.52 // indirect
|
||||
github.com/maxymania/go-system v0.0.0-20170110133659-647cc364bf0b // indirect
|
||||
github.com/mendsley/gojwk v0.0.0-20141217222730-4d5ec6e58103 // indirect
|
||||
github.com/miekg/dns v1.1.72 // indirect
|
||||
@@ -290,7 +290,7 @@ require (
|
||||
github.com/pierrec/lz4/v4 v4.1.26 // indirect
|
||||
github.com/pjbgf/sha1cd v0.6.0 // indirect
|
||||
github.com/pquerna/cachecontrol v0.2.0 // indirect
|
||||
github.com/prometheus/alertmanager v0.34.0 // indirect
|
||||
github.com/prometheus/alertmanager v0.34.1 // indirect
|
||||
github.com/prometheus/client_model v0.6.2 // indirect
|
||||
github.com/prometheus/common v0.70.1 // indirect
|
||||
github.com/prometheus/procfs v0.21.1 // indirect
|
||||
@@ -326,9 +326,9 @@ require (
|
||||
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
|
||||
github.com/yashtewari/glob-intersection v0.2.0 // indirect
|
||||
github.com/zeebo/xxh3 v1.1.0 // indirect
|
||||
go.etcd.io/etcd/api/v3 v3.7.1 // indirect
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.7.1 // indirect
|
||||
go.etcd.io/etcd/client/v3 v3.7.1 // indirect
|
||||
go.etcd.io/etcd/api/v3 v3.7.2 // indirect
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.7.2 // indirect
|
||||
go.etcd.io/etcd/client/v3 v3.7.2 // indirect
|
||||
go.opencensus.io v0.24.0 // indirect
|
||||
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.46.0 // indirect
|
||||
@@ -338,11 +338,11 @@ require (
|
||||
go.uber.org/zap v1.27.1 // indirect
|
||||
go.yaml.in/yaml/v2 v2.4.4 // indirect
|
||||
go.yaml.in/yaml/v3 v3.0.5 // indirect
|
||||
golang.org/x/mod v0.40.0 // indirect
|
||||
golang.org/x/sys v0.47.0 // indirect
|
||||
golang.org/x/time v0.15.0 // indirect
|
||||
golang.org/x/mod v0.41.0 // indirect
|
||||
golang.org/x/sys v0.48.0 // indirect
|
||||
golang.org/x/time v0.16.0 // indirect
|
||||
golang.org/x/tools v0.49.0 // indirect
|
||||
google.golang.org/genproto v0.0.0-20260319201613-d00831a3d3e7 // indirect
|
||||
google.golang.org/genproto v0.0.0-20260622175928-b703f567277d // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260825221802-da73d73af1c5 // indirect
|
||||
gopkg.in/cenkalti/backoff.v1 v1.1.0 // indirect
|
||||
gopkg.in/ini.v1 v1.67.3 // indirect
|
||||
|
||||
@@ -90,8 +90,8 @@ github.com/amoghe/go-crypt v0.0.0-20220222110647-20eada5f5964 h1:I9YN9WMo3SUh7p/
|
||||
github.com/amoghe/go-crypt v0.0.0-20220222110647-20eada5f5964/go.mod h1:eFiR01PwTcpbzXtdMces7zxg6utvFM5puiWHpWB8D/k=
|
||||
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=
|
||||
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
|
||||
github.com/antithesishq/antithesis-sdk-go v0.7.2-default-no-op h1:p2zFsAzvhIpFya8AIOHIbWf7NGvO34QpLGclyf7nXj8=
|
||||
github.com/antithesishq/antithesis-sdk-go v0.7.2-default-no-op/go.mod h1:FQyySiasQQM8735Ddel3MRojmy4dA1IqCeyJ5jmPMbI=
|
||||
github.com/antithesishq/antithesis-sdk-go v0.8.0-default-no-op h1:1BOWQJweNyvZMlpAHXGLiZQn9S+QXGcz3xh94lC0w6E=
|
||||
github.com/antithesishq/antithesis-sdk-go v0.8.0-default-no-op/go.mod h1:FQyySiasQQM8735Ddel3MRojmy4dA1IqCeyJ5jmPMbI=
|
||||
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q=
|
||||
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE=
|
||||
github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI=
|
||||
@@ -104,8 +104,8 @@ github.com/aws/aws-sdk-go v1.55.8 h1:JRmEUbU52aJQZ2AjX4q4Wu7t4uZjOu71uyNmaWlUkJQ
|
||||
github.com/aws/aws-sdk-go v1.55.8/go.mod h1:ZkViS9AqA6otK+JBBNH2++sx1sgxrPKcSzPPvQkUtXk=
|
||||
github.com/bbalet/stopwords v1.0.0 h1:0TnGycCtY0zZi4ltKoOGRFIlZHv0WqpoIGUsObjztfo=
|
||||
github.com/bbalet/stopwords v1.0.0/go.mod h1:sAWrQoDMfqARGIn4s6dp7OW7ISrshUD8IP2q3KoqPjc=
|
||||
github.com/beevik/etree v1.7.1 h1:xBlSFAjlMfZkrCNKCEdZ2MSN9pfQYeRBaISDnAVi4Ek=
|
||||
github.com/beevik/etree v1.7.1/go.mod h1:bh4zJxiIr62SOf9pRzN7UUYaEDa9HEKafK25+sLc0Gc=
|
||||
github.com/beevik/etree v1.8.1 h1:MchsAnqPGCGsfQezhwcouHPlAHlcAOqWpyCVZoyWfjU=
|
||||
github.com/beevik/etree v1.8.1/go.mod h1:bh4zJxiIr62SOf9pRzN7UUYaEDa9HEKafK25+sLc0Gc=
|
||||
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
||||
github.com/beorn7/perks v0.0.0-20160804104726-4c0e84591b9a/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
@@ -357,10 +357,10 @@ github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lY
|
||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-playground/validator/v10 v10.30.4 h1:9Rcod2ZPO6mOEG6b4GqyoHE/H6//Ze0RuhOo1hT1x0w=
|
||||
github.com/go-playground/validator/v10 v10.30.4/go.mod h1:numpT+RPLE91R9oYWMY/R9zRgJBewr3IXHko4OISPpk=
|
||||
github.com/go-playground/universal-translator v0.18.2 h1:LCsMLC9RzmbUMNUPVYD15dmcjwYAJhmX8mPZRW4rAVU=
|
||||
github.com/go-playground/universal-translator v0.18.2/go.mod h1:67VZIMp5lQpDWlnStOct22q1bkdJGJqHghbOtmkawxk=
|
||||
github.com/go-playground/validator/v10 v10.30.5 h1:YyCXvVShZbs2Sm3Mb53eNOlhRXctSOzW5QJAouCTZL4=
|
||||
github.com/go-playground/validator/v10 v10.30.5/go.mod h1:wEqiaov48pXX1kjhc3Da8y0M0Dtg/BK7gurFBLgwFrQ=
|
||||
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
|
||||
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
|
||||
github.com/go-resty/resty/v2 v2.17.2 h1:FQW5oHYcIlkCNrMD2lloGScxcHJ0gkjshV3qcQAyHQk=
|
||||
@@ -475,8 +475,8 @@ github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hf
|
||||
github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20260402051712-545e8a4df936 h1:EwtI+Al+DeppwYX2oXJCETMO23COyaKGP6fHVpkpWpg=
|
||||
github.com/google/pprof v0.0.0-20260402051712-545e8a4df936/go.mod h1:MxpfABSjhmINe3F1It9d+8exIHFvUqtLIRCdOGNXqiI=
|
||||
github.com/google/pprof v0.0.0-20260604005048-7023385849c0 h1:h1QTMDl6q9wDvDCJVpKQSjgleGFYnd2fOxmg2K+6BGE=
|
||||
github.com/google/pprof v0.0.0-20260604005048-7023385849c0/go.mod h1:MxpfABSjhmINe3F1It9d+8exIHFvUqtLIRCdOGNXqiI=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/renameio/v2 v2.0.2 h1:qKZs+tfn+arruZZhQ7TKC/ergJunuJicWS6gLDt/dGw=
|
||||
github.com/google/renameio/v2 v2.0.2/go.mod h1:OX+G6WHHpHq3NVj7cAOleLOwJfcQ1s3uUJQCrr78SWo=
|
||||
@@ -512,8 +512,8 @@ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
|
||||
github.com/hashicorp/yamux v0.1.2 h1:XtB8kyFOyHXYVFnwT5C3+Bdo8gArse7j2AQ0DA0Uey8=
|
||||
github.com/hashicorp/yamux v0.1.2/go.mod h1:C+zze2n6e/7wshOZep2A70/aQU6QBRWJO/G6FT1wIns=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/huandu/xstrings v1.5.0 h1:2ag3IFq9ZDANvthTwTiqSSZLjDc+BedvHPAp5tJy2TI=
|
||||
github.com/huandu/xstrings v1.5.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
|
||||
github.com/huandu/xstrings v1.6.1 h1:yYdKSd6Sjv3fNZt9BDjl1FDsPNfQEaYi19L5LzK2JKs=
|
||||
github.com/huandu/xstrings v1.6.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
|
||||
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
|
||||
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
@@ -573,8 +573,8 @@ github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4
|
||||
github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
|
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/klauspost/compress v1.19.2 h1:hMRETovs/pu/dVWN7zIT1PGG8t509MwT6bO7XSi26R8=
|
||||
github.com/klauspost/compress v1.19.2/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ=
|
||||
github.com/klauspost/compress v1.20.0 h1:a3C1ke2ohxFymNlb2HWAHjDeKCI90scRskErZkR0ezA=
|
||||
github.com/klauspost/compress v1.20.0/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI=
|
||||
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.4.0 h1:S6Hrbc7+ywsr0r+RLapfGBHfyefhCTwEh3A0tV913Dw=
|
||||
github.com/klauspost/cpuid/v2 v2.4.0/go.mod h1:19jmZ9mjzoF//ddRSUsv0zfBTJWh3QJh9FNxZTMrGxU=
|
||||
@@ -641,16 +641,16 @@ github.com/mattermost/xml-roundtrip-validator v0.1.0 h1:RXbVD2UAl7A7nOTR4u7E3ILa
|
||||
github.com/mattermost/xml-roundtrip-validator v0.1.0/go.mod h1:qccnGMcpgwcNaBnxqpJpWWUiPNr5H3O8eDgGV9gT5To=
|
||||
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
|
||||
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
|
||||
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||
github.com/mattn/go-colorable v0.1.15 h1:+u9SLTRGnXv73cEsnsmoZBom+dMU88B2M0aDcWy0/jY=
|
||||
github.com/mattn/go-colorable v0.1.15/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mattn/go-isatty v0.0.21 h1:xYae+lCNBP7QuW4PUnNG61ffM4hVIfm+zUzDuSzYLGs=
|
||||
github.com/mattn/go-isatty v0.0.21/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4=
|
||||
github.com/mattn/go-isatty v0.0.22 h1:j8l17JJ9i6VGPUFUYoTUKPSgKe/83EYU2zBC7YNKMw4=
|
||||
github.com/mattn/go-isatty v0.0.22/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4=
|
||||
github.com/mattn/go-runewidth v0.0.23 h1:7ykA0T0jkPpzSvMS5i9uoNn2Xy3R383f9HDx3RybWcw=
|
||||
github.com/mattn/go-runewidth v0.0.23/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
|
||||
github.com/mattn/go-sqlite3 v1.14.50 h1:dmdFvo1XG4MPzA4IkAmE9upVz/Nj31uRoM5+jC8hYbY=
|
||||
github.com/mattn/go-sqlite3 v1.14.50/go.mod h1:6JTjA44L93a0QCyJef5YvlPoKXntQPjzWv5gtm9sB6w=
|
||||
github.com/mattn/go-sqlite3 v1.14.52 h1:wVbm2Qnf4OXkqhBTSPuCRZDRnxfbVrrmiCEroVdog8U=
|
||||
github.com/mattn/go-sqlite3 v1.14.52/go.mod h1:6JTjA44L93a0QCyJef5YvlPoKXntQPjzWv5gtm9sB6w=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/maxymania/go-system v0.0.0-20170110133659-647cc364bf0b h1:Q53idHrTuQDDHyXaxZ6pUl0I9uyD6Z6uKFK3ocX6LzI=
|
||||
github.com/maxymania/go-system v0.0.0-20170110133659-647cc364bf0b/go.mod h1:KirJrATYGbTyUwVR26xIkaipRqRcMRXBf8N5dacvGus=
|
||||
@@ -696,10 +696,10 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/nats-io/jwt/v2 v2.8.2 h1:XXRgB60MSTnqsRwejQurVDs/hcv2dkt+86GjI+I/bMc=
|
||||
github.com/nats-io/jwt/v2 v2.8.2/go.mod h1:Ag/56sq9OblL4JgdYufDd16Egb17Kr/8WwwuO/forVc=
|
||||
github.com/nats-io/nats-server/v2 v2.14.6 h1:dHjEHa49lUTxIb5jrsk5kz/AmOyOQ4T9ti8djcBumDQ=
|
||||
github.com/nats-io/nats-server/v2 v2.14.6/go.mod h1:u/0bNBzN/m5orQGz7q2NNzxCQ6PWdwaOSwPNDADZn/A=
|
||||
github.com/nats-io/nats.go v1.53.1 h1:Otsq3uLc/kLdjmkNHkXH0jBqwUquwdKFoe3fq6/3/Xo=
|
||||
github.com/nats-io/nats.go v1.53.1/go.mod h1:26HypzazeOkyO3/mqd1zZd53STJN0EjCYF9Uy2ZOBno=
|
||||
github.com/nats-io/nats-server/v2 v2.15.0 h1:M99yf0y05rTr46/qc/Is6ZAowI58Ryp2SjufLCUeVJc=
|
||||
github.com/nats-io/nats-server/v2 v2.15.0/go.mod h1:5qLF4CDGzZVFt//3fUrY1ePpwbi05r7QHPNroSUtolk=
|
||||
github.com/nats-io/nats.go v1.54.0 h1:vsXoOxjHp/GmPUN+EcI7uOf/uB+iAP+kEsAFNQN0yzA=
|
||||
github.com/nats-io/nats.go v1.54.0/go.mod h1:y+DZoD1oBOYfZTU681eTUiUjI0vbqYGixNVFHcjHJ0k=
|
||||
github.com/nats-io/nkeys v0.4.16 h1:rd5oAuLOb8mnAycB0xleuEBNS1pVVnN0fv/FF34Eypg=
|
||||
github.com/nats-io/nkeys v0.4.16/go.mod h1:llLgWoI0o4z/Q57q2R1kHfmocyhGV6VG/U18Glg1Afs=
|
||||
github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
|
||||
@@ -721,12 +721,12 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W
|
||||
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
||||
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
|
||||
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
|
||||
github.com/onsi/ginkgo/v2 v2.32.1 h1:6tlvcDm/3sE8lGJbZ4+d4mO3RLy24/tQWOFzVSQNIfw=
|
||||
github.com/onsi/ginkgo/v2 v2.32.1/go.mod h1:+aXOY+vzZ5mu2iI2HpTZUPmM//oQfsNFX6gU9kNcA44=
|
||||
github.com/onsi/ginkgo/v2 v2.33.0 h1:C8gBA6Uc2ZEubiV+SXiu5tZnMTwEmXHgkJwGozKtZf8=
|
||||
github.com/onsi/ginkgo/v2 v2.33.0/go.mod h1:+aXOY+vzZ5mu2iI2HpTZUPmM//oQfsNFX6gU9kNcA44=
|
||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||
github.com/onsi/gomega v1.43.0 h1:VlG/1FxqNxhSO+lq/OHBNaaqwiBK/mO8JbVkX9Y+FeU=
|
||||
github.com/onsi/gomega v1.43.0/go.mod h1:REff/hsDsodHoKlWsP2mAPhu1+5/6hVYNf9rIEBpeSg=
|
||||
github.com/onsi/gomega v1.44.0 h1:eAiGl3Pw5jz5GQdDff0BcxYpAX1JxW8xD7mFUuwNfZQ=
|
||||
github.com/onsi/gomega v1.44.0/go.mod h1:e/C2HwaZ1DhvjzXXuFhcR7hY7Sh9pl7MmoWKEjzwcdA=
|
||||
github.com/open-policy-agent/opa v1.19.0 h1:+j2OCsjMezZEML2T1lI9giJdGJS/PL1XFKgkHPGIhpo=
|
||||
github.com/open-policy-agent/opa v1.19.0/go.mod h1:pb6Y6klyf7X7X8uXNDflruA9dQC2gMqWROXI5w/kvv0=
|
||||
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
|
||||
@@ -736,8 +736,8 @@ github.com/orcaman/concurrent-map v1.0.0 h1:I/2A2XPCb4IuQWcQhBhSwGfiuybl/J0ev9HD
|
||||
github.com/orcaman/concurrent-map v1.0.0/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI=
|
||||
github.com/owncloud/libre-graph-api-go v1.0.5-0.20260216101009-eeac018af245 h1:JRidLTAKhnvyLMRtVtSF4lhBa0NSAOs6fof+d6JnKII=
|
||||
github.com/owncloud/libre-graph-api-go v1.0.5-0.20260216101009-eeac018af245/go.mod h1:z61VMGAJRtR1nbgXWiNoCkxUXP1B3Je9rMuJbnGd+Og=
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260917145219-ba14a94a3c7a h1:QnKAz6PPmeMgF+w5UJ70InpsrtUeW/6GX+ikkb61XVs=
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260917145219-ba14a94a3c7a/go.mod h1:VohDRQV33rVDiofWNngHqQK7tsgtYJpQBNWsn41j/LM=
|
||||
github.com/owncloud/reva/v2 v2.0.0-20261006130333-e8a7c20b6b93 h1:oq264ouHPdZkMkAVlApVncbY+9uK5pIlwlD5XmNl2FA=
|
||||
github.com/owncloud/reva/v2 v2.0.0-20261006130333-e8a7c20b6b93/go.mod h1:lr0ehPvNrODohFll0kJa/sIi2T6YskJLPjmR2tC2q2U=
|
||||
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw=
|
||||
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c/go.mod h1:X07ZCGwUbLaax7L0S3Tw4hpejzu63ZrrQiUe6W0hcy0=
|
||||
github.com/pablodz/inotifywaitgo v0.0.12 h1:DVJJTFMDlSAdO46yisPF2vzozs/r+4k6ih8MVghq78M=
|
||||
@@ -767,8 +767,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRI
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/pquerna/cachecontrol v0.2.0 h1:vBXSNuE5MYP9IJ5kjsdo8uq+w41jSPgvba2DEnkRx9k=
|
||||
github.com/pquerna/cachecontrol v0.2.0/go.mod h1:NrUG3Z7Rdu85UNR3vm7SOsl1nFIeSiQnrHV5K9mBcUI=
|
||||
github.com/prometheus/alertmanager v0.34.0 h1:z75n0NoypggESmt3HD4JlTXOaOZj1EBz1ACHO4Z6EUk=
|
||||
github.com/prometheus/alertmanager v0.34.0/go.mod h1:/qF39A6Vb1MMoDM1SxcySobb7wmpBZha8COwULiKUUo=
|
||||
github.com/prometheus/alertmanager v0.34.1 h1:qtIIP4s20duq2fbafHIti5NYJGaZNh7irXKbJwe/W/E=
|
||||
github.com/prometheus/alertmanager v0.34.1/go.mod h1:XlyJZycGA13e2hrjPMNrrB4C2tzsenmpt2Prya4taws=
|
||||
github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
||||
@@ -909,8 +909,8 @@ github.com/toorop/go-dkim v0.0.0-20201103131630-e1cd1a0a5208 h1:PM5hJF7HVfNWmCjM
|
||||
github.com/toorop/go-dkim v0.0.0-20201103131630-e1cd1a0a5208/go.mod h1:BzWtXXrXzZUvMacR0oF/fbDDgUPO8L36tDMmRAf14ns=
|
||||
github.com/trustelem/zxcvbn v1.0.1 h1:mp4JFtzdDYGj9WYSD3KQSkwwUumWNFzXaAjckaTYpsc=
|
||||
github.com/trustelem/zxcvbn v1.0.1/go.mod h1:zonUyKeh7sw6psPf/e3DtRqkRyZvAbOfjNz/aO7YQ5s=
|
||||
github.com/tus/tusd/v2 v2.10.0 h1:2yOGmkrDl9RQmRIt/00DR2WvYWOoiEu3CoygILb+WRw=
|
||||
github.com/tus/tusd/v2 v2.10.0/go.mod h1:T/OuJHIAC2NHpkEUyQyyaoWyDNRDcQVpJzWl8tX5GY4=
|
||||
github.com/tus/tusd/v2 v2.10.1 h1:hO312j4rT0unhaF4Ga7izNaYGbPOKI2kVIXbKgtv1W8=
|
||||
github.com/tus/tusd/v2 v2.10.1/go.mod h1:33RsdwtbXdqb3esrge+95TT7XUHl45uSO1vvA96fNbc=
|
||||
github.com/urfave/cli/v2 v2.27.7 h1:bH59vdhbjLv3LAvIu6gd0usJHgoTTPhCFib8qqOwXYU=
|
||||
github.com/urfave/cli/v2 v2.27.7/go.mod h1:CyNAG/xg+iAOg0N4MPGZqVmv2rCoP267496AOXUZjA4=
|
||||
github.com/valyala/fastjson v1.6.10 h1:/yjJg8jaVQdYR3arGxPE2X5z89xrlhS0eGXdv+ADTh4=
|
||||
@@ -950,12 +950,12 @@ github.com/zeebo/xxh3 v1.1.0 h1:s7DLGDK45Dyfg7++yxI0khrfwq9661w9EN78eP/UZVs=
|
||||
github.com/zeebo/xxh3 v1.1.0/go.mod h1:IisAie1LELR4xhVinxWS5+zf1lA4p0MW4T+w+W07F5s=
|
||||
go.etcd.io/bbolt v1.5.0 h1:S7GAl7Fxv12yohbwFfIbQCGDWbQbtDGPET4P/bD4lxU=
|
||||
go.etcd.io/bbolt v1.5.0/go.mod h1:mkltfYE5aUHQxUct9N9V+Kp7aSjFqjgrhcXIS70Lrdk=
|
||||
go.etcd.io/etcd/api/v3 v3.7.1 h1:KJG0/DcWGfe3Y1otDf/fsBf0TSSgpxZ5RO/L8SFt73E=
|
||||
go.etcd.io/etcd/api/v3 v3.7.1/go.mod h1:8bXIpCMeV7E3/XL0Ix123ATn3dB+0V7d9zklHbB0m78=
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.7.1 h1:rKYsj3pRkR0eK3yjT3XOgrhqfmIfj9pzNgxjh7mfFv4=
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.7.1/go.mod h1:cnzZGIUzSfjEwLC6UBVsSXlEK1eepS/JUD7wE6PLRT0=
|
||||
go.etcd.io/etcd/client/v3 v3.7.1 h1:0PEMMC0KuZmVIN+RAbdqfkZ45pYTgKVtmBEbRCvZFUg=
|
||||
go.etcd.io/etcd/client/v3 v3.7.1/go.mod h1:ffNqALa8tRCYhYo1F9oR489y23K39Gz+BSR3ApAGYq0=
|
||||
go.etcd.io/etcd/api/v3 v3.7.2 h1:xgt/6el1LsPWWYNLkhMAK4tZm6dF+1sCqDecpE5gdbk=
|
||||
go.etcd.io/etcd/api/v3 v3.7.2/go.mod h1:RoRCBRt9BfBff1pIGZLUVMiz7wu3bY+b2qLysGu1HY4=
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.7.2 h1:SVtlR7tiSVAYOQ4nWPIyFXb4RMgEcnzeAG9RQ8MoNDU=
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.7.2/go.mod h1:HsSux/B3ahgyw/D5+d4YbZqicOi0mEbuxm6lIUdjAoI=
|
||||
go.etcd.io/etcd/client/v3 v3.7.2 h1:Z66GqDQDI7zPDfVSsIBqGSK4mJYLtv8ESwXa4mPf+wY=
|
||||
go.etcd.io/etcd/client/v3 v3.7.2/go.mod h1:x03t1qMs4tGZirCDJlMuzPBJdQffXJImIyEjLhNBCsY=
|
||||
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
||||
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
||||
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
@@ -1016,8 +1016,8 @@ golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0
|
||||
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
|
||||
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
|
||||
golang.org/x/crypto v0.56.0 h1:GUh5Ii4J5jtcseSMiRqr1jXCNHoxjeV9Fmekc2oLy6Y=
|
||||
golang.org/x/crypto v0.56.0/go.mod h1:OMW5y6CY9l38uPLmxU6l6pwcXp1obtLo3e6gT7gQR2I=
|
||||
golang.org/x/crypto v0.57.0 h1:3ZVCjf8Ggz7zneR/EHRVx68Ctf+2pmIMP2UFhh9cC6M=
|
||||
golang.org/x/crypto v0.57.0/go.mod h1:Fdz0i5U6CoizGwLda9DttjSk6qlZo25zYNtR+ycvuZA=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||
@@ -1028,8 +1028,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
|
||||
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
||||
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
|
||||
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
|
||||
golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f h1:W3F4c+6OLc6H2lb//N1q4WpJkhzJCK5J6kUi1NTVXfM=
|
||||
golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f/go.mod h1:J1xhfL/vlindoeF/aINzNzt2Bket5bjo9sdOYzOsU80=
|
||||
golang.org/x/exp v0.0.0-20260611194520-c48552f49976 h1:X8Hz2ImujgbmetVuW+w2YkyZChE3cBpZi2P158rTG9M=
|
||||
golang.org/x/exp v0.0.0-20260611194520-c48552f49976/go.mod h1:vnf4pv9iKZXY58sQE1L86zmNWJ4159e1RkcWiLCkeEY=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.45.0 h1:FMb1nTbH5H9vF55SriQHgFw5GnNL9Jg6L25BwXKzhB0=
|
||||
@@ -1055,8 +1055,8 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.40.0 h1:hUv+3cXcdRHz08UmSiOob7sadHig73uo5bkXxQ/tvUs=
|
||||
golang.org/x/mod v0.40.0/go.mod h1:0/weTWkPWGBikyTWAX3dkjVztMmBA5hM0DH6BElSupE=
|
||||
golang.org/x/mod v0.41.0 h1:qJmnOUb4YB+FsEuM3HcWucdZASCPGhsX6uljO6pog0c=
|
||||
golang.org/x/mod v0.41.0/go.mod h1:Ek9pY8RKWXwsWvd3rQiHYtMqkjSUV+s1Rj7j4H5Ur6o=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@@ -1109,8 +1109,8 @@ golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4Iltr
|
||||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc=
|
||||
golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs=
|
||||
golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q=
|
||||
golang.org/x/oauth2 v0.37.0 h1:JUlcxA8oAtauLfiH8FX2/FkAWHAdi0QtGCGc+hofE98=
|
||||
golang.org/x/oauth2 v0.37.0/go.mod h1:IxwZNxUULJmpBFf9K/9NTMSIfZZuvuTy1gGxhigP/58=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
@@ -1125,8 +1125,8 @@ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJ
|
||||
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek=
|
||||
golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||
golang.org/x/sync v0.23.0 h1:KameEIfc1IkluZyXWLn39Wd4tURc6GbCiISGiZm2bQk=
|
||||
golang.org/x/sync v0.23.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@@ -1189,8 +1189,8 @@ golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
|
||||
golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||
golang.org/x/sys v0.48.0 h1:bbX/i/6MgT9BVLM9RT1thmxL04yeTAhbEz4SyadbXoo=
|
||||
golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
@@ -1198,8 +1198,8 @@ golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
||||
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
|
||||
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
||||
golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58=
|
||||
golang.org/x/term v0.45.0 h1:NwWyBmoJCbfTHpxrWoZ9C6/VxOf7ic219I8xZZFdrf0=
|
||||
golang.org/x/term v0.45.0/go.mod h1:9aqxs0blBcrm/n0L9QW0aRVD+ktan8ssZromtqJC43w=
|
||||
golang.org/x/term v0.46.0 h1:3+OXuTbaKDgwk8jTi3aSLHRlmWqHEUDUtxnbFigO4YE=
|
||||
golang.org/x/term v0.46.0/go.mod h1:+K02xbkittuwc0Am4abfA3Fc+XRGXkvBXNO88NCXPoc=
|
||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
@@ -1211,13 +1211,13 @@ golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.41.0 h1:vz/seA0lnX87Othu2f/0L24RcgrXD9/YFTSuGjj3rH8=
|
||||
golang.org/x/text v0.41.0/go.mod h1:jvf1O8ajNzZqhSrQBPbutR/EB83Cc0CFrezNQIwbb5M=
|
||||
golang.org/x/text v0.42.0 h1:JbOZXgfeCPU9gacVtYliJqOhD+zhrEqK4LfdpmlUZqI=
|
||||
golang.org/x/text v0.42.0/go.mod h1:ojzP1Z+2QtioaF8DTtO8K5q7JWVVYwZKenzujK0Zd0E=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U=
|
||||
golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno=
|
||||
golang.org/x/time v0.16.0 h1:vMb6ptszcQMkcwiRTAuNNU50gom6++Q/6gY2hDM6VDE=
|
||||
golang.org/x/time v0.16.0/go.mod h1:rVKOqvZeKvrDKTQiAHJ7wmwP0RzleSphoEA9RcdLA0s=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
@@ -1325,8 +1325,8 @@ google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7Fc
|
||||
google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20260319201613-d00831a3d3e7 h1:XzmzkmB14QhVhgnawEVsOn6OFsnpyxNPRY9QV01dNB0=
|
||||
google.golang.org/genproto v0.0.0-20260319201613-d00831a3d3e7/go.mod h1:L43LFes82YgSonw6iTXTxXUX1OlULt4AQtkik4ULL/I=
|
||||
google.golang.org/genproto v0.0.0-20260622175928-b703f567277d h1:CP5omUq8AJTiWMrPKM1WRLJ7zZeXd9OPcQD3TbBNAyY=
|
||||
google.golang.org/genproto v0.0.0-20260622175928-b703f567277d/go.mod h1:DrwuGJgFSEVNpv3S5Q5VxhRTvdnjauw9GtvwVOEARfA=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260819154853-08b0e4226688 h1:ax2KzoSRIZU/M0cIxri3pKxy99vniH1PVxWC6si/eZI=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260819154853-08b0e4226688/go.mod h1:1RJ9BQGyNdZwkGc1eTqkErfRZ6RJyYPHZo73BZ1vQqI=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260825221802-da73d73af1c5 h1:1VUiZAXyC+zmiFYi+WLtBzr68Cj8wOofHjjrA/kkizc=
|
||||
@@ -1344,8 +1344,8 @@ google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3Iji
|
||||
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||
google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
|
||||
google.golang.org/grpc v1.83.2 h1:EManeRomTObA0BU7I8vXgg/78uE5MJ9M8B39EX2WscU=
|
||||
google.golang.org/grpc v1.83.2/go.mod h1:YPI1hK3kDked6iHvgX3tR0y+nX/qpMFKhPgFsokw1S8=
|
||||
google.golang.org/grpc v1.84.0 h1:soMyaPJ8pAak5PIQ0DGBUir0XRo2fRoMqhNWMLlLxO0=
|
||||
google.golang.org/grpc v1.84.0/go.mod h1:ljCht0DrxQrXBDRTZp52Qxh3Ffk8CdYm2sj4O2QN2C0=
|
||||
google.golang.org/grpc/examples v0.0.0-20211102180624-670c133e568e h1:m7aQHHqd0q89mRwhwS9Bx2rjyl/hsFAeta+uGrHsQaU=
|
||||
google.golang.org/grpc/examples v0.0.0-20211102180624-670c133e568e/go.mod h1:gID3PKrg7pWKntu9Ss6zTLJ0ttC0X9IHgREOCZwbCVU=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
|
||||
@@ -3,6 +3,7 @@ package revaconfig
|
||||
import (
|
||||
"math"
|
||||
"net/url"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/cors"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/log"
|
||||
@@ -100,8 +101,9 @@ func OCMConfigFromStruct(cfg *config.Config, logger log.Logger) map[string]inter
|
||||
"service_account_secret": cfg.ServiceAccount.Secret,
|
||||
},
|
||||
"dataprovider": map[string]interface{}{
|
||||
"prefix": "data",
|
||||
"driver": "ocmreceived",
|
||||
"prefix": "data",
|
||||
"driver": "ocmreceived",
|
||||
"upload_directory": filepath.Join(cfg.OCMStorageProvider.StorageRoot, "uploads"),
|
||||
"drivers": map[string]interface{}{
|
||||
"ocmreceived": map[string]interface{}{
|
||||
"insecure": cfg.OCMStorageProvider.Insecure,
|
||||
@@ -190,7 +192,8 @@ func OCMConfigFromStruct(cfg *config.Config, logger log.Logger) map[string]inter
|
||||
},
|
||||
},
|
||||
"storageprovider": map[string]interface{}{
|
||||
"driver": "ocmreceived",
|
||||
"driver": "ocmreceived",
|
||||
"upload_directory": filepath.Join(cfg.OCMStorageProvider.StorageRoot, "uploads"),
|
||||
"drivers": map[string]interface{}{
|
||||
"ocmreceived": map[string]interface{}{
|
||||
"insecure": cfg.OCMStorageProvider.Insecure,
|
||||
|
||||
@@ -87,6 +87,7 @@ func StorageUsersConfigFromStruct(cfg *config.Config) map[string]interface{} {
|
||||
"prefix": cfg.HTTP.Prefix,
|
||||
"driver": cfg.Driver,
|
||||
"drivers": DataProviderDrivers(cfg),
|
||||
"mount_id": cfg.MountID,
|
||||
"nats_address": cfg.Events.Addr,
|
||||
"nats_clusterID": cfg.Events.ClusterID,
|
||||
"nats_tls_insecure": cfg.Events.TLSInsecure,
|
||||
|
||||
+18
-3
@@ -129,6 +129,9 @@ const (
|
||||
|
||||
// Always asserts that condition is true every time this function is called, and that it is called at least once. The corresponding test property will be viewable in the Antithesis SDK: Always group of your triage report.
|
||||
func Always(condition bool, message string, details map[string]any) {
|
||||
if trackerEmitted(message, condition) {
|
||||
return
|
||||
}
|
||||
locationInfo := newLocationInfo(offsetAPICaller)
|
||||
id := makeKey(message, locationInfo)
|
||||
assertImpl(condition, message, details, locationInfo, wasHit, mustBeHit, universalTest, alwaysDisplay, id)
|
||||
@@ -136,6 +139,9 @@ func Always(condition bool, message string, details map[string]any) {
|
||||
|
||||
// AlwaysOrUnreachable asserts that condition is true every time this function is called. The corresponding test property will pass if the assertion is never encountered (unlike Always assertion types). This test property will be viewable in the “Antithesis SDK: Always” group of your triage report.
|
||||
func AlwaysOrUnreachable(condition bool, message string, details map[string]any) {
|
||||
if trackerEmitted(message, condition) {
|
||||
return
|
||||
}
|
||||
locationInfo := newLocationInfo(offsetAPICaller)
|
||||
id := makeKey(message, locationInfo)
|
||||
assertImpl(condition, message, details, locationInfo, wasHit, optionallyHit, universalTest, alwaysOrUnreachableDisplay, id)
|
||||
@@ -143,6 +149,9 @@ func AlwaysOrUnreachable(condition bool, message string, details map[string]any)
|
||||
|
||||
// Sometimes asserts that condition is true at least one time that this function was called. (If the assertion is never encountered, the test property will therefore fail.) This test property will be viewable in the “Antithesis SDK: Sometimes” group.
|
||||
func Sometimes(condition bool, message string, details map[string]any) {
|
||||
if trackerEmitted(message, condition) {
|
||||
return
|
||||
}
|
||||
locationInfo := newLocationInfo(offsetAPICaller)
|
||||
id := makeKey(message, locationInfo)
|
||||
assertImpl(condition, message, details, locationInfo, wasHit, mustBeHit, existentialTest, sometimesDisplay, id)
|
||||
@@ -150,6 +159,9 @@ func Sometimes(condition bool, message string, details map[string]any) {
|
||||
|
||||
// Unreachable asserts that a line of code is never reached. The corresponding test property will fail if this function is ever called. (If it is never called the test property will therefore pass.) This test property will be viewable in the “Antithesis SDK: Reachablity assertions” group.
|
||||
func Unreachable(message string, details map[string]any) {
|
||||
if trackerEmitted(message, false) {
|
||||
return
|
||||
}
|
||||
locationInfo := newLocationInfo(offsetAPICaller)
|
||||
id := makeKey(message, locationInfo)
|
||||
assertImpl(false, message, details, locationInfo, wasHit, optionallyHit, reachabilityTest, unreachableDisplay, id)
|
||||
@@ -157,6 +169,9 @@ func Unreachable(message string, details map[string]any) {
|
||||
|
||||
// Reachable asserts that a line of code is reached at least once. The corresponding test property will pass if this function is ever called. (If it is never called the test property will therefore fail.) This test property will be viewable in the “Antithesis SDK: Reachablity assertions” group.
|
||||
func Reachable(message string, details map[string]any) {
|
||||
if trackerEmitted(message, true) {
|
||||
return
|
||||
}
|
||||
locationInfo := newLocationInfo(offsetAPICaller)
|
||||
id := makeKey(message, locationInfo)
|
||||
assertImpl(true, message, details, locationInfo, wasHit, mustBeHit, reachabilityTest, reachableDisplay, id)
|
||||
@@ -164,13 +179,13 @@ func Reachable(message string, details map[string]any) {
|
||||
|
||||
// AssertRaw is a low-level method designed to be used by third-party frameworks. Regular users of the assert package should not call it.
|
||||
func AssertRaw(cond bool, message string, details map[string]any,
|
||||
classname, funcname, filename string, line int,
|
||||
classname, funcname, filename string, line int, column int,
|
||||
hit bool, mustHit bool,
|
||||
assertType string, displayType string,
|
||||
id string,
|
||||
) {
|
||||
assertImpl(cond, message, details,
|
||||
&locationInfo{classname, funcname, filename, line, columnUnknown},
|
||||
&locationInfo{classname, funcname, filename, line, column},
|
||||
hit, mustHit,
|
||||
assertType, displayType,
|
||||
id)
|
||||
@@ -182,7 +197,7 @@ func assertImpl(cond bool, message string, details map[string]any,
|
||||
assertType string, displayType string,
|
||||
id string,
|
||||
) {
|
||||
trackerEntry := assertTracker.getTrackerEntry(id, loc.Filename, loc.Classname)
|
||||
trackerEntry := getTrackerEntry(id, loc.Filename, loc.Classname)
|
||||
|
||||
// Always grab the Filename and Classname captured when the trackerEntry was established
|
||||
// This provides the consistency needed between instrumentation-time and runtime
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ func Sometimes(condition bool, message string, details map[string]any)
|
||||
func Unreachable(message string, details map[string]any) {}
|
||||
func Reachable(message string, details map[string]any) {}
|
||||
func AssertRaw(cond bool, message string, details map[string]any,
|
||||
classname, funcname, filename string, line int,
|
||||
classname, funcname, filename string, line int, column int,
|
||||
hit bool, mustHit bool,
|
||||
assertType string, displayType string,
|
||||
id string,
|
||||
|
||||
+13
-40
@@ -8,43 +8,22 @@ import (
|
||||
"github.com/antithesishq/antithesis-sdk-go/internal"
|
||||
)
|
||||
|
||||
// TODO: Tracker is intended to prevent sending the same guidance
|
||||
// more than once. In this case, we always send, so the tracker
|
||||
// is not presently used.
|
||||
type booleanGuidance struct {
|
||||
n int
|
||||
}
|
||||
// TODO: Someday this tracker should also start deduplicating
|
||||
// guidance, but there are some complicated policy questions
|
||||
// to settle before we do that.
|
||||
type booleanGuidance struct{}
|
||||
|
||||
type booleanGuidanceTracker map[string]*booleanGuidance
|
||||
// booleanGuidanceTracker keeps the per-id entries: a grow-only map with
|
||||
// stable keys, read on every rich-assert evaluation and written once per
|
||||
// guidance id.
|
||||
var booleanGuidanceTracker sync.Map // message key -> *booleanGuidance
|
||||
|
||||
var (
|
||||
boolean_guidance_tracker booleanGuidanceTracker = make(booleanGuidanceTracker)
|
||||
boolean_guidance_tracker_mutex sync.Mutex
|
||||
boolean_guidance_info_mutex sync.Mutex
|
||||
)
|
||||
|
||||
func (tracker booleanGuidanceTracker) getTrackerEntry(messageKey string) *booleanGuidance {
|
||||
var trackerEntry *booleanGuidance
|
||||
var ok bool
|
||||
|
||||
if tracker == nil {
|
||||
return nil
|
||||
func getBooleanGuidanceEntry(messageKey string) *booleanGuidance {
|
||||
if entry, ok := booleanGuidanceTracker.Load(messageKey); ok {
|
||||
return entry.(*booleanGuidance)
|
||||
}
|
||||
|
||||
boolean_guidance_tracker_mutex.Lock()
|
||||
defer boolean_guidance_tracker_mutex.Unlock()
|
||||
if trackerEntry, ok = boolean_guidance_tracker[messageKey]; !ok {
|
||||
trackerEntry = newBooleanGuidance()
|
||||
tracker[messageKey] = trackerEntry
|
||||
}
|
||||
|
||||
return trackerEntry
|
||||
}
|
||||
|
||||
// Create a boolean guidance tracker
|
||||
func newBooleanGuidance() *booleanGuidance {
|
||||
trackerInfo := booleanGuidance{}
|
||||
return &trackerInfo
|
||||
entry, _ := booleanGuidanceTracker.LoadOrStore(messageKey, &booleanGuidance{})
|
||||
return entry.(*booleanGuidance)
|
||||
}
|
||||
|
||||
func (tI *booleanGuidance) send_value(bgI *booleanGuidanceInfo) {
|
||||
@@ -52,12 +31,6 @@ func (tI *booleanGuidance) send_value(bgI *booleanGuidanceInfo) {
|
||||
return
|
||||
}
|
||||
|
||||
boolean_guidance_info_mutex.Lock()
|
||||
defer boolean_guidance_info_mutex.Unlock()
|
||||
|
||||
// The tracker entry should be consulted to determine
|
||||
// if this Guidance info has already been sent, or not.
|
||||
|
||||
emitBooleanGuidance(bgI)
|
||||
}
|
||||
|
||||
|
||||
+67
-78
@@ -5,6 +5,7 @@ package assert
|
||||
import (
|
||||
"math"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/antithesishq/antithesis-sdk-go/internal"
|
||||
)
|
||||
@@ -45,35 +46,26 @@ func gapTypeForOperand[T Number](num T) numericGapType {
|
||||
//
|
||||
// --------------------------------------------------------------------------------
|
||||
type numericGuidanceInfo struct {
|
||||
gap any
|
||||
descriminator numericGapType
|
||||
maximize bool
|
||||
// The best gap sent so far (a gapValue[uint64] or gapValue[float64],
|
||||
// fixed per entry). Read lock-free on every evaluation; updated under mu.
|
||||
gap atomic.Value
|
||||
// Serializes improvements (compare, update, emit) so guidance emissions
|
||||
// form an ordered monotone chain; the no-improvement fast path never
|
||||
// takes it.
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
type numericGuidanceTracker map[string]*numericGuidanceInfo
|
||||
var numericGuidanceTracker sync.Map // message key -> *numericGuidanceInfo
|
||||
|
||||
var (
|
||||
numeric_guidance_tracker numericGuidanceTracker = make(numericGuidanceTracker)
|
||||
numeric_guidance_tracker_mutex sync.Mutex
|
||||
numeric_guidance_info_mutex sync.Mutex
|
||||
)
|
||||
|
||||
func (tracker numericGuidanceTracker) getTrackerEntry(messageKey string, trackerType numericGapType, maximize bool) *numericGuidanceInfo {
|
||||
var trackerEntry *numericGuidanceInfo
|
||||
var ok bool
|
||||
|
||||
if tracker == nil {
|
||||
return nil
|
||||
func getNumericGuidanceEntry(messageKey string, trackerType numericGapType, maximize bool) *numericGuidanceInfo {
|
||||
if entry, ok := numericGuidanceTracker.Load(messageKey); ok {
|
||||
return entry.(*numericGuidanceInfo)
|
||||
}
|
||||
|
||||
numeric_guidance_tracker_mutex.Lock()
|
||||
defer numeric_guidance_tracker_mutex.Unlock()
|
||||
if trackerEntry, ok = numeric_guidance_tracker[messageKey]; !ok {
|
||||
trackerEntry = newNumericGuidanceInfo(trackerType, maximize)
|
||||
tracker[messageKey] = trackerEntry
|
||||
}
|
||||
|
||||
return trackerEntry
|
||||
entry, _ := numericGuidanceTracker.LoadOrStore(messageKey,
|
||||
newNumericGuidanceInfo(trackerType, maximize))
|
||||
return entry.(*numericGuidanceInfo)
|
||||
}
|
||||
|
||||
// Create an numeric guidance entry
|
||||
@@ -88,8 +80,8 @@ func newNumericGuidanceInfo(trackerType numericGapType, maximize bool) *numericG
|
||||
trackerInfo := numericGuidanceInfo{
|
||||
maximize: maximize,
|
||||
descriminator: trackerType,
|
||||
gap: gap,
|
||||
}
|
||||
trackerInfo.gap.Store(gap)
|
||||
return &trackerInfo
|
||||
}
|
||||
|
||||
@@ -175,14 +167,51 @@ func is_less_than[T numConstraint](left gapValue[T], right gapValue[T]) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// The candidate gap for a pair of guidance operands, in the tracker's
|
||||
// representation (nil when the operand type resolves to none).
|
||||
func candidateGap(data any) any {
|
||||
// Needs to have individual case statements to assist
|
||||
// the compiler to infer the actual type of the var named 'operands'
|
||||
switch operands := data.(type) {
|
||||
case numericOperands[int32]:
|
||||
return makeGap(operands)
|
||||
case numericOperands[int64]:
|
||||
return makeGap(operands)
|
||||
case numericOperands[uint64]:
|
||||
return makeGap(operands)
|
||||
case numericOperands[float64]:
|
||||
return makeFloatGap(operands)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Whether candidate improves on the entry's tracked extremum.
|
||||
func (tI *numericGuidanceInfo) improves(candidate any) bool {
|
||||
maximize := tI.should_maximize()
|
||||
switch prev := tI.gap.Load().(type) {
|
||||
case gapValue[uint64]:
|
||||
if gap, ok := candidate.(gapValue[uint64]); ok {
|
||||
if maximize {
|
||||
return is_greater_than(gap, prev)
|
||||
}
|
||||
return is_less_than(gap, prev)
|
||||
}
|
||||
case gapValue[float64]:
|
||||
if gap, ok := candidate.(gapValue[float64]); ok {
|
||||
if maximize {
|
||||
return is_greater_than(gap, prev)
|
||||
}
|
||||
return is_less_than(gap, prev)
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func send_value_if_needed(tI *numericGuidanceInfo, gI *guidanceInfo) {
|
||||
if tI == nil {
|
||||
return
|
||||
}
|
||||
|
||||
numeric_guidance_info_mutex.Lock()
|
||||
defer numeric_guidance_info_mutex.Unlock()
|
||||
|
||||
// if this is a catalog entry (gI.hit is false)
|
||||
// do not update the reference gap in the tracker (tI *numericGuidanceInfo)
|
||||
if !gI.Hit {
|
||||
@@ -190,59 +219,19 @@ func send_value_if_needed(tI *numericGuidanceInfo, gI *guidanceInfo) {
|
||||
return
|
||||
}
|
||||
|
||||
should_send := false
|
||||
maximize := tI.should_maximize()
|
||||
|
||||
var gap gapValue[uint64]
|
||||
var float_gap gapValue[float64]
|
||||
|
||||
// Needs to have individual case statements to assist
|
||||
// the compiler to infer the actual type of the var named 'operands'
|
||||
switch operands := (gI.Data).(type) {
|
||||
case numericOperands[int32]:
|
||||
gap = makeGap(operands)
|
||||
case numericOperands[int64]:
|
||||
gap = makeGap(operands)
|
||||
case numericOperands[uint64]:
|
||||
gap = makeGap(operands)
|
||||
case numericOperands[float64]:
|
||||
float_gap = makeFloatGap(operands)
|
||||
// Most evaluations do not improve on the tracked extremum; that path is
|
||||
// a lock-free load and compare. The mutex serializes only improvements.
|
||||
candidate := candidateGap(gI.Data)
|
||||
if !tI.improves(candidate) {
|
||||
return
|
||||
}
|
||||
|
||||
var prev_gap gapValue[uint64]
|
||||
var prev_float_gap gapValue[float64]
|
||||
has_prev_gap := false
|
||||
has_prev_float_gap := false
|
||||
|
||||
prev_gap, has_prev_gap = tI.gap.(gapValue[uint64])
|
||||
if !has_prev_gap {
|
||||
prev_float_gap, has_prev_float_gap = tI.gap.(gapValue[float64])
|
||||
}
|
||||
|
||||
if has_prev_gap {
|
||||
if maximize {
|
||||
should_send = is_greater_than(gap, prev_gap)
|
||||
} else {
|
||||
should_send = is_less_than(gap, prev_gap)
|
||||
}
|
||||
}
|
||||
|
||||
if has_prev_float_gap {
|
||||
if maximize {
|
||||
should_send = is_greater_than(float_gap, prev_float_gap)
|
||||
} else {
|
||||
should_send = is_less_than(float_gap, prev_float_gap)
|
||||
}
|
||||
}
|
||||
|
||||
if should_send {
|
||||
if tI.is_integer_gap() {
|
||||
tI.gap = gap
|
||||
} else {
|
||||
tI.gap = float_gap
|
||||
}
|
||||
emitGuidance(gI)
|
||||
tI.mu.Lock()
|
||||
defer tI.mu.Unlock()
|
||||
if !tI.improves(candidate) {
|
||||
return
|
||||
}
|
||||
tI.gap.Store(candidate)
|
||||
emitGuidance(gI)
|
||||
}
|
||||
|
||||
func emitGuidance(gI *guidanceInfo) error {
|
||||
|
||||
+42
-2
@@ -139,13 +139,13 @@ func behavior_to_guidance(behavior string) guidanceFnType {
|
||||
}
|
||||
|
||||
func numericGuidanceImpl[T Number](left, right T, message, id string, loc *locationInfo, guidanceFn guidanceFnType, hit bool) {
|
||||
tI := numeric_guidance_tracker.getTrackerEntry(id, gapTypeForOperand(left), uses_maximize(guidanceFn))
|
||||
tI := getNumericGuidanceEntry(id, gapTypeForOperand(left), uses_maximize(guidanceFn))
|
||||
gI := build_numeric_guidance(guidanceFn, message, left, right, loc, id, hit)
|
||||
send_value_if_needed(tI, gI)
|
||||
}
|
||||
|
||||
func booleanGuidanceImpl(named_bools []NamedBool, message, id string, loc *locationInfo, guidanceFn guidanceFnType, hit bool) {
|
||||
tI := boolean_guidance_tracker.getTrackerEntry(id)
|
||||
tI := getBooleanGuidanceEntry(id)
|
||||
bgI := build_boolean_guidance(guidanceFn, message, named_bools, loc, id, hit)
|
||||
tI.send_value(bgI)
|
||||
}
|
||||
@@ -207,8 +207,27 @@ func add_boolean_details(details map[string]any, named_bools []NamedBool) map[st
|
||||
return enhancedDetails
|
||||
}
|
||||
|
||||
// Whether a numeric rich-assert evaluation can return before capturing its
|
||||
// location or building its details: the assertion side has already emitted
|
||||
// for this condition, and the guidance side does not improve the tracked
|
||||
// extremum. Both checks are lock-free loads. False while the guidance entry
|
||||
// does not exist, so the first evaluation still takes the full path.
|
||||
func numericRichAssertSettled[T Number](left, right T, message string, condition bool) bool {
|
||||
if !trackerEmitted(message, condition) {
|
||||
return false
|
||||
}
|
||||
entry, ok := numericGuidanceTracker.Load(message)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
return !entry.(*numericGuidanceInfo).improves(candidateGap(newOperands(left, right)))
|
||||
}
|
||||
|
||||
// Equivalent to asserting Always(left > right, message, details). Information about left and right will automatically be added to the details parameter, with keys left and right. If you use this function for assertions that compare numeric quantities, you may help Antithesis find more bugs.
|
||||
func AlwaysGreaterThan[T Number](left, right T, message string, details map[string]any) {
|
||||
if numericRichAssertSettled(left, right, message, left > right) {
|
||||
return
|
||||
}
|
||||
loc := newLocationInfo(offsetAPICaller)
|
||||
id := makeKey(message, loc)
|
||||
condition := left > right
|
||||
@@ -220,6 +239,9 @@ func AlwaysGreaterThan[T Number](left, right T, message string, details map[stri
|
||||
|
||||
// Equivalent to asserting Always(left >= right, message, details). Information about left and right will automatically be added to the details parameter, with keys left and right. If you use this function for assertions that compare numeric quantities, you may help Antithesis find more bugs.
|
||||
func AlwaysGreaterThanOrEqualTo[T Number](left, right T, message string, details map[string]any) {
|
||||
if numericRichAssertSettled(left, right, message, left >= right) {
|
||||
return
|
||||
}
|
||||
loc := newLocationInfo(offsetAPICaller)
|
||||
id := makeKey(message, loc)
|
||||
condition := left >= right
|
||||
@@ -231,6 +253,9 @@ func AlwaysGreaterThanOrEqualTo[T Number](left, right T, message string, details
|
||||
|
||||
// Equivalent to asserting Sometimes(T left > T right, message, details). Information about left and right will automatically be added to the details parameter, with keys left and right. If you use this function for assertions that compare numeric quantities, you may help Antithesis find more bugs.
|
||||
func SometimesGreaterThan[T Number](left, right T, message string, details map[string]any) {
|
||||
if numericRichAssertSettled(left, right, message, left > right) {
|
||||
return
|
||||
}
|
||||
loc := newLocationInfo(offsetAPICaller)
|
||||
id := makeKey(message, loc)
|
||||
condition := left > right
|
||||
@@ -242,6 +267,9 @@ func SometimesGreaterThan[T Number](left, right T, message string, details map[s
|
||||
|
||||
// Equivalent to asserting Sometimes(T left >= T right, message, details). Information about left and right will automatically be added to the details parameter, with keys left and right. If you use this function for assertions that compare numeric quantities, you may help Antithesis find more bugs.
|
||||
func SometimesGreaterThanOrEqualTo[T Number](left, right T, message string, details map[string]any) {
|
||||
if numericRichAssertSettled(left, right, message, left >= right) {
|
||||
return
|
||||
}
|
||||
loc := newLocationInfo(offsetAPICaller)
|
||||
id := makeKey(message, loc)
|
||||
condition := left >= right
|
||||
@@ -253,6 +281,9 @@ func SometimesGreaterThanOrEqualTo[T Number](left, right T, message string, deta
|
||||
|
||||
// Equivalent to asserting Always(left < right, message, details). Information about left and right will automatically be added to the details parameter, with keys left and right. If you use this function for assertions that compare numeric quantities, you may help Antithesis find more bugs.
|
||||
func AlwaysLessThan[T Number](left, right T, message string, details map[string]any) {
|
||||
if numericRichAssertSettled(left, right, message, left < right) {
|
||||
return
|
||||
}
|
||||
loc := newLocationInfo(offsetAPICaller)
|
||||
id := makeKey(message, loc)
|
||||
condition := left < right
|
||||
@@ -264,6 +295,9 @@ func AlwaysLessThan[T Number](left, right T, message string, details map[string]
|
||||
|
||||
// Equivalent to asserting Always(left <= right, message, details). Information about left and right will automatically be added to the details parameter, with keys left and right. If you use this function for assertions that compare numeric quantities, you may help Antithesis find more bugs.
|
||||
func AlwaysLessThanOrEqualTo[T Number](left, right T, message string, details map[string]any) {
|
||||
if numericRichAssertSettled(left, right, message, left <= right) {
|
||||
return
|
||||
}
|
||||
loc := newLocationInfo(offsetAPICaller)
|
||||
id := makeKey(message, loc)
|
||||
condition := left <= right
|
||||
@@ -275,6 +309,9 @@ func AlwaysLessThanOrEqualTo[T Number](left, right T, message string, details ma
|
||||
|
||||
// Equivalent to asserting Sometimes(T left < T right, message, details). Information about left and right will automatically be added to the details parameter, with keys left and right. If you use this function for assertions that compare numeric quantities, you may help Antithesis find more bugs.
|
||||
func SometimesLessThan[T Number](left, right T, message string, details map[string]any) {
|
||||
if numericRichAssertSettled(left, right, message, left < right) {
|
||||
return
|
||||
}
|
||||
loc := newLocationInfo(offsetAPICaller)
|
||||
id := makeKey(message, loc)
|
||||
condition := left < right
|
||||
@@ -286,6 +323,9 @@ func SometimesLessThan[T Number](left, right T, message string, details map[stri
|
||||
|
||||
// Equivalent to asserting Sometimes(T left <= T right, message, details). Information about left and right will automatically be added to the details parameter, with keys left and right. If you use this function for assertions that compare numeric quantities, you may help Antithesis find more bugs.
|
||||
func SometimesLessThanOrEqualTo[T Number](left, right T, message string, details map[string]any) {
|
||||
if numericRichAssertSettled(left, right, message, left <= right) {
|
||||
return
|
||||
}
|
||||
loc := newLocationInfo(offsetAPICaller)
|
||||
id := makeKey(message, loc)
|
||||
condition := left <= right
|
||||
|
||||
+41
-68
@@ -3,54 +3,34 @@
|
||||
package assert
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/antithesishq/antithesis-sdk-go/internal"
|
||||
)
|
||||
|
||||
// Tracking info for one assertion id.
|
||||
type trackerInfo struct {
|
||||
Filename string
|
||||
Classname string
|
||||
PassCount int
|
||||
FailCount int
|
||||
|
||||
passEmitted atomic.Bool
|
||||
failEmitted atomic.Bool
|
||||
// Serializes only first-emission attempts (including retries after an
|
||||
// emission error); never taken once a flag is set.
|
||||
emitMutex sync.Mutex
|
||||
}
|
||||
|
||||
type emitTracker map[string]*trackerInfo
|
||||
// assertTracker keeps track of the unique asserts evaluated.
|
||||
var assertTracker sync.Map // message key -> *trackerInfo
|
||||
|
||||
// assert_tracker (global) keeps track of the unique asserts evaluated
|
||||
var (
|
||||
assertTracker emitTracker = make(emitTracker)
|
||||
trackerMutex sync.Mutex
|
||||
trackerInfoMutex sync.Mutex
|
||||
)
|
||||
|
||||
func (tracker emitTracker) getTrackerEntry(messageKey string, filename, classname string) *trackerInfo {
|
||||
var trackerEntry *trackerInfo
|
||||
var ok bool
|
||||
|
||||
if tracker == nil {
|
||||
return nil
|
||||
func getTrackerEntry(messageKey string, filename string, classname string) *trackerInfo {
|
||||
if entry, ok := assertTracker.Load(messageKey); ok {
|
||||
return entry.(*trackerInfo)
|
||||
}
|
||||
|
||||
trackerMutex.Lock()
|
||||
defer trackerMutex.Unlock()
|
||||
if trackerEntry, ok = tracker[messageKey]; !ok {
|
||||
trackerEntry = newTrackerInfo(filename, classname)
|
||||
tracker[messageKey] = trackerEntry
|
||||
}
|
||||
return trackerEntry
|
||||
}
|
||||
|
||||
func newTrackerInfo(filename, classname string) *trackerInfo {
|
||||
trackerInfo := trackerInfo{
|
||||
PassCount: 0,
|
||||
FailCount: 0,
|
||||
Filename: filename,
|
||||
Classname: classname,
|
||||
}
|
||||
return &trackerInfo
|
||||
entry, _ := assertTracker.LoadOrStore(messageKey,
|
||||
&trackerInfo{Filename: filename, Classname: classname})
|
||||
return entry.(*trackerInfo)
|
||||
}
|
||||
|
||||
func (ti *trackerInfo) emit(ai *assertInfo) {
|
||||
@@ -59,53 +39,46 @@ func (ti *trackerInfo) emit(ai *assertInfo) {
|
||||
}
|
||||
|
||||
// Registrations are just sent to voidstar
|
||||
hit := ai.Hit
|
||||
if !hit {
|
||||
if !ai.Hit {
|
||||
emitAssert(ai)
|
||||
return
|
||||
}
|
||||
|
||||
var err error
|
||||
cond := ai.Condition
|
||||
|
||||
trackerInfoMutex.Lock()
|
||||
defer trackerInfoMutex.Unlock()
|
||||
if cond {
|
||||
if ti.PassCount == 0 {
|
||||
err = emitAssert(ai)
|
||||
}
|
||||
if err == nil {
|
||||
ti.PassCount++
|
||||
}
|
||||
flag := &ti.passEmitted
|
||||
if !ai.Condition {
|
||||
flag = &ti.failEmitted
|
||||
}
|
||||
if flag.Load() {
|
||||
return
|
||||
}
|
||||
if ti.FailCount == 0 {
|
||||
err = emitAssert(ai)
|
||||
ti.emitMutex.Lock()
|
||||
defer ti.emitMutex.Unlock()
|
||||
if flag.Load() {
|
||||
return
|
||||
}
|
||||
if err == nil {
|
||||
ti.FailCount++
|
||||
// The flag is only set on success, so an assertion whose emission
|
||||
// failed is retried on its next evaluation (as before).
|
||||
if emitAssert(ai) == nil {
|
||||
flag.Store(true)
|
||||
}
|
||||
}
|
||||
|
||||
func versionMessage() {
|
||||
languageBlock := map[string]any{
|
||||
"name": "Go",
|
||||
"version": runtime.Version(),
|
||||
// Whether this assertion id has already emitted for this condition — i.e.
|
||||
// whether an evaluation can return before capturing its location.
|
||||
func trackerEmitted(id string, condition bool) bool {
|
||||
entry, ok := assertTracker.Load(id)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
versionBlock := map[string]any{
|
||||
"language": languageBlock,
|
||||
"sdk_version": internal.SDK_Version,
|
||||
"protocol_version": internal.Protocol_Version,
|
||||
ti := entry.(*trackerInfo)
|
||||
if condition {
|
||||
return ti.passEmitted.Load()
|
||||
}
|
||||
internal.Json_data(map[string]any{"antithesis_sdk": versionBlock})
|
||||
return ti.failEmitted.Load()
|
||||
}
|
||||
|
||||
// package-level flag
|
||||
var hasEmitted atomic.Bool // initialzed to false
|
||||
|
||||
func emitAssert(ai *assertInfo) error {
|
||||
if hasEmitted.CompareAndSwap(false, true) {
|
||||
versionMessage()
|
||||
}
|
||||
// The version message is emitted by the internal package when the
|
||||
// handler initializes, before any output can happen.
|
||||
return internal.Json_data(wrappedAssertInfo{ai})
|
||||
}
|
||||
+87
-8
@@ -3,10 +3,12 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
crand "crypto/rand"
|
||||
"encoding/binary"
|
||||
"encoding/json"
|
||||
"log"
|
||||
"math/rand"
|
||||
"os"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
func Json_data(v any) error {
|
||||
@@ -26,6 +28,18 @@ func Notify(edge uint64) bool {
|
||||
return handler.notify(edge)
|
||||
}
|
||||
|
||||
// NotifyV2 reports a coverage hit through the lease ABI (linkage v2); ok is
|
||||
// false when the loaded library does not support leases.
|
||||
func NotifyV2(edge uint64, hits uint64) (uint64, bool) {
|
||||
return handler.notify_v2(edge, hits)
|
||||
}
|
||||
|
||||
// LeaseGeneration reads the lease revocation word; ok is false when the
|
||||
// loaded library does not support leases.
|
||||
func LeaseGeneration() (uint64, bool) {
|
||||
return handler.lease_generation()
|
||||
}
|
||||
|
||||
func InitCoverage(num_edges uint64, symbols string) uint64 {
|
||||
return handler.init_coverage(num_edges, symbols)
|
||||
}
|
||||
@@ -34,6 +48,8 @@ type libHandler interface {
|
||||
output(message string)
|
||||
random() uint64
|
||||
notify(edge uint64) bool
|
||||
notify_v2(edge uint64, hits uint64) (uint64, bool)
|
||||
lease_generation() (uint64, bool)
|
||||
init_coverage(num_edges uint64, symbols string) uint64
|
||||
}
|
||||
|
||||
@@ -43,6 +59,13 @@ const (
|
||||
|
||||
var handler libHandler
|
||||
|
||||
// Mirrors the no_antithesis_sdk implementation of random.GetRandom.
|
||||
func osRandom() uint64 {
|
||||
var tmp [8]byte
|
||||
crand.Read(tmp[:])
|
||||
return binary.LittleEndian.Uint64(tmp[:])
|
||||
}
|
||||
|
||||
type localHandler struct {
|
||||
outputFile *os.File // can be nil
|
||||
}
|
||||
@@ -58,13 +81,21 @@ func (h *localHandler) output(message string) {
|
||||
}
|
||||
|
||||
func (h *localHandler) random() uint64 {
|
||||
return rand.Uint64()
|
||||
return osRandom()
|
||||
}
|
||||
|
||||
func (h *localHandler) notify(edge uint64) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (h *localHandler) notify_v2(edge uint64, hits uint64) (uint64, bool) {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
func (h *localHandler) lease_generation() (uint64, bool) {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
func (h *localHandler) init_coverage(num_edges uint64, symbols string) uint64 {
|
||||
return 0
|
||||
}
|
||||
@@ -75,9 +106,32 @@ func init() {
|
||||
// Otherwise fallback to the local handler.
|
||||
handler = openLocalHandler()
|
||||
}
|
||||
|
||||
// The version message is the first output of every run, emitted when the
|
||||
// handler comes up.
|
||||
emitVersionMessage()
|
||||
|
||||
if sdkRunningInDegradedMode {
|
||||
emitDegradedModeProperty()
|
||||
}
|
||||
}
|
||||
|
||||
// If `localOutputEnvVar` is set to a non-empty path, attempt to open that path and truncate the file
|
||||
func emitVersionMessage() {
|
||||
languageBlock := map[string]any{
|
||||
"name": "Go",
|
||||
"version": runtime.Version(),
|
||||
}
|
||||
versionBlock := map[string]any{
|
||||
"language": languageBlock,
|
||||
"sdk_version": SDK_Version,
|
||||
"protocol_version": Protocol_Version,
|
||||
}
|
||||
if data, err := json.Marshal(map[string]any{"antithesis_sdk": versionBlock}); err == nil {
|
||||
handler.output(string(data))
|
||||
}
|
||||
}
|
||||
|
||||
// If `localOutputEnvVar` is set to a non-empty path, attempt to open that path for appending
|
||||
// to serve as the log file of the local handler.
|
||||
// Otherwise, we don't have a log file, and logging is a no-op in the local handler.
|
||||
func openLocalHandler() *localHandler {
|
||||
@@ -86,15 +140,40 @@ func openLocalHandler() *localHandler {
|
||||
return &localHandler{nil}
|
||||
}
|
||||
|
||||
// Open the file R/W (create if needed and possible)
|
||||
file, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0644)
|
||||
// Open the file for writing (create if needed and possible, use O_APPEND to support concurrent writers)
|
||||
file, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644)
|
||||
if err != nil {
|
||||
log.Printf("%s Failed to open path %s: %v", errorLogLinePrefix, path, err)
|
||||
file = nil
|
||||
} else if err = file.Truncate(0); err != nil {
|
||||
log.Printf("%s Failed to truncate file at %s: %v", errorLogLinePrefix, path, err)
|
||||
file = nil
|
||||
}
|
||||
|
||||
return &localHandler{file}
|
||||
}
|
||||
|
||||
const degradedModeProperty = "Go application under test compiled with CGO enabled"
|
||||
|
||||
func emitDegradedModeProperty() {
|
||||
Json_data(map[string]any{
|
||||
"antithesis_assert": map[string]any{
|
||||
"hit": true,
|
||||
"must_hit": true,
|
||||
"assert_type": "always",
|
||||
"display_type": "Always",
|
||||
"message": degradedModeProperty,
|
||||
"id": degradedModeProperty,
|
||||
"condition": false,
|
||||
"location": map[string]any{
|
||||
"class": "",
|
||||
"function": "",
|
||||
"file": "",
|
||||
"begin_line": 0,
|
||||
"begin_column": 0,
|
||||
},
|
||||
"details": map[string]any{
|
||||
"info": "This binary was built without CGO enabled, which is required for " +
|
||||
"coverage-guided fuzzing and thread pausing. Rebuild with CGO_ENABLED=1 so the " +
|
||||
"SDK can link " + defaultNativeLibraryPath + " to enable them.",
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
+8
-1
@@ -3,10 +3,17 @@ package internal
|
||||
// --------------------------------------------------------------------------------
|
||||
// Versions
|
||||
// --------------------------------------------------------------------------------
|
||||
const SDK_Version = "0.7.2"
|
||||
const SDK_Version = "0.8.0"
|
||||
const Protocol_Version = "1.1.0"
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
// Environment Vars
|
||||
// --------------------------------------------------------------------------------
|
||||
const localOutputEnvVar = "ANTITHESIS_SDK_LOCAL_OUTPUT"
|
||||
const outputDirEnvVar = "ANTITHESIS_OUTPUT_DIR"
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
// Paths
|
||||
// --------------------------------------------------------------------------------
|
||||
const defaultNativeLibraryPath = "/usr/lib/libvoidstar.so"
|
||||
const fallbackOutputFilename = "sdk.jsonl"
|
||||
+75
-5
@@ -5,6 +5,7 @@ package internal
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"sync/atomic"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
@@ -60,18 +61,36 @@ import (
|
||||
// return ((go_init_coverage_fn)f)(num_edges, symbols);
|
||||
// }
|
||||
//
|
||||
// typedef uint64_t (*go_notify_coverage_v2_fn)(size_t, uint64_t);
|
||||
// uint64_t
|
||||
// go_notify_coverage_v2(void *f, size_t edge, uint64_t hits) {
|
||||
// return ((go_notify_coverage_v2_fn)f)(edge, hits);
|
||||
// }
|
||||
//
|
||||
// typedef const uint64_t *(*go_lease_generation_addr_fn)(void);
|
||||
// const uint64_t *
|
||||
// go_lease_generation_addr(void *f) {
|
||||
// return ((go_lease_generation_addr_fn)f)();
|
||||
// }
|
||||
//
|
||||
// typedef uint64_t (*go_request_abi_version_fn)(uint64_t);
|
||||
// uint64_t
|
||||
// go_request_abi_version(void *f, uint64_t v) {
|
||||
// return ((go_request_abi_version_fn)f)(v);
|
||||
// }
|
||||
//
|
||||
import "C"
|
||||
|
||||
const (
|
||||
defaultNativeLibraryPath = "/usr/lib/libvoidstar.so"
|
||||
)
|
||||
|
||||
type voidstarHandler struct {
|
||||
fuzzJsonData unsafe.Pointer
|
||||
fuzzFlush unsafe.Pointer
|
||||
fuzzGetRandom unsafe.Pointer
|
||||
initCoverage unsafe.Pointer
|
||||
notifyCoverage unsafe.Pointer
|
||||
// Coverage-lease support (linkage ABI v2, instrumentation.h). Nil/zero
|
||||
// when the loaded library predates the mechanism or negotiation failed.
|
||||
notifyCoverageV2 unsafe.Pointer
|
||||
leaseGeneration *uint64
|
||||
}
|
||||
|
||||
func (h *voidstarHandler) output(message string) {
|
||||
@@ -100,6 +119,23 @@ func (h *voidstarHandler) notify(edge uint64) bool {
|
||||
return ival == 1
|
||||
}
|
||||
|
||||
func (h *voidstarHandler) notify_v2(edge uint64, hits uint64) (uint64, bool) {
|
||||
if h.notifyCoverageV2 == nil {
|
||||
return 0, false
|
||||
}
|
||||
return uint64(C.go_notify_coverage_v2(h.notifyCoverageV2, C.ulong(edge), C.uint64_t(hits))), true
|
||||
}
|
||||
|
||||
func (h *voidstarHandler) lease_generation() (uint64, bool) {
|
||||
if h.leaseGeneration == nil {
|
||||
return 0, false
|
||||
}
|
||||
// The header requires this read to be non-hoistable out of hot loops;
|
||||
// an atomic load has the required opaque semantics. The word lives for
|
||||
// the life of the process and is only ever written by the fuzzer.
|
||||
return atomic.LoadUint64(h.leaseGeneration), true
|
||||
}
|
||||
|
||||
// Attempt to load libvoidstar and some symbols from `path`
|
||||
func openSharedLib(path string) (*voidstarHandler, error) {
|
||||
cstrPath := C.CString(path)
|
||||
@@ -123,6 +159,17 @@ func openSharedLib(path string) (*voidstarHandler, error) {
|
||||
return
|
||||
}
|
||||
|
||||
// Symbols absent from older library vintages must resolve softly: no
|
||||
// library version may fail the SDK's load (instrumentation.h, "Linkage
|
||||
// ABI versioning").
|
||||
loadOptional := func(name string) unsafe.Pointer {
|
||||
cstrName := C.CString(name)
|
||||
defer C.free(unsafe.Pointer(cstrName))
|
||||
symbol := C.dlsym(sharedLib, cstrName)
|
||||
C.dlerror() // clear any lookup error
|
||||
return symbol
|
||||
}
|
||||
|
||||
fuzzJsonData, err := loadFunc("fuzz_json_data")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -143,9 +190,32 @@ func openSharedLib(path string) (*voidstarHandler, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &voidstarHandler{fuzzJsonData, fuzzFlush, fuzzGetRandom, initCoverage, notifyCoverage}, nil
|
||||
handler := &voidstarHandler{
|
||||
fuzzJsonData: fuzzJsonData,
|
||||
fuzzFlush: fuzzFlush,
|
||||
fuzzGetRandom: fuzzGetRandom,
|
||||
initCoverage: initCoverage,
|
||||
notifyCoverage: notifyCoverage,
|
||||
}
|
||||
|
||||
// Negotiate for coverage leases: request ABI v2 and gate on the granted
|
||||
// version (a grant above the request means "cannot negotiate").
|
||||
requestAbi := loadOptional("instrumentation_request_abi_version")
|
||||
notifyV2 := loadOptional("notify_coverage_v2")
|
||||
leaseAddr := loadOptional("coverage_lease_generation_addr")
|
||||
if requestAbi != nil && notifyV2 != nil && leaseAddr != nil {
|
||||
if granted := uint64(C.go_request_abi_version(requestAbi, 2)); granted == 2 {
|
||||
if addr := C.go_lease_generation_addr(leaseAddr); addr != nil {
|
||||
handler.notifyCoverageV2 = notifyV2
|
||||
handler.leaseGeneration = (*uint64)(unsafe.Pointer(addr))
|
||||
}
|
||||
}
|
||||
}
|
||||
return handler, nil
|
||||
}
|
||||
|
||||
const sdkRunningInDegradedMode = false
|
||||
|
||||
// If we have a file at `defaultNativeLibraryPath`, we load the shared library
|
||||
// (and panic on any error encountered during load).
|
||||
func init_in_antithesis() libHandler {
|
||||
|
||||
Generated
Vendored
+58
@@ -0,0 +1,58 @@
|
||||
//go:build enable_antithesis_sdk && linux && amd64 && !cgo
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
const sdkRunningInDegradedMode = true
|
||||
|
||||
type inAntithesisWithoutCgoHandler struct {
|
||||
outputFile *os.File
|
||||
}
|
||||
|
||||
func (h *inAntithesisWithoutCgoHandler) output(message string) {
|
||||
if len(message) == 0 {
|
||||
return
|
||||
}
|
||||
h.outputFile.WriteString(message + "\n")
|
||||
}
|
||||
|
||||
func (h *inAntithesisWithoutCgoHandler) random() uint64 {
|
||||
return osRandom()
|
||||
}
|
||||
|
||||
func (h *inAntithesisWithoutCgoHandler) notify(edge uint64) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (h *inAntithesisWithoutCgoHandler) init_coverage(num_edges uint64, symbols string) uint64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (h *inAntithesisWithoutCgoHandler) notify_v2(edge uint64, hits uint64) (uint64, bool) {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
func (h *inAntithesisWithoutCgoHandler) lease_generation() (uint64, bool) {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
func init_in_antithesis() libHandler {
|
||||
dir, is_set := os.LookupEnv(outputDirEnvVar)
|
||||
if !is_set || len(dir) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
path := filepath.Join(dir, fallbackOutputFilename)
|
||||
file, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644)
|
||||
if err != nil {
|
||||
log.Printf("%s Failed to open path %s: %v", errorLogLinePrefix, path, err)
|
||||
return nil
|
||||
}
|
||||
|
||||
return &inAntithesisWithoutCgoHandler{file}
|
||||
}
|
||||
Generated
Vendored
+3
-1
@@ -1,7 +1,9 @@
|
||||
//go:build enable_antithesis_sdk && (!linux || !amd64 || !cgo)
|
||||
//go:build enable_antithesis_sdk && (!linux || !amd64)
|
||||
|
||||
package internal
|
||||
|
||||
const sdkRunningInDegradedMode = false
|
||||
|
||||
func init_in_antithesis() libHandler {
|
||||
return nil
|
||||
}
|
||||
+19
@@ -1,3 +1,22 @@
|
||||
Release 1.8.1
|
||||
=============
|
||||
|
||||
**Fixes**
|
||||
|
||||
* Fixed a panic-causing bug in all Remove functions.
|
||||
|
||||
Release 1.8.0
|
||||
=============
|
||||
|
||||
**Changes**
|
||||
|
||||
* Added the `Remove` function to all token types, allowing for the easy
|
||||
removal of a token from its parent element.
|
||||
|
||||
**Fixes**
|
||||
|
||||
* Cleaned up several comments for clarity and typo corrections.
|
||||
|
||||
Release 1.7.1
|
||||
=============
|
||||
|
||||
|
||||
+73
-26
@@ -214,6 +214,7 @@ type Writer interface {
|
||||
type Token interface {
|
||||
Parent() *Element
|
||||
Index() int
|
||||
Remove() bool
|
||||
WriteTo(w Writer, s *WriteSettings)
|
||||
dup(parent *Element) Token
|
||||
setParent(parent *Element)
|
||||
@@ -1390,19 +1391,27 @@ func (e *Element) PrevSibling() *Element {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Parent returns this element's parent element. It returns nil if this
|
||||
// element has no parent.
|
||||
// Parent returns the element's parent element, or nil if the element has no
|
||||
// parent.
|
||||
func (e *Element) Parent() *Element {
|
||||
return e.parent
|
||||
}
|
||||
|
||||
// Index returns the index of this element within its parent element's
|
||||
// list of child tokens. If this element has no parent, then the function
|
||||
// returns -1.
|
||||
// Index returns the index of the element within its parent element's list of
|
||||
// child tokens. If the element has no parent, the function returns -1.
|
||||
func (e *Element) Index() int {
|
||||
return e.index
|
||||
}
|
||||
|
||||
// Remove attempts to remove the element from the parent element that contains
|
||||
// it. If the element has no parent, the function returns false.
|
||||
func (e *Element) Remove() bool {
|
||||
if e.parent == nil {
|
||||
return false
|
||||
}
|
||||
return e.parent.RemoveChild(e) != nil
|
||||
}
|
||||
|
||||
// WriteTo serializes the element to the writer w.
|
||||
func (e *Element) WriteTo(w Writer, s *WriteSettings) {
|
||||
w.WriteByte('<')
|
||||
@@ -1624,7 +1633,7 @@ func (c *CharData) SetData(text string) {
|
||||
}
|
||||
}
|
||||
|
||||
// IsCData returns true if this CharData token is contains a CDATA section. It
|
||||
// IsCData returns true if this CharData token contains a CDATA section. It
|
||||
// returns false if the CharData token contains simple text.
|
||||
func (c *CharData) IsCData() bool {
|
||||
return (c.flags & cdataFlag) != 0
|
||||
@@ -1635,20 +1644,30 @@ func (c *CharData) IsWhitespace() bool {
|
||||
return (c.flags & whitespaceFlag) != 0
|
||||
}
|
||||
|
||||
// Parent returns this CharData token's parent element, or nil if it has no
|
||||
// parent.
|
||||
// Parent returns the CharData token's parent element, or nil if the token has
|
||||
// no parent.
|
||||
func (c *CharData) Parent() *Element {
|
||||
return c.parent
|
||||
}
|
||||
|
||||
// Index returns the index of this CharData token within its parent element's
|
||||
// list of child tokens. If this CharData token has no parent, then the
|
||||
// function returns -1.
|
||||
// Index returns the index of the CharData token within its parent element's
|
||||
// list of child tokens. If the CharData token has no parent, the function
|
||||
// returns -1.
|
||||
func (c *CharData) Index() int {
|
||||
return c.index
|
||||
}
|
||||
|
||||
// WriteTo serializes character data to the writer.
|
||||
// Remove attempts to remove the CharData token from the parent element that
|
||||
// contains it. If the CharData token has no parent, the function returns
|
||||
// false.
|
||||
func (c *CharData) Remove() bool {
|
||||
if c.parent == nil {
|
||||
return false
|
||||
}
|
||||
return c.parent.RemoveChild(c) != nil
|
||||
}
|
||||
|
||||
// WriteTo serializes CharData token to the writer.
|
||||
func (c *CharData) WriteTo(w Writer, s *WriteSettings) {
|
||||
if c.IsCData() {
|
||||
w.WriteString(`<![CDATA[`)
|
||||
@@ -1719,19 +1738,28 @@ func (c *Comment) dup(parent *Element) Token {
|
||||
}
|
||||
}
|
||||
|
||||
// Parent returns comment token's parent element, or nil if it has no parent.
|
||||
// Parent returns the comment's parent element, or nil if the comment has no
|
||||
// parent.
|
||||
func (c *Comment) Parent() *Element {
|
||||
return c.parent
|
||||
}
|
||||
|
||||
// Index returns the index of this Comment token within its parent element's
|
||||
// list of child tokens. If this Comment token has no parent, then the
|
||||
// function returns -1.
|
||||
// Index returns the index of the comment within its parent element's list of
|
||||
// child tokens. If the comment has no parent, the function returns -1.
|
||||
func (c *Comment) Index() int {
|
||||
return c.index
|
||||
}
|
||||
|
||||
// WriteTo serialies the comment to the writer.
|
||||
// Remove attempts to remove the comment from the parent element that contains
|
||||
// it. If the comment has no parent, the function returns false.
|
||||
func (c *Comment) Remove() bool {
|
||||
if c.parent == nil {
|
||||
return false
|
||||
}
|
||||
return c.parent.RemoveChild(c) != nil
|
||||
}
|
||||
|
||||
// WriteTo serializes the comment to the writer.
|
||||
func (c *Comment) WriteTo(w Writer, s *WriteSettings) {
|
||||
w.WriteString("<!--")
|
||||
sanitizeComment(w, c.Data)
|
||||
@@ -1783,19 +1811,28 @@ func (d *Directive) dup(parent *Element) Token {
|
||||
}
|
||||
}
|
||||
|
||||
// Parent returns directive token's parent element, or nil if it has no
|
||||
// Parent returns the XML directive's parent element, or nil if it has no
|
||||
// parent.
|
||||
func (d *Directive) Parent() *Element {
|
||||
return d.parent
|
||||
}
|
||||
|
||||
// Index returns the index of this Directive token within its parent element's
|
||||
// list of child tokens. If this Directive token has no parent, then the
|
||||
// function returns -1.
|
||||
// Index returns the index of the XML directive within its parent element's
|
||||
// list of child tokens. If the directive has no parent, the function returns
|
||||
// -1.
|
||||
func (d *Directive) Index() int {
|
||||
return d.index
|
||||
}
|
||||
|
||||
// Remove attempts to remove the XML directive from the parent element that
|
||||
// contains it. If the directive has no parent, the function returns false.
|
||||
func (d *Directive) Remove() bool {
|
||||
if d.parent == nil {
|
||||
return false
|
||||
}
|
||||
return d.parent.RemoveChild(d) != nil
|
||||
}
|
||||
|
||||
// WriteTo serializes the XML directive to the writer.
|
||||
func (d *Directive) WriteTo(w Writer, s *WriteSettings) {
|
||||
w.WriteString("<!")
|
||||
@@ -1851,20 +1888,30 @@ func (p *ProcInst) dup(parent *Element) Token {
|
||||
}
|
||||
}
|
||||
|
||||
// Parent returns processing instruction token's parent element, or nil if it
|
||||
// Parent returns XML processing instruction's parent element, or nil if it
|
||||
// has no parent.
|
||||
func (p *ProcInst) Parent() *Element {
|
||||
return p.parent
|
||||
}
|
||||
|
||||
// Index returns the index of this ProcInst token within its parent element's
|
||||
// list of child tokens. If this ProcInst token has no parent, then the
|
||||
// function returns -1.
|
||||
// Index returns the index of the XML processing instruction within its parent
|
||||
// element's list of child tokens. If the processing instruction has no
|
||||
// parent, the function returns -1.
|
||||
func (p *ProcInst) Index() int {
|
||||
return p.index
|
||||
}
|
||||
|
||||
// WriteTo serializes the processing instruction to the writer.
|
||||
// Remove attempts to remove the XML processing instruction from the parent
|
||||
// element that contains it. If the processing instruction has no parent, the
|
||||
// function returns false.
|
||||
func (p *ProcInst) Remove() bool {
|
||||
if p.parent == nil {
|
||||
return false
|
||||
}
|
||||
return p.parent.RemoveChild(p) != nil
|
||||
}
|
||||
|
||||
// WriteTo serializes the XML processing instruction to the writer.
|
||||
func (p *ProcInst) WriteTo(w Writer, s *WriteSettings) {
|
||||
w.WriteString("<?")
|
||||
sanitizeProcInst(w, p.Target)
|
||||
|
||||
+2
-2
@@ -475,8 +475,8 @@ func (f *filterPos) apply(p *pather) {
|
||||
p.scratch = append(p.scratch, p.candidates[f.index])
|
||||
}
|
||||
} else {
|
||||
if -f.index <= len(p.candidates) {
|
||||
p.scratch = append(p.scratch, p.candidates[len(p.candidates)+f.index])
|
||||
if i := len(p.candidates) + f.index; i >= 0 {
|
||||
p.scratch = append(p.scratch, p.candidates[i])
|
||||
}
|
||||
}
|
||||
p.candidates, p.scratch = p.scratch, p.candidates[0:0]
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
## AI Agents
|
||||
|
||||
AI-assisted contributions are welcome but must be clearly attributed. If you are an AI agent or using an AI agent to contribute:
|
||||
|
||||
- **Commits**: Include a `Co-Authored-By:` trailer identifying the AI model used.
|
||||
- **Pull requests and issues**: State that the content was AI-generated or AI-assisted in the description.
|
||||
- **Code review comments**: Prefix with `[AI]` when posting automated review comments.
|
||||
|
||||
Contributions that obscure their AI origin may be closed.
|
||||
+11
@@ -82,6 +82,17 @@ Help With Tests
|
||||
To anyone interesting in helping or contributing, I sure could use some help creating tests for each language.
|
||||
Please see issue [here](https://github.com/go-playground/locales/issues/1) for details.
|
||||
|
||||
Supported Go Versions
|
||||
---------------------
|
||||
This package is aligned with the [Go release policy](https://go.dev/doc/devel/release) in that support is guaranteed for
|
||||
the two most recent major versions.
|
||||
|
||||
This does not mean the package will not work with older versions of Go, only that we reserve the right to increase the
|
||||
MSGV(Minimum Supported Go Version) when the need arises to address Security issues/patches, OS issues & support or newly
|
||||
introduced functionality that would greatly benefit the maintenance and/or usage of this package.
|
||||
|
||||
If and when the MSGV is increased it will be done so in a minimum of a `Minor` release bump.
|
||||
|
||||
License
|
||||
------
|
||||
Distributed under MIT License, please see license file in code for more details.
|
||||
+5
-2
@@ -8,8 +8,11 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrUnknowTranslation indicates the translation could not be found
|
||||
ErrUnknowTranslation = errors.New("Unknown Translation")
|
||||
// ErrUnknownTranslation indicates the translation could not be found
|
||||
ErrUnknownTranslation = errors.New("unknown translation")
|
||||
|
||||
// Deprecated: Use ErrUnknownTranslation instead.
|
||||
ErrUnknowTranslation = ErrUnknownTranslation
|
||||
)
|
||||
|
||||
var _ error = new(ErrConflictingTranslation)
|
||||
|
||||
+1
-1
@@ -163,7 +163,7 @@ func (t *UniversalTranslator) Import(format ImportExportFormat, dirnameOrFilenam
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
defer func() { _ = f.Close() }()
|
||||
|
||||
return t.ImportByReader(format, f)
|
||||
}
|
||||
|
||||
+83
-33
@@ -101,35 +101,87 @@ func (t *translator) Add(key interface{}, text string, override bool) error {
|
||||
return &ErrConflictingTranslation{locale: t.Locale(), key: key, text: text}
|
||||
}
|
||||
|
||||
lb := strings.Count(text, "{")
|
||||
rb := strings.Count(text, "}")
|
||||
|
||||
if lb != rb {
|
||||
return &ErrMissingBracket{locale: t.Locale(), key: key, text: text}
|
||||
indexes, err := parseParamPlaceholders(text, t.Locale(), key)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
trans := &transText{
|
||||
text: text,
|
||||
}
|
||||
|
||||
var idx int
|
||||
|
||||
for i := 0; i < lb; i++ {
|
||||
s := "{" + strconv.Itoa(i) + "}"
|
||||
idx = strings.Index(text, s)
|
||||
if idx == -1 {
|
||||
return &ErrBadParamSyntax{locale: t.Locale(), param: s, key: key, text: text}
|
||||
}
|
||||
|
||||
trans.indexes = append(trans.indexes, idx)
|
||||
trans.indexes = append(trans.indexes, idx+len(s))
|
||||
}
|
||||
|
||||
t.translations[key] = trans
|
||||
t.translations[key] = &transText{text: text, indexes: indexes}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// parseParamPlaceholders scans text for {N} placeholders where N is a canonical
|
||||
// non-negative integer (no leading zeros). Returns triplets [start, end, paramIdx, ...]
|
||||
// sorted by text position. Requires consecutive param indices starting from 0.
|
||||
func parseParamPlaceholders(text string, locale string, key interface{}) ([]int, error) {
|
||||
var indexes []int
|
||||
seen := make(map[int]struct{})
|
||||
maxParam := -1
|
||||
|
||||
for i := 0; i < len(text); i++ {
|
||||
if text[i] != '{' {
|
||||
continue
|
||||
}
|
||||
|
||||
j := i + 1
|
||||
for j < len(text) && text[j] >= '0' && text[j] <= '9' {
|
||||
j++
|
||||
}
|
||||
|
||||
digitLen := j - i - 1
|
||||
if digitLen == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
if j >= len(text) {
|
||||
return nil, &ErrMissingBracket{locale: locale, key: key, text: text}
|
||||
}
|
||||
|
||||
if text[j] != '}' {
|
||||
i = j - 1
|
||||
continue
|
||||
}
|
||||
|
||||
if digitLen > 1 && text[i+1] == '0' {
|
||||
i = j
|
||||
continue
|
||||
}
|
||||
|
||||
if digitLen > 9 {
|
||||
i = j
|
||||
continue
|
||||
}
|
||||
|
||||
n := 0
|
||||
for k := i + 1; k < j; k++ {
|
||||
n = n*10 + int(text[k]-'0')
|
||||
}
|
||||
|
||||
indexes = append(indexes, i, j+1, n)
|
||||
seen[n] = struct{}{}
|
||||
if n > maxParam {
|
||||
maxParam = n
|
||||
}
|
||||
|
||||
i = j
|
||||
}
|
||||
|
||||
if len(seen) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
if maxParam != len(seen)-1 {
|
||||
for i := 0; i <= maxParam; i++ {
|
||||
if _, ok := seen[i]; !ok {
|
||||
return nil, &ErrBadParamSyntax{locale: locale, param: "{" + strconv.Itoa(i) + "}", key: key, text: text}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return indexes, nil
|
||||
}
|
||||
|
||||
// AddCardinal adds a cardinal plural translation for a particular language/locale
|
||||
// {0} is the only replacement type accepted and only one variable is accepted as
|
||||
// multiple cannot be used for a plural rule determination, unless it is a range;
|
||||
@@ -298,20 +350,18 @@ func (t *translator) T(key interface{}, params ...string) (string, error) {
|
||||
|
||||
trans, ok := t.translations[key]
|
||||
if !ok {
|
||||
return unknownTranslation, ErrUnknowTranslation
|
||||
return unknownTranslation, ErrUnknownTranslation
|
||||
}
|
||||
|
||||
b := make([]byte, 0, 64)
|
||||
|
||||
var start, end, count int
|
||||
var start, end int
|
||||
|
||||
for i := 0; i < len(trans.indexes); i++ {
|
||||
for i := 0; i < len(trans.indexes); i += 3 {
|
||||
end = trans.indexes[i]
|
||||
b = append(b, trans.text[start:end]...)
|
||||
b = append(b, params[count]...)
|
||||
i++
|
||||
start = trans.indexes[i]
|
||||
count++
|
||||
b = append(b, params[trans.indexes[i+2]]...)
|
||||
start = trans.indexes[i+1]
|
||||
}
|
||||
|
||||
b = append(b, trans.text[start:]...)
|
||||
@@ -324,7 +374,7 @@ func (t *translator) C(key interface{}, num float64, digits uint64, param string
|
||||
|
||||
tarr, ok := t.cardinalTanslations[key]
|
||||
if !ok {
|
||||
return unknownTranslation, ErrUnknowTranslation
|
||||
return unknownTranslation, ErrUnknownTranslation
|
||||
}
|
||||
|
||||
rule := t.CardinalPluralRule(num, digits)
|
||||
@@ -344,7 +394,7 @@ func (t *translator) O(key interface{}, num float64, digits uint64, param string
|
||||
|
||||
tarr, ok := t.ordinalTanslations[key]
|
||||
if !ok {
|
||||
return unknownTranslation, ErrUnknowTranslation
|
||||
return unknownTranslation, ErrUnknownTranslation
|
||||
}
|
||||
|
||||
rule := t.OrdinalPluralRule(num, digits)
|
||||
@@ -365,7 +415,7 @@ func (t *translator) R(key interface{}, num1 float64, digits1 uint64, num2 float
|
||||
|
||||
tarr, ok := t.rangeTanslations[key]
|
||||
if !ok {
|
||||
return unknownTranslation, ErrUnknowTranslation
|
||||
return unknownTranslation, ErrUnknownTranslation
|
||||
}
|
||||
|
||||
rule := t.RangePluralRule(num1, digits1, num2, digits2)
|
||||
|
||||
+11
-2
@@ -3045,9 +3045,18 @@ func isHostnamePort(fl FieldLevel) bool {
|
||||
|
||||
// IsPort validates if the current field's value represents a valid port
|
||||
func isPort(fl FieldLevel) bool {
|
||||
val := fl.Field().Uint()
|
||||
field := fl.Field()
|
||||
|
||||
return val >= 1 && val <= 65535
|
||||
switch field.Kind() {
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||
val := field.Int()
|
||||
return val >= 1 && val <= 65535
|
||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
|
||||
val := field.Uint()
|
||||
return val >= 1 && val <= 65535
|
||||
default:
|
||||
panic(fmt.Sprintf("Bad field type %s", field.Type()))
|
||||
}
|
||||
}
|
||||
|
||||
// isLowercase is the validation function for validating if the current field's value is a lowercase string.
|
||||
|
||||
+1
-1
@@ -1445,7 +1445,7 @@ can be used to validate fields typically passed to sockets and connections.
|
||||
|
||||
# Port
|
||||
|
||||
This validates that the value falls within the valid port number range of 1 to 65,535.
|
||||
This validates that an integer value (signed or unsigned) falls within the valid port range of 1-65,535.
|
||||
|
||||
Usage: port
|
||||
|
||||
|
||||
+56
-10
@@ -69,7 +69,8 @@ func toCamelCase(str string, isBig bool) string {
|
||||
|
||||
if len(str) == 0 {
|
||||
// A special case for a string contains only 1 rune.
|
||||
if size != 0 {
|
||||
// A connector is already written by the loop above.
|
||||
if size != 0 && !isConnector(r0) {
|
||||
buf.WriteRune(r0)
|
||||
}
|
||||
|
||||
@@ -102,10 +103,6 @@ func toCamelCase(str string, isBig bool) string {
|
||||
}
|
||||
}
|
||||
|
||||
if isFirstRuneUpper && !isBig {
|
||||
r0 = unicode.ToLower(r0)
|
||||
}
|
||||
|
||||
buf.WriteRune(r0)
|
||||
return buf.String()
|
||||
}
|
||||
@@ -548,6 +545,12 @@ func ShuffleSource(str string, src rand.Source) string {
|
||||
// If increment generates a "carry", the rune to the left of it is incremented.
|
||||
// This process repeats until there is no carry, adding an additional rune if necessary.
|
||||
//
|
||||
// Letters and digits are different kinds of rune. A carry is not passed over a
|
||||
// rune of another kind when at least one non-alphanumeric rune is skipped on the
|
||||
// way; the carry rune is inserted in front of the rune which generated it
|
||||
// instead. For example, the carry of "8a_9" is inserted in front of the "9", so
|
||||
// the result is "8a_10".
|
||||
//
|
||||
// If there is no alphanumeric rune, the rightmost rune will be increased by 1
|
||||
// regardless whether the result is a valid rune or not.
|
||||
//
|
||||
@@ -564,21 +567,32 @@ func ShuffleSource(str string, src rand.Source) string {
|
||||
// "1999zzz" => "2000aaa"
|
||||
// "ZZZ9999" => "AAAA0000"
|
||||
// "***" => "**+"
|
||||
// "8a_9" => "8a_10"
|
||||
func Successor(str string) string {
|
||||
if str == "" {
|
||||
return str
|
||||
}
|
||||
|
||||
var r rune
|
||||
var i int
|
||||
carry := ' '
|
||||
runes := []rune(str)
|
||||
l := len(runes)
|
||||
lastAlphanumeric := l
|
||||
lastKind := invalidRuneKind
|
||||
skippedRune := false
|
||||
|
||||
for i = l - 1; i >= 0; i-- {
|
||||
for i := l - 1; i >= 0; i-- {
|
||||
r = runes[i]
|
||||
|
||||
// A carry is not passed over a rune of another kind (letter vs. number)
|
||||
// once at least one non-alphanumeric rune is skipped on the way.
|
||||
// The carry rune is inserted in front of the rune which generated it.
|
||||
if skippedRune && lastKind != invalidRuneKind {
|
||||
if kind := runeKindOf(r); kind != invalidRuneKind && kind != lastKind {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if ('a' <= r && r <= 'y') ||
|
||||
('A' <= r && r <= 'Y') ||
|
||||
('0' <= r && r <= '8') {
|
||||
@@ -593,26 +607,35 @@ func Successor(str string) string {
|
||||
runes[i] = 'a'
|
||||
carry = 'a'
|
||||
lastAlphanumeric = i
|
||||
lastKind = letterRuneKind
|
||||
skippedRune = false
|
||||
|
||||
case 'Z':
|
||||
runes[i] = 'A'
|
||||
carry = 'A'
|
||||
lastAlphanumeric = i
|
||||
lastKind = letterRuneKind
|
||||
skippedRune = false
|
||||
|
||||
case '9':
|
||||
runes[i] = '0'
|
||||
carry = '0'
|
||||
carry = '1'
|
||||
lastAlphanumeric = i
|
||||
lastKind = numberRuneKind
|
||||
skippedRune = false
|
||||
|
||||
default:
|
||||
skippedRune = true
|
||||
}
|
||||
}
|
||||
|
||||
// Needs to add one character for carry.
|
||||
if i < 0 && carry != ' ' {
|
||||
if carry != ' ' {
|
||||
buf := &stringBuilder{}
|
||||
buf.Grow(l + 4) // Reserve enough space for write.
|
||||
|
||||
if lastAlphanumeric != 0 {
|
||||
buf.WriteString(str[:lastAlphanumeric])
|
||||
buf.WriteString(string(runes[:lastAlphanumeric]))
|
||||
}
|
||||
|
||||
buf.WriteRune(carry)
|
||||
@@ -631,3 +654,26 @@ func Successor(str string) string {
|
||||
|
||||
return string(runes)
|
||||
}
|
||||
|
||||
// runeKind is the kind of a rune which Successor can increase.
|
||||
type runeKind int
|
||||
|
||||
const (
|
||||
invalidRuneKind runeKind = iota
|
||||
letterRuneKind
|
||||
numberRuneKind
|
||||
)
|
||||
|
||||
// runeKindOf returns the Successor kind of r.
|
||||
// Only a-z, A-Z and 0-9 are alphanumeric runes for Successor.
|
||||
func runeKindOf(r rune) runeKind {
|
||||
switch {
|
||||
case 'a' <= r && r <= 'z', 'A' <= r && r <= 'Z':
|
||||
return letterRuneKind
|
||||
|
||||
case '0' <= r && r <= '9':
|
||||
return numberRuneKind
|
||||
}
|
||||
|
||||
return invalidRuneKind
|
||||
}
|
||||
+16
-3
@@ -55,6 +55,10 @@ func Slice(str string, start, end int) string {
|
||||
str = str[size:]
|
||||
}
|
||||
|
||||
if start > 0 {
|
||||
panic("out of range")
|
||||
}
|
||||
|
||||
if end < 0 {
|
||||
return origin[startPos:]
|
||||
}
|
||||
@@ -131,8 +135,13 @@ func Insert(dst, src string, index int) string {
|
||||
return Slice(dst, 0, index) + src + Slice(dst, index, -1)
|
||||
}
|
||||
|
||||
// Scrub scrubs invalid utf8 bytes with repl string.
|
||||
// Adjacent invalid bytes are replaced only once.
|
||||
// Scrub replaces invalid UTF-8 bytes and valid U+FFFD replacement characters in str with repl.
|
||||
// A consecutive run of invalid bytes or U+FFFD characters is replaced only once.
|
||||
//
|
||||
// Samples:
|
||||
//
|
||||
// Scrub("a\uFFFDb", "?") => "a?b"
|
||||
// Scrub("a\uFFFD\uFFFDb", "?") => "a?b"
|
||||
func Scrub(str, repl string) string {
|
||||
var buf *stringBuilder
|
||||
var r rune
|
||||
@@ -166,7 +175,11 @@ func Scrub(str, repl string) string {
|
||||
}
|
||||
|
||||
if buf != nil {
|
||||
buf.WriteString(origin)
|
||||
if hasError {
|
||||
buf.WriteString(repl)
|
||||
} else {
|
||||
buf.WriteString(origin)
|
||||
}
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
|
||||
+42
-15
@@ -17,6 +17,7 @@ type runeRangeMap struct {
|
||||
|
||||
type runeDict struct {
|
||||
Dict [unicode.MaxASCII + 1]rune
|
||||
Set [unicode.MaxASCII + 1]bool
|
||||
}
|
||||
|
||||
type runeMap map[rune]rune
|
||||
@@ -29,7 +30,8 @@ type Translator struct {
|
||||
runeMap runeMap // Rune map for translation.
|
||||
ranges []*runeRangeMap // Ranges of runes.
|
||||
mappedRune rune // If mappedRune >= 0, all matched runes are translated to the mappedRune.
|
||||
reverted bool // If to pattern is empty, all matched characters will be deleted.
|
||||
reverted bool // If from pattern starts with '^', only unmatched characters will be translated.
|
||||
deletion bool // If to pattern is empty, all matched characters will be deleted.
|
||||
hasPattern bool
|
||||
}
|
||||
|
||||
@@ -160,6 +162,7 @@ func NewTranslator(from, to string) *Translator {
|
||||
}
|
||||
|
||||
tr.reverted = reverted
|
||||
tr.deletion = deletion
|
||||
tr.mappedRune = -1
|
||||
tr.hasPattern = true
|
||||
|
||||
@@ -178,6 +181,7 @@ func (tr *Translator) addRune(from, to rune, singleRunes []rune) []rune {
|
||||
}
|
||||
|
||||
tr.quickDict.Dict[from] = to
|
||||
tr.quickDict.Set[from] = true
|
||||
} else {
|
||||
if tr.runeMap == nil {
|
||||
tr.runeMap = make(runeMap)
|
||||
@@ -215,6 +219,7 @@ func (tr *Translator) addRuneRange(fromLo, fromHi, toLo, toHi rune, singleRunes
|
||||
if rrm.FromLo <= r && r <= rrm.FromHi {
|
||||
if r <= unicode.MaxASCII {
|
||||
tr.quickDict.Dict[r] = 0
|
||||
tr.quickDict.Set[r] = false
|
||||
} else {
|
||||
delete(tr.runeMap, r)
|
||||
}
|
||||
@@ -298,7 +303,7 @@ func (tr *Translator) Translate(str string) string {
|
||||
|
||||
var r rune
|
||||
var size int
|
||||
var needTr bool
|
||||
var matched, deleted bool
|
||||
|
||||
orig := str
|
||||
|
||||
@@ -306,14 +311,21 @@ func (tr *Translator) Translate(str string) string {
|
||||
|
||||
for len(str) > 0 {
|
||||
r, size = utf8.DecodeRuneInString(str)
|
||||
r, needTr = tr.TranslateRune(r)
|
||||
r, matched, deleted = tr.translateRune(r)
|
||||
|
||||
if needTr && output == nil {
|
||||
if matched && output == nil {
|
||||
output = allocBuffer(orig, str)
|
||||
}
|
||||
|
||||
if r != utf8.RuneError && output != nil {
|
||||
output.WriteRune(r)
|
||||
if output != nil && !deleted {
|
||||
if matched {
|
||||
output.WriteRune(r)
|
||||
} else {
|
||||
// An unmatched rune must be kept as is. Its original bytes are
|
||||
// copied instead of the decoded rune, so that an invalid byte
|
||||
// is not rewritten as utf8.RuneError.
|
||||
output.WriteString(str[:size])
|
||||
}
|
||||
}
|
||||
|
||||
str = str[size:]
|
||||
@@ -330,13 +342,26 @@ func (tr *Translator) Translate(str string) string {
|
||||
// TranslateRune return translated rune and true if r matches the from pattern.
|
||||
// If r doesn't match the pattern, original r is returned and translated is false.
|
||||
func (tr *Translator) TranslateRune(r rune) (result rune, translated bool) {
|
||||
result, translated, _ = tr.translateRune(r)
|
||||
return
|
||||
}
|
||||
|
||||
// translateRune is the internal implementation of TranslateRune.
|
||||
//
|
||||
// It reports whether r matches the from pattern (matched) and whether the rune
|
||||
// must be dropped from the translation result (deleted). deleted is true only
|
||||
// when r matches a from pattern which has an empty to pattern, i.e. the rune is
|
||||
// removed by Delete or by Translate with an empty to pattern.
|
||||
//
|
||||
// The two flags can't be folded into the returned rune: utf8.RuneError is a
|
||||
// valid rune value which can be a translation result as well.
|
||||
func (tr *Translator) translateRune(r rune) (result rune, matched, deleted bool) {
|
||||
switch {
|
||||
case tr.quickDict != nil:
|
||||
if r <= unicode.MaxASCII {
|
||||
result = tr.quickDict.Dict[r]
|
||||
|
||||
if result != 0 {
|
||||
translated = true
|
||||
if tr.quickDict.Set[r] {
|
||||
result = tr.quickDict.Dict[r]
|
||||
matched = true
|
||||
|
||||
if tr.mappedRune >= 0 {
|
||||
result = tr.mappedRune
|
||||
@@ -352,7 +377,7 @@ func (tr *Translator) TranslateRune(r rune) (result rune, translated bool) {
|
||||
var ok bool
|
||||
|
||||
if result, ok = tr.runeMap[r]; ok {
|
||||
translated = true
|
||||
matched = true
|
||||
|
||||
if tr.mappedRune >= 0 {
|
||||
result = tr.mappedRune
|
||||
@@ -371,7 +396,7 @@ func (tr *Translator) TranslateRune(r rune) (result rune, translated bool) {
|
||||
rrm = ranges[i]
|
||||
|
||||
if rrm.FromLo <= r && r <= rrm.FromHi {
|
||||
translated = true
|
||||
matched = true
|
||||
|
||||
if tr.mappedRune >= 0 {
|
||||
result = tr.mappedRune
|
||||
@@ -393,17 +418,19 @@ func (tr *Translator) TranslateRune(r rune) (result rune, translated bool) {
|
||||
}
|
||||
|
||||
if tr.reverted {
|
||||
if !translated {
|
||||
if !matched {
|
||||
result = tr.mappedRune
|
||||
}
|
||||
|
||||
translated = !translated
|
||||
matched = !matched
|
||||
}
|
||||
|
||||
if !translated {
|
||||
if !matched {
|
||||
result = r
|
||||
}
|
||||
|
||||
deleted = matched && tr.deletion
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -6,7 +6,9 @@ This package provides various compression algorithms.
|
||||
* [S2](https://github.com/klauspost/compress/tree/master/s2#s2-compression) is a high performance replacement for Snappy.
|
||||
* Optimized [deflate](https://godoc.org/github.com/klauspost/compress/flate) packages which can be used as a dropin replacement for [gzip](https://godoc.org/github.com/klauspost/compress/gzip), [zip](https://godoc.org/github.com/klauspost/compress/zip) and [zlib](https://godoc.org/github.com/klauspost/compress/zlib).
|
||||
* [snappy](https://github.com/klauspost/compress/tree/master/snappy) is a drop-in replacement for `github.com/golang/snappy` offering better compression and concurrent streams.
|
||||
* [lzw](https://github.com/klauspost/compress/tree/master/lzw) is a drop-in replacement for `compress/lzw` with 1.4-4x faster decompression and 1.1-2.7x faster compression, depending on the data.
|
||||
* [huff0](https://github.com/klauspost/compress/tree/master/huff0) and [FSE](https://github.com/klauspost/compress/tree/master/fse) implementations for raw entropy encoding.
|
||||
* [Xpress](https://github.com/klauspost/compress/tree/master/xpress) decompression of the Microsoft XPRESS (MS-XCA) plain LZ77 and LZ77+Huffman formats (the LZ77+Huffman variant is the one used in WIM images and Windows Compact OS / WOF data).
|
||||
* [gzhttp](https://github.com/klauspost/compress/tree/master/gzhttp) Provides client and server wrappers for handling gzipped/zstd HTTP requests efficiently.
|
||||
* [pgzip](https://github.com/klauspost/pgzip) is a separate package that provides a very fast parallel gzip implementation.
|
||||
|
||||
|
||||
+1
@@ -260,6 +260,7 @@ func (d *compressor) fillWindow(b []byte) {
|
||||
}
|
||||
// Update window information.
|
||||
d.windowEnd += n
|
||||
d.blockStart = d.windowEnd
|
||||
s.index = n
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -9,6 +9,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/klauspost/compress/internal/le"
|
||||
"github.com/klauspost/compress/internal/regmask"
|
||||
)
|
||||
|
||||
type fastEnc interface {
|
||||
@@ -108,7 +109,7 @@ type tableEntryPrev struct {
|
||||
// hash7 returns the hash of the lowest 7 bytes of u to fit in a hash table with h bits.
|
||||
// Preferably h should be a constant and should always be <64.
|
||||
func hash7(u uint64, h uint8) uint32 {
|
||||
return uint32(((u << (64 - 56)) * prime7bytes) >> ((64 - h) & reg8SizeMask64))
|
||||
return uint32(((u << (64 - 56)) * prime7bytes) >> ((64 - h) & regmask.Shift64ByUint8))
|
||||
}
|
||||
|
||||
// hashLen returns a hash of the lowest mls bytes of with length output bits.
|
||||
|
||||
+7
-5
@@ -14,6 +14,8 @@ import (
|
||||
"io"
|
||||
"math/bits"
|
||||
"sync"
|
||||
|
||||
"github.com/klauspost/compress/internal/regmask"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -557,8 +559,8 @@ func (f *decompressor) readHuffman() error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
rep += int(f.b & uint32(1<<(nb®SizeMaskUint32)-1))
|
||||
f.b >>= nb & regSizeMaskUint32
|
||||
rep += int(f.b & uint32(1<<(nb®mask.Shift32ByUint)-1))
|
||||
f.b >>= nb & regmask.Shift32ByUint
|
||||
f.nb -= nb
|
||||
if i+rep > n {
|
||||
if debugDecode {
|
||||
@@ -731,7 +733,7 @@ func (f *decompressor) moreBits() error {
|
||||
return noEOF(err)
|
||||
}
|
||||
f.roffset++
|
||||
f.b |= uint32(c) << (f.nb & regSizeMaskUint32)
|
||||
f.b |= uint32(c) << (f.nb & regmask.Shift32ByUint)
|
||||
f.nb += 8
|
||||
return nil
|
||||
}
|
||||
@@ -756,7 +758,7 @@ func (f *decompressor) huffSym(h *huffmanDecoder) (int, error) {
|
||||
return 0, noEOF(err)
|
||||
}
|
||||
f.roffset++
|
||||
b |= uint32(c) << (nb & regSizeMaskUint32)
|
||||
b |= uint32(c) << (nb & regmask.Shift32ByUint)
|
||||
nb += 8
|
||||
}
|
||||
chunk := h.chunks[b&(huffmanNumChunks-1)]
|
||||
@@ -775,7 +777,7 @@ func (f *decompressor) huffSym(h *huffmanDecoder) (int, error) {
|
||||
f.err = CorruptInputError(f.roffset)
|
||||
return 0, f.err
|
||||
}
|
||||
f.b = b >> (n & regSizeMaskUint32)
|
||||
f.b = b >> (n & regmask.Shift32ByUint)
|
||||
f.nb = nb - n
|
||||
return int(chunk >> huffmanValueShift), nil
|
||||
}
|
||||
|
||||
+57
-55
@@ -8,6 +8,8 @@ import (
|
||||
"fmt"
|
||||
"math/bits"
|
||||
"strings"
|
||||
|
||||
"github.com/klauspost/compress/internal/regmask"
|
||||
)
|
||||
|
||||
func peekBufio(fr *bufio.Reader) ([]byte, error) {
|
||||
@@ -62,7 +64,7 @@ readLiteral:
|
||||
return
|
||||
}
|
||||
f.roffset++
|
||||
fb |= uint32(c) << (fnb & regSizeMaskUint32)
|
||||
fb |= uint32(c) << (fnb & regmask.Shift32ByUint)
|
||||
fnb += 8
|
||||
}
|
||||
chunk := f.hl.chunks[fb&(huffmanNumChunks-1)]
|
||||
@@ -80,7 +82,7 @@ readLiteral:
|
||||
f.err = CorruptInputError(f.roffset)
|
||||
return
|
||||
}
|
||||
fb = fb >> (n & regSizeMaskUint32)
|
||||
fb = fb >> (n & regmask.Shift32ByUint)
|
||||
fnb = fnb - n
|
||||
v = int(chunk >> huffmanValueShift)
|
||||
break
|
||||
@@ -122,11 +124,11 @@ readLiteral:
|
||||
return
|
||||
}
|
||||
f.roffset++
|
||||
fb |= uint32(c) << (fnb & regSizeMaskUint32)
|
||||
fb |= uint32(c) << (fnb & regmask.Shift32ByUint)
|
||||
fnb += 8
|
||||
}
|
||||
length += int(fb & bitMask32[n])
|
||||
fb >>= n & regSizeMaskUint32
|
||||
fb >>= n & regmask.Shift32ByUint
|
||||
fnb -= n
|
||||
default:
|
||||
if debugDecode {
|
||||
@@ -150,7 +152,7 @@ readLiteral:
|
||||
return
|
||||
}
|
||||
f.roffset++
|
||||
fb |= uint32(c) << (fnb & regSizeMaskUint32)
|
||||
fb |= uint32(c) << (fnb & regmask.Shift32ByUint)
|
||||
fnb += 8
|
||||
}
|
||||
dist = uint32(bits.Reverse8(uint8(fb & 0x1F << 3)))
|
||||
@@ -174,7 +176,7 @@ readLiteral:
|
||||
return
|
||||
}
|
||||
f.roffset++
|
||||
fb |= uint32(c) << (fnb & regSizeMaskUint32)
|
||||
fb |= uint32(c) << (fnb & regmask.Shift32ByUint)
|
||||
fnb += 8
|
||||
}
|
||||
chunk := f.hd.chunks[fb&(huffmanNumChunks-1)]
|
||||
@@ -192,7 +194,7 @@ readLiteral:
|
||||
f.err = CorruptInputError(f.roffset)
|
||||
return
|
||||
}
|
||||
fb = fb >> (n & regSizeMaskUint32)
|
||||
fb = fb >> (n & regmask.Shift32ByUint)
|
||||
fnb = fnb - n
|
||||
dist = uint32(chunk >> huffmanValueShift)
|
||||
break
|
||||
@@ -206,7 +208,7 @@ readLiteral:
|
||||
case dist < maxNumDist:
|
||||
nb := uint(dist-2) >> 1
|
||||
// have 1 bit in bottom of dist, need nb more.
|
||||
extra := (dist & 1) << (nb & regSizeMaskUint32)
|
||||
extra := (dist & 1) << (nb & regmask.Shift32ByUint)
|
||||
for fnb < nb {
|
||||
c, err := fr.ReadByte()
|
||||
if err != nil {
|
||||
@@ -218,13 +220,13 @@ readLiteral:
|
||||
return
|
||||
}
|
||||
f.roffset++
|
||||
fb |= uint32(c) << (fnb & regSizeMaskUint32)
|
||||
fb |= uint32(c) << (fnb & regmask.Shift32ByUint)
|
||||
fnb += 8
|
||||
}
|
||||
extra |= fb & bitMask32[nb]
|
||||
fb >>= nb & regSizeMaskUint32
|
||||
fb >>= nb & regmask.Shift32ByUint
|
||||
fnb -= nb
|
||||
dist = 1<<((nb+1)®SizeMaskUint32) + 1 + extra
|
||||
dist = 1<<((nb+1)®mask.Shift32ByUint) + 1 + extra
|
||||
// slower: dist = bitMask32[nb+1] + 2 + extra
|
||||
default:
|
||||
f.b, f.nb = fb, fnb
|
||||
@@ -313,7 +315,7 @@ readLiteral:
|
||||
return
|
||||
}
|
||||
f.roffset++
|
||||
fb |= uint32(c) << (fnb & regSizeMaskUint32)
|
||||
fb |= uint32(c) << (fnb & regmask.Shift32ByUint)
|
||||
fnb += 8
|
||||
}
|
||||
chunk := f.hl.chunks[fb&(huffmanNumChunks-1)]
|
||||
@@ -331,7 +333,7 @@ readLiteral:
|
||||
f.err = CorruptInputError(f.roffset)
|
||||
return
|
||||
}
|
||||
fb = fb >> (n & regSizeMaskUint32)
|
||||
fb = fb >> (n & regmask.Shift32ByUint)
|
||||
fnb = fnb - n
|
||||
v = int(chunk >> huffmanValueShift)
|
||||
break
|
||||
@@ -373,11 +375,11 @@ readLiteral:
|
||||
return
|
||||
}
|
||||
f.roffset++
|
||||
fb |= uint32(c) << (fnb & regSizeMaskUint32)
|
||||
fb |= uint32(c) << (fnb & regmask.Shift32ByUint)
|
||||
fnb += 8
|
||||
}
|
||||
length += int(fb & bitMask32[n])
|
||||
fb >>= n & regSizeMaskUint32
|
||||
fb >>= n & regmask.Shift32ByUint
|
||||
fnb -= n
|
||||
default:
|
||||
if debugDecode {
|
||||
@@ -401,7 +403,7 @@ readLiteral:
|
||||
return
|
||||
}
|
||||
f.roffset++
|
||||
fb |= uint32(c) << (fnb & regSizeMaskUint32)
|
||||
fb |= uint32(c) << (fnb & regmask.Shift32ByUint)
|
||||
fnb += 8
|
||||
}
|
||||
dist = uint32(bits.Reverse8(uint8(fb & 0x1F << 3)))
|
||||
@@ -425,7 +427,7 @@ readLiteral:
|
||||
return
|
||||
}
|
||||
f.roffset++
|
||||
fb |= uint32(c) << (fnb & regSizeMaskUint32)
|
||||
fb |= uint32(c) << (fnb & regmask.Shift32ByUint)
|
||||
fnb += 8
|
||||
}
|
||||
chunk := f.hd.chunks[fb&(huffmanNumChunks-1)]
|
||||
@@ -443,7 +445,7 @@ readLiteral:
|
||||
f.err = CorruptInputError(f.roffset)
|
||||
return
|
||||
}
|
||||
fb = fb >> (n & regSizeMaskUint32)
|
||||
fb = fb >> (n & regmask.Shift32ByUint)
|
||||
fnb = fnb - n
|
||||
dist = uint32(chunk >> huffmanValueShift)
|
||||
break
|
||||
@@ -457,7 +459,7 @@ readLiteral:
|
||||
case dist < maxNumDist:
|
||||
nb := uint(dist-2) >> 1
|
||||
// have 1 bit in bottom of dist, need nb more.
|
||||
extra := (dist & 1) << (nb & regSizeMaskUint32)
|
||||
extra := (dist & 1) << (nb & regmask.Shift32ByUint)
|
||||
for fnb < nb {
|
||||
c, err := fr.ReadByte()
|
||||
if err != nil {
|
||||
@@ -469,13 +471,13 @@ readLiteral:
|
||||
return
|
||||
}
|
||||
f.roffset++
|
||||
fb |= uint32(c) << (fnb & regSizeMaskUint32)
|
||||
fb |= uint32(c) << (fnb & regmask.Shift32ByUint)
|
||||
fnb += 8
|
||||
}
|
||||
extra |= fb & bitMask32[nb]
|
||||
fb >>= nb & regSizeMaskUint32
|
||||
fb >>= nb & regmask.Shift32ByUint
|
||||
fnb -= nb
|
||||
dist = 1<<((nb+1)®SizeMaskUint32) + 1 + extra
|
||||
dist = 1<<((nb+1)®mask.Shift32ByUint) + 1 + extra
|
||||
// slower: dist = bitMask32[nb+1] + 2 + extra
|
||||
default:
|
||||
f.b, f.nb = fb, fnb
|
||||
@@ -573,7 +575,7 @@ readLiteral:
|
||||
c := pbuf[pos]
|
||||
pos++
|
||||
f.roffset++
|
||||
fb |= uint32(c) << (fnb & regSizeMaskUint32)
|
||||
fb |= uint32(c) << (fnb & regmask.Shift32ByUint)
|
||||
fnb += 8
|
||||
}
|
||||
chunk := f.hl.chunks[fb&(huffmanNumChunks-1)]
|
||||
@@ -592,7 +594,7 @@ readLiteral:
|
||||
f.err = CorruptInputError(f.roffset)
|
||||
return
|
||||
}
|
||||
fb = fb >> (n & regSizeMaskUint32)
|
||||
fb = fb >> (n & regmask.Shift32ByUint)
|
||||
fnb = fnb - n
|
||||
v = int(chunk >> huffmanValueShift)
|
||||
break
|
||||
@@ -643,11 +645,11 @@ readLiteral:
|
||||
c := pbuf[pos]
|
||||
pos++
|
||||
f.roffset++
|
||||
fb |= uint32(c) << (fnb & regSizeMaskUint32)
|
||||
fb |= uint32(c) << (fnb & regmask.Shift32ByUint)
|
||||
fnb += 8
|
||||
}
|
||||
length += int(fb & bitMask32[n])
|
||||
fb >>= n & regSizeMaskUint32
|
||||
fb >>= n & regmask.Shift32ByUint
|
||||
fnb -= n
|
||||
default:
|
||||
fr.Discard(pos)
|
||||
@@ -679,7 +681,7 @@ readLiteral:
|
||||
c := pbuf[pos]
|
||||
pos++
|
||||
f.roffset++
|
||||
fb |= uint32(c) << (fnb & regSizeMaskUint32)
|
||||
fb |= uint32(c) << (fnb & regmask.Shift32ByUint)
|
||||
fnb += 8
|
||||
}
|
||||
dist = uint32(bits.Reverse8(uint8(fb & 0x1F << 3)))
|
||||
@@ -710,7 +712,7 @@ readLiteral:
|
||||
c := pbuf[pos]
|
||||
pos++
|
||||
f.roffset++
|
||||
fb |= uint32(c) << (fnb & regSizeMaskUint32)
|
||||
fb |= uint32(c) << (fnb & regmask.Shift32ByUint)
|
||||
fnb += 8
|
||||
}
|
||||
chunk := f.hd.chunks[fb&(huffmanNumChunks-1)]
|
||||
@@ -729,7 +731,7 @@ readLiteral:
|
||||
f.err = CorruptInputError(f.roffset)
|
||||
return
|
||||
}
|
||||
fb = fb >> (n & regSizeMaskUint32)
|
||||
fb = fb >> (n & regmask.Shift32ByUint)
|
||||
fnb = fnb - n
|
||||
dist = uint32(chunk >> huffmanValueShift)
|
||||
break
|
||||
@@ -743,7 +745,7 @@ readLiteral:
|
||||
case dist < maxNumDist:
|
||||
nb := uint(dist-2) >> 1
|
||||
// have 1 bit in bottom of dist, need nb more.
|
||||
extra := (dist & 1) << (nb & regSizeMaskUint32)
|
||||
extra := (dist & 1) << (nb & regmask.Shift32ByUint)
|
||||
for fnb < nb {
|
||||
if pos >= len(pbuf) {
|
||||
fr.Discard(pos)
|
||||
@@ -762,13 +764,13 @@ readLiteral:
|
||||
c := pbuf[pos]
|
||||
pos++
|
||||
f.roffset++
|
||||
fb |= uint32(c) << (fnb & regSizeMaskUint32)
|
||||
fb |= uint32(c) << (fnb & regmask.Shift32ByUint)
|
||||
fnb += 8
|
||||
}
|
||||
extra |= fb & bitMask32[nb]
|
||||
fb >>= nb & regSizeMaskUint32
|
||||
fb >>= nb & regmask.Shift32ByUint
|
||||
fnb -= nb
|
||||
dist = 1<<((nb+1)®SizeMaskUint32) + 1 + extra
|
||||
dist = 1<<((nb+1)®mask.Shift32ByUint) + 1 + extra
|
||||
// slower: dist = bitMask32[nb+1] + 2 + extra
|
||||
default:
|
||||
fr.Discard(pos)
|
||||
@@ -860,7 +862,7 @@ readLiteral:
|
||||
return
|
||||
}
|
||||
f.roffset++
|
||||
fb |= uint32(c) << (fnb & regSizeMaskUint32)
|
||||
fb |= uint32(c) << (fnb & regmask.Shift32ByUint)
|
||||
fnb += 8
|
||||
}
|
||||
chunk := f.hl.chunks[fb&(huffmanNumChunks-1)]
|
||||
@@ -878,7 +880,7 @@ readLiteral:
|
||||
f.err = CorruptInputError(f.roffset)
|
||||
return
|
||||
}
|
||||
fb = fb >> (n & regSizeMaskUint32)
|
||||
fb = fb >> (n & regmask.Shift32ByUint)
|
||||
fnb = fnb - n
|
||||
v = int(chunk >> huffmanValueShift)
|
||||
break
|
||||
@@ -920,11 +922,11 @@ readLiteral:
|
||||
return
|
||||
}
|
||||
f.roffset++
|
||||
fb |= uint32(c) << (fnb & regSizeMaskUint32)
|
||||
fb |= uint32(c) << (fnb & regmask.Shift32ByUint)
|
||||
fnb += 8
|
||||
}
|
||||
length += int(fb & bitMask32[n])
|
||||
fb >>= n & regSizeMaskUint32
|
||||
fb >>= n & regmask.Shift32ByUint
|
||||
fnb -= n
|
||||
default:
|
||||
if debugDecode {
|
||||
@@ -948,7 +950,7 @@ readLiteral:
|
||||
return
|
||||
}
|
||||
f.roffset++
|
||||
fb |= uint32(c) << (fnb & regSizeMaskUint32)
|
||||
fb |= uint32(c) << (fnb & regmask.Shift32ByUint)
|
||||
fnb += 8
|
||||
}
|
||||
dist = uint32(bits.Reverse8(uint8(fb & 0x1F << 3)))
|
||||
@@ -972,7 +974,7 @@ readLiteral:
|
||||
return
|
||||
}
|
||||
f.roffset++
|
||||
fb |= uint32(c) << (fnb & regSizeMaskUint32)
|
||||
fb |= uint32(c) << (fnb & regmask.Shift32ByUint)
|
||||
fnb += 8
|
||||
}
|
||||
chunk := f.hd.chunks[fb&(huffmanNumChunks-1)]
|
||||
@@ -990,7 +992,7 @@ readLiteral:
|
||||
f.err = CorruptInputError(f.roffset)
|
||||
return
|
||||
}
|
||||
fb = fb >> (n & regSizeMaskUint32)
|
||||
fb = fb >> (n & regmask.Shift32ByUint)
|
||||
fnb = fnb - n
|
||||
dist = uint32(chunk >> huffmanValueShift)
|
||||
break
|
||||
@@ -1004,7 +1006,7 @@ readLiteral:
|
||||
case dist < maxNumDist:
|
||||
nb := uint(dist-2) >> 1
|
||||
// have 1 bit in bottom of dist, need nb more.
|
||||
extra := (dist & 1) << (nb & regSizeMaskUint32)
|
||||
extra := (dist & 1) << (nb & regmask.Shift32ByUint)
|
||||
for fnb < nb {
|
||||
c, err := fr.ReadByte()
|
||||
if err != nil {
|
||||
@@ -1016,13 +1018,13 @@ readLiteral:
|
||||
return
|
||||
}
|
||||
f.roffset++
|
||||
fb |= uint32(c) << (fnb & regSizeMaskUint32)
|
||||
fb |= uint32(c) << (fnb & regmask.Shift32ByUint)
|
||||
fnb += 8
|
||||
}
|
||||
extra |= fb & bitMask32[nb]
|
||||
fb >>= nb & regSizeMaskUint32
|
||||
fb >>= nb & regmask.Shift32ByUint
|
||||
fnb -= nb
|
||||
dist = 1<<((nb+1)®SizeMaskUint32) + 1 + extra
|
||||
dist = 1<<((nb+1)®mask.Shift32ByUint) + 1 + extra
|
||||
// slower: dist = bitMask32[nb+1] + 2 + extra
|
||||
default:
|
||||
f.b, f.nb = fb, fnb
|
||||
@@ -1111,7 +1113,7 @@ readLiteral:
|
||||
return
|
||||
}
|
||||
f.roffset++
|
||||
fb |= uint32(c) << (fnb & regSizeMaskUint32)
|
||||
fb |= uint32(c) << (fnb & regmask.Shift32ByUint)
|
||||
fnb += 8
|
||||
}
|
||||
chunk := f.hl.chunks[fb&(huffmanNumChunks-1)]
|
||||
@@ -1129,7 +1131,7 @@ readLiteral:
|
||||
f.err = CorruptInputError(f.roffset)
|
||||
return
|
||||
}
|
||||
fb = fb >> (n & regSizeMaskUint32)
|
||||
fb = fb >> (n & regmask.Shift32ByUint)
|
||||
fnb = fnb - n
|
||||
v = int(chunk >> huffmanValueShift)
|
||||
break
|
||||
@@ -1171,11 +1173,11 @@ readLiteral:
|
||||
return
|
||||
}
|
||||
f.roffset++
|
||||
fb |= uint32(c) << (fnb & regSizeMaskUint32)
|
||||
fb |= uint32(c) << (fnb & regmask.Shift32ByUint)
|
||||
fnb += 8
|
||||
}
|
||||
length += int(fb & bitMask32[n])
|
||||
fb >>= n & regSizeMaskUint32
|
||||
fb >>= n & regmask.Shift32ByUint
|
||||
fnb -= n
|
||||
default:
|
||||
if debugDecode {
|
||||
@@ -1199,7 +1201,7 @@ readLiteral:
|
||||
return
|
||||
}
|
||||
f.roffset++
|
||||
fb |= uint32(c) << (fnb & regSizeMaskUint32)
|
||||
fb |= uint32(c) << (fnb & regmask.Shift32ByUint)
|
||||
fnb += 8
|
||||
}
|
||||
dist = uint32(bits.Reverse8(uint8(fb & 0x1F << 3)))
|
||||
@@ -1223,7 +1225,7 @@ readLiteral:
|
||||
return
|
||||
}
|
||||
f.roffset++
|
||||
fb |= uint32(c) << (fnb & regSizeMaskUint32)
|
||||
fb |= uint32(c) << (fnb & regmask.Shift32ByUint)
|
||||
fnb += 8
|
||||
}
|
||||
chunk := f.hd.chunks[fb&(huffmanNumChunks-1)]
|
||||
@@ -1241,7 +1243,7 @@ readLiteral:
|
||||
f.err = CorruptInputError(f.roffset)
|
||||
return
|
||||
}
|
||||
fb = fb >> (n & regSizeMaskUint32)
|
||||
fb = fb >> (n & regmask.Shift32ByUint)
|
||||
fnb = fnb - n
|
||||
dist = uint32(chunk >> huffmanValueShift)
|
||||
break
|
||||
@@ -1255,7 +1257,7 @@ readLiteral:
|
||||
case dist < maxNumDist:
|
||||
nb := uint(dist-2) >> 1
|
||||
// have 1 bit in bottom of dist, need nb more.
|
||||
extra := (dist & 1) << (nb & regSizeMaskUint32)
|
||||
extra := (dist & 1) << (nb & regmask.Shift32ByUint)
|
||||
for fnb < nb {
|
||||
c, err := fr.ReadByte()
|
||||
if err != nil {
|
||||
@@ -1267,13 +1269,13 @@ readLiteral:
|
||||
return
|
||||
}
|
||||
f.roffset++
|
||||
fb |= uint32(c) << (fnb & regSizeMaskUint32)
|
||||
fb |= uint32(c) << (fnb & regmask.Shift32ByUint)
|
||||
fnb += 8
|
||||
}
|
||||
extra |= fb & bitMask32[nb]
|
||||
fb >>= nb & regSizeMaskUint32
|
||||
fb >>= nb & regmask.Shift32ByUint
|
||||
fnb -= nb
|
||||
dist = 1<<((nb+1)®SizeMaskUint32) + 1 + extra
|
||||
dist = 1<<((nb+1)®mask.Shift32ByUint) + 1 + extra
|
||||
// slower: dist = bitMask32[nb+1] + 2 + extra
|
||||
default:
|
||||
f.b, f.nb = fb, fnb
|
||||
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
package flate
|
||||
|
||||
const (
|
||||
// Masks for shifts with register sizes of the shift value.
|
||||
// This can be used to work around the x86 design of shifting by mod register size.
|
||||
// It can be used when a variable shift is always smaller than the register size.
|
||||
|
||||
// reg8SizeMaskX - shift value is 8 bits, shifted is X
|
||||
reg8SizeMask8 = 7
|
||||
reg8SizeMask16 = 15
|
||||
reg8SizeMask32 = 31
|
||||
reg8SizeMask64 = 63
|
||||
|
||||
// reg16SizeMaskX - shift value is 16 bits, shifted is X
|
||||
reg16SizeMask8 = reg8SizeMask8
|
||||
reg16SizeMask16 = reg8SizeMask16
|
||||
reg16SizeMask32 = reg8SizeMask32
|
||||
reg16SizeMask64 = reg8SizeMask64
|
||||
|
||||
// reg32SizeMaskX - shift value is 32 bits, shifted is X
|
||||
reg32SizeMask8 = reg8SizeMask8
|
||||
reg32SizeMask16 = reg8SizeMask16
|
||||
reg32SizeMask32 = reg8SizeMask32
|
||||
reg32SizeMask64 = reg8SizeMask64
|
||||
|
||||
// reg64SizeMaskX - shift value is 64 bits, shifted is X
|
||||
reg64SizeMask8 = reg8SizeMask8
|
||||
reg64SizeMask16 = reg8SizeMask16
|
||||
reg64SizeMask32 = reg8SizeMask32
|
||||
reg64SizeMask64 = reg8SizeMask64
|
||||
|
||||
// regSizeMaskUintX - shift value is uint, shifted is X
|
||||
regSizeMaskUint8 = reg8SizeMask8
|
||||
regSizeMaskUint16 = reg8SizeMask16
|
||||
regSizeMaskUint32 = reg8SizeMask32
|
||||
regSizeMaskUint64 = reg8SizeMask64
|
||||
)
|
||||
-39
@@ -1,39 +0,0 @@
|
||||
//go:build !amd64
|
||||
|
||||
package flate
|
||||
|
||||
const (
|
||||
// Masks for shifts with register sizes of the shift value.
|
||||
// This can be used to work around the x86 design of shifting by mod register size.
|
||||
// It can be used when a variable shift is always smaller than the register size.
|
||||
|
||||
// reg8SizeMaskX - shift value is 8 bits, shifted is X
|
||||
reg8SizeMask8 = 0xff
|
||||
reg8SizeMask16 = 0xff
|
||||
reg8SizeMask32 = 0xff
|
||||
reg8SizeMask64 = 0xff
|
||||
|
||||
// reg16SizeMaskX - shift value is 16 bits, shifted is X
|
||||
reg16SizeMask8 = 0xffff
|
||||
reg16SizeMask16 = 0xffff
|
||||
reg16SizeMask32 = 0xffff
|
||||
reg16SizeMask64 = 0xffff
|
||||
|
||||
// reg32SizeMaskX - shift value is 32 bits, shifted is X
|
||||
reg32SizeMask8 = 0xffffffff
|
||||
reg32SizeMask16 = 0xffffffff
|
||||
reg32SizeMask32 = 0xffffffff
|
||||
reg32SizeMask64 = 0xffffffff
|
||||
|
||||
// reg64SizeMaskX - shift value is 64 bits, shifted is X
|
||||
reg64SizeMask8 = 0xffffffffffffffff
|
||||
reg64SizeMask16 = 0xffffffffffffffff
|
||||
reg64SizeMask32 = 0xffffffffffffffff
|
||||
reg64SizeMask64 = 0xffffffffffffffff
|
||||
|
||||
// regSizeMaskUintX - shift value is uint, shifted is X
|
||||
regSizeMaskUint8 = ^uint(0)
|
||||
regSizeMaskUint16 = ^uint(0)
|
||||
regSizeMaskUint32 = ^uint(0)
|
||||
regSizeMaskUint64 = ^uint(0)
|
||||
)
|
||||
+103
-103
@@ -47,12 +47,12 @@ skip_fill0:
|
||||
SHRQ CL, R13
|
||||
|
||||
// v0 := table[val0&mask]
|
||||
MOVW (R9)(R13*2), CX
|
||||
MOVWQZX (R9)(R13*2), CX
|
||||
|
||||
// br0.advance(uint8(v0.entry)
|
||||
MOVB CH, AL
|
||||
SHLQ CL, R11
|
||||
ADDB CL, R12
|
||||
MOVBLZX CH, AX
|
||||
SHLQ CL, R11
|
||||
ADDB CL, R12
|
||||
|
||||
// val1 := br0.peekTopBits(peekBits)
|
||||
MOVQ DI, CX
|
||||
@@ -60,7 +60,7 @@ skip_fill0:
|
||||
SHRQ CL, R13
|
||||
|
||||
// v1 := table[val1&mask]
|
||||
MOVW (R9)(R13*2), CX
|
||||
MOVWQZX (R9)(R13*2), CX
|
||||
|
||||
// br0.advance(uint8(v1.entry))
|
||||
MOVB CH, AH
|
||||
@@ -104,12 +104,12 @@ skip_fill1:
|
||||
SHRQ CL, R13
|
||||
|
||||
// v0 := table[val0&mask]
|
||||
MOVW (R9)(R13*2), CX
|
||||
MOVWQZX (R9)(R13*2), CX
|
||||
|
||||
// br1.advance(uint8(v0.entry)
|
||||
MOVB CH, AL
|
||||
SHLQ CL, R11
|
||||
ADDB CL, R12
|
||||
MOVBLZX CH, AX
|
||||
SHLQ CL, R11
|
||||
ADDB CL, R12
|
||||
|
||||
// val1 := br1.peekTopBits(peekBits)
|
||||
MOVQ DI, CX
|
||||
@@ -117,7 +117,7 @@ skip_fill1:
|
||||
SHRQ CL, R13
|
||||
|
||||
// v1 := table[val1&mask]
|
||||
MOVW (R9)(R13*2), CX
|
||||
MOVWQZX (R9)(R13*2), CX
|
||||
|
||||
// br1.advance(uint8(v1.entry))
|
||||
MOVB CH, AH
|
||||
@@ -161,12 +161,12 @@ skip_fill2:
|
||||
SHRQ CL, R13
|
||||
|
||||
// v0 := table[val0&mask]
|
||||
MOVW (R9)(R13*2), CX
|
||||
MOVWQZX (R9)(R13*2), CX
|
||||
|
||||
// br2.advance(uint8(v0.entry)
|
||||
MOVB CH, AL
|
||||
SHLQ CL, R11
|
||||
ADDB CL, R12
|
||||
MOVBLZX CH, AX
|
||||
SHLQ CL, R11
|
||||
ADDB CL, R12
|
||||
|
||||
// val1 := br2.peekTopBits(peekBits)
|
||||
MOVQ DI, CX
|
||||
@@ -174,7 +174,7 @@ skip_fill2:
|
||||
SHRQ CL, R13
|
||||
|
||||
// v1 := table[val1&mask]
|
||||
MOVW (R9)(R13*2), CX
|
||||
MOVWQZX (R9)(R13*2), CX
|
||||
|
||||
// br2.advance(uint8(v1.entry))
|
||||
MOVB CH, AH
|
||||
@@ -218,12 +218,12 @@ skip_fill3:
|
||||
SHRQ CL, R13
|
||||
|
||||
// v0 := table[val0&mask]
|
||||
MOVW (R9)(R13*2), CX
|
||||
MOVWQZX (R9)(R13*2), CX
|
||||
|
||||
// br3.advance(uint8(v0.entry)
|
||||
MOVB CH, AL
|
||||
SHLQ CL, R11
|
||||
ADDB CL, R12
|
||||
MOVBLZX CH, AX
|
||||
SHLQ CL, R11
|
||||
ADDB CL, R12
|
||||
|
||||
// val1 := br3.peekTopBits(peekBits)
|
||||
MOVQ DI, CX
|
||||
@@ -231,7 +231,7 @@ skip_fill3:
|
||||
SHRQ CL, R13
|
||||
|
||||
// v1 := table[val1&mask]
|
||||
MOVW (R9)(R13*2), CX
|
||||
MOVWQZX (R9)(R13*2), CX
|
||||
|
||||
// br3.advance(uint8(v1.entry))
|
||||
MOVB CH, AH
|
||||
@@ -259,13 +259,13 @@ skip_fill3:
|
||||
// func decompress4x_8b_main_loop_amd64(ctx *decompress4xContext)
|
||||
TEXT ·decompress4x_8b_main_loop_amd64(SB), $0-8
|
||||
// Preload values
|
||||
MOVQ ctx+0(FP), CX
|
||||
MOVBQZX 8(CX), DI
|
||||
MOVQ 16(CX), BX
|
||||
MOVQ 48(CX), SI
|
||||
MOVQ 24(CX), R8
|
||||
MOVQ 32(CX), R9
|
||||
MOVQ (CX), R10
|
||||
MOVQ ctx+0(FP), AX
|
||||
MOVBQZX 8(AX), DI
|
||||
MOVQ 16(AX), BX
|
||||
MOVQ 48(AX), SI
|
||||
MOVQ 24(AX), R8
|
||||
MOVQ 32(AX), R9
|
||||
MOVQ (AX), R10
|
||||
|
||||
// Main loop
|
||||
main_loop:
|
||||
@@ -278,35 +278,35 @@ main_loop:
|
||||
MOVBQZX 40(R10), R12
|
||||
CMPQ R12, $0x20
|
||||
JBE skip_fill0
|
||||
MOVQ 24(R10), R13
|
||||
MOVQ 24(R10), AX
|
||||
SUBQ $0x20, R12
|
||||
SUBQ $0x04, R13
|
||||
MOVQ (R10), R14
|
||||
SUBQ $0x04, AX
|
||||
MOVQ (R10), R13
|
||||
|
||||
// b.value |= uint64(low) << (b.bitsRead & 63)
|
||||
MOVL (R13)(R14*1), R14
|
||||
MOVL (AX)(R13*1), R13
|
||||
MOVQ R12, CX
|
||||
SHLQ CL, R14
|
||||
MOVQ R13, 24(R10)
|
||||
ORQ R14, R11
|
||||
SHLQ CL, R13
|
||||
MOVQ AX, 24(R10)
|
||||
ORQ R13, R11
|
||||
|
||||
// exhausted += (br0.off < 4)
|
||||
CMPQ R13, $0x04
|
||||
CMPQ AX, $0x04
|
||||
ADCB $+0, DL
|
||||
|
||||
skip_fill0:
|
||||
// val0 := br0.peekTopBits(peekBits)
|
||||
MOVQ R11, R13
|
||||
MOVQ R11, AX
|
||||
MOVQ DI, CX
|
||||
SHRQ CL, R13
|
||||
SHRQ CL, AX
|
||||
|
||||
// v0 := table[val0&mask]
|
||||
MOVW (R9)(R13*2), CX
|
||||
MOVWQZX (R9)(AX*2), CX
|
||||
|
||||
// br0.advance(uint8(v0.entry)
|
||||
MOVB CH, AL
|
||||
SHLQ CL, R11
|
||||
ADDB CL, R12
|
||||
MOVBLZX CH, AX
|
||||
SHLQ CL, R11
|
||||
ADDB CL, R12
|
||||
|
||||
// val1 := br0.peekTopBits(peekBits)
|
||||
MOVQ R11, R13
|
||||
@@ -314,7 +314,7 @@ skip_fill0:
|
||||
SHRQ CL, R13
|
||||
|
||||
// v1 := table[val0&mask]
|
||||
MOVW (R9)(R13*2), CX
|
||||
MOVWQZX (R9)(R13*2), CX
|
||||
|
||||
// br0.advance(uint8(v1.entry)
|
||||
MOVB CH, AH
|
||||
@@ -328,7 +328,7 @@ skip_fill0:
|
||||
SHRQ CL, R13
|
||||
|
||||
// v2 := table[val0&mask]
|
||||
MOVW (R9)(R13*2), CX
|
||||
MOVWQZX (R9)(R13*2), CX
|
||||
|
||||
// br0.advance(uint8(v2.entry)
|
||||
MOVB CH, AH
|
||||
@@ -341,7 +341,7 @@ skip_fill0:
|
||||
SHRQ CL, R13
|
||||
|
||||
// v3 := table[val0&mask]
|
||||
MOVW (R9)(R13*2), CX
|
||||
MOVWQZX (R9)(R13*2), CX
|
||||
|
||||
// br0.advance(uint8(v3.entry)
|
||||
MOVB CH, AL
|
||||
@@ -365,35 +365,35 @@ skip_fill0:
|
||||
MOVBQZX 88(R10), R12
|
||||
CMPQ R12, $0x20
|
||||
JBE skip_fill1
|
||||
MOVQ 72(R10), R13
|
||||
MOVQ 72(R10), AX
|
||||
SUBQ $0x20, R12
|
||||
SUBQ $0x04, R13
|
||||
MOVQ 48(R10), R14
|
||||
SUBQ $0x04, AX
|
||||
MOVQ 48(R10), R13
|
||||
|
||||
// b.value |= uint64(low) << (b.bitsRead & 63)
|
||||
MOVL (R13)(R14*1), R14
|
||||
MOVL (AX)(R13*1), R13
|
||||
MOVQ R12, CX
|
||||
SHLQ CL, R14
|
||||
MOVQ R13, 72(R10)
|
||||
ORQ R14, R11
|
||||
SHLQ CL, R13
|
||||
MOVQ AX, 72(R10)
|
||||
ORQ R13, R11
|
||||
|
||||
// exhausted += (br1.off < 4)
|
||||
CMPQ R13, $0x04
|
||||
CMPQ AX, $0x04
|
||||
ADCB $+0, DL
|
||||
|
||||
skip_fill1:
|
||||
// val0 := br1.peekTopBits(peekBits)
|
||||
MOVQ R11, R13
|
||||
MOVQ R11, AX
|
||||
MOVQ DI, CX
|
||||
SHRQ CL, R13
|
||||
SHRQ CL, AX
|
||||
|
||||
// v0 := table[val0&mask]
|
||||
MOVW (R9)(R13*2), CX
|
||||
MOVWQZX (R9)(AX*2), CX
|
||||
|
||||
// br1.advance(uint8(v0.entry)
|
||||
MOVB CH, AL
|
||||
SHLQ CL, R11
|
||||
ADDB CL, R12
|
||||
MOVBLZX CH, AX
|
||||
SHLQ CL, R11
|
||||
ADDB CL, R12
|
||||
|
||||
// val1 := br1.peekTopBits(peekBits)
|
||||
MOVQ R11, R13
|
||||
@@ -401,7 +401,7 @@ skip_fill1:
|
||||
SHRQ CL, R13
|
||||
|
||||
// v1 := table[val0&mask]
|
||||
MOVW (R9)(R13*2), CX
|
||||
MOVWQZX (R9)(R13*2), CX
|
||||
|
||||
// br1.advance(uint8(v1.entry)
|
||||
MOVB CH, AH
|
||||
@@ -415,7 +415,7 @@ skip_fill1:
|
||||
SHRQ CL, R13
|
||||
|
||||
// v2 := table[val0&mask]
|
||||
MOVW (R9)(R13*2), CX
|
||||
MOVWQZX (R9)(R13*2), CX
|
||||
|
||||
// br1.advance(uint8(v2.entry)
|
||||
MOVB CH, AH
|
||||
@@ -428,7 +428,7 @@ skip_fill1:
|
||||
SHRQ CL, R13
|
||||
|
||||
// v3 := table[val0&mask]
|
||||
MOVW (R9)(R13*2), CX
|
||||
MOVWQZX (R9)(R13*2), CX
|
||||
|
||||
// br1.advance(uint8(v3.entry)
|
||||
MOVB CH, AL
|
||||
@@ -452,35 +452,35 @@ skip_fill1:
|
||||
MOVBQZX 136(R10), R12
|
||||
CMPQ R12, $0x20
|
||||
JBE skip_fill2
|
||||
MOVQ 120(R10), R13
|
||||
MOVQ 120(R10), AX
|
||||
SUBQ $0x20, R12
|
||||
SUBQ $0x04, R13
|
||||
MOVQ 96(R10), R14
|
||||
SUBQ $0x04, AX
|
||||
MOVQ 96(R10), R13
|
||||
|
||||
// b.value |= uint64(low) << (b.bitsRead & 63)
|
||||
MOVL (R13)(R14*1), R14
|
||||
MOVL (AX)(R13*1), R13
|
||||
MOVQ R12, CX
|
||||
SHLQ CL, R14
|
||||
MOVQ R13, 120(R10)
|
||||
ORQ R14, R11
|
||||
SHLQ CL, R13
|
||||
MOVQ AX, 120(R10)
|
||||
ORQ R13, R11
|
||||
|
||||
// exhausted += (br2.off < 4)
|
||||
CMPQ R13, $0x04
|
||||
CMPQ AX, $0x04
|
||||
ADCB $+0, DL
|
||||
|
||||
skip_fill2:
|
||||
// val0 := br2.peekTopBits(peekBits)
|
||||
MOVQ R11, R13
|
||||
MOVQ R11, AX
|
||||
MOVQ DI, CX
|
||||
SHRQ CL, R13
|
||||
SHRQ CL, AX
|
||||
|
||||
// v0 := table[val0&mask]
|
||||
MOVW (R9)(R13*2), CX
|
||||
MOVWQZX (R9)(AX*2), CX
|
||||
|
||||
// br2.advance(uint8(v0.entry)
|
||||
MOVB CH, AL
|
||||
SHLQ CL, R11
|
||||
ADDB CL, R12
|
||||
MOVBLZX CH, AX
|
||||
SHLQ CL, R11
|
||||
ADDB CL, R12
|
||||
|
||||
// val1 := br2.peekTopBits(peekBits)
|
||||
MOVQ R11, R13
|
||||
@@ -488,7 +488,7 @@ skip_fill2:
|
||||
SHRQ CL, R13
|
||||
|
||||
// v1 := table[val0&mask]
|
||||
MOVW (R9)(R13*2), CX
|
||||
MOVWQZX (R9)(R13*2), CX
|
||||
|
||||
// br2.advance(uint8(v1.entry)
|
||||
MOVB CH, AH
|
||||
@@ -502,7 +502,7 @@ skip_fill2:
|
||||
SHRQ CL, R13
|
||||
|
||||
// v2 := table[val0&mask]
|
||||
MOVW (R9)(R13*2), CX
|
||||
MOVWQZX (R9)(R13*2), CX
|
||||
|
||||
// br2.advance(uint8(v2.entry)
|
||||
MOVB CH, AH
|
||||
@@ -515,7 +515,7 @@ skip_fill2:
|
||||
SHRQ CL, R13
|
||||
|
||||
// v3 := table[val0&mask]
|
||||
MOVW (R9)(R13*2), CX
|
||||
MOVWQZX (R9)(R13*2), CX
|
||||
|
||||
// br2.advance(uint8(v3.entry)
|
||||
MOVB CH, AL
|
||||
@@ -539,35 +539,35 @@ skip_fill2:
|
||||
MOVBQZX 184(R10), R12
|
||||
CMPQ R12, $0x20
|
||||
JBE skip_fill3
|
||||
MOVQ 168(R10), R13
|
||||
MOVQ 168(R10), AX
|
||||
SUBQ $0x20, R12
|
||||
SUBQ $0x04, R13
|
||||
MOVQ 144(R10), R14
|
||||
SUBQ $0x04, AX
|
||||
MOVQ 144(R10), R13
|
||||
|
||||
// b.value |= uint64(low) << (b.bitsRead & 63)
|
||||
MOVL (R13)(R14*1), R14
|
||||
MOVL (AX)(R13*1), R13
|
||||
MOVQ R12, CX
|
||||
SHLQ CL, R14
|
||||
MOVQ R13, 168(R10)
|
||||
ORQ R14, R11
|
||||
SHLQ CL, R13
|
||||
MOVQ AX, 168(R10)
|
||||
ORQ R13, R11
|
||||
|
||||
// exhausted += (br3.off < 4)
|
||||
CMPQ R13, $0x04
|
||||
CMPQ AX, $0x04
|
||||
ADCB $+0, DL
|
||||
|
||||
skip_fill3:
|
||||
// val0 := br3.peekTopBits(peekBits)
|
||||
MOVQ R11, R13
|
||||
MOVQ R11, AX
|
||||
MOVQ DI, CX
|
||||
SHRQ CL, R13
|
||||
SHRQ CL, AX
|
||||
|
||||
// v0 := table[val0&mask]
|
||||
MOVW (R9)(R13*2), CX
|
||||
MOVWQZX (R9)(AX*2), CX
|
||||
|
||||
// br3.advance(uint8(v0.entry)
|
||||
MOVB CH, AL
|
||||
SHLQ CL, R11
|
||||
ADDB CL, R12
|
||||
MOVBLZX CH, AX
|
||||
SHLQ CL, R11
|
||||
ADDB CL, R12
|
||||
|
||||
// val1 := br3.peekTopBits(peekBits)
|
||||
MOVQ R11, R13
|
||||
@@ -575,7 +575,7 @@ skip_fill3:
|
||||
SHRQ CL, R13
|
||||
|
||||
// v1 := table[val0&mask]
|
||||
MOVW (R9)(R13*2), CX
|
||||
MOVWQZX (R9)(R13*2), CX
|
||||
|
||||
// br3.advance(uint8(v1.entry)
|
||||
MOVB CH, AH
|
||||
@@ -589,7 +589,7 @@ skip_fill3:
|
||||
SHRQ CL, R13
|
||||
|
||||
// v2 := table[val0&mask]
|
||||
MOVW (R9)(R13*2), CX
|
||||
MOVWQZX (R9)(R13*2), CX
|
||||
|
||||
// br3.advance(uint8(v2.entry)
|
||||
MOVB CH, AH
|
||||
@@ -602,7 +602,7 @@ skip_fill3:
|
||||
SHRQ CL, R13
|
||||
|
||||
// v3 := table[val0&mask]
|
||||
MOVW (R9)(R13*2), CX
|
||||
MOVWQZX (R9)(R13*2), CX
|
||||
|
||||
// br3.advance(uint8(v3.entry)
|
||||
MOVB CH, AL
|
||||
@@ -667,7 +667,7 @@ bitReader_fillFast_1_end:
|
||||
MOVQ DI, CX
|
||||
MOVQ R10, R12
|
||||
SHRQ CL, R12
|
||||
MOVW (SI)(R12*2), CX
|
||||
MOVWQZX (SI)(R12*2), CX
|
||||
MOVB CH, AL
|
||||
MOVBQZX CL, CX
|
||||
ADDQ CX, R11
|
||||
@@ -675,7 +675,7 @@ bitReader_fillFast_1_end:
|
||||
MOVQ DI, CX
|
||||
MOVQ R10, R12
|
||||
SHRQ CL, R12
|
||||
MOVW (SI)(R12*2), CX
|
||||
MOVWQZX (SI)(R12*2), CX
|
||||
MOVB CH, AH
|
||||
MOVBQZX CL, CX
|
||||
ADDQ CX, R11
|
||||
@@ -694,7 +694,7 @@ bitReader_fillFast_2_end:
|
||||
MOVQ DI, CX
|
||||
MOVQ R10, R12
|
||||
SHRQ CL, R12
|
||||
MOVW (SI)(R12*2), CX
|
||||
MOVWQZX (SI)(R12*2), CX
|
||||
MOVB CH, AH
|
||||
MOVBQZX CL, CX
|
||||
ADDQ CX, R11
|
||||
@@ -702,7 +702,7 @@ bitReader_fillFast_2_end:
|
||||
MOVQ DI, CX
|
||||
MOVQ R10, R12
|
||||
SHRQ CL, R12
|
||||
MOVW (SI)(R12*2), CX
|
||||
MOVWQZX (SI)(R12*2), CX
|
||||
MOVB CH, AL
|
||||
MOVBQZX CL, CX
|
||||
ADDQ CX, R11
|
||||
@@ -769,13 +769,13 @@ main_loop:
|
||||
|
||||
bitReader_fillFast_1_end:
|
||||
SHRXQ DI, R10, CX
|
||||
MOVW (SI)(CX*2), CX
|
||||
MOVWQZX (SI)(CX*2), CX
|
||||
MOVB CH, AL
|
||||
MOVBQZX CL, CX
|
||||
ADDQ CX, R11
|
||||
SHLXQ CX, R10, R10
|
||||
SHRXQ DI, R10, CX
|
||||
MOVW (SI)(CX*2), CX
|
||||
MOVWQZX (SI)(CX*2), CX
|
||||
MOVB CH, AH
|
||||
MOVBQZX CL, CX
|
||||
ADDQ CX, R11
|
||||
@@ -791,13 +791,13 @@ bitReader_fillFast_1_end:
|
||||
|
||||
bitReader_fillFast_2_end:
|
||||
SHRXQ DI, R10, CX
|
||||
MOVW (SI)(CX*2), CX
|
||||
MOVWQZX (SI)(CX*2), CX
|
||||
MOVB CH, AH
|
||||
MOVBQZX CL, CX
|
||||
ADDQ CX, R11
|
||||
SHLXQ CX, R10, R10
|
||||
SHRXQ DI, R10, CX
|
||||
MOVW (SI)(CX*2), CX
|
||||
MOVWQZX (SI)(CX*2), CX
|
||||
MOVB CH, AL
|
||||
MOVBQZX CL, CX
|
||||
ADDQ CX, R11
|
||||
|
||||
+97
-152
@@ -1,7 +1,7 @@
|
||||
// Code generated by command: go run gen.go -out ../decompress.s -arch amd64,arm64 -pkg=huff0. DO NOT EDIT.
|
||||
// EXPERIMENTAL arm64 output lowered from an amd64 avo program.
|
||||
|
||||
//go:build arm64 && !appengine && !noasm && gc
|
||||
//go:build arm64 && (!appengine && !noasm && gc)
|
||||
|
||||
// func decompress4x_main_loop_amd64(ctx *decompress4xContext)
|
||||
TEXT ·decompress4x_main_loop_arm64(SB), $0-8
|
||||
@@ -32,8 +32,7 @@ main_loop:
|
||||
MOVD (R9), R12
|
||||
|
||||
// b.value |= uint64(low) << (b.bitsRead & 63)
|
||||
ADD R12, R0, R15
|
||||
MOVWU (R15), R12
|
||||
MOVWU (R0)(R12), R12
|
||||
MOVD R11, R1
|
||||
LSL R1, R12, R12
|
||||
MOVD R0, 24(R9)
|
||||
@@ -51,12 +50,10 @@ skip_fill0:
|
||||
LSR R1, R12, R12
|
||||
|
||||
// v0 := table[val0&mask]
|
||||
ADD R12<<1, R8, R15
|
||||
MOVHU (R15), R1
|
||||
MOVHU (R8)(R12<<1), R1
|
||||
|
||||
// br0.advance(uint8(v0.entry)
|
||||
UBFX $8, R1, $8, R16
|
||||
BFI $0, R16, $8, R0
|
||||
UBFX $8, R1, $8, R0
|
||||
LSL R1, R10, R10
|
||||
ADD R1, R11, R15
|
||||
BFI $0, R15, $8, R11
|
||||
@@ -67,8 +64,7 @@ skip_fill0:
|
||||
LSR R1, R12, R12
|
||||
|
||||
// v1 := table[val1&mask]
|
||||
ADD R12<<1, R8, R15
|
||||
MOVHU (R15), R1
|
||||
MOVHU (R8)(R12<<1), R1
|
||||
|
||||
// br0.advance(uint8(v1.entry))
|
||||
UBFX $8, R1, $8, R16
|
||||
@@ -97,8 +93,7 @@ skip_fill0:
|
||||
MOVD 48(R9), R12
|
||||
|
||||
// b.value |= uint64(low) << (b.bitsRead & 63)
|
||||
ADD R12, R0, R15
|
||||
MOVWU (R15), R12
|
||||
MOVWU (R0)(R12), R12
|
||||
MOVD R11, R1
|
||||
LSL R1, R12, R12
|
||||
MOVD R0, 72(R9)
|
||||
@@ -116,12 +111,10 @@ skip_fill1:
|
||||
LSR R1, R12, R12
|
||||
|
||||
// v0 := table[val0&mask]
|
||||
ADD R12<<1, R8, R15
|
||||
MOVHU (R15), R1
|
||||
MOVHU (R8)(R12<<1), R1
|
||||
|
||||
// br1.advance(uint8(v0.entry)
|
||||
UBFX $8, R1, $8, R16
|
||||
BFI $0, R16, $8, R0
|
||||
UBFX $8, R1, $8, R0
|
||||
LSL R1, R10, R10
|
||||
ADD R1, R11, R15
|
||||
BFI $0, R15, $8, R11
|
||||
@@ -132,8 +125,7 @@ skip_fill1:
|
||||
LSR R1, R12, R12
|
||||
|
||||
// v1 := table[val1&mask]
|
||||
ADD R12<<1, R8, R15
|
||||
MOVHU (R15), R1
|
||||
MOVHU (R8)(R12<<1), R1
|
||||
|
||||
// br1.advance(uint8(v1.entry))
|
||||
UBFX $8, R1, $8, R16
|
||||
@@ -145,8 +137,7 @@ skip_fill1:
|
||||
// these two writes get coalesced
|
||||
// out[id * dstEvery + 0] = uint8(v0.entry >> 8)
|
||||
// out[id * dstEvery + 1] = uint8(v1.entry >> 8)
|
||||
ADD R7, R3, R15
|
||||
MOVH R0, (R15)
|
||||
MOVH R0, (R3)(R7)
|
||||
|
||||
// update the bitreader structure
|
||||
MOVD R10, 80(R9)
|
||||
@@ -163,8 +154,7 @@ skip_fill1:
|
||||
MOVD 96(R9), R12
|
||||
|
||||
// b.value |= uint64(low) << (b.bitsRead & 63)
|
||||
ADD R12, R0, R15
|
||||
MOVWU (R15), R12
|
||||
MOVWU (R0)(R12), R12
|
||||
MOVD R11, R1
|
||||
LSL R1, R12, R12
|
||||
MOVD R0, 120(R9)
|
||||
@@ -182,12 +172,10 @@ skip_fill2:
|
||||
LSR R1, R12, R12
|
||||
|
||||
// v0 := table[val0&mask]
|
||||
ADD R12<<1, R8, R15
|
||||
MOVHU (R15), R1
|
||||
MOVHU (R8)(R12<<1), R1
|
||||
|
||||
// br2.advance(uint8(v0.entry)
|
||||
UBFX $8, R1, $8, R16
|
||||
BFI $0, R16, $8, R0
|
||||
UBFX $8, R1, $8, R0
|
||||
LSL R1, R10, R10
|
||||
ADD R1, R11, R15
|
||||
BFI $0, R15, $8, R11
|
||||
@@ -198,8 +186,7 @@ skip_fill2:
|
||||
LSR R1, R12, R12
|
||||
|
||||
// v1 := table[val1&mask]
|
||||
ADD R12<<1, R8, R15
|
||||
MOVHU (R15), R1
|
||||
MOVHU (R8)(R12<<1), R1
|
||||
|
||||
// br2.advance(uint8(v1.entry))
|
||||
UBFX $8, R1, $8, R16
|
||||
@@ -211,8 +198,7 @@ skip_fill2:
|
||||
// these two writes get coalesced
|
||||
// out[id * dstEvery + 0] = uint8(v0.entry >> 8)
|
||||
// out[id * dstEvery + 1] = uint8(v1.entry >> 8)
|
||||
ADD R7<<1, R3, R15
|
||||
MOVH R0, (R15)
|
||||
MOVH R0, (R3)(R7<<1)
|
||||
|
||||
// update the bitreader structure
|
||||
MOVD R10, 128(R9)
|
||||
@@ -229,8 +215,7 @@ skip_fill2:
|
||||
MOVD 144(R9), R12
|
||||
|
||||
// b.value |= uint64(low) << (b.bitsRead & 63)
|
||||
ADD R12, R0, R15
|
||||
MOVWU (R15), R12
|
||||
MOVWU (R0)(R12), R12
|
||||
MOVD R11, R1
|
||||
LSL R1, R12, R12
|
||||
MOVD R0, 168(R9)
|
||||
@@ -248,12 +233,10 @@ skip_fill3:
|
||||
LSR R1, R12, R12
|
||||
|
||||
// v0 := table[val0&mask]
|
||||
ADD R12<<1, R8, R15
|
||||
MOVHU (R15), R1
|
||||
MOVHU (R8)(R12<<1), R1
|
||||
|
||||
// br3.advance(uint8(v0.entry)
|
||||
UBFX $8, R1, $8, R16
|
||||
BFI $0, R16, $8, R0
|
||||
UBFX $8, R1, $8, R0
|
||||
LSL R1, R10, R10
|
||||
ADD R1, R11, R15
|
||||
BFI $0, R15, $8, R11
|
||||
@@ -264,8 +247,7 @@ skip_fill3:
|
||||
LSR R1, R12, R12
|
||||
|
||||
// v1 := table[val1&mask]
|
||||
ADD R12<<1, R8, R15
|
||||
MOVHU (R15), R1
|
||||
MOVHU (R8)(R12<<1), R1
|
||||
|
||||
// br3.advance(uint8(v1.entry))
|
||||
UBFX $8, R1, $8, R16
|
||||
@@ -278,16 +260,13 @@ skip_fill3:
|
||||
// out[id * dstEvery + 0] = uint8(v0.entry >> 8)
|
||||
// out[id * dstEvery + 1] = uint8(v1.entry >> 8)
|
||||
ADD R7<<1, R7, R1
|
||||
ADD R1, R3, R15
|
||||
MOVH R0, (R15)
|
||||
MOVH R0, (R3)(R1)
|
||||
|
||||
// update the bitreader structure
|
||||
MOVD R10, 176(R9)
|
||||
MOVB R11, 184(R9)
|
||||
ADD $0x02, R3, R3
|
||||
AND $0xff, R2, R15
|
||||
AND $0xff, R2, R16
|
||||
TST R16, R15
|
||||
TST $0xff, R2
|
||||
BEQ main_loop
|
||||
MOVD ctx+0(FP), R0
|
||||
MOVD 16(R0), R16
|
||||
@@ -299,13 +278,13 @@ skip_fill3:
|
||||
// func decompress4x_8b_main_loop_amd64(ctx *decompress4xContext)
|
||||
TEXT ·decompress4x_8b_main_loop_arm64(SB), $0-8
|
||||
// Preload values
|
||||
MOVD ctx+0(FP), R1
|
||||
MOVBU 8(R1), R6
|
||||
MOVD 16(R1), R3
|
||||
MOVD 48(R1), R5
|
||||
MOVD 24(R1), R7
|
||||
MOVD 32(R1), R8
|
||||
MOVD (R1), R9
|
||||
MOVD ctx+0(FP), R0
|
||||
MOVBU 8(R0), R6
|
||||
MOVD 16(R0), R3
|
||||
MOVD 48(R0), R5
|
||||
MOVD 24(R0), R7
|
||||
MOVD 32(R0), R8
|
||||
MOVD (R0), R9
|
||||
|
||||
// Main loop
|
||||
main_loop:
|
||||
@@ -319,37 +298,34 @@ main_loop:
|
||||
MOVBU 40(R9), R11
|
||||
CMP $0x20, R11
|
||||
BLS skip_fill0
|
||||
MOVD 24(R9), R12
|
||||
MOVD 24(R9), R0
|
||||
SUB $0x20, R11, R11
|
||||
SUB $0x04, R12, R12
|
||||
MOVD (R9), R13
|
||||
SUB $0x04, R0, R0
|
||||
MOVD (R9), R12
|
||||
|
||||
// b.value |= uint64(low) << (b.bitsRead & 63)
|
||||
ADD R13, R12, R15
|
||||
MOVWU (R15), R13
|
||||
MOVWU (R0)(R12), R12
|
||||
MOVD R11, R1
|
||||
LSL R1, R13, R13
|
||||
MOVD R12, 24(R9)
|
||||
ORR R13, R10, R10
|
||||
LSL R1, R12, R12
|
||||
MOVD R0, 24(R9)
|
||||
ORR R12, R10, R10
|
||||
|
||||
// exhausted += (br0.off < 4)
|
||||
CMP $0x04, R12
|
||||
CMP $0x04, R0
|
||||
CSINC HS, R2, R2, R16
|
||||
BFI $0, R16, $8, R2
|
||||
|
||||
skip_fill0:
|
||||
// val0 := br0.peekTopBits(peekBits)
|
||||
MOVD R10, R12
|
||||
MOVD R10, R0
|
||||
MOVD R6, R1
|
||||
LSR R1, R12, R12
|
||||
LSR R1, R0, R0
|
||||
|
||||
// v0 := table[val0&mask]
|
||||
ADD R12<<1, R8, R15
|
||||
MOVHU (R15), R1
|
||||
MOVHU (R8)(R0<<1), R1
|
||||
|
||||
// br0.advance(uint8(v0.entry)
|
||||
UBFX $8, R1, $8, R16
|
||||
BFI $0, R16, $8, R0
|
||||
UBFX $8, R1, $8, R0
|
||||
LSL R1, R10, R10
|
||||
ADD R1, R11, R15
|
||||
BFI $0, R15, $8, R11
|
||||
@@ -360,8 +336,7 @@ skip_fill0:
|
||||
LSR R1, R12, R12
|
||||
|
||||
// v1 := table[val0&mask]
|
||||
ADD R12<<1, R8, R15
|
||||
MOVHU (R15), R1
|
||||
MOVHU (R8)(R12<<1), R1
|
||||
|
||||
// br0.advance(uint8(v1.entry)
|
||||
UBFX $8, R1, $8, R16
|
||||
@@ -377,8 +352,7 @@ skip_fill0:
|
||||
LSR R1, R12, R12
|
||||
|
||||
// v2 := table[val0&mask]
|
||||
ADD R12<<1, R8, R15
|
||||
MOVHU (R15), R1
|
||||
MOVHU (R8)(R12<<1), R1
|
||||
|
||||
// br0.advance(uint8(v2.entry)
|
||||
UBFX $8, R1, $8, R16
|
||||
@@ -393,8 +367,7 @@ skip_fill0:
|
||||
LSR R1, R12, R12
|
||||
|
||||
// v3 := table[val0&mask]
|
||||
ADD R12<<1, R8, R15
|
||||
MOVHU (R15), R1
|
||||
MOVHU (R8)(R12<<1), R1
|
||||
|
||||
// br0.advance(uint8(v3.entry)
|
||||
UBFX $8, R1, $8, R16
|
||||
@@ -420,37 +393,34 @@ skip_fill0:
|
||||
MOVBU 88(R9), R11
|
||||
CMP $0x20, R11
|
||||
BLS skip_fill1
|
||||
MOVD 72(R9), R12
|
||||
MOVD 72(R9), R0
|
||||
SUB $0x20, R11, R11
|
||||
SUB $0x04, R12, R12
|
||||
MOVD 48(R9), R13
|
||||
SUB $0x04, R0, R0
|
||||
MOVD 48(R9), R12
|
||||
|
||||
// b.value |= uint64(low) << (b.bitsRead & 63)
|
||||
ADD R13, R12, R15
|
||||
MOVWU (R15), R13
|
||||
MOVWU (R0)(R12), R12
|
||||
MOVD R11, R1
|
||||
LSL R1, R13, R13
|
||||
MOVD R12, 72(R9)
|
||||
ORR R13, R10, R10
|
||||
LSL R1, R12, R12
|
||||
MOVD R0, 72(R9)
|
||||
ORR R12, R10, R10
|
||||
|
||||
// exhausted += (br1.off < 4)
|
||||
CMP $0x04, R12
|
||||
CMP $0x04, R0
|
||||
CSINC HS, R2, R2, R16
|
||||
BFI $0, R16, $8, R2
|
||||
|
||||
skip_fill1:
|
||||
// val0 := br1.peekTopBits(peekBits)
|
||||
MOVD R10, R12
|
||||
MOVD R10, R0
|
||||
MOVD R6, R1
|
||||
LSR R1, R12, R12
|
||||
LSR R1, R0, R0
|
||||
|
||||
// v0 := table[val0&mask]
|
||||
ADD R12<<1, R8, R15
|
||||
MOVHU (R15), R1
|
||||
MOVHU (R8)(R0<<1), R1
|
||||
|
||||
// br1.advance(uint8(v0.entry)
|
||||
UBFX $8, R1, $8, R16
|
||||
BFI $0, R16, $8, R0
|
||||
UBFX $8, R1, $8, R0
|
||||
LSL R1, R10, R10
|
||||
ADD R1, R11, R15
|
||||
BFI $0, R15, $8, R11
|
||||
@@ -461,8 +431,7 @@ skip_fill1:
|
||||
LSR R1, R12, R12
|
||||
|
||||
// v1 := table[val0&mask]
|
||||
ADD R12<<1, R8, R15
|
||||
MOVHU (R15), R1
|
||||
MOVHU (R8)(R12<<1), R1
|
||||
|
||||
// br1.advance(uint8(v1.entry)
|
||||
UBFX $8, R1, $8, R16
|
||||
@@ -478,8 +447,7 @@ skip_fill1:
|
||||
LSR R1, R12, R12
|
||||
|
||||
// v2 := table[val0&mask]
|
||||
ADD R12<<1, R8, R15
|
||||
MOVHU (R15), R1
|
||||
MOVHU (R8)(R12<<1), R1
|
||||
|
||||
// br1.advance(uint8(v2.entry)
|
||||
UBFX $8, R1, $8, R16
|
||||
@@ -494,8 +462,7 @@ skip_fill1:
|
||||
LSR R1, R12, R12
|
||||
|
||||
// v3 := table[val0&mask]
|
||||
ADD R12<<1, R8, R15
|
||||
MOVHU (R15), R1
|
||||
MOVHU (R8)(R12<<1), R1
|
||||
|
||||
// br1.advance(uint8(v3.entry)
|
||||
UBFX $8, R1, $8, R16
|
||||
@@ -510,8 +477,7 @@ skip_fill1:
|
||||
// out[id * dstEvery + 1] = uint8(v1.entry >> 8)
|
||||
// out[id * dstEvery + 3] = uint8(v2.entry >> 8)
|
||||
// out[id * dstEvery + 4] = uint8(v3.entry >> 8)
|
||||
ADD R7, R3, R15
|
||||
MOVW R0, (R15)
|
||||
MOVW R0, (R3)(R7)
|
||||
|
||||
// update the bitreader structure
|
||||
MOVD R10, 80(R9)
|
||||
@@ -522,37 +488,34 @@ skip_fill1:
|
||||
MOVBU 136(R9), R11
|
||||
CMP $0x20, R11
|
||||
BLS skip_fill2
|
||||
MOVD 120(R9), R12
|
||||
MOVD 120(R9), R0
|
||||
SUB $0x20, R11, R11
|
||||
SUB $0x04, R12, R12
|
||||
MOVD 96(R9), R13
|
||||
SUB $0x04, R0, R0
|
||||
MOVD 96(R9), R12
|
||||
|
||||
// b.value |= uint64(low) << (b.bitsRead & 63)
|
||||
ADD R13, R12, R15
|
||||
MOVWU (R15), R13
|
||||
MOVWU (R0)(R12), R12
|
||||
MOVD R11, R1
|
||||
LSL R1, R13, R13
|
||||
MOVD R12, 120(R9)
|
||||
ORR R13, R10, R10
|
||||
LSL R1, R12, R12
|
||||
MOVD R0, 120(R9)
|
||||
ORR R12, R10, R10
|
||||
|
||||
// exhausted += (br2.off < 4)
|
||||
CMP $0x04, R12
|
||||
CMP $0x04, R0
|
||||
CSINC HS, R2, R2, R16
|
||||
BFI $0, R16, $8, R2
|
||||
|
||||
skip_fill2:
|
||||
// val0 := br2.peekTopBits(peekBits)
|
||||
MOVD R10, R12
|
||||
MOVD R10, R0
|
||||
MOVD R6, R1
|
||||
LSR R1, R12, R12
|
||||
LSR R1, R0, R0
|
||||
|
||||
// v0 := table[val0&mask]
|
||||
ADD R12<<1, R8, R15
|
||||
MOVHU (R15), R1
|
||||
MOVHU (R8)(R0<<1), R1
|
||||
|
||||
// br2.advance(uint8(v0.entry)
|
||||
UBFX $8, R1, $8, R16
|
||||
BFI $0, R16, $8, R0
|
||||
UBFX $8, R1, $8, R0
|
||||
LSL R1, R10, R10
|
||||
ADD R1, R11, R15
|
||||
BFI $0, R15, $8, R11
|
||||
@@ -563,8 +526,7 @@ skip_fill2:
|
||||
LSR R1, R12, R12
|
||||
|
||||
// v1 := table[val0&mask]
|
||||
ADD R12<<1, R8, R15
|
||||
MOVHU (R15), R1
|
||||
MOVHU (R8)(R12<<1), R1
|
||||
|
||||
// br2.advance(uint8(v1.entry)
|
||||
UBFX $8, R1, $8, R16
|
||||
@@ -580,8 +542,7 @@ skip_fill2:
|
||||
LSR R1, R12, R12
|
||||
|
||||
// v2 := table[val0&mask]
|
||||
ADD R12<<1, R8, R15
|
||||
MOVHU (R15), R1
|
||||
MOVHU (R8)(R12<<1), R1
|
||||
|
||||
// br2.advance(uint8(v2.entry)
|
||||
UBFX $8, R1, $8, R16
|
||||
@@ -596,8 +557,7 @@ skip_fill2:
|
||||
LSR R1, R12, R12
|
||||
|
||||
// v3 := table[val0&mask]
|
||||
ADD R12<<1, R8, R15
|
||||
MOVHU (R15), R1
|
||||
MOVHU (R8)(R12<<1), R1
|
||||
|
||||
// br2.advance(uint8(v3.entry)
|
||||
UBFX $8, R1, $8, R16
|
||||
@@ -624,37 +584,34 @@ skip_fill2:
|
||||
MOVBU 184(R9), R11
|
||||
CMP $0x20, R11
|
||||
BLS skip_fill3
|
||||
MOVD 168(R9), R12
|
||||
MOVD 168(R9), R0
|
||||
SUB $0x20, R11, R11
|
||||
SUB $0x04, R12, R12
|
||||
MOVD 144(R9), R13
|
||||
SUB $0x04, R0, R0
|
||||
MOVD 144(R9), R12
|
||||
|
||||
// b.value |= uint64(low) << (b.bitsRead & 63)
|
||||
ADD R13, R12, R15
|
||||
MOVWU (R15), R13
|
||||
MOVWU (R0)(R12), R12
|
||||
MOVD R11, R1
|
||||
LSL R1, R13, R13
|
||||
MOVD R12, 168(R9)
|
||||
ORR R13, R10, R10
|
||||
LSL R1, R12, R12
|
||||
MOVD R0, 168(R9)
|
||||
ORR R12, R10, R10
|
||||
|
||||
// exhausted += (br3.off < 4)
|
||||
CMP $0x04, R12
|
||||
CMP $0x04, R0
|
||||
CSINC HS, R2, R2, R16
|
||||
BFI $0, R16, $8, R2
|
||||
|
||||
skip_fill3:
|
||||
// val0 := br3.peekTopBits(peekBits)
|
||||
MOVD R10, R12
|
||||
MOVD R10, R0
|
||||
MOVD R6, R1
|
||||
LSR R1, R12, R12
|
||||
LSR R1, R0, R0
|
||||
|
||||
// v0 := table[val0&mask]
|
||||
ADD R12<<1, R8, R15
|
||||
MOVHU (R15), R1
|
||||
MOVHU (R8)(R0<<1), R1
|
||||
|
||||
// br3.advance(uint8(v0.entry)
|
||||
UBFX $8, R1, $8, R16
|
||||
BFI $0, R16, $8, R0
|
||||
UBFX $8, R1, $8, R0
|
||||
LSL R1, R10, R10
|
||||
ADD R1, R11, R15
|
||||
BFI $0, R15, $8, R11
|
||||
@@ -665,8 +622,7 @@ skip_fill3:
|
||||
LSR R1, R12, R12
|
||||
|
||||
// v1 := table[val0&mask]
|
||||
ADD R12<<1, R8, R15
|
||||
MOVHU (R15), R1
|
||||
MOVHU (R8)(R12<<1), R1
|
||||
|
||||
// br3.advance(uint8(v1.entry)
|
||||
UBFX $8, R1, $8, R16
|
||||
@@ -682,8 +638,7 @@ skip_fill3:
|
||||
LSR R1, R12, R12
|
||||
|
||||
// v2 := table[val0&mask]
|
||||
ADD R12<<1, R8, R15
|
||||
MOVHU (R15), R1
|
||||
MOVHU (R8)(R12<<1), R1
|
||||
|
||||
// br3.advance(uint8(v2.entry)
|
||||
UBFX $8, R1, $8, R16
|
||||
@@ -698,8 +653,7 @@ skip_fill3:
|
||||
LSR R1, R12, R12
|
||||
|
||||
// v3 := table[val0&mask]
|
||||
ADD R12<<1, R8, R15
|
||||
MOVHU (R15), R1
|
||||
MOVHU (R8)(R12<<1), R1
|
||||
|
||||
// br3.advance(uint8(v3.entry)
|
||||
UBFX $8, R1, $8, R16
|
||||
@@ -715,16 +669,13 @@ skip_fill3:
|
||||
// out[id * dstEvery + 3] = uint8(v2.entry >> 8)
|
||||
// out[id * dstEvery + 4] = uint8(v3.entry >> 8)
|
||||
ADD R7<<1, R7, R1
|
||||
ADD R1, R3, R15
|
||||
MOVW R0, (R15)
|
||||
MOVW R0, (R3)(R1)
|
||||
|
||||
// update the bitreader structure
|
||||
MOVD R10, 176(R9)
|
||||
MOVB R11, 184(R9)
|
||||
ADD $0x04, R3, R3
|
||||
AND $0xff, R2, R15
|
||||
AND $0xff, R2, R16
|
||||
TST R16, R15
|
||||
TST $0xff, R2
|
||||
BEQ main_loop
|
||||
MOVD ctx+0(FP), R0
|
||||
MOVD 16(R0), R16
|
||||
@@ -761,8 +712,7 @@ main_loop:
|
||||
BLT bitReader_fillFast_1_end
|
||||
SUB $0x20, R10, R10
|
||||
SUB $0x04, R8, R8
|
||||
ADD R8, R7, R15
|
||||
MOVWU (R15), R11
|
||||
MOVWU (R7)(R8), R11
|
||||
MOVD R10, R1
|
||||
LSL R1, R11, R11
|
||||
ORR R11, R9, R9
|
||||
@@ -771,8 +721,7 @@ bitReader_fillFast_1_end:
|
||||
MOVD R6, R1
|
||||
MOVD R9, R11
|
||||
LSR R1, R11, R11
|
||||
ADD R11<<1, R5, R15
|
||||
MOVHU (R15), R1
|
||||
MOVHU (R5)(R11<<1), R1
|
||||
UBFX $8, R1, $8, R16
|
||||
BFI $0, R16, $8, R0
|
||||
MOVBU R1, R1
|
||||
@@ -781,8 +730,7 @@ bitReader_fillFast_1_end:
|
||||
MOVD R6, R1
|
||||
MOVD R9, R11
|
||||
LSR R1, R11, R11
|
||||
ADD R11<<1, R5, R15
|
||||
MOVHU (R15), R1
|
||||
MOVHU (R5)(R11<<1), R1
|
||||
UBFX $8, R1, $8, R16
|
||||
BFI $8, R16, $8, R0
|
||||
MOVBU R1, R1
|
||||
@@ -793,8 +741,7 @@ bitReader_fillFast_1_end:
|
||||
BLT bitReader_fillFast_2_end
|
||||
SUB $0x20, R10, R10
|
||||
SUB $0x04, R8, R8
|
||||
ADD R8, R7, R15
|
||||
MOVWU (R15), R11
|
||||
MOVWU (R7)(R8), R11
|
||||
MOVD R10, R1
|
||||
LSL R1, R11, R11
|
||||
ORR R11, R9, R9
|
||||
@@ -803,8 +750,7 @@ bitReader_fillFast_2_end:
|
||||
MOVD R6, R1
|
||||
MOVD R9, R11
|
||||
LSR R1, R11, R11
|
||||
ADD R11<<1, R5, R15
|
||||
MOVHU (R15), R1
|
||||
MOVHU (R5)(R11<<1), R1
|
||||
UBFX $8, R1, $8, R16
|
||||
BFI $8, R16, $8, R0
|
||||
MOVBU R1, R1
|
||||
@@ -813,8 +759,7 @@ bitReader_fillFast_2_end:
|
||||
MOVD R6, R1
|
||||
MOVD R9, R11
|
||||
LSR R1, R11, R11
|
||||
ADD R11<<1, R5, R15
|
||||
MOVHU (R15), R1
|
||||
MOVHU (R5)(R11<<1), R1
|
||||
UBFX $8, R1, $8, R16
|
||||
BFI $0, R16, $8, R0
|
||||
MOVBU R1, R1
|
||||
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
//go:build !386
|
||||
|
||||
// Package regmask provides masks for variable shift counts.
|
||||
//
|
||||
// Go defines a shift by more than the width of the shifted value as producing
|
||||
// zero, so the compiler has to guard every variable shift against that: on
|
||||
// amd64 with a CMP and an SBB, on arm64 with a CMP and a CSEL, and so on. When
|
||||
// the count is known to be smaller than the width anyway, masking it with the
|
||||
// width minus one lets the compiler drop the guard. The mask itself costs
|
||||
// nothing on the architectures whose shift instructions already use only the
|
||||
// low bits of the count, which the compiler knows about.
|
||||
//
|
||||
// Each constant is named for the width of the value being shifted and the type
|
||||
// of the shift count, and may only be used where the count is always smaller
|
||||
// than that width:
|
||||
//
|
||||
// x := y >> (n & regmask.Shift64ByUint) // y is 64 bits, n is a uint below 64
|
||||
package regmask
|
||||
|
||||
const (
|
||||
// ShiftNByUint8 - shifting an N bit value by a uint8
|
||||
Shift8ByUint8 = 7
|
||||
Shift16ByUint8 = 15
|
||||
Shift32ByUint8 = 31
|
||||
Shift64ByUint8 = 63
|
||||
|
||||
// ShiftNByUint16 - shifting an N bit value by a uint16
|
||||
Shift8ByUint16 = Shift8ByUint8
|
||||
Shift16ByUint16 = Shift16ByUint8
|
||||
Shift32ByUint16 = Shift32ByUint8
|
||||
Shift64ByUint16 = Shift64ByUint8
|
||||
|
||||
// ShiftNByUint32 - shifting an N bit value by a uint32
|
||||
Shift8ByUint32 = Shift8ByUint8
|
||||
Shift16ByUint32 = Shift16ByUint8
|
||||
Shift32ByUint32 = Shift32ByUint8
|
||||
Shift64ByUint32 = Shift64ByUint8
|
||||
|
||||
// ShiftNByUint64 - shifting an N bit value by a uint64
|
||||
Shift8ByUint64 = Shift8ByUint8
|
||||
Shift16ByUint64 = Shift16ByUint8
|
||||
Shift32ByUint64 = Shift32ByUint8
|
||||
Shift64ByUint64 = Shift64ByUint8
|
||||
|
||||
// ShiftNByUint - shifting an N bit value by a uint
|
||||
Shift8ByUint = Shift8ByUint8
|
||||
Shift16ByUint = Shift16ByUint8
|
||||
Shift32ByUint = Shift32ByUint8
|
||||
Shift64ByUint = Shift64ByUint8
|
||||
)
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
//go:build 386
|
||||
|
||||
package regmask
|
||||
|
||||
// A 64 bit shift on 386 is synthesized from 32 bit instructions, and masking its
|
||||
// count makes the compiler emit more code rather than less, so those masks are
|
||||
// no-ops here: each is the largest value its count type can hold, which the
|
||||
// compiler folds away. Shifts of narrower values behave as elsewhere.
|
||||
const (
|
||||
// ShiftNByUint8 - shifting an N bit value by a uint8
|
||||
Shift8ByUint8 = 7
|
||||
Shift16ByUint8 = 15
|
||||
Shift32ByUint8 = 31
|
||||
Shift64ByUint8 = 0xff
|
||||
|
||||
// ShiftNByUint16 - shifting an N bit value by a uint16
|
||||
Shift8ByUint16 = Shift8ByUint8
|
||||
Shift16ByUint16 = Shift16ByUint8
|
||||
Shift32ByUint16 = Shift32ByUint8
|
||||
Shift64ByUint16 = 0xffff
|
||||
|
||||
// ShiftNByUint32 - shifting an N bit value by a uint32
|
||||
Shift8ByUint32 = Shift8ByUint8
|
||||
Shift16ByUint32 = Shift16ByUint8
|
||||
Shift32ByUint32 = Shift32ByUint8
|
||||
Shift64ByUint32 = 0xffffffff
|
||||
|
||||
// ShiftNByUint64 - shifting an N bit value by a uint64
|
||||
Shift8ByUint64 = Shift8ByUint8
|
||||
Shift16ByUint64 = Shift16ByUint8
|
||||
Shift32ByUint64 = Shift32ByUint8
|
||||
Shift64ByUint64 = 0xffffffffffffffff
|
||||
|
||||
// ShiftNByUint - shifting an N bit value by a uint
|
||||
Shift8ByUint = Shift8ByUint8
|
||||
Shift16ByUint = Shift16ByUint8
|
||||
Shift32ByUint = Shift32ByUint8
|
||||
Shift64ByUint = ^uint(0)
|
||||
)
|
||||
Generated
Vendored
+2
-2
@@ -1,4 +1,4 @@
|
||||
//go:build !appengine && !noasm && gc
|
||||
//go:build (amd64 || arm64) && !appengine && !noasm && gc
|
||||
|
||||
package s2
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"github.com/klauspost/compress/internal/race"
|
||||
)
|
||||
|
||||
const hasAmd64Asm = true
|
||||
const hasAsm = true
|
||||
|
||||
var encPools [4]sync.Pool
|
||||
|
||||
+7
-1
@@ -86,12 +86,18 @@ func encodeBlockBetterGo(dst, src []byte) (d int) {
|
||||
// We initialize repeat to 0, so we never match on first attempt
|
||||
repeat := 0
|
||||
|
||||
// Cap the adaptive skip, as encodeBetterBlockAsm and the snappy Go encoder
|
||||
// below already do. Without a cap, a long stretch with no matches lets the
|
||||
// skip grow geometrically until it strides past the start of the next
|
||||
// compressible region and loses the matches there.
|
||||
const maxSkip = 100
|
||||
|
||||
for {
|
||||
candidateL := 0
|
||||
nextS := 0
|
||||
for {
|
||||
// Next src position to check
|
||||
nextS = s + (s-nextEmit)>>7 + 1
|
||||
nextS = s + min((s-nextEmit)>>7+1, maxSkip)
|
||||
if nextS > sLimit {
|
||||
goto emitRemainder
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
//go:build !amd64 || appengine || !gc || noasm
|
||||
//go:build (!amd64 && !arm64) || appengine || !gc || noasm
|
||||
|
||||
package s2
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"math/bits"
|
||||
)
|
||||
|
||||
const hasAmd64Asm = false
|
||||
const hasAsm = false
|
||||
|
||||
// encodeBlock encodes a non-empty src to a guaranteed-large-enough dst. It
|
||||
// assumes that the varint-encoded length of the decompressed bytes has already
|
||||
|
||||
+212
-632
File diff suppressed because it is too large.
Load diff
+23562
File diff suppressed because it is too large.
Load diff
Generated
Vendored
+2
-2
@@ -1,6 +1,6 @@
|
||||
// Code generated by command: go run gen.go -out ../encodeblock_amd64.s -stubs ../encodeblock_amd64.go -pkg=s2. DO NOT EDIT.
|
||||
// Code generated by command: go run gen.go -out ../encodeblock_amd64.s -stubs ../encodeblock_asm.go -pkg=s2. DO NOT EDIT.
|
||||
|
||||
//go:build !appengine && !noasm && gc && !noasm
|
||||
//go:build (amd64 || arm64) && !appengine && !noasm && gc && !noasm
|
||||
|
||||
package s2
|
||||
|
||||
+2
-2
@@ -32,7 +32,7 @@ func (l *LZ4Converter) ConvertBlock(dst, src []byte) ([]byte, int, error) {
|
||||
|
||||
s, d := 0, len(dst)
|
||||
dst = dst[:cap(dst)]
|
||||
if !debug && hasAmd64Asm {
|
||||
if !debug && hasAsm {
|
||||
res, sz := cvtLZ4BlockAsm(dst[d:], src)
|
||||
if res < 0 {
|
||||
const (
|
||||
@@ -288,7 +288,7 @@ func (l *LZ4Converter) ConvertBlockSnappy(dst, src []byte) ([]byte, int, error)
|
||||
s, d := 0, len(dst)
|
||||
dst = dst[:cap(dst)]
|
||||
// Use assembly when possible
|
||||
if !debug && hasAmd64Asm {
|
||||
if !debug && hasAsm {
|
||||
res, sz := cvtLZ4BlockSnappyAsm(dst[d:], src)
|
||||
if res < 0 {
|
||||
const (
|
||||
|
||||
+2
-2
@@ -37,7 +37,7 @@ func (l *LZ4sConverter) ConvertBlock(dst, src []byte) ([]byte, int, error) {
|
||||
|
||||
s, d := 0, len(dst)
|
||||
dst = dst[:cap(dst)]
|
||||
if !debug && hasAmd64Asm {
|
||||
if !debug && hasAsm {
|
||||
res, sz := cvtLZ4sBlockAsm(dst[d:], src)
|
||||
if res < 0 {
|
||||
const (
|
||||
@@ -297,7 +297,7 @@ func (l *LZ4sConverter) ConvertBlockSnappy(dst, src []byte) ([]byte, int, error)
|
||||
s, d := 0, len(dst)
|
||||
dst = dst[:cap(dst)]
|
||||
// Use assembly when possible
|
||||
if !debug && hasAmd64Asm {
|
||||
if !debug && hasAsm {
|
||||
res, sz := cvtLZ4sBlockSnappyAsm(dst[d:], src)
|
||||
if res < 0 {
|
||||
const (
|
||||
|
||||
+2
-4
@@ -451,9 +451,7 @@ func (r *Reader) DecodeConcurrent(w io.Writer, concurrent int) (written int64, e
|
||||
}
|
||||
// Writer
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
wg.Go(func() {
|
||||
for toWrite := range queue {
|
||||
entry := <-toWrite
|
||||
reUse <- toWrite
|
||||
@@ -480,7 +478,7 @@ func (r *Reader) DecodeConcurrent(w io.Writer, concurrent int) (written int64, e
|
||||
}
|
||||
aWritten += int64(n)
|
||||
}
|
||||
}()
|
||||
})
|
||||
|
||||
defer func() {
|
||||
if r.err != nil {
|
||||
|
||||
+2
-4
@@ -139,11 +139,9 @@ func (w *Writer) Reset(writer io.Writer) {
|
||||
|
||||
toWrite := make(chan chan result, w.concurrency)
|
||||
w.output = toWrite
|
||||
w.writerWg.Add(1)
|
||||
|
||||
// Start a writer goroutine that will write all output in order.
|
||||
go func() {
|
||||
defer w.writerWg.Done()
|
||||
w.writerWg.Go(func() {
|
||||
|
||||
// Get a queued write.
|
||||
for write := range toWrite {
|
||||
@@ -175,7 +173,7 @@ func (w *Writer) Reset(writer io.Writer) {
|
||||
// This can be used for synchronizing flushes.
|
||||
close(write)
|
||||
}
|
||||
}()
|
||||
})
|
||||
}
|
||||
|
||||
// Write satisfies the io.Writer interface.
|
||||
|
||||
+9
-16
@@ -1,7 +1,7 @@
|
||||
// Code generated by command: go run gen_fse.go -out ../fse_decoder.s -arch amd64,arm64 -pkg=zstd. DO NOT EDIT.
|
||||
// EXPERIMENTAL arm64 output lowered from an amd64 avo program.
|
||||
|
||||
//go:build arm64 && !appengine && !noasm && gc && !noasm
|
||||
//go:build arm64 && (!appengine && !noasm && gc && !noasm)
|
||||
|
||||
// func buildDtable_asm(s *fseDecoder, ctx *buildDtableAsmContext) int
|
||||
TEXT ·buildDtable_asm(SB), $0-24
|
||||
@@ -26,11 +26,10 @@ TEXT ·buildDtable_asm(SB), $0-24
|
||||
JMP init_main_loop_condition
|
||||
|
||||
init_main_loop:
|
||||
ADD R8<<1, R1, R15
|
||||
MOVH (R15), R9
|
||||
AND $0xffff, R9, R15
|
||||
MOVH (R1)(R8<<1), R9
|
||||
MOVD $-1, R16
|
||||
AND $0xffff, R16, R16
|
||||
AND $0xffff, R9, R15
|
||||
CMP R16, R15
|
||||
BNE do_not_update_high_threshold
|
||||
ADD R7<<3, R5, R15
|
||||
@@ -39,8 +38,7 @@ init_main_loop:
|
||||
MOVD $0x0000000000000001, R9
|
||||
|
||||
do_not_update_high_threshold:
|
||||
ADD R8<<1, R3, R15
|
||||
MOVH R9, (R15)
|
||||
MOVH R9, (R3)(R8<<1)
|
||||
ADD $1, R8, R8
|
||||
|
||||
init_main_loop_condition:
|
||||
@@ -64,8 +62,7 @@ init_main_loop_condition:
|
||||
|
||||
spread_main_loop:
|
||||
MOVD $0, R12
|
||||
ADD R11<<1, R1, R15
|
||||
MOVH (R15), R13
|
||||
MOVH (R1)(R11<<1), R13
|
||||
JMP spread_inner_loop_condition
|
||||
|
||||
spread_inner_loop:
|
||||
@@ -102,11 +99,9 @@ spread_check_ok:
|
||||
build_table_main_table:
|
||||
ADD R6<<3, R5, R15
|
||||
MOVBU 1(R15), R1
|
||||
ADD R1<<1, R3, R15
|
||||
MOVHU (R15), R7
|
||||
MOVHU (R3)(R1<<1), R7
|
||||
ADD $1, R7, R8
|
||||
ADD R1<<1, R3, R15
|
||||
MOVH R8, (R15)
|
||||
MOVH R8, (R3)(R1<<1)
|
||||
MOVD R7, R8
|
||||
CLZ R8, R16
|
||||
MOVD $63, R8
|
||||
@@ -129,12 +124,10 @@ build_table_main_table:
|
||||
RET
|
||||
|
||||
build_table_check1_ok:
|
||||
AND $0xff, R1, R15
|
||||
AND $0xff, R1, R16
|
||||
TST R16, R15
|
||||
TST $0xff, R1
|
||||
BNE build_table_check2_ok
|
||||
AND $0xffff, R7, R15
|
||||
AND $0xffff, R6, R16
|
||||
AND $0xffff, R7, R15
|
||||
CMP R16, R15
|
||||
BNE build_table_check2_ok
|
||||
MOVD ctx+8(FP), R0
|
||||
|
||||
+12
@@ -52,6 +52,11 @@ func (d *Digest) Reset() {
|
||||
d.n = 0
|
||||
}
|
||||
|
||||
// maxAsmSize bounds the input handed to a single writeBlocks call. Assembly is
|
||||
// never preemptible, so an unbounded call holds every P in stop-the-world for
|
||||
// its duration. Whole 32-byte blocks, so Write can feed it in pieces.
|
||||
const maxAsmSize = 128 << 10 // 4096 whole 32-byte blocks
|
||||
|
||||
// Size always returns 8 bytes.
|
||||
func (d *Digest) Size() int { return 8 }
|
||||
|
||||
@@ -83,6 +88,13 @@ func (d *Digest) Write(b []byte) (n int, err error) {
|
||||
d.n = 0
|
||||
}
|
||||
|
||||
for len(b) >= maxAsmSize {
|
||||
// Assembly is not preemptible, so hashing a large buffer in one call
|
||||
// blocks every stop-the-world for the whole call. Feed it in chunks.
|
||||
writeBlocks(d, b[:maxAsmSize])
|
||||
b = b[maxAsmSize:]
|
||||
}
|
||||
|
||||
if len(b) >= 32 {
|
||||
// One or more full blocks left.
|
||||
nw := writeBlocks(d, b)
|
||||
|
||||
+5
-1
@@ -175,7 +175,11 @@ finalize:
|
||||
RET
|
||||
|
||||
// func writeBlocks(d *Digest, b []byte) int
|
||||
TEXT ·writeBlocks(SB), NOSPLIT|NOFRAME, $0-40
|
||||
//
|
||||
// Deliberately not NOSPLIT: the stack check is the preemption point that lets a
|
||||
// stop-the-world proceed between chunks. The frame must be >= abi.StackSmall
|
||||
// (128), or the assembler marks this leaf NOSPLIT anyway and drops that check.
|
||||
TEXT ·writeBlocks(SB), $128-40
|
||||
// Load fixed primes needed for round.
|
||||
MOVQ ·primes+0(SB), prime1
|
||||
MOVQ ·primes+8(SB), prime2
|
||||
|
||||
+5
-1
@@ -163,7 +163,11 @@ finalize:
|
||||
RET
|
||||
|
||||
// func writeBlocks(s *Digest, b []byte) int
|
||||
TEXT ·writeBlocks(SB), NOSPLIT|NOFRAME, $0-40
|
||||
//
|
||||
// Deliberately not NOSPLIT: the stack check is the preemption point that lets a
|
||||
// stop-the-world proceed between chunks. The frame must be >= abi.StackSmall
|
||||
// (128), or the assembler marks this leaf NOSPLIT anyway and drops that check.
|
||||
TEXT ·writeBlocks(SB), $128-40
|
||||
LDP ·primes+0(SB), (prime1, prime2)
|
||||
|
||||
// Load state. Assume v[1-4] are stored contiguously.
|
||||
|
||||
+366
-366
File diff suppressed because it is too large.
Load diff
+271
-335
@@ -1,7 +1,7 @@
|
||||
// Code generated by command: go run gen.go -out ../seqdec.s -arch amd64,arm64 -pkg=zstd. DO NOT EDIT.
|
||||
// EXPERIMENTAL arm64 output lowered from an amd64 avo program.
|
||||
|
||||
//go:build arm64 && !appengine && !noasm && gc && !noasm
|
||||
//go:build arm64 && (!appengine && !noasm && gc && !noasm)
|
||||
|
||||
// func sequenceDecs_decode_amd64(s *sequenceDecs, br *bitReader, ctx *decodeAsmContext) int
|
||||
// Requires: CMOV
|
||||
@@ -60,8 +60,7 @@ sequenceDecs_decode_amd64_fill_end:
|
||||
MOVD R3, R1
|
||||
MOVD R2, R14
|
||||
LSL R1, R14, R14
|
||||
UBFX $8, R0, $8, R16
|
||||
BFI $0, R16, $8, R1
|
||||
UBFX $8, R0, $8, R1
|
||||
LSR $0x20, R0, R0
|
||||
TST R1, R1
|
||||
BEQ sequenceDecs_decode_amd64_of_update_zero
|
||||
@@ -82,8 +81,7 @@ sequenceDecs_decode_amd64_of_update_zero:
|
||||
MOVD R3, R1
|
||||
MOVD R2, R14
|
||||
LSL R1, R14, R14
|
||||
UBFX $8, R0, $8, R16
|
||||
BFI $0, R16, $8, R1
|
||||
UBFX $8, R0, $8, R1
|
||||
LSR $0x20, R0, R0
|
||||
TST R1, R1
|
||||
BEQ sequenceDecs_decode_amd64_ml_update_zero
|
||||
@@ -133,8 +131,7 @@ sequenceDecs_decode_amd64_fill_2_end:
|
||||
MOVD R3, R1
|
||||
MOVD R2, R14
|
||||
LSL R1, R14, R14
|
||||
UBFX $8, R0, $8, R16
|
||||
BFI $0, R16, $8, R1
|
||||
UBFX $8, R0, $8, R1
|
||||
LSR $0x20, R0, R0
|
||||
TST R1, R1
|
||||
BEQ sequenceDecs_decode_amd64_ll_update_zero
|
||||
@@ -151,14 +148,12 @@ sequenceDecs_decode_amd64_ll_update_zero:
|
||||
MOVD R0, (R9)
|
||||
|
||||
// Fill bitreader for state updates
|
||||
MOVD R13, 8(RSP)
|
||||
MOVD R8, R0
|
||||
LSR $0x08, R0, R0
|
||||
MOVBU R0, R0
|
||||
MOVD ctx+16(FP), R1
|
||||
MOVD 96(R1), R16
|
||||
CMP $0x00, R16
|
||||
BEQ sequenceDecs_decode_amd64_skip_update
|
||||
MOVD R13, 8(RSP)
|
||||
UBFX $8, R8, $8, R0
|
||||
MOVD ctx+16(FP), R1
|
||||
MOVD 96(R1), R16
|
||||
CMP $0x00, R16
|
||||
BEQ sequenceDecs_decode_amd64_skip_update
|
||||
|
||||
// Update Literal Length State
|
||||
MOVBU R6, R13
|
||||
@@ -169,7 +164,7 @@ sequenceDecs_decode_amd64_ll_update_zero:
|
||||
NEG R1, R16
|
||||
ROR R16, R14, R14
|
||||
MOVD $0x00000001, R4
|
||||
BFI $0, R13, $8, R1
|
||||
MOVBU R13, R1
|
||||
LSLW R1, R4, R4
|
||||
SUBW $1, R4, R4
|
||||
AND R4, R14, R14
|
||||
@@ -178,8 +173,7 @@ sequenceDecs_decode_amd64_ll_update_zero:
|
||||
// Load ctx.llTable
|
||||
MOVD ctx+16(FP), R1
|
||||
MOVD (R1), R1
|
||||
ADD R6<<3, R1, R15
|
||||
MOVD (R15), R6
|
||||
MOVD (R1)(R6<<3), R6
|
||||
|
||||
// Update Match Length State
|
||||
MOVBU R7, R13
|
||||
@@ -190,7 +184,7 @@ sequenceDecs_decode_amd64_ll_update_zero:
|
||||
NEG R1, R16
|
||||
ROR R16, R14, R14
|
||||
MOVD $0x00000001, R4
|
||||
BFI $0, R13, $8, R1
|
||||
MOVBU R13, R1
|
||||
LSLW R1, R4, R4
|
||||
SUBW $1, R4, R4
|
||||
AND R4, R14, R14
|
||||
@@ -199,8 +193,7 @@ sequenceDecs_decode_amd64_ll_update_zero:
|
||||
// Load ctx.mlTable
|
||||
MOVD ctx+16(FP), R1
|
||||
MOVD 24(R1), R1
|
||||
ADD R7<<3, R1, R15
|
||||
MOVD (R15), R7
|
||||
MOVD (R1)(R7<<3), R7
|
||||
|
||||
// Update Offset State
|
||||
MOVBU R8, R13
|
||||
@@ -211,7 +204,7 @@ sequenceDecs_decode_amd64_ll_update_zero:
|
||||
NEG R1, R16
|
||||
ROR R16, R14, R14
|
||||
MOVD $0x00000001, R4
|
||||
BFI $0, R13, $8, R1
|
||||
MOVBU R13, R1
|
||||
LSLW R1, R4, R4
|
||||
SUBW $1, R4, R4
|
||||
AND R4, R14, R14
|
||||
@@ -220,8 +213,7 @@ sequenceDecs_decode_amd64_ll_update_zero:
|
||||
// Load ctx.ofTable
|
||||
MOVD ctx+16(FP), R1
|
||||
MOVD 48(R1), R1
|
||||
ADD R8<<3, R1, R15
|
||||
MOVD (R15), R8
|
||||
MOVD (R1)(R8<<3), R8
|
||||
|
||||
sequenceDecs_decode_amd64_skip_update:
|
||||
// Adjust offset
|
||||
@@ -411,8 +403,7 @@ sequenceDecs_decode_56_amd64_fill_end:
|
||||
MOVD R3, R1
|
||||
MOVD R2, R14
|
||||
LSL R1, R14, R14
|
||||
UBFX $8, R0, $8, R16
|
||||
BFI $0, R16, $8, R1
|
||||
UBFX $8, R0, $8, R1
|
||||
LSR $0x20, R0, R0
|
||||
TST R1, R1
|
||||
BEQ sequenceDecs_decode_56_amd64_of_update_zero
|
||||
@@ -433,8 +424,7 @@ sequenceDecs_decode_56_amd64_of_update_zero:
|
||||
MOVD R3, R1
|
||||
MOVD R2, R14
|
||||
LSL R1, R14, R14
|
||||
UBFX $8, R0, $8, R16
|
||||
BFI $0, R16, $8, R1
|
||||
UBFX $8, R0, $8, R1
|
||||
LSR $0x20, R0, R0
|
||||
TST R1, R1
|
||||
BEQ sequenceDecs_decode_56_amd64_ml_update_zero
|
||||
@@ -455,8 +445,7 @@ sequenceDecs_decode_56_amd64_ml_update_zero:
|
||||
MOVD R3, R1
|
||||
MOVD R2, R14
|
||||
LSL R1, R14, R14
|
||||
UBFX $8, R0, $8, R16
|
||||
BFI $0, R16, $8, R1
|
||||
UBFX $8, R0, $8, R1
|
||||
LSR $0x20, R0, R0
|
||||
TST R1, R1
|
||||
BEQ sequenceDecs_decode_56_amd64_ll_update_zero
|
||||
@@ -473,14 +462,12 @@ sequenceDecs_decode_56_amd64_ll_update_zero:
|
||||
MOVD R0, (R9)
|
||||
|
||||
// Fill bitreader for state updates
|
||||
MOVD R13, 8(RSP)
|
||||
MOVD R8, R0
|
||||
LSR $0x08, R0, R0
|
||||
MOVBU R0, R0
|
||||
MOVD ctx+16(FP), R1
|
||||
MOVD 96(R1), R16
|
||||
CMP $0x00, R16
|
||||
BEQ sequenceDecs_decode_56_amd64_skip_update
|
||||
MOVD R13, 8(RSP)
|
||||
UBFX $8, R8, $8, R0
|
||||
MOVD ctx+16(FP), R1
|
||||
MOVD 96(R1), R16
|
||||
CMP $0x00, R16
|
||||
BEQ sequenceDecs_decode_56_amd64_skip_update
|
||||
|
||||
// Update Literal Length State
|
||||
MOVBU R6, R13
|
||||
@@ -491,7 +478,7 @@ sequenceDecs_decode_56_amd64_ll_update_zero:
|
||||
NEG R1, R16
|
||||
ROR R16, R14, R14
|
||||
MOVD $0x00000001, R4
|
||||
BFI $0, R13, $8, R1
|
||||
MOVBU R13, R1
|
||||
LSLW R1, R4, R4
|
||||
SUBW $1, R4, R4
|
||||
AND R4, R14, R14
|
||||
@@ -500,8 +487,7 @@ sequenceDecs_decode_56_amd64_ll_update_zero:
|
||||
// Load ctx.llTable
|
||||
MOVD ctx+16(FP), R1
|
||||
MOVD (R1), R1
|
||||
ADD R6<<3, R1, R15
|
||||
MOVD (R15), R6
|
||||
MOVD (R1)(R6<<3), R6
|
||||
|
||||
// Update Match Length State
|
||||
MOVBU R7, R13
|
||||
@@ -512,7 +498,7 @@ sequenceDecs_decode_56_amd64_ll_update_zero:
|
||||
NEG R1, R16
|
||||
ROR R16, R14, R14
|
||||
MOVD $0x00000001, R4
|
||||
BFI $0, R13, $8, R1
|
||||
MOVBU R13, R1
|
||||
LSLW R1, R4, R4
|
||||
SUBW $1, R4, R4
|
||||
AND R4, R14, R14
|
||||
@@ -521,8 +507,7 @@ sequenceDecs_decode_56_amd64_ll_update_zero:
|
||||
// Load ctx.mlTable
|
||||
MOVD ctx+16(FP), R1
|
||||
MOVD 24(R1), R1
|
||||
ADD R7<<3, R1, R15
|
||||
MOVD (R15), R7
|
||||
MOVD (R1)(R7<<3), R7
|
||||
|
||||
// Update Offset State
|
||||
MOVBU R8, R13
|
||||
@@ -533,7 +518,7 @@ sequenceDecs_decode_56_amd64_ll_update_zero:
|
||||
NEG R1, R16
|
||||
ROR R16, R14, R14
|
||||
MOVD $0x00000001, R4
|
||||
BFI $0, R13, $8, R1
|
||||
MOVBU R13, R1
|
||||
LSLW R1, R4, R4
|
||||
SUBW $1, R4, R4
|
||||
AND R4, R14, R14
|
||||
@@ -542,8 +527,7 @@ sequenceDecs_decode_56_amd64_ll_update_zero:
|
||||
// Load ctx.ofTable
|
||||
MOVD ctx+16(FP), R1
|
||||
MOVD 48(R1), R1
|
||||
ADD R8<<3, R1, R15
|
||||
MOVD (R15), R8
|
||||
MOVD (R1)(R8<<3), R8
|
||||
|
||||
sequenceDecs_decode_56_amd64_skip_update:
|
||||
// Adjust offset
|
||||
@@ -716,16 +700,16 @@ main_loop:
|
||||
MOVD $0, R13
|
||||
|
||||
copy_1:
|
||||
ADD R13, R5, R15
|
||||
VLD1 (R15), [V0.B16]
|
||||
ADD R13, R3, R15
|
||||
VST1 [V0.B16], (R15)
|
||||
ADD $0x10, R13, R13
|
||||
CMP R10, R13
|
||||
BLO copy_1
|
||||
ADD R10, R5, R5
|
||||
ADD R10, R3, R3
|
||||
ADD R10, R6, R6
|
||||
ADD R13, R5, R15
|
||||
FMOVQ (R15), F0
|
||||
ADD R13, R3, R15
|
||||
FMOVQ F0, (R15)
|
||||
ADD $0x10, R13, R13
|
||||
CMP R10, R13
|
||||
BLO copy_1
|
||||
ADD R10, R5, R5
|
||||
ADD R10, R3, R3
|
||||
ADD R10, R6, R6
|
||||
|
||||
// Malformed input if seq.mo > t+len(hist) || seq.mo > s.windowSize)
|
||||
check_offset:
|
||||
@@ -748,21 +732,19 @@ check_offset:
|
||||
BLO copy_4_small
|
||||
|
||||
copy_4_loop:
|
||||
VLD1 (R13), [V0.B16]
|
||||
VST1 [V0.B16], (R3)
|
||||
ADD $0x10, R13, R13
|
||||
ADD $0x10, R3, R3
|
||||
SUBS $0x10, R10, R10
|
||||
BHS copy_4_loop
|
||||
ADD R10, R13, R13
|
||||
ADD $16, R13, R13
|
||||
ADD R10, R3, R3
|
||||
ADD $16, R3, R3
|
||||
ADD $-16, R13, R15
|
||||
VLD1 (R15), [V0.B16]
|
||||
ADD $-16, R3, R15
|
||||
VST1 [V0.B16], (R15)
|
||||
JMP copy_4_end
|
||||
FMOVQ (R13), F0
|
||||
FMOVQ F0, (R3)
|
||||
ADD $0x10, R13, R13
|
||||
ADD $0x10, R3, R3
|
||||
SUBS $0x10, R10, R10
|
||||
BHS copy_4_loop
|
||||
ADD R10, R13, R13
|
||||
ADD $16, R13, R13
|
||||
ADD R10, R3, R3
|
||||
ADD $16, R3, R3
|
||||
FMOVQ -16(R13), F0
|
||||
FMOVQ F0, -16(R3)
|
||||
JMP copy_4_end
|
||||
|
||||
copy_4_small:
|
||||
CMP $0x03, R12
|
||||
@@ -816,21 +798,19 @@ copy_all_from_history:
|
||||
BLO copy_5_small
|
||||
|
||||
copy_5_loop:
|
||||
VLD1 (R13), [V0.B16]
|
||||
VST1 [V0.B16], (R3)
|
||||
ADD $0x10, R13, R13
|
||||
ADD $0x10, R3, R3
|
||||
SUBS $0x10, R14, R14
|
||||
BHS copy_5_loop
|
||||
ADD R14, R13, R13
|
||||
ADD $16, R13, R13
|
||||
ADD R14, R3, R3
|
||||
ADD $16, R3, R3
|
||||
ADD $-16, R13, R15
|
||||
VLD1 (R15), [V0.B16]
|
||||
ADD $-16, R3, R15
|
||||
VST1 [V0.B16], (R15)
|
||||
JMP copy_5_end
|
||||
FMOVQ (R13), F0
|
||||
FMOVQ F0, (R3)
|
||||
ADD $0x10, R13, R13
|
||||
ADD $0x10, R3, R3
|
||||
SUBS $0x10, R14, R14
|
||||
BHS copy_5_loop
|
||||
ADD R14, R13, R13
|
||||
ADD $16, R13, R13
|
||||
ADD R14, R3, R3
|
||||
ADD $16, R3, R3
|
||||
FMOVQ -16(R13), F0
|
||||
FMOVQ F0, -16(R3)
|
||||
JMP copy_5_end
|
||||
|
||||
copy_5_small:
|
||||
CMP $0x03, R10
|
||||
@@ -903,21 +883,20 @@ copy_match:
|
||||
ADD R12, R3, R3
|
||||
|
||||
copy_2:
|
||||
VLD1 (R10), [V0.B16]
|
||||
VST1 [V0.B16], (R11)
|
||||
ADD $0x10, R10, R10
|
||||
ADD $0x10, R11, R11
|
||||
SUBS $0x10, R12, R12
|
||||
BHI copy_2
|
||||
JMP handle_loop
|
||||
FMOVQ (R10), F0
|
||||
FMOVQ F0, (R11)
|
||||
ADD $0x10, R10, R10
|
||||
ADD $0x10, R11, R11
|
||||
SUBS $0x10, R12, R12
|
||||
BHI copy_2
|
||||
JMP handle_loop
|
||||
|
||||
// Copy overlapping match
|
||||
copy_overlapping_match:
|
||||
ADD R12, R6, R6
|
||||
|
||||
copy_slow_3:
|
||||
MOVBU (R10), R16
|
||||
BFI $0, R16, $8, R11
|
||||
MOVBU (R10), R11
|
||||
MOVB R11, (R3)
|
||||
ADD $1, R10, R10
|
||||
ADD $1, R3, R3
|
||||
@@ -1002,21 +981,19 @@ main_loop:
|
||||
BLO copy_1_small
|
||||
|
||||
copy_1_loop:
|
||||
VLD1 (R5), [V0.B16]
|
||||
VST1 [V0.B16], (R3)
|
||||
ADD $0x10, R5, R5
|
||||
ADD $0x10, R3, R3
|
||||
SUBS $0x10, R13, R13
|
||||
BHS copy_1_loop
|
||||
ADD R13, R5, R5
|
||||
ADD $16, R5, R5
|
||||
ADD R13, R3, R3
|
||||
ADD $16, R3, R3
|
||||
ADD $-16, R5, R15
|
||||
VLD1 (R15), [V0.B16]
|
||||
ADD $-16, R3, R15
|
||||
VST1 [V0.B16], (R15)
|
||||
JMP copy_1_end
|
||||
FMOVQ (R5), F0
|
||||
FMOVQ F0, (R3)
|
||||
ADD $0x10, R5, R5
|
||||
ADD $0x10, R3, R3
|
||||
SUBS $0x10, R13, R13
|
||||
BHS copy_1_loop
|
||||
ADD R13, R5, R5
|
||||
ADD $16, R5, R5
|
||||
ADD R13, R3, R3
|
||||
ADD $16, R3, R3
|
||||
FMOVQ -16(R5), F0
|
||||
FMOVQ F0, -16(R3)
|
||||
JMP copy_1_end
|
||||
|
||||
copy_1_small:
|
||||
CMP $0x03, R10
|
||||
@@ -1094,21 +1071,19 @@ check_offset:
|
||||
BLO copy_4_small
|
||||
|
||||
copy_4_loop:
|
||||
VLD1 (R13), [V0.B16]
|
||||
VST1 [V0.B16], (R3)
|
||||
ADD $0x10, R13, R13
|
||||
ADD $0x10, R3, R3
|
||||
SUBS $0x10, R10, R10
|
||||
BHS copy_4_loop
|
||||
ADD R10, R13, R13
|
||||
ADD $16, R13, R13
|
||||
ADD R10, R3, R3
|
||||
ADD $16, R3, R3
|
||||
ADD $-16, R13, R15
|
||||
VLD1 (R15), [V0.B16]
|
||||
ADD $-16, R3, R15
|
||||
VST1 [V0.B16], (R15)
|
||||
JMP copy_4_end
|
||||
FMOVQ (R13), F0
|
||||
FMOVQ F0, (R3)
|
||||
ADD $0x10, R13, R13
|
||||
ADD $0x10, R3, R3
|
||||
SUBS $0x10, R10, R10
|
||||
BHS copy_4_loop
|
||||
ADD R10, R13, R13
|
||||
ADD $16, R13, R13
|
||||
ADD R10, R3, R3
|
||||
ADD $16, R3, R3
|
||||
FMOVQ -16(R13), F0
|
||||
FMOVQ F0, -16(R3)
|
||||
JMP copy_4_end
|
||||
|
||||
copy_4_small:
|
||||
CMP $0x03, R12
|
||||
@@ -1162,21 +1137,19 @@ copy_all_from_history:
|
||||
BLO copy_5_small
|
||||
|
||||
copy_5_loop:
|
||||
VLD1 (R13), [V0.B16]
|
||||
VST1 [V0.B16], (R3)
|
||||
ADD $0x10, R13, R13
|
||||
ADD $0x10, R3, R3
|
||||
SUBS $0x10, R14, R14
|
||||
BHS copy_5_loop
|
||||
ADD R14, R13, R13
|
||||
ADD $16, R13, R13
|
||||
ADD R14, R3, R3
|
||||
ADD $16, R3, R3
|
||||
ADD $-16, R13, R15
|
||||
VLD1 (R15), [V0.B16]
|
||||
ADD $-16, R3, R15
|
||||
VST1 [V0.B16], (R15)
|
||||
JMP copy_5_end
|
||||
FMOVQ (R13), F0
|
||||
FMOVQ F0, (R3)
|
||||
ADD $0x10, R13, R13
|
||||
ADD $0x10, R3, R3
|
||||
SUBS $0x10, R14, R14
|
||||
BHS copy_5_loop
|
||||
ADD R14, R13, R13
|
||||
ADD $16, R13, R13
|
||||
ADD R14, R3, R3
|
||||
ADD $16, R3, R3
|
||||
FMOVQ -16(R13), F0
|
||||
FMOVQ F0, -16(R3)
|
||||
JMP copy_5_end
|
||||
|
||||
copy_5_small:
|
||||
CMP $0x03, R10
|
||||
@@ -1250,21 +1223,19 @@ copy_match:
|
||||
BLO copy_2_small
|
||||
|
||||
copy_2_loop:
|
||||
VLD1 (R10), [V0.B16]
|
||||
VST1 [V0.B16], (R3)
|
||||
ADD $0x10, R10, R10
|
||||
ADD $0x10, R3, R3
|
||||
SUBS $0x10, R11, R11
|
||||
BHS copy_2_loop
|
||||
ADD R11, R10, R10
|
||||
ADD $16, R10, R10
|
||||
ADD R11, R3, R3
|
||||
ADD $16, R3, R3
|
||||
ADD $-16, R10, R15
|
||||
VLD1 (R15), [V0.B16]
|
||||
ADD $-16, R3, R15
|
||||
VST1 [V0.B16], (R15)
|
||||
JMP copy_2_end
|
||||
FMOVQ (R10), F0
|
||||
FMOVQ F0, (R3)
|
||||
ADD $0x10, R10, R10
|
||||
ADD $0x10, R3, R3
|
||||
SUBS $0x10, R11, R11
|
||||
BHS copy_2_loop
|
||||
ADD R11, R10, R10
|
||||
ADD $16, R10, R10
|
||||
ADD R11, R3, R3
|
||||
ADD $16, R3, R3
|
||||
FMOVQ -16(R10), F0
|
||||
FMOVQ F0, -16(R3)
|
||||
JMP copy_2_end
|
||||
|
||||
copy_2_small:
|
||||
CMP $0x03, R12
|
||||
@@ -1326,8 +1297,7 @@ copy_overlapping_match:
|
||||
ADD R12, R6, R6
|
||||
|
||||
copy_slow_3:
|
||||
MOVBU (R10), R16
|
||||
BFI $0, R16, $8, R11
|
||||
MOVBU (R10), R11
|
||||
MOVB R11, (R3)
|
||||
ADD $1, R10, R10
|
||||
ADD $1, R3, R3
|
||||
@@ -1453,8 +1423,7 @@ sequenceDecs_decodeSync_amd64_fill_end:
|
||||
MOVD R3, R1
|
||||
MOVD R2, R13
|
||||
LSL R1, R13, R13
|
||||
UBFX $8, R0, $8, R16
|
||||
BFI $0, R16, $8, R1
|
||||
UBFX $8, R0, $8, R1
|
||||
LSR $0x20, R0, R0
|
||||
TST R1, R1
|
||||
BEQ sequenceDecs_decodeSync_amd64_of_update_zero
|
||||
@@ -1475,8 +1444,7 @@ sequenceDecs_decodeSync_amd64_of_update_zero:
|
||||
MOVD R3, R1
|
||||
MOVD R2, R13
|
||||
LSL R1, R13, R13
|
||||
UBFX $8, R0, $8, R16
|
||||
BFI $0, R16, $8, R1
|
||||
UBFX $8, R0, $8, R1
|
||||
LSR $0x20, R0, R0
|
||||
TST R1, R1
|
||||
BEQ sequenceDecs_decodeSync_amd64_ml_update_zero
|
||||
@@ -1526,8 +1494,7 @@ sequenceDecs_decodeSync_amd64_fill_2_end:
|
||||
MOVD R3, R1
|
||||
MOVD R2, R13
|
||||
LSL R1, R13, R13
|
||||
UBFX $8, R0, $8, R16
|
||||
BFI $0, R16, $8, R1
|
||||
UBFX $8, R0, $8, R1
|
||||
LSR $0x20, R0, R0
|
||||
TST R1, R1
|
||||
BEQ sequenceDecs_decodeSync_amd64_ll_update_zero
|
||||
@@ -1544,14 +1511,12 @@ sequenceDecs_decodeSync_amd64_ll_update_zero:
|
||||
MOVD R0, 32(RSP)
|
||||
|
||||
// Fill bitreader for state updates
|
||||
MOVD R12, 8(RSP)
|
||||
MOVD R8, R0
|
||||
LSR $0x08, R0, R0
|
||||
MOVBU R0, R0
|
||||
MOVD ctx+16(FP), R1
|
||||
MOVD 96(R1), R16
|
||||
CMP $0x00, R16
|
||||
BEQ sequenceDecs_decodeSync_amd64_skip_update
|
||||
MOVD R12, 8(RSP)
|
||||
UBFX $8, R8, $8, R0
|
||||
MOVD ctx+16(FP), R1
|
||||
MOVD 96(R1), R16
|
||||
CMP $0x00, R16
|
||||
BEQ sequenceDecs_decodeSync_amd64_skip_update
|
||||
|
||||
// Update Literal Length State
|
||||
MOVBU R6, R12
|
||||
@@ -1562,7 +1527,7 @@ sequenceDecs_decodeSync_amd64_ll_update_zero:
|
||||
NEG R1, R16
|
||||
ROR R16, R13, R13
|
||||
MOVD $0x00000001, R14
|
||||
BFI $0, R12, $8, R1
|
||||
MOVBU R12, R1
|
||||
LSLW R1, R14, R14
|
||||
SUBW $1, R14, R14
|
||||
AND R14, R13, R13
|
||||
@@ -1571,8 +1536,7 @@ sequenceDecs_decodeSync_amd64_ll_update_zero:
|
||||
// Load ctx.llTable
|
||||
MOVD ctx+16(FP), R1
|
||||
MOVD (R1), R1
|
||||
ADD R6<<3, R1, R15
|
||||
MOVD (R15), R6
|
||||
MOVD (R1)(R6<<3), R6
|
||||
|
||||
// Update Match Length State
|
||||
MOVBU R7, R12
|
||||
@@ -1583,7 +1547,7 @@ sequenceDecs_decodeSync_amd64_ll_update_zero:
|
||||
NEG R1, R16
|
||||
ROR R16, R13, R13
|
||||
MOVD $0x00000001, R14
|
||||
BFI $0, R12, $8, R1
|
||||
MOVBU R12, R1
|
||||
LSLW R1, R14, R14
|
||||
SUBW $1, R14, R14
|
||||
AND R14, R13, R13
|
||||
@@ -1592,8 +1556,7 @@ sequenceDecs_decodeSync_amd64_ll_update_zero:
|
||||
// Load ctx.mlTable
|
||||
MOVD ctx+16(FP), R1
|
||||
MOVD 24(R1), R1
|
||||
ADD R7<<3, R1, R15
|
||||
MOVD (R15), R7
|
||||
MOVD (R1)(R7<<3), R7
|
||||
|
||||
// Update Offset State
|
||||
MOVBU R8, R12
|
||||
@@ -1604,7 +1567,7 @@ sequenceDecs_decodeSync_amd64_ll_update_zero:
|
||||
NEG R1, R16
|
||||
ROR R16, R13, R13
|
||||
MOVD $0x00000001, R14
|
||||
BFI $0, R12, $8, R1
|
||||
MOVBU R12, R1
|
||||
LSLW R1, R14, R14
|
||||
SUBW $1, R14, R14
|
||||
AND R14, R13, R13
|
||||
@@ -1613,21 +1576,18 @@ sequenceDecs_decodeSync_amd64_ll_update_zero:
|
||||
// Load ctx.ofTable
|
||||
MOVD ctx+16(FP), R1
|
||||
MOVD 48(R1), R1
|
||||
ADD R8<<3, R1, R15
|
||||
MOVD (R15), R8
|
||||
MOVD (R1)(R8<<3), R8
|
||||
|
||||
sequenceDecs_decodeSync_amd64_skip_update:
|
||||
// Adjust offset
|
||||
MOVD s+0(FP), R1
|
||||
MOVD 16(RSP), R12
|
||||
CMP $0x01, R0
|
||||
BLS sequenceDecs_decodeSync_amd64_adjust_offsetB_1_or_0
|
||||
ADD $144, R1, R15
|
||||
VLD1 (R15), [V0.B16]
|
||||
MOVD R12, 144(R1)
|
||||
ADD $152, R1, R15
|
||||
VST1 [V0.B16], (R15)
|
||||
JMP sequenceDecs_decodeSync_amd64_after_adjust
|
||||
MOVD s+0(FP), R1
|
||||
MOVD 16(RSP), R12
|
||||
CMP $0x01, R0
|
||||
BLS sequenceDecs_decodeSync_amd64_adjust_offsetB_1_or_0
|
||||
FMOVQ 144(R1), F0
|
||||
MOVD R12, 144(R1)
|
||||
FMOVQ F0, 152(R1)
|
||||
JMP sequenceDecs_decodeSync_amd64_after_adjust
|
||||
|
||||
sequenceDecs_decodeSync_amd64_adjust_offsetB_1_or_0:
|
||||
MOVD 32(RSP), R16
|
||||
@@ -1709,16 +1669,16 @@ sequenceDecs_decodeSync_amd64_match_len_ofs_ok:
|
||||
MOVD $0, R13
|
||||
|
||||
copy_1:
|
||||
ADD R13, R10, R15
|
||||
VLD1 (R15), [V0.B16]
|
||||
ADD R13, R9, R15
|
||||
VST1 [V0.B16], (R15)
|
||||
ADD $0x10, R13, R13
|
||||
CMP R0, R13
|
||||
BLO copy_1
|
||||
ADD R0, R10, R10
|
||||
ADD R0, R9, R9
|
||||
ADD R0, R11, R11
|
||||
ADD R13, R10, R15
|
||||
FMOVQ (R15), F0
|
||||
ADD R13, R9, R15
|
||||
FMOVQ F0, (R15)
|
||||
ADD $0x10, R13, R13
|
||||
CMP R0, R13
|
||||
BLO copy_1
|
||||
ADD R0, R10, R10
|
||||
ADD R0, R9, R9
|
||||
ADD R0, R11, R11
|
||||
|
||||
// Malformed input if seq.mo > t+len(hist) || seq.mo > s.windowSize)
|
||||
check_offset:
|
||||
@@ -1744,21 +1704,19 @@ check_offset:
|
||||
BLO copy_4_small
|
||||
|
||||
copy_4_loop:
|
||||
VLD1 (R13), [V0.B16]
|
||||
VST1 [V0.B16], (R9)
|
||||
ADD $0x10, R13, R13
|
||||
ADD $0x10, R9, R9
|
||||
SUBS $0x10, R0, R0
|
||||
BHS copy_4_loop
|
||||
ADD R0, R13, R13
|
||||
ADD $16, R13, R13
|
||||
ADD R0, R9, R9
|
||||
ADD $16, R9, R9
|
||||
ADD $-16, R13, R15
|
||||
VLD1 (R15), [V0.B16]
|
||||
ADD $-16, R9, R15
|
||||
VST1 [V0.B16], (R15)
|
||||
JMP copy_4_end
|
||||
FMOVQ (R13), F0
|
||||
FMOVQ F0, (R9)
|
||||
ADD $0x10, R13, R13
|
||||
ADD $0x10, R9, R9
|
||||
SUBS $0x10, R0, R0
|
||||
BHS copy_4_loop
|
||||
ADD R0, R13, R13
|
||||
ADD $16, R13, R13
|
||||
ADD R0, R9, R9
|
||||
ADD $16, R9, R9
|
||||
FMOVQ -16(R13), F0
|
||||
FMOVQ F0, -16(R9)
|
||||
JMP copy_4_end
|
||||
|
||||
copy_4_small:
|
||||
CMP $0x03, R12
|
||||
@@ -1809,21 +1767,19 @@ copy_all_from_history:
|
||||
BLO copy_5_small
|
||||
|
||||
copy_5_loop:
|
||||
VLD1 (R13), [V0.B16]
|
||||
VST1 [V0.B16], (R9)
|
||||
ADD $0x10, R13, R13
|
||||
ADD $0x10, R9, R9
|
||||
SUBS $0x10, R14, R14
|
||||
BHS copy_5_loop
|
||||
ADD R14, R13, R13
|
||||
ADD $16, R13, R13
|
||||
ADD R14, R9, R9
|
||||
ADD $16, R9, R9
|
||||
ADD $-16, R13, R15
|
||||
VLD1 (R15), [V0.B16]
|
||||
ADD $-16, R9, R15
|
||||
VST1 [V0.B16], (R15)
|
||||
JMP copy_5_end
|
||||
FMOVQ (R13), F0
|
||||
FMOVQ F0, (R9)
|
||||
ADD $0x10, R13, R13
|
||||
ADD $0x10, R9, R9
|
||||
SUBS $0x10, R14, R14
|
||||
BHS copy_5_loop
|
||||
ADD R14, R13, R13
|
||||
ADD $16, R13, R13
|
||||
ADD R14, R9, R9
|
||||
ADD $16, R9, R9
|
||||
FMOVQ -16(R13), F0
|
||||
FMOVQ F0, -16(R9)
|
||||
JMP copy_5_end
|
||||
|
||||
copy_5_small:
|
||||
CMP $0x03, R0
|
||||
@@ -1896,21 +1852,20 @@ copy_match:
|
||||
ADD R12, R9, R9
|
||||
|
||||
copy_2:
|
||||
VLD1 (R0), [V0.B16]
|
||||
VST1 [V0.B16], (R1)
|
||||
ADD $0x10, R0, R0
|
||||
ADD $0x10, R1, R1
|
||||
SUBS $0x10, R12, R12
|
||||
BHI copy_2
|
||||
JMP handle_loop
|
||||
FMOVQ (R0), F0
|
||||
FMOVQ F0, (R1)
|
||||
ADD $0x10, R0, R0
|
||||
ADD $0x10, R1, R1
|
||||
SUBS $0x10, R12, R12
|
||||
BHI copy_2
|
||||
JMP handle_loop
|
||||
|
||||
// Copy overlapping match
|
||||
copy_overlapping_match:
|
||||
ADD R12, R11, R11
|
||||
|
||||
copy_slow_3:
|
||||
MOVBU (R0), R16
|
||||
BFI $0, R16, $8, R1
|
||||
MOVBU (R0), R1
|
||||
MOVB R1, (R9)
|
||||
ADD $1, R0, R0
|
||||
ADD $1, R9, R9
|
||||
@@ -2078,8 +2033,7 @@ sequenceDecs_decodeSync_safe_amd64_fill_end:
|
||||
MOVD R3, R1
|
||||
MOVD R2, R13
|
||||
LSL R1, R13, R13
|
||||
UBFX $8, R0, $8, R16
|
||||
BFI $0, R16, $8, R1
|
||||
UBFX $8, R0, $8, R1
|
||||
LSR $0x20, R0, R0
|
||||
TST R1, R1
|
||||
BEQ sequenceDecs_decodeSync_safe_amd64_of_update_zero
|
||||
@@ -2100,8 +2054,7 @@ sequenceDecs_decodeSync_safe_amd64_of_update_zero:
|
||||
MOVD R3, R1
|
||||
MOVD R2, R13
|
||||
LSL R1, R13, R13
|
||||
UBFX $8, R0, $8, R16
|
||||
BFI $0, R16, $8, R1
|
||||
UBFX $8, R0, $8, R1
|
||||
LSR $0x20, R0, R0
|
||||
TST R1, R1
|
||||
BEQ sequenceDecs_decodeSync_safe_amd64_ml_update_zero
|
||||
@@ -2151,8 +2104,7 @@ sequenceDecs_decodeSync_safe_amd64_fill_2_end:
|
||||
MOVD R3, R1
|
||||
MOVD R2, R13
|
||||
LSL R1, R13, R13
|
||||
UBFX $8, R0, $8, R16
|
||||
BFI $0, R16, $8, R1
|
||||
UBFX $8, R0, $8, R1
|
||||
LSR $0x20, R0, R0
|
||||
TST R1, R1
|
||||
BEQ sequenceDecs_decodeSync_safe_amd64_ll_update_zero
|
||||
@@ -2169,14 +2121,12 @@ sequenceDecs_decodeSync_safe_amd64_ll_update_zero:
|
||||
MOVD R0, 32(RSP)
|
||||
|
||||
// Fill bitreader for state updates
|
||||
MOVD R12, 8(RSP)
|
||||
MOVD R8, R0
|
||||
LSR $0x08, R0, R0
|
||||
MOVBU R0, R0
|
||||
MOVD ctx+16(FP), R1
|
||||
MOVD 96(R1), R16
|
||||
CMP $0x00, R16
|
||||
BEQ sequenceDecs_decodeSync_safe_amd64_skip_update
|
||||
MOVD R12, 8(RSP)
|
||||
UBFX $8, R8, $8, R0
|
||||
MOVD ctx+16(FP), R1
|
||||
MOVD 96(R1), R16
|
||||
CMP $0x00, R16
|
||||
BEQ sequenceDecs_decodeSync_safe_amd64_skip_update
|
||||
|
||||
// Update Literal Length State
|
||||
MOVBU R6, R12
|
||||
@@ -2187,7 +2137,7 @@ sequenceDecs_decodeSync_safe_amd64_ll_update_zero:
|
||||
NEG R1, R16
|
||||
ROR R16, R13, R13
|
||||
MOVD $0x00000001, R14
|
||||
BFI $0, R12, $8, R1
|
||||
MOVBU R12, R1
|
||||
LSLW R1, R14, R14
|
||||
SUBW $1, R14, R14
|
||||
AND R14, R13, R13
|
||||
@@ -2196,8 +2146,7 @@ sequenceDecs_decodeSync_safe_amd64_ll_update_zero:
|
||||
// Load ctx.llTable
|
||||
MOVD ctx+16(FP), R1
|
||||
MOVD (R1), R1
|
||||
ADD R6<<3, R1, R15
|
||||
MOVD (R15), R6
|
||||
MOVD (R1)(R6<<3), R6
|
||||
|
||||
// Update Match Length State
|
||||
MOVBU R7, R12
|
||||
@@ -2208,7 +2157,7 @@ sequenceDecs_decodeSync_safe_amd64_ll_update_zero:
|
||||
NEG R1, R16
|
||||
ROR R16, R13, R13
|
||||
MOVD $0x00000001, R14
|
||||
BFI $0, R12, $8, R1
|
||||
MOVBU R12, R1
|
||||
LSLW R1, R14, R14
|
||||
SUBW $1, R14, R14
|
||||
AND R14, R13, R13
|
||||
@@ -2217,8 +2166,7 @@ sequenceDecs_decodeSync_safe_amd64_ll_update_zero:
|
||||
// Load ctx.mlTable
|
||||
MOVD ctx+16(FP), R1
|
||||
MOVD 24(R1), R1
|
||||
ADD R7<<3, R1, R15
|
||||
MOVD (R15), R7
|
||||
MOVD (R1)(R7<<3), R7
|
||||
|
||||
// Update Offset State
|
||||
MOVBU R8, R12
|
||||
@@ -2229,7 +2177,7 @@ sequenceDecs_decodeSync_safe_amd64_ll_update_zero:
|
||||
NEG R1, R16
|
||||
ROR R16, R13, R13
|
||||
MOVD $0x00000001, R14
|
||||
BFI $0, R12, $8, R1
|
||||
MOVBU R12, R1
|
||||
LSLW R1, R14, R14
|
||||
SUBW $1, R14, R14
|
||||
AND R14, R13, R13
|
||||
@@ -2238,21 +2186,18 @@ sequenceDecs_decodeSync_safe_amd64_ll_update_zero:
|
||||
// Load ctx.ofTable
|
||||
MOVD ctx+16(FP), R1
|
||||
MOVD 48(R1), R1
|
||||
ADD R8<<3, R1, R15
|
||||
MOVD (R15), R8
|
||||
MOVD (R1)(R8<<3), R8
|
||||
|
||||
sequenceDecs_decodeSync_safe_amd64_skip_update:
|
||||
// Adjust offset
|
||||
MOVD s+0(FP), R1
|
||||
MOVD 16(RSP), R12
|
||||
CMP $0x01, R0
|
||||
BLS sequenceDecs_decodeSync_safe_amd64_adjust_offsetB_1_or_0
|
||||
ADD $144, R1, R15
|
||||
VLD1 (R15), [V0.B16]
|
||||
MOVD R12, 144(R1)
|
||||
ADD $152, R1, R15
|
||||
VST1 [V0.B16], (R15)
|
||||
JMP sequenceDecs_decodeSync_safe_amd64_after_adjust
|
||||
MOVD s+0(FP), R1
|
||||
MOVD 16(RSP), R12
|
||||
CMP $0x01, R0
|
||||
BLS sequenceDecs_decodeSync_safe_amd64_adjust_offsetB_1_or_0
|
||||
FMOVQ 144(R1), F0
|
||||
MOVD R12, 144(R1)
|
||||
FMOVQ F0, 152(R1)
|
||||
JMP sequenceDecs_decodeSync_safe_amd64_after_adjust
|
||||
|
||||
sequenceDecs_decodeSync_safe_amd64_adjust_offsetB_1_or_0:
|
||||
MOVD 32(RSP), R16
|
||||
@@ -2335,21 +2280,19 @@ sequenceDecs_decodeSync_safe_amd64_match_len_ofs_ok:
|
||||
BLO copy_1_small
|
||||
|
||||
copy_1_loop:
|
||||
VLD1 (R10), [V0.B16]
|
||||
VST1 [V0.B16], (R9)
|
||||
ADD $0x10, R10, R10
|
||||
ADD $0x10, R9, R9
|
||||
SUBS $0x10, R13, R13
|
||||
BHS copy_1_loop
|
||||
ADD R13, R10, R10
|
||||
ADD $16, R10, R10
|
||||
ADD R13, R9, R9
|
||||
ADD $16, R9, R9
|
||||
ADD $-16, R10, R15
|
||||
VLD1 (R15), [V0.B16]
|
||||
ADD $-16, R9, R15
|
||||
VST1 [V0.B16], (R15)
|
||||
JMP copy_1_end
|
||||
FMOVQ (R10), F0
|
||||
FMOVQ F0, (R9)
|
||||
ADD $0x10, R10, R10
|
||||
ADD $0x10, R9, R9
|
||||
SUBS $0x10, R13, R13
|
||||
BHS copy_1_loop
|
||||
ADD R13, R10, R10
|
||||
ADD $16, R10, R10
|
||||
ADD R13, R9, R9
|
||||
ADD $16, R9, R9
|
||||
FMOVQ -16(R10), F0
|
||||
FMOVQ F0, -16(R9)
|
||||
JMP copy_1_end
|
||||
|
||||
copy_1_small:
|
||||
CMP $0x03, R0
|
||||
@@ -2430,21 +2373,19 @@ check_offset:
|
||||
BLO copy_4_small
|
||||
|
||||
copy_4_loop:
|
||||
VLD1 (R13), [V0.B16]
|
||||
VST1 [V0.B16], (R9)
|
||||
ADD $0x10, R13, R13
|
||||
ADD $0x10, R9, R9
|
||||
SUBS $0x10, R0, R0
|
||||
BHS copy_4_loop
|
||||
ADD R0, R13, R13
|
||||
ADD $16, R13, R13
|
||||
ADD R0, R9, R9
|
||||
ADD $16, R9, R9
|
||||
ADD $-16, R13, R15
|
||||
VLD1 (R15), [V0.B16]
|
||||
ADD $-16, R9, R15
|
||||
VST1 [V0.B16], (R15)
|
||||
JMP copy_4_end
|
||||
FMOVQ (R13), F0
|
||||
FMOVQ F0, (R9)
|
||||
ADD $0x10, R13, R13
|
||||
ADD $0x10, R9, R9
|
||||
SUBS $0x10, R0, R0
|
||||
BHS copy_4_loop
|
||||
ADD R0, R13, R13
|
||||
ADD $16, R13, R13
|
||||
ADD R0, R9, R9
|
||||
ADD $16, R9, R9
|
||||
FMOVQ -16(R13), F0
|
||||
FMOVQ F0, -16(R9)
|
||||
JMP copy_4_end
|
||||
|
||||
copy_4_small:
|
||||
CMP $0x03, R12
|
||||
@@ -2495,21 +2436,19 @@ copy_all_from_history:
|
||||
BLO copy_5_small
|
||||
|
||||
copy_5_loop:
|
||||
VLD1 (R13), [V0.B16]
|
||||
VST1 [V0.B16], (R9)
|
||||
ADD $0x10, R13, R13
|
||||
ADD $0x10, R9, R9
|
||||
SUBS $0x10, R14, R14
|
||||
BHS copy_5_loop
|
||||
ADD R14, R13, R13
|
||||
ADD $16, R13, R13
|
||||
ADD R14, R9, R9
|
||||
ADD $16, R9, R9
|
||||
ADD $-16, R13, R15
|
||||
VLD1 (R15), [V0.B16]
|
||||
ADD $-16, R9, R15
|
||||
VST1 [V0.B16], (R15)
|
||||
JMP copy_5_end
|
||||
FMOVQ (R13), F0
|
||||
FMOVQ F0, (R9)
|
||||
ADD $0x10, R13, R13
|
||||
ADD $0x10, R9, R9
|
||||
SUBS $0x10, R14, R14
|
||||
BHS copy_5_loop
|
||||
ADD R14, R13, R13
|
||||
ADD $16, R13, R13
|
||||
ADD R14, R9, R9
|
||||
ADD $16, R9, R9
|
||||
FMOVQ -16(R13), F0
|
||||
FMOVQ F0, -16(R9)
|
||||
JMP copy_5_end
|
||||
|
||||
copy_5_small:
|
||||
CMP $0x03, R0
|
||||
@@ -2583,21 +2522,19 @@ copy_match:
|
||||
BLO copy_2_small
|
||||
|
||||
copy_2_loop:
|
||||
VLD1 (R0), [V0.B16]
|
||||
VST1 [V0.B16], (R9)
|
||||
ADD $0x10, R0, R0
|
||||
ADD $0x10, R9, R9
|
||||
SUBS $0x10, R1, R1
|
||||
BHS copy_2_loop
|
||||
ADD R1, R0, R0
|
||||
ADD $16, R0, R0
|
||||
ADD R1, R9, R9
|
||||
ADD $16, R9, R9
|
||||
ADD $-16, R0, R15
|
||||
VLD1 (R15), [V0.B16]
|
||||
ADD $-16, R9, R15
|
||||
VST1 [V0.B16], (R15)
|
||||
JMP copy_2_end
|
||||
FMOVQ (R0), F0
|
||||
FMOVQ F0, (R9)
|
||||
ADD $0x10, R0, R0
|
||||
ADD $0x10, R9, R9
|
||||
SUBS $0x10, R1, R1
|
||||
BHS copy_2_loop
|
||||
ADD R1, R0, R0
|
||||
ADD $16, R0, R0
|
||||
ADD R1, R9, R9
|
||||
ADD $16, R9, R9
|
||||
FMOVQ -16(R0), F0
|
||||
FMOVQ F0, -16(R9)
|
||||
JMP copy_2_end
|
||||
|
||||
copy_2_small:
|
||||
CMP $0x03, R12
|
||||
@@ -2659,8 +2596,7 @@ copy_overlapping_match:
|
||||
ADD R12, R11, R11
|
||||
|
||||
copy_slow_3:
|
||||
MOVBU (R0), R16
|
||||
BFI $0, R16, $8, R1
|
||||
MOVBU (R0), R1
|
||||
MOVB R1, (R9)
|
||||
ADD $1, R0, R0
|
||||
ADD $1, R9, R9
|
||||
|
||||
+19
-7
@@ -5,13 +5,13 @@ package colorable
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
syscall "golang.org/x/sys/windows"
|
||||
"io"
|
||||
"math"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
syscall "golang.org/x/sys/windows"
|
||||
"unsafe"
|
||||
|
||||
"github.com/mattn/go-isatty"
|
||||
@@ -93,6 +93,7 @@ type writer struct {
|
||||
handle syscall.Handle
|
||||
althandle syscall.Handle
|
||||
oldattr word
|
||||
curattr word
|
||||
oldpos coord
|
||||
rest bytes.Buffer
|
||||
mutex sync.Mutex
|
||||
@@ -112,7 +113,7 @@ func NewColorable(file *os.File) io.Writer {
|
||||
var csbi consoleScreenBufferInfo
|
||||
handle := syscall.Handle(file.Fd())
|
||||
procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
|
||||
return &writer{out: file, handle: handle, oldattr: csbi.attributes, oldpos: coord{0, 0}}
|
||||
return &writer{out: file, handle: handle, oldattr: csbi.attributes, curattr: csbi.attributes, oldpos: coord{0, 0}}
|
||||
}
|
||||
return file
|
||||
}
|
||||
@@ -438,7 +439,11 @@ func (w *writer) Write(data []byte) (n int, err error) {
|
||||
w.mutex.Lock()
|
||||
defer w.mutex.Unlock()
|
||||
var csbi consoleScreenBufferInfo
|
||||
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
||||
|
||||
if w.rest.Len() == 0 && bytes.IndexByte(data, 0x1b) == -1 {
|
||||
w.out.Write(data)
|
||||
return len(data), nil
|
||||
}
|
||||
|
||||
handle := w.handle
|
||||
|
||||
@@ -517,7 +522,7 @@ loop:
|
||||
w.rest.Reset()
|
||||
break
|
||||
}
|
||||
buf.Write([]byte(string(c)))
|
||||
buf.WriteByte(c)
|
||||
}
|
||||
if m == 0 {
|
||||
break loop
|
||||
@@ -678,11 +683,11 @@ loop:
|
||||
procFillConsoleOutputCharacter.Call(uintptr(handle), uintptr(' '), uintptr(n), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written)))
|
||||
procFillConsoleOutputAttribute.Call(uintptr(handle), uintptr(csbi.attributes), uintptr(n), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written)))
|
||||
case 'm':
|
||||
procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
|
||||
attr := csbi.attributes
|
||||
attr := w.curattr
|
||||
cs := buf.String()
|
||||
if cs == "" {
|
||||
procSetConsoleTextAttribute.Call(uintptr(handle), uintptr(w.oldattr))
|
||||
w.curattr = w.oldattr
|
||||
continue
|
||||
}
|
||||
token := strings.Split(cs, ";")
|
||||
@@ -814,9 +819,12 @@ loop:
|
||||
attr |= backgroundBlue
|
||||
}
|
||||
}
|
||||
procSetConsoleTextAttribute.Call(uintptr(handle), uintptr(attr))
|
||||
}
|
||||
}
|
||||
if attr != w.curattr {
|
||||
procSetConsoleTextAttribute.Call(uintptr(handle), uintptr(attr))
|
||||
w.curattr = attr
|
||||
}
|
||||
case 'h':
|
||||
var ci consoleCursorInfo
|
||||
cs := buf.String()
|
||||
@@ -834,6 +842,8 @@ loop:
|
||||
w.althandle = syscall.Handle(h)
|
||||
if w.althandle != 0 {
|
||||
handle = w.althandle
|
||||
procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
|
||||
w.curattr = csbi.attributes
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -853,6 +863,8 @@ loop:
|
||||
syscall.CloseHandle(w.althandle)
|
||||
w.althandle = 0
|
||||
handle = w.handle
|
||||
procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
|
||||
w.curattr = csbi.attributes
|
||||
}
|
||||
}
|
||||
case 's':
|
||||
|
||||
+8
-1
@@ -47,9 +47,10 @@ func IsTerminal(fd uintptr) bool {
|
||||
// Check pipe name is used for cygwin/msys2 pty.
|
||||
// Cygwin/MSYS2 PTY has a name like:
|
||||
// \{cygwin,msys}-XXXXXXXXXXXXXXXX-ptyN-{from,to}-master
|
||||
// On Windows 7 a trailing suffix (e.g. "-nat") may be appended.
|
||||
func isCygwinPipeName(name string) bool {
|
||||
token := strings.Split(name, "-")
|
||||
if len(token) != 5 {
|
||||
if len(token) < 5 {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -76,6 +77,12 @@ func isCygwinPipeName(name string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, t := range token[5:] {
|
||||
if t == "" {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
+21
-56
@@ -29,7 +29,6 @@ import (
|
||||
"math"
|
||||
"reflect"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
@@ -104,27 +103,28 @@ type handleVal struct {
|
||||
val any
|
||||
}
|
||||
|
||||
var handleLock sync.Mutex
|
||||
var handleVals atomic.Value // stores map[unsafe.Pointer]handleVal
|
||||
// handleVals maps unsafe.Pointer handles to handleVal. A sync.Map keeps
|
||||
// lookups lock-free on the hot callback path while insertion and removal
|
||||
// stay O(1); the previous copy-on-write map made every registration copy
|
||||
// the whole table, so opening N connections (each registering several
|
||||
// functions) was quadratic in time and allocation.
|
||||
var handleVals sync.Map
|
||||
|
||||
func newHandle(db *SQLiteConn, v any) unsafe.Pointer {
|
||||
val := handleVal{db: db, val: v}
|
||||
var p unsafe.Pointer = C.malloc(C.size_t(1))
|
||||
if p == nil {
|
||||
panic("can't allocate 'cgo-pointer hack index pointer': ptr == nil")
|
||||
}
|
||||
|
||||
handleLock.Lock()
|
||||
defer handleLock.Unlock()
|
||||
|
||||
next := cloneHandleVals(len(loadHandleVals()) + 1)
|
||||
next[p] = val
|
||||
handleVals.Store(next)
|
||||
handleVals.Store(p, handleVal{db: db, val: v})
|
||||
return p
|
||||
}
|
||||
|
||||
func lookupHandleVal(handle unsafe.Pointer) handleVal {
|
||||
return loadHandleVals()[handle]
|
||||
v, ok := handleVals.Load(handle)
|
||||
if !ok {
|
||||
return handleVal{}
|
||||
}
|
||||
return v.(handleVal)
|
||||
}
|
||||
|
||||
func lookupHandle(handle unsafe.Pointer) any {
|
||||
@@ -134,55 +134,20 @@ func lookupHandle(handle unsafe.Pointer) any {
|
||||
// deleteHandle releases a single handle created by newHandle. It is a no-op
|
||||
// if the handle is unknown (e.g. already released).
|
||||
func deleteHandle(handle unsafe.Pointer) {
|
||||
handleLock.Lock()
|
||||
defer handleLock.Unlock()
|
||||
|
||||
current := loadHandleVals()
|
||||
if _, ok := current[handle]; !ok {
|
||||
return
|
||||
if _, ok := handleVals.LoadAndDelete(handle); ok {
|
||||
C.free(handle)
|
||||
}
|
||||
next := make(map[unsafe.Pointer]handleVal, len(current)-1)
|
||||
for h, v := range current {
|
||||
if h == handle {
|
||||
continue
|
||||
}
|
||||
next[h] = v
|
||||
}
|
||||
handleVals.Store(next)
|
||||
C.free(handle)
|
||||
}
|
||||
|
||||
func deleteHandles(db *SQLiteConn) {
|
||||
handleLock.Lock()
|
||||
defer handleLock.Unlock()
|
||||
|
||||
current := loadHandleVals()
|
||||
if len(current) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
next := make(map[unsafe.Pointer]handleVal, len(current))
|
||||
for handle, val := range current {
|
||||
if val.db == db {
|
||||
C.free(handle)
|
||||
continue
|
||||
handleVals.Range(func(handle, val any) bool {
|
||||
if val.(handleVal).db == db {
|
||||
if _, ok := handleVals.LoadAndDelete(handle); ok {
|
||||
C.free(handle.(unsafe.Pointer))
|
||||
}
|
||||
}
|
||||
next[handle] = val
|
||||
}
|
||||
handleVals.Store(next)
|
||||
}
|
||||
|
||||
func loadHandleVals() map[unsafe.Pointer]handleVal {
|
||||
m, _ := handleVals.Load().(map[unsafe.Pointer]handleVal)
|
||||
return m
|
||||
}
|
||||
|
||||
func cloneHandleVals(size int) map[unsafe.Pointer]handleVal {
|
||||
next := make(map[unsafe.Pointer]handleVal, size)
|
||||
for handle, val := range loadHandleVals() {
|
||||
next[handle] = val
|
||||
}
|
||||
return next
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
// This is only here so that tests can refer to it.
|
||||
|
||||
+2
-2
@@ -159,7 +159,7 @@ func convertAssign(dest, src any) error {
|
||||
}
|
||||
|
||||
dpv := reflect.ValueOf(dest)
|
||||
if dpv.Kind() != reflect.Ptr {
|
||||
if dpv.Kind() != reflect.Pointer {
|
||||
return errors.New("destination not a pointer")
|
||||
}
|
||||
if dpv.IsNil() {
|
||||
@@ -192,7 +192,7 @@ func convertAssign(dest, src any) error {
|
||||
// This also allows scanning into user defined types such as "type Int int64".
|
||||
// For symmetry, also check for string destination types.
|
||||
switch dv.Kind() {
|
||||
case reflect.Ptr:
|
||||
case reflect.Pointer:
|
||||
if src == nil {
|
||||
dv.Set(reflect.Zero(dv.Type()))
|
||||
return nil
|
||||
|
||||
+183
-40
@@ -220,6 +220,25 @@ _sqlite3_prepare_v2_internal(sqlite3 *db, const char *zSql, int nBytes, sqlite3_
|
||||
}
|
||||
#endif
|
||||
|
||||
// Steps a statement once and reports the post-step column count and the
|
||||
// cumulative re-prepare count, in a single CGO crossing. Used for the
|
||||
// eager first step of cached statements: only after the first step is an
|
||||
// expired statement guaranteed to have been re-prepared following a
|
||||
// schema change, so only then do the column count and metadata describe
|
||||
// the current schema.
|
||||
static int
|
||||
_sqlite3_step_columns(sqlite3_stmt* stmt, int* ncol, int* repreps)
|
||||
{
|
||||
int rv = _sqlite3_step_internal(stmt);
|
||||
*ncol = sqlite3_column_count(stmt);
|
||||
#ifdef SQLITE_STMTSTATUS_REPREPARE
|
||||
*repreps = sqlite3_stmt_status(stmt, SQLITE_STMTSTATUS_REPREPARE, 0);
|
||||
#else
|
||||
*repreps = -1;
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
|
||||
void _sqlite3_result_text(sqlite3_context* ctx, const char* s, int n) {
|
||||
sqlite3_result_text(ctx, s, n, &free);
|
||||
}
|
||||
@@ -445,8 +464,11 @@ type SQLiteDriver struct {
|
||||
|
||||
// SQLiteConn implements driver.Conn.
|
||||
type SQLiteConn struct {
|
||||
mu sync.Mutex
|
||||
db *C.sqlite3
|
||||
mu sync.Mutex
|
||||
db *C.sqlite3
|
||||
// activeRows identifies the cancellable Rows currently calling sqlite3_step.
|
||||
// It is guarded by mu so a stale cancellation cannot interrupt later work.
|
||||
activeRows *SQLiteRows
|
||||
loc *time.Location
|
||||
txlock string
|
||||
funcs []*functionInfo
|
||||
@@ -477,6 +499,10 @@ type SQLiteStmt struct {
|
||||
namedParams map[string][3]int
|
||||
cacheKey string
|
||||
metadata *sqliteStmtMetadata
|
||||
// repreps is the statement's cumulative re-prepare count observed
|
||||
// at the last eager first step; a change means SQLite re-prepared
|
||||
// the statement after a schema change and metadata must be rebuilt.
|
||||
repreps C.int
|
||||
}
|
||||
|
||||
type sqliteStmtMetadata struct {
|
||||
@@ -492,14 +518,18 @@ type SQLiteResult struct {
|
||||
|
||||
// SQLiteRows implements driver.Rows.
|
||||
type SQLiteRows struct {
|
||||
s *SQLiteStmt
|
||||
nc int32 // Number of columns
|
||||
cls bool // True if we need to close the parent statement in Close
|
||||
cols []string
|
||||
decltype []string
|
||||
colvals *C.sqlite3_go_col
|
||||
ctx context.Context // no better alternative to pass context into Next() method
|
||||
closemu sync.Mutex
|
||||
s *SQLiteStmt
|
||||
nc int32 // Number of columns
|
||||
cls bool // True if we need to close the parent statement in Close
|
||||
cols []string
|
||||
decltype []string
|
||||
colvals *C.sqlite3_go_col
|
||||
ctx context.Context // no better alternative to pass context into Next() method
|
||||
stopCancellation func() bool
|
||||
// pendingStep buffers the result of the eager first step taken for
|
||||
// cached statements in query(); -1 when no step is buffered.
|
||||
pendingStep C.int
|
||||
closemu sync.Mutex
|
||||
}
|
||||
|
||||
type functionInfo struct {
|
||||
@@ -968,7 +998,7 @@ func (c *SQLiteConn) exec(ctx context.Context, query string, args []driver.Named
|
||||
na := s.NumInput()
|
||||
if len(args)-start < na {
|
||||
s.Close()
|
||||
return nil, fmt.Errorf("not enough args to execute query: want %d got %d", na, len(args))
|
||||
return nil, fmt.Errorf("not enough args to execute query: want %d got %d", na, len(args)-start)
|
||||
}
|
||||
stmtArgs := stmtArgs(args, start, na)
|
||||
res, err = s.(*SQLiteStmt).exec(ctx, stmtArgs)
|
||||
@@ -1609,6 +1639,18 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if conn.stmtCacheEnabled && int(C.sqlite3_libversion_number()) < 3020000 {
|
||||
// Schema-change detection for cached statements relies on
|
||||
// SQLITE_STMTSTATUS_REPREPARE (3.20.0); with an older runtime
|
||||
// library run without the cache rather than risk serving
|
||||
// statements whose metadata a schema change has expired. The
|
||||
// compile-time check in _sqlite3_step_columns is not enough:
|
||||
// with USE_LIBSQLITE3 the header and the runtime library can
|
||||
// differ.
|
||||
conn.stmtCache = nil
|
||||
conn.stmtCacheEnabled = false
|
||||
}
|
||||
|
||||
exec := func(s string) error {
|
||||
cs := C.CString(s)
|
||||
rv := C.sqlite3_exec(db, cs, nil, nil, nil)
|
||||
@@ -2354,13 +2396,24 @@ func (s *SQLiteStmt) query(ctx context.Context, args []driver.NamedValue) (drive
|
||||
}
|
||||
|
||||
rows := &SQLiteRows{
|
||||
s: s,
|
||||
nc: int32(C.sqlite3_column_count(s.s)),
|
||||
cls: s.cls,
|
||||
cols: nil,
|
||||
decltype: nil,
|
||||
colvals: nil,
|
||||
ctx: ctx,
|
||||
s: s,
|
||||
cls: s.cls,
|
||||
ctx: ctx,
|
||||
pendingStep: -1,
|
||||
}
|
||||
if s.cacheKey != "" {
|
||||
// A schema change expires cached statements and SQLite only
|
||||
// re-prepares them on their next step, so the column count and
|
||||
// metadata read before stepping could describe the old schema.
|
||||
// Take the query's first step eagerly (it was going to run at
|
||||
// the first Next anyway) and read them afterwards.
|
||||
rv, err := rows.eagerFirstStepLocked()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rows.pendingStep = rv
|
||||
} else {
|
||||
rows.nc = int32(C.sqlite3_column_count(s.s))
|
||||
}
|
||||
if rows.nc > 0 {
|
||||
rows.colvals = (*C.sqlite3_go_col)(C.malloc(C.size_t(rows.nc) * C.size_t(unsafe.Sizeof(C.sqlite3_go_col{}))))
|
||||
@@ -2466,6 +2519,7 @@ func (s *SQLiteStmt) Readonly() bool {
|
||||
func (rc *SQLiteRows) Close() error {
|
||||
rc.closemu.Lock()
|
||||
defer rc.closemu.Unlock()
|
||||
rc.stopWatchingCancellation()
|
||||
s := rc.s
|
||||
if s == nil {
|
||||
if rc.colvals != nil {
|
||||
@@ -2497,6 +2551,40 @@ func (rc *SQLiteRows) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *SQLiteConn) interruptActiveRows(rows *SQLiteRows) {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
if c.activeRows == rows && c.db != nil {
|
||||
C.sqlite3_interrupt(c.db)
|
||||
}
|
||||
}
|
||||
|
||||
func (rc *SQLiteRows) stopWatchingCancellation() {
|
||||
if rc.stopCancellation == nil {
|
||||
return
|
||||
}
|
||||
// A false return is harmless: a callback already in progress can interrupt
|
||||
// only while rc owns conn.activeRows, which is guarded by conn.mu.
|
||||
rc.stopCancellation()
|
||||
rc.stopCancellation = nil
|
||||
}
|
||||
|
||||
func (rc *SQLiteRows) startStepping() {
|
||||
conn := rc.s.c
|
||||
conn.mu.Lock()
|
||||
conn.activeRows = rc
|
||||
conn.mu.Unlock()
|
||||
}
|
||||
|
||||
func (rc *SQLiteRows) finishStepping() {
|
||||
conn := rc.s.c
|
||||
conn.mu.Lock()
|
||||
if conn.activeRows == rc {
|
||||
conn.activeRows = nil
|
||||
}
|
||||
conn.mu.Unlock()
|
||||
}
|
||||
|
||||
func (s *SQLiteStmt) cacheMetadata() bool {
|
||||
return !s.cls || s.cacheKey != ""
|
||||
}
|
||||
@@ -2583,33 +2671,88 @@ func (rc *SQLiteRows) Next(dest []driver.Value) error {
|
||||
return io.EOF
|
||||
}
|
||||
|
||||
if rc.ctx.Done() == nil {
|
||||
return rc.nextSyncLocked(dest)
|
||||
if rv := rc.pendingStep; rv >= 0 {
|
||||
rc.pendingStep = -1
|
||||
return rc.readStepResultLocked(dest, rv)
|
||||
}
|
||||
sema := make(chan struct{})
|
||||
var err error
|
||||
go func() {
|
||||
err = rc.nextSyncLocked(dest)
|
||||
close(sema)
|
||||
}()
|
||||
select {
|
||||
case <-sema:
|
||||
return err
|
||||
case <-rc.ctx.Done():
|
||||
select {
|
||||
case <-sema: // no need to interrupt
|
||||
default:
|
||||
// this is still racy and can be no-op if executed between sqlite3_* calls in nextSyncLocked.
|
||||
C.sqlite3_interrupt(rc.s.c.db)
|
||||
<-sema // ensure goroutine completed
|
||||
|
||||
if rc.stopCancellation == nil {
|
||||
if rc.ctx.Done() == nil {
|
||||
rv := C._sqlite3_step_internal(rc.s.s)
|
||||
return rc.readStepResultLocked(dest, rv)
|
||||
}
|
||||
return rc.ctx.Err()
|
||||
conn := rc.s.c
|
||||
rc.stopCancellation = context.AfterFunc(rc.ctx, func() {
|
||||
conn.interruptActiveRows(rc)
|
||||
})
|
||||
}
|
||||
if err := rc.ctx.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rv := rc.stepCancellableLocked()
|
||||
err := rc.readStepResultLocked(dest, rv)
|
||||
if ctxErr := rc.ctx.Err(); ctxErr != nil {
|
||||
return ctxErr
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// nextSyncLocked moves cursor to next; must be called with locked mutex.
|
||||
func (rc *SQLiteRows) nextSyncLocked(dest []driver.Value) error {
|
||||
rv := C._sqlite3_step_internal(rc.s.s)
|
||||
// eagerFirstStepLocked performs the first step of a cached statement
|
||||
// under the same cancellation rules as Next, records the post-step
|
||||
// column count, and drops the statement's cached metadata when SQLite
|
||||
// re-prepared it after a schema change. Note that this runs the first
|
||||
// step at query time, so a data-modifying statement issued through
|
||||
// Query executes even if Next is never called.
|
||||
func (rc *SQLiteRows) eagerFirstStepLocked() (C.int, error) {
|
||||
s := rc.s
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
if rc.ctx.Done() != nil && rc.stopCancellation == nil {
|
||||
conn := s.c
|
||||
rc.stopCancellation = context.AfterFunc(rc.ctx, func() {
|
||||
conn.interruptActiveRows(rc)
|
||||
})
|
||||
}
|
||||
if err := rc.ctx.Err(); err != nil {
|
||||
rc.stopWatchingCancellation()
|
||||
return 0, err
|
||||
}
|
||||
var ncol, repreps C.int
|
||||
var rv C.int
|
||||
if rc.ctx.Done() == nil {
|
||||
rv = C._sqlite3_step_columns(s.s, &ncol, &repreps)
|
||||
} else {
|
||||
rc.startStepping()
|
||||
rv = C._sqlite3_step_columns(s.s, &ncol, &repreps)
|
||||
rc.finishStepping()
|
||||
}
|
||||
if err := rc.ctx.Err(); err != nil {
|
||||
rc.stopWatchingCancellation()
|
||||
C._sqlite3_reset_clear(s.s)
|
||||
return 0, err
|
||||
}
|
||||
if rv != C.SQLITE_ROW && rv != C.SQLITE_DONE {
|
||||
rc.stopWatchingCancellation()
|
||||
err := s.c.lastError()
|
||||
C._sqlite3_reset_clear(s.s)
|
||||
return 0, err
|
||||
}
|
||||
rc.nc = int32(ncol)
|
||||
if repreps != s.repreps {
|
||||
s.repreps = repreps
|
||||
s.metadata = nil
|
||||
}
|
||||
return rv, nil
|
||||
}
|
||||
|
||||
func (rc *SQLiteRows) stepCancellableLocked() C.int {
|
||||
rc.startStepping()
|
||||
defer rc.finishStepping()
|
||||
return C._sqlite3_step_internal(rc.s.s)
|
||||
}
|
||||
|
||||
func (rc *SQLiteRows) readStepResultLocked(dest []driver.Value, rv C.int) error {
|
||||
if rv == C.SQLITE_DONE {
|
||||
return io.EOF
|
||||
}
|
||||
|
||||
+22
-24
@@ -11,43 +11,41 @@ import (
|
||||
"crypto/sha512"
|
||||
)
|
||||
|
||||
// This file provides several different implementations for the
|
||||
// default embedded sqlite_crypt function.
|
||||
// This function is uses a caesar-cypher by default
|
||||
// and is used within the UserAuthentication module to encode
|
||||
// the password.
|
||||
// This file provides several different implementations for the default
|
||||
// embedded sqlite_crypt function. This function uses a caesar-cypher by
|
||||
// default and is used within the UserAuthentication module to encode the
|
||||
// password.
|
||||
//
|
||||
// The provided functions can be used as an overload to the sqlite_crypt
|
||||
// function through the use of the RegisterFunc on the connection.
|
||||
//
|
||||
// Because the functions can serv a purpose to an end-user
|
||||
// without using the UserAuthentication module
|
||||
// the functions are default compiled in.
|
||||
// Because the functions can serve a purpose to an end-user without using the
|
||||
// UserAuthentication module the functions are default compiled in.
|
||||
//
|
||||
// From SQLITE3 - user-auth.txt
|
||||
// The sqlite_user.pw field is encoded by a built-in SQL function
|
||||
// "sqlite_crypt(X,Y)". The two arguments are both BLOBs. The first argument
|
||||
// is the plaintext password supplied to the sqlite3_user_authenticate()
|
||||
// interface. The second argument is the sqlite_user.pw value and is supplied
|
||||
// "sqlite_crypt(X,Y)". The two arguments are both BLOBs. The first argument is
|
||||
// the plain-text password supplied to the sqlite3_user_authenticate()
|
||||
// interface. The second argument is the sqlite_user.pw value and is supplied
|
||||
// so that the function can extract the "salt" used by the password encoder.
|
||||
// The result of sqlite_crypt(X,Y) is another blob which is the value that
|
||||
// ends up being stored in sqlite_user.pw. To verify credentials X supplied
|
||||
// by the sqlite3_user_authenticate() routine, SQLite runs:
|
||||
// The result of sqlite_crypt(X,Y) is another blob which is the value that ends
|
||||
// up being stored in sqlite_user.pw. To verify credentials X supplied by the
|
||||
// sqlite3_user_authenticate() routine, SQLite runs:
|
||||
//
|
||||
// sqlite_user.pw == sqlite_crypt(X, sqlite_user.pw)
|
||||
//
|
||||
// To compute an appropriate sqlite_user.pw value from a new or modified
|
||||
// password X, sqlite_crypt(X,NULL) is run. A new random salt is selected
|
||||
// when the second argument is NULL.
|
||||
// password X, sqlite_crypt(X,NULL) is run. A new random salt is selected when
|
||||
// the second argument is NULL.
|
||||
//
|
||||
// The built-in version of of sqlite_crypt() uses a simple Caesar-cypher
|
||||
// which prevents passwords from being revealed by searching the raw database
|
||||
// for ASCII text, but is otherwise trivally broken. For better password
|
||||
// security, the database should be encrypted using the SQLite Encryption
|
||||
// Extension or similar technology. Or, the application can use the
|
||||
// sqlite3_create_function() interface to provide an alternative
|
||||
// implementation of sqlite_crypt() that computes a stronger password hash,
|
||||
// perhaps using a cryptographic hash function like SHA1.
|
||||
// The built-in version of of sqlite_crypt() uses a simple Caesar-cypher which
|
||||
// prevents passwords from being revealed by searching the raw database for
|
||||
// ASCII text, but is otherwise trivally broken. For better password security,
|
||||
// the database should be encrypted using the SQLite Encryption Extension or
|
||||
// similar technology. Or, the application can use the
|
||||
// sqlite3_create_function() interface to provide an alternative implementation
|
||||
// of sqlite_crypt() that computes a stronger password hash, perhaps using a
|
||||
// cryptographic hash function like SHA1.
|
||||
|
||||
// CryptEncoderSHA1 encodes a password with SHA1
|
||||
func CryptEncoderSHA1(pass []byte, hash any) []byte {
|
||||
|
||||
-1
@@ -4,7 +4,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build libsqlite3
|
||||
// +build libsqlite3
|
||||
|
||||
package sqlite3
|
||||
|
||||
|
||||
-1
@@ -4,7 +4,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build sqlite_omit_load_extension
|
||||
// +build sqlite_omit_load_extension
|
||||
|
||||
package sqlite3
|
||||
|
||||
|
||||
-1
@@ -5,7 +5,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build sqlite_allow_uri_authority
|
||||
// +build sqlite_allow_uri_authority
|
||||
|
||||
package sqlite3
|
||||
|
||||
|
||||
-1
@@ -5,7 +5,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !windows && sqlite_app_armor
|
||||
// +build !windows,sqlite_app_armor
|
||||
|
||||
package sqlite3
|
||||
|
||||
|
||||
-1
@@ -1,5 +1,4 @@
|
||||
//go:build sqlite_column_metadata
|
||||
// +build sqlite_column_metadata
|
||||
|
||||
package sqlite3
|
||||
|
||||
|
||||
-1
@@ -5,7 +5,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build sqlite_dbstat
|
||||
// +build sqlite_dbstat
|
||||
|
||||
package sqlite3
|
||||
|
||||
|
||||
-1
@@ -5,7 +5,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build sqlite_foreign_keys
|
||||
// +build sqlite_foreign_keys
|
||||
|
||||
package sqlite3
|
||||
|
||||
|
||||
-1
@@ -4,7 +4,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build sqlite_fts5 || fts5
|
||||
// +build sqlite_fts5 fts5
|
||||
|
||||
package sqlite3
|
||||
|
||||
|
||||
-1
@@ -4,7 +4,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build sqlite_icu || icu
|
||||
// +build sqlite_icu icu
|
||||
|
||||
package sqlite3
|
||||
|
||||
|
||||
-1
@@ -5,7 +5,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build sqlite_introspect
|
||||
// +build sqlite_introspect
|
||||
|
||||
package sqlite3
|
||||
|
||||
|
||||
-1
@@ -4,7 +4,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build sqlite_math_functions
|
||||
// +build sqlite_math_functions
|
||||
|
||||
package sqlite3
|
||||
|
||||
|
||||
-1
@@ -4,7 +4,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build sqlite_os_trace
|
||||
// +build sqlite_os_trace
|
||||
|
||||
package sqlite3
|
||||
|
||||
|
||||
-1
@@ -5,7 +5,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build sqlite_percentile
|
||||
// +build sqlite_percentile
|
||||
|
||||
package sqlite3
|
||||
|
||||
|
||||
-1
@@ -5,7 +5,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build cgo
|
||||
// +build cgo
|
||||
|
||||
package sqlite3
|
||||
|
||||
|
||||
-1
@@ -5,7 +5,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build sqlite_preupdate_hook
|
||||
// +build sqlite_preupdate_hook
|
||||
|
||||
package sqlite3
|
||||
|
||||
|
||||
-1
@@ -5,7 +5,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !sqlite_preupdate_hook && cgo
|
||||
// +build !sqlite_preupdate_hook,cgo
|
||||
|
||||
package sqlite3
|
||||
|
||||
|
||||
-1
@@ -5,7 +5,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build sqlite_secure_delete
|
||||
// +build sqlite_secure_delete
|
||||
|
||||
package sqlite3
|
||||
|
||||
|
||||
-1
@@ -5,7 +5,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build sqlite_secure_delete_fast
|
||||
// +build sqlite_secure_delete_fast
|
||||
|
||||
package sqlite3
|
||||
|
||||
|
||||
-1
@@ -1,5 +1,4 @@
|
||||
//go:build libsqlite3 && !sqlite_serialize
|
||||
// +build libsqlite3,!sqlite_serialize
|
||||
|
||||
package sqlite3
|
||||
|
||||
|
||||
-1
@@ -5,7 +5,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build sqlite_stat4
|
||||
// +build sqlite_stat4
|
||||
|
||||
package sqlite3
|
||||
|
||||
|
||||
-1
@@ -4,7 +4,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build cgo && sqlite_unlock_notify
|
||||
// +build cgo,sqlite_unlock_notify
|
||||
|
||||
package sqlite3
|
||||
|
||||
|
||||
-1
@@ -4,7 +4,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build sqlite_userauth
|
||||
// +build sqlite_userauth
|
||||
|
||||
package sqlite3
|
||||
|
||||
|
||||
-1
@@ -5,7 +5,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build sqlite_vacuum_full
|
||||
// +build sqlite_vacuum_full
|
||||
|
||||
package sqlite3
|
||||
|
||||
|
||||
-1
@@ -5,7 +5,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build sqlite_vacuum_incr
|
||||
// +build sqlite_vacuum_incr
|
||||
|
||||
package sqlite3
|
||||
|
||||
|
||||
-1
@@ -4,7 +4,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build sqlite_vtable || vtable
|
||||
// +build sqlite_vtable vtable
|
||||
|
||||
package sqlite3
|
||||
|
||||
|
||||
-1
@@ -4,7 +4,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build solaris
|
||||
// +build solaris
|
||||
|
||||
package sqlite3
|
||||
|
||||
|
||||
-1
@@ -4,7 +4,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build cgo
|
||||
// +build cgo
|
||||
|
||||
package sqlite3
|
||||
|
||||
|
||||
-1
@@ -4,7 +4,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build sqlite_trace || trace
|
||||
// +build sqlite_trace trace
|
||||
|
||||
package sqlite3
|
||||
|
||||
|
||||
-1
@@ -4,7 +4,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build cgo
|
||||
// +build cgo
|
||||
|
||||
package sqlite3
|
||||
|
||||
|
||||
-1
@@ -4,7 +4,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package sqlite3
|
||||
|
||||
|
||||
-1
@@ -4,7 +4,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !cgo
|
||||
// +build !cgo
|
||||
|
||||
package sqlite3
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2013-2025 The NATS Authors
|
||||
// Copyright 2013-2026 The NATS Authors
|
||||
// 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
|
||||
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
Copyright (c) 2011 The LevelDB-Go Authors. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name of Google Inc. nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
// Copyright 2020-2023 The LevelDB-Go, Pebble and NATS Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be found in
|
||||
// the LICENSE file.
|
||||
|
||||
package fastrand
|
||||
|
||||
import _ "unsafe" // required by go:linkname
|
||||
|
||||
// Uint32 returns a lock free uint32 value.
|
||||
//
|
||||
//go:linkname Uint32 runtime.fastrand
|
||||
func Uint32() uint32
|
||||
|
||||
// Uint32n returns a lock free uint32 value in the interval [0, n).
|
||||
//
|
||||
//go:linkname Uint32n runtime.fastrandn
|
||||
func Uint32n(n uint32) uint32
|
||||
|
||||
// Uint64 returns a lock free uint64 value.
|
||||
func Uint64() uint64 {
|
||||
v := uint64(Uint32())
|
||||
return v<<32 | uint64(Uint32())
|
||||
}
|
||||
+31
-15
@@ -1,4 +1,4 @@
|
||||
// Copyright 2018-2025 The NATS Authors
|
||||
// Copyright 2018-2026 The NATS Authors
|
||||
// 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
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
"io"
|
||||
"io/fs"
|
||||
"math"
|
||||
"math/rand"
|
||||
"math/rand/v2"
|
||||
"net/http"
|
||||
"net/textproto"
|
||||
"reflect"
|
||||
@@ -34,7 +34,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/nats-io/jwt/v2"
|
||||
"github.com/nats-io/nats-server/v2/internal/fastrand"
|
||||
"github.com/nats-io/nkeys"
|
||||
"github.com/nats-io/nuid"
|
||||
)
|
||||
@@ -67,6 +66,7 @@ type Account struct {
|
||||
updated time.Time
|
||||
mu sync.RWMutex
|
||||
smu sync.Mutex // serializes route interest updates
|
||||
cmu sync.Mutex // serializes claim updates
|
||||
sl *Sublist
|
||||
ic *client
|
||||
sq *sendq
|
||||
@@ -802,7 +802,7 @@ func (a *Account) AddWeightedMappings(src string, dests ...*MapDest) error {
|
||||
m := &mapping{src: src, wc: subjectHasWildcard(src), dests: make([]*destination, 0, len(dests)+1)}
|
||||
seen := make(map[string]struct{})
|
||||
|
||||
var tw = make(map[string]uint8)
|
||||
tw := make(map[string]uint8)
|
||||
for _, d := range dests {
|
||||
if _, ok := seen[d.Subject]; ok {
|
||||
return fmt.Errorf("duplicate entry for %q", d.Subject)
|
||||
@@ -1006,7 +1006,7 @@ func (a *Account) selectMappedSubject(dest string) (string, bool) {
|
||||
if len(dests) == 1 && dests[0].weight == 100 {
|
||||
d = dests[0]
|
||||
} else {
|
||||
w := uint8(fastrand.Uint32n(100))
|
||||
w := uint8(rand.Uint32N(100))
|
||||
for _, rm := range dests {
|
||||
if w < rm.weight {
|
||||
d = rm
|
||||
@@ -1068,6 +1068,7 @@ func (a *Account) addClient(c *client) int {
|
||||
} else if c.kind == LEAF {
|
||||
a.nleafs++
|
||||
}
|
||||
isGlobal := a.Name == globalAccountName
|
||||
a.mu.Unlock()
|
||||
|
||||
// If we added a new leaf use the list lock and add it to the list.
|
||||
@@ -1077,7 +1078,7 @@ func (a *Account) addClient(c *client) int {
|
||||
a.lmu.Unlock()
|
||||
}
|
||||
|
||||
if c != nil && c.srv != nil {
|
||||
if !isGlobal && c != nil && c.srv != nil {
|
||||
c.srv.accConnsUpdate(a)
|
||||
}
|
||||
|
||||
@@ -1162,13 +1163,14 @@ func (a *Account) removeClient(c *client) int {
|
||||
}
|
||||
}
|
||||
}
|
||||
isGlobal := a.Name == globalAccountName
|
||||
a.mu.Unlock()
|
||||
|
||||
if c.kind == LEAF {
|
||||
a.removeLeafNode(c)
|
||||
}
|
||||
|
||||
if c != nil && c.srv != nil {
|
||||
if !isGlobal && c != nil && c.srv != nil {
|
||||
c.srv.accConnsUpdate(a)
|
||||
}
|
||||
|
||||
@@ -1217,7 +1219,8 @@ func (a *Account) AddServiceExportWithResponse(subject string, respType ServiceR
|
||||
|
||||
// AddServiceExportWithresponse will configure the account with the defined export and response type.
|
||||
func (a *Account) addServiceExportWithResponseAndAccountPos(
|
||||
subject string, respType ServiceRespType, accounts []*Account, accountPos uint) error {
|
||||
subject string, respType ServiceRespType, accounts []*Account, accountPos uint,
|
||||
) error {
|
||||
if a == nil {
|
||||
return ErrMissingAccount
|
||||
}
|
||||
@@ -2388,7 +2391,7 @@ func shouldSample(l *serviceLatency, c *client) (bool, http.Header) {
|
||||
if l.sampling >= 100 {
|
||||
return true, nil
|
||||
}
|
||||
if l.sampling > 0 && rand.Int31n(100) <= int32(l.sampling) {
|
||||
if l.sampling > 0 && rand.Int32N(100) <= int32(l.sampling) {
|
||||
return true, nil
|
||||
}
|
||||
h := c.parseState.getHeader()
|
||||
@@ -2480,8 +2483,8 @@ func (a *Account) processServiceImportResponse(sub *subscription, c *client, _ *
|
||||
// for all service replies, unless we are bound to a leafnode.
|
||||
// Lock should be held.
|
||||
func (a *Account) createRespWildcard() {
|
||||
var b = [baseServerLen]byte{'_', 'R', '_', '.'}
|
||||
rn := fastrand.Uint64()
|
||||
b := [baseServerLen]byte{'_', 'R', '_', '.'}
|
||||
rn := rand.Uint64()
|
||||
for i, l := replyPrefixLen, rn; i < len(b); i++ {
|
||||
b[i] = digits[l%base]
|
||||
l /= base
|
||||
@@ -2500,7 +2503,7 @@ func isTrackedReply(reply []byte) bool {
|
||||
func (a *Account) newServiceReply(tracking bool) []byte {
|
||||
a.mu.Lock()
|
||||
s := a.srv
|
||||
rn := fastrand.Uint64()
|
||||
rn := rand.Uint64()
|
||||
|
||||
// Check if we need to create the reply here.
|
||||
var createdSiReply bool
|
||||
@@ -3478,6 +3481,9 @@ func (s *Server) updateAccountClaimsWithRefresh(a *Account, ac *jwt.AccountClaim
|
||||
if a == nil {
|
||||
return
|
||||
}
|
||||
// Rebuilding the exports below empties them, so must not overlap with the
|
||||
// checks at the end that mark imports of other accounts invalid.
|
||||
a.cmu.Lock()
|
||||
s.Debugf("Updating account claims: %s/%s", a.Name, ac.Name)
|
||||
a.checkExpiration(ac.Claims())
|
||||
|
||||
@@ -3609,7 +3615,8 @@ func (s *Server) updateAccountClaimsWithRefresh(a *Account, ac *jwt.AccountClaim
|
||||
case jwt.Stream:
|
||||
s.Debugf("Adding stream export %q for %s", e.Subject, tl)
|
||||
if err := a.addStreamExportWithAccountPos(
|
||||
string(e.Subject), authAccounts(e.TokenReq), e.AccountTokenPosition); err != nil {
|
||||
string(e.Subject), authAccounts(e.TokenReq), e.AccountTokenPosition,
|
||||
); err != nil {
|
||||
s.Debugf("Error adding stream export to account [%s]: %v", tl, err.Error())
|
||||
}
|
||||
case jwt.Service:
|
||||
@@ -3622,7 +3629,8 @@ func (s *Server) updateAccountClaimsWithRefresh(a *Account, ac *jwt.AccountClaim
|
||||
rt = Chunked
|
||||
}
|
||||
if err := a.addServiceExportWithResponseAndAccountPos(
|
||||
string(e.Subject), rt, authAccounts(e.TokenReq), e.AccountTokenPosition); err != nil {
|
||||
string(e.Subject), rt, authAccounts(e.TokenReq), e.AccountTokenPosition,
|
||||
); err != nil {
|
||||
s.Debugf("Error adding service export to account [%s]: %v", tl, err)
|
||||
continue
|
||||
}
|
||||
@@ -3685,6 +3693,9 @@ func (s *Server) updateAccountClaimsWithRefresh(a *Account, ac *jwt.AccountClaim
|
||||
}
|
||||
a.mu.Unlock()
|
||||
}
|
||||
// Resolving the imports below can update this same account again.
|
||||
a.cmu.Unlock()
|
||||
|
||||
var incompleteImports []*jwt.Import
|
||||
for _, i := range ac.Imports {
|
||||
acc, err := s.lookupAccount(i.Account)
|
||||
@@ -3726,6 +3737,8 @@ func (s *Server) updateAccountClaimsWithRefresh(a *Account, ac *jwt.AccountClaim
|
||||
}
|
||||
}
|
||||
}
|
||||
a.cmu.Lock()
|
||||
|
||||
// Now let's apply any needed changes from import/export changes.
|
||||
if !a.checkStreamImportsEqual(old) {
|
||||
awcsti := map[string]struct{}{a.Name: {}}
|
||||
@@ -4037,6 +4050,9 @@ func (s *Server) updateAccountClaimsWithRefresh(a *Account, ac *jwt.AccountClaim
|
||||
}
|
||||
}
|
||||
|
||||
// Updating other accounts below takes their lock, so release ours first.
|
||||
a.cmu.Unlock()
|
||||
|
||||
if _, ok := s.incompleteAccExporterMap.Load(old.Name); ok && refreshImportingAccounts {
|
||||
s.incompleteAccExporterMap.Delete(old.Name)
|
||||
s.accounts.Range(func(key, value any) bool {
|
||||
@@ -4133,7 +4149,7 @@ func buildInternalNkeyUser(uc *jwt.UserClaims, acts map[string]struct{}, acc *Ac
|
||||
}
|
||||
|
||||
// Now check for permissions.
|
||||
var p = buildPermissionsFromJwt(&uc.Permissions)
|
||||
p := buildPermissionsFromJwt(&uc.Permissions)
|
||||
if p == nil {
|
||||
nu.defaultPerms = true
|
||||
acc.mu.RLock()
|
||||
|
||||
+356
@@ -0,0 +1,356 @@
|
||||
// Copyright 2026 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package archive
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"io"
|
||||
)
|
||||
|
||||
const MagicBytes = "NATSARC1"
|
||||
|
||||
// maxNameLen bounds the entry name length accepted when reading an archive,
|
||||
// avoiding an unbounded allocation on corrupt or malicious input. The name is
|
||||
// the only variable-length field read directly from the stream.
|
||||
const maxNameLen = 1 << 20
|
||||
|
||||
var (
|
||||
ErrClosed = errors.New("archive: closed")
|
||||
ErrInvalidArchive = errors.New("archive: invalid archive stream")
|
||||
ErrIncompleteEntry = errors.New("archive: entry not fully written")
|
||||
ErrNoActiveEntry = errors.New("archive: no active entry")
|
||||
ErrWriteTooLong = errors.New("archive: write exceeds declared entry size")
|
||||
ErrNilHeader = errors.New("archive: nil header")
|
||||
ErrNegativeEntrySize = errors.New("archive: negative entry size")
|
||||
)
|
||||
|
||||
// Header describes one archive entry.
|
||||
//
|
||||
// On the wire each entry is the encoded header fields followed by the payload.
|
||||
// HeaderSize and PayloadSize describe how that payload is split (e.g. message
|
||||
// headers vs. body); the payload length is their sum and is not stored
|
||||
// separately. Sequence is always encoded, with 0 meaning "unset".
|
||||
type Header struct {
|
||||
Name string
|
||||
HeaderSize int64
|
||||
PayloadSize int64
|
||||
Timestamp int64
|
||||
Sequence uint64
|
||||
}
|
||||
|
||||
func (h *Header) clone() *Header {
|
||||
if h == nil {
|
||||
return nil
|
||||
}
|
||||
c := *h
|
||||
return &c
|
||||
}
|
||||
|
||||
// Writer writes a stream of archive entries.
|
||||
type Writer struct {
|
||||
w io.Writer
|
||||
wroteMagic bool
|
||||
header *Header
|
||||
remaining int64
|
||||
closed bool
|
||||
}
|
||||
|
||||
// NewWriter returns a new stream writer.
|
||||
func NewWriter(w io.Writer) *Writer {
|
||||
return &Writer{w: w}
|
||||
}
|
||||
|
||||
// WriteHeader starts a new archive entry.
|
||||
func (a *Writer) WriteHeader(hdr *Header) error {
|
||||
if a.closed {
|
||||
return ErrClosed
|
||||
}
|
||||
if hdr == nil {
|
||||
return ErrNilHeader
|
||||
}
|
||||
if hdr.HeaderSize < 0 || hdr.PayloadSize < 0 {
|
||||
return ErrNegativeEntrySize
|
||||
}
|
||||
if a.header != nil && a.remaining > 0 {
|
||||
return ErrIncompleteEntry
|
||||
}
|
||||
totalPayloadSize := hdr.HeaderSize + hdr.PayloadSize
|
||||
if totalPayloadSize < 0 {
|
||||
return ErrNegativeEntrySize
|
||||
}
|
||||
if !a.wroteMagic {
|
||||
if _, err := io.WriteString(a.w, MagicBytes); err != nil {
|
||||
return err
|
||||
}
|
||||
a.wroteMagic = true
|
||||
}
|
||||
if err := a.writeUvarint(uint64(len(hdr.Name))); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := a.writeVarint(hdr.Timestamp); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := a.writeUvarint(hdr.Sequence); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := a.writeUvarint(uint64(hdr.HeaderSize)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := a.writeUvarint(uint64(hdr.PayloadSize)); err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := io.WriteString(a.w, hdr.Name); err != nil {
|
||||
return err
|
||||
}
|
||||
a.header = hdr.clone()
|
||||
a.remaining = totalPayloadSize
|
||||
if a.remaining == 0 {
|
||||
a.header = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Write writes payload bytes for the current entry.
|
||||
func (a *Writer) Write(p []byte) (int, error) {
|
||||
if a.closed {
|
||||
return 0, ErrClosed
|
||||
}
|
||||
if len(p) == 0 {
|
||||
return 0, nil
|
||||
}
|
||||
if a.header == nil {
|
||||
return 0, ErrNoActiveEntry
|
||||
}
|
||||
wanted := len(p)
|
||||
if int64(wanted) > a.remaining {
|
||||
wanted = int(a.remaining)
|
||||
}
|
||||
n, err := a.w.Write(p[:wanted])
|
||||
a.remaining -= int64(n)
|
||||
if err != nil {
|
||||
return n, err
|
||||
}
|
||||
if n < wanted {
|
||||
return n, io.ErrShortWrite
|
||||
}
|
||||
if len(p) > wanted {
|
||||
if a.remaining == 0 {
|
||||
a.header = nil
|
||||
}
|
||||
return n, ErrWriteTooLong
|
||||
}
|
||||
if a.remaining == 0 {
|
||||
a.header = nil
|
||||
}
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// Close finalizes the stream writer.
|
||||
func (a *Writer) Close() error {
|
||||
if a.closed {
|
||||
return nil
|
||||
}
|
||||
a.closed = true
|
||||
if a.header != nil && a.remaining > 0 {
|
||||
return ErrIncompleteEntry
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Flush flushes the underlying writer if it supports flushing.
|
||||
func (a *Writer) Flush() error {
|
||||
if a.closed {
|
||||
return ErrClosed
|
||||
}
|
||||
if f, ok := a.w.(interface{ Flush() error }); ok {
|
||||
return f.Flush()
|
||||
}
|
||||
if f, ok := a.w.(interface{ Flush() }); ok {
|
||||
f.Flush()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Reader reads a stream of archive entries.
|
||||
type Reader struct {
|
||||
r *bufio.Reader
|
||||
header *Header
|
||||
remaining int64
|
||||
seenMagic bool
|
||||
err error
|
||||
}
|
||||
|
||||
// NewReader returns a new stream reader.
|
||||
func NewReader(r io.Reader) *Reader {
|
||||
return &Reader{r: bufio.NewReader(r)}
|
||||
}
|
||||
|
||||
func (u *Reader) discardCurrent() error {
|
||||
if u.remaining == 0 {
|
||||
u.header = nil
|
||||
return nil
|
||||
}
|
||||
_, err := io.CopyN(io.Discard, u.r, u.remaining)
|
||||
u.remaining = 0
|
||||
u.header = nil
|
||||
if errors.Is(err, io.EOF) || errors.Is(err, io.ErrUnexpectedEOF) {
|
||||
return ErrInvalidArchive
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// Next advances to the next entry and returns its header.
|
||||
func (u *Reader) Next() (*Header, error) {
|
||||
if u.err != nil {
|
||||
return nil, u.err
|
||||
}
|
||||
if err := u.discardCurrent(); err != nil {
|
||||
u.err = err
|
||||
return nil, err
|
||||
}
|
||||
if !u.seenMagic {
|
||||
magic := make([]byte, len(MagicBytes))
|
||||
if _, err := io.ReadFull(u.r, magic); err != nil {
|
||||
if errors.Is(err, io.EOF) || errors.Is(err, io.ErrUnexpectedEOF) {
|
||||
u.err = io.EOF
|
||||
return nil, io.EOF
|
||||
}
|
||||
u.err = err
|
||||
return nil, err
|
||||
}
|
||||
if string(magic) != MagicBytes {
|
||||
u.err = ErrInvalidArchive
|
||||
return nil, ErrInvalidArchive
|
||||
}
|
||||
u.seenMagic = true
|
||||
}
|
||||
// A clean io.EOF on the first field is the normal end of the stream.
|
||||
nameLen, err := u.readUvarint()
|
||||
if err != nil {
|
||||
u.err = err
|
||||
return nil, err
|
||||
}
|
||||
timestamp, err := u.readVarint()
|
||||
if err != nil {
|
||||
u.err = noEOF(err)
|
||||
return nil, u.err
|
||||
}
|
||||
sequence, err := u.readUvarint()
|
||||
if err != nil {
|
||||
u.err = noEOF(err)
|
||||
return nil, u.err
|
||||
}
|
||||
headerSize, err := u.readUvarint()
|
||||
if err != nil {
|
||||
u.err = noEOF(err)
|
||||
return nil, u.err
|
||||
}
|
||||
payloadSize, err := u.readUvarint()
|
||||
if err != nil {
|
||||
u.err = noEOF(err)
|
||||
return nil, u.err
|
||||
}
|
||||
// HeaderSize/PayloadSize are stored as int64: a value above MaxInt64
|
||||
// converts to a negative int64, and an overflowing sum lands negative too,
|
||||
// so the sign checks below cover both cases.
|
||||
hdrSize, plSize := int64(headerSize), int64(payloadSize)
|
||||
total := hdrSize + plSize
|
||||
if nameLen > maxNameLen || hdrSize < 0 || plSize < 0 || total < 0 {
|
||||
u.err = ErrInvalidArchive
|
||||
return nil, ErrInvalidArchive
|
||||
}
|
||||
name := make([]byte, nameLen)
|
||||
if _, err := io.ReadFull(u.r, name); err != nil {
|
||||
u.err = ErrInvalidArchive
|
||||
return nil, ErrInvalidArchive
|
||||
}
|
||||
u.header = &Header{
|
||||
Name: string(name),
|
||||
Timestamp: timestamp,
|
||||
Sequence: sequence,
|
||||
HeaderSize: hdrSize,
|
||||
PayloadSize: plSize,
|
||||
}
|
||||
u.remaining = total
|
||||
return u.header.clone(), nil
|
||||
}
|
||||
|
||||
// Read reads bytes from the current entry payload.
|
||||
func (u *Reader) Read(p []byte) (int, error) {
|
||||
if u.err != nil {
|
||||
return 0, u.err
|
||||
}
|
||||
if len(p) == 0 {
|
||||
return 0, nil
|
||||
}
|
||||
if u.header == nil || u.remaining == 0 {
|
||||
return 0, io.EOF
|
||||
}
|
||||
|
||||
if int64(len(p)) > u.remaining {
|
||||
p = p[:int(u.remaining)]
|
||||
}
|
||||
n, err := io.ReadFull(u.r, p)
|
||||
u.remaining -= int64(n)
|
||||
if err != nil {
|
||||
u.err = ErrInvalidArchive
|
||||
return n, ErrInvalidArchive
|
||||
}
|
||||
if u.remaining == 0 {
|
||||
u.header = nil
|
||||
}
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// noEOF converts a clean io.EOF into ErrInvalidArchive. It is used for header
|
||||
// fields after the first: reaching EOF there means the entry was truncated
|
||||
// rather than that the stream ended cleanly on an entry boundary.
|
||||
func noEOF(err error) error {
|
||||
if err != nil && errors.Is(err, io.EOF) {
|
||||
return ErrInvalidArchive
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (a *Writer) writeVarint(v int64) error {
|
||||
var tmp [binary.MaxVarintLen64]byte
|
||||
n := binary.PutVarint(tmp[:], v)
|
||||
_, err := a.w.Write(tmp[:n])
|
||||
return err
|
||||
}
|
||||
|
||||
func (a *Writer) writeUvarint(v uint64) error {
|
||||
var tmp [binary.MaxVarintLen64]byte
|
||||
n := binary.PutUvarint(tmp[:], v)
|
||||
_, err := a.w.Write(tmp[:n])
|
||||
return err
|
||||
}
|
||||
|
||||
func (u *Reader) readVarint() (int64, error) {
|
||||
v, err := binary.ReadVarint(u.r)
|
||||
if err != nil && !errors.Is(err, io.EOF) {
|
||||
return v, ErrInvalidArchive
|
||||
}
|
||||
return v, err
|
||||
}
|
||||
|
||||
func (u *Reader) readUvarint() (uint64, error) {
|
||||
v, err := binary.ReadUvarint(u.r)
|
||||
if err != nil && !errors.Is(err, io.EOF) {
|
||||
return v, ErrInvalidArchive
|
||||
}
|
||||
return v, err
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2012-2025 The NATS Authors
|
||||
// Copyright 2012-2026 The NATS Authors
|
||||
// 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
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022-2025 The NATS Authors
|
||||
// Copyright 2022-2026 The NATS Authors
|
||||
// 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
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2023-2025 The NATS Authors
|
||||
// Copyright 2023-2026 The NATS Authors
|
||||
// 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
|
||||
|
||||
Loaded 100 of 302 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user