[chore] update dependencies (#4361)

- codeberg.org/gruf/go-kv/v2 v2.0.5 => v2.0.6
- github.com/coreos/go-oidc/v3 v3.14.1 => v3.15.0
- github.com/miekg/dns v1.1.67 => v1.1.68
- github.com/tdewolff/minify/v2 v2.23.9 => v2.23.11
- github.com/yuin/goldmark v1.7.12 => v1.7.13
- golang.org/x/crypto v0.40.0 => v0.41.0
- golang.org/x/image v0.29.0 => v0.30.0
- golang.org/x/net v0.42.0 => v0.43.0
- golang.org/x/sys v0.34.0 => v0.35.0
- golang.org/x/text v0.27.0 => v0.28.0
- modernc.org/sqlite v1.38.0 => v1.38.2

Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4361
Co-authored-by: kim <grufwub@gmail.com>
Co-committed-by: kim <grufwub@gmail.com>
This commit is contained in:
kim 2025-08-10 15:05:54 +02:00 committed by kim
commit 67100809b3
111 changed files with 49874 additions and 40191 deletions

35
go.mod
View file

@ -6,7 +6,7 @@ go 1.24.5
replace github.com/go-swagger/go-swagger => codeberg.org/superseriousbusiness/go-swagger v0.32.3-gts-go1.23-fix
// Replace modernc/sqlite with our version that fixes the concurrency INTERRUPT issue
replace modernc.org/sqlite => gitlab.com/NyaaaWhatsUpDoc/sqlite v1.38.0-concurrency-workaround
replace modernc.org/sqlite => gitlab.com/NyaaaWhatsUpDoc/sqlite v1.38.2-concurrency-workaround
require (
code.superseriousbusiness.org/activity v1.16.0
@ -23,7 +23,7 @@ require (
codeberg.org/gruf/go-fastcopy v1.1.3
codeberg.org/gruf/go-ffmpreg v0.6.8
codeberg.org/gruf/go-iotools v0.0.0-20240710125620-934ae9c654cf
codeberg.org/gruf/go-kv/v2 v2.0.5
codeberg.org/gruf/go-kv/v2 v2.0.6
codeberg.org/gruf/go-list v0.0.0-20240425093752-494db03d641f
codeberg.org/gruf/go-mempool v0.0.0-20240507125005-cef10d64a760
codeberg.org/gruf/go-mutexes v1.5.2
@ -36,7 +36,7 @@ require (
github.com/KimMachineGun/automemlimit v0.7.4
github.com/SherClockHolmes/webpush-go v1.4.0
github.com/buckket/go-blurhash v1.1.0
github.com/coreos/go-oidc/v3 v3.14.1
github.com/coreos/go-oidc/v3 v3.15.0
github.com/gin-contrib/cors v1.7.6
github.com/gin-contrib/gzip v1.2.3
github.com/gin-contrib/sessions v1.0.4
@ -50,7 +50,7 @@ require (
github.com/jackc/pgx/v5 v5.7.5
github.com/k3a/html2text v1.2.1
github.com/microcosm-cc/bluemonday v1.0.27
github.com/miekg/dns v1.1.67
github.com/miekg/dns v1.1.68
github.com/minio/minio-go/v7 v7.0.95
github.com/mitchellh/mapstructure v1.5.0
github.com/ncruces/go-sqlite3 v0.27.1
@ -62,7 +62,7 @@ require (
github.com/spf13/pflag v1.0.7
github.com/spf13/viper v1.20.1
github.com/stretchr/testify v1.10.0
github.com/tdewolff/minify/v2 v2.23.9
github.com/tdewolff/minify/v2 v2.23.11
github.com/technologize/otel-go-contrib v1.1.1
github.com/temoto/robotstxt v1.1.2
github.com/tetratelabs/wazero v1.9.0
@ -73,7 +73,7 @@ require (
github.com/uptrace/bun/dialect/sqlitedialect v1.2.15
github.com/uptrace/bun/extra/bunotel v1.2.15
github.com/wagslane/go-password-validator v0.3.0
github.com/yuin/goldmark v1.7.12
github.com/yuin/goldmark v1.7.13
go.opentelemetry.io/contrib/exporters/autoexport v0.62.0
go.opentelemetry.io/contrib/instrumentation/runtime v0.62.0
go.opentelemetry.io/otel v1.37.0
@ -82,15 +82,15 @@ require (
go.opentelemetry.io/otel/sdk/metric v1.37.0
go.opentelemetry.io/otel/trace v1.37.0
go.uber.org/automaxprocs v1.6.0
golang.org/x/crypto v0.40.0
golang.org/x/image v0.29.0
golang.org/x/net v0.42.0
golang.org/x/crypto v0.41.0
golang.org/x/image v0.30.0
golang.org/x/net v0.43.0
golang.org/x/oauth2 v0.30.0
golang.org/x/sys v0.34.0
golang.org/x/text v0.27.0
golang.org/x/sys v0.35.0
golang.org/x/text v0.28.0
gopkg.in/mcuadros/go-syslog.v2 v2.3.0
gopkg.in/yaml.v3 v3.0.1
modernc.org/sqlite v1.38.0
modernc.org/sqlite v1.38.2
mvdan.cc/xurls/v2 v2.6.0
)
@ -101,6 +101,7 @@ require (
codeberg.org/gruf/go-kv v1.6.5 // indirect
codeberg.org/gruf/go-mangler v1.4.4 // indirect
codeberg.org/gruf/go-maps v1.0.4 // indirect
codeberg.org/gruf/go-xunsafe v0.0.0-20250809104800-512a9df57d73 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.1 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
@ -201,7 +202,7 @@ require (
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.12.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/tdewolff/parse/v2 v2.8.1 // indirect
github.com/tdewolff/parse/v2 v2.8.2-0.20250806174018-50048bb39781 // indirect
github.com/tinylib/msgp v1.3.0 // indirect
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect
github.com/toqueteos/webbrowser v1.2.0 // indirect
@ -229,16 +230,16 @@ require (
go.opentelemetry.io/proto/otlp v1.7.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/arch v0.18.0 // indirect
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 // indirect
golang.org/x/mod v0.25.0 // indirect
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b // indirect
golang.org/x/mod v0.26.0 // indirect
golang.org/x/sync v0.16.0 // indirect
golang.org/x/tools v0.34.0 // indirect
golang.org/x/tools v0.35.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250603155806-513f23925822 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822 // indirect
google.golang.org/grpc v1.73.0 // indirect
google.golang.org/protobuf v1.36.6 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
modernc.org/libc v1.65.10 // indirect
modernc.org/libc v1.66.3 // indirect
modernc.org/mathutil v1.7.1 // indirect
modernc.org/memory v1.11.0 // indirect
)

80
go.sum generated
View file

@ -34,8 +34,8 @@ codeberg.org/gruf/go-iotools v0.0.0-20240710125620-934ae9c654cf h1:84s/ii8N6lYls
codeberg.org/gruf/go-iotools v0.0.0-20240710125620-934ae9c654cf/go.mod h1:zZAICsp5rY7+hxnws2V0ePrWxE0Z2Z/KXcN3p/RQCfk=
codeberg.org/gruf/go-kv v1.6.5 h1:ttPf0NA8F79pDqBttSudPTVCZmGncumeNIxmeM9ztz0=
codeberg.org/gruf/go-kv v1.6.5/go.mod h1:c4PsGqw05bDScvISpK+d31SiDEpBorweCL50hsiK3dc=
codeberg.org/gruf/go-kv/v2 v2.0.5 h1:FuUAJcdWrj1jzySalGpe8sZSvBLr+LbvZiHMjt014s0=
codeberg.org/gruf/go-kv/v2 v2.0.5/go.mod h1:mNL6SrBnYGEyrx6Mh4E1tAdhO0+T9/1iBrPJxIwxY24=
codeberg.org/gruf/go-kv/v2 v2.0.6 h1:X4NEiTn6b17kJmfrVd+5tuo3owHUGKTha9GsSkqvNZ8=
codeberg.org/gruf/go-kv/v2 v2.0.6/go.mod h1:uo6rPR14/ll+SDSU3K7DfINNmWD5NJ0EiahPayOguy0=
codeberg.org/gruf/go-list v0.0.0-20240425093752-494db03d641f h1:Ss6Z+vygy+jOGhj96d/GwsYYDd22QmIcH74zM7/nQkw=
codeberg.org/gruf/go-list v0.0.0-20240425093752-494db03d641f/go.mod h1:F9pl4h34iuVN7kucKam9fLwsItTc+9mmaKt7pNXRd/4=
codeberg.org/gruf/go-loosy v0.0.0-20231007123304-bb910d1ab5c4 h1:IXwfoU7f2whT6+JKIKskNl/hBlmWmnF1vZd84Eb3cyA=
@ -58,6 +58,8 @@ codeberg.org/gruf/go-storage v0.3.1 h1:g66UIM/xXnEk9ejT+W0T9s/PODBZhXa/8ajzeY/ME
codeberg.org/gruf/go-storage v0.3.1/go.mod h1:r43n/zi7YGOCl2iSl7AMI27D1zcWS65Bi2+5xDzypeo=
codeberg.org/gruf/go-structr v0.9.7 h1:yQeIxTjYb6reNdgESk915twyjolydYBqat/mlZrP7bg=
codeberg.org/gruf/go-structr v0.9.7/go.mod h1:9k5hYztZ4PsBS+m1v5hUTeFiVUBTLF5VA7d9cd1OEMs=
codeberg.org/gruf/go-xunsafe v0.0.0-20250809104800-512a9df57d73 h1:pRaOwIOS1WSZoPCAvE0H1zpv+D4gF37OVppybffqdI8=
codeberg.org/gruf/go-xunsafe v0.0.0-20250809104800-512a9df57d73/go.mod h1:9wkq+dmHjUhB/0ZxDUWAwsWuXwwGyx5N1dDCB9hpWs8=
codeberg.org/superseriousbusiness/go-swagger v0.32.3-gts-go1.23-fix h1:k76/Th+bruqU/d+dB0Ru466ctTF2aVjKpisy/471ILE=
codeberg.org/superseriousbusiness/go-swagger v0.32.3-gts-go1.23-fix/go.mod h1:lAwO1nKff3qNRJYVQeTCl1am5pcNiiA2VyDf8TqzS24=
github.com/DmitriyVTitov/size v1.5.0 h1:/PzqxYrOyOUX1BXj6J9OuVRVGe+66VL4D9FlUaW515g=
@ -103,8 +105,8 @@ github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJ
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
github.com/cnf/structhash v0.0.0-20201127153200-e1b16c1ebc08 h1:ox2F0PSMlrAAiAdknSRMDrAr8mfxPCfSZolH+/qQnyQ=
github.com/cnf/structhash v0.0.0-20201127153200-e1b16c1ebc08/go.mod h1:pCxVEbcm3AMg7ejXyorUXi6HQCzOIBf7zEDVPtw0/U4=
github.com/coreos/go-oidc/v3 v3.14.1 h1:9ePWwfdwC4QKRlCXsJGou56adA/owXczOzwKdOumLqk=
github.com/coreos/go-oidc/v3 v3.14.1/go.mod h1:HaZ3szPaZ0e4r6ebqvsLWlk2Tn+aejfmrfah6hnSYEU=
github.com/coreos/go-oidc/v3 v3.15.0 h1:R6Oz8Z4bqWR7VFQ+sPSvZPQv4x8M+sJkDO5ojgwlyAg=
github.com/coreos/go-oidc/v3 v3.15.0/go.mod h1:HaZ3szPaZ0e4r6ebqvsLWlk2Tn+aejfmrfah6hnSYEU=
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@ -311,8 +313,8 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk=
github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA=
github.com/miekg/dns v1.1.67 h1:kg0EHj0G4bfT5/oOys6HhZw4vmMlnoZ+gDu8tJ/AlI0=
github.com/miekg/dns v1.1.67/go.mod h1:fujopn7TB3Pu3JM69XaawiU0wqjpL9/8xGop5UrTPps=
github.com/miekg/dns v1.1.68 h1:jsSRkNozw7G/mnmXULynzMNIsgY2dHC8LO6U6Ij2JEA=
github.com/miekg/dns v1.1.68/go.mod h1:fujopn7TB3Pu3JM69XaawiU0wqjpL9/8xGop5UrTPps=
github.com/minio/crc64nvme v1.0.2 h1:6uO1UxGAD+kwqWWp7mBFsi5gAse66C4NXO8cmcVculg=
github.com/minio/crc64nvme v1.0.2/go.mod h1:eVfm2fAzLlxMdUGc0EEBGSMmPwmXD5XiNRpnu9J3bvg=
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
@ -429,10 +431,10 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/tdewolff/minify/v2 v2.23.9 h1:s8hX6wQzOqmanyLxmlynInRPVgZ/xASy6sUHfGsW6kU=
github.com/tdewolff/minify/v2 v2.23.9/go.mod h1:VW3ISUd3gDOZuQ/jwZr4sCzsuX+Qvsx87FDMjk6Rvno=
github.com/tdewolff/parse/v2 v2.8.1 h1:J5GSHru6o3jF1uLlEKVXkDxxcVx6yzOlIVIotK4w2po=
github.com/tdewolff/parse/v2 v2.8.1/go.mod h1:Hwlni2tiVNKyzR1o6nUs4FOF07URA+JLBLd6dlIXYqo=
github.com/tdewolff/minify/v2 v2.23.11 h1:cZqTVCtuVvPC8/GbCvYgIcdAQGmoxEObZzKeKIUixTE=
github.com/tdewolff/minify/v2 v2.23.11/go.mod h1:vmkbfGQ5hp/eYB+TswNWKma67S0a+32HBL+mFWxjZ2Q=
github.com/tdewolff/parse/v2 v2.8.2-0.20250806174018-50048bb39781 h1:2qicgFovKg1XtX7Wf6GwexUdpb7q/jMIE2IgkYsVAvE=
github.com/tdewolff/parse/v2 v2.8.2-0.20250806174018-50048bb39781/go.mod h1:Hwlni2tiVNKyzR1o6nUs4FOF07URA+JLBLd6dlIXYqo=
github.com/tdewolff/test v1.0.11 h1:FdLbwQVHxqG16SlkGveC0JVyrJN62COWTRyUFzfbtBE=
github.com/tdewolff/test v1.0.11/go.mod h1:XPuWBzvdUzhCuxWO1ojpXsyzsA5bFoS3tO/Q3kFuTG8=
github.com/technologize/otel-go-contrib v1.1.1 h1:wZH9aSPNWZWIkEh3vfaKfMb15AJ80jJ1aVj/4GZdqIw=
@ -506,10 +508,10 @@ github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FB
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3IfnEUduWvb9is428/nNb5L3U01M=
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yuin/goldmark v1.7.12 h1:YwGP/rrea2/CnCtUHgjuolG/PnMxdQtPMO5PvaE2/nY=
github.com/yuin/goldmark v1.7.12/go.mod h1:ip/1k0VRfGynBgxOz0yCqHrbZXhcjxyuS66Brc7iBKg=
gitlab.com/NyaaaWhatsUpDoc/sqlite v1.38.0-concurrency-workaround h1:C5sLzVJmDHukxwLHWgOK+bc7suJjwp+WKId/dqI305s=
gitlab.com/NyaaaWhatsUpDoc/sqlite v1.38.0-concurrency-workaround/go.mod h1:1Bj+yES4SVvBZ4cBOpVZ6QgesMCKpJZDq0nxYzOpmNE=
github.com/yuin/goldmark v1.7.13 h1:GPddIs617DnBLFFVJFgpo1aBfe/4xcvMc3SB5t/D0pA=
github.com/yuin/goldmark v1.7.13/go.mod h1:ip/1k0VRfGynBgxOz0yCqHrbZXhcjxyuS66Brc7iBKg=
gitlab.com/NyaaaWhatsUpDoc/sqlite v1.38.2-concurrency-workaround h1:v1DRiquV7HAI68FED0VopIYIWXtuaYYZxj3fL71Zz+s=
gitlab.com/NyaaaWhatsUpDoc/sqlite v1.38.2-concurrency-workaround/go.mod h1:cPTJYSlgg3Sfg046yBShXENNtPrWrDX8bsbAQBzgQ5E=
go.mongodb.org/mongo-driver v1.17.3 h1:TQyXhnsWfWtgAhMtOgtYHMTkZIfBTpMTsMnd9ZBeHxQ=
go.mongodb.org/mongo-driver v1.17.3/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ=
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
@ -575,19 +577,19 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
golang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM=
golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY=
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 h1:R84qjqJb5nVJMxqWYb3np9L5ZsaDtB+a39EqjV0JSUM=
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0/go.mod h1:S9Xr4PYopiDyqSyp5NjCrhFrqg6A5zA2E/iPHPhqnS8=
golang.org/x/image v0.29.0 h1:HcdsyR4Gsuys/Axh0rDEmlBmB68rW1U9BUdB3UVHsas=
golang.org/x/image v0.29.0/go.mod h1:RVJROnf3SLK8d26OW91j4FrIHGbsJ8QnbEocVTOWQDA=
golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4=
golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc=
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b h1:M2rDM6z3Fhozi9O7NWsxAkg/yqS/lQJ6PmkyIV3YP+o=
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8=
golang.org/x/image v0.30.0 h1:jD5RhkmVAnjqaCUXfbGBrn3lpxbknfN9w2UhHHU+5B4=
golang.org/x/image v0.30.0/go.mod h1:SAEUTxCCMWSrJcCy/4HwavEsfZZJlYxeHLc6tTiAe/c=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.25.0 h1:n7a+ZbQKQA/Ysbyb0/6IbB1H/X41mKgbhfv7AfG/44w=
golang.org/x/mod v0.25.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
golang.org/x/mod v0.26.0 h1:EGMPT//Ezu+ylkCijjPc+f4Aih7sZvaAr+O3EHBxvZg=
golang.org/x/mod v0.26.0/go.mod h1:/j6NAhSk8iQ723BGAUyoAcn7SlD7s15Dp9Nd/SfeaFQ=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
@ -603,8 +605,8 @@ golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs=
golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8=
golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE=
golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg=
golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI=
golang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@ -631,8 +633,8 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA=
golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
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=
@ -643,8 +645,8 @@ golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
golang.org/x/term v0.33.0 h1:NuFncQrRcaRvVmgRkvM3j/F00gWIAlcmlB8ACEKmGIg=
golang.org/x/term v0.33.0/go.mod h1:s18+ql9tYWp1IfpV9DmCtQDDSRBUjKaw9M1eAv5UeF0=
golang.org/x/term v0.34.0 h1:O/2T7POpk0ZZ7MAzMeWFSg6S5IpWd/RXDlM9hgM3DR4=
golang.org/x/term v0.34.0/go.mod h1:5jC53AEywhIVebHgPVeg0mj8OD3VO9OzclacVrqpaAw=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
@ -655,8 +657,8 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4=
golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU=
golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng=
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
@ -664,8 +666,8 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/tools v0.34.0 h1:qIpSLOxeCYGg9TrcJokLBG4KFA6d795g0xkBkiESGlo=
golang.org/x/tools v0.34.0/go.mod h1:pAP9OwEaY1CAW3HOmg3hLZC5Z0CCmzjAF2UQMSqNARg=
golang.org/x/tools v0.35.0 h1:mBffYraMEf7aa0sB+NuKnuCy8qI/9Bughn8dC2Gu5r0=
golang.org/x/tools v0.35.0/go.mod h1:NKdj5HkL/73byiZSJjqJgKn3ep7KjFkBOkR/Hps3VPw=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto/googleapis/api v0.0.0-20250603155806-513f23925822 h1:oWVWY3NzT7KJppx2UKhKmzPq4SRe0LdCijVRwvGeikY=
google.golang.org/genproto/googleapis/api v0.0.0-20250603155806-513f23925822/go.mod h1:h3c4v36UTKzUiuaOKQ6gr3S+0hovBtUrXzTG/i3+XEc=
@ -688,16 +690,18 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
modernc.org/cc/v4 v4.26.1 h1:+X5NtzVBn0KgsBCBe+xkDC7twLb/jNVj9FPgiwSQO3s=
modernc.org/cc/v4 v4.26.1/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0=
modernc.org/cc/v4 v4.26.2 h1:991HMkLjJzYBIfha6ECZdjrIYz2/1ayr+FL8GN+CNzM=
modernc.org/cc/v4 v4.26.2/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0=
modernc.org/ccgo/v4 v4.28.0 h1:rjznn6WWehKq7dG4JtLRKxb52Ecv8OUGah8+Z/SfpNU=
modernc.org/ccgo/v4 v4.28.0/go.mod h1:JygV3+9AV6SmPhDasu4JgquwU81XAKLd3OKTUDNOiKE=
modernc.org/fileutil v1.3.3 h1:3qaU+7f7xxTUmvU1pJTZiDLAIoJVdUSSauJNHg9yXoA=
modernc.org/fileutil v1.3.3/go.mod h1:HxmghZSZVAz/LXcMNwZPA/DRrQZEVP9VX0V4LQGQFOc=
modernc.org/fileutil v1.3.8 h1:qtzNm7ED75pd1C7WgAGcK4edm4fvhtBsEiI/0NQ54YM=
modernc.org/fileutil v1.3.8/go.mod h1:HxmghZSZVAz/LXcMNwZPA/DRrQZEVP9VX0V4LQGQFOc=
modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI=
modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito=
modernc.org/libc v1.65.10 h1:ZwEk8+jhW7qBjHIT+wd0d9VjitRyQef9BnzlzGwMODc=
modernc.org/libc v1.65.10/go.mod h1:StFvYpx7i/mXtBAfVOjaU0PWZOvIRoZSgXhrwXzr8Po=
modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks=
modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI=
modernc.org/libc v1.66.3 h1:cfCbjTUcdsKyyZZfEUKfoHcP3S0Wkvz3jgSzByEWVCQ=
modernc.org/libc v1.66.3/go.mod h1:XD9zO8kt59cANKvHPXpx7yS2ELPheAey0vjIuZOhOU8=
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI=

View file

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2021 gruf
Copyright (c) gruf
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

View file

@ -5,88 +5,10 @@ package format
import (
"reflect"
"unsafe"
"codeberg.org/gruf/go-xunsafe"
)
const (
// see: go/src/internal/abi/type.go
abi_KindDirectIface uint8 = 1 << 5
abi_KindMask uint8 = (1 << 5) - 1
)
// abi_Type is a copy of the memory layout of abi.Type{}.
//
// see: go/src/internal/abi/type.go
type abi_Type struct {
_ uintptr
PtrBytes uintptr
_ uint32
_ uint8
_ uint8
_ uint8
Kind_ uint8
_ func(unsafe.Pointer, unsafe.Pointer) bool
_ *byte
_ int32
_ int32
}
// abi_EmptyInterface is a copy of the memory layout of abi.EmptyInterface{},
// which is to say also the memory layout of any method-less interface.
//
// see: go/src/internal/abi/iface.go
type abi_EmptyInterface struct {
Type *abi_Type
Data unsafe.Pointer
}
// abi_NonEmptyInterface is a copy of the memory layout of abi.NonEmptyInterface{},
// which is to say also the memory layout of any interface containing method(s).
//
// see: go/src/internal/abi/iface.go on 1.25+
// see: go/src/reflect/value.go on 1.24
type abi_NonEmptyInterface struct {
ITab uintptr
Data unsafe.Pointer
}
// see: go/src/internal/abi/type.go Type.Kind()
func abi_Type_Kind(t reflect.Type) uint8 {
iface := (*abi_NonEmptyInterface)(unsafe.Pointer(&t))
atype := (*abi_Type)(unsafe.Pointer(iface.Data))
return atype.Kind_ & abi_KindMask
}
// see: go/src/internal/abi/type.go Type.IfaceIndir()
func abi_Type_IfaceIndir(t reflect.Type) bool {
iface := (*abi_NonEmptyInterface)(unsafe.Pointer(&t))
atype := (*abi_Type)(unsafe.Pointer(iface.Data))
return atype.Kind_&abi_KindDirectIface == 0
}
// pack_iface packs a new reflect.nonEmptyInterface{} using shielded
// itab and data pointer, returning a pointer for caller casting.
func pack_iface(itab uintptr, word unsafe.Pointer) unsafe.Pointer {
return unsafe.Pointer(&abi_NonEmptyInterface{
ITab: itab,
Data: word,
})
}
// get_iface_ITab generates a new value of given type,
// casts it to the generic param interface type, and
// returns the .itab portion of the reflect.nonEmptyInterface{}.
// this is useful for later calls to pack_iface for known type.
func get_iface_ITab[I any](t reflect.Type) uintptr {
s := reflect.New(t).Elem().Interface().(I)
i := (*abi_NonEmptyInterface)(unsafe.Pointer(&s))
return i.ITab
}
// unpack_eface returns the .Data portion of an abi.EmptyInterface{}.
func unpack_eface(a any) unsafe.Pointer {
return (*abi_EmptyInterface)(unsafe.Pointer((&a))).Data
}
// add returns the ptr addition of starting ptr and a delta.
func add(ptr unsafe.Pointer, delta uintptr) unsafe.Pointer {
return unsafe.Pointer(uintptr(ptr) + delta)
@ -97,167 +19,7 @@ func typeof[T any]() reflect.Type {
return reflect.TypeFor[T]()
}
// see: go/src/reflect/value.go
type reflect_flag uintptr
const (
// see: go/src/reflect/value.go
reflect_flagKindWidth = 5 // there are 27 kinds
reflect_flagKindMask reflect_flag = 1<<reflect_flagKindWidth - 1
reflect_flagStickyRO reflect_flag = 1 << 5
reflect_flagEmbedRO reflect_flag = 1 << 6
reflect_flagIndir reflect_flag = 1 << 7
reflect_flagAddr reflect_flag = 1 << 8
reflect_flagMethod reflect_flag = 1 << 9
reflect_flagMethodShift = 10
reflect_flagRO reflect_flag = reflect_flagStickyRO | reflect_flagEmbedRO
// custom flag to indicate key types.
flagKeyType = 1 << 10
// custom xunsafe.Reflect_flag to indicate key types.
flagKeyType xunsafe.Reflect_flag = 1 << 10
)
// reflect_iface_elem_flags returns the reflect_flag expected of an unboxed interface element of type.
//
// see: go/src/reflect/value.go unpackElem()
func reflect_iface_elem_flags(elemType reflect.Type) reflect_flag {
if elemType == nil {
return 0
}
flags := reflect_flag(abi_Type_Kind(elemType))
if abi_Type_IfaceIndir(elemType) {
flags |= reflect_flagIndir
}
return flags
}
// reflect_pointer_elem_flags returns the reflect_flag expected of a dereferenced pointer element of type.
//
// see: go/src/reflect/value.go Value.Elem()
func reflect_pointer_elem_flags(ptrFlags reflect_flag, elemType reflect.Type) reflect_flag {
return ptrFlags | reflect_flagIndir | reflect_flagAddr | reflect_flag(abi_Type_Kind(elemType))
}
// reflect_array_elem_flags returns the reflect_flag expected of an element of type in an array.
//
// see: go/src/reflect/value.go Value.Index()
func reflect_array_elem_flags(arrayFlags reflect_flag, elemType reflect.Type) reflect_flag {
return arrayFlags&(reflect_flagIndir|reflect_flagAddr) | reflect_flag(abi_Type_Kind(elemType))
}
// reflect_slice_elem_flags returns the reflect_flag expected of a slice element of type.
//
// see: go/src/reflect/value.go Value.Index()
func reflect_slice_elem_flags(elemType reflect.Type) reflect_flag {
return reflect_flagAddr | reflect_flagIndir | reflect_flag(abi_Type_Kind(elemType))
}
// reflect_struct_field_flags returns the reflect_flag expected of a struct field of type.
//
// see: go/src/reflect/value.go Value.Field()
func reflect_struct_field_flags(structFlags reflect_flag, fieldType reflect.Type) reflect_flag {
return structFlags&(reflect_flagIndir|reflect_flagAddr) | reflect_flag(abi_Type_Kind(fieldType))
}
// reflect_map_key_flags returns the reflect_flag expected of a map key of type (with our own key type mask set).
//
// see: go/src/reflect/map_swiss.go MapIter.Key()
func reflect_map_key_flags(keyType reflect.Type) reflect_flag {
return flagKeyType | reflect_flag(abi_Type_Kind(keyType))
}
// reflect_map_elem_flags returns the reflect_flag expected of a map element of type.
//
// see: go/src/reflect/map_swiss.go MapIter.Value()
func reflect_map_elem_flags(elemType reflect.Type) reflect_flag {
return reflect_flag(abi_Type_Kind(elemType))
}
// reflect_Value is a copy of the memory layout of reflect.Value{}.
//
// see: go/src/reflect/value.go
type reflect_Value struct {
typ_ unsafe.Pointer
ptr unsafe.Pointer
reflect_flag
}
func init() {
if unsafe.Sizeof(reflect_Value{}) != unsafe.Sizeof(reflect.Value{}) {
panic("reflect_Value{} not in sync with reflect.Value{}")
}
}
// reflect_type_data returns the .word from the reflect.Type{} cast
// as the reflect.nonEmptyInterface{}, which itself will be a pointer
// to the actual abi.Type{} that this reflect.Type{} is wrapping.
func reflect_type_data(t reflect.Type) unsafe.Pointer {
return (*abi_NonEmptyInterface)(unsafe.Pointer(&t)).Data
}
// build_reflect_value manually builds a reflect.Value{} by setting the internal field members.
func build_reflect_value(rtype reflect.Type, data unsafe.Pointer, flags reflect_flag) reflect.Value {
return *(*reflect.Value)(unsafe.Pointer(&reflect_Value{reflect_type_data(rtype), data, flags}))
}
// maps_Iter is a copy of the memory layout of maps.Iter{}.
//
// see: go/src/internal/runtime/maps/table.go
type maps_Iter struct {
key unsafe.Pointer
elem unsafe.Pointer
_ uintptr
_ uintptr
_ uint64
_ uint64
_ uint64
_ uint8
_ int
_ uintptr
_ struct{ _ unsafe.Pointer }
_ uint64
}
// reflect_MapIter is a copy of the memory layout of reflect.MapIter{}.
//
// see: go/src/reflect/map_swiss.go
type reflect_MapIter struct {
m reflect.Value
hiter maps_Iter
}
func init() {
if unsafe.Sizeof(reflect_MapIter{}) != unsafe.Sizeof(reflect.MapIter{}) {
panic("reflect_MapIter{} not in sync with reflect.MapIter{}")
}
}
// map_iter creates a new map iterator from value,
// skipping the initial v.MapRange() type checking.
func map_iter(v reflect.Value) *reflect.MapIter {
var i reflect_MapIter
i.m = v
return (*reflect.MapIter)(unsafe.Pointer(&i))
}
// map_key returns ptr to current map key in iter.
func map_key(i *reflect.MapIter) unsafe.Pointer {
return (*reflect_MapIter)(unsafe.Pointer(i)).hiter.key
}
// map_elem returns ptr to current map element in iter.
func map_elem(i *reflect.MapIter) unsafe.Pointer {
return (*reflect_MapIter)(unsafe.Pointer(i)).hiter.elem
}
// see: go/src/internal/unsafeheader/unsafeheader.go
type unsafeheader_Slice struct {
Data unsafe.Pointer
Len int
Cap int
}
// see: go/src/internal/unsafeheader/unsafeheader.go
type unsafeheader_String struct {
Data unsafe.Pointer
Len int
}

View file

@ -1,19 +1,23 @@
package format
import "unsafe"
import (
"unsafe"
"codeberg.org/gruf/go-xunsafe"
)
// iterArrayType returns a FormatFunc capable of iterating
// and formatting the given array type currently in typenode{}.
// and formatting the given array type currently in TypeIter{}.
// note this will fetch a sub-FormatFunc for the array element
// type, and also handle special cases of [n]byte, [n]rune arrays.
func (fmt *Formatter) iterArrayType(t typenode) FormatFunc {
func (fmt *Formatter) iterArrayType(t xunsafe.TypeIter) FormatFunc {
// Array element type.
elem := t.rtype.Elem()
elem := t.Type.Elem()
// Get nested elem typenode with appropriate flags.
flags := reflect_array_elem_flags(t.flags, elem)
et := t.next(elem, flags)
// Get nested elem TypeIter with appropriate flags.
flags := xunsafe.ReflectArrayElemFlags(t.Flag, elem)
et := t.Child(elem, flags)
// Get elem format func.
fn := fmt.loadOrGet(et)
@ -22,7 +26,7 @@ func (fmt *Formatter) iterArrayType(t typenode) FormatFunc {
}
// Handle possible sizes.
switch t.rtype.Len() {
switch t.Type.Len() {
case 0:
return emptyArrayType(t)
case 1:
@ -32,8 +36,8 @@ func (fmt *Formatter) iterArrayType(t typenode) FormatFunc {
}
}
func emptyArrayType(t typenode) FormatFunc {
if !t.needs_typestr() {
func emptyArrayType(t xunsafe.TypeIter) FormatFunc {
if !needs_typestr(t) {
// Simply append empty.
return func(s *State) {
s.B = append(s.B, "[]"...)
@ -41,7 +45,7 @@ func emptyArrayType(t typenode) FormatFunc {
}
// Array type string with refs.
typestr := t.typestr_with_refs()
typestr := typestr_with_refs(t)
// Append empty with type.
return func(s *State) {
@ -54,8 +58,8 @@ func emptyArrayType(t typenode) FormatFunc {
}
}
func iterSingleArrayType(t typenode, fn FormatFunc) FormatFunc {
if !t.needs_typestr() {
func iterSingleArrayType(t xunsafe.TypeIter, fn FormatFunc) FormatFunc {
if !needs_typestr(t) {
return func(s *State) {
// Wrap 'fn' in braces.
s.B = append(s.B, '[')
@ -65,7 +69,7 @@ func iterSingleArrayType(t typenode, fn FormatFunc) FormatFunc {
}
// Array type string with refs.
typestr := t.typestr_with_refs()
typestr := typestr_with_refs(t)
// Wrap in type+braces.
return func(s *State) {
@ -87,14 +91,14 @@ func iterSingleArrayType(t typenode, fn FormatFunc) FormatFunc {
}
}
func iterMultiArrayType(t typenode, fn FormatFunc) FormatFunc {
func iterMultiArrayType(t xunsafe.TypeIter, fn FormatFunc) FormatFunc {
// Array element in-memory size.
esz := t.rtype.Elem().Size()
esz := t.Type.Elem().Size()
// Number of elements.
n := t.rtype.Len()
n := t.Type.Len()
if !t.needs_typestr() {
if !needs_typestr(t) {
// Wrap elems in braces.
return func(s *State) {
ptr := s.P
@ -121,7 +125,7 @@ func iterMultiArrayType(t typenode, fn FormatFunc) FormatFunc {
}
// Array type string with refs.
typestr := t.typestr_with_refs()
typestr := typestr_with_refs(t)
// Wrap in type+braces.
return func(s *State) {
@ -158,13 +162,13 @@ func iterMultiArrayType(t typenode, fn FormatFunc) FormatFunc {
}
}
func wrapByteArray(t typenode, fn FormatFunc) FormatFunc {
n := t.rtype.Len()
if !t.needs_typestr() {
func wrapByteArray(t xunsafe.TypeIter, fn FormatFunc) FormatFunc {
n := t.Type.Len()
if !needs_typestr(t) {
return func(s *State) {
if s.A.AsText() || s.A.AsQuotedText() || s.A.AsQuotedASCII() {
var v string
p := (*unsafeheader_String)(unsafe.Pointer(&v))
p := (*xunsafe.Unsafeheader_String)(unsafe.Pointer(&v))
p.Len = n
p.Data = s.P
appendString(s, v)
@ -173,11 +177,11 @@ func wrapByteArray(t typenode, fn FormatFunc) FormatFunc {
}
}
}
typestr := t.typestr_with_ptrs()
typestr := typestr_with_ptrs(t)
return func(s *State) {
if s.A.AsText() || s.A.AsQuotedText() || s.A.AsQuotedASCII() {
var v string
p := (*unsafeheader_String)(unsafe.Pointer(&v))
p := (*xunsafe.Unsafeheader_String)(unsafe.Pointer(&v))
p.Len = n
p.Data = s.P
if s.A.WithType() {
@ -193,13 +197,13 @@ func wrapByteArray(t typenode, fn FormatFunc) FormatFunc {
}
}
func wrapRuneArray(t typenode, fn FormatFunc) FormatFunc {
n := t.rtype.Len()
if !t.needs_typestr() {
func wrapRuneArray(t xunsafe.TypeIter, fn FormatFunc) FormatFunc {
n := t.Type.Len()
if !needs_typestr(t) {
return func(s *State) {
if s.A.AsText() || s.A.AsQuotedText() || s.A.AsQuotedASCII() {
var v []rune
p := (*unsafeheader_Slice)(unsafe.Pointer(&v))
p := (*xunsafe.Unsafeheader_Slice)(unsafe.Pointer(&v))
p.Cap = n
p.Len = n
p.Data = s.P
@ -209,11 +213,11 @@ func wrapRuneArray(t typenode, fn FormatFunc) FormatFunc {
}
}
}
typestr := t.typestr_with_ptrs()
typestr := typestr_with_ptrs(t)
return func(s *State) {
if s.A.AsText() || s.A.AsQuotedText() || s.A.AsQuotedASCII() {
var v []rune
p := (*unsafeheader_Slice)(unsafe.Pointer(&v))
p := (*xunsafe.Unsafeheader_Slice)(unsafe.Pointer(&v))
p.Cap = n
p.Len = n
p.Data = s.P

60
vendor/codeberg.org/gruf/go-kv/v2/format/cache.go generated vendored Normal file
View file

@ -0,0 +1,60 @@
package format
import (
"sync/atomic"
"unsafe"
"codeberg.org/gruf/go-xunsafe"
)
// cache is a concurrency-safe map[xunsafe.TypeInfo]FormatFunc
// cache, designed for heavy reads but with unfortunately expensive
// writes. it is designed such that after some initial load period
// in which functions are cached by types, all future ops are reads.
type cache struct{ p unsafe.Pointer }
// Get will check cache for format func under key.
func (c *cache) Get(t xunsafe.TypeInfo) FormatFunc {
if p := c.load(); p != nil {
return (*p)[t]
}
return nil
}
// Put will place given format func in cache under key, if not already exists.
func (c *cache) Put(t xunsafe.TypeInfo, fn FormatFunc) {
for {
p := c.load()
var cache map[xunsafe.TypeInfo]FormatFunc
if p != nil {
if _, ok := (*p)[t]; ok {
return
}
cache = make(map[xunsafe.TypeInfo]FormatFunc, len(*p)+1)
for key, value := range *p {
cache[key] = value
}
} else {
cache = make(map[xunsafe.TypeInfo]FormatFunc, 1)
}
cache[t] = fn
if c.cas(p, &cache) {
return
}
}
}
// load is a typed wrapper around atomic.LoadPointer().
func (c *cache) load() *map[xunsafe.TypeInfo]FormatFunc {
return (*map[xunsafe.TypeInfo]FormatFunc)(atomic.LoadPointer(&c.p))
}
// cas is a typed wrapper around atomic.CompareAndSwapPointer().
func (c *cache) cas(old, new *map[xunsafe.TypeInfo]FormatFunc) bool {
return atomic.CompareAndSwapPointer(&c.p, unsafe.Pointer(old), unsafe.Pointer(new))
}

View file

@ -4,8 +4,9 @@ import (
"reflect"
"runtime/debug"
"strconv"
"sync"
"unsafe"
"codeberg.org/gruf/go-xunsafe"
)
// Global formatter instance.
@ -93,15 +94,7 @@ type Formatter struct {
// internal
// format func
// cache map.
fns sync.Map
}
// LoadFor returns a FormatFunc for the given value type.
func (fmt *Formatter) LoadFor(value any) FormatFunc {
rtype := reflect.TypeOf(value)
flags := reflect_iface_elem_flags(rtype)
t := new_typenode(rtype, flags)
return fmt.loadOrStore(t)
fns cache
}
// Append calls AppendState() with a newly allocated State{}, returning byte buffer.
@ -126,17 +119,17 @@ func (fmt *Formatter) AppendState(s *State, value any) {
// global defaults.
s.A = defaultArgs
}
s.P = unpack_eface(value)
t := xunsafe.TypeIterFrom(value)
s.P = xunsafe.UnpackEface(value)
s.ifaces.clear()
s.ifaces.set(s.P)
fmt.LoadFor(value)(s)
fmt.loadOrStore(t)(s)
}
func (fmt *Formatter) loadOrGet(t typenode) FormatFunc {
func (fmt *Formatter) loadOrGet(t xunsafe.TypeIter) FormatFunc {
// Look for existing stored
// func under this type key.
v, _ := fmt.fns.Load(t.key())
fn, _ := v.(FormatFunc)
fn := fmt.fns.Get(t.TypeInfo)
if fn == nil {
// Load format func
@ -150,14 +143,13 @@ func (fmt *Formatter) loadOrGet(t typenode) FormatFunc {
return fn
}
func (fmt *Formatter) loadOrStore(t typenode) FormatFunc {
func (fmt *Formatter) loadOrStore(t xunsafe.TypeIter) FormatFunc {
// Get cache key.
key := t.key()
key := t.TypeInfo
// Look for existing stored
// func under this type key.
v, _ := fmt.fns.Load(key)
fn, _ := v.(FormatFunc)
fn := fmt.fns.Get(key)
if fn == nil {
// Load format func
@ -167,8 +159,8 @@ func (fmt *Formatter) loadOrStore(t typenode) FormatFunc {
panic("unreachable")
}
// Store in map under type.
fmt.fns.Store(key, fn)
// Store under type.
fmt.fns.Put(key, fn)
}
return fn
@ -188,8 +180,8 @@ var (
runesType = typeof[[]rune]()
)
func (fmt *Formatter) get(t typenode) (fn FormatFunc) {
if t.rtype == nil {
func (fmt *Formatter) get(t xunsafe.TypeIter) (fn FormatFunc) {
if t.Type == nil {
// catch nil type.
return appendNil
}
@ -205,7 +197,7 @@ func (fmt *Formatter) get(t typenode) (fn FormatFunc) {
// Don't allow method functions for map keys,
// to prevent situation of the method receiver
// attempting to modify stored map key itself.
if t.flags&flagKeyType != 0 {
if t.Flag&flagKeyType != 0 {
return
}
@ -228,20 +220,20 @@ func (fmt *Formatter) get(t typenode) (fn FormatFunc) {
}
}()
if t.rtype == reflectTypeType {
if t.Type == reflectTypeType {
// DO NOT iterate down internal ABI
// types, some are in non-GC memory.
return getPointerType(t)
}
if !t.visit() {
if !visit(t) {
// On type recursion simply
// format as raw pointer.
return getPointerType(t)
}
// Get func for type kind.
switch t.rtype.Kind() {
switch t.Type.Kind() {
case reflect.Interface:
return fmt.getInterfaceType(t)
case reflect.String:
@ -269,7 +261,7 @@ func (fmt *Formatter) get(t typenode) (fn FormatFunc) {
case reflect.Pointer:
return fmt.derefPointerType(t)
case reflect.Array:
elem := t.rtype.Elem()
elem := t.Type.Elem()
switch fn := fmt.iterArrayType(t); {
case elem.AssignableTo(byteType):
return wrapByteArray(t, fn)
@ -280,9 +272,9 @@ func (fmt *Formatter) get(t typenode) (fn FormatFunc) {
}
case reflect.Slice:
switch fn := fmt.iterSliceType(t); {
case t.rtype.AssignableTo(bytesType):
case t.Type.AssignableTo(bytesType):
return wrapByteSlice(t, fn)
case t.rtype.AssignableTo(runesType):
case t.Type.AssignableTo(runesType):
return wrapRuneSlice(t, fn)
default:
return fn
@ -296,12 +288,12 @@ func (fmt *Formatter) get(t typenode) (fn FormatFunc) {
}
}
func (fmt *Formatter) getInterfaceType(t typenode) FormatFunc {
if t.rtype.NumMethod() == 0 {
func (fmt *Formatter) getInterfaceType(t xunsafe.TypeIter) FormatFunc {
if t.Type.NumMethod() == 0 {
return func(s *State) {
// Unpack empty interface.
eface := *(*any)(s.P)
s.P = unpack_eface(eface)
s.P = xunsafe.UnpackEface(eface)
// Get reflected type information.
rtype := reflect.TypeOf(eface)
@ -319,9 +311,10 @@ func (fmt *Formatter) getInterfaceType(t typenode) FormatFunc {
// Store value ptr.
s.ifaces.set(s.P)
// Wrap in our typenode for before load.
flags := reflect_iface_elem_flags(rtype)
t := new_typenode(rtype, flags)
// Wrap before load.
var t xunsafe.TypeIter
t.Flag = xunsafe.ReflectIfaceElemFlags(rtype)
t.Type = rtype
// Load + pass to func.
fmt.loadOrStore(t)(s)
@ -330,7 +323,7 @@ func (fmt *Formatter) getInterfaceType(t typenode) FormatFunc {
return func(s *State) {
// Unpack interface-with-method ptr.
iface := *(*interface{ M() })(s.P)
s.P = unpack_eface(iface)
s.P = xunsafe.UnpackEface(iface)
// Get reflected type information.
rtype := reflect.TypeOf(iface)
@ -348,9 +341,10 @@ func (fmt *Formatter) getInterfaceType(t typenode) FormatFunc {
// Store value ptr.
s.ifaces.set(s.P)
// Wrap in our typenode for before load.
flags := reflect_iface_elem_flags(rtype)
t := new_typenode(rtype, flags)
// Wrap before load.
var t xunsafe.TypeIter
t.Flag = xunsafe.ReflectIfaceElemFlags(rtype)
t.Type = rtype
// Load + pass to func.
fmt.loadOrStore(t)(s)
@ -358,20 +352,20 @@ func (fmt *Formatter) getInterfaceType(t typenode) FormatFunc {
}
}
func getStringType(t typenode) FormatFunc {
func getStringType(t xunsafe.TypeIter) FormatFunc {
return with_typestr_ptrs(t, func(s *State) {
appendString(s, *(*string)(s.P))
})
}
func getBoolType(t typenode) FormatFunc {
func getBoolType(t xunsafe.TypeIter) FormatFunc {
return with_typestr_ptrs(t, func(s *State) {
s.B = strconv.AppendBool(s.B, *(*bool)(s.P))
})
}
func getIntType(t typenode) FormatFunc {
switch t.rtype.Bits() {
func getIntType(t xunsafe.TypeIter) FormatFunc {
switch t.Type.Bits() {
case 8:
return with_typestr_ptrs(t, func(s *State) {
appendInt(s, int64(*(*int8)(s.P)))
@ -403,8 +397,8 @@ func getIntType(t typenode) FormatFunc {
}
}
func getUintType(t typenode) FormatFunc {
switch t.rtype.Bits() {
func getUintType(t xunsafe.TypeIter) FormatFunc {
switch t.Type.Bits() {
case 8:
return with_typestr_ptrs(t, func(s *State) {
switch {
@ -433,8 +427,8 @@ func getUintType(t typenode) FormatFunc {
}
}
func getFloatType(t typenode) FormatFunc {
switch t.rtype.Bits() {
func getFloatType(t xunsafe.TypeIter) FormatFunc {
switch t.Type.Bits() {
case 32:
return with_typestr_ptrs(t, func(s *State) {
appendFloat(s, float64(*(*float32)(s.P)), 32)
@ -448,8 +442,8 @@ func getFloatType(t typenode) FormatFunc {
}
}
func getComplexType(t typenode) FormatFunc {
switch t.rtype.Bits() {
func getComplexType(t xunsafe.TypeIter) FormatFunc {
switch t.Type.Bits() {
case 64:
return with_typestr_ptrs(t, func(s *State) {
v := *(*complex64)(s.P)
@ -467,8 +461,8 @@ func getComplexType(t typenode) FormatFunc {
}
}
func getPointerType(t typenode) FormatFunc {
switch t.indirect() {
func getPointerType(t xunsafe.TypeIter) FormatFunc {
switch t.Indirect() {
case true:
return with_typestr_ptrs(t, func(s *State) {
s.P = *(*unsafe.Pointer)(s.P)
@ -483,18 +477,18 @@ func getPointerType(t typenode) FormatFunc {
}
}
func with_typestr_ptrs(t typenode, fn FormatFunc) FormatFunc {
func with_typestr_ptrs(t xunsafe.TypeIter, fn FormatFunc) FormatFunc {
if fn == nil {
panic("nil func")
}
// Check for type wrapping.
if !t.needs_typestr() {
if !needs_typestr(t) {
return fn
}
// Get type string with pointers.
typestr := t.typestr_with_ptrs()
typestr := typestr_with_ptrs(t)
// Wrap format func to include
// type information when needed.

View file

@ -1,21 +1,25 @@
package format
import "unsafe"
import (
"unsafe"
"codeberg.org/gruf/go-xunsafe"
)
// iterMapType returns a FormatFunc capable of iterating
// and formatting the given map type currently in typenode{}.
// and formatting the given map type currently in TypeIter{}.
// note this will fetch sub-FormatFuncs for key / value types.
func (fmt *Formatter) iterMapType(t typenode) FormatFunc {
func (fmt *Formatter) iterMapType(t xunsafe.TypeIter) FormatFunc {
// Key / value types.
key := t.rtype.Key()
elem := t.rtype.Elem()
key := t.Type.Key()
elem := t.Type.Elem()
// Get nested k / v typenodes with appropriate flags.
flagsKey := reflect_map_key_flags(key)
flagsVal := reflect_map_elem_flags(elem)
kt := t.next(t.rtype.Key(), flagsKey)
vt := t.next(t.rtype.Elem(), flagsVal)
// Get nested k / v TypeIters with appropriate flags.
flagsKey := xunsafe.ReflectMapKeyFlags(key) | flagKeyType
flagsVal := xunsafe.ReflectMapElemFlags(elem)
kt := t.Child(key, flagsKey)
vt := t.Child(elem, flagsVal)
// Get key format func.
kfn := fmt.loadOrGet(kt)
@ -30,14 +34,14 @@ func (fmt *Formatter) iterMapType(t typenode) FormatFunc {
}
// Final map type.
rtype := t.rtype
flags := t.flags
rtype := t.Type
flags := t.Flag
// Map type string with ptrs / refs.
typestrPtrs := t.typestr_with_ptrs()
typestrRefs := t.typestr_with_refs()
typestrPtrs := typestr_with_ptrs(t)
typestrRefs := typestr_with_refs(t)
if !t.needs_typestr() {
if !needs_typestr(t) {
return func(s *State) {
if s.P == nil || *(*unsafe.Pointer)(s.P) == nil {
// Append nil.
@ -45,9 +49,9 @@ func (fmt *Formatter) iterMapType(t typenode) FormatFunc {
return
}
// Build reflect value, and then a map iter.
v := build_reflect_value(rtype, s.P, flags)
i := map_iter(v)
// Build reflect value, and then a map iterator.
v := xunsafe.BuildReflectValue(rtype, s.P, flags)
i := xunsafe.GetMapIter(v)
// Prepend object brace.
s.B = append(s.B, '{')
@ -56,15 +60,15 @@ func (fmt *Formatter) iterMapType(t typenode) FormatFunc {
l := len(s.B)
for i.Next() {
// Pass to key fn.
s.P = map_key(i)
// Pass to map key func.
s.P = xunsafe.Map_Key(i)
kfn(s)
// Add key seperator.
s.B = append(s.B, '=')
// Pass to elem fn.
s.P = map_elem(i)
// Pass to map elem func.
s.P = xunsafe.Map_Elem(i)
vfn(s)
// Add comma pair seperator.
@ -89,8 +93,8 @@ func (fmt *Formatter) iterMapType(t typenode) FormatFunc {
}
// Build reflect value, and then a map iter.
v := build_reflect_value(rtype, s.P, flags)
i := map_iter(v)
v := xunsafe.BuildReflectValue(rtype, s.P, flags)
i := xunsafe.GetMapIter(v)
// Include type info.
if s.A.WithType() {
@ -104,15 +108,15 @@ func (fmt *Formatter) iterMapType(t typenode) FormatFunc {
l := len(s.B)
for i.Next() {
// Pass to key fn.
s.P = map_key(i)
// Pass to map key func.
s.P = xunsafe.Map_Key(i)
kfn(s)
// Add key seperator.
s.B = append(s.B, '=')
// Pass to elem fn.
s.P = map_elem(i)
// Pass to map elem func.
s.P = xunsafe.Map_Elem(i)
vfn(s)
// Add comma pair seperator.

View file

@ -3,31 +3,45 @@ package format
import (
"reflect"
"unsafe"
"codeberg.org/gruf/go-xunsafe"
)
type Stringer interface{ String() string }
type Formattable interface{ Format(*State) }
var (
// stringer type for implement checks.
stringerType = typeof[Stringer]()
// formattableType type for implement checks.
formattableType = typeof[Formattable]()
// error type for implement checks.
errorType = typeof[error]()
)
// getMethodType returns a *possible* FormatFunc to handle case
// of a type that implements any known interface{} types, else nil.
func getMethodType(t typenode) FormatFunc {
func getMethodType(t xunsafe.TypeIter) FormatFunc {
switch {
case t.rtype.Implements(stringerType):
switch t.rtype.Kind() {
case t.Type.Implements(stringerType):
switch t.Type.Kind() {
case reflect.Interface:
return getInterfaceStringerType(t)
default:
return getConcreteStringerType(t)
}
case t.rtype.Implements(errorType):
switch t.rtype.Kind() {
case t.Type.Implements(formattableType):
switch t.Type.Kind() {
case reflect.Interface:
return getInterfaceFormattableType(t)
default:
return getConcreteFormattableType(t)
}
case t.Type.Implements(errorType):
switch t.Type.Kind() {
case reflect.Interface:
return getInterfaceErrorType(t)
default:
@ -40,12 +54,12 @@ func getMethodType(t typenode) FormatFunc {
// getInterfaceStringerType returns a FormatFunc to handle case of an interface{}
// type that implements Stringer{}, i.e. Stringer{} itself and any superset of.
func getInterfaceStringerType(t typenode) FormatFunc {
switch t.indirect() && !t.iface_indir() {
func getInterfaceStringerType(t xunsafe.TypeIter) FormatFunc {
switch t.Indirect() && !t.IfaceIndir() {
case true:
return with_typestr_ptrs(t, func(s *State) {
s.P = *(*unsafe.Pointer)(s.P)
if s.P == nil || (*abi_NonEmptyInterface)(s.P).Data == nil {
if s.P == nil || (*xunsafe.Abi_NonEmptyInterface)(s.P).Data == nil {
appendNil(s)
return
}
@ -54,7 +68,7 @@ func getInterfaceStringerType(t typenode) FormatFunc {
})
case false:
return with_typestr_ptrs(t, func(s *State) {
if s.P == nil || (*abi_NonEmptyInterface)(s.P).Data == nil {
if s.P == nil || (*xunsafe.Abi_NonEmptyInterface)(s.P).Data == nil {
appendNil(s)
return
}
@ -68,9 +82,9 @@ func getInterfaceStringerType(t typenode) FormatFunc {
// getConcreteStringerType returns a FormatFunc to handle case of concrete
// (i.e. non-interface{}) type that has a Stringer{} method receiver.
func getConcreteStringerType(t typenode) FormatFunc {
itab := get_iface_ITab[Stringer](t.rtype)
switch t.indirect() && !t.iface_indir() {
func getConcreteStringerType(t xunsafe.TypeIter) FormatFunc {
itab := xunsafe.GetIfaceITab[Stringer](t.Type)
switch t.Indirect() && !t.IfaceIndir() {
case true:
return with_typestr_ptrs(t, func(s *State) {
s.P = *(*unsafe.Pointer)(s.P)
@ -78,17 +92,66 @@ func getConcreteStringerType(t typenode) FormatFunc {
appendNil(s)
return
}
v := *(*Stringer)(pack_iface(itab, s.P))
v := *(*Stringer)(xunsafe.PackIface(itab, s.P))
appendString(s, v.String())
})
case false:
return with_typestr_ptrs(t, func(s *State) {
v := *(*Stringer)(xunsafe.PackIface(itab, s.P))
appendString(s, v.String())
})
default:
panic("unreachable")
}
}
// getInterfaceFormattableType returns a FormatFunc to handle case of an interface{}
// type that implements Formattable{}, i.e. Formattable{} itself and any superset of.
func getInterfaceFormattableType(t xunsafe.TypeIter) FormatFunc {
switch t.Indirect() && !t.IfaceIndir() {
case true:
return with_typestr_ptrs(t, func(s *State) {
s.P = *(*unsafe.Pointer)(s.P)
if s.P == nil || (*xunsafe.Abi_NonEmptyInterface)(s.P).Data == nil {
appendNil(s)
return
}
v := *(*Formattable)(s.P)
v.Format(s)
})
case false:
return with_typestr_ptrs(t, func(s *State) {
if s.P == nil || (*xunsafe.Abi_NonEmptyInterface)(s.P).Data == nil {
appendNil(s)
return
}
v := *(*Formattable)(s.P)
v.Format(s)
})
default:
panic("unreachable")
}
}
// getConcreteFormattableType returns a FormatFunc to handle case of concrete
// (i.e. non-interface{}) type that has a Formattable{} method receiver.
func getConcreteFormattableType(t xunsafe.TypeIter) FormatFunc {
itab := xunsafe.GetIfaceITab[Formattable](t.Type)
switch t.Indirect() && !t.IfaceIndir() {
case true:
return with_typestr_ptrs(t, func(s *State) {
s.P = *(*unsafe.Pointer)(s.P)
if s.P == nil {
appendNil(s)
return
}
v := *(*Stringer)(pack_iface(itab, s.P))
appendString(s, v.String())
v := *(*Formattable)(xunsafe.PackIface(itab, s.P))
v.Format(s)
})
case false:
return with_typestr_ptrs(t, func(s *State) {
v := *(*Formattable)(xunsafe.PackIface(itab, s.P))
v.Format(s)
})
default:
panic("unreachable")
@ -97,12 +160,12 @@ func getConcreteStringerType(t typenode) FormatFunc {
// getInterfaceErrorType returns a FormatFunc to handle case of an interface{}
// type that implements error{}, i.e. error{} itself and any superset of.
func getInterfaceErrorType(t typenode) FormatFunc {
switch t.indirect() && !t.iface_indir() {
func getInterfaceErrorType(t xunsafe.TypeIter) FormatFunc {
switch t.Indirect() && !t.IfaceIndir() {
case true:
return with_typestr_ptrs(t, func(s *State) {
s.P = *(*unsafe.Pointer)(s.P)
if s.P == nil || (*abi_NonEmptyInterface)(s.P).Data == nil {
if s.P == nil || (*xunsafe.Abi_NonEmptyInterface)(s.P).Data == nil {
appendNil(s)
return
}
@ -111,7 +174,7 @@ func getInterfaceErrorType(t typenode) FormatFunc {
})
case false:
return with_typestr_ptrs(t, func(s *State) {
if s.P == nil || (*abi_NonEmptyInterface)(s.P).Data == nil {
if s.P == nil || (*xunsafe.Abi_NonEmptyInterface)(s.P).Data == nil {
appendNil(s)
return
}
@ -125,9 +188,9 @@ func getInterfaceErrorType(t typenode) FormatFunc {
// getConcreteErrorType returns a FormatFunc to handle case of concrete
// (i.e. non-interface{}) type that has an error{} method receiver.
func getConcreteErrorType(t typenode) FormatFunc {
itab := get_iface_ITab[error](t.rtype)
switch t.indirect() && !t.iface_indir() {
func getConcreteErrorType(t xunsafe.TypeIter) FormatFunc {
itab := xunsafe.GetIfaceITab[error](t.Type)
switch t.Indirect() && !t.IfaceIndir() {
case true:
return with_typestr_ptrs(t, func(s *State) {
s.P = *(*unsafe.Pointer)(s.P)
@ -135,16 +198,12 @@ func getConcreteErrorType(t typenode) FormatFunc {
appendNil(s)
return
}
v := *(*error)(pack_iface(itab, s.P))
v := *(*error)(xunsafe.PackIface(itab, s.P))
appendString(s, v.Error())
})
case false:
return with_typestr_ptrs(t, func(s *State) {
if s.P == nil {
appendNil(s)
return
}
v := *(*error)(pack_iface(itab, s.P))
v := *(*error)(xunsafe.PackIface(itab, s.P))
appendString(s, v.Error())
})
default:

View file

@ -3,34 +3,36 @@ package format
import (
"reflect"
"unsafe"
"codeberg.org/gruf/go-xunsafe"
)
// derefPointerType returns a FormatFunc capable of dereferencing
// and formatting the given pointer type currently in typenode{}.
// and formatting the given pointer type currently in TypeIter{}.
// note this will fetch a sub-FormatFunc for resulting value type.
func (fmt *Formatter) derefPointerType(t typenode) FormatFunc {
func (fmt *Formatter) derefPointerType(t xunsafe.TypeIter) FormatFunc {
var n int
rtype := t.rtype
flags := t.flags
rtype := t.Type
flags := t.Flag
// Iteratively dereference pointer types.
for rtype.Kind() == reflect.Pointer {
// If this is actual indirect
// memory, increase dereferences.
if flags&reflect_flagIndir != 0 {
// If this actual indirect memory,
// increase dereferences counter.
if flags&xunsafe.Reflect_flagIndir != 0 {
n++
}
// Get next elem type.
rtype = rtype.Elem()
// Get next set of dereferenced elem type flags.
flags = reflect_pointer_elem_flags(flags, rtype)
// Get next set of dereferenced element type flags.
flags = xunsafe.ReflectPointerElemFlags(flags, rtype)
}
// Wrap value as typenode.
vt := t.next(rtype, flags)
// Wrap value as TypeIter.
vt := t.Child(rtype, flags)
// Get value format func.
fn := fmt.loadOrGet(vt)
@ -38,7 +40,7 @@ func (fmt *Formatter) derefPointerType(t typenode) FormatFunc {
panic("unreachable")
}
if !t.needs_typestr() {
if !needs_typestr(t) {
if n <= 0 {
// No derefs are needed.
return func(s *State) {
@ -83,7 +85,7 @@ func (fmt *Formatter) derefPointerType(t typenode) FormatFunc {
}
// Final type string with ptrs.
typestr := t.typestr_with_ptrs()
typestr := typestr_with_ptrs(t)
if n <= 0 {
// No derefs are needed.

View file

@ -1,18 +1,20 @@
package format
import "codeberg.org/gruf/go-xunsafe"
// iterSliceType returns a FormatFunc capable of iterating
// and formatting the given slice type currently in typenode{}.
// and formatting the given slice type currently in TypeIter{}.
// note this will fetch a sub-FormatFunc for the slice element
// type, and also handle special cases of []byte, []rune slices.
func (fmt *Formatter) iterSliceType(t typenode) FormatFunc {
func (fmt *Formatter) iterSliceType(t xunsafe.TypeIter) FormatFunc {
// Get nested element type.
elem := t.rtype.Elem()
elem := t.Type.Elem()
esz := elem.Size()
// Get nested elem typenode with flags.
flags := reflect_slice_elem_flags(elem)
et := t.next(elem, flags)
// Get nested elem TypeIter{} with flags.
flags := xunsafe.ReflectSliceElemFlags(elem)
et := t.Child(elem, flags)
// Get elem format func.
fn := fmt.loadOrGet(et)
@ -20,12 +22,12 @@ func (fmt *Formatter) iterSliceType(t typenode) FormatFunc {
panic("unreachable")
}
if !t.needs_typestr() {
if !needs_typestr(t) {
return func(s *State) {
ptr := s.P
// Get data as unsafe slice header.
hdr := (*unsafeheader_Slice)(ptr)
hdr := (*xunsafe.Unsafeheader_Slice)(ptr)
if hdr == nil || hdr.Data == nil {
// Append nil.
@ -57,14 +59,14 @@ func (fmt *Formatter) iterSliceType(t typenode) FormatFunc {
}
// Slice type string with ptrs / refs.
typestrPtrs := t.typestr_with_ptrs()
typestrRefs := t.typestr_with_refs()
typestrPtrs := typestr_with_ptrs(t)
typestrRefs := typestr_with_refs(t)
return func(s *State) {
ptr := s.P
// Get data as unsafe slice header.
hdr := (*unsafeheader_Slice)(ptr)
hdr := (*xunsafe.Unsafeheader_Slice)(ptr)
if hdr == nil || hdr.Data == nil {
// Append nil value with type.
@ -105,8 +107,8 @@ func (fmt *Formatter) iterSliceType(t typenode) FormatFunc {
}
}
func wrapByteSlice(t typenode, fn FormatFunc) FormatFunc {
if !t.needs_typestr() {
func wrapByteSlice(t xunsafe.TypeIter, fn FormatFunc) FormatFunc {
if !needs_typestr(t) {
return func(s *State) {
if s.A.AsText() || s.A.AsQuotedText() || s.A.AsQuotedASCII() {
appendString(s, *(*string)(s.P))
@ -115,7 +117,7 @@ func wrapByteSlice(t typenode, fn FormatFunc) FormatFunc {
}
}
}
typestr := t.typestr_with_ptrs()
typestr := typestr_with_ptrs(t)
return func(s *State) {
if s.A.AsText() || s.A.AsQuotedText() || s.A.AsQuotedASCII() {
if s.A.WithType() {
@ -131,8 +133,8 @@ func wrapByteSlice(t typenode, fn FormatFunc) FormatFunc {
}
}
func wrapRuneSlice(t typenode, fn FormatFunc) FormatFunc {
if !t.needs_typestr() {
func wrapRuneSlice(t xunsafe.TypeIter, fn FormatFunc) FormatFunc {
if !needs_typestr(t) {
return func(s *State) {
if s.A.AsText() || s.A.AsQuotedText() || s.A.AsQuotedASCII() {
appendString(s, string(*(*[]rune)(s.P)))
@ -141,7 +143,7 @@ func wrapRuneSlice(t typenode, fn FormatFunc) FormatFunc {
}
}
}
typestr := t.typestr_with_ptrs()
typestr := typestr_with_ptrs(t)
return func(s *State) {
if s.A.AsText() || s.A.AsQuotedText() || s.A.AsQuotedASCII() {
if s.A.WithType() {

View file

@ -1,5 +1,7 @@
package format
import "codeberg.org/gruf/go-xunsafe"
// field stores the minimum necessary
// data for iterating and formatting
// each field in a given struct.
@ -10,23 +12,23 @@ type field struct {
}
// iterStructType returns a FormatFunc capable of iterating
// and formatting the given struct type currently in typenode{}.
// and formatting the given struct type currently in TypeIter{}.
// note this will fetch sub-FormatFuncs for each struct field.
func (fmt *Formatter) iterStructType(t typenode) FormatFunc {
func (fmt *Formatter) iterStructType(t xunsafe.TypeIter) FormatFunc {
// Number of struct fields.
n := t.rtype.NumField()
n := t.Type.NumField()
// Gather format functions.
fields := make([]field, n)
for i := 0; i < n; i++ {
// Get struct field at index.
sfield := t.rtype.Field(i)
sfield := t.Type.Field(i)
rtype := sfield.Type
// Get nested field typenode with appropriate flags.
flags := reflect_struct_field_flags(t.flags, rtype)
ft := t.next(sfield.Type, flags)
// Get nested field TypeIter with appropriate flags.
flags := xunsafe.ReflectStructFieldFlags(t.Flag, rtype)
ft := t.Child(sfield.Type, flags)
// Get field format func.
fn := fmt.loadOrGet(ft)
@ -53,8 +55,8 @@ func (fmt *Formatter) iterStructType(t typenode) FormatFunc {
}
}
func emptyStructType(t typenode) FormatFunc {
if !t.needs_typestr() {
func emptyStructType(t xunsafe.TypeIter) FormatFunc {
if !needs_typestr(t) {
return func(s *State) {
// Append empty object.
s.B = append(s.B, "{}"...)
@ -62,7 +64,7 @@ func emptyStructType(t typenode) FormatFunc {
}
// Struct type string with refs.
typestr := t.typestr_with_refs()
typestr := typestr_with_refs(t)
// Append empty object
// with type information.
@ -74,12 +76,12 @@ func emptyStructType(t typenode) FormatFunc {
}
}
func iterSingleFieldStructType(t typenode, field field) FormatFunc {
func iterSingleFieldStructType(t xunsafe.TypeIter, field field) FormatFunc {
if field.format == nil {
panic("nil func")
}
if !t.needs_typestr() {
if !needs_typestr(t) {
return func(s *State) {
// Wrap 'fn' with braces + field name.
s.B = append(s.B, "{"+field.name+"="...)
@ -89,7 +91,7 @@ func iterSingleFieldStructType(t typenode, field field) FormatFunc {
}
// Struct type string with refs.
typestr := t.typestr_with_refs()
typestr := typestr_with_refs(t)
return func(s *State) {
// Include type info.
@ -104,14 +106,14 @@ func iterSingleFieldStructType(t typenode, field field) FormatFunc {
}
}
func iterMultiFieldStructType(t typenode, fields []field) FormatFunc {
func iterMultiFieldStructType(t xunsafe.TypeIter, fields []field) FormatFunc {
for _, field := range fields {
if field.format == nil {
panic("nil func")
}
}
if !t.needs_typestr() {
if !needs_typestr(t) {
return func(s *State) {
ptr := s.P
@ -139,7 +141,7 @@ func iterMultiFieldStructType(t typenode, fields []field) FormatFunc {
}
// Struct type string with refs.
typestr := t.typestr_with_refs()
typestr := typestr_with_refs(t)
return func(s *State) {
ptr := s.P

View file

@ -3,58 +3,17 @@ package format
import (
"reflect"
"strings"
"codeberg.org/gruf/go-xunsafe"
)
// typenode ...
type typenode struct {
typeinfo
parent *typenode
}
// typeinfo ...
type typeinfo struct {
rtype reflect.Type
flags reflect_flag
}
// new_typenode returns a new typenode{} with reflect.Type and flags.
func new_typenode(t reflect.Type, flags reflect_flag) typenode {
return typenode{typeinfo: typeinfo{
rtype: t,
flags: flags,
}}
}
// key returns data (i.e. type value info)
// to store a FormatFunc under in a cache.
func (n typenode) key() typeinfo {
return n.typeinfo
}
// indirect returns whether reflect_flagIndir is set for given type flags.
func (n typenode) indirect() bool {
return n.flags&reflect_flagIndir != 0
}
// iface_indir returns the result of abi.Type{}.IfaceIndir() for underlying type.
func (n typenode) iface_indir() bool {
return abi_Type_IfaceIndir(n.rtype)
}
// next ...
func (n typenode) next(t reflect.Type, flags reflect_flag) typenode {
child := new_typenode(t, flags)
child.parent = &n
return child
}
// visit ...
func (n typenode) visit() bool {
t := n.rtype
func visit(iter xunsafe.TypeIter) bool {
t := iter.Type
// Check if type is already encountered further up tree.
for node := n.parent; node != nil; node = node.parent {
if node.rtype == t {
for node := iter.Parent; node != nil; node = node.Parent {
if node.Type == t {
return false
}
}
@ -63,16 +22,16 @@ func (n typenode) visit() bool {
}
// needs_typestr returns whether the type contained in the
// receiving typenode{} needs type string information prefixed
// receiving TypeIter{} needs type string information prefixed
// when the TypeMask argument flag bit is set. Certain types
// don't need this as the parent type already indicates this.
func (n typenode) needs_typestr() bool {
if n.parent == nil {
func needs_typestr(iter xunsafe.TypeIter) bool {
if iter.Parent == nil {
return true
}
switch p := n.parent.rtype; p.Kind() {
switch p := iter.Parent.Type; p.Kind() {
case reflect.Pointer:
return n.parent.needs_typestr()
return needs_typestr(*iter.Parent)
case reflect.Slice,
reflect.Array,
reflect.Map:
@ -83,17 +42,17 @@ func (n typenode) needs_typestr() bool {
}
// typestr_with_ptrs returns the type string for
// current typenode{} with asterisks for pointers.
func (n typenode) typestr_with_ptrs() string {
t := n.rtype
// current xunsafe.TypeIter{} with asterisks for pointers.
func typestr_with_ptrs(iter xunsafe.TypeIter) string {
t := iter.Type
// Check for parent.
if n.parent == nil {
if iter.Parent == nil {
return t.String()
}
// Get parent type.
p := n.parent.rtype
p := iter.Parent.Type
// If parent is not ptr, then
// this was not a deref'd ptr.
@ -107,17 +66,17 @@ func (n typenode) typestr_with_ptrs() string {
}
// typestr_with_refs returns the type string for
// current typenode{} with ampersands for pointers.
func (n typenode) typestr_with_refs() string {
t := n.rtype
// current xunsafe.TypeIter{} with ampersands for pointers.
func typestr_with_refs(iter xunsafe.TypeIter) string {
t := iter.Type
// Check for parent.
if n.parent == nil {
if iter.Parent == nil {
return t.String()
}
// Get parent type.
p := n.parent.rtype
p := iter.Parent.Type
var d int

9
vendor/codeberg.org/gruf/go-xunsafe/LICENSE generated vendored Normal file
View file

@ -0,0 +1,9 @@
MIT License
Copyright (c) gruf
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

3
vendor/codeberg.org/gruf/go-xunsafe/README.md generated vendored Normal file
View file

@ -0,0 +1,3 @@
# go-xunsafe
xunafe as in EXTRA UNSAFE. this exposes reflect and internal ABI package data structures in a manner that is kept up-to-date and version gated by the compile-time Go version. This package performs no validity checks on the data you provide to it, it is expected that you know what you are doing. Not to mention that some of the internal ABI data must only be exposed VERY carefully given that it is in non garbage-collected memory.

109
vendor/codeberg.org/gruf/go-xunsafe/abi.go generated vendored Normal file
View file

@ -0,0 +1,109 @@
//go:build go1.24 && !go1.26
package xunsafe
import (
"reflect"
"unsafe"
)
func init() {
// TypeOf(reflect.Type{}) == *struct{ abi.Type{} }
t := reflect.TypeOf(reflect.TypeOf(0)).Elem()
if t.Size() != unsafe.Sizeof(Abi_Type{}) {
panic("Abi_Type{} not in sync with abi.Type{}")
}
}
const (
// see: go/src/internal/abi/type.go
Abi_KindDirectIface uint8 = 1 << 5
Abi_KindMask uint8 = (1 << 5) - 1
)
// Abi_Type is a copy of the memory layout of abi.Type{}.
//
// see: go/src/internal/abi/type.go
type Abi_Type struct {
_ uintptr
PtrBytes uintptr
_ uint32
_ uint8
_ uint8
_ uint8
Kind_ uint8
_ func(unsafe.Pointer, unsafe.Pointer) bool
_ *byte
_ int32
_ int32
}
// Abi_EmptyInterface is a copy of the memory layout of abi.EmptyInterface{},
// which is to say also the memory layout of any method-less interface.
//
// see: go/src/internal/abi/iface.go
type Abi_EmptyInterface struct {
Type *Abi_Type
Data unsafe.Pointer
}
// Abi_NonEmptyInterface is a copy of the memory layout of abi.NonEmptyInterface{},
// which is to say also the memory layout of any interface containing method(s).
//
// see: go/src/internal/abi/iface.go on 1.25+
// see: go/src/reflect/value.go on 1.24
type Abi_NonEmptyInterface struct {
ITab uintptr
Data unsafe.Pointer
}
// see: go/src/internal/abi/type.go Type.Kind()
func Abi_Type_Kind(t reflect.Type) uint8 {
iface := (*Abi_NonEmptyInterface)(unsafe.Pointer(&t))
atype := (*Abi_Type)(unsafe.Pointer(iface.Data))
return atype.Kind_ & Abi_KindMask
}
// see: go/src/internal/abi/type.go Type.IfaceIndir()
func Abi_Type_IfaceIndir(t reflect.Type) bool {
iface := (*Abi_NonEmptyInterface)(unsafe.Pointer(&t))
atype := (*Abi_Type)(unsafe.Pointer(iface.Data))
return atype.Kind_&Abi_KindDirectIface == 0
}
// PackIface packs a new reflect.nonEmptyInterface{} using shielded
// itab and data pointer, returning a pointer for caller casting.
func PackIface(itab uintptr, word unsafe.Pointer) unsafe.Pointer {
return unsafe.Pointer(&Abi_NonEmptyInterface{
ITab: itab,
Data: word,
})
}
// GetIfaceITab generates a new value of given type,
// casts it to the generic param interface type, and
// returns the .itab portion of the abi.NonEmptyInterface{}.
// this is useful for later calls to PackIface for known type.
func GetIfaceITab[I any](t reflect.Type) uintptr {
s := reflect.New(t).Elem().Interface().(I)
i := (*Abi_NonEmptyInterface)(unsafe.Pointer(&s))
return i.ITab
}
// UnpackEface returns the .Data portion of an abi.EmptyInterface{}.
func UnpackEface(a any) unsafe.Pointer {
return (*Abi_EmptyInterface)(unsafe.Pointer((&a))).Data
}
// see: go/src/internal/unsafeheader/unsafeheader.go
type Unsafeheader_Slice struct {
Data unsafe.Pointer
Len int
Cap int
}
// see: go/src/internal/unsafeheader/unsafeheader.go
type Unsafeheader_String struct {
Data unsafe.Pointer
Len int
}

157
vendor/codeberg.org/gruf/go-xunsafe/reflect.go generated vendored Normal file
View file

@ -0,0 +1,157 @@
//go:build go1.24 && !go1.26
package xunsafe
import (
"reflect"
"unsafe"
)
// see: go/src/reflect/value.go
type Reflect_flag uintptr
const (
// see: go/src/reflect/value.go
Reflect_flagKindWidth = 5 // there are 27 kinds
Reflect_flagKindMask Reflect_flag = 1<<Reflect_flagKindWidth - 1
Reflect_flagStickyRO Reflect_flag = 1 << 5
Reflect_flagEmbedRO Reflect_flag = 1 << 6
Reflect_flagIndir Reflect_flag = 1 << 7
Reflect_flagAddr Reflect_flag = 1 << 8
Reflect_flagMethod Reflect_flag = 1 << 9
Reflect_flagMethodShift = 10
Reflect_flagRO Reflect_flag = Reflect_flagStickyRO | Reflect_flagEmbedRO
)
// ReflectIfaceElemFlags returns the reflect_flag expected of an unboxed interface element of type.
//
// see: go/src/reflect/value.go unpackElem()
func ReflectIfaceElemFlags(elemType reflect.Type) Reflect_flag {
if elemType == nil {
return 0
}
flags := Reflect_flag(Abi_Type_Kind(elemType))
if Abi_Type_IfaceIndir(elemType) {
flags |= Reflect_flagIndir
}
return flags
}
// ReflectPointerElemFlags returns the reflect_flag expected of a dereferenced pointer element of type.
//
// see: go/src/reflect/value.go Value.Elem()
func ReflectPointerElemFlags(ptrFlags Reflect_flag, elemType reflect.Type) Reflect_flag {
return ptrFlags | Reflect_flagIndir | Reflect_flagAddr | Reflect_flag(Abi_Type_Kind(elemType))
}
// ReflectArrayElemFlags returns the reflect_flag expected of an element of type in an array.
//
// see: go/src/reflect/value.go Value.Index()
func ReflectArrayElemFlags(arrayFlags Reflect_flag, elemType reflect.Type) Reflect_flag {
return arrayFlags&(Reflect_flagIndir|Reflect_flagAddr) | Reflect_flag(Abi_Type_Kind(elemType))
}
// reflect_slice_elem_flags returns the reflect_flag expected of a slice element of type.
//
// see: go/src/reflect/value.go Value.Index()
func ReflectSliceElemFlags(elemType reflect.Type) Reflect_flag {
return Reflect_flagAddr | Reflect_flagIndir | Reflect_flag(Abi_Type_Kind(elemType))
}
// ReflectStructFieldFlags returns the reflect_flag expected of a struct field of type.
//
// see: go/src/reflect/value.go Value.Field()
func ReflectStructFieldFlags(structFlags Reflect_flag, fieldType reflect.Type) Reflect_flag {
return structFlags&(Reflect_flagIndir|Reflect_flagAddr) | Reflect_flag(Abi_Type_Kind(fieldType))
}
// ReflectMapKeyFlags returns the reflect_flag expected of a map key of type.
//
// see: go/src/reflect/map_swiss.go MapIter.Key()
func ReflectMapKeyFlags(keyType reflect.Type) Reflect_flag {
return Reflect_flag(Abi_Type_Kind(keyType))
}
// ReflectMapElemFlags returns the reflect_flag expected of a map element of type.
//
// see: go/src/reflect/map_swiss.go MapIter.Value()
func ReflectMapElemFlags(elemType reflect.Type) Reflect_flag {
return Reflect_flag(Abi_Type_Kind(elemType))
}
// reflect_Value is a copy of the memory layout of reflect.Value{}.
//
// see: go/src/reflect/value.go
type reflect_Value struct {
typ_ unsafe.Pointer
ptr unsafe.Pointer
Reflect_flag
}
func init() {
if unsafe.Sizeof(reflect_Value{}) != unsafe.Sizeof(reflect.Value{}) {
panic("reflect_Value{} not in sync with reflect.Value{}")
}
}
// reflect_type_data returns the .word from the reflect.Type{} cast
// as the reflect.nonEmptyInterface{}, which itself will be a pointer
// to the actual abi.Type{} that this reflect.Type{} is wrapping.
func ReflectTypeData(t reflect.Type) unsafe.Pointer {
return (*Abi_NonEmptyInterface)(unsafe.Pointer(&t)).Data
}
// BuildReflectValue manually builds a reflect.Value{} by setting the internal field members.
func BuildReflectValue(rtype reflect.Type, data unsafe.Pointer, flags Reflect_flag) reflect.Value {
return *(*reflect.Value)(unsafe.Pointer(&reflect_Value{ReflectTypeData(rtype), data, flags}))
}
// Reflect_MapIter is a copy of the memory layout of reflect.MapIter{}.
//
// see: go/src/reflect/map_swiss.go
type Reflect_MapIter struct {
m reflect.Value
hiter maps_Iter
}
// maps_Iter is a copy of the memory layout of maps.Iter{}.
//
// see: go/src/internal/runtime/maps/table.go
type maps_Iter struct {
key unsafe.Pointer
elem unsafe.Pointer
_ uintptr
_ uintptr
_ uint64
_ uint64
_ uint64
_ uint8
_ int
_ uintptr
_ struct{ _ unsafe.Pointer }
_ uint64
}
func init() {
if unsafe.Sizeof(Reflect_MapIter{}) != unsafe.Sizeof(reflect.MapIter{}) {
panic("Reflect_MapIter{} not in sync with reflect.MapIter{}")
}
}
// GetMapIter creates a new map iterator from value,
// skipping the initial v.MapRange() type checking.
func GetMapIter(v reflect.Value) *reflect.MapIter {
var i Reflect_MapIter
i.m = v
return (*reflect.MapIter)(unsafe.Pointer(&i))
}
// Map_Key returns ptr to current map key in iter.
func Map_Key(i *reflect.MapIter) unsafe.Pointer {
return (*Reflect_MapIter)(unsafe.Pointer(i)).hiter.key
}
// Map_Elem returns ptr to current map element in iter.
func Map_Elem(i *reflect.MapIter) unsafe.Pointer {
return (*Reflect_MapIter)(unsafe.Pointer(i)).hiter.elem
}

49
vendor/codeberg.org/gruf/go-xunsafe/types.go generated vendored Normal file
View file

@ -0,0 +1,49 @@
package xunsafe
import "reflect"
// TypeIter provides a simple wrapper for
// a means of following reflected types.
type TypeIter struct {
TypeInfo
Parent *TypeIter
}
// TypeInfo wraps reflect type information
// along with flags specifying further details
// necessary due to type nesting.
type TypeInfo struct {
Type reflect.Type
Flag Reflect_flag
}
// ToTypeIter creates a new TypeIter{} from reflect type and flags.
func ToTypeIter(rtype reflect.Type, flags Reflect_flag) TypeIter {
return TypeIter{TypeInfo: TypeInfo{rtype, flags}}
}
// TypeIterFrom creates new TypeIter from interface value type.
// Note this will always assume the initial value passed to you
// will be coming from an interface.
func TypeIterFrom(a any) TypeIter {
rtype := reflect.TypeOf(a)
flags := ReflectIfaceElemFlags(rtype)
return ToTypeIter(rtype, flags)
}
// Indirect returns whether Reflect_flagIndir is set on receiving TypeInfo{}.Flag.
func (t TypeInfo) Indirect() bool {
return t.Flag&Reflect_flagIndir != 0
}
// IfaceIndir calls Abi_Type_IfaceIndir() on receiving TypeInfo{}.Type.
func (t TypeInfo) IfaceIndir() bool {
return Abi_Type_IfaceIndir(t.Type)
}
// Child returns a new TypeIter{} for given type and flags, with parent pointing to receiver.
func (i TypeIter) Child(rtype reflect.Type, flags Reflect_flag) TypeIter {
child := ToTypeIter(rtype, flags)
child.Parent = &i
return child
}

View file

@ -1,15 +1,11 @@
package oidc
import (
"bytes"
"context"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
"strings"
"time"
jose "github.com/go-jose/go-jose/v4"
@ -145,18 +141,6 @@ func (p *Provider) newVerifier(keySet KeySet, config *Config) *IDTokenVerifier {
return NewVerifier(p.issuer, keySet, config)
}
func parseJWT(p string) ([]byte, error) {
parts := strings.Split(p, ".")
if len(parts) < 2 {
return nil, fmt.Errorf("oidc: malformed jwt, expected 3 parts got %d", len(parts))
}
payload, err := base64.RawURLEncoding.DecodeString(parts[1])
if err != nil {
return nil, fmt.Errorf("oidc: malformed jwt payload: %v", err)
}
return payload, nil
}
func contains(sli []string, ele string) bool {
for _, s := range sli {
if s == ele {
@ -219,12 +203,49 @@ func resolveDistributedClaim(ctx context.Context, verifier *IDTokenVerifier, src
//
// token, err := verifier.Verify(ctx, rawIDToken)
func (v *IDTokenVerifier) Verify(ctx context.Context, rawIDToken string) (*IDToken, error) {
// Throw out tokens with invalid claims before trying to verify the token. This lets
// us do cheap checks before possibly re-syncing keys.
payload, err := parseJWT(rawIDToken)
var supportedSigAlgs []jose.SignatureAlgorithm
for _, alg := range v.config.SupportedSigningAlgs {
supportedSigAlgs = append(supportedSigAlgs, jose.SignatureAlgorithm(alg))
}
if len(supportedSigAlgs) == 0 {
// If no algorithms were specified by both the config and discovery, default
// to the one mandatory algorithm "RS256".
supportedSigAlgs = []jose.SignatureAlgorithm{jose.RS256}
}
if v.config.InsecureSkipSignatureCheck {
// "none" is a required value to even parse a JWT with the "none" algorithm
// using go-jose.
supportedSigAlgs = append(supportedSigAlgs, "none")
}
// Parse and verify the signature first. This at least forces the user to have
// a valid, signed ID token before we do any other processing.
jws, err := jose.ParseSigned(rawIDToken, supportedSigAlgs)
if err != nil {
return nil, fmt.Errorf("oidc: malformed jwt: %v", err)
}
switch len(jws.Signatures) {
case 0:
return nil, fmt.Errorf("oidc: id token not signed")
case 1:
default:
return nil, fmt.Errorf("oidc: multiple signatures on id token not supported")
}
sig := jws.Signatures[0]
var payload []byte
if v.config.InsecureSkipSignatureCheck {
// Yolo mode.
payload = jws.UnsafePayloadWithoutVerification()
} else {
// The JWT is attached here for the happy path to avoid the verifier from
// having to parse the JWT twice.
ctx = context.WithValue(ctx, parsedJWTKey, jws)
payload, err = v.keySet.VerifySignature(ctx, rawIDToken)
if err != nil {
return nil, fmt.Errorf("failed to verify signature: %v", err)
}
}
var token idToken
if err := json.Unmarshal(payload, &token); err != nil {
return nil, fmt.Errorf("oidc: failed to unmarshal claims: %v", err)
@ -254,6 +275,7 @@ func (v *IDTokenVerifier) Verify(ctx context.Context, rawIDToken string) (*IDTok
AccessTokenHash: token.AtHash,
claims: payload,
distributedClaims: distributedClaims,
sigAlgorithm: sig.Header.Algorithm,
}
// Check issuer.
@ -306,45 +328,6 @@ func (v *IDTokenVerifier) Verify(ctx context.Context, rawIDToken string) (*IDTok
}
}
if v.config.InsecureSkipSignatureCheck {
return t, nil
}
var supportedSigAlgs []jose.SignatureAlgorithm
for _, alg := range v.config.SupportedSigningAlgs {
supportedSigAlgs = append(supportedSigAlgs, jose.SignatureAlgorithm(alg))
}
if len(supportedSigAlgs) == 0 {
// If no algorithms were specified by both the config and discovery, default
// to the one mandatory algorithm "RS256".
supportedSigAlgs = []jose.SignatureAlgorithm{jose.RS256}
}
jws, err := jose.ParseSigned(rawIDToken, supportedSigAlgs)
if err != nil {
return nil, fmt.Errorf("oidc: malformed jwt: %v", err)
}
switch len(jws.Signatures) {
case 0:
return nil, fmt.Errorf("oidc: id token not signed")
case 1:
default:
return nil, fmt.Errorf("oidc: multiple signatures on id token not supported")
}
sig := jws.Signatures[0]
t.sigAlgorithm = sig.Header.Algorithm
ctx = context.WithValue(ctx, parsedJWTKey, jws)
gotPayload, err := v.keySet.VerifySignature(ctx, rawIDToken)
if err != nil {
return nil, fmt.Errorf("failed to verify signature: %v", err)
}
// Ensure that the payload returned by the square actually matches the payload parsed earlier.
if !bytes.Equal(gotPayload, payload) {
return nil, errors.New("oidc: internal error, payload parsed did not match previous payload")
}
return t, nil
}

View file

@ -44,8 +44,6 @@ type ResponseWriter interface {
LocalAddr() net.Addr
// RemoteAddr returns the net.Addr of the client that sent the current request.
RemoteAddr() net.Addr
// Network returns the value of the Net field of the Server (e.g., "tcp", "tcp-tls").
Network() string
// WriteMsg writes a reply back to the client.
WriteMsg(*Msg) error
// Write writes a raw buffer back to the client.
@ -79,7 +77,6 @@ type response struct {
udpSession *SessionUDP // oob data to get egress interface right
pcSession net.Addr // address to use when writing to a generic net.PacketConn
writer Writer // writer to output the raw DNS bits
network string // corresponding Server.Net value
}
// handleRefused returns a HandlerFunc that returns REFUSED for every request it gets.
@ -560,7 +557,7 @@ func (srv *Server) serveUDP(l net.PacketConn) error {
// Serve a new TCP connection.
func (srv *Server) serveTCPConn(wg *sync.WaitGroup, rw net.Conn) {
w := &response{tsigProvider: srv.tsigProvider(), tcp: rw, network: srv.Net}
w := &response{tsigProvider: srv.tsigProvider(), tcp: rw}
if srv.DecorateWriter != nil {
w.writer = srv.DecorateWriter(w)
} else {
@ -615,7 +612,7 @@ func (srv *Server) serveTCPConn(wg *sync.WaitGroup, rw net.Conn) {
// Serve a new UDP request.
func (srv *Server) serveUDPPacket(wg *sync.WaitGroup, m []byte, u net.PacketConn, udpSession *SessionUDP, pcSession net.Addr) {
w := &response{tsigProvider: srv.tsigProvider(), udp: u, udpSession: udpSession, pcSession: pcSession, network: srv.Net}
w := &response{tsigProvider: srv.tsigProvider(), udp: u, udpSession: udpSession, pcSession: pcSession}
if srv.DecorateWriter != nil {
w.writer = srv.DecorateWriter(w)
} else {
@ -821,9 +818,6 @@ func (w *response) RemoteAddr() net.Addr {
}
}
// Network implements the ResponseWriter.Network method.
func (w *response) Network() string { return w.network }
// TsigStatus implements the ResponseWriter.TsigStatus method.
func (w *response) TsigStatus() error { return w.tsigStatus }

View file

@ -3,7 +3,7 @@ package dns
import "fmt"
// Version is current version of this library.
var Version = v{1, 1, 67}
var Version = v{1, 1, 68}
// v holds the version of this library.
type v struct {

View file

@ -1,14 +1,12 @@
package html
// generated by hasher -type=Hash -file=hash.go; DO NOT EDIT, except for adding more constants to the list and rerun go generate
// uses github.com/tdewolff/hasher
//go:generate hasher -type=Hash -file=hash.go
// Hash defines perfect hashes for a predefined list of strings
type Hash uint32
// Unique hash definitions to be used instead of strings
// Identifiers for the hashes associated with the text in the comments.
const (
A Hash = 0x1 // a
Abbr Hash = 0x40004 // abbr
@ -277,22 +275,297 @@ const (
Xmp Hash = 0x7903 // xmp
)
// String returns the hash' name.
//var HashMap = map[string]Hash{
// "a": A,
// "abbr": Abbr,
// "about": About,
// "accept": Accept,
// "accept-charset": Accept_Charset,
// "accesskey": Accesskey,
// "acronym": Acronym,
// "action": Action,
// "address": Address,
// "allow": Allow,
// "allowfullscreen": Allowfullscreen,
// "amp-boilerplate": Amp_Boilerplate,
// "applet": Applet,
// "area": Area,
// "article": Article,
// "as": As,
// "aside": Aside,
// "async": Async,
// "audio": Audio,
// "autocapitalize": Autocapitalize,
// "autocomplete": Autocomplete,
// "autofocus": Autofocus,
// "autoplay": Autoplay,
// "b": B,
// "base": Base,
// "basefont": Basefont,
// "bb": Bb,
// "bdi": Bdi,
// "bdo": Bdo,
// "big": Big,
// "blocking": Blocking,
// "blockquote": Blockquote,
// "body": Body,
// "br": Br,
// "button": Button,
// "canvas": Canvas,
// "caption": Caption,
// "capture": Capture,
// "center": Center,
// "charset": Charset,
// "checked": Checked,
// "cite": Cite,
// "class": Class,
// "code": Code,
// "col": Col,
// "colgroup": Colgroup,
// "color": Color,
// "cols": Cols,
// "colspan": Colspan,
// "content": Content,
// "contenteditable": Contenteditable,
// "controls": Controls,
// "coords": Coords,
// "crossorigin": Crossorigin,
// "data": Data,
// "datalist": Datalist,
// "datatype": Datatype,
// "datetime": Datetime,
// "dd": Dd,
// "decoding": Decoding,
// "default": Default,
// "defer": Defer,
// "del": Del,
// "details": Details,
// "dfn": Dfn,
// "dialog": Dialog,
// "dir": Dir,
// "disabled": Disabled,
// "div": Div,
// "dl": Dl,
// "draggable": Draggable,
// "dt": Dt,
// "em": Em,
// "embed": Embed,
// "enctype": Enctype,
// "enterkeyhint": Enterkeyhint,
// "fetchpriority": Fetchpriority,
// "fieldset": Fieldset,
// "figcaption": Figcaption,
// "figure": Figure,
// "font": Font,
// "footer": Footer,
// "for": For,
// "form": Form,
// "formaction": Formaction,
// "formenctype": Formenctype,
// "formmethod": Formmethod,
// "formnovalidate": Formnovalidate,
// "formtarget": Formtarget,
// "frame": Frame,
// "frameset": Frameset,
// "h1": H1,
// "h2": H2,
// "h3": H3,
// "h4": H4,
// "h5": H5,
// "h6": H6,
// "head": Head,
// "header": Header,
// "headers": Headers,
// "height": Height,
// "hgroup": Hgroup,
// "hidden": Hidden,
// "high": High,
// "hr": Hr,
// "href": Href,
// "hreflang": Hreflang,
// "html": Html,
// "http-equiv": Http_Equiv,
// "i": I,
// "id": Id,
// "iframe": Iframe,
// "image": Image,
// "imagesizes": Imagesizes,
// "imagesrcset": Imagesrcset,
// "img": Img,
// "inert": Inert,
// "inlist": Inlist,
// "input": Input,
// "inputmode": Inputmode,
// "ins": Ins,
// "is": Is,
// "ismap": Ismap,
// "itemid": Itemid,
// "itemprop": Itemprop,
// "itemref": Itemref,
// "itemscope": Itemscope,
// "itemtype": Itemtype,
// "kbd": Kbd,
// "kind": Kind,
// "label": Label,
// "lang": Lang,
// "legend": Legend,
// "li": Li,
// "link": Link,
// "list": List,
// "loading": Loading,
// "loop": Loop,
// "low": Low,
// "main": Main,
// "map": Map,
// "mark": Mark,
// "marquee": Marquee,
// "math": Math,
// "max": Max,
// "maxlength": Maxlength,
// "media": Media,
// "menu": Menu,
// "menuitem": Menuitem,
// "meta": Meta,
// "meter": Meter,
// "method": Method,
// "min": Min,
// "minlength": Minlength,
// "multiple": Multiple,
// "muted": Muted,
// "name": Name,
// "nav": Nav,
// "nobr": Nobr,
// "noembed": Noembed,
// "noframes": Noframes,
// "nomodule": Nomodule,
// "noscript": Noscript,
// "novalidate": Novalidate,
// "object": Object,
// "ol": Ol,
// "open": Open,
// "optgroup": Optgroup,
// "optimum": Optimum,
// "option": Option,
// "output": Output,
// "p": P,
// "param": Param,
// "pattern": Pattern,
// "picture": Picture,
// "ping": Ping,
// "plaintext": Plaintext,
// "playsinline": Playsinline,
// "popover": Popover,
// "popovertarget": Popovertarget,
// "popovertargetaction": Popovertargetaction,
// "portal": Portal,
// "poster": Poster,
// "pre": Pre,
// "prefix": Prefix,
// "preload": Preload,
// "profile": Profile,
// "progress": Progress,
// "property": Property,
// "q": Q,
// "rb": Rb,
// "readonly": Readonly,
// "referrerpolicy": Referrerpolicy,
// "rel": Rel,
// "required": Required,
// "resource": Resource,
// "rev": Rev,
// "reversed": Reversed,
// "rows": Rows,
// "rowspan": Rowspan,
// "rp": Rp,
// "rt": Rt,
// "rtc": Rtc,
// "ruby": Ruby,
// "s": S,
// "samp": Samp,
// "sandbox": Sandbox,
// "scope": Scope,
// "script": Script,
// "section": Section,
// "select": Select,
// "selected": Selected,
// "shadowrootdelegatesfocus": Shadowrootdelegatesfocus,
// "shadowrootmode": Shadowrootmode,
// "shape": Shape,
// "size": Size,
// "sizes": Sizes,
// "slot": Slot,
// "small": Small,
// "source": Source,
// "span": Span,
// "spellcheck": Spellcheck,
// "src": Src,
// "srclang": Srclang,
// "srcset": Srcset,
// "start": Start,
// "step": Step,
// "strike": Strike,
// "strong": Strong,
// "style": Style,
// "sub": Sub,
// "summary": Summary,
// "sup": Sup,
// "svg": Svg,
// "tabindex": Tabindex,
// "table": Table,
// "target": Target,
// "tbody": Tbody,
// "td": Td,
// "template": Template,
// "text": Text,
// "textarea": Textarea,
// "tfoot": Tfoot,
// "th": Th,
// "thead": Thead,
// "time": Time,
// "title": Title,
// "tr": Tr,
// "track": Track,
// "translate": Translate,
// "tt": Tt,
// "type": Type,
// "typeof": Typeof,
// "u": U,
// "ul": Ul,
// "usemap": Usemap,
// "value": Value,
// "var": Var,
// "video": Video,
// "vocab": Vocab,
// "wbr": Wbr,
// "width": Width,
// "wrap": Wrap,
// "xmlns": Xmlns,
// "xmp": Xmp,
//}
// String returns the text associated with the hash.
func (i Hash) String() string {
return string(i.Bytes())
}
// Bytes returns the text associated with the hash.
func (i Hash) Bytes() []byte {
start := uint32(i >> 8)
n := uint32(i & 0xff)
if start+n > uint32(len(_Hash_text)) {
return ""
return []byte{}
}
return _Hash_text[start : start+n]
}
// ToHash returns the hash whose name is s. It returns zero if there is no
// such hash. It is case sensitive.
// ToHash returns a hash Hash for a given []byte. Hash is a uint32 that is associated with the text in []byte. It returns zero if no match found.
func ToHash(s []byte) Hash {
if len(s) == 0 || len(s) > _Hash_maxLen {
return 0
}
//if 3 < len(s) {
// return HashMap[string(s)]
//}
h := uint32(_Hash_hash0)
for i := 0; i < len(s); i++ {
h ^= uint32(s[i])
@ -320,9 +593,11 @@ NEXT:
return 0
}
const _Hash_hash0 = 0x51243bbc
const _Hash_hash0 = 0x87d8a7d9
const _Hash_maxLen = 24
const _Hash_text = "aboutputbodyaccept-charsetfooterbasefontitleaccesskeyacronym" +
var _Hash_text = []byte("" +
"aboutputbodyaccept-charsetfooterbasefontitleaccesskeyacronym" +
"ainputmodeferowspanametabindexmlnsamp-boilerplateaddressandb" +
"oxmparamarkbdirubyasyncanvasidecodingaudiobjectrackindatalis" +
"tepatternavalueautocapitalizeautocompletemplateautofocusemap" +
@ -339,272 +614,272 @@ const _Hash_text = "aboutputbodyaccept-charsetfooterbasefontitleaccesskeyacronym
"mreferrerpolicyitemscopenitemtypematheaderspellcheckedmaxlen" +
"gth2meterminlength3multiplemutedprefixpreloadingprofileprogr" +
"essrclangstrikestrongstylesubdoptimumarqueesummarysuportalsv" +
"gvocabbrwbrwidth4wraposter"
"gvocabbrwbrwidth4wraposter")
var _Hash_table = [1 << 9]Hash{
0x0: 0x4405, // defer
0x5: 0x18002, // ol
0x6: 0x3720a, // spellcheck
0x7: 0x40b02, // h4
0x8: 0x40705, // width
0x9: 0x9402, // id
0xb: 0x14904, // nobr
0xc: 0x31d05, // small
0xf: 0x2b506, // hgroup
0x10: 0x27702, // th
0x15: 0x24f06, // center
0x18: 0xd10c, // autocomplete
0x1b: 0x2c304, // area
0x1e: 0x17f03, // col
0x1f: 0x2a106, // height
0x21: 0x4b04, // span
0x22: 0x37e03, // max
0x23: 0x3cf06, // strong
0x24: 0x501, // p
0x29: 0x24b06, // source
0x2c: 0x8e06, // canvas
0x2d: 0x2c09, // accesskey
0x2e: 0x18607, // picture
0x30: 0x3a403, // pre
0x31: 0x5d04, // samp
0x34: 0x40902, // dt
0x36: 0x30505, // sizes
0x37: 0x1a908, // nomodule
0x39: 0x2a504, // html
0x3a: 0x31203, // src
0x3c: 0x28d06, // dialog
0x3e: 0x3ab03, // rel
0x40: 0x1a06, // footer
0x43: 0x30d0b, // imagesrcset
0x46: 0x3c906, // strike
0x47: 0x2e805, // video
0x4a: 0x2d702, // hr
0x4b: 0x36108, // itemtype
0x4c: 0x1c804, // link
0x4e: 0x6702, // rp
0x4f: 0x2801, // i
0x50: 0xee06, // applet
0x51: 0x17f08, // colgroup
0x53: 0x1905, // tfoot
0x54: 0xc06, // accept
0x57: 0x14d04, // cite
0x58: 0x1307, // charset
0x59: 0x17604, // code
0x5a: 0x4e04, // name
0x5b: 0x2bf04, // text
0x5d: 0x31f05, // allow
0x5e: 0x36c04, // head
0x61: 0x16605, // embed
0x62: 0x3fa03, // svg
0x63: 0x3fd05, // vocab
0x64: 0x5e0f, // amp-boilerplate
0x65: 0x38805, // meter
0x67: 0x3320d, // popovertarget
0x69: 0x3b04, // main
0x6a: 0x41006, // poster
0x6c: 0x1c302, // dl
0x6e: 0x26006, // action
0x71: 0x17807, // default
0x72: 0x3d05, // input
0x74: 0xb202, // is
0x75: 0x27506, // method
0x79: 0x7903, // xmp
0x7a: 0x101, // b
0x7b: 0x21f06, // inlist
0x7c: 0x25c0a, // formaction
0x7e: 0x39708, // multiple
0x80: 0x1f203, // del
0x81: 0x26a07, // enctype
0x83: 0x27b0e, // formnovalidate
0x84: 0x2404, // font
0x85: 0x11d06, // typeof
0x86: 0x2d704, // href
0x87: 0x13a0a, // blockquote
0x88: 0x4807, // rowspan
0x89: 0x3aa07, // preload
0x8a: 0x12f03, // big
0x8c: 0x38d09, // minlength
0x90: 0x1bb05, // table
0x91: 0x39f05, // muted
0x92: 0x3e407, // marquee
0x94: 0x3507, // acronym
0x96: 0x40d04, // wrap
0x98: 0x14b02, // br
0x9a: 0x10b02, // rt
0x9e: 0xa602, // tr
0x9f: 0x35709, // itemscope
0xa4: 0xad04, // data
0xa5: 0x29706, // target
0xac: 0x11908, // datatype
0xae: 0xb304, // step
0xb3: 0x1cc08, // controls
0xb5: 0xbe05, // value
0xb6: 0x2ba09, // plaintext
0xb7: 0x1da09, // draggable
0xc0: 0x8a05, // async
0xc2: 0x2a804, // loop
0xc3: 0x28904, // time
0xc6: 0x2004, // base
0xc7: 0x23f06, // script
0xce: 0x32103, // low
0xcf: 0x3dc03, // bdo
0xd1: 0x18b03, // rev
0xd2: 0x1e306, // coords
0xd3: 0x8403, // dir
0xd4: 0x2f608, // menuitem
0xd6: 0x22507, // article
0xd8: 0x11d04, // type
0xda: 0x18b08, // reversed
0xdb: 0x23707, // caption
0xdc: 0x35d04, // open
0xdd: 0x1701, // s
0xe0: 0x2705, // title
0xe1: 0x9508, // decoding
0xe3: 0xc0e, // accept-charset
0xe4: 0x15a05, // class
0xe5: 0x3f203, // sup
0xe6: 0xdb08, // template
0xe7: 0x16c08, // noframes
0xe8: 0x3ad07, // loading
0xeb: 0xa106, // object
0xee: 0x3da03, // sub
0xef: 0x2fa06, // itemid
0xf0: 0x30904, // slot
0xf1: 0x8604, // ruby
0xf4: 0x1f102, // td
0xf5: 0x11208, // required
0xf9: 0x16e05, // frame
0xfc: 0x2102, // as
0xfd: 0x37e09, // maxlength
0xff: 0x31f0f, // allowfullscreen
0x101: 0x2160b, // crossorigin
0x102: 0xed03, // map
0x104: 0x6e02, // dd
0x105: 0x705, // tbody
0x107: 0x2d502, // h1
0x109: 0x5004, // meta
0x10a: 0x1, // a
0x10c: 0x16a03, // dfn
0x10e: 0x34507, // itemref
0x110: 0x38d03, // min
0x111: 0x28508, // datetime
0x114: 0xdc02, // em
0x115: 0x7f04, // mark
0x119: 0x2d708, // hreflang
0x11a: 0x3de07, // optimum
0x11c: 0x1220d, // fetchpriority
0x11d: 0x39502, // h3
0x11e: 0x5905, // xmlns
0x11f: 0x19903, // div
0x121: 0x40403, // wbr
0x128: 0x2bf08, // textarea
0x129: 0x3d505, // style
0x12a: 0x3f406, // portal
0x12b: 0x1b107, // content
0x12d: 0x19b03, // var
0x12f: 0x40004, // abbr
0x133: 0x31803, // img
0x138: 0x35b05, // scope
0x13b: 0x30504, // size
0x13e: 0x29f02, // h6
0x141: 0xfc08, // autoplay
0x142: 0x2c408, // readonly
0x143: 0x3d09, // inputmode
0x144: 0x19208, // disabled
0x145: 0x4804, // rows
0x149: 0x3490e, // referrerpolicy
0x14a: 0x1c405, // label
0x14b: 0x36c06, // header
0x14c: 0xad08, // datalist
0x14d: 0xe309, // autofocus
0x14e: 0xb607, // pattern
0x150: 0x2cc06, // hidden
0x151: 0x5, // about
0x152: 0x14406, // button
0x154: 0x2f206, // iframe
0x155: 0x1d308, // selected
0x156: 0x3c207, // srclang
0x15b: 0xb102, // li
0x15c: 0x22305, // start
0x15d: 0x7307, // sandbox
0x15e: 0x31b03, // ins
0x162: 0x1a307, // colspan
0x163: 0x1ff0e, // shadowrootmode
0x164: 0xb104, // list
0x166: 0x5208, // tabindex
0x169: 0x3b407, // profile
0x16b: 0x301, // u
0x16c: 0x23d08, // noscript
0x16e: 0x2660b, // formenctype
0x16f: 0x16e08, // frameset
0x170: 0x28b05, // media
0x174: 0x2008, // basefont
0x176: 0x2b104, // ping
0x177: 0x3bb08, // progress
0x178: 0x206, // output
0x17a: 0x36904, // math
0x17b: 0x2930a, // formtarget
0x17d: 0x7b05, // param
0x180: 0x13208, // blocking
0x185: 0x37707, // checked
0x188: 0x32e05, // ismap
0x18a: 0x38602, // h2
0x18c: 0x2df0a, // http-equiv
0x18e: 0x10d07, // capture
0x190: 0x2db04, // lang
0x195: 0x27f0a, // novalidate
0x197: 0x1a304, // cols
0x198: 0x804, // body
0x199: 0xbc03, // nav
0x19a: 0x1b10f, // contenteditable
0x19b: 0x15e07, // section
0x19e: 0x14e08, // itemprop
0x19f: 0x15208, // property
0x1a1: 0xc30e, // autocapitalize
0x1a4: 0x3eb07, // summary
0x1a6: 0x1000b, // playsinline
0x1a9: 0x8303, // bdi
0x1ab: 0x29d02, // h5
0x1ac: 0x6d07, // address
0x1b0: 0x2d204, // high
0x1b1: 0x33207, // popover
0x1b3: 0xa605, // track
0x1b6: 0x8203, // kbd
0x1b7: 0x11401, // q
0x1b8: 0x2340a, // figcaption
0x1b9: 0x30005, // image
0x1ba: 0x25c04, // form
0x1c1: 0x3000a, // imagesizes
0x1c4: 0x1e818, // shadowrootdelegatesfocus
0x1c5: 0x2ec06, // option
0x1c6: 0x9d05, // audio
0x1c8: 0x40102, // bb
0x1c9: 0x16407, // noembed
0x1cc: 0x10805, // inert
0x1cf: 0x1d306, // select
0x1d1: 0x22c08, // fieldset
0x1d2: 0x31206, // srcset
0x1d3: 0x2f604, // menu
0x1d5: 0x36c07, // headers
0x1dd: 0x1be06, // legend
0x1de: 0xaa04, // kind
0x1e0: 0x24908, // resource
0x1e2: 0xf309, // translate
0x1e4: 0x2aa08, // optgroup
0x1e6: 0x33213, // popovertargetaction
0x1e7: 0x2710a, // formmethod
0x1e9: 0xb802, // tt
0x1ea: 0x36b05, // thead
0x1eb: 0x17c02, // ul
0x1ee: 0x3a406, // prefix
0x1ef: 0x19e05, // color
0x1f1: 0x21105, // shape
0x1f3: 0x25c03, // for
0x1f4: 0x2500c, // enterkeyhint
0x1f7: 0xea06, // usemap
0x1f8: 0x1f02, // rb
0x1fa: 0x20b07, // details
0x1fb: 0x10b03, // rtc
0x1fc: 0x9205, // aside
0x1fe: 0x24506, // figure
0x3: 0xb304, // step
0x4: 0x2004, // base
0x5: 0xb607, // pattern
0x8: 0x8403, // dir
0xa: 0xe309, // autofocus
0xc: 0x3b04, // main
0xf: 0x2801, // i
0x10: 0x1, // a
0x12: 0x40004, // abbr
0x13: 0x40705, // width
0x15: 0x24506, // figure
0x16: 0x23f06, // script
0x17: 0x5e0f, // amp-boilerplate
0x18: 0x3d09, // inputmode
0x19: 0xb802, // tt
0x1c: 0x2d704, // href
0x1d: 0x22305, // start
0x21: 0x4807, // rowspan
0x23: 0x1e306, // coords
0x25: 0xb104, // list
0x28: 0x3fa03, // svg
0x29: 0x2d502, // h1
0x2a: 0x15a05, // class
0x2b: 0x2e805, // video
0x2c: 0x3490e, // referrerpolicy
0x2d: 0x2f608, // menuitem
0x2e: 0x38805, // meter
0x30: 0x17604, // code
0x33: 0x2c408, // readonly
0x35: 0x3c207, // srclang
0x37: 0x3320d, // popovertarget
0x39: 0x2db04, // lang
0x3a: 0x3a403, // pre
0x3d: 0x2f206, // iframe
0x3e: 0x1b107, // content
0x3f: 0x2fa06, // itemid
0x40: 0x27f0a, // novalidate
0x41: 0x1d306, // select
0x43: 0x3c906, // strike
0x44: 0x1a304, // cols
0x46: 0x36b05, // thead
0x48: 0x32103, // low
0x4b: 0x1000b, // playsinline
0x4d: 0x31206, // srcset
0x51: 0x1c405, // label
0x52: 0x3bb08, // progress
0x53: 0x6702, // rp
0x54: 0x19903, // div
0x55: 0xad08, // datalist
0x5b: 0x28d06, // dialog
0x5c: 0x5208, // tabindex
0x5d: 0x40d04, // wrap
0x61: 0x16e05, // frame
0x64: 0x3000a, // imagesizes
0x67: 0x6d07, // address
0x69: 0x3da03, // sub
0x6d: 0x4b04, // span
0x6f: 0x16a03, // dfn
0x70: 0xf309, // translate
0x71: 0x1f203, // del
0x72: 0x705, // tbody
0x74: 0x15208, // property
0x7b: 0x38d09, // minlength
0x7d: 0x2cc06, // hidden
0x7e: 0x18b03, // rev
0x7f: 0xdb08, // template
0x81: 0x20b07, // details
0x82: 0x8303, // bdi
0x86: 0x22507, // article
0x88: 0x2ec06, // option
0x89: 0x40902, // dt
0x8b: 0x31b03, // ins
0x8d: 0x18607, // picture
0x8f: 0x18b08, // reversed
0x92: 0x19b03, // var
0x93: 0xad04, // data
0x95: 0x8e06, // canvas
0x96: 0x7b05, // param
0x97: 0x3eb07, // summary
0x98: 0x15e07, // section
0x9a: 0x2c09, // accesskey
0x9b: 0x26006, // action
0x9c: 0x9402, // id
0x9e: 0x1701, // s
0x9f: 0x10b02, // rt
0xa0: 0x2c304, // area
0xa2: 0x3b407, // profile
0xa5: 0x31203, // src
0xa6: 0xea06, // usemap
0xa8: 0x1be06, // legend
0xa9: 0x8604, // ruby
0xaf: 0x26a07, // enctype
0xb0: 0x2a106, // height
0xb1: 0x2340a, // figcaption
0xb2: 0x3aa07, // preload
0xb4: 0x10b03, // rtc
0xb5: 0x40b02, // h4
0xb6: 0xa106, // object
0xb8: 0x3fd05, // vocab
0xb9: 0x19208, // disabled
0xba: 0x16605, // embed
0xbc: 0x9508, // decoding
0xc1: 0x2102, // as
0xc2: 0x14904, // nobr
0xc4: 0x16c08, // noframes
0xc5: 0x3507, // acronym
0xc6: 0x2930a, // formtarget
0xc7: 0x35b05, // scope
0xc8: 0x30504, // size
0xcb: 0x3ad07, // loading
0xcd: 0x17f03, // col
0xd0: 0x2a804, // loop
0xd1: 0x1307, // charset
0xd2: 0x1bb05, // table
0xd5: 0x3a406, // prefix
0xd6: 0x3de07, // optimum
0xd8: 0x24f06, // center
0xdb: 0xdc02, // em
0xdc: 0x2aa08, // optgroup
0xde: 0x40403, // wbr
0xe2: 0x3cf06, // strong
0xe6: 0xbe05, // value
0xe9: 0x14b02, // br
0xed: 0xee06, // applet
0xf0: 0x206, // output
0xf1: 0x22c08, // fieldset
0xfb: 0x14406, // button
0xfc: 0x30d0b, // imagesrcset
0xfd: 0xc06, // accept
0x100: 0x31d05, // small
0x102: 0x3f406, // portal
0x103: 0x8a05, // async
0x104: 0x11208, // required
0x105: 0x35d04, // open
0x107: 0xaa04, // kind
0x108: 0x33213, // popovertargetaction
0x109: 0x2a504, // html
0x10b: 0x501, // p
0x10c: 0x7f04, // mark
0x10d: 0x32e05, // ismap
0x10f: 0x1cc08, // controls
0x110: 0xa605, // track
0x112: 0x38d03, // min
0x113: 0x16407, // noembed
0x116: 0x21f06, // inlist
0x118: 0x1da09, // draggable
0x119: 0x14e08, // itemprop
0x11a: 0x1f02, // rb
0x11c: 0x17c02, // ul
0x11e: 0xa602, // tr
0x11f: 0x27702, // th
0x122: 0x29d02, // h5
0x126: 0x1905, // tfoot
0x127: 0x37e03, // max
0x129: 0x2d702, // hr
0x12b: 0x1ff0e, // shadowrootmode
0x12c: 0x29706, // target
0x12f: 0x3f203, // sup
0x134: 0x11d06, // typeof
0x136: 0x18002, // ol
0x137: 0x36c04, // head
0x138: 0x7307, // sandbox
0x13a: 0x2b506, // hgroup
0x13f: 0x5004, // meta
0x141: 0x5905, // xmlns
0x143: 0x38602, // h2
0x144: 0xc0e, // accept-charset
0x146: 0x2bf04, // text
0x147: 0x13a0a, // blockquote
0x149: 0x1f102, // td
0x14a: 0x37707, // checked
0x14d: 0x2b104, // ping
0x14e: 0x2f604, // menu
0x150: 0x5d04, // samp
0x151: 0x2008, // basefont
0x152: 0x2710a, // formmethod
0x155: 0xed03, // map
0x156: 0x27b0e, // formnovalidate
0x159: 0x6e02, // dd
0x15c: 0xc30e, // autocapitalize
0x15d: 0x2660b, // formenctype
0x15e: 0xbc03, // nav
0x161: 0x101, // b
0x163: 0x1a06, // footer
0x164: 0x24b06, // source
0x166: 0x35709, // itemscope
0x16a: 0x10d07, // capture
0x16c: 0x36c06, // header
0x16d: 0x1c804, // link
0x171: 0x2160b, // crossorigin
0x172: 0x4405, // defer
0x175: 0x2705, // title
0x177: 0x28b05, // media
0x178: 0x11401, // q
0x179: 0x21105, // shape
0x17c: 0x25c03, // for
0x17d: 0x30904, // slot
0x17e: 0x7903, // xmp
0x184: 0x2404, // font
0x187: 0x13208, // blocking
0x188: 0x8203, // kbd
0x18a: 0x1a908, // nomodule
0x18b: 0x4e04, // name
0x18f: 0x29f02, // h6
0x191: 0x31f05, // allow
0x194: 0x39708, // multiple
0x196: 0x30505, // sizes
0x199: 0x23707, // caption
0x19b: 0x34507, // itemref
0x19c: 0x19e05, // color
0x19f: 0x1220d, // fetchpriority
0x1a7: 0xd10c, // autocomplete
0x1a8: 0x1a307, // colspan
0x1aa: 0x16e08, // frameset
0x1ab: 0x31f0f, // allowfullscreen
0x1ac: 0x14d04, // cite
0x1ae: 0x3ab03, // rel
0x1b0: 0x39502, // h3
0x1b1: 0x25c0a, // formaction
0x1b3: 0x36904, // math
0x1b4: 0x39f05, // muted
0x1b5: 0x1e818, // shadowrootdelegatesfocus
0x1b6: 0x24908, // resource
0x1b9: 0x40102, // bb
0x1ba: 0x2df0a, // http-equiv
0x1be: 0x30005, // image
0x1bf: 0x2bf08, // textarea
0x1c1: 0x28904, // time
0x1c2: 0x5, // about
0x1c3: 0x25c04, // form
0x1c4: 0x301, // u
0x1c5: 0x41006, // poster
0x1c8: 0x1d308, // selected
0x1c9: 0x2d204, // high
0x1ca: 0x3d505, // style
0x1cc: 0x4804, // rows
0x1cd: 0x36c07, // headers
0x1cf: 0x3720a, // spellcheck
0x1d1: 0x11d04, // type
0x1d3: 0xfc08, // autoplay
0x1d4: 0x28508, // datetime
0x1d7: 0x9d05, // audio
0x1d9: 0xb202, // is
0x1de: 0x3dc03, // bdo
0x1df: 0x3d05, // input
0x1e0: 0x31803, // img
0x1e1: 0x11908, // datatype
0x1e2: 0x36108, // itemtype
0x1e3: 0x33207, // popover
0x1e4: 0x2ba09, // plaintext
0x1e6: 0x12f03, // big
0x1e9: 0x2500c, // enterkeyhint
0x1ea: 0x17807, // default
0x1ec: 0x27506, // method
0x1ed: 0x37e09, // maxlength
0x1f0: 0x2d708, // hreflang
0x1f1: 0x1c302, // dl
0x1f2: 0xb102, // li
0x1f4: 0x17f08, // colgroup
0x1f6: 0x1b10f, // contenteditable
0x1f7: 0x3e407, // marquee
0x1f9: 0x9205, // aside
0x1fa: 0x804, // body
0x1fb: 0x10805, // inert
0x1fd: 0x23d08, // noscript
}

View file

@ -23,6 +23,7 @@ var (
svgMimeBytes = []byte("image/svg+xml")
formMimeBytes = []byte("application/x-www-form-urlencoded")
mathMimeBytes = []byte("application/mathml+xml")
xmlMimeBytes = []byte("text/xml")
dataSchemeBytes = []byte("data:")
jsSchemeBytes = []byte("javascript:")
httpBytes = []byte("http")
@ -129,7 +130,7 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st
w.Write(t.Data)
}
}
case html.SvgToken:
case html.SVGToken:
if err := m.MinifyMimetype(svgMimeBytes, w, buffer.NewReader(t.Data), inlineParams); err != nil {
if err != minify.ErrNotExist {
return minify.UpdateErrorPosition(err, z, t.Offset)
@ -145,6 +146,14 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st
w.Write(t.Data)
}
omitSpace = false
case html.XMLToken:
if err := m.MinifyMimetype(xmlMimeBytes, w, buffer.NewReader(t.Data), nil); err != nil {
if err != minify.ErrNotExist {
return minify.UpdateErrorPosition(err, z, t.Offset)
}
w.Write(t.Data)
}
omitSpace = false
case html.TemplateToken:
w.Write(t.Data)
omitSpace = false
@ -199,7 +208,7 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st
} else if next.TokenType == html.TextToken && !parse.IsAllWhitespace(next.Data) || next.TokenType == html.TemplateToken {
// stop looking when text encountered
break
} else if next.TokenType == html.StartTagToken || next.TokenType == html.EndTagToken || next.TokenType == html.SvgToken || next.TokenType == html.MathToken {
} else if next.TokenType == html.StartTagToken || next.TokenType == html.EndTagToken || next.TokenType == html.SVGToken || next.TokenType == html.MathToken || next.TokenType == html.XMLToken {
if o.KeepWhitespace {
break
}
@ -208,7 +217,7 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st
t.Data = t.Data[:len(t.Data)-1]
omitSpace = false
break
} else if next.TokenType == html.StartTagToken || next.TokenType == html.SvgToken || next.TokenType == html.MathToken {
} else if next.TokenType == html.StartTagToken || next.TokenType == html.SVGToken || next.TokenType == html.MathToken || next.TokenType == html.XMLToken {
break
}
}

View file

@ -9,6 +9,9 @@ wget -q --show-progress https://github.com/tdewolff/minify/archive/v$VERSION.tar
SHA256=`sha256sum v$VERSION.tar.gz`
SHA256=( $SHA256 )
GOMODCACHE="$PWD"/go-mod go mod download -modcacherw -x
tar -caf minify-v$VERSION-deps.tar.xz go-mod
echo ""
echo "Releasing for AUR..."
cd /home/taco/dev/aur/minify

View file

@ -1,42 +1,61 @@
package html
// generated by hasher -type=Hash -file=hash.go; DO NOT EDIT, except for adding more constants to the list and rerun go generate
// uses github.com/tdewolff/hasher
//go:generate hasher -type=Hash -file=hash.go
// Hash defines perfect hashes for a predefined list of strings
type Hash uint32
// Unique hash definitions to be used instead of strings
// Identifiers for the hashes associated with the text in the comments.
const (
Iframe Hash = 0x6 // iframe
Math Hash = 0x604 // math
Plaintext Hash = 0x1e09 // plaintext
Plaintext Hash = 0x2109 // plaintext
Script Hash = 0xa06 // script
Style Hash = 0x1405 // style
Svg Hash = 0x1903 // svg
Textarea Hash = 0x2308 // textarea
Textarea Hash = 0x2608 // textarea
Title Hash = 0xf05 // title
Xmp Hash = 0x1c03 // xmp
Xml Hash = 0x1c03 // xml
Xmp Hash = 0x1f03 // xmp
)
// String returns the hash' name.
//var HashMap = map[string]Hash{
// "iframe": Iframe,
// "math": Math,
// "plaintext": Plaintext,
// "script": Script,
// "style": Style,
// "svg": Svg,
// "textarea": Textarea,
// "title": Title,
// "xml": Xml,
// "xmp": Xmp,
//}
// String returns the text associated with the hash.
func (i Hash) String() string {
return string(i.Bytes())
}
// Bytes returns the text associated with the hash.
func (i Hash) Bytes() []byte {
start := uint32(i >> 8)
n := uint32(i & 0xff)
if start+n > uint32(len(_Hash_text)) {
return ""
return []byte{}
}
return _Hash_text[start : start+n]
}
// ToHash returns the hash whose name is s. It returns zero if there is no
// such hash. It is case sensitive.
// ToHash returns a hash Hash for a given []byte. Hash is a uint32 that is associated with the text in []byte. It returns zero if no match found.
func ToHash(s []byte) Hash {
if len(s) == 0 || len(s) > _Hash_maxLen {
return 0
}
//if 3 < len(s) {
// return HashMap[string(s)]
//}
h := uint32(_Hash_hash0)
for i := 0; i < len(s); i++ {
h ^= uint32(s[i])
@ -64,18 +83,21 @@ NEXT:
return 0
}
const _Hash_hash0 = 0x9acb0442
const _Hash_hash0 = 0xb4b790b3
const _Hash_maxLen = 9
const _Hash_text = "iframemathscriptitlestylesvgxmplaintextarea"
var _Hash_text = []byte("" +
"iframemathscriptitlestylesvgxmlxmplaintextarea")
var _Hash_table = [1 << 4]Hash{
0x0: 0x2308, // textarea
0x2: 0x6, // iframe
0x4: 0xf05, // title
0x5: 0x1e09, // plaintext
0x7: 0x1405, // style
0x8: 0x604, // math
0x9: 0xa06, // script
0xa: 0x1903, // svg
0xb: 0x1c03, // xmp
0x2: 0xa06, // script
0x3: 0xf05, // title
0x4: 0x1405, // style
0x5: 0x604, // math
0x6: 0x6, // iframe
0x8: 0x1c03, // xml
0x9: 0x2608, // textarea
0xc: 0x1f03, // xmp
0xe: 0x2109, // plaintext
0xf: 0x1903, // svg
}

View file

@ -21,8 +21,9 @@ const (
EndTagToken
AttributeToken
TextToken
SvgToken
SVGToken
MathToken
XMLToken
TemplateToken
)
@ -47,10 +48,14 @@ func (tt TokenType) String() string {
return "Attribute"
case TextToken:
return "Text"
case SvgToken:
return "Svg"
case SVGToken:
return "SVG"
case MathToken:
return "Math"
case XMLToken:
return "XML"
case TemplateToken:
return "Template"
}
return "Invalid(" + strconv.Itoa(int(tt)) + ")"
}
@ -371,8 +376,8 @@ func (l *Lexer) shiftStartTag() (TokenType, []byte) {
l.r.Move(1)
}
l.text = parse.ToLower(l.r.Lexeme()[1:])
if h := ToHash(l.text); h == Textarea || h == Title || h == Style || h == Xmp || h == Iframe || h == Script || h == Plaintext || h == Svg || h == Math {
if h == Svg || h == Math {
if h := ToHash(l.text); h == Textarea || h == Title || h == Style || h == Xmp || h == Iframe || h == Script || h == Plaintext || h == Svg || h == Math || h == Xml {
if h == Svg || h == Math || h == Xml {
data := l.shiftXML(h)
if l.err != nil {
return ErrorToken, nil
@ -380,10 +385,12 @@ func (l *Lexer) shiftStartTag() (TokenType, []byte) {
l.inTag = false
if h == Svg {
return SvgToken, data
}
return SVGToken, data
} else if h == Math {
return MathToken, data
}
return XMLToken, data
}
l.rawTag = h
}
return StartTagToken, l.r.Shift()

View file

@ -496,6 +496,7 @@ Extensions
- [goldmark-enclave](https://github.com/quailyquaily/goldmark-enclave): Adds support for embedding youtube/bilibili video, X's [oembed X](https://publish.x.com/), [tradingview chart](https://www.tradingview.com/widget/)'s chart, [quaily widget](https://quaily.com), [spotify embeds](https://developer.spotify.com/documentation/embeds), [dify embed](https://dify.ai/) and html audio into the document.
- [goldmark-wiki-table](https://github.com/movsb/goldmark-wiki-table): Adds support for embedding Wiki Tables.
- [goldmark-tgmd](https://github.com/Mad-Pixels/goldmark-tgmd): A Telegram markdown renderer that can be passed to `goldmark.WithRenderer()`.
- [goldmark-treeblood](https://github.com/Wyatt915/goldmark-treeblood): Renders $\LaTeX$ expressions as MathML (pure Go, no external dependencies).
### Loading extensions at runtime
[goldmark-dynamic](https://github.com/yuin/goldmark-dynamic) allows you to write a goldmark extension in Lua and load it at runtime without re-compilation.

View file

@ -89,10 +89,7 @@ func (b *fencedCodeBlockParser) Continue(node ast.Node, reader text.Reader, pc C
}
pos, padding := util.IndentPositionPadding(line, reader.LineOffset(), segment.Padding, fdata.indent)
if pos < 0 {
pos = util.FirstNonSpacePosition(line)
if pos < 0 {
pos = 0
}
pos = max(0, util.FirstNonSpacePosition(line)) - segment.Padding
padding = 0
}
seg := text.NewSegmentPadding(segment.Start+pos, segment.Stop, padding)

View file

@ -11,8 +11,6 @@
// requires Go 1.6 or later)
//
// See https://http2.github.io/ for more information on HTTP/2.
//
// See https://http2.golang.org/ for a test server running this code.
package http2 // import "golang.org/x/net/http2"
import (

View file

@ -349,6 +349,9 @@ struct ltchars {
#define _HIDIOCGRAWPHYS HIDIOCGRAWPHYS(_HIDIOCGRAWPHYS_LEN)
#define _HIDIOCGRAWUNIQ HIDIOCGRAWUNIQ(_HIDIOCGRAWUNIQ_LEN)
// Renamed in v6.16, commit c6d732c38f93 ("net: ethtool: remove duplicate defines for family info")
#define ETHTOOL_FAMILY_NAME ETHTOOL_GENL_NAME
#define ETHTOOL_FAMILY_VERSION ETHTOOL_GENL_VERSION
'
includes_NetBSD='

View file

@ -602,14 +602,9 @@ func Connectx(fd int, srcIf uint32, srcAddr, dstAddr Sockaddr, associd SaeAssocI
return
}
// sys connectx(fd int, endpoints *SaEndpoints, associd SaeAssocID, flags uint32, iov []Iovec, n *uintptr, connid *SaeConnID) (err error)
const minIovec = 8
func Readv(fd int, iovs [][]byte) (n int, err error) {
if !darwinKernelVersionMin(11, 0, 0) {
return 0, ENOSYS
}
iovecs := make([]Iovec, 0, minIovec)
iovecs = appendBytes(iovecs, iovs)
n, err = readv(fd, iovecs)
@ -618,9 +613,6 @@ func Readv(fd int, iovs [][]byte) (n int, err error) {
}
func Preadv(fd int, iovs [][]byte, offset int64) (n int, err error) {
if !darwinKernelVersionMin(11, 0, 0) {
return 0, ENOSYS
}
iovecs := make([]Iovec, 0, minIovec)
iovecs = appendBytes(iovecs, iovs)
n, err = preadv(fd, iovecs, offset)
@ -629,10 +621,6 @@ func Preadv(fd int, iovs [][]byte, offset int64) (n int, err error) {
}
func Writev(fd int, iovs [][]byte) (n int, err error) {
if !darwinKernelVersionMin(11, 0, 0) {
return 0, ENOSYS
}
iovecs := make([]Iovec, 0, minIovec)
iovecs = appendBytes(iovecs, iovs)
if raceenabled {
@ -644,10 +632,6 @@ func Writev(fd int, iovs [][]byte) (n int, err error) {
}
func Pwritev(fd int, iovs [][]byte, offset int64) (n int, err error) {
if !darwinKernelVersionMin(11, 0, 0) {
return 0, ENOSYS
}
iovecs := make([]Iovec, 0, minIovec)
iovecs = appendBytes(iovecs, iovs)
if raceenabled {
@ -707,45 +691,7 @@ func readvRacedetect(iovecs []Iovec, n int, err error) {
}
}
func darwinMajorMinPatch() (maj, min, patch int, err error) {
var un Utsname
err = Uname(&un)
if err != nil {
return
}
var mmp [3]int
c := 0
Loop:
for _, b := range un.Release[:] {
switch {
case b >= '0' && b <= '9':
mmp[c] = 10*mmp[c] + int(b-'0')
case b == '.':
c++
if c > 2 {
return 0, 0, 0, ENOTSUP
}
case b == 0:
break Loop
default:
return 0, 0, 0, ENOTSUP
}
}
if c != 2 {
return 0, 0, 0, ENOTSUP
}
return mmp[0], mmp[1], mmp[2], nil
}
func darwinKernelVersionMin(maj, min, patch int) bool {
actualMaj, actualMin, actualPatch, err := darwinMajorMinPatch()
if err != nil {
return false
}
return actualMaj > maj || actualMaj == maj && (actualMin > min || actualMin == min && actualPatch >= patch)
}
//sys connectx(fd int, endpoints *SaEndpoints, associd SaeAssocID, flags uint32, iov []Iovec, n *uintptr, connid *SaeConnID) (err error)
//sys sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error)
//sys shmat(id int, addr uintptr, flag int) (ret uintptr, err error)

View file

@ -328,6 +328,8 @@ const (
AUDIT_KERNEL = 0x7d0
AUDIT_KERNEL_OTHER = 0x524
AUDIT_KERN_MODULE = 0x532
AUDIT_LANDLOCK_ACCESS = 0x58f
AUDIT_LANDLOCK_DOMAIN = 0x590
AUDIT_LAST_FEATURE = 0x1
AUDIT_LAST_KERN_ANOM_MSG = 0x707
AUDIT_LAST_USER_MSG = 0x4af
@ -492,6 +494,7 @@ const (
BPF_F_BEFORE = 0x8
BPF_F_ID = 0x20
BPF_F_NETFILTER_IP_DEFRAG = 0x1
BPF_F_PREORDER = 0x40
BPF_F_QUERY_EFFECTIVE = 0x1
BPF_F_REDIRECT_FLAGS = 0x19
BPF_F_REPLACE = 0x4
@ -528,6 +531,7 @@ const (
BPF_LDX = 0x1
BPF_LEN = 0x80
BPF_LL_OFF = -0x200000
BPF_LOAD_ACQ = 0x100
BPF_LSH = 0x60
BPF_MAJOR_VERSION = 0x1
BPF_MAXINSNS = 0x1000
@ -555,6 +559,7 @@ const (
BPF_RET = 0x6
BPF_RSH = 0x70
BPF_ST = 0x2
BPF_STORE_REL = 0x110
BPF_STX = 0x3
BPF_SUB = 0x10
BPF_TAG_SIZE = 0x8
@ -844,9 +849,9 @@ const (
DM_UUID_FLAG = 0x4000
DM_UUID_LEN = 0x81
DM_VERSION = 0xc138fd00
DM_VERSION_EXTRA = "-ioctl (2025-01-17)"
DM_VERSION_EXTRA = "-ioctl (2025-04-28)"
DM_VERSION_MAJOR = 0x4
DM_VERSION_MINOR = 0x31
DM_VERSION_MINOR = 0x32
DM_VERSION_PATCHLEVEL = 0x0
DT_BLK = 0x6
DT_CHR = 0x2
@ -937,9 +942,6 @@ const (
EPOLL_CTL_MOD = 0x3
EPOLL_IOC_TYPE = 0x8a
EROFS_SUPER_MAGIC_V1 = 0xe0f5e1e2
ESP_V4_FLOW = 0xa
ESP_V6_FLOW = 0xc
ETHER_FLOW = 0x12
ETHTOOL_BUSINFO_LEN = 0x20
ETHTOOL_EROMVERS_LEN = 0x20
ETHTOOL_FAMILY_NAME = "ethtool"
@ -1213,6 +1215,7 @@ const (
FAN_EVENT_INFO_TYPE_DFID_NAME = 0x2
FAN_EVENT_INFO_TYPE_ERROR = 0x5
FAN_EVENT_INFO_TYPE_FID = 0x1
FAN_EVENT_INFO_TYPE_MNT = 0x7
FAN_EVENT_INFO_TYPE_NEW_DFID_NAME = 0xc
FAN_EVENT_INFO_TYPE_OLD_DFID_NAME = 0xa
FAN_EVENT_INFO_TYPE_PIDFD = 0x4
@ -1231,9 +1234,12 @@ const (
FAN_MARK_IGNORED_SURV_MODIFY = 0x40
FAN_MARK_IGNORE_SURV = 0x440
FAN_MARK_INODE = 0x0
FAN_MARK_MNTNS = 0x110
FAN_MARK_MOUNT = 0x10
FAN_MARK_ONLYDIR = 0x8
FAN_MARK_REMOVE = 0x2
FAN_MNT_ATTACH = 0x1000000
FAN_MNT_DETACH = 0x2000000
FAN_MODIFY = 0x2
FAN_MOVE = 0xc0
FAN_MOVED_FROM = 0x40
@ -1255,6 +1261,7 @@ const (
FAN_REPORT_DIR_FID = 0x400
FAN_REPORT_FD_ERROR = 0x2000
FAN_REPORT_FID = 0x200
FAN_REPORT_MNT = 0x4000
FAN_REPORT_NAME = 0x800
FAN_REPORT_PIDFD = 0x80
FAN_REPORT_TARGET_FID = 0x1000
@ -1274,6 +1281,7 @@ const (
FIB_RULE_PERMANENT = 0x1
FIB_RULE_UNRESOLVED = 0x4
FIDEDUPERANGE = 0xc0189436
FSCRYPT_ADD_KEY_FLAG_HW_WRAPPED = 0x1
FSCRYPT_KEY_DESCRIPTOR_SIZE = 0x8
FSCRYPT_KEY_DESC_PREFIX = "fscrypt:"
FSCRYPT_KEY_DESC_PREFIX_SIZE = 0x8
@ -1582,7 +1590,6 @@ const (
IPV6_DONTFRAG = 0x3e
IPV6_DROP_MEMBERSHIP = 0x15
IPV6_DSTOPTS = 0x3b
IPV6_FLOW = 0x11
IPV6_FREEBIND = 0x4e
IPV6_HDRINCL = 0x24
IPV6_HOPLIMIT = 0x34
@ -1633,7 +1640,6 @@ const (
IPV6_TRANSPARENT = 0x4b
IPV6_UNICAST_HOPS = 0x10
IPV6_UNICAST_IF = 0x4c
IPV6_USER_FLOW = 0xe
IPV6_V6ONLY = 0x1a
IPV6_VERSION = 0x60
IPV6_VERSION_MASK = 0xf0
@ -1695,7 +1701,6 @@ const (
IP_TTL = 0x2
IP_UNBLOCK_SOURCE = 0x25
IP_UNICAST_IF = 0x32
IP_USER_FLOW = 0xd
IP_XFRM_POLICY = 0x11
ISOFS_SUPER_MAGIC = 0x9660
ISTRIP = 0x20
@ -1817,7 +1822,11 @@ const (
LANDLOCK_ACCESS_FS_WRITE_FILE = 0x2
LANDLOCK_ACCESS_NET_BIND_TCP = 0x1
LANDLOCK_ACCESS_NET_CONNECT_TCP = 0x2
LANDLOCK_CREATE_RULESET_ERRATA = 0x2
LANDLOCK_CREATE_RULESET_VERSION = 0x1
LANDLOCK_RESTRICT_SELF_LOG_NEW_EXEC_ON = 0x2
LANDLOCK_RESTRICT_SELF_LOG_SAME_EXEC_OFF = 0x1
LANDLOCK_RESTRICT_SELF_LOG_SUBDOMAINS_OFF = 0x4
LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET = 0x1
LANDLOCK_SCOPE_SIGNAL = 0x2
LINUX_REBOOT_CMD_CAD_OFF = 0x0
@ -2493,6 +2502,10 @@ const (
PR_FP_EXC_UND = 0x40000
PR_FP_MODE_FR = 0x1
PR_FP_MODE_FRE = 0x2
PR_FUTEX_HASH = 0x4e
PR_FUTEX_HASH_GET_IMMUTABLE = 0x3
PR_FUTEX_HASH_GET_SLOTS = 0x2
PR_FUTEX_HASH_SET_SLOTS = 0x1
PR_GET_AUXV = 0x41555856
PR_GET_CHILD_SUBREAPER = 0x25
PR_GET_DUMPABLE = 0x3
@ -2652,6 +2665,10 @@ const (
PR_TAGGED_ADDR_ENABLE = 0x1
PR_TASK_PERF_EVENTS_DISABLE = 0x1f
PR_TASK_PERF_EVENTS_ENABLE = 0x20
PR_TIMER_CREATE_RESTORE_IDS = 0x4d
PR_TIMER_CREATE_RESTORE_IDS_GET = 0x2
PR_TIMER_CREATE_RESTORE_IDS_OFF = 0x0
PR_TIMER_CREATE_RESTORE_IDS_ON = 0x1
PR_TIMING_STATISTICAL = 0x0
PR_TIMING_TIMESTAMP = 0x1
PR_TSC_ENABLE = 0x1
@ -2732,6 +2749,7 @@ const (
PTRACE_SETREGSET = 0x4205
PTRACE_SETSIGINFO = 0x4203
PTRACE_SETSIGMASK = 0x420b
PTRACE_SET_SYSCALL_INFO = 0x4212
PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG = 0x4210
PTRACE_SINGLESTEP = 0x9
PTRACE_SYSCALL = 0x18
@ -2982,6 +3000,7 @@ const (
RTPROT_NTK = 0xf
RTPROT_OPENR = 0x63
RTPROT_OSPF = 0xbc
RTPROT_OVN = 0x54
RTPROT_RA = 0x9
RTPROT_REDIRECT = 0x1
RTPROT_RIP = 0xbd
@ -3336,7 +3355,7 @@ const (
TASKSTATS_GENL_NAME = "TASKSTATS"
TASKSTATS_GENL_VERSION = 0x1
TASKSTATS_TYPE_MAX = 0x6
TASKSTATS_VERSION = 0xf
TASKSTATS_VERSION = 0x10
TCIFLUSH = 0x0
TCIOFF = 0x2
TCIOFLUSH = 0x2
@ -3406,8 +3425,6 @@ const (
TCP_TX_DELAY = 0x25
TCP_ULP = 0x1f
TCP_USER_TIMEOUT = 0x12
TCP_V4_FLOW = 0x1
TCP_V6_FLOW = 0x5
TCP_WINDOW_CLAMP = 0xa
TCP_ZEROCOPY_RECEIVE = 0x23
TFD_TIMER_ABSTIME = 0x1
@ -3530,8 +3547,6 @@ const (
UDP_NO_CHECK6_RX = 0x66
UDP_NO_CHECK6_TX = 0x65
UDP_SEGMENT = 0x67
UDP_V4_FLOW = 0x2
UDP_V6_FLOW = 0x6
UMOUNT_NOFOLLOW = 0x8
USBDEVICE_SUPER_MAGIC = 0x9fa2
UTIME_NOW = 0x3fffffff
@ -3574,7 +3589,7 @@ const (
WDIOS_TEMPPANIC = 0x4
WDIOS_UNKNOWN = -0x1
WEXITED = 0x4
WGALLOWEDIP_A_MAX = 0x3
WGALLOWEDIP_A_MAX = 0x4
WGDEVICE_A_MAX = 0x8
WGPEER_A_MAX = 0xa
WG_CMD_MAX = 0x1
@ -3688,6 +3703,7 @@ const (
XDP_SHARED_UMEM = 0x1
XDP_STATISTICS = 0x7
XDP_TXMD_FLAGS_CHECKSUM = 0x2
XDP_TXMD_FLAGS_LAUNCH_TIME = 0x4
XDP_TXMD_FLAGS_TIMESTAMP = 0x1
XDP_TX_METADATA = 0x2
XDP_TX_RING = 0x3

View file

@ -68,6 +68,7 @@ const (
CS8 = 0x30
CSIZE = 0x30
CSTOPB = 0x40
DM_MPATH_PROBE_PATHS = 0xfd12
ECCGETLAYOUT = 0x81484d11
ECCGETSTATS = 0x80104d12
ECHOCTL = 0x200
@ -360,6 +361,7 @@ const (
SO_OOBINLINE = 0xa
SO_PASSCRED = 0x10
SO_PASSPIDFD = 0x4c
SO_PASSRIGHTS = 0x53
SO_PASSSEC = 0x22
SO_PEEK_OFF = 0x2a
SO_PEERCRED = 0x11

View file

@ -68,6 +68,7 @@ const (
CS8 = 0x30
CSIZE = 0x30
CSTOPB = 0x40
DM_MPATH_PROBE_PATHS = 0xfd12
ECCGETLAYOUT = 0x81484d11
ECCGETSTATS = 0x80104d12
ECHOCTL = 0x200
@ -361,6 +362,7 @@ const (
SO_OOBINLINE = 0xa
SO_PASSCRED = 0x10
SO_PASSPIDFD = 0x4c
SO_PASSRIGHTS = 0x53
SO_PASSSEC = 0x22
SO_PEEK_OFF = 0x2a
SO_PEERCRED = 0x11

View file

@ -68,6 +68,7 @@ const (
CS8 = 0x30
CSIZE = 0x30
CSTOPB = 0x40
DM_MPATH_PROBE_PATHS = 0xfd12
ECCGETLAYOUT = 0x81484d11
ECCGETSTATS = 0x80104d12
ECHOCTL = 0x200
@ -366,6 +367,7 @@ const (
SO_OOBINLINE = 0xa
SO_PASSCRED = 0x10
SO_PASSPIDFD = 0x4c
SO_PASSRIGHTS = 0x53
SO_PASSSEC = 0x22
SO_PEEK_OFF = 0x2a
SO_PEERCRED = 0x11

View file

@ -68,6 +68,7 @@ const (
CS8 = 0x30
CSIZE = 0x30
CSTOPB = 0x40
DM_MPATH_PROBE_PATHS = 0xfd12
ECCGETLAYOUT = 0x81484d11
ECCGETSTATS = 0x80104d12
ECHOCTL = 0x200
@ -359,6 +360,7 @@ const (
SO_OOBINLINE = 0xa
SO_PASSCRED = 0x10
SO_PASSPIDFD = 0x4c
SO_PASSRIGHTS = 0x53
SO_PASSSEC = 0x22
SO_PEEK_OFF = 0x2a
SO_PEERCRED = 0x11

View file

@ -68,6 +68,7 @@ const (
CS8 = 0x30
CSIZE = 0x30
CSTOPB = 0x40
DM_MPATH_PROBE_PATHS = 0xfd12
ECCGETLAYOUT = 0x81484d11
ECCGETSTATS = 0x80104d12
ECHOCTL = 0x200
@ -353,6 +354,7 @@ const (
SO_OOBINLINE = 0xa
SO_PASSCRED = 0x10
SO_PASSPIDFD = 0x4c
SO_PASSRIGHTS = 0x53
SO_PASSSEC = 0x22
SO_PEEK_OFF = 0x2a
SO_PEERCRED = 0x11

View file

@ -68,6 +68,7 @@ const (
CS8 = 0x30
CSIZE = 0x30
CSTOPB = 0x40
DM_MPATH_PROBE_PATHS = 0x2000fd12
ECCGETLAYOUT = 0x41484d11
ECCGETSTATS = 0x40104d12
ECHOCTL = 0x200
@ -359,6 +360,7 @@ const (
SO_OOBINLINE = 0x100
SO_PASSCRED = 0x11
SO_PASSPIDFD = 0x4c
SO_PASSRIGHTS = 0x53
SO_PASSSEC = 0x22
SO_PEEK_OFF = 0x2a
SO_PEERCRED = 0x12

View file

@ -68,6 +68,7 @@ const (
CS8 = 0x30
CSIZE = 0x30
CSTOPB = 0x40
DM_MPATH_PROBE_PATHS = 0x2000fd12
ECCGETLAYOUT = 0x41484d11
ECCGETSTATS = 0x40104d12
ECHOCTL = 0x200
@ -359,6 +360,7 @@ const (
SO_OOBINLINE = 0x100
SO_PASSCRED = 0x11
SO_PASSPIDFD = 0x4c
SO_PASSRIGHTS = 0x53
SO_PASSSEC = 0x22
SO_PEEK_OFF = 0x2a
SO_PEERCRED = 0x12

View file

@ -68,6 +68,7 @@ const (
CS8 = 0x30
CSIZE = 0x30
CSTOPB = 0x40
DM_MPATH_PROBE_PATHS = 0x2000fd12
ECCGETLAYOUT = 0x41484d11
ECCGETSTATS = 0x40104d12
ECHOCTL = 0x200
@ -359,6 +360,7 @@ const (
SO_OOBINLINE = 0x100
SO_PASSCRED = 0x11
SO_PASSPIDFD = 0x4c
SO_PASSRIGHTS = 0x53
SO_PASSSEC = 0x22
SO_PEEK_OFF = 0x2a
SO_PEERCRED = 0x12

View file

@ -68,6 +68,7 @@ const (
CS8 = 0x30
CSIZE = 0x30
CSTOPB = 0x40
DM_MPATH_PROBE_PATHS = 0x2000fd12
ECCGETLAYOUT = 0x41484d11
ECCGETSTATS = 0x40104d12
ECHOCTL = 0x200
@ -359,6 +360,7 @@ const (
SO_OOBINLINE = 0x100
SO_PASSCRED = 0x11
SO_PASSPIDFD = 0x4c
SO_PASSRIGHTS = 0x53
SO_PASSSEC = 0x22
SO_PEEK_OFF = 0x2a
SO_PEERCRED = 0x12

View file

@ -68,6 +68,7 @@ const (
CS8 = 0x300
CSIZE = 0x300
CSTOPB = 0x400
DM_MPATH_PROBE_PATHS = 0x2000fd12
ECCGETLAYOUT = 0x41484d11
ECCGETSTATS = 0x40104d12
ECHOCTL = 0x40
@ -414,6 +415,7 @@ const (
SO_OOBINLINE = 0xa
SO_PASSCRED = 0x14
SO_PASSPIDFD = 0x4c
SO_PASSRIGHTS = 0x53
SO_PASSSEC = 0x22
SO_PEEK_OFF = 0x2a
SO_PEERCRED = 0x15

View file

@ -68,6 +68,7 @@ const (
CS8 = 0x300
CSIZE = 0x300
CSTOPB = 0x400
DM_MPATH_PROBE_PATHS = 0x2000fd12
ECCGETLAYOUT = 0x41484d11
ECCGETSTATS = 0x40104d12
ECHOCTL = 0x40
@ -418,6 +419,7 @@ const (
SO_OOBINLINE = 0xa
SO_PASSCRED = 0x14
SO_PASSPIDFD = 0x4c
SO_PASSRIGHTS = 0x53
SO_PASSSEC = 0x22
SO_PEEK_OFF = 0x2a
SO_PEERCRED = 0x15

View file

@ -68,6 +68,7 @@ const (
CS8 = 0x300
CSIZE = 0x300
CSTOPB = 0x400
DM_MPATH_PROBE_PATHS = 0x2000fd12
ECCGETLAYOUT = 0x41484d11
ECCGETSTATS = 0x40104d12
ECHOCTL = 0x40
@ -418,6 +419,7 @@ const (
SO_OOBINLINE = 0xa
SO_PASSCRED = 0x14
SO_PASSPIDFD = 0x4c
SO_PASSRIGHTS = 0x53
SO_PASSSEC = 0x22
SO_PEEK_OFF = 0x2a
SO_PEERCRED = 0x15

View file

@ -68,6 +68,7 @@ const (
CS8 = 0x30
CSIZE = 0x30
CSTOPB = 0x40
DM_MPATH_PROBE_PATHS = 0xfd12
ECCGETLAYOUT = 0x81484d11
ECCGETSTATS = 0x80104d12
ECHOCTL = 0x200
@ -350,6 +351,7 @@ const (
SO_OOBINLINE = 0xa
SO_PASSCRED = 0x10
SO_PASSPIDFD = 0x4c
SO_PASSRIGHTS = 0x53
SO_PASSSEC = 0x22
SO_PEEK_OFF = 0x2a
SO_PEERCRED = 0x11

View file

@ -68,6 +68,7 @@ const (
CS8 = 0x30
CSIZE = 0x30
CSTOPB = 0x40
DM_MPATH_PROBE_PATHS = 0xfd12
ECCGETLAYOUT = 0x81484d11
ECCGETSTATS = 0x80104d12
ECHOCTL = 0x200
@ -422,6 +423,7 @@ const (
SO_OOBINLINE = 0xa
SO_PASSCRED = 0x10
SO_PASSPIDFD = 0x4c
SO_PASSRIGHTS = 0x53
SO_PASSSEC = 0x22
SO_PEEK_OFF = 0x2a
SO_PEERCRED = 0x11

View file

@ -71,6 +71,7 @@ const (
CS8 = 0x30
CSIZE = 0x30
CSTOPB = 0x40
DM_MPATH_PROBE_PATHS = 0x2000fd12
ECCGETLAYOUT = 0x41484d11
ECCGETSTATS = 0x40104d12
ECHOCTL = 0x200
@ -461,6 +462,7 @@ const (
SO_OOBINLINE = 0x100
SO_PASSCRED = 0x2
SO_PASSPIDFD = 0x55
SO_PASSRIGHTS = 0x5c
SO_PASSSEC = 0x1f
SO_PEEK_OFF = 0x26
SO_PEERCRED = 0x40

View file

@ -462,4 +462,5 @@ const (
SYS_GETXATTRAT = 464
SYS_LISTXATTRAT = 465
SYS_REMOVEXATTRAT = 466
SYS_OPEN_TREE_ATTR = 467
)

View file

@ -385,4 +385,5 @@ const (
SYS_GETXATTRAT = 464
SYS_LISTXATTRAT = 465
SYS_REMOVEXATTRAT = 466
SYS_OPEN_TREE_ATTR = 467
)

View file

@ -426,4 +426,5 @@ const (
SYS_GETXATTRAT = 464
SYS_LISTXATTRAT = 465
SYS_REMOVEXATTRAT = 466
SYS_OPEN_TREE_ATTR = 467
)

View file

@ -329,4 +329,5 @@ const (
SYS_GETXATTRAT = 464
SYS_LISTXATTRAT = 465
SYS_REMOVEXATTRAT = 466
SYS_OPEN_TREE_ATTR = 467
)

View file

@ -325,4 +325,5 @@ const (
SYS_GETXATTRAT = 464
SYS_LISTXATTRAT = 465
SYS_REMOVEXATTRAT = 466
SYS_OPEN_TREE_ATTR = 467
)

View file

@ -446,4 +446,5 @@ const (
SYS_GETXATTRAT = 4464
SYS_LISTXATTRAT = 4465
SYS_REMOVEXATTRAT = 4466
SYS_OPEN_TREE_ATTR = 4467
)

View file

@ -376,4 +376,5 @@ const (
SYS_GETXATTRAT = 5464
SYS_LISTXATTRAT = 5465
SYS_REMOVEXATTRAT = 5466
SYS_OPEN_TREE_ATTR = 5467
)

View file

@ -376,4 +376,5 @@ const (
SYS_GETXATTRAT = 5464
SYS_LISTXATTRAT = 5465
SYS_REMOVEXATTRAT = 5466
SYS_OPEN_TREE_ATTR = 5467
)

View file

@ -446,4 +446,5 @@ const (
SYS_GETXATTRAT = 4464
SYS_LISTXATTRAT = 4465
SYS_REMOVEXATTRAT = 4466
SYS_OPEN_TREE_ATTR = 4467
)

View file

@ -453,4 +453,5 @@ const (
SYS_GETXATTRAT = 464
SYS_LISTXATTRAT = 465
SYS_REMOVEXATTRAT = 466
SYS_OPEN_TREE_ATTR = 467
)

View file

@ -425,4 +425,5 @@ const (
SYS_GETXATTRAT = 464
SYS_LISTXATTRAT = 465
SYS_REMOVEXATTRAT = 466
SYS_OPEN_TREE_ATTR = 467
)

View file

@ -425,4 +425,5 @@ const (
SYS_GETXATTRAT = 464
SYS_LISTXATTRAT = 465
SYS_REMOVEXATTRAT = 466
SYS_OPEN_TREE_ATTR = 467
)

View file

@ -330,4 +330,5 @@ const (
SYS_GETXATTRAT = 464
SYS_LISTXATTRAT = 465
SYS_REMOVEXATTRAT = 466
SYS_OPEN_TREE_ATTR = 467
)

View file

@ -391,4 +391,5 @@ const (
SYS_GETXATTRAT = 464
SYS_LISTXATTRAT = 465
SYS_REMOVEXATTRAT = 466
SYS_OPEN_TREE_ATTR = 467
)

View file

@ -404,4 +404,5 @@ const (
SYS_GETXATTRAT = 464
SYS_LISTXATTRAT = 465
SYS_REMOVEXATTRAT = 466
SYS_OPEN_TREE_ATTR = 467
)

View file

@ -115,7 +115,9 @@ type Statx_t struct {
Atomic_write_unit_max uint32
Atomic_write_segments_max uint32
Dio_read_offset_align uint32
_ [9]uint64
Atomic_write_unit_max_opt uint32
_ [1]uint32
_ [8]uint64
}
type Fsid struct {
@ -199,7 +201,8 @@ type FscryptAddKeyArg struct {
Key_spec FscryptKeySpecifier
Raw_size uint32
Key_id uint32
_ [8]uint32
Flags uint32
_ [7]uint32
}
type FscryptRemoveKeyArg struct {
@ -2317,6 +2320,11 @@ const (
NFT_CT_AVGPKT = 0x10
NFT_CT_ZONE = 0x11
NFT_CT_EVENTMASK = 0x12
NFT_CT_SRC_IP = 0x13
NFT_CT_DST_IP = 0x14
NFT_CT_SRC_IP6 = 0x15
NFT_CT_DST_IP6 = 0x16
NFT_CT_ID = 0x17
NFTA_CT_UNSPEC = 0x0
NFTA_CT_DREG = 0x1
NFTA_CT_KEY = 0x2
@ -2597,8 +2605,8 @@ const (
SOF_TIMESTAMPING_BIND_PHC = 0x8000
SOF_TIMESTAMPING_OPT_ID_TCP = 0x10000
SOF_TIMESTAMPING_LAST = 0x20000
SOF_TIMESTAMPING_MASK = 0x3ffff
SOF_TIMESTAMPING_LAST = 0x40000
SOF_TIMESTAMPING_MASK = 0x7ffff
SCM_TSTAMP_SND = 0x0
SCM_TSTAMP_SCHED = 0x1
@ -4044,7 +4052,7 @@ const (
ETHTOOL_A_TSINFO_PHC_INDEX = 0x5
ETHTOOL_A_TSINFO_STATS = 0x6
ETHTOOL_A_TSINFO_HWTSTAMP_PROVIDER = 0x7
ETHTOOL_A_TSINFO_MAX = 0x7
ETHTOOL_A_TSINFO_MAX = 0x9
ETHTOOL_A_CABLE_TEST_UNSPEC = 0x0
ETHTOOL_A_CABLE_TEST_HEADER = 0x1
ETHTOOL_A_CABLE_TEST_MAX = 0x1
@ -4130,6 +4138,19 @@ const (
ETHTOOL_A_TUNNEL_INFO_MAX = 0x2
)
const (
TCP_V4_FLOW = 0x1
UDP_V4_FLOW = 0x2
TCP_V6_FLOW = 0x5
UDP_V6_FLOW = 0x6
ESP_V4_FLOW = 0xa
ESP_V6_FLOW = 0xc
IP_USER_FLOW = 0xd
IPV6_USER_FLOW = 0xe
IPV6_FLOW = 0x11
ETHER_FLOW = 0x12
)
const SPEED_UNKNOWN = -0x1
type EthtoolDrvinfo struct {
@ -4780,7 +4801,7 @@ const (
NL80211_ATTR_MAC_HINT = 0xc8
NL80211_ATTR_MAC_MASK = 0xd7
NL80211_ATTR_MAX_AP_ASSOC_STA = 0xca
NL80211_ATTR_MAX = 0x150
NL80211_ATTR_MAX = 0x151
NL80211_ATTR_MAX_CRIT_PROT_DURATION = 0xb4
NL80211_ATTR_MAX_CSA_COUNTERS = 0xce
NL80211_ATTR_MAX_HW_TIMESTAMP_PEERS = 0x143
@ -5414,7 +5435,7 @@ const (
NL80211_FREQUENCY_ATTR_GO_CONCURRENT = 0xf
NL80211_FREQUENCY_ATTR_INDOOR_ONLY = 0xe
NL80211_FREQUENCY_ATTR_IR_CONCURRENT = 0xf
NL80211_FREQUENCY_ATTR_MAX = 0x21
NL80211_FREQUENCY_ATTR_MAX = 0x22
NL80211_FREQUENCY_ATTR_MAX_TX_POWER = 0x6
NL80211_FREQUENCY_ATTR_NO_10MHZ = 0x11
NL80211_FREQUENCY_ATTR_NO_160MHZ = 0xc
@ -5530,7 +5551,7 @@ const (
NL80211_MAX_SUPP_SELECTORS = 0x80
NL80211_MBSSID_CONFIG_ATTR_EMA = 0x5
NL80211_MBSSID_CONFIG_ATTR_INDEX = 0x3
NL80211_MBSSID_CONFIG_ATTR_MAX = 0x5
NL80211_MBSSID_CONFIG_ATTR_MAX = 0x6
NL80211_MBSSID_CONFIG_ATTR_MAX_EMA_PROFILE_PERIODICITY = 0x2
NL80211_MBSSID_CONFIG_ATTR_MAX_INTERFACES = 0x1
NL80211_MBSSID_CONFIG_ATTR_TX_IFINDEX = 0x4

View file

@ -282,19 +282,13 @@ type Taskstats struct {
Ac_exitcode uint32
Ac_flag uint8
Ac_nice uint8
_ [4]byte
_ [6]byte
Cpu_count uint64
Cpu_delay_total uint64
Cpu_delay_max uint64
Cpu_delay_min uint64
Blkio_count uint64
Blkio_delay_total uint64
Blkio_delay_max uint64
Blkio_delay_min uint64
Swapin_count uint64
Swapin_delay_total uint64
Swapin_delay_max uint64
Swapin_delay_min uint64
Cpu_run_real_total uint64
Cpu_run_virtual_total uint64
Ac_comm [32]int8
@ -330,17 +324,11 @@ type Taskstats struct {
Cpu_scaled_run_real_total uint64
Freepages_count uint64
Freepages_delay_total uint64
Freepages_delay_max uint64
Freepages_delay_min uint64
Thrashing_count uint64
Thrashing_delay_total uint64
Thrashing_delay_max uint64
Thrashing_delay_min uint64
Ac_btime64 uint64
Compact_count uint64
Compact_delay_total uint64
Compact_delay_max uint64
Compact_delay_min uint64
Ac_tgid uint32
_ [4]byte
Ac_tgetime uint64
@ -348,10 +336,22 @@ type Taskstats struct {
Ac_exe_inode uint64
Wpcopy_count uint64
Wpcopy_delay_total uint64
Wpcopy_delay_max uint64
Wpcopy_delay_min uint64
Irq_count uint64
Irq_delay_total uint64
Cpu_delay_max uint64
Cpu_delay_min uint64
Blkio_delay_max uint64
Blkio_delay_min uint64
Swapin_delay_max uint64
Swapin_delay_min uint64
Freepages_delay_max uint64
Freepages_delay_min uint64
Thrashing_delay_max uint64
Thrashing_delay_min uint64
Compact_delay_max uint64
Compact_delay_min uint64
Wpcopy_delay_max uint64
Wpcopy_delay_min uint64
Irq_delay_max uint64
Irq_delay_min uint64
}

View file

@ -300,16 +300,10 @@ type Taskstats struct {
Ac_nice uint8
Cpu_count uint64
Cpu_delay_total uint64
Cpu_delay_max uint64
Cpu_delay_min uint64
Blkio_count uint64
Blkio_delay_total uint64
Blkio_delay_max uint64
Blkio_delay_min uint64
Swapin_count uint64
Swapin_delay_total uint64
Swapin_delay_max uint64
Swapin_delay_min uint64
Cpu_run_real_total uint64
Cpu_run_virtual_total uint64
Ac_comm [32]int8
@ -344,27 +338,33 @@ type Taskstats struct {
Cpu_scaled_run_real_total uint64
Freepages_count uint64
Freepages_delay_total uint64
Freepages_delay_max uint64
Freepages_delay_min uint64
Thrashing_count uint64
Thrashing_delay_total uint64
Thrashing_delay_max uint64
Thrashing_delay_min uint64
Ac_btime64 uint64
Compact_count uint64
Compact_delay_total uint64
Compact_delay_max uint64
Compact_delay_min uint64
Ac_tgid uint32
Ac_tgetime uint64
Ac_exe_dev uint64
Ac_exe_inode uint64
Wpcopy_count uint64
Wpcopy_delay_total uint64
Wpcopy_delay_max uint64
Wpcopy_delay_min uint64
Irq_count uint64
Irq_delay_total uint64
Cpu_delay_max uint64
Cpu_delay_min uint64
Blkio_delay_max uint64
Blkio_delay_min uint64
Swapin_delay_max uint64
Swapin_delay_min uint64
Freepages_delay_max uint64
Freepages_delay_min uint64
Thrashing_delay_max uint64
Thrashing_delay_min uint64
Compact_delay_max uint64
Compact_delay_min uint64
Wpcopy_delay_max uint64
Wpcopy_delay_min uint64
Irq_delay_max uint64
Irq_delay_min uint64
}

View file

@ -91,7 +91,7 @@ type Stat_t struct {
Gid uint32
Rdev uint64
_ uint16
_ [4]byte
_ [6]byte
Size int64
Blksize int32
_ [4]byte
@ -273,19 +273,13 @@ type Taskstats struct {
Ac_exitcode uint32
Ac_flag uint8
Ac_nice uint8
_ [4]byte
_ [6]byte
Cpu_count uint64
Cpu_delay_total uint64
Cpu_delay_max uint64
Cpu_delay_min uint64
Blkio_count uint64
Blkio_delay_total uint64
Blkio_delay_max uint64
Blkio_delay_min uint64
Swapin_count uint64
Swapin_delay_total uint64
Swapin_delay_max uint64
Swapin_delay_min uint64
Cpu_run_real_total uint64
Cpu_run_virtual_total uint64
Ac_comm [32]uint8
@ -321,17 +315,11 @@ type Taskstats struct {
Cpu_scaled_run_real_total uint64
Freepages_count uint64
Freepages_delay_total uint64
Freepages_delay_max uint64
Freepages_delay_min uint64
Thrashing_count uint64
Thrashing_delay_total uint64
Thrashing_delay_max uint64
Thrashing_delay_min uint64
Ac_btime64 uint64
Compact_count uint64
Compact_delay_total uint64
Compact_delay_max uint64
Compact_delay_min uint64
Ac_tgid uint32
_ [4]byte
Ac_tgetime uint64
@ -339,10 +327,22 @@ type Taskstats struct {
Ac_exe_inode uint64
Wpcopy_count uint64
Wpcopy_delay_total uint64
Wpcopy_delay_max uint64
Wpcopy_delay_min uint64
Irq_count uint64
Irq_delay_total uint64
Cpu_delay_max uint64
Cpu_delay_min uint64
Blkio_delay_max uint64
Blkio_delay_min uint64
Swapin_delay_max uint64
Swapin_delay_min uint64
Freepages_delay_max uint64
Freepages_delay_min uint64
Thrashing_delay_max uint64
Thrashing_delay_min uint64
Compact_delay_max uint64
Compact_delay_min uint64
Wpcopy_delay_max uint64
Wpcopy_delay_min uint64
Irq_delay_max uint64
Irq_delay_min uint64
}

View file

@ -279,16 +279,10 @@ type Taskstats struct {
Ac_nice uint8
Cpu_count uint64
Cpu_delay_total uint64
Cpu_delay_max uint64
Cpu_delay_min uint64
Blkio_count uint64
Blkio_delay_total uint64
Blkio_delay_max uint64
Blkio_delay_min uint64
Swapin_count uint64
Swapin_delay_total uint64
Swapin_delay_max uint64
Swapin_delay_min uint64
Cpu_run_real_total uint64
Cpu_run_virtual_total uint64
Ac_comm [32]int8
@ -323,27 +317,33 @@ type Taskstats struct {
Cpu_scaled_run_real_total uint64
Freepages_count uint64
Freepages_delay_total uint64
Freepages_delay_max uint64
Freepages_delay_min uint64
Thrashing_count uint64
Thrashing_delay_total uint64
Thrashing_delay_max uint64
Thrashing_delay_min uint64
Ac_btime64 uint64
Compact_count uint64
Compact_delay_total uint64
Compact_delay_max uint64
Compact_delay_min uint64
Ac_tgid uint32
Ac_tgetime uint64
Ac_exe_dev uint64
Ac_exe_inode uint64
Wpcopy_count uint64
Wpcopy_delay_total uint64
Wpcopy_delay_max uint64
Wpcopy_delay_min uint64
Irq_count uint64
Irq_delay_total uint64
Cpu_delay_max uint64
Cpu_delay_min uint64
Blkio_delay_max uint64
Blkio_delay_min uint64
Swapin_delay_max uint64
Swapin_delay_min uint64
Freepages_delay_max uint64
Freepages_delay_min uint64
Thrashing_delay_max uint64
Thrashing_delay_min uint64
Compact_delay_max uint64
Compact_delay_min uint64
Wpcopy_delay_max uint64
Wpcopy_delay_min uint64
Irq_delay_max uint64
Irq_delay_min uint64
}

View file

@ -280,16 +280,10 @@ type Taskstats struct {
Ac_nice uint8
Cpu_count uint64
Cpu_delay_total uint64
Cpu_delay_max uint64
Cpu_delay_min uint64
Blkio_count uint64
Blkio_delay_total uint64
Blkio_delay_max uint64
Blkio_delay_min uint64
Swapin_count uint64
Swapin_delay_total uint64
Swapin_delay_max uint64
Swapin_delay_min uint64
Cpu_run_real_total uint64
Cpu_run_virtual_total uint64
Ac_comm [32]int8
@ -324,27 +318,33 @@ type Taskstats struct {
Cpu_scaled_run_real_total uint64
Freepages_count uint64
Freepages_delay_total uint64
Freepages_delay_max uint64
Freepages_delay_min uint64
Thrashing_count uint64
Thrashing_delay_total uint64
Thrashing_delay_max uint64
Thrashing_delay_min uint64
Ac_btime64 uint64
Compact_count uint64
Compact_delay_total uint64
Compact_delay_max uint64
Compact_delay_min uint64
Ac_tgid uint32
Ac_tgetime uint64
Ac_exe_dev uint64
Ac_exe_inode uint64
Wpcopy_count uint64
Wpcopy_delay_total uint64
Wpcopy_delay_max uint64
Wpcopy_delay_min uint64
Irq_count uint64
Irq_delay_total uint64
Cpu_delay_max uint64
Cpu_delay_min uint64
Blkio_delay_max uint64
Blkio_delay_min uint64
Swapin_delay_max uint64
Swapin_delay_min uint64
Freepages_delay_max uint64
Freepages_delay_min uint64
Thrashing_delay_max uint64
Thrashing_delay_min uint64
Compact_delay_max uint64
Compact_delay_min uint64
Wpcopy_delay_max uint64
Wpcopy_delay_min uint64
Irq_delay_max uint64
Irq_delay_min uint64
}

View file

@ -278,19 +278,13 @@ type Taskstats struct {
Ac_exitcode uint32
Ac_flag uint8
Ac_nice uint8
_ [4]byte
_ [6]byte
Cpu_count uint64
Cpu_delay_total uint64
Cpu_delay_max uint64
Cpu_delay_min uint64
Blkio_count uint64
Blkio_delay_total uint64
Blkio_delay_max uint64
Blkio_delay_min uint64
Swapin_count uint64
Swapin_delay_total uint64
Swapin_delay_max uint64
Swapin_delay_min uint64
Cpu_run_real_total uint64
Cpu_run_virtual_total uint64
Ac_comm [32]int8
@ -326,17 +320,11 @@ type Taskstats struct {
Cpu_scaled_run_real_total uint64
Freepages_count uint64
Freepages_delay_total uint64
Freepages_delay_max uint64
Freepages_delay_min uint64
Thrashing_count uint64
Thrashing_delay_total uint64
Thrashing_delay_max uint64
Thrashing_delay_min uint64
Ac_btime64 uint64
Compact_count uint64
Compact_delay_total uint64
Compact_delay_max uint64
Compact_delay_min uint64
Ac_tgid uint32
_ [4]byte
Ac_tgetime uint64
@ -344,10 +332,22 @@ type Taskstats struct {
Ac_exe_inode uint64
Wpcopy_count uint64
Wpcopy_delay_total uint64
Wpcopy_delay_max uint64
Wpcopy_delay_min uint64
Irq_count uint64
Irq_delay_total uint64
Cpu_delay_max uint64
Cpu_delay_min uint64
Blkio_delay_max uint64
Blkio_delay_min uint64
Swapin_delay_max uint64
Swapin_delay_min uint64
Freepages_delay_max uint64
Freepages_delay_min uint64
Thrashing_delay_max uint64
Thrashing_delay_min uint64
Compact_delay_max uint64
Compact_delay_min uint64
Wpcopy_delay_max uint64
Wpcopy_delay_min uint64
Irq_delay_max uint64
Irq_delay_min uint64
}

View file

@ -282,16 +282,10 @@ type Taskstats struct {
Ac_nice uint8
Cpu_count uint64
Cpu_delay_total uint64
Cpu_delay_max uint64
Cpu_delay_min uint64
Blkio_count uint64
Blkio_delay_total uint64
Blkio_delay_max uint64
Blkio_delay_min uint64
Swapin_count uint64
Swapin_delay_total uint64
Swapin_delay_max uint64
Swapin_delay_min uint64
Cpu_run_real_total uint64
Cpu_run_virtual_total uint64
Ac_comm [32]int8
@ -326,27 +320,33 @@ type Taskstats struct {
Cpu_scaled_run_real_total uint64
Freepages_count uint64
Freepages_delay_total uint64
Freepages_delay_max uint64
Freepages_delay_min uint64
Thrashing_count uint64
Thrashing_delay_total uint64
Thrashing_delay_max uint64
Thrashing_delay_min uint64
Ac_btime64 uint64
Compact_count uint64
Compact_delay_total uint64
Compact_delay_max uint64
Compact_delay_min uint64
Ac_tgid uint32
Ac_tgetime uint64
Ac_exe_dev uint64
Ac_exe_inode uint64
Wpcopy_count uint64
Wpcopy_delay_total uint64
Wpcopy_delay_max uint64
Wpcopy_delay_min uint64
Irq_count uint64
Irq_delay_total uint64
Cpu_delay_max uint64
Cpu_delay_min uint64
Blkio_delay_max uint64
Blkio_delay_min uint64
Swapin_delay_max uint64
Swapin_delay_min uint64
Freepages_delay_max uint64
Freepages_delay_min uint64
Thrashing_delay_max uint64
Thrashing_delay_min uint64
Compact_delay_max uint64
Compact_delay_min uint64
Wpcopy_delay_max uint64
Wpcopy_delay_min uint64
Irq_delay_max uint64
Irq_delay_min uint64
}

View file

@ -282,16 +282,10 @@ type Taskstats struct {
Ac_nice uint8
Cpu_count uint64
Cpu_delay_total uint64
Cpu_delay_max uint64
Cpu_delay_min uint64
Blkio_count uint64
Blkio_delay_total uint64
Blkio_delay_max uint64
Blkio_delay_min uint64
Swapin_count uint64
Swapin_delay_total uint64
Swapin_delay_max uint64
Swapin_delay_min uint64
Cpu_run_real_total uint64
Cpu_run_virtual_total uint64
Ac_comm [32]int8
@ -326,27 +320,33 @@ type Taskstats struct {
Cpu_scaled_run_real_total uint64
Freepages_count uint64
Freepages_delay_total uint64
Freepages_delay_max uint64
Freepages_delay_min uint64
Thrashing_count uint64
Thrashing_delay_total uint64
Thrashing_delay_max uint64
Thrashing_delay_min uint64
Ac_btime64 uint64
Compact_count uint64
Compact_delay_total uint64
Compact_delay_max uint64
Compact_delay_min uint64
Ac_tgid uint32
Ac_tgetime uint64
Ac_exe_dev uint64
Ac_exe_inode uint64
Wpcopy_count uint64
Wpcopy_delay_total uint64
Wpcopy_delay_max uint64
Wpcopy_delay_min uint64
Irq_count uint64
Irq_delay_total uint64
Cpu_delay_max uint64
Cpu_delay_min uint64
Blkio_delay_max uint64
Blkio_delay_min uint64
Swapin_delay_max uint64
Swapin_delay_min uint64
Freepages_delay_max uint64
Freepages_delay_min uint64
Thrashing_delay_max uint64
Thrashing_delay_min uint64
Compact_delay_max uint64
Compact_delay_min uint64
Wpcopy_delay_max uint64
Wpcopy_delay_min uint64
Irq_delay_max uint64
Irq_delay_min uint64
}

View file

@ -278,19 +278,13 @@ type Taskstats struct {
Ac_exitcode uint32
Ac_flag uint8
Ac_nice uint8
_ [4]byte
_ [6]byte
Cpu_count uint64
Cpu_delay_total uint64
Cpu_delay_max uint64
Cpu_delay_min uint64
Blkio_count uint64
Blkio_delay_total uint64
Blkio_delay_max uint64
Blkio_delay_min uint64
Swapin_count uint64
Swapin_delay_total uint64
Swapin_delay_max uint64
Swapin_delay_min uint64
Cpu_run_real_total uint64
Cpu_run_virtual_total uint64
Ac_comm [32]int8
@ -326,17 +320,11 @@ type Taskstats struct {
Cpu_scaled_run_real_total uint64
Freepages_count uint64
Freepages_delay_total uint64
Freepages_delay_max uint64
Freepages_delay_min uint64
Thrashing_count uint64
Thrashing_delay_total uint64
Thrashing_delay_max uint64
Thrashing_delay_min uint64
Ac_btime64 uint64
Compact_count uint64
Compact_delay_total uint64
Compact_delay_max uint64
Compact_delay_min uint64
Ac_tgid uint32
_ [4]byte
Ac_tgetime uint64
@ -344,10 +332,22 @@ type Taskstats struct {
Ac_exe_inode uint64
Wpcopy_count uint64
Wpcopy_delay_total uint64
Wpcopy_delay_max uint64
Wpcopy_delay_min uint64
Irq_count uint64
Irq_delay_total uint64
Cpu_delay_max uint64
Cpu_delay_min uint64
Blkio_delay_max uint64
Blkio_delay_min uint64
Swapin_delay_max uint64
Swapin_delay_min uint64
Freepages_delay_max uint64
Freepages_delay_min uint64
Thrashing_delay_max uint64
Thrashing_delay_min uint64
Compact_delay_max uint64
Compact_delay_min uint64
Wpcopy_delay_max uint64
Wpcopy_delay_min uint64
Irq_delay_max uint64
Irq_delay_min uint64
}

View file

@ -90,7 +90,7 @@ type Stat_t struct {
Gid uint32
Rdev uint64
_ uint16
_ [4]byte
_ [6]byte
Size int64
Blksize int32
_ [4]byte
@ -285,19 +285,13 @@ type Taskstats struct {
Ac_exitcode uint32
Ac_flag uint8
Ac_nice uint8
_ [4]byte
_ [6]byte
Cpu_count uint64
Cpu_delay_total uint64
Cpu_delay_max uint64
Cpu_delay_min uint64
Blkio_count uint64
Blkio_delay_total uint64
Blkio_delay_max uint64
Blkio_delay_min uint64
Swapin_count uint64
Swapin_delay_total uint64
Swapin_delay_max uint64
Swapin_delay_min uint64
Cpu_run_real_total uint64
Cpu_run_virtual_total uint64
Ac_comm [32]uint8
@ -333,17 +327,11 @@ type Taskstats struct {
Cpu_scaled_run_real_total uint64
Freepages_count uint64
Freepages_delay_total uint64
Freepages_delay_max uint64
Freepages_delay_min uint64
Thrashing_count uint64
Thrashing_delay_total uint64
Thrashing_delay_max uint64
Thrashing_delay_min uint64
Ac_btime64 uint64
Compact_count uint64
Compact_delay_total uint64
Compact_delay_max uint64
Compact_delay_min uint64
Ac_tgid uint32
_ [4]byte
Ac_tgetime uint64
@ -351,10 +339,22 @@ type Taskstats struct {
Ac_exe_inode uint64
Wpcopy_count uint64
Wpcopy_delay_total uint64
Wpcopy_delay_max uint64
Wpcopy_delay_min uint64
Irq_count uint64
Irq_delay_total uint64
Cpu_delay_max uint64
Cpu_delay_min uint64
Blkio_delay_max uint64
Blkio_delay_min uint64
Swapin_delay_max uint64
Swapin_delay_min uint64
Freepages_delay_max uint64
Freepages_delay_min uint64
Thrashing_delay_max uint64
Thrashing_delay_min uint64
Compact_delay_max uint64
Compact_delay_min uint64
Wpcopy_delay_max uint64
Wpcopy_delay_min uint64
Irq_delay_max uint64
Irq_delay_min uint64
}

View file

@ -289,16 +289,10 @@ type Taskstats struct {
Ac_nice uint8
Cpu_count uint64
Cpu_delay_total uint64
Cpu_delay_max uint64
Cpu_delay_min uint64
Blkio_count uint64
Blkio_delay_total uint64
Blkio_delay_max uint64
Blkio_delay_min uint64
Swapin_count uint64
Swapin_delay_total uint64
Swapin_delay_max uint64
Swapin_delay_min uint64
Cpu_run_real_total uint64
Cpu_run_virtual_total uint64
Ac_comm [32]uint8
@ -333,27 +327,33 @@ type Taskstats struct {
Cpu_scaled_run_real_total uint64
Freepages_count uint64
Freepages_delay_total uint64
Freepages_delay_max uint64
Freepages_delay_min uint64
Thrashing_count uint64
Thrashing_delay_total uint64
Thrashing_delay_max uint64
Thrashing_delay_min uint64
Ac_btime64 uint64
Compact_count uint64
Compact_delay_total uint64
Compact_delay_max uint64
Compact_delay_min uint64
Ac_tgid uint32
Ac_tgetime uint64
Ac_exe_dev uint64
Ac_exe_inode uint64
Wpcopy_count uint64
Wpcopy_delay_total uint64
Wpcopy_delay_max uint64
Wpcopy_delay_min uint64
Irq_count uint64
Irq_delay_total uint64
Cpu_delay_max uint64
Cpu_delay_min uint64
Blkio_delay_max uint64
Blkio_delay_min uint64
Swapin_delay_max uint64
Swapin_delay_min uint64
Freepages_delay_max uint64
Freepages_delay_min uint64
Thrashing_delay_max uint64
Thrashing_delay_min uint64
Compact_delay_max uint64
Compact_delay_min uint64
Wpcopy_delay_max uint64
Wpcopy_delay_min uint64
Irq_delay_max uint64
Irq_delay_min uint64
}

View file

@ -289,16 +289,10 @@ type Taskstats struct {
Ac_nice uint8
Cpu_count uint64
Cpu_delay_total uint64
Cpu_delay_max uint64
Cpu_delay_min uint64
Blkio_count uint64
Blkio_delay_total uint64
Blkio_delay_max uint64
Blkio_delay_min uint64
Swapin_count uint64
Swapin_delay_total uint64
Swapin_delay_max uint64
Swapin_delay_min uint64
Cpu_run_real_total uint64
Cpu_run_virtual_total uint64
Ac_comm [32]uint8
@ -333,27 +327,33 @@ type Taskstats struct {
Cpu_scaled_run_real_total uint64
Freepages_count uint64
Freepages_delay_total uint64
Freepages_delay_max uint64
Freepages_delay_min uint64
Thrashing_count uint64
Thrashing_delay_total uint64
Thrashing_delay_max uint64
Thrashing_delay_min uint64
Ac_btime64 uint64
Compact_count uint64
Compact_delay_total uint64
Compact_delay_max uint64
Compact_delay_min uint64
Ac_tgid uint32
Ac_tgetime uint64
Ac_exe_dev uint64
Ac_exe_inode uint64
Wpcopy_count uint64
Wpcopy_delay_total uint64
Wpcopy_delay_max uint64
Wpcopy_delay_min uint64
Irq_count uint64
Irq_delay_total uint64
Cpu_delay_max uint64
Cpu_delay_min uint64
Blkio_delay_max uint64
Blkio_delay_min uint64
Swapin_delay_max uint64
Swapin_delay_min uint64
Freepages_delay_max uint64
Freepages_delay_min uint64
Thrashing_delay_max uint64
Thrashing_delay_min uint64
Compact_delay_max uint64
Compact_delay_min uint64
Wpcopy_delay_max uint64
Wpcopy_delay_min uint64
Irq_delay_max uint64
Irq_delay_min uint64
}

View file

@ -307,16 +307,10 @@ type Taskstats struct {
Ac_nice uint8
Cpu_count uint64
Cpu_delay_total uint64
Cpu_delay_max uint64
Cpu_delay_min uint64
Blkio_count uint64
Blkio_delay_total uint64
Blkio_delay_max uint64
Blkio_delay_min uint64
Swapin_count uint64
Swapin_delay_total uint64
Swapin_delay_max uint64
Swapin_delay_min uint64
Cpu_run_real_total uint64
Cpu_run_virtual_total uint64
Ac_comm [32]uint8
@ -351,27 +345,33 @@ type Taskstats struct {
Cpu_scaled_run_real_total uint64
Freepages_count uint64
Freepages_delay_total uint64
Freepages_delay_max uint64
Freepages_delay_min uint64
Thrashing_count uint64
Thrashing_delay_total uint64
Thrashing_delay_max uint64
Thrashing_delay_min uint64
Ac_btime64 uint64
Compact_count uint64
Compact_delay_total uint64
Compact_delay_max uint64
Compact_delay_min uint64
Ac_tgid uint32
Ac_tgetime uint64
Ac_exe_dev uint64
Ac_exe_inode uint64
Wpcopy_count uint64
Wpcopy_delay_total uint64
Wpcopy_delay_max uint64
Wpcopy_delay_min uint64
Irq_count uint64
Irq_delay_total uint64
Cpu_delay_max uint64
Cpu_delay_min uint64
Blkio_delay_max uint64
Blkio_delay_min uint64
Swapin_delay_max uint64
Swapin_delay_min uint64
Freepages_delay_max uint64
Freepages_delay_min uint64
Thrashing_delay_max uint64
Thrashing_delay_min uint64
Compact_delay_max uint64
Compact_delay_min uint64
Wpcopy_delay_max uint64
Wpcopy_delay_min uint64
Irq_delay_max uint64
Irq_delay_min uint64
}

View file

@ -302,16 +302,10 @@ type Taskstats struct {
Ac_nice uint8
Cpu_count uint64
Cpu_delay_total uint64
Cpu_delay_max uint64
Cpu_delay_min uint64
Blkio_count uint64
Blkio_delay_total uint64
Blkio_delay_max uint64
Blkio_delay_min uint64
Swapin_count uint64
Swapin_delay_total uint64
Swapin_delay_max uint64
Swapin_delay_min uint64
Cpu_run_real_total uint64
Cpu_run_virtual_total uint64
Ac_comm [32]int8
@ -346,27 +340,33 @@ type Taskstats struct {
Cpu_scaled_run_real_total uint64
Freepages_count uint64
Freepages_delay_total uint64
Freepages_delay_max uint64
Freepages_delay_min uint64
Thrashing_count uint64
Thrashing_delay_total uint64
Thrashing_delay_max uint64
Thrashing_delay_min uint64
Ac_btime64 uint64
Compact_count uint64
Compact_delay_total uint64
Compact_delay_max uint64
Compact_delay_min uint64
Ac_tgid uint32
Ac_tgetime uint64
Ac_exe_dev uint64
Ac_exe_inode uint64
Wpcopy_count uint64
Wpcopy_delay_total uint64
Wpcopy_delay_max uint64
Wpcopy_delay_min uint64
Irq_count uint64
Irq_delay_total uint64
Cpu_delay_max uint64
Cpu_delay_min uint64
Blkio_delay_max uint64
Blkio_delay_min uint64
Swapin_delay_max uint64
Swapin_delay_min uint64
Freepages_delay_max uint64
Freepages_delay_min uint64
Thrashing_delay_max uint64
Thrashing_delay_min uint64
Compact_delay_max uint64
Compact_delay_min uint64
Wpcopy_delay_max uint64
Wpcopy_delay_min uint64
Irq_delay_max uint64
Irq_delay_min uint64
}

View file

@ -284,16 +284,10 @@ type Taskstats struct {
Ac_nice uint8
Cpu_count uint64
Cpu_delay_total uint64
Cpu_delay_max uint64
Cpu_delay_min uint64
Blkio_count uint64
Blkio_delay_total uint64
Blkio_delay_max uint64
Blkio_delay_min uint64
Swapin_count uint64
Swapin_delay_total uint64
Swapin_delay_max uint64
Swapin_delay_min uint64
Cpu_run_real_total uint64
Cpu_run_virtual_total uint64
Ac_comm [32]int8
@ -328,27 +322,33 @@ type Taskstats struct {
Cpu_scaled_run_real_total uint64
Freepages_count uint64
Freepages_delay_total uint64
Freepages_delay_max uint64
Freepages_delay_min uint64
Thrashing_count uint64
Thrashing_delay_total uint64
Thrashing_delay_max uint64
Thrashing_delay_min uint64
Ac_btime64 uint64
Compact_count uint64
Compact_delay_total uint64
Compact_delay_max uint64
Compact_delay_min uint64
Ac_tgid uint32
Ac_tgetime uint64
Ac_exe_dev uint64
Ac_exe_inode uint64
Wpcopy_count uint64
Wpcopy_delay_total uint64
Wpcopy_delay_max uint64
Wpcopy_delay_min uint64
Irq_count uint64
Irq_delay_total uint64
Cpu_delay_max uint64
Cpu_delay_min uint64
Blkio_delay_max uint64
Blkio_delay_min uint64
Swapin_delay_max uint64
Swapin_delay_min uint64
Freepages_delay_max uint64
Freepages_delay_min uint64
Thrashing_delay_max uint64
Thrashing_delay_min uint64
Compact_delay_max uint64
Compact_delay_min uint64
Wpcopy_delay_max uint64
Wpcopy_delay_min uint64
Irq_delay_max uint64
Irq_delay_min uint64
}

View file

@ -224,13 +224,22 @@ extractQueries:
return response.dr, nil
}
// abs returns an absolute representation of path, based on cfg.Dir.
func (cfg *Config) abs(path string) (string, error) {
if filepath.IsAbs(path) {
return path, nil
}
// In case cfg.Dir is relative, pass it to filepath.Abs.
return filepath.Abs(filepath.Join(cfg.Dir, path))
}
func (state *golistState) runContainsQueries(response *responseDeduper, queries []string) error {
for _, query := range queries {
// TODO(matloob): Do only one query per directory.
fdir := filepath.Dir(query)
// Pass absolute path of directory to go list so that it knows to treat it as a directory,
// not a package path.
pattern, err := filepath.Abs(fdir)
pattern, err := state.cfg.abs(fdir)
if err != nil {
return fmt.Errorf("could not determine absolute path of file= query path %q: %v", query, err)
}
@ -703,9 +712,8 @@ func (state *golistState) getGoVersion() (int, error) {
// getPkgPath finds the package path of a directory if it's relative to a root
// directory.
func (state *golistState) getPkgPath(dir string) (string, bool, error) {
absDir, err := filepath.Abs(dir)
if err != nil {
return "", false, err
if !filepath.IsAbs(dir) {
panic("non-absolute dir passed to getPkgPath")
}
roots, err := state.determineRootDirs()
if err != nil {
@ -715,7 +723,7 @@ func (state *golistState) getPkgPath(dir string) (string, bool, error) {
for rdir, rpath := range roots {
// Make sure that the directory is in the module,
// to avoid creating a path relative to another module.
if !strings.HasPrefix(absDir, rdir) {
if !strings.HasPrefix(dir, rdir) {
continue
}
// TODO(matloob): This doesn't properly handle symlinks.

View file

@ -55,7 +55,7 @@ func (state *golistState) determineRootDirsModules() (map[string]string, error)
}
if mod.Dir != "" && mod.Path != "" {
// This is a valid module; add it to the map.
absDir, err := filepath.Abs(mod.Dir)
absDir, err := state.cfg.abs(mod.Dir)
if err != nil {
return nil, err
}

View file

@ -36,13 +36,13 @@ const (
)
// LookupAll only returns those Candidates whose import path
// finds all the nms.
func (ix *Index) LookupAll(pkg string, names ...string) map[string][]Candidate {
// finds all the names.
func (ix *Index) LookupAll(pkgName string, names ...string) map[string][]Candidate {
// this can be made faster when benchmarks show that it needs to be
names = uniquify(names)
byImpPath := make(map[string][]Candidate)
for _, nm := range names {
cands := ix.Lookup(pkg, nm, false)
cands := ix.Lookup(pkgName, nm, false)
for _, c := range cands {
byImpPath[c.ImportPath] = append(byImpPath[c.ImportPath], c)
}
@ -67,9 +67,9 @@ func uniquify(in []string) []string {
// Lookup finds all the symbols in the index with the given PkgName and name.
// If prefix is true, it finds all of these with name as a prefix.
func (ix *Index) Lookup(pkg, name string, prefix bool) []Candidate {
loc, ok := slices.BinarySearchFunc(ix.Entries, pkg, func(e Entry, pkg string) int {
return strings.Compare(e.PkgName, pkg)
func (ix *Index) Lookup(pkgName, name string, prefix bool) []Candidate {
loc, ok := slices.BinarySearchFunc(ix.Entries, pkgName, func(e Entry, pkg string) int {
return strings.Compare(e.PkgName, pkgName)
})
if !ok {
return nil // didn't find the package
@ -78,7 +78,7 @@ func (ix *Index) Lookup(pkg, name string, prefix bool) []Candidate {
// loc is the first entry for this package name, but there may be several
for i := loc; i < len(ix.Entries); i++ {
e := ix.Entries[i]
if e.PkgName != pkg {
if e.PkgName != pkgName {
break // end of sorted package names
}
nloc, ok := slices.BinarySearchFunc(e.Names, name, func(s string, name string) int {
@ -105,7 +105,7 @@ func (ix *Index) Lookup(pkg, name string, prefix bool) []Candidate {
continue // should never happen
}
px := Candidate{
PkgName: pkg,
PkgName: pkgName,
Name: flds[0],
Dir: string(e.Dir),
ImportPath: e.ImportPath,

View file

@ -5,6 +5,8 @@
// Package packagesinternal exposes internal-only fields from go/packages.
package packagesinternal
import "fmt"
var GetDepsErrors = func(p any) []*PackageError { return nil }
type PackageError struct {
@ -13,5 +15,9 @@ type PackageError struct {
Err string // the error itself
}
func (err PackageError) String() string {
return fmt.Sprintf("%s: %s (import stack: %s)", err.Pos, err.Err, err.ImportStack)
}
var TypecheckCgo int
var DepsErrors int // must be set as a LoadMode to call GetDepsErrors

1
vendor/modernc.org/libc/AUTHORS generated vendored
View file

@ -13,6 +13,7 @@ Dan Peterson <danp@danp.net>
Fabrice Colliot <f.colliot@gmail.com>
Jan Mercl <0xjnml@gmail.com>
Jason DeBettencourt <jasond17@gmail.com>
Jasper Siepkes <jasper@siepkes.nl>
Koichi Shiraishi <zchee.io@gmail.com>
Marius Orcsik <marius@federated.id>
Patricio Whittingslow <graded.sp@gmail.com>

View file

@ -13,6 +13,7 @@ Fabrice Colliot <f.colliot@gmail.com>
Jaap Aarts <jaap.aarts1@gmail.com>
Jan Mercl <0xjnml@gmail.com>
Jason DeBettencourt <jasond17@gmail.com>
Jasper Siepkes <jasper@siepkes.nl>
Koichi Shiraishi <zchee.io@gmail.com>
Marius Orcsik <marius@federated.id>
Patricio Whittingslow <graded.sp@gmail.com>

1
vendor/modernc.org/libc/Makefile generated vendored
View file

@ -39,6 +39,7 @@ editor:
go test -c -o /dev/null
go build -o /dev/null -v generator*.go
go build -o /dev/null -v genasm.go
go vet 2>&1 | grep -n 'asm_' || true
generate: download
mkdir -p $(DIR) || true

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -17,6 +17,9 @@ do
echo "GOOS=freebsd GOARCH=arm64"
GOOS=freebsd GOARCH=arm64 go build -tags=$tag -v ./...
GOOS=freebsd GOARCH=arm64 go test -tags=$tag -c -o /dev/null
echo "GOOS=illumos GOARCH=amd64"
GOOS=illumos GOARCH=amd64 go build -tags=$tag -v ./...
GOOS=illumos GOARCH=amd64 go test -tags=$tag -c -o /dev/null
#TODO echo "GOOS=freebsd GOARCH=arm"
#TODO GOOS=freebsd GOARCH=arm go build -tags=$tag -v ./...
#TODO GOOS=freebsd GOARCH=arm go test -tags=$tag -c -o /dev/null

View file

@ -162,6 +162,7 @@ const __DBL_DIG__ = 15
const __DBL_HAS_DENORM__ = 1
const __DBL_HAS_INFINITY__ = 1
const __DBL_HAS_QUIET_NAN__ = 1
const __DBL_IS_IEC_60559__ = 2
const __DBL_MANT_DIG__ = 53
const __DBL_MAX_10_EXP__ = 308
const __DBL_MAX_EXP__ = 1024
@ -200,6 +201,7 @@ const __FLT32X_EPSILON__ = 0
const __FLT32X_HAS_DENORM__ = 1
const __FLT32X_HAS_INFINITY__ = 1
const __FLT32X_HAS_QUIET_NAN__ = 1
const __FLT32X_IS_IEC_60559__ = 2
const __FLT32X_MANT_DIG__ = 53
const __FLT32X_MAX_10_EXP__ = 308
const __FLT32X_MAX_EXP__ = 1024
@ -215,6 +217,7 @@ const __FLT32_EPSILON__ = 0
const __FLT32_HAS_DENORM__ = 1
const __FLT32_HAS_INFINITY__ = 1
const __FLT32_HAS_QUIET_NAN__ = 1
const __FLT32_IS_IEC_60559__ = 2
const __FLT32_MANT_DIG__ = 24
const __FLT32_MAX_10_EXP__ = 38
const __FLT32_MAX_EXP__ = 128
@ -230,6 +233,7 @@ const __FLT64_EPSILON__ = 0
const __FLT64_HAS_DENORM__ = 1
const __FLT64_HAS_INFINITY__ = 1
const __FLT64_HAS_QUIET_NAN__ = 1
const __FLT64_IS_IEC_60559__ = 2
const __FLT64_MANT_DIG__ = 53
const __FLT64_MAX_10_EXP__ = 308
const __FLT64_MAX_EXP__ = 1024
@ -247,6 +251,7 @@ const __FLT_EVAL_METHOD__ = 1
const __FLT_HAS_DENORM__ = 1
const __FLT_HAS_INFINITY__ = 1
const __FLT_HAS_QUIET_NAN__ = 1
const __FLT_IS_IEC_60559__ = 2
const __FLT_MANT_DIG__ = 24
const __FLT_MAX_10_EXP__ = 38
const __FLT_MAX_EXP__ = 128
@ -282,11 +287,13 @@ const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 = 1
const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 = 1
const __GCC_IEC_559 = 2
const __GCC_IEC_559_COMPLEX = 2
const __GNUC_EXECUTION_CHARSET_NAME = "UTF-8"
const __GNUC_MINOR__ = 2
const __GNUC_PATCHLEVEL__ = 1
const __GNUC_PATCHLEVEL__ = 0
const __GNUC_STDC_INLINE__ = 1
const __GNUC__ = 10
const __GXX_ABI_VERSION = 1014
const __GNUC_WIDE_EXECUTION_CHARSET_NAME = "UTF-32BE"
const __GNUC__ = 12
const __GXX_ABI_VERSION = 1017
const __HAVE_SPECULATION_SAFE_VALUE = 1
const __INT16_MAX__ = 32767
const __INT32_MAX__ = 2147483647
@ -323,6 +330,7 @@ const __LDBL_EPSILON__ = 0
const __LDBL_HAS_DENORM__ = 1
const __LDBL_HAS_INFINITY__ = 1
const __LDBL_HAS_QUIET_NAN__ = 1
const __LDBL_IS_IEC_60559__ = 2
const __LDBL_MANT_DIG__ = 53
const __LDBL_MAX_10_EXP__ = 308
const __LDBL_MAX_EXP__ = 1024
@ -391,7 +399,7 @@ const __UINT_LEAST32_MAX__ = 4294967295
const __UINT_LEAST64_MAX__ = 18446744073709551615
const __UINT_LEAST8_MAX__ = 255
const __USE_TIME_BITS64 = 1
const __VERSION__ = "10.2.1 20210110"
const __VERSION__ = "12.2.0"
const __WCHAR_MAX__ = 2147483647
const __WCHAR_MIN__ = -2147483648
const __WCHAR_TYPE__ = 0

2
vendor/modernc.org/libc/etc.go generated vendored
View file

@ -13,7 +13,6 @@ import (
"path/filepath"
"reflect"
"runtime"
"runtime/debug"
"sort"
"strconv"
"strings"
@ -99,7 +98,6 @@ func todo(s string, args ...interface{}) string { //TODO-
dmesg("%s", r)
}
fmt.Fprintf(os.Stdout, "%s\n", r)
fmt.Fprintf(os.Stdout, "%s\n", debug.Stack()) //TODO-
os.Stdout.Sync()
os.Exit(1)
panic("unrechable")

View file

@ -921,7 +921,23 @@ func Xfileno(t *TLS, stream uintptr) int32 {
if __ccgo_strace {
trc("t=%v stream=%v, (%v:)", t, stream, origin(2))
}
panic(todo(""))
if stream == 0 {
if dmesgs {
dmesg("%v: FAIL", origin(1))
}
t.setErrno(errno.EBADF)
return -1
}
if fd := int32((*stdio.FILE)(unsafe.Pointer(stream)).F_file); fd >= 0 {
return fd
}
if dmesgs {
dmesg("%v: FAIL", origin(1))
}
t.setErrno(errno.EBADF)
return -1
}
func newCFtsent(t *TLS, info int, path string, stat *unix.Stat_t, err syscallErrno) uintptr {

View file

@ -12,6 +12,7 @@ import (
"os/exec"
"path/filepath"
"runtime"
// "runtime/debug"
"time"
"unsafe"
@ -26,6 +27,7 @@ import (
"modernc.org/libc/limits"
"modernc.org/libc/netdb"
"modernc.org/libc/netinet/in"
// "modernc.org/libc/signal"
"modernc.org/libc/stdio"
"modernc.org/libc/sys/socket"
@ -55,6 +57,8 @@ type (
type file uintptr
type Tsize_t = types.Size_t
func (f file) fd() int32 {
panic(todo(""))
// return (*stdio.FILE)(unsafe.Pointer(f)).F_fileno
@ -2102,3 +2106,10 @@ func Xclock_gettime(t *TLS, clk_id int32, tp uintptr) int32 {
}
panic(todo(""))
}
func Xgmtime_r(tls *TLS, t uintptr, tm uintptr) (r uintptr) {
if __ccgo_strace {
trc("tls=%v t=%v tm=%v, (%v:)", tls, t, tm, origin(2))
}
panic(todo(""))
}

31
vendor/modernc.org/libc/libc_unix.go generated vendored
View file

@ -1298,21 +1298,6 @@ func Xstrftime(tls *TLS, s uintptr, n size_t, f uintptr, tm uintptr) (r size_t)
}
func Xgmtime_r(tls *TLS, t uintptr, tm uintptr) (r uintptr) {
if __ccgo_strace {
trc("tls=%v t=%v tm=%v, (%v:)", tls, t, tm, origin(2))
defer func() { trc("-> %v", r) }()
}
if x___secs_to_tm(tls, int64(*(*time_t)(unsafe.Pointer(t))), tm) < 0 {
*(*int32)(unsafe.Pointer(X__errno_location(tls))) = int32(errno.EOVERFLOW)
return uintptr(0)
}
(*ctime.Tm)(unsafe.Pointer(tm)).Ftm_isdst = 0
(*ctime.Tm)(unsafe.Pointer(tm)).Ftm_gmtoff = 0
(*ctime.Tm)(unsafe.Pointer(tm)).Ftm_zone = uintptr(unsafe.Pointer(&x___utc))
return tm
}
func x___secs_to_tm(tls *TLS, t int64, tm uintptr) (r int32) {
var c_cycles, leap, months, q_cycles, qc_cycles, remdays, remsecs, remyears, wday, yday int32
var days, secs, years int64
@ -1386,19 +1371,3 @@ func x___secs_to_tm(tls *TLS, t int64, tm uintptr) (r int32) {
(*ctime.Tm)(unsafe.Pointer(tm)).Ftm_sec = remsecs % int32(60)
return 0
}
// int clock_gettime(clockid_t clk_id, struct timespec *tp);
func Xclock_gettime(t *TLS, clk_id int32, tp uintptr) int32 {
if __ccgo_strace {
trc("t=%v clk_id=%v tp=%v, (%v:)", t, clk_id, tp, origin(2))
}
var ts unix.Timespec
if err := unix.ClockGettime(clk_id, &ts); err != nil {
t.setErrno(err)
trc("FAIL: %v", err)
return -1
}
*(*unix.Timespec)(unsafe.Pointer(tp)) = ts
return 0
}

46
vendor/modernc.org/libc/libc_unix3.go generated vendored Normal file
View file

@ -0,0 +1,46 @@
// Copyright 2024 The Libc Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build unix && !illumos && !(linux && (amd64 || arm64 || loong64 || ppc64le || s390x || riscv64 || 386 || arm))
package libc // import "modernc.org/libc"
import (
"unsafe"
"golang.org/x/sys/unix"
"modernc.org/libc/errno"
ctime "modernc.org/libc/time"
)
// int clock_gettime(clockid_t clk_id, struct timespec *tp);
func Xclock_gettime(t *TLS, clk_id int32, tp uintptr) int32 {
if __ccgo_strace {
trc("t=%v clk_id=%v tp=%v, (%v:)", t, clk_id, tp, origin(2))
}
var ts unix.Timespec
if err := unix.ClockGettime(clk_id, &ts); err != nil {
t.setErrno(err)
trc("FAIL: %v", err)
return -1
}
*(*unix.Timespec)(unsafe.Pointer(tp)) = ts
return 0
}
func Xgmtime_r(tls *TLS, t uintptr, tm uintptr) (r uintptr) {
if __ccgo_strace {
trc("tls=%v t=%v tm=%v, (%v:)", tls, t, tm, origin(2))
defer func() { trc("-> %v", r) }()
}
if x___secs_to_tm(tls, int64(*(*time_t)(unsafe.Pointer(t))), tm) < 0 {
*(*int32)(unsafe.Pointer(X__errno_location(tls))) = int32(errno.EOVERFLOW)
return uintptr(0)
}
(*ctime.Tm)(unsafe.Pointer(tm)).Ftm_isdst = 0
(*ctime.Tm)(unsafe.Pointer(tm)).Ftm_gmtoff = 0
(*ctime.Tm)(unsafe.Pointer(tm)).Ftm_zone = uintptr(unsafe.Pointer(&x___utc))
return tm
}

View file

@ -4,13 +4,16 @@
package libc // import "modernc.org/libc"
//go:noescape
func TLSAlloc(p0 *TLS, p1 int) uintptr
//go:noescape
func TLSFree(p0 *TLS, p1 int)
func tlsAlloc(tls *TLS, n int) uintptr {
return tls.Alloc(n)
}
func tlsFre(tls *TLS, n int) {
func tlsFree(tls *TLS, n int) {
tls.Free(n)
}

View file

@ -1,8 +1,9 @@
// Code generated for linux/amd64 by 'genasm []', DO NOT EDIT.
#include "funcdata.h"
#include "textflag.h"
TEXT ·TLSAlloc(SB),$24-24
GO_ARGS
NO_LOCAL_POINTERS
MOVQ p0+0(FP), AX
MOVQ AX, 0(SP)
MOVQ p1+8(FP), AX
@ -13,6 +14,8 @@ TEXT ·TLSAlloc(SB),$24-24
RET
TEXT ·TLSFree(SB),$16-16
GO_ARGS
NO_LOCAL_POINTERS
MOVQ p0+0(FP), AX
MOVQ AX, 0(SP)
MOVQ p1+8(FP), AX

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

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