Merge pull request #5610 from thaJeztah/27.x_backport_moby_deps

[27.x backport] dependency updates for moby/moby
This commit is contained in:
Sebastiaan van Stijn 2024-11-14 10:27:53 +01:00 committed by GitHub
commit 2958a27e0f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
115 changed files with 1679 additions and 2228 deletions

View File

@ -49,7 +49,7 @@ require (
go.opentelemetry.io/otel/sdk/metric v1.21.0 go.opentelemetry.io/otel/sdk/metric v1.21.0
go.opentelemetry.io/otel/trace v1.21.0 go.opentelemetry.io/otel/trace v1.21.0
golang.org/x/sync v0.8.0 golang.org/x/sync v0.8.0
golang.org/x/sys v0.25.0 golang.org/x/sys v0.26.0
golang.org/x/term v0.24.0 golang.org/x/term v0.24.0
golang.org/x/text v0.18.0 golang.org/x/text v0.18.0
gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v2 v2.4.0
@ -75,7 +75,7 @@ require (
github.com/gorilla/mux v1.8.1 // indirect github.com/gorilla/mux v1.8.1 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/klauspost/compress v1.17.9 // indirect github.com/klauspost/compress v1.17.11 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/miekg/pkcs11 v1.1.1 // indirect github.com/miekg/pkcs11 v1.1.1 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect github.com/moby/docker-image-spec v1.3.1 // indirect
@ -101,5 +101,5 @@ require (
google.golang.org/genproto/googleapis/api v0.0.0-20240604185151-ef581f913117 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240604185151-ef581f913117 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 // indirect
google.golang.org/grpc v1.66.2 // indirect google.golang.org/grpc v1.66.2 // indirect
google.golang.org/protobuf v1.34.1 // indirect google.golang.org/protobuf v1.35.1 // indirect
) )

View File

@ -151,8 +151,8 @@ github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7V
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= 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/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
@ -385,8 +385,8 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= 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.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@ -425,8 +425,8 @@ google.golang.org/grpc v1.66.2 h1:3QdXkuq3Bkh7w+ywLdLvM56cmGvQHUMZpiCzt6Rqaoo=
google.golang.org/grpc v1.66.2/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y= google.golang.org/grpc v1.66.2/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/cenkalti/backoff.v2 v2.2.1 h1:eJ9UAg01/HIHG987TwxvnzK2MgxXq97YY6rYDpY9aII= gopkg.in/cenkalti/backoff.v2 v2.2.1 h1:eJ9UAg01/HIHG987TwxvnzK2MgxXq97YY6rYDpY9aII=

View File

@ -1,5 +1,5 @@
# This is an example goreleaser.yaml file with some sane defaults. version: 2
# Make sure to check the documentation at http://goreleaser.com
before: before:
hooks: hooks:
- ./gen.sh - ./gen.sh
@ -99,7 +99,7 @@ archives:
checksum: checksum:
name_template: 'checksums.txt' name_template: 'checksums.txt'
snapshot: snapshot:
name_template: "{{ .Tag }}-next" version_template: "{{ .Tag }}-next"
changelog: changelog:
sort: asc sort: asc
filters: filters:

View File

@ -16,6 +16,27 @@ This package provides various compression algorithms.
# changelog # changelog
* Sep 23rd, 2024 - [1.17.10](https://github.com/klauspost/compress/releases/tag/v1.17.10)
* gzhttp: Add TransportAlwaysDecompress option. https://github.com/klauspost/compress/pull/978
* gzhttp: Add supported decompress request body by @mirecl in https://github.com/klauspost/compress/pull/1002
* s2: Add EncodeBuffer buffer recycling callback https://github.com/klauspost/compress/pull/982
* zstd: Improve memory usage on small streaming encodes https://github.com/klauspost/compress/pull/1007
* flate: read data written with partial flush by @vajexal in https://github.com/klauspost/compress/pull/996
* Jun 12th, 2024 - [1.17.9](https://github.com/klauspost/compress/releases/tag/v1.17.9)
* s2: Reduce ReadFrom temporary allocations https://github.com/klauspost/compress/pull/949
* flate, zstd: Shave some bytes off amd64 matchLen by @greatroar in https://github.com/klauspost/compress/pull/963
* Upgrade zip/zlib to 1.22.4 upstream https://github.com/klauspost/compress/pull/970 https://github.com/klauspost/compress/pull/971
* zstd: BuildDict fails with RLE table https://github.com/klauspost/compress/pull/951
* Apr 9th, 2024 - [1.17.8](https://github.com/klauspost/compress/releases/tag/v1.17.8)
* zstd: Reject blocks where reserved values are not 0 https://github.com/klauspost/compress/pull/885
* zstd: Add RLE detection+encoding https://github.com/klauspost/compress/pull/938
* Feb 21st, 2024 - [1.17.7](https://github.com/klauspost/compress/releases/tag/v1.17.7)
* s2: Add AsyncFlush method: Complete the block without flushing by @Jille in https://github.com/klauspost/compress/pull/927
* s2: Fix literal+repeat exceeds dst crash https://github.com/klauspost/compress/pull/930
* Feb 5th, 2024 - [1.17.6](https://github.com/klauspost/compress/releases/tag/v1.17.6) * Feb 5th, 2024 - [1.17.6](https://github.com/klauspost/compress/releases/tag/v1.17.6)
* zstd: Fix incorrect repeat coding in best mode https://github.com/klauspost/compress/pull/923 * zstd: Fix incorrect repeat coding in best mode https://github.com/klauspost/compress/pull/923
* s2: Fix DecodeConcurrent deadlock on errors https://github.com/klauspost/compress/pull/925 * s2: Fix DecodeConcurrent deadlock on errors https://github.com/klauspost/compress/pull/925
@ -81,7 +102,7 @@ https://github.com/klauspost/compress/pull/919 https://github.com/klauspost/comp
* zstd: Various minor improvements by @greatroar in https://github.com/klauspost/compress/pull/788 https://github.com/klauspost/compress/pull/794 https://github.com/klauspost/compress/pull/795 * zstd: Various minor improvements by @greatroar in https://github.com/klauspost/compress/pull/788 https://github.com/klauspost/compress/pull/794 https://github.com/klauspost/compress/pull/795
* s2: Fix huge block overflow https://github.com/klauspost/compress/pull/779 * s2: Fix huge block overflow https://github.com/klauspost/compress/pull/779
* s2: Allow CustomEncoder fallback https://github.com/klauspost/compress/pull/780 * s2: Allow CustomEncoder fallback https://github.com/klauspost/compress/pull/780
* gzhttp: Suppport ResponseWriter Unwrap() in gzhttp handler by @jgimenez in https://github.com/klauspost/compress/pull/799 * gzhttp: Support ResponseWriter Unwrap() in gzhttp handler by @jgimenez in https://github.com/klauspost/compress/pull/799
* Mar 13, 2023 - [v1.16.1](https://github.com/klauspost/compress/releases/tag/v1.16.1) * Mar 13, 2023 - [v1.16.1](https://github.com/klauspost/compress/releases/tag/v1.16.1)
* zstd: Speed up + improve best encoder by @greatroar in https://github.com/klauspost/compress/pull/776 * zstd: Speed up + improve best encoder by @greatroar in https://github.com/klauspost/compress/pull/776
@ -136,7 +157,7 @@ https://github.com/klauspost/compress/pull/919 https://github.com/klauspost/comp
* zstd: Add [WithDecodeAllCapLimit](https://pkg.go.dev/github.com/klauspost/compress@v1.15.10/zstd#WithDecodeAllCapLimit) https://github.com/klauspost/compress/pull/649 * zstd: Add [WithDecodeAllCapLimit](https://pkg.go.dev/github.com/klauspost/compress@v1.15.10/zstd#WithDecodeAllCapLimit) https://github.com/klauspost/compress/pull/649
* Add Go 1.19 - deprecate Go 1.16 https://github.com/klauspost/compress/pull/651 * Add Go 1.19 - deprecate Go 1.16 https://github.com/klauspost/compress/pull/651
* flate: Improve level 5+6 compression https://github.com/klauspost/compress/pull/656 * flate: Improve level 5+6 compression https://github.com/klauspost/compress/pull/656
* zstd: Improve "better" compresssion https://github.com/klauspost/compress/pull/657 * zstd: Improve "better" compression https://github.com/klauspost/compress/pull/657
* s2: Improve "best" compression https://github.com/klauspost/compress/pull/658 * s2: Improve "best" compression https://github.com/klauspost/compress/pull/658
* s2: Improve "better" compression. https://github.com/klauspost/compress/pull/635 * s2: Improve "better" compression. https://github.com/klauspost/compress/pull/635
* s2: Slightly faster non-assembly decompression https://github.com/klauspost/compress/pull/646 * s2: Slightly faster non-assembly decompression https://github.com/klauspost/compress/pull/646
@ -339,7 +360,7 @@ While the release has been extensively tested, it is recommended to testing when
* s2: Fix binaries. * s2: Fix binaries.
* Feb 25, 2021 (v1.11.8) * Feb 25, 2021 (v1.11.8)
* s2: Fixed occational out-of-bounds write on amd64. Upgrade recommended. * s2: Fixed occasional out-of-bounds write on amd64. Upgrade recommended.
* s2: Add AMD64 assembly for better mode. 25-50% faster. [#315](https://github.com/klauspost/compress/pull/315) * s2: Add AMD64 assembly for better mode. 25-50% faster. [#315](https://github.com/klauspost/compress/pull/315)
* s2: Less upfront decoder allocation. [#322](https://github.com/klauspost/compress/pull/322) * s2: Less upfront decoder allocation. [#322](https://github.com/klauspost/compress/pull/322)
* zstd: Faster "compression" of incompressible data. [#314](https://github.com/klauspost/compress/pull/314) * zstd: Faster "compression" of incompressible data. [#314](https://github.com/klauspost/compress/pull/314)
@ -518,7 +539,7 @@ While the release has been extensively tested, it is recommended to testing when
* Feb 19, 2016: Faster bit writer, level -2 is 15% faster, level 1 is 4% faster. * Feb 19, 2016: Faster bit writer, level -2 is 15% faster, level 1 is 4% faster.
* Feb 19, 2016: Handle small payloads faster in level 1-3. * Feb 19, 2016: Handle small payloads faster in level 1-3.
* Feb 19, 2016: Added faster level 2 + 3 compression modes. * Feb 19, 2016: Added faster level 2 + 3 compression modes.
* Feb 19, 2016: [Rebalanced compression levels](https://blog.klauspost.com/rebalancing-deflate-compression-levels/), so there is a more even progresssion in terms of compression. New default level is 5. * Feb 19, 2016: [Rebalanced compression levels](https://blog.klauspost.com/rebalancing-deflate-compression-levels/), so there is a more even progression in terms of compression. New default level is 5.
* Feb 14, 2016: Snappy: Merge upstream changes. * Feb 14, 2016: Snappy: Merge upstream changes.
* Feb 14, 2016: Snappy: Fix aggressive skipping. * Feb 14, 2016: Snappy: Fix aggressive skipping.
* Feb 14, 2016: Snappy: Update benchmark. * Feb 14, 2016: Snappy: Update benchmark.

View File

@ -15,7 +15,7 @@ const (
// It is possible, but by no way guaranteed that corrupt data will // It is possible, but by no way guaranteed that corrupt data will
// return an error. // return an error.
// It is up to the caller to verify integrity of the returned data. // It is up to the caller to verify integrity of the returned data.
// Use a predefined Scrach to set maximum acceptable output size. // Use a predefined Scratch to set maximum acceptable output size.
func Decompress(b []byte, s *Scratch) ([]byte, error) { func Decompress(b []byte, s *Scratch) ([]byte, error) {
s, err := s.prepare(b) s, err := s.prepare(b)
if err != nil { if err != nil {

View File

@ -1136,7 +1136,7 @@ func (s *Scratch) matches(ct cTable, w io.Writer) {
errs++ errs++
} }
if errs > 0 { if errs > 0 {
fmt.Fprintf(w, "%d errros in base, stopping\n", errs) fmt.Fprintf(w, "%d errors in base, stopping\n", errs)
continue continue
} }
// Ensure that all combinations are covered. // Ensure that all combinations are covered.
@ -1152,7 +1152,7 @@ func (s *Scratch) matches(ct cTable, w io.Writer) {
errs++ errs++
} }
if errs > 20 { if errs > 20 {
fmt.Fprintf(w, "%d errros, stopping\n", errs) fmt.Fprintf(w, "%d errors, stopping\n", errs)
break break
} }
} }

View File

@ -598,7 +598,9 @@ func (b *blockDec) prepareSequences(in []byte, hist *history) (err error) {
printf("RLE set to 0x%x, code: %v", symb, v) printf("RLE set to 0x%x, code: %v", symb, v)
} }
case compModeFSE: case compModeFSE:
println("Reading table for", tableIndex(i)) if debugDecoder {
println("Reading table for", tableIndex(i))
}
if seq.fse == nil || seq.fse.preDefined { if seq.fse == nil || seq.fse.preDefined {
seq.fse = fseDecoderPool.Get().(*fseDecoder) seq.fse = fseDecoderPool.Get().(*fseDecoder)
} }

View File

@ -179,9 +179,9 @@ encodeLoop:
if repIndex >= 0 && load3232(src, repIndex) == uint32(cv>>(repOff*8)) { if repIndex >= 0 && load3232(src, repIndex) == uint32(cv>>(repOff*8)) {
// Consider history as well. // Consider history as well.
var seq seq var seq seq
lenght := 4 + e.matchlen(s+4+repOff, repIndex+4, src) length := 4 + e.matchlen(s+4+repOff, repIndex+4, src)
seq.matchLen = uint32(lenght - zstdMinMatch) seq.matchLen = uint32(length - zstdMinMatch)
// We might be able to match backwards. // We might be able to match backwards.
// Extend as long as we can. // Extend as long as we can.
@ -210,12 +210,12 @@ encodeLoop:
// Index match start+1 (long) -> s - 1 // Index match start+1 (long) -> s - 1
index0 := s + repOff index0 := s + repOff
s += lenght + repOff s += length + repOff
nextEmit = s nextEmit = s
if s >= sLimit { if s >= sLimit {
if debugEncoder { if debugEncoder {
println("repeat ended", s, lenght) println("repeat ended", s, length)
} }
break encodeLoop break encodeLoop
@ -241,9 +241,9 @@ encodeLoop:
if false && repIndex >= 0 && load6432(src, repIndex) == load6432(src, s+repOff) { if false && repIndex >= 0 && load6432(src, repIndex) == load6432(src, s+repOff) {
// Consider history as well. // Consider history as well.
var seq seq var seq seq
lenght := 8 + e.matchlen(s+8+repOff2, repIndex+8, src) length := 8 + e.matchlen(s+8+repOff2, repIndex+8, src)
seq.matchLen = uint32(lenght - zstdMinMatch) seq.matchLen = uint32(length - zstdMinMatch)
// We might be able to match backwards. // We might be able to match backwards.
// Extend as long as we can. // Extend as long as we can.
@ -270,11 +270,11 @@ encodeLoop:
} }
blk.sequences = append(blk.sequences, seq) blk.sequences = append(blk.sequences, seq)
s += lenght + repOff2 s += length + repOff2
nextEmit = s nextEmit = s
if s >= sLimit { if s >= sLimit {
if debugEncoder { if debugEncoder {
println("repeat ended", s, lenght) println("repeat ended", s, length)
} }
break encodeLoop break encodeLoop
@ -708,9 +708,9 @@ encodeLoop:
if repIndex >= 0 && load3232(src, repIndex) == uint32(cv>>(repOff*8)) { if repIndex >= 0 && load3232(src, repIndex) == uint32(cv>>(repOff*8)) {
// Consider history as well. // Consider history as well.
var seq seq var seq seq
lenght := 4 + e.matchlen(s+4+repOff, repIndex+4, src) length := 4 + e.matchlen(s+4+repOff, repIndex+4, src)
seq.matchLen = uint32(lenght - zstdMinMatch) seq.matchLen = uint32(length - zstdMinMatch)
// We might be able to match backwards. // We might be able to match backwards.
// Extend as long as we can. // Extend as long as we can.
@ -738,12 +738,12 @@ encodeLoop:
blk.sequences = append(blk.sequences, seq) blk.sequences = append(blk.sequences, seq)
// Index match start+1 (long) -> s - 1 // Index match start+1 (long) -> s - 1
s += lenght + repOff s += length + repOff
nextEmit = s nextEmit = s
if s >= sLimit { if s >= sLimit {
if debugEncoder { if debugEncoder {
println("repeat ended", s, lenght) println("repeat ended", s, length)
} }
break encodeLoop break encodeLoop
@ -772,9 +772,9 @@ encodeLoop:
if false && repIndex >= 0 && load6432(src, repIndex) == load6432(src, s+repOff) { if false && repIndex >= 0 && load6432(src, repIndex) == load6432(src, s+repOff) {
// Consider history as well. // Consider history as well.
var seq seq var seq seq
lenght := 8 + e.matchlen(s+8+repOff2, repIndex+8, src) length := 8 + e.matchlen(s+8+repOff2, repIndex+8, src)
seq.matchLen = uint32(lenght - zstdMinMatch) seq.matchLen = uint32(length - zstdMinMatch)
// We might be able to match backwards. // We might be able to match backwards.
// Extend as long as we can. // Extend as long as we can.
@ -801,11 +801,11 @@ encodeLoop:
} }
blk.sequences = append(blk.sequences, seq) blk.sequences = append(blk.sequences, seq)
s += lenght + repOff2 s += length + repOff2
nextEmit = s nextEmit = s
if s >= sLimit { if s >= sLimit {
if debugEncoder { if debugEncoder {
println("repeat ended", s, lenght) println("repeat ended", s, length)
} }
break encodeLoop break encodeLoop

View File

@ -138,9 +138,9 @@ encodeLoop:
if repIndex >= 0 && load3232(src, repIndex) == uint32(cv>>(repOff*8)) { if repIndex >= 0 && load3232(src, repIndex) == uint32(cv>>(repOff*8)) {
// Consider history as well. // Consider history as well.
var seq seq var seq seq
lenght := 4 + e.matchlen(s+4+repOff, repIndex+4, src) length := 4 + e.matchlen(s+4+repOff, repIndex+4, src)
seq.matchLen = uint32(lenght - zstdMinMatch) seq.matchLen = uint32(length - zstdMinMatch)
// We might be able to match backwards. // We might be able to match backwards.
// Extend as long as we can. // Extend as long as we can.
@ -166,11 +166,11 @@ encodeLoop:
println("repeat sequence", seq, "next s:", s) println("repeat sequence", seq, "next s:", s)
} }
blk.sequences = append(blk.sequences, seq) blk.sequences = append(blk.sequences, seq)
s += lenght + repOff s += length + repOff
nextEmit = s nextEmit = s
if s >= sLimit { if s >= sLimit {
if debugEncoder { if debugEncoder {
println("repeat ended", s, lenght) println("repeat ended", s, length)
} }
break encodeLoop break encodeLoop
@ -798,9 +798,9 @@ encodeLoop:
if repIndex >= 0 && load3232(src, repIndex) == uint32(cv>>(repOff*8)) { if repIndex >= 0 && load3232(src, repIndex) == uint32(cv>>(repOff*8)) {
// Consider history as well. // Consider history as well.
var seq seq var seq seq
lenght := 4 + e.matchlen(s+4+repOff, repIndex+4, src) length := 4 + e.matchlen(s+4+repOff, repIndex+4, src)
seq.matchLen = uint32(lenght - zstdMinMatch) seq.matchLen = uint32(length - zstdMinMatch)
// We might be able to match backwards. // We might be able to match backwards.
// Extend as long as we can. // Extend as long as we can.
@ -826,11 +826,11 @@ encodeLoop:
println("repeat sequence", seq, "next s:", s) println("repeat sequence", seq, "next s:", s)
} }
blk.sequences = append(blk.sequences, seq) blk.sequences = append(blk.sequences, seq)
s += lenght + repOff s += length + repOff
nextEmit = s nextEmit = s
if s >= sLimit { if s >= sLimit {
if debugEncoder { if debugEncoder {
println("repeat ended", s, lenght) println("repeat ended", s, length)
} }
break encodeLoop break encodeLoop

View File

@ -6,6 +6,7 @@ package zstd
import ( import (
"crypto/rand" "crypto/rand"
"errors"
"fmt" "fmt"
"io" "io"
"math" "math"
@ -149,6 +150,9 @@ func (e *Encoder) ResetContentSize(w io.Writer, size int64) {
// and write CRC if requested. // and write CRC if requested.
func (e *Encoder) Write(p []byte) (n int, err error) { func (e *Encoder) Write(p []byte) (n int, err error) {
s := &e.state s := &e.state
if s.eofWritten {
return 0, ErrEncoderClosed
}
for len(p) > 0 { for len(p) > 0 {
if len(p)+len(s.filling) < e.o.blockSize { if len(p)+len(s.filling) < e.o.blockSize {
if e.o.crc { if e.o.crc {
@ -202,7 +206,7 @@ func (e *Encoder) nextBlock(final bool) error {
return nil return nil
} }
if final && len(s.filling) > 0 { if final && len(s.filling) > 0 {
s.current = e.EncodeAll(s.filling, s.current[:0]) s.current = e.encodeAll(s.encoder, s.filling, s.current[:0])
var n2 int var n2 int
n2, s.err = s.w.Write(s.current) n2, s.err = s.w.Write(s.current)
if s.err != nil { if s.err != nil {
@ -288,6 +292,9 @@ func (e *Encoder) nextBlock(final bool) error {
s.filling, s.current, s.previous = s.previous[:0], s.filling, s.current s.filling, s.current, s.previous = s.previous[:0], s.filling, s.current
s.nInput += int64(len(s.current)) s.nInput += int64(len(s.current))
s.wg.Add(1) s.wg.Add(1)
if final {
s.eofWritten = true
}
go func(src []byte) { go func(src []byte) {
if debugEncoder { if debugEncoder {
println("Adding block,", len(src), "bytes, final:", final) println("Adding block,", len(src), "bytes, final:", final)
@ -303,9 +310,6 @@ func (e *Encoder) nextBlock(final bool) error {
blk := enc.Block() blk := enc.Block()
enc.Encode(blk, src) enc.Encode(blk, src)
blk.last = final blk.last = final
if final {
s.eofWritten = true
}
// Wait for pending writes. // Wait for pending writes.
s.wWg.Wait() s.wWg.Wait()
if s.writeErr != nil { if s.writeErr != nil {
@ -401,12 +405,20 @@ func (e *Encoder) Flush() error {
if len(s.filling) > 0 { if len(s.filling) > 0 {
err := e.nextBlock(false) err := e.nextBlock(false)
if err != nil { if err != nil {
// Ignore Flush after Close.
if errors.Is(s.err, ErrEncoderClosed) {
return nil
}
return err return err
} }
} }
s.wg.Wait() s.wg.Wait()
s.wWg.Wait() s.wWg.Wait()
if s.err != nil { if s.err != nil {
// Ignore Flush after Close.
if errors.Is(s.err, ErrEncoderClosed) {
return nil
}
return s.err return s.err
} }
return s.writeErr return s.writeErr
@ -422,6 +434,9 @@ func (e *Encoder) Close() error {
} }
err := e.nextBlock(true) err := e.nextBlock(true)
if err != nil { if err != nil {
if errors.Is(s.err, ErrEncoderClosed) {
return nil
}
return err return err
} }
if s.frameContentSize > 0 { if s.frameContentSize > 0 {
@ -459,6 +474,11 @@ func (e *Encoder) Close() error {
} }
_, s.err = s.w.Write(frame) _, s.err = s.w.Write(frame)
} }
if s.err == nil {
s.err = ErrEncoderClosed
return nil
}
return s.err return s.err
} }
@ -469,6 +489,15 @@ func (e *Encoder) Close() error {
// Data compressed with EncodeAll can be decoded with the Decoder, // Data compressed with EncodeAll can be decoded with the Decoder,
// using either a stream or DecodeAll. // using either a stream or DecodeAll.
func (e *Encoder) EncodeAll(src, dst []byte) []byte { func (e *Encoder) EncodeAll(src, dst []byte) []byte {
e.init.Do(e.initialize)
enc := <-e.encoders
defer func() {
e.encoders <- enc
}()
return e.encodeAll(enc, src, dst)
}
func (e *Encoder) encodeAll(enc encoder, src, dst []byte) []byte {
if len(src) == 0 { if len(src) == 0 {
if e.o.fullZero { if e.o.fullZero {
// Add frame header. // Add frame header.
@ -491,13 +520,7 @@ func (e *Encoder) EncodeAll(src, dst []byte) []byte {
} }
return dst return dst
} }
e.init.Do(e.initialize)
enc := <-e.encoders
defer func() {
// Release encoder reference to last block.
// If a non-single block is needed the encoder will reset again.
e.encoders <- enc
}()
// Use single segments when above minimum window and below window size. // Use single segments when above minimum window and below window size.
single := len(src) <= e.o.windowSize && len(src) > MinWindowSize single := len(src) <= e.o.windowSize && len(src) > MinWindowSize
if e.o.single != nil { if e.o.single != nil {

View File

@ -146,7 +146,9 @@ func (d *frameDec) reset(br byteBuffer) error {
} }
return err return err
} }
printf("raw: %x, mantissa: %d, exponent: %d\n", wd, wd&7, wd>>3) if debugDecoder {
printf("raw: %x, mantissa: %d, exponent: %d\n", wd, wd&7, wd>>3)
}
windowLog := 10 + (wd >> 3) windowLog := 10 + (wd >> 3)
windowBase := uint64(1) << windowLog windowBase := uint64(1) << windowLog
windowAdd := (windowBase / 8) * uint64(wd&0x7) windowAdd := (windowBase / 8) * uint64(wd&0x7)

View File

@ -146,7 +146,7 @@ func (s *sequenceDecs) decodeSyncSimple(hist []byte) (bool, error) {
return true, fmt.Errorf("output bigger than max block size (%d)", maxBlockSize) return true, fmt.Errorf("output bigger than max block size (%d)", maxBlockSize)
default: default:
return true, fmt.Errorf("sequenceDecs_decode returned erronous code %d", errCode) return true, fmt.Errorf("sequenceDecs_decode returned erroneous code %d", errCode)
} }
s.seqSize += ctx.litRemain s.seqSize += ctx.litRemain
@ -292,7 +292,7 @@ func (s *sequenceDecs) decode(seqs []seqVals) error {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
return fmt.Errorf("sequenceDecs_decode_amd64 returned erronous code %d", errCode) return fmt.Errorf("sequenceDecs_decode_amd64 returned erroneous code %d", errCode)
} }
if ctx.litRemain < 0 { if ctx.litRemain < 0 {

View File

@ -1814,7 +1814,7 @@ TEXT ·sequenceDecs_decodeSync_amd64(SB), $64-32
MOVQ 40(SP), AX MOVQ 40(SP), AX
ADDQ AX, 48(SP) ADDQ AX, 48(SP)
// Calculate poiter to s.out[cap(s.out)] (a past-end pointer) // Calculate pointer to s.out[cap(s.out)] (a past-end pointer)
ADDQ R10, 32(SP) ADDQ R10, 32(SP)
// outBase += outPosition // outBase += outPosition
@ -2376,7 +2376,7 @@ TEXT ·sequenceDecs_decodeSync_bmi2(SB), $64-32
MOVQ 40(SP), CX MOVQ 40(SP), CX
ADDQ CX, 48(SP) ADDQ CX, 48(SP)
// Calculate poiter to s.out[cap(s.out)] (a past-end pointer) // Calculate pointer to s.out[cap(s.out)] (a past-end pointer)
ADDQ R9, 32(SP) ADDQ R9, 32(SP)
// outBase += outPosition // outBase += outPosition
@ -2896,7 +2896,7 @@ TEXT ·sequenceDecs_decodeSync_safe_amd64(SB), $64-32
MOVQ 40(SP), AX MOVQ 40(SP), AX
ADDQ AX, 48(SP) ADDQ AX, 48(SP)
// Calculate poiter to s.out[cap(s.out)] (a past-end pointer) // Calculate pointer to s.out[cap(s.out)] (a past-end pointer)
ADDQ R10, 32(SP) ADDQ R10, 32(SP)
// outBase += outPosition // outBase += outPosition
@ -3560,7 +3560,7 @@ TEXT ·sequenceDecs_decodeSync_safe_bmi2(SB), $64-32
MOVQ 40(SP), CX MOVQ 40(SP), CX
ADDQ CX, 48(SP) ADDQ CX, 48(SP)
// Calculate poiter to s.out[cap(s.out)] (a past-end pointer) // Calculate pointer to s.out[cap(s.out)] (a past-end pointer)
ADDQ R9, 32(SP) ADDQ R9, 32(SP)
// outBase += outPosition // outBase += outPosition

View File

@ -88,6 +88,10 @@ var (
// Close has been called. // Close has been called.
ErrDecoderClosed = errors.New("decoder used after Close") ErrDecoderClosed = errors.New("decoder used after Close")
// ErrEncoderClosed will be returned if the Encoder was used after
// Close has been called.
ErrEncoderClosed = errors.New("encoder used after Close")
// ErrDecoderNilInput is returned when a nil Reader was provided // ErrDecoderNilInput is returned when a nil Reader was provided
// and an operation other than Reset/DecodeAll/Close was attempted. // and an operation other than Reset/DecodeAll/Close was attempted.
ErrDecoderNilInput = errors.New("nil input provided as reader") ErrDecoderNilInput = errors.New("nil input provided as reader")

View File

@ -156,7 +156,7 @@ from the generated architecture-specific files listed below, and merge these
into a common file for each OS. into a common file for each OS.
The merge is performed in the following steps: The merge is performed in the following steps:
1. Construct the set of common code that is idential in all architecture-specific files. 1. Construct the set of common code that is identical in all architecture-specific files.
2. Write this common code to the merged file. 2. Write this common code to the merged file.
3. Remove the common code from all architecture-specific files. 3. Remove the common code from all architecture-specific files.

View File

@ -656,7 +656,7 @@ errors=$(
signals=$( signals=$(
echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags | echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print $2 }' | awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print $2 }' |
grep -v 'SIGSTKSIZE\|SIGSTKSZ\|SIGRT\|SIGMAX64' | grep -E -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT|SIGMAX64)' |
sort sort
) )
@ -666,7 +666,7 @@ echo '#include <errno.h>' | $CC -x c - -E -dM $ccflags |
sort >_error.grep sort >_error.grep
echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags | echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print "^\t" $2 "[ \t]*=" }' | awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print "^\t" $2 "[ \t]*=" }' |
grep -v 'SIGSTKSIZE\|SIGSTKSZ\|SIGRT\|SIGMAX64' | grep -E -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT|SIGMAX64)' |
sort >_signal.grep sort >_signal.grep
echo '// mkerrors.sh' "$@" echo '// mkerrors.sh' "$@"

View File

@ -360,7 +360,7 @@ func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int,
var status _C_int var status _C_int
var r Pid_t var r Pid_t
err = ERESTART err = ERESTART
// AIX wait4 may return with ERESTART errno, while the processus is still // AIX wait4 may return with ERESTART errno, while the process is still
// active. // active.
for err == ERESTART { for err == ERESTART {
r, err = wait4(Pid_t(pid), &status, options, rusage) r, err = wait4(Pid_t(pid), &status, options, rusage)

View File

@ -1295,6 +1295,48 @@ func GetsockoptTCPInfo(fd, level, opt int) (*TCPInfo, error) {
return &value, err return &value, err
} }
// GetsockoptTCPCCVegasInfo returns algorithm specific congestion control information for a socket using the "vegas"
// algorithm.
//
// The socket's congestion control algorighm can be retrieved via [GetsockoptString] with the [TCP_CONGESTION] option:
//
// algo, err := unix.GetsockoptString(fd, unix.IPPROTO_TCP, unix.TCP_CONGESTION)
func GetsockoptTCPCCVegasInfo(fd, level, opt int) (*TCPVegasInfo, error) {
var value [SizeofTCPCCInfo / 4]uint32 // ensure proper alignment
vallen := _Socklen(SizeofTCPCCInfo)
err := getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen)
out := (*TCPVegasInfo)(unsafe.Pointer(&value[0]))
return out, err
}
// GetsockoptTCPCCDCTCPInfo returns algorithm specific congestion control information for a socket using the "dctp"
// algorithm.
//
// The socket's congestion control algorighm can be retrieved via [GetsockoptString] with the [TCP_CONGESTION] option:
//
// algo, err := unix.GetsockoptString(fd, unix.IPPROTO_TCP, unix.TCP_CONGESTION)
func GetsockoptTCPCCDCTCPInfo(fd, level, opt int) (*TCPDCTCPInfo, error) {
var value [SizeofTCPCCInfo / 4]uint32 // ensure proper alignment
vallen := _Socklen(SizeofTCPCCInfo)
err := getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen)
out := (*TCPDCTCPInfo)(unsafe.Pointer(&value[0]))
return out, err
}
// GetsockoptTCPCCBBRInfo returns algorithm specific congestion control information for a socket using the "bbr"
// algorithm.
//
// The socket's congestion control algorighm can be retrieved via [GetsockoptString] with the [TCP_CONGESTION] option:
//
// algo, err := unix.GetsockoptString(fd, unix.IPPROTO_TCP, unix.TCP_CONGESTION)
func GetsockoptTCPCCBBRInfo(fd, level, opt int) (*TCPBBRInfo, error) {
var value [SizeofTCPCCInfo / 4]uint32 // ensure proper alignment
vallen := _Socklen(SizeofTCPCCInfo)
err := getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen)
out := (*TCPBBRInfo)(unsafe.Pointer(&value[0]))
return out, err
}
// GetsockoptString returns the string value of the socket option opt for the // GetsockoptString returns the string value of the socket option opt for the
// socket associated with fd at the given socket level. // socket associated with fd at the given socket level.
func GetsockoptString(fd, level, opt int) (string, error) { func GetsockoptString(fd, level, opt int) (string, error) {
@ -1959,7 +2001,26 @@ func Getpgrp() (pid int) {
//sysnb Getpid() (pid int) //sysnb Getpid() (pid int)
//sysnb Getppid() (ppid int) //sysnb Getppid() (ppid int)
//sys Getpriority(which int, who int) (prio int, err error) //sys Getpriority(which int, who int) (prio int, err error)
//sys Getrandom(buf []byte, flags int) (n int, err error)
func Getrandom(buf []byte, flags int) (n int, err error) {
vdsoRet, supported := vgetrandom(buf, uint32(flags))
if supported {
if vdsoRet < 0 {
return 0, errnoErr(syscall.Errno(-vdsoRet))
}
return vdsoRet, nil
}
var p *byte
if len(buf) > 0 {
p = &buf[0]
}
r, _, e := Syscall(SYS_GETRANDOM, uintptr(unsafe.Pointer(p)), uintptr(len(buf)), uintptr(flags))
if e != 0 {
return 0, errnoErr(e)
}
return int(r), nil
}
//sysnb Getrusage(who int, rusage *Rusage) (err error) //sysnb Getrusage(who int, rusage *Rusage) (err error)
//sysnb Getsid(pid int) (sid int, err error) //sysnb Getsid(pid int) (sid int, err error)
//sysnb Gettid() (tid int) //sysnb Gettid() (tid int)

View File

@ -182,3 +182,5 @@ func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error
} }
return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags) return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags)
} }
const SYS_FSTATAT = SYS_NEWFSTATAT

View File

@ -214,3 +214,5 @@ func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error
} }
return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags) return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags)
} }
const SYS_FSTATAT = SYS_NEWFSTATAT

View File

@ -187,3 +187,5 @@ func RISCVHWProbe(pairs []RISCVHWProbePairs, set *CPUSet, flags uint) (err error
} }
return riscvHWProbe(pairs, setSize, set, flags) return riscvHWProbe(pairs, setSize, set, flags)
} }
const SYS_FSTATAT = SYS_NEWFSTATAT

13
vendor/golang.org/x/sys/unix/vgetrandom_linux.go generated vendored Normal file
View File

@ -0,0 +1,13 @@
// Copyright 2024 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build linux && go1.24
package unix
import _ "unsafe"
//go:linkname vgetrandom runtime.vgetrandom
//go:noescape
func vgetrandom(p []byte, flags uint32) (ret int, supported bool)

11
vendor/golang.org/x/sys/unix/vgetrandom_unsupported.go generated vendored Normal file
View File

@ -0,0 +1,11 @@
// Copyright 2024 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build !linux || !go1.24
package unix
func vgetrandom(p []byte, flags uint32) (ret int, supported bool) {
return -1, false
}

View File

@ -495,6 +495,7 @@ const (
BPF_F_TEST_REG_INVARIANTS = 0x80 BPF_F_TEST_REG_INVARIANTS = 0x80
BPF_F_TEST_RND_HI32 = 0x4 BPF_F_TEST_RND_HI32 = 0x4
BPF_F_TEST_RUN_ON_CPU = 0x1 BPF_F_TEST_RUN_ON_CPU = 0x1
BPF_F_TEST_SKB_CHECKSUM_COMPLETE = 0x4
BPF_F_TEST_STATE_FREQ = 0x8 BPF_F_TEST_STATE_FREQ = 0x8
BPF_F_TEST_XDP_LIVE_FRAMES = 0x2 BPF_F_TEST_XDP_LIVE_FRAMES = 0x2
BPF_F_XDP_DEV_BOUND_ONLY = 0x40 BPF_F_XDP_DEV_BOUND_ONLY = 0x40
@ -1922,6 +1923,7 @@ const (
MNT_EXPIRE = 0x4 MNT_EXPIRE = 0x4
MNT_FORCE = 0x1 MNT_FORCE = 0x1
MNT_ID_REQ_SIZE_VER0 = 0x18 MNT_ID_REQ_SIZE_VER0 = 0x18
MNT_ID_REQ_SIZE_VER1 = 0x20
MODULE_INIT_COMPRESSED_FILE = 0x4 MODULE_INIT_COMPRESSED_FILE = 0x4
MODULE_INIT_IGNORE_MODVERSIONS = 0x1 MODULE_INIT_IGNORE_MODVERSIONS = 0x1
MODULE_INIT_IGNORE_VERMAGIC = 0x2 MODULE_INIT_IGNORE_VERMAGIC = 0x2
@ -2187,7 +2189,7 @@ const (
NFT_REG_SIZE = 0x10 NFT_REG_SIZE = 0x10
NFT_REJECT_ICMPX_MAX = 0x3 NFT_REJECT_ICMPX_MAX = 0x3
NFT_RT_MAX = 0x4 NFT_RT_MAX = 0x4
NFT_SECMARK_CTX_MAXLEN = 0x100 NFT_SECMARK_CTX_MAXLEN = 0x1000
NFT_SET_MAXNAMELEN = 0x100 NFT_SET_MAXNAMELEN = 0x100
NFT_SOCKET_MAX = 0x3 NFT_SOCKET_MAX = 0x3
NFT_TABLE_F_MASK = 0x7 NFT_TABLE_F_MASK = 0x7
@ -2356,9 +2358,11 @@ const (
PERF_MEM_LVLNUM_IO = 0xa PERF_MEM_LVLNUM_IO = 0xa
PERF_MEM_LVLNUM_L1 = 0x1 PERF_MEM_LVLNUM_L1 = 0x1
PERF_MEM_LVLNUM_L2 = 0x2 PERF_MEM_LVLNUM_L2 = 0x2
PERF_MEM_LVLNUM_L2_MHB = 0x5
PERF_MEM_LVLNUM_L3 = 0x3 PERF_MEM_LVLNUM_L3 = 0x3
PERF_MEM_LVLNUM_L4 = 0x4 PERF_MEM_LVLNUM_L4 = 0x4
PERF_MEM_LVLNUM_LFB = 0xc PERF_MEM_LVLNUM_LFB = 0xc
PERF_MEM_LVLNUM_MSC = 0x6
PERF_MEM_LVLNUM_NA = 0xf PERF_MEM_LVLNUM_NA = 0xf
PERF_MEM_LVLNUM_PMEM = 0xe PERF_MEM_LVLNUM_PMEM = 0xe
PERF_MEM_LVLNUM_RAM = 0xd PERF_MEM_LVLNUM_RAM = 0xd
@ -2431,6 +2435,7 @@ const (
PRIO_PGRP = 0x1 PRIO_PGRP = 0x1
PRIO_PROCESS = 0x0 PRIO_PROCESS = 0x0
PRIO_USER = 0x2 PRIO_USER = 0x2
PROCFS_IOCTL_MAGIC = 'f'
PROC_SUPER_MAGIC = 0x9fa0 PROC_SUPER_MAGIC = 0x9fa0
PROT_EXEC = 0x4 PROT_EXEC = 0x4
PROT_GROWSDOWN = 0x1000000 PROT_GROWSDOWN = 0x1000000
@ -2933,11 +2938,12 @@ const (
RUSAGE_SELF = 0x0 RUSAGE_SELF = 0x0
RUSAGE_THREAD = 0x1 RUSAGE_THREAD = 0x1
RWF_APPEND = 0x10 RWF_APPEND = 0x10
RWF_ATOMIC = 0x40
RWF_DSYNC = 0x2 RWF_DSYNC = 0x2
RWF_HIPRI = 0x1 RWF_HIPRI = 0x1
RWF_NOAPPEND = 0x20 RWF_NOAPPEND = 0x20
RWF_NOWAIT = 0x8 RWF_NOWAIT = 0x8
RWF_SUPPORTED = 0x3f RWF_SUPPORTED = 0x7f
RWF_SYNC = 0x4 RWF_SYNC = 0x4
RWF_WRITE_LIFE_NOT_SET = 0x0 RWF_WRITE_LIFE_NOT_SET = 0x0
SCHED_BATCH = 0x3 SCHED_BATCH = 0x3
@ -3210,6 +3216,7 @@ const (
STATX_ATTR_MOUNT_ROOT = 0x2000 STATX_ATTR_MOUNT_ROOT = 0x2000
STATX_ATTR_NODUMP = 0x40 STATX_ATTR_NODUMP = 0x40
STATX_ATTR_VERITY = 0x100000 STATX_ATTR_VERITY = 0x100000
STATX_ATTR_WRITE_ATOMIC = 0x400000
STATX_BASIC_STATS = 0x7ff STATX_BASIC_STATS = 0x7ff
STATX_BLOCKS = 0x400 STATX_BLOCKS = 0x400
STATX_BTIME = 0x800 STATX_BTIME = 0x800
@ -3226,6 +3233,7 @@ const (
STATX_SUBVOL = 0x8000 STATX_SUBVOL = 0x8000
STATX_TYPE = 0x1 STATX_TYPE = 0x1
STATX_UID = 0x8 STATX_UID = 0x8
STATX_WRITE_ATOMIC = 0x10000
STATX__RESERVED = 0x80000000 STATX__RESERVED = 0x80000000
SYNC_FILE_RANGE_WAIT_AFTER = 0x4 SYNC_FILE_RANGE_WAIT_AFTER = 0x4
SYNC_FILE_RANGE_WAIT_BEFORE = 0x1 SYNC_FILE_RANGE_WAIT_BEFORE = 0x1
@ -3624,6 +3632,7 @@ const (
XDP_UMEM_PGOFF_COMPLETION_RING = 0x180000000 XDP_UMEM_PGOFF_COMPLETION_RING = 0x180000000
XDP_UMEM_PGOFF_FILL_RING = 0x100000000 XDP_UMEM_PGOFF_FILL_RING = 0x100000000
XDP_UMEM_REG = 0x4 XDP_UMEM_REG = 0x4
XDP_UMEM_TX_METADATA_LEN = 0x4
XDP_UMEM_TX_SW_CSUM = 0x2 XDP_UMEM_TX_SW_CSUM = 0x2
XDP_UMEM_UNALIGNED_CHUNK_FLAG = 0x1 XDP_UMEM_UNALIGNED_CHUNK_FLAG = 0x1
XDP_USE_NEED_WAKEUP = 0x8 XDP_USE_NEED_WAKEUP = 0x8

View File

@ -153,9 +153,14 @@ const (
NFDBITS = 0x20 NFDBITS = 0x20
NLDLY = 0x100 NLDLY = 0x100
NOFLSH = 0x80 NOFLSH = 0x80
NS_GET_MNTNS_ID = 0x8008b705
NS_GET_NSTYPE = 0xb703 NS_GET_NSTYPE = 0xb703
NS_GET_OWNER_UID = 0xb704 NS_GET_OWNER_UID = 0xb704
NS_GET_PARENT = 0xb702 NS_GET_PARENT = 0xb702
NS_GET_PID_FROM_PIDNS = 0x8004b706
NS_GET_PID_IN_PIDNS = 0x8004b708
NS_GET_TGID_FROM_PIDNS = 0x8004b707
NS_GET_TGID_IN_PIDNS = 0x8004b709
NS_GET_USERNS = 0xb701 NS_GET_USERNS = 0xb701
OLCUC = 0x2 OLCUC = 0x2
ONLCR = 0x4 ONLCR = 0x4

View File

@ -153,9 +153,14 @@ const (
NFDBITS = 0x40 NFDBITS = 0x40
NLDLY = 0x100 NLDLY = 0x100
NOFLSH = 0x80 NOFLSH = 0x80
NS_GET_MNTNS_ID = 0x8008b705
NS_GET_NSTYPE = 0xb703 NS_GET_NSTYPE = 0xb703
NS_GET_OWNER_UID = 0xb704 NS_GET_OWNER_UID = 0xb704
NS_GET_PARENT = 0xb702 NS_GET_PARENT = 0xb702
NS_GET_PID_FROM_PIDNS = 0x8004b706
NS_GET_PID_IN_PIDNS = 0x8004b708
NS_GET_TGID_FROM_PIDNS = 0x8004b707
NS_GET_TGID_IN_PIDNS = 0x8004b709
NS_GET_USERNS = 0xb701 NS_GET_USERNS = 0xb701
OLCUC = 0x2 OLCUC = 0x2
ONLCR = 0x4 ONLCR = 0x4

View File

@ -150,9 +150,14 @@ const (
NFDBITS = 0x20 NFDBITS = 0x20
NLDLY = 0x100 NLDLY = 0x100
NOFLSH = 0x80 NOFLSH = 0x80
NS_GET_MNTNS_ID = 0x8008b705
NS_GET_NSTYPE = 0xb703 NS_GET_NSTYPE = 0xb703
NS_GET_OWNER_UID = 0xb704 NS_GET_OWNER_UID = 0xb704
NS_GET_PARENT = 0xb702 NS_GET_PARENT = 0xb702
NS_GET_PID_FROM_PIDNS = 0x8004b706
NS_GET_PID_IN_PIDNS = 0x8004b708
NS_GET_TGID_FROM_PIDNS = 0x8004b707
NS_GET_TGID_IN_PIDNS = 0x8004b709
NS_GET_USERNS = 0xb701 NS_GET_USERNS = 0xb701
OLCUC = 0x2 OLCUC = 0x2
ONLCR = 0x4 ONLCR = 0x4

View File

@ -154,9 +154,14 @@ const (
NFDBITS = 0x40 NFDBITS = 0x40
NLDLY = 0x100 NLDLY = 0x100
NOFLSH = 0x80 NOFLSH = 0x80
NS_GET_MNTNS_ID = 0x8008b705
NS_GET_NSTYPE = 0xb703 NS_GET_NSTYPE = 0xb703
NS_GET_OWNER_UID = 0xb704 NS_GET_OWNER_UID = 0xb704
NS_GET_PARENT = 0xb702 NS_GET_PARENT = 0xb702
NS_GET_PID_FROM_PIDNS = 0x8004b706
NS_GET_PID_IN_PIDNS = 0x8004b708
NS_GET_TGID_FROM_PIDNS = 0x8004b707
NS_GET_TGID_IN_PIDNS = 0x8004b709
NS_GET_USERNS = 0xb701 NS_GET_USERNS = 0xb701
OLCUC = 0x2 OLCUC = 0x2
ONLCR = 0x4 ONLCR = 0x4

View File

@ -154,9 +154,14 @@ const (
NFDBITS = 0x40 NFDBITS = 0x40
NLDLY = 0x100 NLDLY = 0x100
NOFLSH = 0x80 NOFLSH = 0x80
NS_GET_MNTNS_ID = 0x8008b705
NS_GET_NSTYPE = 0xb703 NS_GET_NSTYPE = 0xb703
NS_GET_OWNER_UID = 0xb704 NS_GET_OWNER_UID = 0xb704
NS_GET_PARENT = 0xb702 NS_GET_PARENT = 0xb702
NS_GET_PID_FROM_PIDNS = 0x8004b706
NS_GET_PID_IN_PIDNS = 0x8004b708
NS_GET_TGID_FROM_PIDNS = 0x8004b707
NS_GET_TGID_IN_PIDNS = 0x8004b709
NS_GET_USERNS = 0xb701 NS_GET_USERNS = 0xb701
OLCUC = 0x2 OLCUC = 0x2
ONLCR = 0x4 ONLCR = 0x4

View File

@ -150,9 +150,14 @@ const (
NFDBITS = 0x20 NFDBITS = 0x20
NLDLY = 0x100 NLDLY = 0x100
NOFLSH = 0x80 NOFLSH = 0x80
NS_GET_MNTNS_ID = 0x4008b705
NS_GET_NSTYPE = 0x2000b703 NS_GET_NSTYPE = 0x2000b703
NS_GET_OWNER_UID = 0x2000b704 NS_GET_OWNER_UID = 0x2000b704
NS_GET_PARENT = 0x2000b702 NS_GET_PARENT = 0x2000b702
NS_GET_PID_FROM_PIDNS = 0x4004b706
NS_GET_PID_IN_PIDNS = 0x4004b708
NS_GET_TGID_FROM_PIDNS = 0x4004b707
NS_GET_TGID_IN_PIDNS = 0x4004b709
NS_GET_USERNS = 0x2000b701 NS_GET_USERNS = 0x2000b701
OLCUC = 0x2 OLCUC = 0x2
ONLCR = 0x4 ONLCR = 0x4

View File

@ -150,9 +150,14 @@ const (
NFDBITS = 0x40 NFDBITS = 0x40
NLDLY = 0x100 NLDLY = 0x100
NOFLSH = 0x80 NOFLSH = 0x80
NS_GET_MNTNS_ID = 0x4008b705
NS_GET_NSTYPE = 0x2000b703 NS_GET_NSTYPE = 0x2000b703
NS_GET_OWNER_UID = 0x2000b704 NS_GET_OWNER_UID = 0x2000b704
NS_GET_PARENT = 0x2000b702 NS_GET_PARENT = 0x2000b702
NS_GET_PID_FROM_PIDNS = 0x4004b706
NS_GET_PID_IN_PIDNS = 0x4004b708
NS_GET_TGID_FROM_PIDNS = 0x4004b707
NS_GET_TGID_IN_PIDNS = 0x4004b709
NS_GET_USERNS = 0x2000b701 NS_GET_USERNS = 0x2000b701
OLCUC = 0x2 OLCUC = 0x2
ONLCR = 0x4 ONLCR = 0x4

View File

@ -150,9 +150,14 @@ const (
NFDBITS = 0x40 NFDBITS = 0x40
NLDLY = 0x100 NLDLY = 0x100
NOFLSH = 0x80 NOFLSH = 0x80
NS_GET_MNTNS_ID = 0x4008b705
NS_GET_NSTYPE = 0x2000b703 NS_GET_NSTYPE = 0x2000b703
NS_GET_OWNER_UID = 0x2000b704 NS_GET_OWNER_UID = 0x2000b704
NS_GET_PARENT = 0x2000b702 NS_GET_PARENT = 0x2000b702
NS_GET_PID_FROM_PIDNS = 0x4004b706
NS_GET_PID_IN_PIDNS = 0x4004b708
NS_GET_TGID_FROM_PIDNS = 0x4004b707
NS_GET_TGID_IN_PIDNS = 0x4004b709
NS_GET_USERNS = 0x2000b701 NS_GET_USERNS = 0x2000b701
OLCUC = 0x2 OLCUC = 0x2
ONLCR = 0x4 ONLCR = 0x4

View File

@ -150,9 +150,14 @@ const (
NFDBITS = 0x20 NFDBITS = 0x20
NLDLY = 0x100 NLDLY = 0x100
NOFLSH = 0x80 NOFLSH = 0x80
NS_GET_MNTNS_ID = 0x4008b705
NS_GET_NSTYPE = 0x2000b703 NS_GET_NSTYPE = 0x2000b703
NS_GET_OWNER_UID = 0x2000b704 NS_GET_OWNER_UID = 0x2000b704
NS_GET_PARENT = 0x2000b702 NS_GET_PARENT = 0x2000b702
NS_GET_PID_FROM_PIDNS = 0x4004b706
NS_GET_PID_IN_PIDNS = 0x4004b708
NS_GET_TGID_FROM_PIDNS = 0x4004b707
NS_GET_TGID_IN_PIDNS = 0x4004b709
NS_GET_USERNS = 0x2000b701 NS_GET_USERNS = 0x2000b701
OLCUC = 0x2 OLCUC = 0x2
ONLCR = 0x4 ONLCR = 0x4

View File

@ -152,9 +152,14 @@ const (
NL3 = 0x300 NL3 = 0x300
NLDLY = 0x300 NLDLY = 0x300
NOFLSH = 0x80000000 NOFLSH = 0x80000000
NS_GET_MNTNS_ID = 0x4008b705
NS_GET_NSTYPE = 0x2000b703 NS_GET_NSTYPE = 0x2000b703
NS_GET_OWNER_UID = 0x2000b704 NS_GET_OWNER_UID = 0x2000b704
NS_GET_PARENT = 0x2000b702 NS_GET_PARENT = 0x2000b702
NS_GET_PID_FROM_PIDNS = 0x4004b706
NS_GET_PID_IN_PIDNS = 0x4004b708
NS_GET_TGID_FROM_PIDNS = 0x4004b707
NS_GET_TGID_IN_PIDNS = 0x4004b709
NS_GET_USERNS = 0x2000b701 NS_GET_USERNS = 0x2000b701
OLCUC = 0x4 OLCUC = 0x4
ONLCR = 0x2 ONLCR = 0x2

View File

@ -152,9 +152,14 @@ const (
NL3 = 0x300 NL3 = 0x300
NLDLY = 0x300 NLDLY = 0x300
NOFLSH = 0x80000000 NOFLSH = 0x80000000
NS_GET_MNTNS_ID = 0x4008b705
NS_GET_NSTYPE = 0x2000b703 NS_GET_NSTYPE = 0x2000b703
NS_GET_OWNER_UID = 0x2000b704 NS_GET_OWNER_UID = 0x2000b704
NS_GET_PARENT = 0x2000b702 NS_GET_PARENT = 0x2000b702
NS_GET_PID_FROM_PIDNS = 0x4004b706
NS_GET_PID_IN_PIDNS = 0x4004b708
NS_GET_TGID_FROM_PIDNS = 0x4004b707
NS_GET_TGID_IN_PIDNS = 0x4004b709
NS_GET_USERNS = 0x2000b701 NS_GET_USERNS = 0x2000b701
OLCUC = 0x4 OLCUC = 0x4
ONLCR = 0x2 ONLCR = 0x2

View File

@ -152,9 +152,14 @@ const (
NL3 = 0x300 NL3 = 0x300
NLDLY = 0x300 NLDLY = 0x300
NOFLSH = 0x80000000 NOFLSH = 0x80000000
NS_GET_MNTNS_ID = 0x4008b705
NS_GET_NSTYPE = 0x2000b703 NS_GET_NSTYPE = 0x2000b703
NS_GET_OWNER_UID = 0x2000b704 NS_GET_OWNER_UID = 0x2000b704
NS_GET_PARENT = 0x2000b702 NS_GET_PARENT = 0x2000b702
NS_GET_PID_FROM_PIDNS = 0x4004b706
NS_GET_PID_IN_PIDNS = 0x4004b708
NS_GET_TGID_FROM_PIDNS = 0x4004b707
NS_GET_TGID_IN_PIDNS = 0x4004b709
NS_GET_USERNS = 0x2000b701 NS_GET_USERNS = 0x2000b701
OLCUC = 0x4 OLCUC = 0x4
ONLCR = 0x2 ONLCR = 0x2

View File

@ -150,9 +150,14 @@ const (
NFDBITS = 0x40 NFDBITS = 0x40
NLDLY = 0x100 NLDLY = 0x100
NOFLSH = 0x80 NOFLSH = 0x80
NS_GET_MNTNS_ID = 0x8008b705
NS_GET_NSTYPE = 0xb703 NS_GET_NSTYPE = 0xb703
NS_GET_OWNER_UID = 0xb704 NS_GET_OWNER_UID = 0xb704
NS_GET_PARENT = 0xb702 NS_GET_PARENT = 0xb702
NS_GET_PID_FROM_PIDNS = 0x8004b706
NS_GET_PID_IN_PIDNS = 0x8004b708
NS_GET_TGID_FROM_PIDNS = 0x8004b707
NS_GET_TGID_IN_PIDNS = 0x8004b709
NS_GET_USERNS = 0xb701 NS_GET_USERNS = 0xb701
OLCUC = 0x2 OLCUC = 0x2
ONLCR = 0x4 ONLCR = 0x4

View File

@ -150,9 +150,14 @@ const (
NFDBITS = 0x40 NFDBITS = 0x40
NLDLY = 0x100 NLDLY = 0x100
NOFLSH = 0x80 NOFLSH = 0x80
NS_GET_MNTNS_ID = 0x8008b705
NS_GET_NSTYPE = 0xb703 NS_GET_NSTYPE = 0xb703
NS_GET_OWNER_UID = 0xb704 NS_GET_OWNER_UID = 0xb704
NS_GET_PARENT = 0xb702 NS_GET_PARENT = 0xb702
NS_GET_PID_FROM_PIDNS = 0x8004b706
NS_GET_PID_IN_PIDNS = 0x8004b708
NS_GET_TGID_FROM_PIDNS = 0x8004b707
NS_GET_TGID_IN_PIDNS = 0x8004b709
NS_GET_USERNS = 0xb701 NS_GET_USERNS = 0xb701
OLCUC = 0x2 OLCUC = 0x2
ONLCR = 0x4 ONLCR = 0x4

View File

@ -155,9 +155,14 @@ const (
NFDBITS = 0x40 NFDBITS = 0x40
NLDLY = 0x100 NLDLY = 0x100
NOFLSH = 0x80 NOFLSH = 0x80
NS_GET_MNTNS_ID = 0x4008b705
NS_GET_NSTYPE = 0x2000b703 NS_GET_NSTYPE = 0x2000b703
NS_GET_OWNER_UID = 0x2000b704 NS_GET_OWNER_UID = 0x2000b704
NS_GET_PARENT = 0x2000b702 NS_GET_PARENT = 0x2000b702
NS_GET_PID_FROM_PIDNS = 0x4004b706
NS_GET_PID_IN_PIDNS = 0x4004b708
NS_GET_TGID_FROM_PIDNS = 0x4004b707
NS_GET_TGID_IN_PIDNS = 0x4004b709
NS_GET_USERNS = 0x2000b701 NS_GET_USERNS = 0x2000b701
OLCUC = 0x2 OLCUC = 0x2
ONLCR = 0x4 ONLCR = 0x4

View File

@ -971,23 +971,6 @@ func Getpriority(which int, who int) (prio int, err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrandom(buf []byte, flags int) (n int, err error) {
var _p0 unsafe.Pointer
if len(buf) > 0 {
_p0 = unsafe.Pointer(&buf[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(SYS_GETRANDOM, uintptr(_p0), uintptr(len(buf)), uintptr(flags))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrusage(who int, rusage *Rusage) (err error) { func Getrusage(who int, rusage *Rusage) (err error) {
_, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
if e1 != 0 { if e1 != 0 {

View File

@ -341,6 +341,7 @@ const (
SYS_STATX = 332 SYS_STATX = 332
SYS_IO_PGETEVENTS = 333 SYS_IO_PGETEVENTS = 333
SYS_RSEQ = 334 SYS_RSEQ = 334
SYS_URETPROBE = 335
SYS_PIDFD_SEND_SIGNAL = 424 SYS_PIDFD_SEND_SIGNAL = 424
SYS_IO_URING_SETUP = 425 SYS_IO_URING_SETUP = 425
SYS_IO_URING_ENTER = 426 SYS_IO_URING_ENTER = 426

View File

@ -85,7 +85,7 @@ const (
SYS_SPLICE = 76 SYS_SPLICE = 76
SYS_TEE = 77 SYS_TEE = 77
SYS_READLINKAT = 78 SYS_READLINKAT = 78
SYS_FSTATAT = 79 SYS_NEWFSTATAT = 79
SYS_FSTAT = 80 SYS_FSTAT = 80
SYS_SYNC = 81 SYS_SYNC = 81
SYS_FSYNC = 82 SYS_FSYNC = 82

View File

@ -84,6 +84,8 @@ const (
SYS_SPLICE = 76 SYS_SPLICE = 76
SYS_TEE = 77 SYS_TEE = 77
SYS_READLINKAT = 78 SYS_READLINKAT = 78
SYS_NEWFSTATAT = 79
SYS_FSTAT = 80
SYS_SYNC = 81 SYS_SYNC = 81
SYS_FSYNC = 82 SYS_FSYNC = 82
SYS_FDATASYNC = 83 SYS_FDATASYNC = 83

View File

@ -84,7 +84,7 @@ const (
SYS_SPLICE = 76 SYS_SPLICE = 76
SYS_TEE = 77 SYS_TEE = 77
SYS_READLINKAT = 78 SYS_READLINKAT = 78
SYS_FSTATAT = 79 SYS_NEWFSTATAT = 79
SYS_FSTAT = 80 SYS_FSTAT = 80
SYS_SYNC = 81 SYS_SYNC = 81
SYS_FSYNC = 82 SYS_FSYNC = 82

View File

@ -87,31 +87,35 @@ type StatxTimestamp struct {
} }
type Statx_t struct { type Statx_t struct {
Mask uint32 Mask uint32
Blksize uint32 Blksize uint32
Attributes uint64 Attributes uint64
Nlink uint32 Nlink uint32
Uid uint32 Uid uint32
Gid uint32 Gid uint32
Mode uint16 Mode uint16
_ [1]uint16 _ [1]uint16
Ino uint64 Ino uint64
Size uint64 Size uint64
Blocks uint64 Blocks uint64
Attributes_mask uint64 Attributes_mask uint64
Atime StatxTimestamp Atime StatxTimestamp
Btime StatxTimestamp Btime StatxTimestamp
Ctime StatxTimestamp Ctime StatxTimestamp
Mtime StatxTimestamp Mtime StatxTimestamp
Rdev_major uint32 Rdev_major uint32
Rdev_minor uint32 Rdev_minor uint32
Dev_major uint32 Dev_major uint32
Dev_minor uint32 Dev_minor uint32
Mnt_id uint64 Mnt_id uint64
Dio_mem_align uint32 Dio_mem_align uint32
Dio_offset_align uint32 Dio_offset_align uint32
Subvol uint64 Subvol uint64
_ [11]uint64 Atomic_write_unit_min uint32
Atomic_write_unit_max uint32
Atomic_write_segments_max uint32
_ [1]uint32
_ [9]uint64
} }
type Fsid struct { type Fsid struct {
@ -516,6 +520,29 @@ type TCPInfo struct {
Total_rto_time uint32 Total_rto_time uint32
} }
type TCPVegasInfo struct {
Enabled uint32
Rttcnt uint32
Rtt uint32
Minrtt uint32
}
type TCPDCTCPInfo struct {
Enabled uint16
Ce_state uint16
Alpha uint32
Ab_ecn uint32
Ab_tot uint32
}
type TCPBBRInfo struct {
Bw_lo uint32
Bw_hi uint32
Min_rtt uint32
Pacing_gain uint32
Cwnd_gain uint32
}
type CanFilter struct { type CanFilter struct {
Id uint32 Id uint32
Mask uint32 Mask uint32
@ -557,6 +584,7 @@ const (
SizeofICMPv6Filter = 0x20 SizeofICMPv6Filter = 0x20
SizeofUcred = 0xc SizeofUcred = 0xc
SizeofTCPInfo = 0xf8 SizeofTCPInfo = 0xf8
SizeofTCPCCInfo = 0x14
SizeofCanFilter = 0x8 SizeofCanFilter = 0x8
SizeofTCPRepairOpt = 0x8 SizeofTCPRepairOpt = 0x8
) )
@ -3766,7 +3794,7 @@ const (
ETHTOOL_MSG_PSE_GET = 0x24 ETHTOOL_MSG_PSE_GET = 0x24
ETHTOOL_MSG_PSE_SET = 0x25 ETHTOOL_MSG_PSE_SET = 0x25
ETHTOOL_MSG_RSS_GET = 0x26 ETHTOOL_MSG_RSS_GET = 0x26
ETHTOOL_MSG_USER_MAX = 0x2b ETHTOOL_MSG_USER_MAX = 0x2c
ETHTOOL_MSG_KERNEL_NONE = 0x0 ETHTOOL_MSG_KERNEL_NONE = 0x0
ETHTOOL_MSG_STRSET_GET_REPLY = 0x1 ETHTOOL_MSG_STRSET_GET_REPLY = 0x1
ETHTOOL_MSG_LINKINFO_GET_REPLY = 0x2 ETHTOOL_MSG_LINKINFO_GET_REPLY = 0x2
@ -3806,7 +3834,7 @@ const (
ETHTOOL_MSG_MODULE_NTF = 0x24 ETHTOOL_MSG_MODULE_NTF = 0x24
ETHTOOL_MSG_PSE_GET_REPLY = 0x25 ETHTOOL_MSG_PSE_GET_REPLY = 0x25
ETHTOOL_MSG_RSS_GET_REPLY = 0x26 ETHTOOL_MSG_RSS_GET_REPLY = 0x26
ETHTOOL_MSG_KERNEL_MAX = 0x2b ETHTOOL_MSG_KERNEL_MAX = 0x2c
ETHTOOL_FLAG_COMPACT_BITSETS = 0x1 ETHTOOL_FLAG_COMPACT_BITSETS = 0x1
ETHTOOL_FLAG_OMIT_REPLY = 0x2 ETHTOOL_FLAG_OMIT_REPLY = 0x2
ETHTOOL_FLAG_STATS = 0x4 ETHTOOL_FLAG_STATS = 0x4
@ -3951,7 +3979,7 @@ const (
ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL = 0x17 ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL = 0x17
ETHTOOL_A_COALESCE_USE_CQE_MODE_TX = 0x18 ETHTOOL_A_COALESCE_USE_CQE_MODE_TX = 0x18
ETHTOOL_A_COALESCE_USE_CQE_MODE_RX = 0x19 ETHTOOL_A_COALESCE_USE_CQE_MODE_RX = 0x19
ETHTOOL_A_COALESCE_MAX = 0x1c ETHTOOL_A_COALESCE_MAX = 0x1e
ETHTOOL_A_PAUSE_UNSPEC = 0x0 ETHTOOL_A_PAUSE_UNSPEC = 0x0
ETHTOOL_A_PAUSE_HEADER = 0x1 ETHTOOL_A_PAUSE_HEADER = 0x1
ETHTOOL_A_PAUSE_AUTONEG = 0x2 ETHTOOL_A_PAUSE_AUTONEG = 0x2
@ -4609,7 +4637,7 @@ const (
NL80211_ATTR_MAC_HINT = 0xc8 NL80211_ATTR_MAC_HINT = 0xc8
NL80211_ATTR_MAC_MASK = 0xd7 NL80211_ATTR_MAC_MASK = 0xd7
NL80211_ATTR_MAX_AP_ASSOC_STA = 0xca NL80211_ATTR_MAX_AP_ASSOC_STA = 0xca
NL80211_ATTR_MAX = 0x14a NL80211_ATTR_MAX = 0x14c
NL80211_ATTR_MAX_CRIT_PROT_DURATION = 0xb4 NL80211_ATTR_MAX_CRIT_PROT_DURATION = 0xb4
NL80211_ATTR_MAX_CSA_COUNTERS = 0xce NL80211_ATTR_MAX_CSA_COUNTERS = 0xce
NL80211_ATTR_MAX_MATCH_SETS = 0x85 NL80211_ATTR_MAX_MATCH_SETS = 0x85
@ -5213,7 +5241,7 @@ const (
NL80211_FREQUENCY_ATTR_GO_CONCURRENT = 0xf NL80211_FREQUENCY_ATTR_GO_CONCURRENT = 0xf
NL80211_FREQUENCY_ATTR_INDOOR_ONLY = 0xe NL80211_FREQUENCY_ATTR_INDOOR_ONLY = 0xe
NL80211_FREQUENCY_ATTR_IR_CONCURRENT = 0xf NL80211_FREQUENCY_ATTR_IR_CONCURRENT = 0xf
NL80211_FREQUENCY_ATTR_MAX = 0x20 NL80211_FREQUENCY_ATTR_MAX = 0x21
NL80211_FREQUENCY_ATTR_MAX_TX_POWER = 0x6 NL80211_FREQUENCY_ATTR_MAX_TX_POWER = 0x6
NL80211_FREQUENCY_ATTR_NO_10MHZ = 0x11 NL80211_FREQUENCY_ATTR_NO_10MHZ = 0x11
NL80211_FREQUENCY_ATTR_NO_160MHZ = 0xc NL80211_FREQUENCY_ATTR_NO_160MHZ = 0xc

View File

@ -65,7 +65,7 @@ func LoadDLL(name string) (dll *DLL, err error) {
return d, nil return d, nil
} }
// MustLoadDLL is like LoadDLL but panics if load operation failes. // MustLoadDLL is like LoadDLL but panics if load operation fails.
func MustLoadDLL(name string) *DLL { func MustLoadDLL(name string) *DLL {
d, e := LoadDLL(name) d, e := LoadDLL(name)
if e != nil { if e != nil {

View File

@ -102,7 +102,7 @@ type decoder struct {
} }
// newError returns an error object with position info. // newError returns an error object with position info.
func (d decoder) newError(pos int, f string, x ...interface{}) error { func (d decoder) newError(pos int, f string, x ...any) error {
line, column := d.Position(pos) line, column := d.Position(pos)
head := fmt.Sprintf("(line %d:%d): ", line, column) head := fmt.Sprintf("(line %d:%d): ", line, column)
return errors.New(head+f, x...) return errors.New(head+f, x...)
@ -114,7 +114,7 @@ func (d decoder) unexpectedTokenError(tok json.Token) error {
} }
// syntaxError returns a syntax error for given position. // syntaxError returns a syntax error for given position.
func (d decoder) syntaxError(pos int, f string, x ...interface{}) error { func (d decoder) syntaxError(pos int, f string, x ...any) error {
line, column := d.Position(pos) line, column := d.Position(pos)
head := fmt.Sprintf("syntax error (line %d:%d): ", line, column) head := fmt.Sprintf("syntax error (line %d:%d): ", line, column)
return errors.New(head+f, x...) return errors.New(head+f, x...)
@ -351,7 +351,7 @@ func (d decoder) unmarshalScalar(fd protoreflect.FieldDescriptor) (protoreflect.
panic(fmt.Sprintf("unmarshalScalar: invalid scalar kind %v", kind)) panic(fmt.Sprintf("unmarshalScalar: invalid scalar kind %v", kind))
} }
return protoreflect.Value{}, d.newError(tok.Pos(), "invalid value for %v type: %v", kind, tok.RawString()) return protoreflect.Value{}, d.newError(tok.Pos(), "invalid value for %v field %v: %v", kind, fd.JSONName(), tok.RawString())
} }
func unmarshalInt(tok json.Token, bitSize int) (protoreflect.Value, bool) { func unmarshalInt(tok json.Token, bitSize int) (protoreflect.Value, bool) {

View File

@ -216,9 +216,7 @@ func (m unpopulatedFieldRanger) Range(f func(protoreflect.FieldDescriptor, proto
} }
v := m.Get(fd) v := m.Get(fd)
isProto2Scalar := fd.Syntax() == protoreflect.Proto2 && fd.Default().IsValid() if fd.HasPresence() {
isSingularMessage := fd.Cardinality() != protoreflect.Repeated && fd.Message() != nil
if isProto2Scalar || isSingularMessage {
if m.skipNull { if m.skipNull {
continue continue
} }

View File

@ -84,7 +84,7 @@ type decoder struct {
} }
// newError returns an error object with position info. // newError returns an error object with position info.
func (d decoder) newError(pos int, f string, x ...interface{}) error { func (d decoder) newError(pos int, f string, x ...any) error {
line, column := d.Position(pos) line, column := d.Position(pos)
head := fmt.Sprintf("(line %d:%d): ", line, column) head := fmt.Sprintf("(line %d:%d): ", line, column)
return errors.New(head+f, x...) return errors.New(head+f, x...)
@ -96,7 +96,7 @@ func (d decoder) unexpectedTokenError(tok text.Token) error {
} }
// syntaxError returns a syntax error for given position. // syntaxError returns a syntax error for given position.
func (d decoder) syntaxError(pos int, f string, x ...interface{}) error { func (d decoder) syntaxError(pos int, f string, x ...any) error {
line, column := d.Position(pos) line, column := d.Position(pos)
head := fmt.Sprintf("syntax error (line %d:%d): ", line, column) head := fmt.Sprintf("syntax error (line %d:%d): ", line, column)
return errors.New(head+f, x...) return errors.New(head+f, x...)

View File

@ -9,7 +9,7 @@
// dependency on the descriptor proto package). // dependency on the descriptor proto package).
package descopts package descopts
import pref "google.golang.org/protobuf/reflect/protoreflect" import "google.golang.org/protobuf/reflect/protoreflect"
// These variables are set by the init function in descriptor.pb.go via logic // These variables are set by the init function in descriptor.pb.go via logic
// in internal/filetype. In other words, so long as the descriptor proto package // in internal/filetype. In other words, so long as the descriptor proto package
@ -17,13 +17,13 @@ import pref "google.golang.org/protobuf/reflect/protoreflect"
// //
// Each variable is populated with a nil pointer to the options struct. // Each variable is populated with a nil pointer to the options struct.
var ( var (
File pref.ProtoMessage File protoreflect.ProtoMessage
Enum pref.ProtoMessage Enum protoreflect.ProtoMessage
EnumValue pref.ProtoMessage EnumValue protoreflect.ProtoMessage
Message pref.ProtoMessage Message protoreflect.ProtoMessage
Field pref.ProtoMessage Field protoreflect.ProtoMessage
Oneof pref.ProtoMessage Oneof protoreflect.ProtoMessage
ExtensionRange pref.ProtoMessage ExtensionRange protoreflect.ProtoMessage
Service pref.ProtoMessage Service protoreflect.ProtoMessage
Method pref.ProtoMessage Method protoreflect.ProtoMessage
) )

View File

@ -5,7 +5,7 @@
// Package editionssupport defines constants for editions that are supported. // Package editionssupport defines constants for editions that are supported.
package editionssupport package editionssupport
import descriptorpb "google.golang.org/protobuf/types/descriptorpb" import "google.golang.org/protobuf/types/descriptorpb"
const ( const (
Minimum = descriptorpb.Edition_EDITION_PROTO2 Minimum = descriptorpb.Edition_EDITION_PROTO2

View File

@ -214,7 +214,7 @@ func (d *Decoder) parseNext() (Token, error) {
// newSyntaxError returns an error with line and column information useful for // newSyntaxError returns an error with line and column information useful for
// syntax errors. // syntax errors.
func (d *Decoder) newSyntaxError(pos int, f string, x ...interface{}) error { func (d *Decoder) newSyntaxError(pos int, f string, x ...any) error {
e := errors.New(f, x...) e := errors.New(f, x...)
line, column := d.Position(pos) line, column := d.Position(pos)
return errors.New("syntax error (line %d:%d): %v", line, column, e) return errors.New("syntax error (line %d:%d): %v", line, column, e)

View File

@ -601,7 +601,7 @@ func (d *Decoder) consumeToken(kind Kind, size int, attrs uint8) Token {
// newSyntaxError returns a syntax error with line and column information for // newSyntaxError returns a syntax error with line and column information for
// current position. // current position.
func (d *Decoder) newSyntaxError(f string, x ...interface{}) error { func (d *Decoder) newSyntaxError(f string, x ...any) error {
e := errors.New(f, x...) e := errors.New(f, x...)
line, column := d.Position(len(d.orig) - len(d.in)) line, column := d.Position(len(d.orig) - len(d.in))
return errors.New("syntax error (line %d:%d): %v", line, column, e) return errors.New("syntax error (line %d:%d): %v", line, column, e)

View File

@ -17,7 +17,7 @@ var Error = errors.New("protobuf error")
// New formats a string according to the format specifier and arguments and // New formats a string according to the format specifier and arguments and
// returns an error that has a "proto" prefix. // returns an error that has a "proto" prefix.
func New(f string, x ...interface{}) error { func New(f string, x ...any) error {
return &prefixError{s: format(f, x...)} return &prefixError{s: format(f, x...)}
} }
@ -43,7 +43,7 @@ func (e *prefixError) Unwrap() error {
// Wrap returns an error that has a "proto" prefix, the formatted string described // Wrap returns an error that has a "proto" prefix, the formatted string described
// by the format specifier and arguments, and a suffix of err. The error wraps err. // by the format specifier and arguments, and a suffix of err. The error wraps err.
func Wrap(err error, f string, x ...interface{}) error { func Wrap(err error, f string, x ...any) error {
return &wrapError{ return &wrapError{
s: format(f, x...), s: format(f, x...),
err: err, err: err,
@ -67,7 +67,7 @@ func (e *wrapError) Is(target error) bool {
return target == Error return target == Error
} }
func format(f string, x ...interface{}) string { func format(f string, x ...any) string {
// avoid "proto: " prefix when chaining // avoid "proto: " prefix when chaining
for i := 0; i < len(x); i++ { for i := 0; i < len(x); i++ {
switch e := x[i].(type) { switch e := x[i].(type) {

View File

@ -258,6 +258,7 @@ type (
StringName stringName StringName stringName
IsProto3Optional bool // promoted from google.protobuf.FieldDescriptorProto IsProto3Optional bool // promoted from google.protobuf.FieldDescriptorProto
IsWeak bool // promoted from google.protobuf.FieldOptions IsWeak bool // promoted from google.protobuf.FieldOptions
IsLazy bool // promoted from google.protobuf.FieldOptions
Default defaultValue Default defaultValue
ContainingOneof protoreflect.OneofDescriptor // must be consistent with Message.Oneofs.Fields ContainingOneof protoreflect.OneofDescriptor // must be consistent with Message.Oneofs.Fields
Enum protoreflect.EnumDescriptor Enum protoreflect.EnumDescriptor
@ -351,6 +352,7 @@ func (fd *Field) IsPacked() bool {
} }
func (fd *Field) IsExtension() bool { return false } func (fd *Field) IsExtension() bool { return false }
func (fd *Field) IsWeak() bool { return fd.L1.IsWeak } func (fd *Field) IsWeak() bool { return fd.L1.IsWeak }
func (fd *Field) IsLazy() bool { return fd.L1.IsLazy }
func (fd *Field) IsList() bool { return fd.Cardinality() == protoreflect.Repeated && !fd.IsMap() } func (fd *Field) IsList() bool { return fd.Cardinality() == protoreflect.Repeated && !fd.IsMap() }
func (fd *Field) IsMap() bool { return fd.Message() != nil && fd.Message().IsMapEntry() } func (fd *Field) IsMap() bool { return fd.Message() != nil && fd.Message().IsMapEntry() }
func (fd *Field) MapKey() protoreflect.FieldDescriptor { func (fd *Field) MapKey() protoreflect.FieldDescriptor {
@ -383,6 +385,10 @@ func (fd *Field) Message() protoreflect.MessageDescriptor {
} }
return fd.L1.Message return fd.L1.Message
} }
func (fd *Field) IsMapEntry() bool {
parent, ok := fd.L0.Parent.(protoreflect.MessageDescriptor)
return ok && parent.IsMapEntry()
}
func (fd *Field) Format(s fmt.State, r rune) { descfmt.FormatDesc(s, r, fd) } func (fd *Field) Format(s fmt.State, r rune) { descfmt.FormatDesc(s, r, fd) }
func (fd *Field) ProtoType(protoreflect.FieldDescriptor) {} func (fd *Field) ProtoType(protoreflect.FieldDescriptor) {}
@ -421,6 +427,7 @@ type (
Extendee protoreflect.MessageDescriptor Extendee protoreflect.MessageDescriptor
Cardinality protoreflect.Cardinality Cardinality protoreflect.Cardinality
Kind protoreflect.Kind Kind protoreflect.Kind
IsLazy bool
EditionFeatures EditionFeatures EditionFeatures EditionFeatures
} }
ExtensionL2 struct { ExtensionL2 struct {
@ -461,6 +468,7 @@ func (xd *Extension) IsPacked() bool {
} }
func (xd *Extension) IsExtension() bool { return true } func (xd *Extension) IsExtension() bool { return true }
func (xd *Extension) IsWeak() bool { return false } func (xd *Extension) IsWeak() bool { return false }
func (xd *Extension) IsLazy() bool { return xd.L1.IsLazy }
func (xd *Extension) IsList() bool { return xd.Cardinality() == protoreflect.Repeated } func (xd *Extension) IsList() bool { return xd.Cardinality() == protoreflect.Repeated }
func (xd *Extension) IsMap() bool { return false } func (xd *Extension) IsMap() bool { return false }
func (xd *Extension) MapKey() protoreflect.FieldDescriptor { return nil } func (xd *Extension) MapKey() protoreflect.FieldDescriptor { return nil }

View File

@ -495,6 +495,8 @@ func (xd *Extension) unmarshalOptions(b []byte) {
switch num { switch num {
case genid.FieldOptions_Packed_field_number: case genid.FieldOptions_Packed_field_number:
xd.L1.EditionFeatures.IsPacked = protowire.DecodeBool(v) xd.L1.EditionFeatures.IsPacked = protowire.DecodeBool(v)
case genid.FieldOptions_Lazy_field_number:
xd.L1.IsLazy = protowire.DecodeBool(v)
} }
case protowire.BytesType: case protowire.BytesType:
v, m := protowire.ConsumeBytes(b) v, m := protowire.ConsumeBytes(b)
@ -534,7 +536,7 @@ func (sd *Service) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd protor
} }
var nameBuilderPool = sync.Pool{ var nameBuilderPool = sync.Pool{
New: func() interface{} { return new(strs.Builder) }, New: func() any { return new(strs.Builder) },
} }
func getBuilder() *strs.Builder { func getBuilder() *strs.Builder {

View File

@ -45,6 +45,11 @@ func (file *File) resolveMessages() {
case protoreflect.MessageKind, protoreflect.GroupKind: case protoreflect.MessageKind, protoreflect.GroupKind:
fd.L1.Message = file.resolveMessageDependency(fd.L1.Message, listFieldDeps, depIdx) fd.L1.Message = file.resolveMessageDependency(fd.L1.Message, listFieldDeps, depIdx)
depIdx++ depIdx++
if fd.L1.Kind == protoreflect.GroupKind && (fd.IsMap() || fd.IsMapEntry()) {
// A map field might inherit delimited encoding from a file-wide default feature.
// But maps never actually use delimited encoding. (At least for now...)
fd.L1.Kind = protoreflect.MessageKind
}
} }
// Default is resolved here since it depends on Enum being resolved. // Default is resolved here since it depends on Enum being resolved.
@ -499,6 +504,8 @@ func (fd *Field) unmarshalOptions(b []byte) {
fd.L1.EditionFeatures.IsPacked = protowire.DecodeBool(v) fd.L1.EditionFeatures.IsPacked = protowire.DecodeBool(v)
case genid.FieldOptions_Weak_field_number: case genid.FieldOptions_Weak_field_number:
fd.L1.IsWeak = protowire.DecodeBool(v) fd.L1.IsWeak = protowire.DecodeBool(v)
case genid.FieldOptions_Lazy_field_number:
fd.L1.IsLazy = protowire.DecodeBool(v)
case FieldOptions_EnforceUTF8: case FieldOptions_EnforceUTF8:
fd.L1.EditionFeatures.IsUTF8Validated = protowire.DecodeBool(v) fd.L1.EditionFeatures.IsUTF8Validated = protowire.DecodeBool(v)
} }

View File

@ -68,7 +68,7 @@ func unmarshalFeatureSet(b []byte, parent EditionFeatures) EditionFeatures {
v, m := protowire.ConsumeBytes(b) v, m := protowire.ConsumeBytes(b)
b = b[m:] b = b[m:]
switch num { switch num {
case genid.GoFeatures_LegacyUnmarshalJsonEnum_field_number: case genid.FeatureSet_Go_ext_number:
parent = unmarshalGoFeature(v, parent) parent = unmarshalGoFeature(v, parent)
} }
} }

View File

@ -68,7 +68,7 @@ type Builder struct {
// and for input and output messages referenced by service methods. // and for input and output messages referenced by service methods.
// Dependencies must come after declarations, but the ordering of // Dependencies must come after declarations, but the ordering of
// dependencies themselves is unspecified. // dependencies themselves is unspecified.
GoTypes []interface{} GoTypes []any
// DependencyIndexes is an ordered list of indexes into GoTypes for the // DependencyIndexes is an ordered list of indexes into GoTypes for the
// dependencies of messages, extensions, or services. // dependencies of messages, extensions, or services.
@ -268,7 +268,7 @@ func (x depIdxs) Get(i, j int32) int32 {
type ( type (
resolverByIndex struct { resolverByIndex struct {
goTypes []interface{} goTypes []any
depIdxs depIdxs depIdxs depIdxs
fileRegistry fileRegistry
} }

View File

@ -860,11 +860,13 @@ const (
EnumValueOptions_Deprecated_field_name protoreflect.Name = "deprecated" EnumValueOptions_Deprecated_field_name protoreflect.Name = "deprecated"
EnumValueOptions_Features_field_name protoreflect.Name = "features" EnumValueOptions_Features_field_name protoreflect.Name = "features"
EnumValueOptions_DebugRedact_field_name protoreflect.Name = "debug_redact" EnumValueOptions_DebugRedact_field_name protoreflect.Name = "debug_redact"
EnumValueOptions_FeatureSupport_field_name protoreflect.Name = "feature_support"
EnumValueOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option" EnumValueOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option"
EnumValueOptions_Deprecated_field_fullname protoreflect.FullName = "google.protobuf.EnumValueOptions.deprecated" EnumValueOptions_Deprecated_field_fullname protoreflect.FullName = "google.protobuf.EnumValueOptions.deprecated"
EnumValueOptions_Features_field_fullname protoreflect.FullName = "google.protobuf.EnumValueOptions.features" EnumValueOptions_Features_field_fullname protoreflect.FullName = "google.protobuf.EnumValueOptions.features"
EnumValueOptions_DebugRedact_field_fullname protoreflect.FullName = "google.protobuf.EnumValueOptions.debug_redact" EnumValueOptions_DebugRedact_field_fullname protoreflect.FullName = "google.protobuf.EnumValueOptions.debug_redact"
EnumValueOptions_FeatureSupport_field_fullname protoreflect.FullName = "google.protobuf.EnumValueOptions.feature_support"
EnumValueOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.EnumValueOptions.uninterpreted_option" EnumValueOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.EnumValueOptions.uninterpreted_option"
) )
@ -873,6 +875,7 @@ const (
EnumValueOptions_Deprecated_field_number protoreflect.FieldNumber = 1 EnumValueOptions_Deprecated_field_number protoreflect.FieldNumber = 1
EnumValueOptions_Features_field_number protoreflect.FieldNumber = 2 EnumValueOptions_Features_field_number protoreflect.FieldNumber = 2
EnumValueOptions_DebugRedact_field_number protoreflect.FieldNumber = 3 EnumValueOptions_DebugRedact_field_number protoreflect.FieldNumber = 3
EnumValueOptions_FeatureSupport_field_number protoreflect.FieldNumber = 4
EnumValueOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999 EnumValueOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999
) )

View File

@ -6,6 +6,6 @@
// and the well-known types. // and the well-known types.
package genid package genid
import protoreflect "google.golang.org/protobuf/reflect/protoreflect" import "google.golang.org/protobuf/reflect/protoreflect"
const GoogleProtobuf_package protoreflect.FullName = "google.protobuf" const GoogleProtobuf_package protoreflect.FullName = "google.protobuf"

View File

@ -12,20 +12,25 @@ import (
const File_google_protobuf_go_features_proto = "google/protobuf/go_features.proto" const File_google_protobuf_go_features_proto = "google/protobuf/go_features.proto"
// Names for google.protobuf.GoFeatures. // Names for pb.GoFeatures.
const ( const (
GoFeatures_message_name protoreflect.Name = "GoFeatures" GoFeatures_message_name protoreflect.Name = "GoFeatures"
GoFeatures_message_fullname protoreflect.FullName = "google.protobuf.GoFeatures" GoFeatures_message_fullname protoreflect.FullName = "pb.GoFeatures"
) )
// Field names for google.protobuf.GoFeatures. // Field names for pb.GoFeatures.
const ( const (
GoFeatures_LegacyUnmarshalJsonEnum_field_name protoreflect.Name = "legacy_unmarshal_json_enum" GoFeatures_LegacyUnmarshalJsonEnum_field_name protoreflect.Name = "legacy_unmarshal_json_enum"
GoFeatures_LegacyUnmarshalJsonEnum_field_fullname protoreflect.FullName = "google.protobuf.GoFeatures.legacy_unmarshal_json_enum" GoFeatures_LegacyUnmarshalJsonEnum_field_fullname protoreflect.FullName = "pb.GoFeatures.legacy_unmarshal_json_enum"
) )
// Field numbers for google.protobuf.GoFeatures. // Field numbers for pb.GoFeatures.
const ( const (
GoFeatures_LegacyUnmarshalJsonEnum_field_number protoreflect.FieldNumber = 1 GoFeatures_LegacyUnmarshalJsonEnum_field_number protoreflect.FieldNumber = 1
) )
// Extension numbers
const (
FeatureSet_Go_ext_number protoreflect.FieldNumber = 1002
)

View File

@ -4,7 +4,7 @@
package genid package genid
import protoreflect "google.golang.org/protobuf/reflect/protoreflect" import "google.golang.org/protobuf/reflect/protoreflect"
// Generic field names and numbers for synthetic map entry messages. // Generic field names and numbers for synthetic map entry messages.
const ( const (

View File

@ -4,7 +4,7 @@
package genid package genid
import protoreflect "google.golang.org/protobuf/reflect/protoreflect" import "google.golang.org/protobuf/reflect/protoreflect"
// Generic field name and number for messages in wrappers.proto. // Generic field name and number for messages in wrappers.proto.
const ( const (

View File

@ -22,13 +22,13 @@ type Export struct{}
// NewError formats a string according to the format specifier and arguments and // NewError formats a string according to the format specifier and arguments and
// returns an error that has a "proto" prefix. // returns an error that has a "proto" prefix.
func (Export) NewError(f string, x ...interface{}) error { func (Export) NewError(f string, x ...any) error {
return errors.New(f, x...) return errors.New(f, x...)
} }
// enum is any enum type generated by protoc-gen-go // enum is any enum type generated by protoc-gen-go
// and must be a named int32 type. // and must be a named int32 type.
type enum = interface{} type enum = any
// EnumOf returns the protoreflect.Enum interface over e. // EnumOf returns the protoreflect.Enum interface over e.
// It returns nil if e is nil. // It returns nil if e is nil.
@ -81,7 +81,7 @@ func (Export) EnumStringOf(ed protoreflect.EnumDescriptor, n protoreflect.EnumNu
// message is any message type generated by protoc-gen-go // message is any message type generated by protoc-gen-go
// and must be a pointer to a named struct type. // and must be a pointer to a named struct type.
type message = interface{} type message = any
// legacyMessageWrapper wraps a v2 message as a v1 message. // legacyMessageWrapper wraps a v2 message as a v1 message.
type legacyMessageWrapper struct{ m protoreflect.ProtoMessage } type legacyMessageWrapper struct{ m protoreflect.ProtoMessage }

View File

@ -68,7 +68,7 @@ func (mi *MessageInfo) isInitExtensions(ext *map[int32]ExtensionField) error {
} }
for _, x := range *ext { for _, x := range *ext {
ei := getExtensionFieldInfo(x.Type()) ei := getExtensionFieldInfo(x.Type())
if ei.funcs.isInit == nil { if ei.funcs.isInit == nil || x.isUnexpandedLazy() {
continue continue
} }
v := x.Value() v := x.Value()

View File

@ -67,7 +67,6 @@ type lazyExtensionValue struct {
xi *extensionFieldInfo xi *extensionFieldInfo
value protoreflect.Value value protoreflect.Value
b []byte b []byte
fn func() protoreflect.Value
} }
type ExtensionField struct { type ExtensionField struct {
@ -99,6 +98,28 @@ func (f *ExtensionField) canLazy(xt protoreflect.ExtensionType) bool {
return false return false
} }
// isUnexpandedLazy returns true if the ExensionField is lazy and not
// yet expanded, which means it's present and already checked for
// initialized required fields.
func (f *ExtensionField) isUnexpandedLazy() bool {
return f.lazy != nil && atomic.LoadUint32(&f.lazy.atomicOnce) == 0
}
// lazyBuffer retrieves the buffer for a lazy extension if it's not yet expanded.
//
// The returned buffer has to be kept over whatever operation we're planning,
// as re-retrieving it will fail after the message is lazily decoded.
func (f *ExtensionField) lazyBuffer() []byte {
// This function might be in the critical path, so check the atomic without
// taking a look first, then only take the lock if needed.
if !f.isUnexpandedLazy() {
return nil
}
f.lazy.mu.Lock()
defer f.lazy.mu.Unlock()
return f.lazy.b
}
func (f *ExtensionField) lazyInit() { func (f *ExtensionField) lazyInit() {
f.lazy.mu.Lock() f.lazy.mu.Lock()
defer f.lazy.mu.Unlock() defer f.lazy.mu.Unlock()
@ -136,10 +157,9 @@ func (f *ExtensionField) lazyInit() {
} }
f.lazy.value = val f.lazy.value = val
} else { } else {
f.lazy.value = f.lazy.fn() panic("No support for lazy fns for ExtensionField")
} }
f.lazy.xi = nil f.lazy.xi = nil
f.lazy.fn = nil
f.lazy.b = nil f.lazy.b = nil
atomic.StoreUint32(&f.lazy.atomicOnce, 1) atomic.StoreUint32(&f.lazy.atomicOnce, 1)
} }
@ -152,13 +172,6 @@ func (f *ExtensionField) Set(t protoreflect.ExtensionType, v protoreflect.Value)
f.lazy = nil f.lazy = nil
} }
// SetLazy sets the type and a value that is to be lazily evaluated upon first use.
// This must not be called concurrently.
func (f *ExtensionField) SetLazy(t protoreflect.ExtensionType, fn func() protoreflect.Value) {
f.typ = t
f.lazy = &lazyExtensionValue{fn: fn}
}
// Value returns the value of the extension field. // Value returns the value of the extension field.
// This may be called concurrently. // This may be called concurrently.
func (f *ExtensionField) Value() protoreflect.Value { func (f *ExtensionField) Value() protoreflect.Value {

View File

@ -65,6 +65,9 @@ func (mi *MessageInfo) initOneofFieldCoders(od protoreflect.OneofDescriptor, si
if err != nil { if err != nil {
return out, err return out, err
} }
if cf.funcs.isInit == nil {
out.initialized = true
}
vi.Set(vw) vi.Set(vw)
return out, nil return out, nil
} }

View File

@ -189,6 +189,9 @@ func (mi *MessageInfo) makeCoderMethods(t reflect.Type, si structInfo) {
if mi.methods.Merge == nil { if mi.methods.Merge == nil {
mi.methods.Merge = mi.merge mi.methods.Merge = mi.merge
} }
if mi.methods.Equal == nil {
mi.methods.Equal = equal
}
} }
// getUnknownBytes returns a *[]byte for the unknown fields. // getUnknownBytes returns a *[]byte for the unknown fields.

View File

@ -26,6 +26,15 @@ func sizeMessageSet(mi *MessageInfo, p pointer, opts marshalOptions) (size int)
} }
num, _ := protowire.DecodeTag(xi.wiretag) num, _ := protowire.DecodeTag(xi.wiretag)
size += messageset.SizeField(num) size += messageset.SizeField(num)
if fullyLazyExtensions(opts) {
// Don't expand the extension, instead use the buffer to calculate size
if lb := x.lazyBuffer(); lb != nil {
// We got hold of the buffer, so it's still lazy.
// Don't count the tag size in the extension buffer, it's already added.
size += protowire.SizeTag(messageset.FieldMessage) + len(lb) - xi.tagsize
continue
}
}
size += xi.funcs.size(x.Value(), protowire.SizeTag(messageset.FieldMessage), opts) size += xi.funcs.size(x.Value(), protowire.SizeTag(messageset.FieldMessage), opts)
} }
@ -85,6 +94,19 @@ func marshalMessageSetField(mi *MessageInfo, b []byte, x ExtensionField, opts ma
xi := getExtensionFieldInfo(x.Type()) xi := getExtensionFieldInfo(x.Type())
num, _ := protowire.DecodeTag(xi.wiretag) num, _ := protowire.DecodeTag(xi.wiretag)
b = messageset.AppendFieldStart(b, num) b = messageset.AppendFieldStart(b, num)
if fullyLazyExtensions(opts) {
// Don't expand the extension if it's still in wire format, instead use the buffer content.
if lb := x.lazyBuffer(); lb != nil {
// The tag inside the lazy buffer is a different tag (the extension
// number), but what we need here is the tag for FieldMessage:
b = protowire.AppendVarint(b, protowire.EncodeTag(messageset.FieldMessage, protowire.BytesType))
b = append(b, lb[xi.tagsize:]...)
b = messageset.AppendFieldEnd(b)
return b, nil
}
}
b, err := xi.funcs.marshal(b, x.Value(), protowire.EncodeTag(messageset.FieldMessage, protowire.BytesType), opts) b, err := xi.funcs.marshal(b, x.Value(), protowire.EncodeTag(messageset.FieldMessage, protowire.BytesType), opts)
if err != nil { if err != nil {
return b, err return b, err

View File

@ -1,210 +0,0 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build purego || appengine
// +build purego appengine
package impl
import (
"reflect"
"google.golang.org/protobuf/encoding/protowire"
)
func sizeEnum(p pointer, f *coderFieldInfo, _ marshalOptions) (size int) {
v := p.v.Elem().Int()
return f.tagsize + protowire.SizeVarint(uint64(v))
}
func appendEnum(b []byte, p pointer, f *coderFieldInfo, opts marshalOptions) ([]byte, error) {
v := p.v.Elem().Int()
b = protowire.AppendVarint(b, f.wiretag)
b = protowire.AppendVarint(b, uint64(v))
return b, nil
}
func consumeEnum(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, _ unmarshalOptions) (out unmarshalOutput, err error) {
if wtyp != protowire.VarintType {
return out, errUnknown
}
v, n := protowire.ConsumeVarint(b)
if n < 0 {
return out, errDecode
}
p.v.Elem().SetInt(int64(v))
out.n = n
return out, nil
}
func mergeEnum(dst, src pointer, _ *coderFieldInfo, _ mergeOptions) {
dst.v.Elem().Set(src.v.Elem())
}
var coderEnum = pointerCoderFuncs{
size: sizeEnum,
marshal: appendEnum,
unmarshal: consumeEnum,
merge: mergeEnum,
}
func sizeEnumNoZero(p pointer, f *coderFieldInfo, opts marshalOptions) (size int) {
if p.v.Elem().Int() == 0 {
return 0
}
return sizeEnum(p, f, opts)
}
func appendEnumNoZero(b []byte, p pointer, f *coderFieldInfo, opts marshalOptions) ([]byte, error) {
if p.v.Elem().Int() == 0 {
return b, nil
}
return appendEnum(b, p, f, opts)
}
func mergeEnumNoZero(dst, src pointer, _ *coderFieldInfo, _ mergeOptions) {
if src.v.Elem().Int() != 0 {
dst.v.Elem().Set(src.v.Elem())
}
}
var coderEnumNoZero = pointerCoderFuncs{
size: sizeEnumNoZero,
marshal: appendEnumNoZero,
unmarshal: consumeEnum,
merge: mergeEnumNoZero,
}
func sizeEnumPtr(p pointer, f *coderFieldInfo, opts marshalOptions) (size int) {
return sizeEnum(pointer{p.v.Elem()}, f, opts)
}
func appendEnumPtr(b []byte, p pointer, f *coderFieldInfo, opts marshalOptions) ([]byte, error) {
return appendEnum(b, pointer{p.v.Elem()}, f, opts)
}
func consumeEnumPtr(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, opts unmarshalOptions) (out unmarshalOutput, err error) {
if wtyp != protowire.VarintType {
return out, errUnknown
}
if p.v.Elem().IsNil() {
p.v.Elem().Set(reflect.New(p.v.Elem().Type().Elem()))
}
return consumeEnum(b, pointer{p.v.Elem()}, wtyp, f, opts)
}
func mergeEnumPtr(dst, src pointer, _ *coderFieldInfo, _ mergeOptions) {
if !src.v.Elem().IsNil() {
v := reflect.New(dst.v.Type().Elem().Elem())
v.Elem().Set(src.v.Elem().Elem())
dst.v.Elem().Set(v)
}
}
var coderEnumPtr = pointerCoderFuncs{
size: sizeEnumPtr,
marshal: appendEnumPtr,
unmarshal: consumeEnumPtr,
merge: mergeEnumPtr,
}
func sizeEnumSlice(p pointer, f *coderFieldInfo, opts marshalOptions) (size int) {
s := p.v.Elem()
for i, llen := 0, s.Len(); i < llen; i++ {
size += protowire.SizeVarint(uint64(s.Index(i).Int())) + f.tagsize
}
return size
}
func appendEnumSlice(b []byte, p pointer, f *coderFieldInfo, opts marshalOptions) ([]byte, error) {
s := p.v.Elem()
for i, llen := 0, s.Len(); i < llen; i++ {
b = protowire.AppendVarint(b, f.wiretag)
b = protowire.AppendVarint(b, uint64(s.Index(i).Int()))
}
return b, nil
}
func consumeEnumSlice(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, opts unmarshalOptions) (out unmarshalOutput, err error) {
s := p.v.Elem()
if wtyp == protowire.BytesType {
b, n := protowire.ConsumeBytes(b)
if n < 0 {
return out, errDecode
}
for len(b) > 0 {
v, n := protowire.ConsumeVarint(b)
if n < 0 {
return out, errDecode
}
rv := reflect.New(s.Type().Elem()).Elem()
rv.SetInt(int64(v))
s.Set(reflect.Append(s, rv))
b = b[n:]
}
out.n = n
return out, nil
}
if wtyp != protowire.VarintType {
return out, errUnknown
}
v, n := protowire.ConsumeVarint(b)
if n < 0 {
return out, errDecode
}
rv := reflect.New(s.Type().Elem()).Elem()
rv.SetInt(int64(v))
s.Set(reflect.Append(s, rv))
out.n = n
return out, nil
}
func mergeEnumSlice(dst, src pointer, _ *coderFieldInfo, _ mergeOptions) {
dst.v.Elem().Set(reflect.AppendSlice(dst.v.Elem(), src.v.Elem()))
}
var coderEnumSlice = pointerCoderFuncs{
size: sizeEnumSlice,
marshal: appendEnumSlice,
unmarshal: consumeEnumSlice,
merge: mergeEnumSlice,
}
func sizeEnumPackedSlice(p pointer, f *coderFieldInfo, opts marshalOptions) (size int) {
s := p.v.Elem()
llen := s.Len()
if llen == 0 {
return 0
}
n := 0
for i := 0; i < llen; i++ {
n += protowire.SizeVarint(uint64(s.Index(i).Int()))
}
return f.tagsize + protowire.SizeBytes(n)
}
func appendEnumPackedSlice(b []byte, p pointer, f *coderFieldInfo, opts marshalOptions) ([]byte, error) {
s := p.v.Elem()
llen := s.Len()
if llen == 0 {
return b, nil
}
b = protowire.AppendVarint(b, f.wiretag)
n := 0
for i := 0; i < llen; i++ {
n += protowire.SizeVarint(uint64(s.Index(i).Int()))
}
b = protowire.AppendVarint(b, uint64(n))
for i := 0; i < llen; i++ {
b = protowire.AppendVarint(b, uint64(s.Index(i).Int()))
}
return b, nil
}
var coderEnumPackedSlice = pointerCoderFuncs{
size: sizeEnumPackedSlice,
marshal: appendEnumPackedSlice,
unmarshal: consumeEnumSlice,
merge: mergeEnumSlice,
}

View File

@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !purego && !appengine
// +build !purego,!appengine
package impl package impl
// When using unsafe pointers, we can just treat enum values as int32s. // When using unsafe pointers, we can just treat enum values as int32s.

View File

@ -14,7 +14,7 @@ import (
// unwrapper unwraps the value to the underlying value. // unwrapper unwraps the value to the underlying value.
// This is implemented by List and Map. // This is implemented by List and Map.
type unwrapper interface { type unwrapper interface {
protoUnwrap() interface{} protoUnwrap() any
} }
// A Converter coverts to/from Go reflect.Value types and protobuf protoreflect.Value types. // A Converter coverts to/from Go reflect.Value types and protobuf protoreflect.Value types.
@ -322,7 +322,7 @@ func (c *stringConverter) PBValueOf(v reflect.Value) protoreflect.Value {
return protoreflect.ValueOfString(v.Convert(stringType).String()) return protoreflect.ValueOfString(v.Convert(stringType).String())
} }
func (c *stringConverter) GoValueOf(v protoreflect.Value) reflect.Value { func (c *stringConverter) GoValueOf(v protoreflect.Value) reflect.Value {
// pref.Value.String never panics, so we go through an interface // protoreflect.Value.String never panics, so we go through an interface
// conversion here to check the type. // conversion here to check the type.
s := v.Interface().(string) s := v.Interface().(string)
if c.goType.Kind() == reflect.Slice && s == "" { if c.goType.Kind() == reflect.Slice && s == "" {

View File

@ -136,6 +136,6 @@ func (ls *listReflect) NewElement() protoreflect.Value {
func (ls *listReflect) IsValid() bool { func (ls *listReflect) IsValid() bool {
return !ls.v.IsNil() return !ls.v.IsNil()
} }
func (ls *listReflect) protoUnwrap() interface{} { func (ls *listReflect) protoUnwrap() any {
return ls.v.Interface() return ls.v.Interface()
} }

View File

@ -116,6 +116,6 @@ func (ms *mapReflect) NewValue() protoreflect.Value {
func (ms *mapReflect) IsValid() bool { func (ms *mapReflect) IsValid() bool {
return !ms.v.IsNil() return !ms.v.IsNil()
} }
func (ms *mapReflect) protoUnwrap() interface{} { func (ms *mapReflect) protoUnwrap() any {
return ms.v.Interface() return ms.v.Interface()
} }

View File

@ -10,7 +10,7 @@ import (
"sync/atomic" "sync/atomic"
"google.golang.org/protobuf/internal/flags" "google.golang.org/protobuf/internal/flags"
proto "google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
piface "google.golang.org/protobuf/runtime/protoiface" piface "google.golang.org/protobuf/runtime/protoiface"
) )
@ -49,8 +49,11 @@ func (mi *MessageInfo) sizePointer(p pointer, opts marshalOptions) (size int) {
return 0 return 0
} }
if opts.UseCachedSize() && mi.sizecacheOffset.IsValid() { if opts.UseCachedSize() && mi.sizecacheOffset.IsValid() {
if size := atomic.LoadInt32(p.Apply(mi.sizecacheOffset).Int32()); size >= 0 { // The size cache contains the size + 1, to allow the
return int(size) // zero value to be invalid, while also allowing for a
// 0 size to be cached.
if size := atomic.LoadInt32(p.Apply(mi.sizecacheOffset).Int32()); size > 0 {
return int(size - 1)
} }
} }
return mi.sizePointerSlow(p, opts) return mi.sizePointerSlow(p, opts)
@ -60,7 +63,7 @@ func (mi *MessageInfo) sizePointerSlow(p pointer, opts marshalOptions) (size int
if flags.ProtoLegacy && mi.isMessageSet { if flags.ProtoLegacy && mi.isMessageSet {
size = sizeMessageSet(mi, p, opts) size = sizeMessageSet(mi, p, opts)
if mi.sizecacheOffset.IsValid() { if mi.sizecacheOffset.IsValid() {
atomic.StoreInt32(p.Apply(mi.sizecacheOffset).Int32(), int32(size)) atomic.StoreInt32(p.Apply(mi.sizecacheOffset).Int32(), int32(size+1))
} }
return size return size
} }
@ -84,13 +87,16 @@ func (mi *MessageInfo) sizePointerSlow(p pointer, opts marshalOptions) (size int
} }
} }
if mi.sizecacheOffset.IsValid() { if mi.sizecacheOffset.IsValid() {
if size > math.MaxInt32 { if size > (math.MaxInt32 - 1) {
// The size is too large for the int32 sizecache field. // The size is too large for the int32 sizecache field.
// We will need to recompute the size when encoding; // We will need to recompute the size when encoding;
// unfortunately expensive, but better than invalid output. // unfortunately expensive, but better than invalid output.
atomic.StoreInt32(p.Apply(mi.sizecacheOffset).Int32(), -1) atomic.StoreInt32(p.Apply(mi.sizecacheOffset).Int32(), 0)
} else { } else {
atomic.StoreInt32(p.Apply(mi.sizecacheOffset).Int32(), int32(size)) // The size cache contains the size + 1, to allow the
// zero value to be invalid, while also allowing for a
// 0 size to be cached.
atomic.StoreInt32(p.Apply(mi.sizecacheOffset).Int32(), int32(size+1))
} }
} }
return size return size
@ -149,6 +155,14 @@ func (mi *MessageInfo) marshalAppendPointer(b []byte, p pointer, opts marshalOpt
return b, nil return b, nil
} }
// fullyLazyExtensions returns true if we should attempt to keep extensions lazy over size and marshal.
func fullyLazyExtensions(opts marshalOptions) bool {
// When deterministic marshaling is requested, force an unmarshal for lazy
// extensions to produce a deterministic result, instead of passing through
// bytes lazily that may or may not match what Go Protobuf would produce.
return opts.flags&piface.MarshalDeterministic == 0
}
func (mi *MessageInfo) sizeExtensions(ext *map[int32]ExtensionField, opts marshalOptions) (n int) { func (mi *MessageInfo) sizeExtensions(ext *map[int32]ExtensionField, opts marshalOptions) (n int) {
if ext == nil { if ext == nil {
return 0 return 0
@ -158,6 +172,14 @@ func (mi *MessageInfo) sizeExtensions(ext *map[int32]ExtensionField, opts marsha
if xi.funcs.size == nil { if xi.funcs.size == nil {
continue continue
} }
if fullyLazyExtensions(opts) {
// Don't expand the extension, instead use the buffer to calculate size
if lb := x.lazyBuffer(); lb != nil {
// We got hold of the buffer, so it's still lazy.
n += len(lb)
continue
}
}
n += xi.funcs.size(x.Value(), xi.tagsize, opts) n += xi.funcs.size(x.Value(), xi.tagsize, opts)
} }
return n return n
@ -176,6 +198,13 @@ func (mi *MessageInfo) appendExtensions(b []byte, ext *map[int32]ExtensionField,
var err error var err error
for _, x := range *ext { for _, x := range *ext {
xi := getExtensionFieldInfo(x.Type()) xi := getExtensionFieldInfo(x.Type())
if fullyLazyExtensions(opts) {
// Don't expand the extension if it's still in wire format, instead use the buffer content.
if lb := x.lazyBuffer(); lb != nil {
b = append(b, lb...)
continue
}
}
b, err = xi.funcs.marshal(b, x.Value(), xi.wiretag, opts) b, err = xi.funcs.marshal(b, x.Value(), xi.wiretag, opts)
} }
return b, err return b, err
@ -191,6 +220,13 @@ func (mi *MessageInfo) appendExtensions(b []byte, ext *map[int32]ExtensionField,
for _, k := range keys { for _, k := range keys {
x := (*ext)[int32(k)] x := (*ext)[int32(k)]
xi := getExtensionFieldInfo(x.Type()) xi := getExtensionFieldInfo(x.Type())
if fullyLazyExtensions(opts) {
// Don't expand the extension if it's still in wire format, instead use the buffer content.
if lb := x.lazyBuffer(); lb != nil {
b = append(b, lb...)
continue
}
}
b, err = xi.funcs.marshal(b, x.Value(), xi.wiretag, opts) b, err = xi.funcs.marshal(b, x.Value(), xi.wiretag, opts)
if err != nil { if err != nil {
return b, err return b, err

View File

@ -0,0 +1,224 @@
// Copyright 2024 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package impl
import (
"bytes"
"google.golang.org/protobuf/encoding/protowire"
"google.golang.org/protobuf/reflect/protoreflect"
"google.golang.org/protobuf/runtime/protoiface"
)
func equal(in protoiface.EqualInput) protoiface.EqualOutput {
return protoiface.EqualOutput{Equal: equalMessage(in.MessageA, in.MessageB)}
}
// equalMessage is a fast-path variant of protoreflect.equalMessage.
// It takes advantage of the internal messageState type to avoid
// unnecessary allocations, type assertions.
func equalMessage(mx, my protoreflect.Message) bool {
if mx == nil || my == nil {
return mx == my
}
if mx.Descriptor() != my.Descriptor() {
return false
}
msx, ok := mx.(*messageState)
if !ok {
return protoreflect.ValueOfMessage(mx).Equal(protoreflect.ValueOfMessage(my))
}
msy, ok := my.(*messageState)
if !ok {
return protoreflect.ValueOfMessage(mx).Equal(protoreflect.ValueOfMessage(my))
}
mi := msx.messageInfo()
miy := msy.messageInfo()
if mi != miy {
return protoreflect.ValueOfMessage(mx).Equal(protoreflect.ValueOfMessage(my))
}
mi.init()
// Compares regular fields
// Modified Message.Range code that compares two messages of the same type
// while going over the fields.
for _, ri := range mi.rangeInfos {
var fd protoreflect.FieldDescriptor
var vx, vy protoreflect.Value
switch ri := ri.(type) {
case *fieldInfo:
hx := ri.has(msx.pointer())
hy := ri.has(msy.pointer())
if hx != hy {
return false
}
if !hx {
continue
}
fd = ri.fieldDesc
vx = ri.get(msx.pointer())
vy = ri.get(msy.pointer())
case *oneofInfo:
fnx := ri.which(msx.pointer())
fny := ri.which(msy.pointer())
if fnx != fny {
return false
}
if fnx <= 0 {
continue
}
fi := mi.fields[fnx]
fd = fi.fieldDesc
vx = fi.get(msx.pointer())
vy = fi.get(msy.pointer())
}
if !equalValue(fd, vx, vy) {
return false
}
}
// Compare extensions.
// This is more complicated because mx or my could have empty/nil extension maps,
// however some populated extension map values are equal to nil extension maps.
emx := mi.extensionMap(msx.pointer())
emy := mi.extensionMap(msy.pointer())
if emx != nil {
for k, x := range *emx {
xd := x.Type().TypeDescriptor()
xv := x.Value()
var y ExtensionField
ok := false
if emy != nil {
y, ok = (*emy)[k]
}
// We need to treat empty lists as equal to nil values
if emy == nil || !ok {
if xd.IsList() && xv.List().Len() == 0 {
continue
}
return false
}
if !equalValue(xd, xv, y.Value()) {
return false
}
}
}
if emy != nil {
// emy may have extensions emx does not have, need to check them as well
for k, y := range *emy {
if emx != nil {
// emx has the field, so we already checked it
if _, ok := (*emx)[k]; ok {
continue
}
}
// Empty lists are equal to nil
if y.Type().TypeDescriptor().IsList() && y.Value().List().Len() == 0 {
continue
}
// Cant be equal if the extension is populated
return false
}
}
return equalUnknown(mx.GetUnknown(), my.GetUnknown())
}
func equalValue(fd protoreflect.FieldDescriptor, vx, vy protoreflect.Value) bool {
// slow path
if fd.Kind() != protoreflect.MessageKind {
return vx.Equal(vy)
}
// fast path special cases
if fd.IsMap() {
if fd.MapValue().Kind() == protoreflect.MessageKind {
return equalMessageMap(vx.Map(), vy.Map())
}
return vx.Equal(vy)
}
if fd.IsList() {
return equalMessageList(vx.List(), vy.List())
}
return equalMessage(vx.Message(), vy.Message())
}
// Mostly copied from protoreflect.equalMap.
// This variant only works for messages as map types.
// All other map types should be handled via Value.Equal.
func equalMessageMap(mx, my protoreflect.Map) bool {
if mx.Len() != my.Len() {
return false
}
equal := true
mx.Range(func(k protoreflect.MapKey, vx protoreflect.Value) bool {
if !my.Has(k) {
equal = false
return false
}
vy := my.Get(k)
equal = equalMessage(vx.Message(), vy.Message())
return equal
})
return equal
}
// Mostly copied from protoreflect.equalList.
// The only change is the usage of equalImpl instead of protoreflect.equalValue.
func equalMessageList(lx, ly protoreflect.List) bool {
if lx.Len() != ly.Len() {
return false
}
for i := 0; i < lx.Len(); i++ {
// We only operate on messages here since equalImpl will not call us in any other case.
if !equalMessage(lx.Get(i).Message(), ly.Get(i).Message()) {
return false
}
}
return true
}
// equalUnknown compares unknown fields by direct comparison on the raw bytes
// of each individual field number.
// Copied from protoreflect.equalUnknown.
func equalUnknown(x, y protoreflect.RawFields) bool {
if len(x) != len(y) {
return false
}
if bytes.Equal([]byte(x), []byte(y)) {
return true
}
mx := make(map[protoreflect.FieldNumber]protoreflect.RawFields)
my := make(map[protoreflect.FieldNumber]protoreflect.RawFields)
for len(x) > 0 {
fnum, _, n := protowire.ConsumeField(x)
mx[fnum] = append(mx[fnum], x[:n]...)
x = x[n:]
}
for len(y) > 0 {
fnum, _, n := protowire.ConsumeField(y)
my[fnum] = append(my[fnum], y[:n]...)
y = y[n:]
}
if len(mx) != len(my) {
return false
}
for k, v1 := range mx {
if v2, ok := my[k]; !ok || !bytes.Equal([]byte(v1), []byte(v2)) {
return false
}
}
return true
}

View File

@ -53,7 +53,7 @@ type ExtensionInfo struct {
// type returned by InterfaceOf may not be identical. // type returned by InterfaceOf may not be identical.
// //
// Deprecated: Use InterfaceOf(xt.Zero()) instead. // Deprecated: Use InterfaceOf(xt.Zero()) instead.
ExtensionType interface{} ExtensionType any
// Field is the field number of the extension. // Field is the field number of the extension.
// //
@ -95,16 +95,16 @@ func (xi *ExtensionInfo) New() protoreflect.Value {
func (xi *ExtensionInfo) Zero() protoreflect.Value { func (xi *ExtensionInfo) Zero() protoreflect.Value {
return xi.lazyInit().Zero() return xi.lazyInit().Zero()
} }
func (xi *ExtensionInfo) ValueOf(v interface{}) protoreflect.Value { func (xi *ExtensionInfo) ValueOf(v any) protoreflect.Value {
return xi.lazyInit().PBValueOf(reflect.ValueOf(v)) return xi.lazyInit().PBValueOf(reflect.ValueOf(v))
} }
func (xi *ExtensionInfo) InterfaceOf(v protoreflect.Value) interface{} { func (xi *ExtensionInfo) InterfaceOf(v protoreflect.Value) any {
return xi.lazyInit().GoValueOf(v).Interface() return xi.lazyInit().GoValueOf(v).Interface()
} }
func (xi *ExtensionInfo) IsValidValue(v protoreflect.Value) bool { func (xi *ExtensionInfo) IsValidValue(v protoreflect.Value) bool {
return xi.lazyInit().IsValidPB(v) return xi.lazyInit().IsValidPB(v)
} }
func (xi *ExtensionInfo) IsValidInterface(v interface{}) bool { func (xi *ExtensionInfo) IsValidInterface(v any) bool {
return xi.lazyInit().IsValidGo(reflect.ValueOf(v)) return xi.lazyInit().IsValidGo(reflect.ValueOf(v))
} }
func (xi *ExtensionInfo) TypeDescriptor() protoreflect.ExtensionTypeDescriptor { func (xi *ExtensionInfo) TypeDescriptor() protoreflect.ExtensionTypeDescriptor {

View File

@ -97,7 +97,7 @@ func (e *legacyEnumWrapper) Number() protoreflect.EnumNumber {
func (e *legacyEnumWrapper) ProtoReflect() protoreflect.Enum { func (e *legacyEnumWrapper) ProtoReflect() protoreflect.Enum {
return e return e
} }
func (e *legacyEnumWrapper) protoUnwrap() interface{} { func (e *legacyEnumWrapper) protoUnwrap() any {
v := reflect.New(e.goTyp).Elem() v := reflect.New(e.goTyp).Elem()
v.SetInt(int64(e.num)) v.SetInt(int64(e.num))
return v.Interface() return v.Interface()

View File

@ -160,6 +160,7 @@ func (x placeholderExtension) HasPresence() bool
func (x placeholderExtension) HasOptionalKeyword() bool { return false } func (x placeholderExtension) HasOptionalKeyword() bool { return false }
func (x placeholderExtension) IsExtension() bool { return true } func (x placeholderExtension) IsExtension() bool { return true }
func (x placeholderExtension) IsWeak() bool { return false } func (x placeholderExtension) IsWeak() bool { return false }
func (x placeholderExtension) IsLazy() bool { return false }
func (x placeholderExtension) IsPacked() bool { return false } func (x placeholderExtension) IsPacked() bool { return false }
func (x placeholderExtension) IsList() bool { return false } func (x placeholderExtension) IsList() bool { return false }
func (x placeholderExtension) IsMap() bool { return false } func (x placeholderExtension) IsMap() bool { return false }

View File

@ -216,7 +216,7 @@ func aberrantLoadMessageDescReentrant(t reflect.Type, name protoreflect.FullName
} }
for _, fn := range methods { for _, fn := range methods {
for _, v := range fn.Func.Call([]reflect.Value{reflect.Zero(fn.Type.In(0))}) { for _, v := range fn.Func.Call([]reflect.Value{reflect.Zero(fn.Type.In(0))}) {
if vs, ok := v.Interface().([]interface{}); ok { if vs, ok := v.Interface().([]any); ok {
for _, v := range vs { for _, v := range vs {
oneofWrappers = append(oneofWrappers, reflect.TypeOf(v)) oneofWrappers = append(oneofWrappers, reflect.TypeOf(v))
} }
@ -567,6 +567,6 @@ func (m aberrantMessage) IsValid() bool {
func (m aberrantMessage) ProtoMethods() *protoiface.Methods { func (m aberrantMessage) ProtoMethods() *protoiface.Methods {
return aberrantProtoMethods return aberrantProtoMethods
} }
func (m aberrantMessage) protoUnwrap() interface{} { func (m aberrantMessage) protoUnwrap() any {
return m.v.Interface() return m.v.Interface()
} }

View File

@ -30,12 +30,12 @@ type MessageInfo struct {
// Desc is the underlying message descriptor type and must be populated. // Desc is the underlying message descriptor type and must be populated.
Desc protoreflect.MessageDescriptor Desc protoreflect.MessageDescriptor
// Exporter must be provided in a purego environment in order to provide // Deprecated: Exporter will be removed the next time we bump
// access to unexported fields. // protoimpl.GenVersion. See https://github.com/golang/protobuf/issues/1640
Exporter exporter Exporter exporter
// OneofWrappers is list of pointers to oneof wrapper struct types. // OneofWrappers is list of pointers to oneof wrapper struct types.
OneofWrappers []interface{} OneofWrappers []any
initMu sync.Mutex // protects all unexported fields initMu sync.Mutex // protects all unexported fields
initDone uint32 initDone uint32
@ -47,7 +47,7 @@ type MessageInfo struct {
// exporter is a function that returns a reference to the ith field of v, // exporter is a function that returns a reference to the ith field of v,
// where v is a pointer to a struct. It returns nil if it does not support // where v is a pointer to a struct. It returns nil if it does not support
// exporting the requested field (e.g., already exported). // exporting the requested field (e.g., already exported).
type exporter func(v interface{}, i int) interface{} type exporter func(v any, i int) any
// getMessageInfo returns the MessageInfo for any message type that // getMessageInfo returns the MessageInfo for any message type that
// is generated by our implementation of protoc-gen-go (for v2 and on). // is generated by our implementation of protoc-gen-go (for v2 and on).
@ -201,7 +201,7 @@ fieldLoop:
} }
for _, fn := range methods { for _, fn := range methods {
for _, v := range fn.Func.Call([]reflect.Value{reflect.Zero(fn.Type.In(0))}) { for _, v := range fn.Func.Call([]reflect.Value{reflect.Zero(fn.Type.In(0))}) {
if vs, ok := v.Interface().([]interface{}); ok { if vs, ok := v.Interface().([]any); ok {
oneofWrappers = vs oneofWrappers = vs
} }
} }
@ -256,7 +256,7 @@ func (mi *MessageInfo) Message(i int) protoreflect.MessageType {
type mapEntryType struct { type mapEntryType struct {
desc protoreflect.MessageDescriptor desc protoreflect.MessageDescriptor
valType interface{} // zero value of enum or message type valType any // zero value of enum or message type
} }
func (mt mapEntryType) New() protoreflect.Message { func (mt mapEntryType) New() protoreflect.Message {

View File

@ -20,7 +20,7 @@ type reflectMessageInfo struct {
// fieldTypes contains the zero value of an enum or message field. // fieldTypes contains the zero value of an enum or message field.
// For lists, it contains the element type. // For lists, it contains the element type.
// For maps, it contains the entry value type. // For maps, it contains the entry value type.
fieldTypes map[protoreflect.FieldNumber]interface{} fieldTypes map[protoreflect.FieldNumber]any
// denseFields is a subset of fields where: // denseFields is a subset of fields where:
// 0 < fieldDesc.Number() < len(denseFields) // 0 < fieldDesc.Number() < len(denseFields)
@ -28,7 +28,7 @@ type reflectMessageInfo struct {
denseFields []*fieldInfo denseFields []*fieldInfo
// rangeInfos is a list of all fields (not belonging to a oneof) and oneofs. // rangeInfos is a list of all fields (not belonging to a oneof) and oneofs.
rangeInfos []interface{} // either *fieldInfo or *oneofInfo rangeInfos []any // either *fieldInfo or *oneofInfo
getUnknown func(pointer) protoreflect.RawFields getUnknown func(pointer) protoreflect.RawFields
setUnknown func(pointer, protoreflect.RawFields) setUnknown func(pointer, protoreflect.RawFields)
@ -224,7 +224,7 @@ func (mi *MessageInfo) makeFieldTypes(si structInfo) {
} }
if ft != nil { if ft != nil {
if mi.fieldTypes == nil { if mi.fieldTypes == nil {
mi.fieldTypes = make(map[protoreflect.FieldNumber]interface{}) mi.fieldTypes = make(map[protoreflect.FieldNumber]any)
} }
mi.fieldTypes[fd.Number()] = reflect.Zero(ft).Interface() mi.fieldTypes[fd.Number()] = reflect.Zero(ft).Interface()
} }
@ -255,6 +255,10 @@ func (m *extensionMap) Has(xd protoreflect.ExtensionTypeDescriptor) (ok bool) {
if !ok { if !ok {
return false return false
} }
if x.isUnexpandedLazy() {
// Avoid calling x.Value(), which triggers a lazy unmarshal.
return true
}
switch { switch {
case xd.IsList(): case xd.IsList():
return x.Value().List().Len() > 0 return x.Value().List().Len() > 0
@ -389,7 +393,7 @@ var (
// MessageOf returns a reflective view over a message. The input must be a // MessageOf returns a reflective view over a message. The input must be a
// pointer to a named Go struct. If the provided type has a ProtoReflect method, // pointer to a named Go struct. If the provided type has a ProtoReflect method,
// it must be implemented by calling this method. // it must be implemented by calling this method.
func (mi *MessageInfo) MessageOf(m interface{}) protoreflect.Message { func (mi *MessageInfo) MessageOf(m any) protoreflect.Message {
if reflect.TypeOf(m) != mi.GoReflectType { if reflect.TypeOf(m) != mi.GoReflectType {
panic(fmt.Sprintf("type mismatch: got %T, want %v", m, mi.GoReflectType)) panic(fmt.Sprintf("type mismatch: got %T, want %v", m, mi.GoReflectType))
} }
@ -417,7 +421,7 @@ func (m *messageIfaceWrapper) Reset() {
func (m *messageIfaceWrapper) ProtoReflect() protoreflect.Message { func (m *messageIfaceWrapper) ProtoReflect() protoreflect.Message {
return (*messageReflectWrapper)(m) return (*messageReflectWrapper)(m)
} }
func (m *messageIfaceWrapper) protoUnwrap() interface{} { func (m *messageIfaceWrapper) protoUnwrap() any {
return m.p.AsIfaceOf(m.mi.GoReflectType.Elem()) return m.p.AsIfaceOf(m.mi.GoReflectType.Elem())
} }

View File

@ -23,7 +23,7 @@ func (m *messageState) New() protoreflect.Message {
func (m *messageState) Interface() protoreflect.ProtoMessage { func (m *messageState) Interface() protoreflect.ProtoMessage {
return m.protoUnwrap().(protoreflect.ProtoMessage) return m.protoUnwrap().(protoreflect.ProtoMessage)
} }
func (m *messageState) protoUnwrap() interface{} { func (m *messageState) protoUnwrap() any {
return m.pointer().AsIfaceOf(m.messageInfo().GoReflectType.Elem()) return m.pointer().AsIfaceOf(m.messageInfo().GoReflectType.Elem())
} }
func (m *messageState) ProtoMethods() *protoiface.Methods { func (m *messageState) ProtoMethods() *protoiface.Methods {
@ -154,7 +154,7 @@ func (m *messageReflectWrapper) Interface() protoreflect.ProtoMessage {
} }
return (*messageIfaceWrapper)(m) return (*messageIfaceWrapper)(m)
} }
func (m *messageReflectWrapper) protoUnwrap() interface{} { func (m *messageReflectWrapper) protoUnwrap() any {
return m.pointer().AsIfaceOf(m.messageInfo().GoReflectType.Elem()) return m.pointer().AsIfaceOf(m.messageInfo().GoReflectType.Elem())
} }
func (m *messageReflectWrapper) ProtoMethods() *protoiface.Methods { func (m *messageReflectWrapper) ProtoMethods() *protoiface.Methods {

View File

@ -1,215 +0,0 @@
// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build purego || appengine
// +build purego appengine
package impl
import (
"fmt"
"reflect"
"sync"
)
const UnsafeEnabled = false
// Pointer is an opaque pointer type.
type Pointer interface{}
// offset represents the offset to a struct field, accessible from a pointer.
// The offset is the field index into a struct.
type offset struct {
index int
export exporter
}
// offsetOf returns a field offset for the struct field.
func offsetOf(f reflect.StructField, x exporter) offset {
if len(f.Index) != 1 {
panic("embedded structs are not supported")
}
if f.PkgPath == "" {
return offset{index: f.Index[0]} // field is already exported
}
if x == nil {
panic("exporter must be provided for unexported field")
}
return offset{index: f.Index[0], export: x}
}
// IsValid reports whether the offset is valid.
func (f offset) IsValid() bool { return f.index >= 0 }
// invalidOffset is an invalid field offset.
var invalidOffset = offset{index: -1}
// zeroOffset is a noop when calling pointer.Apply.
var zeroOffset = offset{index: 0}
// pointer is an abstract representation of a pointer to a struct or field.
type pointer struct{ v reflect.Value }
// pointerOf returns p as a pointer.
func pointerOf(p Pointer) pointer {
return pointerOfIface(p)
}
// pointerOfValue returns v as a pointer.
func pointerOfValue(v reflect.Value) pointer {
return pointer{v: v}
}
// pointerOfIface returns the pointer portion of an interface.
func pointerOfIface(v interface{}) pointer {
return pointer{v: reflect.ValueOf(v)}
}
// IsNil reports whether the pointer is nil.
func (p pointer) IsNil() bool {
return p.v.IsNil()
}
// Apply adds an offset to the pointer to derive a new pointer
// to a specified field. The current pointer must be pointing at a struct.
func (p pointer) Apply(f offset) pointer {
if f.export != nil {
if v := reflect.ValueOf(f.export(p.v.Interface(), f.index)); v.IsValid() {
return pointer{v: v}
}
}
return pointer{v: p.v.Elem().Field(f.index).Addr()}
}
// AsValueOf treats p as a pointer to an object of type t and returns the value.
// It is equivalent to reflect.ValueOf(p.AsIfaceOf(t))
func (p pointer) AsValueOf(t reflect.Type) reflect.Value {
if got := p.v.Type().Elem(); got != t {
panic(fmt.Sprintf("invalid type: got %v, want %v", got, t))
}
return p.v
}
// AsIfaceOf treats p as a pointer to an object of type t and returns the value.
// It is equivalent to p.AsValueOf(t).Interface()
func (p pointer) AsIfaceOf(t reflect.Type) interface{} {
return p.AsValueOf(t).Interface()
}
func (p pointer) Bool() *bool { return p.v.Interface().(*bool) }
func (p pointer) BoolPtr() **bool { return p.v.Interface().(**bool) }
func (p pointer) BoolSlice() *[]bool { return p.v.Interface().(*[]bool) }
func (p pointer) Int32() *int32 { return p.v.Interface().(*int32) }
func (p pointer) Int32Ptr() **int32 { return p.v.Interface().(**int32) }
func (p pointer) Int32Slice() *[]int32 { return p.v.Interface().(*[]int32) }
func (p pointer) Int64() *int64 { return p.v.Interface().(*int64) }
func (p pointer) Int64Ptr() **int64 { return p.v.Interface().(**int64) }
func (p pointer) Int64Slice() *[]int64 { return p.v.Interface().(*[]int64) }
func (p pointer) Uint32() *uint32 { return p.v.Interface().(*uint32) }
func (p pointer) Uint32Ptr() **uint32 { return p.v.Interface().(**uint32) }
func (p pointer) Uint32Slice() *[]uint32 { return p.v.Interface().(*[]uint32) }
func (p pointer) Uint64() *uint64 { return p.v.Interface().(*uint64) }
func (p pointer) Uint64Ptr() **uint64 { return p.v.Interface().(**uint64) }
func (p pointer) Uint64Slice() *[]uint64 { return p.v.Interface().(*[]uint64) }
func (p pointer) Float32() *float32 { return p.v.Interface().(*float32) }
func (p pointer) Float32Ptr() **float32 { return p.v.Interface().(**float32) }
func (p pointer) Float32Slice() *[]float32 { return p.v.Interface().(*[]float32) }
func (p pointer) Float64() *float64 { return p.v.Interface().(*float64) }
func (p pointer) Float64Ptr() **float64 { return p.v.Interface().(**float64) }
func (p pointer) Float64Slice() *[]float64 { return p.v.Interface().(*[]float64) }
func (p pointer) String() *string { return p.v.Interface().(*string) }
func (p pointer) StringPtr() **string { return p.v.Interface().(**string) }
func (p pointer) StringSlice() *[]string { return p.v.Interface().(*[]string) }
func (p pointer) Bytes() *[]byte { return p.v.Interface().(*[]byte) }
func (p pointer) BytesPtr() **[]byte { return p.v.Interface().(**[]byte) }
func (p pointer) BytesSlice() *[][]byte { return p.v.Interface().(*[][]byte) }
func (p pointer) WeakFields() *weakFields { return (*weakFields)(p.v.Interface().(*WeakFields)) }
func (p pointer) Extensions() *map[int32]ExtensionField {
return p.v.Interface().(*map[int32]ExtensionField)
}
func (p pointer) Elem() pointer {
return pointer{v: p.v.Elem()}
}
// PointerSlice copies []*T from p as a new []pointer.
// This behavior differs from the implementation in pointer_unsafe.go.
func (p pointer) PointerSlice() []pointer {
// TODO: reconsider this
if p.v.IsNil() {
return nil
}
n := p.v.Elem().Len()
s := make([]pointer, n)
for i := 0; i < n; i++ {
s[i] = pointer{v: p.v.Elem().Index(i)}
}
return s
}
// AppendPointerSlice appends v to p, which must be a []*T.
func (p pointer) AppendPointerSlice(v pointer) {
sp := p.v.Elem()
sp.Set(reflect.Append(sp, v.v))
}
// SetPointer sets *p to v.
func (p pointer) SetPointer(v pointer) {
p.v.Elem().Set(v.v)
}
func growSlice(p pointer, addCap int) {
// TODO: Once we only support Go 1.20 and newer, use reflect.Grow.
in := p.v.Elem()
out := reflect.MakeSlice(in.Type(), in.Len(), in.Len()+addCap)
reflect.Copy(out, in)
p.v.Elem().Set(out)
}
func (p pointer) growBoolSlice(addCap int) {
growSlice(p, addCap)
}
func (p pointer) growInt32Slice(addCap int) {
growSlice(p, addCap)
}
func (p pointer) growUint32Slice(addCap int) {
growSlice(p, addCap)
}
func (p pointer) growInt64Slice(addCap int) {
growSlice(p, addCap)
}
func (p pointer) growUint64Slice(addCap int) {
growSlice(p, addCap)
}
func (p pointer) growFloat64Slice(addCap int) {
growSlice(p, addCap)
}
func (p pointer) growFloat32Slice(addCap int) {
growSlice(p, addCap)
}
func (Export) MessageStateOf(p Pointer) *messageState { panic("not supported") }
func (ms *messageState) pointer() pointer { panic("not supported") }
func (ms *messageState) messageInfo() *MessageInfo { panic("not supported") }
func (ms *messageState) LoadMessageInfo() *MessageInfo { panic("not supported") }
func (ms *messageState) StoreMessageInfo(mi *MessageInfo) { panic("not supported") }
type atomicNilMessage struct {
once sync.Once
m messageReflectWrapper
}
func (m *atomicNilMessage) Init(mi *MessageInfo) *messageReflectWrapper {
m.once.Do(func() {
m.m.p = pointerOfIface(reflect.Zero(mi.GoReflectType).Interface())
m.m.mi = mi
})
return &m.m
}

View File

@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !purego && !appengine
// +build !purego,!appengine
package impl package impl
import ( import (
@ -50,7 +47,7 @@ func pointerOfValue(v reflect.Value) pointer {
} }
// pointerOfIface returns the pointer portion of an interface. // pointerOfIface returns the pointer portion of an interface.
func pointerOfIface(v interface{}) pointer { func pointerOfIface(v any) pointer {
type ifaceHeader struct { type ifaceHeader struct {
Type unsafe.Pointer Type unsafe.Pointer
Data unsafe.Pointer Data unsafe.Pointer
@ -80,7 +77,7 @@ func (p pointer) AsValueOf(t reflect.Type) reflect.Value {
// AsIfaceOf treats p as a pointer to an object of type t and returns the value. // AsIfaceOf treats p as a pointer to an object of type t and returns the value.
// It is equivalent to p.AsValueOf(t).Interface() // It is equivalent to p.AsValueOf(t).Interface()
func (p pointer) AsIfaceOf(t reflect.Type) interface{} { func (p pointer) AsIfaceOf(t reflect.Type) any {
// TODO: Use tricky unsafe magic to directly create ifaceHeader. // TODO: Use tricky unsafe magic to directly create ifaceHeader.
return p.AsValueOf(t).Interface() return p.AsValueOf(t).Interface()
} }

View File

@ -18,7 +18,7 @@ type messageField struct {
} }
var messageFieldPool = sync.Pool{ var messageFieldPool = sync.Pool{
New: func() interface{} { return new([]messageField) }, New: func() any { return new([]messageField) },
} }
type ( type (
@ -69,7 +69,7 @@ type mapEntry struct {
} }
var mapEntryPool = sync.Pool{ var mapEntryPool = sync.Pool{
New: func() interface{} { return new([]mapEntry) }, New: func() any { return new([]mapEntry) },
} }
type ( type (

View File

@ -1,28 +0,0 @@
// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build purego || appengine
// +build purego appengine
package strs
import pref "google.golang.org/protobuf/reflect/protoreflect"
func UnsafeString(b []byte) string {
return string(b)
}
func UnsafeBytes(s string) []byte {
return []byte(s)
}
type Builder struct{}
func (*Builder) AppendFullName(prefix pref.FullName, name pref.Name) pref.FullName {
return prefix.Append(name)
}
func (*Builder) MakeString(b []byte) string {
return string(b)
}

View File

@ -2,8 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !purego && !appengine && !go1.21 //go:build !go1.21
// +build !purego,!appengine,!go1.21
package strs package strs

View File

@ -2,8 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !purego && !appengine && go1.21 //go:build go1.21
// +build !purego,!appengine,go1.21
package strs package strs

View File

@ -51,7 +51,7 @@ import (
// 10. Send out the CL for review and submit it. // 10. Send out the CL for review and submit it.
const ( const (
Major = 1 Major = 1
Minor = 34 Minor = 35
Patch = 1 Patch = 1
PreRelease = "" PreRelease = ""
) )

View File

@ -8,6 +8,7 @@ import (
"reflect" "reflect"
"google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/reflect/protoreflect"
"google.golang.org/protobuf/runtime/protoiface"
) )
// Equal reports whether two messages are equal, // Equal reports whether two messages are equal,
@ -51,6 +52,14 @@ func Equal(x, y Message) bool {
if mx.IsValid() != my.IsValid() { if mx.IsValid() != my.IsValid() {
return false return false
} }
// Only one of the messages needs to implement the fast-path for it to work.
pmx := protoMethods(mx)
pmy := protoMethods(my)
if pmx != nil && pmy != nil && pmx.Equal != nil && pmy.Equal != nil {
return pmx.Equal(protoiface.EqualInput{MessageA: mx, MessageB: my}).Equal
}
vx := protoreflect.ValueOfMessage(mx) vx := protoreflect.ValueOfMessage(mx)
vy := protoreflect.ValueOfMessage(my) vy := protoreflect.ValueOfMessage(my)
return vx.Equal(vy) return vx.Equal(vy)

View File

@ -39,7 +39,49 @@ func ClearExtension(m Message, xt protoreflect.ExtensionType) {
// If the field is unpopulated, it returns the default value for // If the field is unpopulated, it returns the default value for
// scalars and an immutable, empty value for lists or messages. // scalars and an immutable, empty value for lists or messages.
// It panics if xt does not extend m. // It panics if xt does not extend m.
func GetExtension(m Message, xt protoreflect.ExtensionType) interface{} { //
// The type of the value is dependent on the field type of the extension.
// For extensions generated by protoc-gen-go, the Go type is as follows:
//
// ╔═══════════════════╤═════════════════════════╗
// ║ Go type │ Protobuf kind ║
// ╠═══════════════════╪═════════════════════════╣
// ║ bool │ bool ║
// ║ int32 │ int32, sint32, sfixed32 ║
// ║ int64 │ int64, sint64, sfixed64 ║
// ║ uint32 │ uint32, fixed32 ║
// ║ uint64 │ uint64, fixed64 ║
// ║ float32 │ float ║
// ║ float64 │ double ║
// ║ string │ string ║
// ║ []byte │ bytes ║
// ║ protoreflect.Enum │ enum ║
// ║ proto.Message │ message, group ║
// ╚═══════════════════╧═════════════════════════╝
//
// The protoreflect.Enum and proto.Message types are the concrete Go type
// associated with the named enum or message. Repeated fields are represented
// using a Go slice of the base element type.
//
// If a generated extension descriptor variable is directly passed to
// GetExtension, then the call should be followed immediately by a
// type assertion to the expected output value. For example:
//
// mm := proto.GetExtension(m, foopb.E_MyExtension).(*foopb.MyMessage)
//
// This pattern enables static analysis tools to verify that the asserted type
// matches the Go type associated with the extension field and
// also enables a possible future migration to a type-safe extension API.
//
// Since singular messages are the most common extension type, the pattern of
// calling HasExtension followed by GetExtension may be simplified to:
//
// if mm := proto.GetExtension(m, foopb.E_MyExtension).(*foopb.MyMessage); mm != nil {
// ... // make use of mm
// }
//
// The mm variable is non-nil if and only if HasExtension reports true.
func GetExtension(m Message, xt protoreflect.ExtensionType) any {
// Treat nil message interface as an empty message; return the default. // Treat nil message interface as an empty message; return the default.
if m == nil { if m == nil {
return xt.InterfaceOf(xt.Zero()) return xt.InterfaceOf(xt.Zero())
@ -51,7 +93,36 @@ func GetExtension(m Message, xt protoreflect.ExtensionType) interface{} {
// SetExtension stores the value of an extension field. // SetExtension stores the value of an extension field.
// It panics if m is invalid, xt does not extend m, or if type of v // It panics if m is invalid, xt does not extend m, or if type of v
// is invalid for the specified extension field. // is invalid for the specified extension field.
func SetExtension(m Message, xt protoreflect.ExtensionType, v interface{}) { //
// The type of the value is dependent on the field type of the extension.
// For extensions generated by protoc-gen-go, the Go type is as follows:
//
// ╔═══════════════════╤═════════════════════════╗
// ║ Go type │ Protobuf kind ║
// ╠═══════════════════╪═════════════════════════╣
// ║ bool │ bool ║
// ║ int32 │ int32, sint32, sfixed32 ║
// ║ int64 │ int64, sint64, sfixed64 ║
// ║ uint32 │ uint32, fixed32 ║
// ║ uint64 │ uint64, fixed64 ║
// ║ float32 │ float ║
// ║ float64 │ double ║
// ║ string │ string ║
// ║ []byte │ bytes ║
// ║ protoreflect.Enum │ enum ║
// ║ proto.Message │ message, group ║
// ╚═══════════════════╧═════════════════════════╝
//
// The protoreflect.Enum and proto.Message types are the concrete Go type
// associated with the named enum or message. Repeated fields are represented
// using a Go slice of the base element type.
//
// If a generated extension descriptor variable is directly passed to
// SetExtension (e.g., foopb.E_MyExtension), then the value should be a
// concrete type that matches the expected Go type for the extension descriptor
// so that static analysis tools can verify type correctness.
// This also enables a possible future migration to a type-safe extension API.
func SetExtension(m Message, xt protoreflect.ExtensionType, v any) {
xd := xt.TypeDescriptor() xd := xt.TypeDescriptor()
pv := xt.ValueOf(v) pv := xt.ValueOf(v)
@ -78,7 +149,7 @@ func SetExtension(m Message, xt protoreflect.ExtensionType, v interface{}) {
// It returns immediately if f returns false. // It returns immediately if f returns false.
// While iterating, mutating operations may only be performed // While iterating, mutating operations may only be performed
// on the current extension field. // on the current extension field.
func RangeExtensions(m Message, f func(protoreflect.ExtensionType, interface{}) bool) { func RangeExtensions(m Message, f func(protoreflect.ExtensionType, any) bool) {
// Treat nil message interface as an empty message; nothing to range over. // Treat nil message interface as an empty message; nothing to range over.
if m == nil { if m == nil {
return return

View File

@ -150,6 +150,7 @@ func (r descsByName) initFieldsFromDescriptorProto(fds []*descriptorpb.FieldDesc
opts = proto.Clone(opts).(*descriptorpb.FieldOptions) opts = proto.Clone(opts).(*descriptorpb.FieldOptions)
f.L1.Options = func() protoreflect.ProtoMessage { return opts } f.L1.Options = func() protoreflect.ProtoMessage { return opts }
f.L1.IsWeak = opts.GetWeak() f.L1.IsWeak = opts.GetWeak()
f.L1.IsLazy = opts.GetLazy()
if opts.Packed != nil { if opts.Packed != nil {
f.L1.EditionFeatures.IsPacked = opts.GetPacked() f.L1.EditionFeatures.IsPacked = opts.GetPacked()
} }
@ -214,6 +215,9 @@ func (r descsByName) initExtensionDeclarations(xds []*descriptorpb.FieldDescript
if xd.JsonName != nil { if xd.JsonName != nil {
x.L2.StringName.InitJSON(xd.GetJsonName()) x.L2.StringName.InitJSON(xd.GetJsonName())
} }
if x.L1.Kind == protoreflect.MessageKind && x.L1.EditionFeatures.IsDelimitedEncoded {
x.L1.Kind = protoreflect.GroupKind
}
} }
return xs, nil return xs, nil
} }

View File

@ -46,6 +46,11 @@ func (r *resolver) resolveMessageDependencies(ms []filedesc.Message, mds []*desc
if f.L1.Kind, f.L1.Enum, f.L1.Message, err = r.findTarget(f.Kind(), f.Parent().FullName(), partialName(fd.GetTypeName()), f.IsWeak()); err != nil { if f.L1.Kind, f.L1.Enum, f.L1.Message, err = r.findTarget(f.Kind(), f.Parent().FullName(), partialName(fd.GetTypeName()), f.IsWeak()); err != nil {
return errors.New("message field %q cannot resolve type: %v", f.FullName(), err) return errors.New("message field %q cannot resolve type: %v", f.FullName(), err)
} }
if f.L1.Kind == protoreflect.GroupKind && (f.IsMap() || f.IsMapEntry()) {
// A map field might inherit delimited encoding from a file-wide default feature.
// But maps never actually use delimited encoding. (At least for now...)
f.L1.Kind = protoreflect.MessageKind
}
if fd.DefaultValue != nil { if fd.DefaultValue != nil {
v, ev, err := unmarshalDefault(fd.GetDefaultValue(), f, r.allowUnresolvable) v, ev, err := unmarshalDefault(fd.GetDefaultValue(), f, r.allowUnresolvable)
if err != nil { if err != nil {

View File

@ -116,18 +116,6 @@ func validateMessageDeclarations(file *filedesc.File, ms []filedesc.Message, mds
if m.ExtensionRanges().Len() > 0 { if m.ExtensionRanges().Len() > 0 {
return errors.New("message %q using proto3 semantics cannot have extension ranges", m.FullName()) return errors.New("message %q using proto3 semantics cannot have extension ranges", m.FullName())
} }
// Verify that field names in proto3 do not conflict if lowercased
// with all underscores removed.
// See protoc v3.8.0: src/google/protobuf/descriptor.cc:5830-5847
names := map[string]protoreflect.FieldDescriptor{}
for i := 0; i < m.Fields().Len(); i++ {
f1 := m.Fields().Get(i)
s := strings.Replace(strings.ToLower(string(f1.Name())), "_", "", -1)
if f2, ok := names[s]; ok {
return errors.New("message %q using proto3 semantics has conflict: %q with %q", m.FullName(), f1.Name(), f2.Name())
}
names[s] = f1
}
} }
for j, fd := range md.GetField() { for j, fd := range md.GetField() {

View File

@ -14,7 +14,7 @@ import (
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
"google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/reflect/protoreflect"
"google.golang.org/protobuf/types/descriptorpb" "google.golang.org/protobuf/types/descriptorpb"
gofeaturespb "google.golang.org/protobuf/types/gofeaturespb" "google.golang.org/protobuf/types/gofeaturespb"
) )
var defaults = &descriptorpb.FeatureSetDefaults{} var defaults = &descriptorpb.FeatureSetDefaults{}

View File

@ -23,6 +23,7 @@ type (
Unmarshal func(unmarshalInput) (unmarshalOutput, error) Unmarshal func(unmarshalInput) (unmarshalOutput, error)
Merge func(mergeInput) mergeOutput Merge func(mergeInput) mergeOutput
CheckInitialized func(checkInitializedInput) (checkInitializedOutput, error) CheckInitialized func(checkInitializedInput) (checkInitializedOutput, error)
Equal func(equalInput) equalOutput
} }
supportFlags = uint64 supportFlags = uint64
sizeInput = struct { sizeInput = struct {
@ -75,4 +76,13 @@ type (
checkInitializedOutput = struct { checkInitializedOutput = struct {
pragma.NoUnkeyedLiterals pragma.NoUnkeyedLiterals
} }
equalInput = struct {
pragma.NoUnkeyedLiterals
MessageA Message
MessageB Message
}
equalOutput = struct {
pragma.NoUnkeyedLiterals
Equal bool
}
) )

View File

@ -485,6 +485,8 @@ func (p *SourcePath) appendEnumValueOptions(b []byte) []byte {
b = p.appendSingularField(b, "features", (*SourcePath).appendFeatureSet) b = p.appendSingularField(b, "features", (*SourcePath).appendFeatureSet)
case 3: case 3:
b = p.appendSingularField(b, "debug_redact", nil) b = p.appendSingularField(b, "debug_redact", nil)
case 4:
b = p.appendSingularField(b, "feature_support", (*SourcePath).appendFieldOptions_FeatureSupport)
case 999: case 999:
b = p.appendRepeatedField(b, "uninterpreted_option", (*SourcePath).appendUninterpretedOption) b = p.appendRepeatedField(b, "uninterpreted_option", (*SourcePath).appendUninterpretedOption)
} }

View File

@ -510,7 +510,7 @@ type ExtensionType interface {
// //
// ValueOf is more extensive than protoreflect.ValueOf for a given field's // ValueOf is more extensive than protoreflect.ValueOf for a given field's
// value as it has more type information available. // value as it has more type information available.
ValueOf(interface{}) Value ValueOf(any) Value
// InterfaceOf completely unwraps the Value to the underlying Go type. // InterfaceOf completely unwraps the Value to the underlying Go type.
// InterfaceOf panics if the input is nil or does not represent the // InterfaceOf panics if the input is nil or does not represent the
@ -519,13 +519,13 @@ type ExtensionType interface {
// //
// InterfaceOf is able to unwrap the Value further than Value.Interface // InterfaceOf is able to unwrap the Value further than Value.Interface
// as it has more type information available. // as it has more type information available.
InterfaceOf(Value) interface{} InterfaceOf(Value) any
// IsValidValue reports whether the Value is valid to assign to the field. // IsValidValue reports whether the Value is valid to assign to the field.
IsValidValue(Value) bool IsValidValue(Value) bool
// IsValidInterface reports whether the input is valid to assign to the field. // IsValidInterface reports whether the input is valid to assign to the field.
IsValidInterface(interface{}) bool IsValidInterface(any) bool
} }
// EnumDescriptor describes an enum and // EnumDescriptor describes an enum and

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