diff --git a/core/blockchain_reader.go b/core/blockchain_reader.go index 9aad5aa90c..6f71d3108f 100644 --- a/core/blockchain_reader.go +++ b/core/blockchain_reader.go @@ -229,6 +229,14 @@ func (bc *BlockChain) GetReceiptsByHash(hash common.Hash) types.Receipts { return receipts } +func (bc *BlockChain) GetRawReceiptsByHash(hash common.Hash) types.Receipts { + number := rawdb.ReadHeaderNumber(bc.db, hash) + if number == nil { + return nil + } + return rawdb.ReadRawReceipts(bc.db, hash, *number) +} + // GetUnclesInChain retrieves all the uncles from a given block backwards until // a specific distance is reached. func (bc *BlockChain) GetUnclesInChain(block *types.Block, length int) []*types.Header { diff --git a/core/filtermaps/chain_view.go b/core/filtermaps/chain_view.go index 4580f6b687..66dff87292 100644 --- a/core/filtermaps/chain_view.go +++ b/core/filtermaps/chain_view.go @@ -29,6 +29,7 @@ type blockchain interface { GetHeader(hash common.Hash, number uint64) *types.Header GetCanonicalHash(number uint64) common.Hash GetReceiptsByHash(hash common.Hash) types.Receipts + GetRawReceiptsByHash(hash common.Hash) types.Receipts } // ChainView represents an immutable view of a chain with a block id and a set @@ -102,10 +103,23 @@ func (cv *ChainView) Receipts(number uint64) types.Receipts { blockHash := cv.BlockHash(number) if blockHash == (common.Hash{}) { log.Error("Chain view: block hash unavailable", "number", number, "head", cv.headNumber) + return nil } return cv.chain.GetReceiptsByHash(blockHash) } +// RawReceipts returns the set of receipts belonging to the block at the given +// block number. Does not derive the fields of the receipts, should only be +// used during creation of the filter maps, please use cv.Receipts during querying. +func (cv *ChainView) RawReceipts(number uint64) types.Receipts { + blockHash := cv.BlockHash(number) + if blockHash == (common.Hash{}) { + log.Error("Chain view: block hash unavailable", "number", number, "head", cv.headNumber) + return nil + } + return cv.chain.GetRawReceiptsByHash(blockHash) +} + // SharedRange returns the block range shared by two chain views. func (cv *ChainView) SharedRange(cv2 *ChainView) common.Range[uint64] { cv.lock.Lock() diff --git a/core/filtermaps/map_renderer.go b/core/filtermaps/map_renderer.go index a98e80ab99..81ab215701 100644 --- a/core/filtermaps/map_renderer.go +++ b/core/filtermaps/map_renderer.go @@ -693,7 +693,7 @@ func (f *FilterMaps) newLogIteratorFromMapBoundary(mapIndex uint32, startBlock, return nil, fmt.Errorf("iterator entry point %d after target chain head block %d", startBlock, f.targetView.HeadNumber()) } // get block receipts - receipts := f.targetView.Receipts(startBlock) + receipts := f.targetView.RawReceipts(startBlock) if receipts == nil { return nil, fmt.Errorf("receipts not found for start block %d", startBlock) } @@ -760,7 +760,7 @@ func (l *logIterator) next() error { if l.delimiter { l.delimiter = false l.blockNumber++ - l.receipts = l.chainView.Receipts(l.blockNumber) + l.receipts = l.chainView.RawReceipts(l.blockNumber) if l.receipts == nil { return fmt.Errorf("receipts not found for block %d", l.blockNumber) } diff --git a/ctxc/filters/filter_system_test.go b/ctxc/filters/filter_system_test.go index 0a1e528c19..2666085db6 100644 --- a/ctxc/filters/filter_system_test.go +++ b/ctxc/filters/filter_system_test.go @@ -190,6 +190,13 @@ func (b *testBackend) CurrentView() *filtermaps.ChainView { return filtermaps.NewChainView(b, head.Number.Uint64(), head.Hash()) } +func (b *testBackend) GetRawReceiptsByHash(hash common.Hash) types.Receipts { + if number := rawdb.ReadHeaderNumber(b.db, hash); number != nil { + return rawdb.ReadRawReceipts(b.db, hash, *number) + } + return nil +} + func newTestFilterSystem(t testing.TB, db ctxcdb.Database, cfg Config) (*testBackend, *FilterSystem) { backend := &testBackend{db: db} sys := NewFilterSystem(backend, cfg) diff --git a/go.mod b/go.mod index 15c282fe48..b3d8a8456c 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/aws/aws-sdk-go-v2/credentials v1.17.67 github.com/aws/aws-sdk-go-v2/service/route53 v1.51.1 github.com/cespare/cp v1.1.1 - github.com/charmbracelet/bubbletea v1.3.4 + github.com/charmbracelet/bubbletea v1.3.5 github.com/cloudflare/cloudflare-go v0.115.0 github.com/cockroachdb/pebble v1.1.5 github.com/consensys/gnark-crypto v0.17.0 @@ -129,14 +129,14 @@ require ( github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/charmbracelet/colorprofile v0.3.1 // indirect github.com/charmbracelet/lipgloss v1.1.0 // indirect - github.com/charmbracelet/x/ansi v0.8.0 // indirect + github.com/charmbracelet/x/ansi v0.9.2 // indirect github.com/charmbracelet/x/cellbuf v0.0.13 // indirect github.com/charmbracelet/x/term v0.2.1 // indirect github.com/cockroachdb/errors v1.11.3 // indirect github.com/cockroachdb/fifo v0.0.0-20240816210425-c5d0cb0b6fc0 // indirect github.com/cockroachdb/logtags v0.0.0-20241215232642-bb51bb14a506 // indirect github.com/cockroachdb/redact v1.1.6 // indirect - github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect + github.com/cockroachdb/tokenbucket v0.0.0-20250429170803-42689b6311bb // indirect github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be // indirect github.com/consensys/bavard v0.1.30 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect @@ -251,7 +251,7 @@ require ( gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect lukechampine.com/blake3 v1.4.0 // indirect - modernc.org/libc v1.64.0 // indirect + modernc.org/libc v1.64.1 // indirect modernc.org/mathutil v1.7.1 // indirect modernc.org/memory v1.10.0 // indirect modernc.org/sqlite v1.37.0 // indirect diff --git a/go.sum b/go.sum index a6af42c0de..f4387522dd 100644 --- a/go.sum +++ b/go.sum @@ -338,14 +338,14 @@ github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/charmbracelet/bubbletea v1.3.4 h1:kCg7B+jSCFPLYRA52SDZjr51kG/fMUEoPoZrkaDHyoI= -github.com/charmbracelet/bubbletea v1.3.4/go.mod h1:dtcUCyCGEX3g9tosuYiut3MXgY/Jsv9nKVdibKKRRXo= +github.com/charmbracelet/bubbletea v1.3.5 h1:JAMNLTbqMOhSwoELIr0qyP4VidFq72/6E9j7HHmRKQc= +github.com/charmbracelet/bubbletea v1.3.5/go.mod h1:TkCnmH+aBd4LrXhXcqrKiYwRs7qyQx5rBgH5fVY3v54= github.com/charmbracelet/colorprofile v0.3.1 h1:k8dTHMd7fgw4bnFd7jXTLZrSU/CQrKnL3m+AxCzDz40= github.com/charmbracelet/colorprofile v0.3.1/go.mod h1:/GkGusxNs8VB/RSOh3fu0TJmQ4ICMMPApIIVn0KszZ0= github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY= github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30= -github.com/charmbracelet/x/ansi v0.8.0 h1:9GTq3xq9caJW8ZrBTe0LIe2fvfLR/bYXKTx2llXn7xE= -github.com/charmbracelet/x/ansi v0.8.0/go.mod h1:wdYl/ONOLHLIVmQaxbIYEC/cRKOQyjTkowiI4blgS9Q= +github.com/charmbracelet/x/ansi v0.9.2 h1:92AGsQmNTRMzuzHEYfCdjQeUzTrgE1vfO5/7fEVoXdY= +github.com/charmbracelet/x/ansi v0.9.2/go.mod h1:3RQDQ6lDnROptfpWuUVIUG64bD2g2BgntdxH0Ya5TeE= github.com/charmbracelet/x/cellbuf v0.0.13 h1:/KBBKHuVRbq1lYx5BzEHBAFBP8VcQzJejZ/IA3iR28k= github.com/charmbracelet/x/cellbuf v0.0.13/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs= github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ= @@ -375,8 +375,8 @@ github.com/cockroachdb/pebble v1.1.5 h1:5AAWCBWbat0uE0blr8qzufZP5tBjkRyy/jWe1QWL github.com/cockroachdb/pebble v1.1.5/go.mod h1:17wO9el1YEigxkP/YtV8NtCivQDgoCyBg5c4VR/eOWo= github.com/cockroachdb/redact v1.1.6 h1:zXJBwDZ84xJNlHl1rMyCojqyIxv+7YUpQiJLQ7n4314= github.com/cockroachdb/redact v1.1.6/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= -github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= -github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= +github.com/cockroachdb/tokenbucket v0.0.0-20250429170803-42689b6311bb h1:3bCgBvB8PbJVMX1ouCcSIxvsqKPYM7gs72o0zC76n9g= +github.com/cockroachdb/tokenbucket v0.0.0-20250429170803-42689b6311bb/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= github.com/common-nighthawk/go-figure v0.0.0-20190529165535-67e0ed34491a/go.mod h1:mk5IQ+Y0ZeO87b858TlA645sVcEcbiX6YqP98kt+7+w= github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be h1:J5BL2kskAlV9ckgEsNQXscjIaLiOYiZ75d4e94E6dcQ= @@ -1823,8 +1823,8 @@ modernc.org/libc v1.19.0/go.mod h1:ZRfIaEkgrYgZDl6pa4W39HgN5G/yDW+NRmNKZBDFrk0= modernc.org/libc v1.20.3/go.mod h1:ZRfIaEkgrYgZDl6pa4W39HgN5G/yDW+NRmNKZBDFrk0= modernc.org/libc v1.21.4/go.mod h1:przBsL5RDOZajTVslkugzLBj1evTue36jEomFQOoYuI= modernc.org/libc v1.21.5/go.mod h1:przBsL5RDOZajTVslkugzLBj1evTue36jEomFQOoYuI= -modernc.org/libc v1.64.0 h1:U0k8BD2d3cD3e9I8RLcZgJBHAcsJzbXx5mKGSb5pyJA= -modernc.org/libc v1.64.0/go.mod h1:7m9VzGq7APssBTydds2zBcxGREwvIGpuUBaKTXdm2Qs= +modernc.org/libc v1.64.1 h1:EnFXu9N9epQohXMH+h1/w3SxHVGozuPjbux5KVFf5bM= +modernc.org/libc v1.64.1/go.mod h1:7m9VzGq7APssBTydds2zBcxGREwvIGpuUBaKTXdm2Qs= modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU= modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg= diff --git a/trie/proof_test.go b/trie/proof_test.go index 82dc7a671f..f3de98147d 100644 --- a/trie/proof_test.go +++ b/trie/proof_test.go @@ -1004,12 +1004,12 @@ func TestRangeProofKeysWithSharedPrefix(t *testing.T) { // to exit with errors func TestRangeProofErrors(t *testing.T) { // Different number of keys to values - _, err := VerifyRangeProof((common.Hash{}), []byte{}, make([][]byte, 5), make([][]byte, 4), nil) + _, _, _, _, err := VerifyRangeProof((common.Hash{}), []byte{}, []byte{}, make([][]byte, 5), make([][]byte, 4), nil) if have, want := err.Error(), "inconsistent proof data, keys: 5, values: 4"; have != want { t.Fatalf("wrong error, have %q, want %q", err.Error(), want) } // Non-increasing paths - _, err = VerifyRangeProof((common.Hash{}), []byte{}, + _, _, _, _, err = VerifyRangeProof((common.Hash{}), []byte{}, []byte{}, [][]byte{[]byte{2, 1}, []byte{2, 1}}, make([][]byte, 2), nil) if have, want := err.Error(), "range is not monotonically increasing"; have != want { t.Fatalf("wrong error, have %q, want %q", err.Error(), want) @@ -1017,14 +1017,14 @@ func TestRangeProofErrors(t *testing.T) { // A prefixed path is never motivated. Inserting the second element will // require rewriting/overwriting the previous value-node, thus can only // happen if the data is corrupt. - _, err = VerifyRangeProof((common.Hash{}), []byte{}, + _, _, _, _, err = VerifyRangeProof((common.Hash{}), []byte{}, []byte{}, [][]byte{[]byte{2, 1}, []byte{2, 1, 2}}, [][]byte{[]byte{1}, []byte{1}}, nil) if have, want := err.Error(), "range contains path prefixes"; have != want { t.Fatalf("wrong error, have %q, want %q", err.Error(), want) } // Empty values (deletions) - _, err = VerifyRangeProof((common.Hash{}), []byte{}, + _, _, _, _, err = VerifyRangeProof((common.Hash{}), []byte{}, []byte{}, [][]byte{[]byte{2, 1}, []byte{2, 2}}, [][]byte{[]byte{1}, []byte{}}, nil) if have, want := err.Error(), "range contains deletion"; have != want { diff --git a/vendor/github.com/charmbracelet/bubbletea/.golangci-soft.yml b/vendor/github.com/charmbracelet/bubbletea/.golangci-soft.yml deleted file mode 100644 index d325d4fcc6..0000000000 --- a/vendor/github.com/charmbracelet/bubbletea/.golangci-soft.yml +++ /dev/null @@ -1,40 +0,0 @@ -run: - tests: false - issues-exit-code: 0 - -issues: - include: - - EXC0001 - - EXC0005 - - EXC0011 - - EXC0012 - - EXC0013 - - max-issues-per-linter: 0 - max-same-issues: 0 - -linters: - enable: - - exhaustive - - goconst - - godot - - godox - - mnd - - gomoddirectives - - goprintffuncname - - misspell - - nakedret - - nestif - - noctx - - nolintlint - - prealloc - - wrapcheck - - # disable default linters, they are already enabled in .golangci.yml - disable: - - errcheck - - gosimple - - govet - - ineffassign - - staticcheck - - unused diff --git a/vendor/github.com/charmbracelet/bubbletea/.golangci.yml b/vendor/github.com/charmbracelet/bubbletea/.golangci.yml index d6789e014c..be61d89ba1 100644 --- a/vendor/github.com/charmbracelet/bubbletea/.golangci.yml +++ b/vendor/github.com/charmbracelet/bubbletea/.golangci.yml @@ -1,24 +1,23 @@ +version: "2" run: tests: false - -issues: - include: - - EXC0001 - - EXC0005 - - EXC0011 - - EXC0012 - - EXC0013 - - max-issues-per-linter: 0 - max-same-issues: 0 - linters: enable: - bodyclose - - gofumpt - - goimports + - exhaustive + - goconst + - godot + - godox + - gomoddirectives + - goprintffuncname - gosec + - misspell + - nakedret + - nestif - nilerr + - noctx + - nolintlint + - prealloc - revive - rowserrcheck - sqlclosecheck @@ -26,3 +25,17 @@ linters: - unconvert - unparam - whitespace + - wrapcheck + exclusions: + generated: lax + presets: + - common-false-positives +issues: + max-issues-per-linter: 0 + max-same-issues: 0 +formatters: + enable: + - gofumpt + - goimports + exclusions: + generated: lax diff --git a/vendor/github.com/charmbracelet/bubbletea/README.md b/vendor/github.com/charmbracelet/bubbletea/README.md index 58dd1828e2..8f5b1c47a9 100644 --- a/vendor/github.com/charmbracelet/bubbletea/README.md +++ b/vendor/github.com/charmbracelet/bubbletea/README.md @@ -1,7 +1,12 @@ # Bubble Tea

- Bubble Tea Title Treatment
+ + + + + +
Latest Release GoDoc Build Status diff --git a/vendor/github.com/charmbracelet/bubbletea/Taskfile.yaml b/vendor/github.com/charmbracelet/bubbletea/Taskfile.yaml new file mode 100644 index 0000000000..35072035df --- /dev/null +++ b/vendor/github.com/charmbracelet/bubbletea/Taskfile.yaml @@ -0,0 +1,14 @@ +# https://taskfile.dev + +version: '3' + +tasks: + lint: + desc: Run lint + cmds: + - golangci-lint run + + test: + desc: Run tests + cmds: + - go test ./... {{.CLI_ARGS}} diff --git a/vendor/github.com/charmbracelet/bubbletea/inputreader_other.go b/vendor/github.com/charmbracelet/bubbletea/inputreader_other.go index 3426a177c7..1d1b176101 100644 --- a/vendor/github.com/charmbracelet/bubbletea/inputreader_other.go +++ b/vendor/github.com/charmbracelet/bubbletea/inputreader_other.go @@ -4,11 +4,16 @@ package tea import ( + "fmt" "io" "github.com/muesli/cancelreader" ) func newInputReader(r io.Reader, _ bool) (cancelreader.CancelReader, error) { - return cancelreader.NewReader(r) + cr, err := cancelreader.NewReader(r) + if err != nil { + return nil, fmt.Errorf("bubbletea: error creating cancel reader: %w", err) + } + return cr, nil } diff --git a/vendor/github.com/charmbracelet/bubbletea/key.go b/vendor/github.com/charmbracelet/bubbletea/key.go index ab4792ac63..12a161a799 100644 --- a/vendor/github.com/charmbracelet/bubbletea/key.go +++ b/vendor/github.com/charmbracelet/bubbletea/key.go @@ -622,7 +622,7 @@ func detectOneMsg(b []byte, canHaveMoreData bool) (w int, msg Msg) { case '<': if matchIndices := mouseSGRRegex.FindSubmatchIndex(b[3:]); matchIndices != nil { // SGR mouse events length is the length of the match plus the length of the escape sequence - mouseEventSGRLen := matchIndices[1] + 3 //nolint:gomnd + mouseEventSGRLen := matchIndices[1] + 3 //nolint:mnd return mouseEventSGRLen, MouseMsg(parseSGRMouseEvent(b)) } } diff --git a/vendor/github.com/charmbracelet/bubbletea/key_sequences.go b/vendor/github.com/charmbracelet/bubbletea/key_sequences.go index 15483ef528..dce9bf4857 100644 --- a/vendor/github.com/charmbracelet/bubbletea/key_sequences.go +++ b/vendor/github.com/charmbracelet/bubbletea/key_sequences.go @@ -119,13 +119,12 @@ func detectBracketedPaste(input []byte) (hasBp bool, width int, msg Msg) { } // detectReportFocus detects a focus report sequence. -// nolint: gomnd func detectReportFocus(input []byte) (hasRF bool, width int, msg Msg) { switch { case bytes.Equal(input, []byte("\x1b[I")): - return true, 3, FocusMsg{} + return true, 3, FocusMsg{} //nolint:mnd case bytes.Equal(input, []byte("\x1b[O")): - return true, 3, BlurMsg{} + return true, 3, BlurMsg{} //nolint:mnd } return false, 0, nil } diff --git a/vendor/github.com/charmbracelet/bubbletea/key_windows.go b/vendor/github.com/charmbracelet/bubbletea/key_windows.go index d59ff1c462..c977fb842f 100644 --- a/vendor/github.com/charmbracelet/bubbletea/key_windows.go +++ b/vendor/github.com/charmbracelet/bubbletea/key_windows.go @@ -87,7 +87,7 @@ func readConInputs(ctx context.Context, msgsch chan<- Msg, con *conInputReader) if err != nil { return fmt.Errorf("coninput context error: %w", err) } - return err + return nil } } } @@ -114,7 +114,7 @@ func mouseEventButton(p, s coninput.ButtonState) (button MouseButton, action Mou case s&coninput.FROM_LEFT_4TH_BUTTON_PRESSED > 0: button = MouseButtonForward } - return + return button, action } switch { @@ -147,7 +147,7 @@ func mouseEvent(p coninput.ButtonState, e coninput.MouseEventRecord) MouseMsg { if ev.Action == MouseActionRelease { ev.Type = MouseRelease } - switch ev.Button { + switch ev.Button { //nolint:exhaustive case MouseButtonLeft: ev.Type = MouseLeft case MouseButtonMiddle: @@ -190,7 +190,7 @@ func keyType(e coninput.KeyEventRecord) KeyType { shiftPressed := e.ControlKeyState.Contains(coninput.SHIFT_PRESSED) ctrlPressed := e.ControlKeyState.Contains(coninput.LEFT_CTRL_PRESSED | coninput.RIGHT_CTRL_PRESSED) - switch code { + switch code { //nolint:exhaustive case coninput.VK_RETURN: return KeyEnter case coninput.VK_BACK: @@ -276,6 +276,46 @@ func keyType(e coninput.KeyEventRecord) KeyType { return KeyPgDown case coninput.VK_DELETE: return KeyDelete + case coninput.VK_F1: + return KeyF1 + case coninput.VK_F2: + return KeyF2 + case coninput.VK_F3: + return KeyF3 + case coninput.VK_F4: + return KeyF4 + case coninput.VK_F5: + return KeyF5 + case coninput.VK_F6: + return KeyF6 + case coninput.VK_F7: + return KeyF7 + case coninput.VK_F8: + return KeyF8 + case coninput.VK_F9: + return KeyF9 + case coninput.VK_F10: + return KeyF10 + case coninput.VK_F11: + return KeyF11 + case coninput.VK_F12: + return KeyF12 + case coninput.VK_F13: + return KeyF13 + case coninput.VK_F14: + return KeyF14 + case coninput.VK_F15: + return KeyF15 + case coninput.VK_F16: + return KeyF16 + case coninput.VK_F17: + return KeyF17 + case coninput.VK_F18: + return KeyF18 + case coninput.VK_F19: + return KeyF19 + case coninput.VK_F20: + return KeyF20 default: switch { case e.ControlKeyState.Contains(coninput.LEFT_CTRL_PRESSED) && e.ControlKeyState.Contains(coninput.RIGHT_ALT_PRESSED): @@ -348,7 +388,7 @@ func keyType(e coninput.KeyEventRecord) KeyType { return KeyCtrlUnderscore } - switch code { + switch code { //nolint:exhaustive case coninput.VK_OEM_4: return KeyCtrlOpenBracket case coninput.VK_OEM_6: diff --git a/vendor/github.com/charmbracelet/bubbletea/logging.go b/vendor/github.com/charmbracelet/bubbletea/logging.go index a53118193c..349758cbce 100644 --- a/vendor/github.com/charmbracelet/bubbletea/logging.go +++ b/vendor/github.com/charmbracelet/bubbletea/logging.go @@ -33,7 +33,7 @@ type LogOptionsSetter interface { // LogToFileWith does allows to call LogToFile with a custom LogOptionsSetter. func LogToFileWith(path string, prefix string, log LogOptionsSetter) (*os.File, error) { - f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0o600) //nolint:gomnd + f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0o600) //nolint:mnd if err != nil { return nil, fmt.Errorf("error opening file for logging: %w", err) } diff --git a/vendor/github.com/charmbracelet/bubbletea/mouse.go b/vendor/github.com/charmbracelet/bubbletea/mouse.go index 6ec51cc0c0..490f49acbe 100644 --- a/vendor/github.com/charmbracelet/bubbletea/mouse.go +++ b/vendor/github.com/charmbracelet/bubbletea/mouse.go @@ -172,7 +172,7 @@ const ( func parseSGRMouseEvent(buf []byte) MouseEvent { str := string(buf[3:]) matches := mouseSGRRegex.FindStringSubmatch(str) - if len(matches) != 5 { //nolint:gomnd + if len(matches) != 5 { //nolint:mnd // Unreachable, we already checked the regex in `detectOneMsg`. panic("invalid mouse event") } diff --git a/vendor/github.com/charmbracelet/bubbletea/options.go b/vendor/github.com/charmbracelet/bubbletea/options.go index c509353b18..49cf378b59 100644 --- a/vendor/github.com/charmbracelet/bubbletea/options.go +++ b/vendor/github.com/charmbracelet/bubbletea/options.go @@ -19,7 +19,7 @@ type ProgramOption func(*Program) // cancelled it will exit with an error ErrProgramKilled. func WithContext(ctx context.Context) ProgramOption { return func(p *Program) { - p.ctx = ctx + p.externalCtx = ctx } } diff --git a/vendor/github.com/charmbracelet/bubbletea/tea.go b/vendor/github.com/charmbracelet/bubbletea/tea.go index 0bc915e5b3..c4866f220b 100644 --- a/vendor/github.com/charmbracelet/bubbletea/tea.go +++ b/vendor/github.com/charmbracelet/bubbletea/tea.go @@ -27,6 +27,9 @@ import ( "golang.org/x/sync/errgroup" ) +// ErrProgramPanic is returned by [Program.Run] when the program recovers from a panic. +var ErrProgramPanic = errors.New("program experienced a panic") + // ErrProgramKilled is returned by [Program.Run] when the program gets killed. var ErrProgramKilled = errors.New("program was killed") @@ -147,6 +150,12 @@ type Program struct { inputType inputType + // externalCtx is a context that was passed in via WithContext, otherwise defaulting + // to ctx.Background() (in case it was not), the internal context is derived from it. + externalCtx context.Context + + // ctx is the programs's internal context for signalling internal teardown. + // It is built and derived from the externalCtx in NewProgram(). ctx context.Context cancel context.CancelFunc @@ -243,11 +252,11 @@ func NewProgram(model Model, opts ...ProgramOption) *Program { // A context can be provided with a ProgramOption, but if none was provided // we'll use the default background context. - if p.ctx == nil { - p.ctx = context.Background() + if p.externalCtx == nil { + p.externalCtx = context.Background() } // Initialize context and teardown channel. - p.ctx, p.cancel = context.WithCancel(p.ctx) + p.ctx, p.cancel = context.WithCancel(p.externalCtx) // if no output was set, set it to stdout if p.output == nil { @@ -346,7 +355,11 @@ func (p *Program) handleCommands(cmds chan Cmd) chan struct{} { go func() { // Recover from panics. if !p.startupOptions.has(withoutCatchPanics) { - defer p.recoverFromPanic() + defer func() { + if r := recover(); r != nil { + p.recoverFromGoPanic(r) + } + }() } msg := cmd() // this can be long. @@ -422,7 +435,7 @@ func (p *Program) eventLoop(model Model, cmds chan Cmd) (Model, error) { // work. if runtime.GOOS == "windows" && !p.mouseMode { p.mouseMode = true - p.initCancelReader(true) //nolint:errcheck + p.initCancelReader(true) //nolint:errcheck,gosec } case disableMouseMsg: @@ -433,7 +446,7 @@ func (p *Program) eventLoop(model Model, cmds chan Cmd) (Model, error) { // mouse events. if runtime.GOOS == "windows" && p.mouseMode { p.mouseMode = false - p.initCancelReader(true) //nolint:errcheck + p.initCancelReader(true) //nolint:errcheck,gosec } case showCursorMsg: @@ -460,7 +473,11 @@ func (p *Program) eventLoop(model Model, cmds chan Cmd) (Model, error) { case BatchMsg: for _, cmd := range msg { - cmds <- cmd + select { + case <-p.ctx.Done(): + return model, nil + case cmds <- cmd: + } } continue @@ -483,7 +500,7 @@ func (p *Program) eventLoop(model Model, cmds chan Cmd) (Model, error) { }) } - //nolint:errcheck + //nolint:errcheck,gosec g.Wait() // wait for all commands from batch msg to finish continue } @@ -506,7 +523,13 @@ func (p *Program) eventLoop(model Model, cmds chan Cmd) (Model, error) { var cmd Cmd model, cmd = model.Update(msg) // run update - cmds <- cmd // process command (if any) + + select { + case <-p.ctx.Done(): + return model, nil + case cmds <- cmd: // process command (if any) + } + p.renderer.write(model.View()) // send view to renderer } } @@ -515,11 +538,15 @@ func (p *Program) eventLoop(model Model, cmds chan Cmd) (Model, error) { // Run initializes the program and runs its event loops, blocking until it gets // terminated by either [Program.Quit], [Program.Kill], or its signal handler. // Returns the final model. -func (p *Program) Run() (Model, error) { +func (p *Program) Run() (returnModel Model, returnErr error) { p.handlers = channelHandlers{} cmds := make(chan Cmd) - p.errs = make(chan error) - p.finished = make(chan struct{}, 1) + p.errs = make(chan error, 1) + + p.finished = make(chan struct{}) + defer func() { + close(p.finished) + }() defer p.cancel() @@ -568,7 +595,12 @@ func (p *Program) Run() (Model, error) { // Recover from panics. if !p.startupOptions.has(withoutCatchPanics) { - defer p.recoverFromPanic() + defer func() { + if r := recover(); r != nil { + returnErr = fmt.Errorf("%w: %w", ErrProgramKilled, ErrProgramPanic) + p.recoverFromPanic(r) + } + }() } // If no renderer is set use the standard one. @@ -645,11 +677,27 @@ func (p *Program) Run() (Model, error) { // Run event loop, handle updates and draw. model, err := p.eventLoop(model, cmds) - killed := p.ctx.Err() != nil || err != nil - if killed && err == nil { - err = fmt.Errorf("%w: %s", ErrProgramKilled, p.ctx.Err()) + + if err == nil && len(p.errs) > 0 { + err = <-p.errs // Drain a leftover error in case eventLoop crashed } - if err == nil { + + killed := p.externalCtx.Err() != nil || p.ctx.Err() != nil || err != nil + if killed { + if err == nil && p.externalCtx.Err() != nil { + // Return also as context error the cancellation of an external context. + // This is the context the user knows about and should be able to act on. + err = fmt.Errorf("%w: %w", ErrProgramKilled, p.externalCtx.Err()) + } else if err == nil && p.ctx.Err() != nil { + // Return only that the program was killed (not the internal mechanism). + // The user does not know or need to care about the internal program context. + err = ErrProgramKilled + } else { + // Return that the program was killed and also the error that caused it. + err = fmt.Errorf("%w: %w", ErrProgramKilled, err) + } + } else { + // Graceful shutdown of the program (not killed): // Ensure we rendered the final state of the model. p.renderer.write(model.View()) } @@ -704,11 +752,11 @@ func (p *Program) Quit() { p.Send(Quit()) } -// Kill stops the program immediately and restores the former terminal state. +// Kill signals the program to stop immediately and restore the former terminal state. // The final render that you would normally see when quitting will be skipped. // [program.Run] returns a [ErrProgramKilled] error. func (p *Program) Kill() { - p.shutdown(true) + p.cancel() } // Wait waits/blocks until the underlying Program finished shutting down. @@ -717,7 +765,11 @@ func (p *Program) Wait() { } // shutdown performs operations to free up resources and restore the terminal -// to its original state. +// to its original state. It is called once at the end of the program's lifetime. +// +// This method should not be called to signal the program to be killed/shutdown. +// Doing so can lead to race conditions with the eventual call at the program's end. +// As alternatives, the [Quit] or [Kill] convenience methods should be used instead. func (p *Program) shutdown(kill bool) { p.cancel() @@ -744,19 +796,30 @@ func (p *Program) shutdown(kill bool) { } _ = p.restoreTerminalState() - if !kill { - p.finished <- struct{}{} - } } // recoverFromPanic recovers from a panic, prints the stack trace, and restores // the terminal to a usable state. -func (p *Program) recoverFromPanic() { - if r := recover(); r != nil { - p.shutdown(true) - fmt.Printf("Caught panic:\n\n%s\n\nRestoring terminal...\n\n", r) - debug.PrintStack() +func (p *Program) recoverFromPanic(r interface{}) { + select { + case p.errs <- ErrProgramPanic: + default: } + p.shutdown(true) // Ok to call here, p.Run() cannot do it anymore. + fmt.Printf("Caught panic:\n\n%s\n\nRestoring terminal...\n\n", r) + debug.PrintStack() +} + +// recoverFromGoPanic recovers from a goroutine panic, prints a stack trace and +// signals for the program to be killed and terminal restored to a usable state. +func (p *Program) recoverFromGoPanic(r interface{}) { + select { + case p.errs <- ErrProgramPanic: + default: + } + p.cancel() + fmt.Printf("Caught goroutine panic:\n\n%s\n\nRestoring terminal...\n\n", r) + debug.PrintStack() } // ReleaseTerminal restores the original terminal state and cancels the input diff --git a/vendor/github.com/charmbracelet/bubbletea/tty.go b/vendor/github.com/charmbracelet/bubbletea/tty.go index 9490facacb..6812bfc58d 100644 --- a/vendor/github.com/charmbracelet/bubbletea/tty.go +++ b/vendor/github.com/charmbracelet/bubbletea/tty.go @@ -52,7 +52,7 @@ func (p *Program) restoreTerminalState() error { p.renderer.exitAltScreen() // give the terminal a moment to catch up - time.Sleep(time.Millisecond * 10) //nolint:gomnd + time.Sleep(time.Millisecond * 10) //nolint:mnd } } @@ -109,7 +109,7 @@ func (p *Program) readLoop() { func (p *Program) waitForReadLoop() { select { case <-p.readLoopDone: - case <-time.After(500 * time.Millisecond): //nolint:gomnd + case <-time.After(500 * time.Millisecond): //nolint:mnd // The read loop hangs, which means the input // cancelReader's cancel function has returned true even // though it was not able to cancel the read. diff --git a/vendor/github.com/charmbracelet/bubbletea/tty_windows.go b/vendor/github.com/charmbracelet/bubbletea/tty_windows.go index a3a2525bc6..154491a6a1 100644 --- a/vendor/github.com/charmbracelet/bubbletea/tty_windows.go +++ b/vendor/github.com/charmbracelet/bubbletea/tty_windows.go @@ -19,7 +19,7 @@ func (p *Program) initInput() (err error) { p.ttyInput = f p.previousTtyInputState, err = term.MakeRaw(p.ttyInput.Fd()) if err != nil { - return err + return fmt.Errorf("error making raw: %w", err) } // Enable VT input @@ -38,7 +38,7 @@ func (p *Program) initInput() (err error) { p.ttyOutput = f p.previousOutputState, err = term.GetState(f.Fd()) if err != nil { - return err + return fmt.Errorf("error getting state: %w", err) } var mode uint32 @@ -51,14 +51,14 @@ func (p *Program) initInput() (err error) { } } - return + return nil } // Open the Windows equivalent of a TTY. func openInputTTY() (*os.File, error) { f, err := os.OpenFile("CONIN$", os.O_RDWR, 0o644) if err != nil { - return nil, err + return nil, fmt.Errorf("error opening file: %w", err) } return f, nil } diff --git a/vendor/github.com/charmbracelet/x/ansi/color.go b/vendor/github.com/charmbracelet/x/ansi/color.go index 77f8a08d1f..09feb97597 100644 --- a/vendor/github.com/charmbracelet/x/ansi/color.go +++ b/vendor/github.com/charmbracelet/x/ansi/color.go @@ -2,34 +2,9 @@ package ansi import ( "image/color" -) -// Technically speaking, the 16 basic ANSI colors are arbitrary and can be -// customized at the terminal level. Given that, we're returning what we feel -// are good defaults. -// -// This could also be a slice, but we use a map to make the mappings very -// explicit. -// -// See: https://www.ditig.com/publications/256-colors-cheat-sheet -var lowANSI = map[uint32]uint32{ - 0: 0x000000, // black - 1: 0x800000, // red - 2: 0x008000, // green - 3: 0x808000, // yellow - 4: 0x000080, // blue - 5: 0x800080, // magenta - 6: 0x008080, // cyan - 7: 0xc0c0c0, // white - 8: 0x808080, // bright black - 9: 0xff0000, // bright red - 10: 0x00ff00, // bright green - 11: 0xffff00, // bright yellow - 12: 0x0000ff, // bright blue - 13: 0xff00ff, // bright magenta - 14: 0x00ffff, // bright cyan - 15: 0xffffff, // bright white -} + "github.com/lucasb-eyer/go-colorful" +) // Color is a color that can be used in a terminal. ANSI (including // ANSI256) and 24-bit "true colors" fall under this category. @@ -100,28 +75,33 @@ func (c BasicColor) RGBA() (uint32, uint32, uint32, uint32) { return 0, 0, 0, 0xffff } - r, g, b := ansiToRGB(ansi) - return toRGBA(r, g, b) + return ansiToRGB(byte(ansi)).RGBA() } -// ExtendedColor is an ANSI 256 (8-bit) color with a value from 0 to 255. -type ExtendedColor uint8 +// IndexedColor is an ANSI 256 (8-bit) color with a value from 0 to 255. +type IndexedColor uint8 -var _ Color = ExtendedColor(0) +var _ Color = IndexedColor(0) // RGBA returns the red, green, blue and alpha components of the color. It // satisfies the color.Color interface. -func (c ExtendedColor) RGBA() (uint32, uint32, uint32, uint32) { - r, g, b := ansiToRGB(uint32(c)) - return toRGBA(r, g, b) +func (c IndexedColor) RGBA() (uint32, uint32, uint32, uint32) { + return ansiToRGB(byte(c)).RGBA() } +// ExtendedColor is an ANSI 256 (8-bit) color with a value from 0 to 255. +// +// Deprecated: use [IndexedColor] instead. +type ExtendedColor = IndexedColor + // TrueColor is a 24-bit color that can be used in the terminal. // This can be used to represent RGB colors. // // For example, the color red can be represented as: // // TrueColor(0xff0000) +// +// Deprecated: use [RGBColor] instead. type TrueColor uint32 var _ Color = TrueColor(0) @@ -133,44 +113,25 @@ func (c TrueColor) RGBA() (uint32, uint32, uint32, uint32) { return toRGBA(r, g, b) } +// RGBColor is a 24-bit color that can be used in the terminal. +// This can be used to represent RGB colors. +type RGBColor struct { + R uint8 + G uint8 + B uint8 +} + +// RGBA returns the red, green, blue and alpha components of the color. It +// satisfies the color.Color interface. +func (c RGBColor) RGBA() (uint32, uint32, uint32, uint32) { + return toRGBA(uint32(c.R), uint32(c.G), uint32(c.B)) +} + // ansiToRGB converts an ANSI color to a 24-bit RGB color. // // r, g, b := ansiToRGB(57) -func ansiToRGB(ansi uint32) (uint32, uint32, uint32) { - // For out-of-range values return black. - if ansi > 255 { - return 0, 0, 0 - } - - // Low ANSI. - if ansi < 16 { - h, ok := lowANSI[ansi] - if !ok { - return 0, 0, 0 - } - r, g, b := hexToRGB(h) - return r, g, b - } - - // Grays. - if ansi > 231 { - s := (ansi-232)*10 + 8 - return s, s, s - } - - // ANSI256. - n := ansi - 16 - b := n % 6 - g := (n - b) / 6 % 6 - r := (n - b - g*6) / 36 % 6 - for _, v := range []*uint32{&r, &g, &b} { - if *v > 0 { - c := *v*40 + 55 - *v = c - } - } - - return r, g, b +func ansiToRGB(ansi byte) color.Color { + return ansiHex[ansi] } // hexToRGB converts a number in hexadecimal format to red, green, and blue @@ -194,3 +155,630 @@ func toRGBA(r, g, b uint32) (uint32, uint32, uint32, uint32) { b |= b << 8 return r, g, b, 0xffff } + +//nolint:unused +func distSq(r1, g1, b1, r2, g2, b2 int) int { + return ((r1-r2)*(r1-r2) + (g1-g2)*(g1-g2) + (b1-b2)*(b1-b2)) +} + +func to6Cube[T int | float64](v T) int { + if v < 48 { + return 0 + } + if v < 115 { + return 1 + } + return int((v - 35) / 40) +} + +// Convert256 converts a [color.Color], usually a 24-bit color, to xterm(1) 256 +// color palette. +// +// xterm provides a 6x6x6 color cube (16 - 231) and 24 greys (232 - 255). We +// map our RGB color to the closest in the cube, also work out the closest +// grey, and use the nearest of the two based on the lightness of the color. +// +// Note that the xterm has much lower resolution for darker colors (they are +// not evenly spread out), so our 6 levels are not evenly spread: 0x0, 0x5f +// (95), 0x87 (135), 0xaf (175), 0xd7 (215) and 0xff (255). Greys are more +// evenly spread (8, 18, 28 ... 238). +func Convert256(c color.Color) IndexedColor { + // If the color is already an IndexedColor, return it. + if i, ok := c.(IndexedColor); ok { + return i + } + + // Note: this is mostly ported from tmux/colour.c. + col, ok := colorful.MakeColor(c) + if !ok { + return IndexedColor(0) + } + + r := col.R * 255 + g := col.G * 255 + b := col.B * 255 + + q2c := [6]int{0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff} + + // Map RGB to 6x6x6 cube. + qr := to6Cube(r) + cr := q2c[qr] + qg := to6Cube(g) + cg := q2c[qg] + qb := to6Cube(b) + cb := q2c[qb] + + // If we have hit the color exactly, return early. + ci := (36 * qr) + (6 * qg) + qb + if cr == int(r) && cg == int(g) && cb == int(b) { + return IndexedColor(16 + ci) //nolint:gosec + } + + // Work out the closest grey (average of RGB). + greyAvg := int(r+g+b) / 3 + var greyIdx int + if greyAvg > 238 { + greyIdx = 23 + } else { + greyIdx = (greyAvg - 3) / 10 + } + grey := 8 + (10 * greyIdx) + + // Return the one which is nearer to the original input rgb value + // XXX: This is where it differs from tmux's implementation, we prefer the + // closer color to the original in terms of light distances rather than the + // cube distance. + c2 := colorful.Color{R: float64(cr) / 255.0, G: float64(cg) / 255.0, B: float64(cb) / 255.0} + g2 := colorful.Color{R: float64(grey) / 255.0, G: float64(grey) / 255.0, B: float64(grey) / 255.0} + colorDist := col.DistanceHSLuv(c2) + grayDist := col.DistanceHSLuv(g2) + + if colorDist <= grayDist { + return IndexedColor(16 + ci) //nolint:gosec + } + return IndexedColor(232 + greyIdx) //nolint:gosec + + // // Is grey or 6x6x6 color closest? + // d := distSq(cr, cg, cb, int(r), int(g), int(b)) + // if distSq(grey, grey, grey, int(r), int(g), int(b)) < d { + // return IndexedColor(232 + greyIdx) //nolint:gosec + // } + // return IndexedColor(16 + ci) //nolint:gosec +} + +// Convert16 converts a [color.Color] to a 16-color ANSI color. It will first +// try to find a match in the 256 xterm(1) color palette, and then map that to +// the 16-color ANSI palette. +func Convert16(c color.Color) BasicColor { + switch c := c.(type) { + case BasicColor: + // If the color is already a BasicColor, return it. + return c + case IndexedColor: + // If the color is already an IndexedColor, return the corresponding + // BasicColor. + return ansi256To16[c] + default: + c256 := Convert256(c) + return ansi256To16[c256] + } +} + +// RGB values of ANSI colors (0-255). +var ansiHex = [...]color.RGBA{ + 0: {R: 0x00, G: 0x00, B: 0x00, A: 0xff}, // "#000000" + 1: {R: 0x80, G: 0x00, B: 0x00, A: 0xff}, // "#800000" + 2: {R: 0x00, G: 0x80, B: 0x00, A: 0xff}, // "#008000" + 3: {R: 0x80, G: 0x80, B: 0x00, A: 0xff}, // "#808000" + 4: {R: 0x00, G: 0x00, B: 0x80, A: 0xff}, // "#000080" + 5: {R: 0x80, G: 0x00, B: 0x80, A: 0xff}, // "#800080" + 6: {R: 0x00, G: 0x80, B: 0x80, A: 0xff}, // "#008080" + 7: {R: 0xc0, G: 0xc0, B: 0xc0, A: 0xff}, // "#c0c0c0" + 8: {R: 0x80, G: 0x80, B: 0x80, A: 0xff}, // "#808080" + 9: {R: 0xff, G: 0x00, B: 0x00, A: 0xff}, // "#ff0000" + 10: {R: 0x00, G: 0xff, B: 0x00, A: 0xff}, // "#00ff00" + 11: {R: 0xff, G: 0xff, B: 0x00, A: 0xff}, // "#ffff00" + 12: {R: 0x00, G: 0x00, B: 0xff, A: 0xff}, // "#0000ff" + 13: {R: 0xff, G: 0x00, B: 0xff, A: 0xff}, // "#ff00ff" + 14: {R: 0x00, G: 0xff, B: 0xff, A: 0xff}, // "#00ffff" + 15: {R: 0xff, G: 0xff, B: 0xff, A: 0xff}, // "#ffffff" + 16: {R: 0x00, G: 0x00, B: 0x00, A: 0xff}, // "#000000" + 17: {R: 0x00, G: 0x00, B: 0x5f, A: 0xff}, // "#00005f" + 18: {R: 0x00, G: 0x00, B: 0x87, A: 0xff}, // "#000087" + 19: {R: 0x00, G: 0x00, B: 0xaf, A: 0xff}, // "#0000af" + 20: {R: 0x00, G: 0x00, B: 0xd7, A: 0xff}, // "#0000d7" + 21: {R: 0x00, G: 0x00, B: 0xff, A: 0xff}, // "#0000ff" + 22: {R: 0x00, G: 0x5f, B: 0x00, A: 0xff}, // "#005f00" + 23: {R: 0x00, G: 0x5f, B: 0x5f, A: 0xff}, // "#005f5f" + 24: {R: 0x00, G: 0x5f, B: 0x87, A: 0xff}, // "#005f87" + 25: {R: 0x00, G: 0x5f, B: 0xaf, A: 0xff}, // "#005faf" + 26: {R: 0x00, G: 0x5f, B: 0xd7, A: 0xff}, // "#005fd7" + 27: {R: 0x00, G: 0x5f, B: 0xff, A: 0xff}, // "#005fff" + 28: {R: 0x00, G: 0x87, B: 0x00, A: 0xff}, // "#008700" + 29: {R: 0x00, G: 0x87, B: 0x5f, A: 0xff}, // "#00875f" + 30: {R: 0x00, G: 0x87, B: 0x87, A: 0xff}, // "#008787" + 31: {R: 0x00, G: 0x87, B: 0xaf, A: 0xff}, // "#0087af" + 32: {R: 0x00, G: 0x87, B: 0xd7, A: 0xff}, // "#0087d7" + 33: {R: 0x00, G: 0x87, B: 0xff, A: 0xff}, // "#0087ff" + 34: {R: 0x00, G: 0xaf, B: 0x00, A: 0xff}, // "#00af00" + 35: {R: 0x00, G: 0xaf, B: 0x5f, A: 0xff}, // "#00af5f" + 36: {R: 0x00, G: 0xaf, B: 0x87, A: 0xff}, // "#00af87" + 37: {R: 0x00, G: 0xaf, B: 0xaf, A: 0xff}, // "#00afaf" + 38: {R: 0x00, G: 0xaf, B: 0xd7, A: 0xff}, // "#00afd7" + 39: {R: 0x00, G: 0xaf, B: 0xff, A: 0xff}, // "#00afff" + 40: {R: 0x00, G: 0xd7, B: 0x00, A: 0xff}, // "#00d700" + 41: {R: 0x00, G: 0xd7, B: 0x5f, A: 0xff}, // "#00d75f" + 42: {R: 0x00, G: 0xd7, B: 0x87, A: 0xff}, // "#00d787" + 43: {R: 0x00, G: 0xd7, B: 0xaf, A: 0xff}, // "#00d7af" + 44: {R: 0x00, G: 0xd7, B: 0xd7, A: 0xff}, // "#00d7d7" + 45: {R: 0x00, G: 0xd7, B: 0xff, A: 0xff}, // "#00d7ff" + 46: {R: 0x00, G: 0xff, B: 0x00, A: 0xff}, // "#00ff00" + 47: {R: 0x00, G: 0xff, B: 0x5f, A: 0xff}, // "#00ff5f" + 48: {R: 0x00, G: 0xff, B: 0x87, A: 0xff}, // "#00ff87" + 49: {R: 0x00, G: 0xff, B: 0xaf, A: 0xff}, // "#00ffaf" + 50: {R: 0x00, G: 0xff, B: 0xd7, A: 0xff}, // "#00ffd7" + 51: {R: 0x00, G: 0xff, B: 0xff, A: 0xff}, // "#00ffff" + 52: {R: 0x5f, G: 0x00, B: 0x00, A: 0xff}, // "#5f0000" + 53: {R: 0x5f, G: 0x00, B: 0x5f, A: 0xff}, // "#5f005f" + 54: {R: 0x5f, G: 0x00, B: 0x87, A: 0xff}, // "#5f0087" + 55: {R: 0x5f, G: 0x00, B: 0xaf, A: 0xff}, // "#5f00af" + 56: {R: 0x5f, G: 0x00, B: 0xd7, A: 0xff}, // "#5f00d7" + 57: {R: 0x5f, G: 0x00, B: 0xff, A: 0xff}, // "#5f00ff" + 58: {R: 0x5f, G: 0x5f, B: 0x00, A: 0xff}, // "#5f5f00" + 59: {R: 0x5f, G: 0x5f, B: 0x5f, A: 0xff}, // "#5f5f5f" + 60: {R: 0x5f, G: 0x5f, B: 0x87, A: 0xff}, // "#5f5f87" + 61: {R: 0x5f, G: 0x5f, B: 0xaf, A: 0xff}, // "#5f5faf" + 62: {R: 0x5f, G: 0x5f, B: 0xd7, A: 0xff}, // "#5f5fd7" + 63: {R: 0x5f, G: 0x5f, B: 0xff, A: 0xff}, // "#5f5fff" + 64: {R: 0x5f, G: 0x87, B: 0x00, A: 0xff}, // "#5f8700" + 65: {R: 0x5f, G: 0x87, B: 0x5f, A: 0xff}, // "#5f875f" + 66: {R: 0x5f, G: 0x87, B: 0x87, A: 0xff}, // "#5f8787" + 67: {R: 0x5f, G: 0x87, B: 0xaf, A: 0xff}, // "#5f87af" + 68: {R: 0x5f, G: 0x87, B: 0xd7, A: 0xff}, // "#5f87d7" + 69: {R: 0x5f, G: 0x87, B: 0xff, A: 0xff}, // "#5f87ff" + 70: {R: 0x5f, G: 0xaf, B: 0x00, A: 0xff}, // "#5faf00" + 71: {R: 0x5f, G: 0xaf, B: 0x5f, A: 0xff}, // "#5faf5f" + 72: {R: 0x5f, G: 0xaf, B: 0x87, A: 0xff}, // "#5faf87" + 73: {R: 0x5f, G: 0xaf, B: 0xaf, A: 0xff}, // "#5fafaf" + 74: {R: 0x5f, G: 0xaf, B: 0xd7, A: 0xff}, // "#5fafd7" + 75: {R: 0x5f, G: 0xaf, B: 0xff, A: 0xff}, // "#5fafff" + 76: {R: 0x5f, G: 0xd7, B: 0x00, A: 0xff}, // "#5fd700" + 77: {R: 0x5f, G: 0xd7, B: 0x5f, A: 0xff}, // "#5fd75f" + 78: {R: 0x5f, G: 0xd7, B: 0x87, A: 0xff}, // "#5fd787" + 79: {R: 0x5f, G: 0xd7, B: 0xaf, A: 0xff}, // "#5fd7af" + 80: {R: 0x5f, G: 0xd7, B: 0xd7, A: 0xff}, // "#5fd7d7" + 81: {R: 0x5f, G: 0xd7, B: 0xff, A: 0xff}, // "#5fd7ff" + 82: {R: 0x5f, G: 0xff, B: 0x00, A: 0xff}, // "#5fff00" + 83: {R: 0x5f, G: 0xff, B: 0x5f, A: 0xff}, // "#5fff5f" + 84: {R: 0x5f, G: 0xff, B: 0x87, A: 0xff}, // "#5fff87" + 85: {R: 0x5f, G: 0xff, B: 0xaf, A: 0xff}, // "#5fffaf" + 86: {R: 0x5f, G: 0xff, B: 0xd7, A: 0xff}, // "#5fffd7" + 87: {R: 0x5f, G: 0xff, B: 0xff, A: 0xff}, // "#5fffff" + 88: {R: 0x87, G: 0x00, B: 0x00, A: 0xff}, // "#870000" + 89: {R: 0x87, G: 0x00, B: 0x5f, A: 0xff}, // "#87005f" + 90: {R: 0x87, G: 0x00, B: 0x87, A: 0xff}, // "#870087" + 91: {R: 0x87, G: 0x00, B: 0xaf, A: 0xff}, // "#8700af" + 92: {R: 0x87, G: 0x00, B: 0xd7, A: 0xff}, // "#8700d7" + 93: {R: 0x87, G: 0x00, B: 0xff, A: 0xff}, // "#8700ff" + 94: {R: 0x87, G: 0x5f, B: 0x00, A: 0xff}, // "#875f00" + 95: {R: 0x87, G: 0x5f, B: 0x5f, A: 0xff}, // "#875f5f" + 96: {R: 0x87, G: 0x5f, B: 0x87, A: 0xff}, // "#875f87" + 97: {R: 0x87, G: 0x5f, B: 0xaf, A: 0xff}, // "#875faf" + 98: {R: 0x87, G: 0x5f, B: 0xd7, A: 0xff}, // "#875fd7" + 99: {R: 0x87, G: 0x5f, B: 0xff, A: 0xff}, // "#875fff" + 100: {R: 0x87, G: 0x87, B: 0x00, A: 0xff}, // "#878700" + 101: {R: 0x87, G: 0x87, B: 0x5f, A: 0xff}, // "#87875f" + 102: {R: 0x87, G: 0x87, B: 0x87, A: 0xff}, // "#878787" + 103: {R: 0x87, G: 0x87, B: 0xaf, A: 0xff}, // "#8787af" + 104: {R: 0x87, G: 0x87, B: 0xd7, A: 0xff}, // "#8787d7" + 105: {R: 0x87, G: 0x87, B: 0xff, A: 0xff}, // "#8787ff" + 106: {R: 0x87, G: 0xaf, B: 0x00, A: 0xff}, // "#87af00" + 107: {R: 0x87, G: 0xaf, B: 0x5f, A: 0xff}, // "#87af5f" + 108: {R: 0x87, G: 0xaf, B: 0x87, A: 0xff}, // "#87af87" + 109: {R: 0x87, G: 0xaf, B: 0xaf, A: 0xff}, // "#87afaf" + 110: {R: 0x87, G: 0xaf, B: 0xd7, A: 0xff}, // "#87afd7" + 111: {R: 0x87, G: 0xaf, B: 0xff, A: 0xff}, // "#87afff" + 112: {R: 0x87, G: 0xd7, B: 0x00, A: 0xff}, // "#87d700" + 113: {R: 0x87, G: 0xd7, B: 0x5f, A: 0xff}, // "#87d75f" + 114: {R: 0x87, G: 0xd7, B: 0x87, A: 0xff}, // "#87d787" + 115: {R: 0x87, G: 0xd7, B: 0xaf, A: 0xff}, // "#87d7af" + 116: {R: 0x87, G: 0xd7, B: 0xd7, A: 0xff}, // "#87d7d7" + 117: {R: 0x87, G: 0xd7, B: 0xff, A: 0xff}, // "#87d7ff" + 118: {R: 0x87, G: 0xff, B: 0x00, A: 0xff}, // "#87ff00" + 119: {R: 0x87, G: 0xff, B: 0x5f, A: 0xff}, // "#87ff5f" + 120: {R: 0x87, G: 0xff, B: 0x87, A: 0xff}, // "#87ff87" + 121: {R: 0x87, G: 0xff, B: 0xaf, A: 0xff}, // "#87ffaf" + 122: {R: 0x87, G: 0xff, B: 0xd7, A: 0xff}, // "#87ffd7" + 123: {R: 0x87, G: 0xff, B: 0xff, A: 0xff}, // "#87ffff" + 124: {R: 0xaf, G: 0x00, B: 0x00, A: 0xff}, // "#af0000" + 125: {R: 0xaf, G: 0x00, B: 0x5f, A: 0xff}, // "#af005f" + 126: {R: 0xaf, G: 0x00, B: 0x87, A: 0xff}, // "#af0087" + 127: {R: 0xaf, G: 0x00, B: 0xaf, A: 0xff}, // "#af00af" + 128: {R: 0xaf, G: 0x00, B: 0xd7, A: 0xff}, // "#af00d7" + 129: {R: 0xaf, G: 0x00, B: 0xff, A: 0xff}, // "#af00ff" + 130: {R: 0xaf, G: 0x5f, B: 0x00, A: 0xff}, // "#af5f00" + 131: {R: 0xaf, G: 0x5f, B: 0x5f, A: 0xff}, // "#af5f5f" + 132: {R: 0xaf, G: 0x5f, B: 0x87, A: 0xff}, // "#af5f87" + 133: {R: 0xaf, G: 0x5f, B: 0xaf, A: 0xff}, // "#af5faf" + 134: {R: 0xaf, G: 0x5f, B: 0xd7, A: 0xff}, // "#af5fd7" + 135: {R: 0xaf, G: 0x5f, B: 0xff, A: 0xff}, // "#af5fff" + 136: {R: 0xaf, G: 0x87, B: 0x00, A: 0xff}, // "#af8700" + 137: {R: 0xaf, G: 0x87, B: 0x5f, A: 0xff}, // "#af875f" + 138: {R: 0xaf, G: 0x87, B: 0x87, A: 0xff}, // "#af8787" + 139: {R: 0xaf, G: 0x87, B: 0xaf, A: 0xff}, // "#af87af" + 140: {R: 0xaf, G: 0x87, B: 0xd7, A: 0xff}, // "#af87d7" + 141: {R: 0xaf, G: 0x87, B: 0xff, A: 0xff}, // "#af87ff" + 142: {R: 0xaf, G: 0xaf, B: 0x00, A: 0xff}, // "#afaf00" + 143: {R: 0xaf, G: 0xaf, B: 0x5f, A: 0xff}, // "#afaf5f" + 144: {R: 0xaf, G: 0xaf, B: 0x87, A: 0xff}, // "#afaf87" + 145: {R: 0xaf, G: 0xaf, B: 0xaf, A: 0xff}, // "#afafaf" + 146: {R: 0xaf, G: 0xaf, B: 0xd7, A: 0xff}, // "#afafd7" + 147: {R: 0xaf, G: 0xaf, B: 0xff, A: 0xff}, // "#afafff" + 148: {R: 0xaf, G: 0xd7, B: 0x00, A: 0xff}, // "#afd700" + 149: {R: 0xaf, G: 0xd7, B: 0x5f, A: 0xff}, // "#afd75f" + 150: {R: 0xaf, G: 0xd7, B: 0x87, A: 0xff}, // "#afd787" + 151: {R: 0xaf, G: 0xd7, B: 0xaf, A: 0xff}, // "#afd7af" + 152: {R: 0xaf, G: 0xd7, B: 0xd7, A: 0xff}, // "#afd7d7" + 153: {R: 0xaf, G: 0xd7, B: 0xff, A: 0xff}, // "#afd7ff" + 154: {R: 0xaf, G: 0xff, B: 0x00, A: 0xff}, // "#afff00" + 155: {R: 0xaf, G: 0xff, B: 0x5f, A: 0xff}, // "#afff5f" + 156: {R: 0xaf, G: 0xff, B: 0x87, A: 0xff}, // "#afff87" + 157: {R: 0xaf, G: 0xff, B: 0xaf, A: 0xff}, // "#afffaf" + 158: {R: 0xaf, G: 0xff, B: 0xd7, A: 0xff}, // "#afffd7" + 159: {R: 0xaf, G: 0xff, B: 0xff, A: 0xff}, // "#afffff" + 160: {R: 0xd7, G: 0x00, B: 0x00, A: 0xff}, // "#d70000" + 161: {R: 0xd7, G: 0x00, B: 0x5f, A: 0xff}, // "#d7005f" + 162: {R: 0xd7, G: 0x00, B: 0x87, A: 0xff}, // "#d70087" + 163: {R: 0xd7, G: 0x00, B: 0xaf, A: 0xff}, // "#d700af" + 164: {R: 0xd7, G: 0x00, B: 0xd7, A: 0xff}, // "#d700d7" + 165: {R: 0xd7, G: 0x00, B: 0xff, A: 0xff}, // "#d700ff" + 166: {R: 0xd7, G: 0x5f, B: 0x00, A: 0xff}, // "#d75f00" + 167: {R: 0xd7, G: 0x5f, B: 0x5f, A: 0xff}, // "#d75f5f" + 168: {R: 0xd7, G: 0x5f, B: 0x87, A: 0xff}, // "#d75f87" + 169: {R: 0xd7, G: 0x5f, B: 0xaf, A: 0xff}, // "#d75faf" + 170: {R: 0xd7, G: 0x5f, B: 0xd7, A: 0xff}, // "#d75fd7" + 171: {R: 0xd7, G: 0x5f, B: 0xff, A: 0xff}, // "#d75fff" + 172: {R: 0xd7, G: 0x87, B: 0x00, A: 0xff}, // "#d78700" + 173: {R: 0xd7, G: 0x87, B: 0x5f, A: 0xff}, // "#d7875f" + 174: {R: 0xd7, G: 0x87, B: 0x87, A: 0xff}, // "#d78787" + 175: {R: 0xd7, G: 0x87, B: 0xaf, A: 0xff}, // "#d787af" + 176: {R: 0xd7, G: 0x87, B: 0xd7, A: 0xff}, // "#d787d7" + 177: {R: 0xd7, G: 0x87, B: 0xff, A: 0xff}, // "#d787ff" + 178: {R: 0xd7, G: 0xaf, B: 0x00, A: 0xff}, // "#d7af00" + 179: {R: 0xd7, G: 0xaf, B: 0x5f, A: 0xff}, // "#d7af5f" + 180: {R: 0xd7, G: 0xaf, B: 0x87, A: 0xff}, // "#d7af87" + 181: {R: 0xd7, G: 0xaf, B: 0xaf, A: 0xff}, // "#d7afaf" + 182: {R: 0xd7, G: 0xaf, B: 0xd7, A: 0xff}, // "#d7afd7" + 183: {R: 0xd7, G: 0xaf, B: 0xff, A: 0xff}, // "#d7afff" + 184: {R: 0xd7, G: 0xd7, B: 0x00, A: 0xff}, // "#d7d700" + 185: {R: 0xd7, G: 0xd7, B: 0x5f, A: 0xff}, // "#d7d75f" + 186: {R: 0xd7, G: 0xd7, B: 0x87, A: 0xff}, // "#d7d787" + 187: {R: 0xd7, G: 0xd7, B: 0xaf, A: 0xff}, // "#d7d7af" + 188: {R: 0xd7, G: 0xd7, B: 0xd7, A: 0xff}, // "#d7d7d7" + 189: {R: 0xd7, G: 0xd7, B: 0xff, A: 0xff}, // "#d7d7ff" + 190: {R: 0xd7, G: 0xff, B: 0x00, A: 0xff}, // "#d7ff00" + 191: {R: 0xd7, G: 0xff, B: 0x5f, A: 0xff}, // "#d7ff5f" + 192: {R: 0xd7, G: 0xff, B: 0x87, A: 0xff}, // "#d7ff87" + 193: {R: 0xd7, G: 0xff, B: 0xaf, A: 0xff}, // "#d7ffaf" + 194: {R: 0xd7, G: 0xff, B: 0xd7, A: 0xff}, // "#d7ffd7" + 195: {R: 0xd7, G: 0xff, B: 0xff, A: 0xff}, // "#d7ffff" + 196: {R: 0xff, G: 0x00, B: 0x00, A: 0xff}, // "#ff0000" + 197: {R: 0xff, G: 0x00, B: 0x5f, A: 0xff}, // "#ff005f" + 198: {R: 0xff, G: 0x00, B: 0x87, A: 0xff}, // "#ff0087" + 199: {R: 0xff, G: 0x00, B: 0xaf, A: 0xff}, // "#ff00af" + 200: {R: 0xff, G: 0x00, B: 0xd7, A: 0xff}, // "#ff00d7" + 201: {R: 0xff, G: 0x00, B: 0xff, A: 0xff}, // "#ff00ff" + 202: {R: 0xff, G: 0x5f, B: 0x00, A: 0xff}, // "#ff5f00" + 203: {R: 0xff, G: 0x5f, B: 0x5f, A: 0xff}, // "#ff5f5f" + 204: {R: 0xff, G: 0x5f, B: 0x87, A: 0xff}, // "#ff5f87" + 205: {R: 0xff, G: 0x5f, B: 0xaf, A: 0xff}, // "#ff5faf" + 206: {R: 0xff, G: 0x5f, B: 0xd7, A: 0xff}, // "#ff5fd7" + 207: {R: 0xff, G: 0x5f, B: 0xff, A: 0xff}, // "#ff5fff" + 208: {R: 0xff, G: 0x87, B: 0x00, A: 0xff}, // "#ff8700" + 209: {R: 0xff, G: 0x87, B: 0x5f, A: 0xff}, // "#ff875f" + 210: {R: 0xff, G: 0x87, B: 0x87, A: 0xff}, // "#ff8787" + 211: {R: 0xff, G: 0x87, B: 0xaf, A: 0xff}, // "#ff87af" + 212: {R: 0xff, G: 0x87, B: 0xd7, A: 0xff}, // "#ff87d7" + 213: {R: 0xff, G: 0x87, B: 0xff, A: 0xff}, // "#ff87ff" + 214: {R: 0xff, G: 0xaf, B: 0x00, A: 0xff}, // "#ffaf00" + 215: {R: 0xff, G: 0xaf, B: 0x5f, A: 0xff}, // "#ffaf5f" + 216: {R: 0xff, G: 0xaf, B: 0x87, A: 0xff}, // "#ffaf87" + 217: {R: 0xff, G: 0xaf, B: 0xaf, A: 0xff}, // "#ffafaf" + 218: {R: 0xff, G: 0xaf, B: 0xd7, A: 0xff}, // "#ffafd7" + 219: {R: 0xff, G: 0xaf, B: 0xff, A: 0xff}, // "#ffafff" + 220: {R: 0xff, G: 0xd7, B: 0x00, A: 0xff}, // "#ffd700" + 221: {R: 0xff, G: 0xd7, B: 0x5f, A: 0xff}, // "#ffd75f" + 222: {R: 0xff, G: 0xd7, B: 0x87, A: 0xff}, // "#ffd787" + 223: {R: 0xff, G: 0xd7, B: 0xaf, A: 0xff}, // "#ffd7af" + 224: {R: 0xff, G: 0xd7, B: 0xd7, A: 0xff}, // "#ffd7d7" + 225: {R: 0xff, G: 0xd7, B: 0xff, A: 0xff}, // "#ffd7ff" + 226: {R: 0xff, G: 0xff, B: 0x00, A: 0xff}, // "#ffff00" + 227: {R: 0xff, G: 0xff, B: 0x5f, A: 0xff}, // "#ffff5f" + 228: {R: 0xff, G: 0xff, B: 0x87, A: 0xff}, // "#ffff87" + 229: {R: 0xff, G: 0xff, B: 0xaf, A: 0xff}, // "#ffffaf" + 230: {R: 0xff, G: 0xff, B: 0xd7, A: 0xff}, // "#ffffd7" + 231: {R: 0xff, G: 0xff, B: 0xff, A: 0xff}, // "#ffffff" + 232: {R: 0x08, G: 0x08, B: 0x08, A: 0xff}, // "#080808" + 233: {R: 0x12, G: 0x12, B: 0x12, A: 0xff}, // "#121212" + 234: {R: 0x1c, G: 0x1c, B: 0x1c, A: 0xff}, // "#1c1c1c" + 235: {R: 0x26, G: 0x26, B: 0x26, A: 0xff}, // "#262626" + 236: {R: 0x30, G: 0x30, B: 0x30, A: 0xff}, // "#303030" + 237: {R: 0x3a, G: 0x3a, B: 0x3a, A: 0xff}, // "#3a3a3a" + 238: {R: 0x44, G: 0x44, B: 0x44, A: 0xff}, // "#444444" + 239: {R: 0x4e, G: 0x4e, B: 0x4e, A: 0xff}, // "#4e4e4e" + 240: {R: 0x58, G: 0x58, B: 0x58, A: 0xff}, // "#585858" + 241: {R: 0x62, G: 0x62, B: 0x62, A: 0xff}, // "#626262" + 242: {R: 0x6c, G: 0x6c, B: 0x6c, A: 0xff}, // "#6c6c6c" + 243: {R: 0x76, G: 0x76, B: 0x76, A: 0xff}, // "#767676" + 244: {R: 0x80, G: 0x80, B: 0x80, A: 0xff}, // "#808080" + 245: {R: 0x8a, G: 0x8a, B: 0x8a, A: 0xff}, // "#8a8a8a" + 246: {R: 0x94, G: 0x94, B: 0x94, A: 0xff}, // "#949494" + 247: {R: 0x9e, G: 0x9e, B: 0x9e, A: 0xff}, // "#9e9e9e" + 248: {R: 0xa8, G: 0xa8, B: 0xa8, A: 0xff}, // "#a8a8a8" + 249: {R: 0xb2, G: 0xb2, B: 0xb2, A: 0xff}, // "#b2b2b2" + 250: {R: 0xbc, G: 0xbc, B: 0xbc, A: 0xff}, // "#bcbcbc" + 251: {R: 0xc6, G: 0xc6, B: 0xc6, A: 0xff}, // "#c6c6c6" + 252: {R: 0xd0, G: 0xd0, B: 0xd0, A: 0xff}, // "#d0d0d0" + 253: {R: 0xda, G: 0xda, B: 0xda, A: 0xff}, // "#dadada" + 254: {R: 0xe4, G: 0xe4, B: 0xe4, A: 0xff}, // "#e4e4e4" + 255: {R: 0xee, G: 0xee, B: 0xee, A: 0xff}, // "#eeeeee" +} + +var ansi256To16 = [...]BasicColor{ + 0: 0, + 1: 1, + 2: 2, + 3: 3, + 4: 4, + 5: 5, + 6: 6, + 7: 7, + 8: 8, + 9: 9, + 10: 10, + 11: 11, + 12: 12, + 13: 13, + 14: 14, + 15: 15, + 16: 0, + 17: 4, + 18: 4, + 19: 4, + 20: 12, + 21: 12, + 22: 2, + 23: 6, + 24: 4, + 25: 4, + 26: 12, + 27: 12, + 28: 2, + 29: 2, + 30: 6, + 31: 4, + 32: 12, + 33: 12, + 34: 2, + 35: 2, + 36: 2, + 37: 6, + 38: 12, + 39: 12, + 40: 10, + 41: 10, + 42: 10, + 43: 10, + 44: 14, + 45: 12, + 46: 10, + 47: 10, + 48: 10, + 49: 10, + 50: 10, + 51: 14, + 52: 1, + 53: 5, + 54: 4, + 55: 4, + 56: 12, + 57: 12, + 58: 3, + 59: 8, + 60: 4, + 61: 4, + 62: 12, + 63: 12, + 64: 2, + 65: 2, + 66: 6, + 67: 4, + 68: 12, + 69: 12, + 70: 2, + 71: 2, + 72: 2, + 73: 6, + 74: 12, + 75: 12, + 76: 10, + 77: 10, + 78: 10, + 79: 10, + 80: 14, + 81: 12, + 82: 10, + 83: 10, + 84: 10, + 85: 10, + 86: 10, + 87: 14, + 88: 1, + 89: 1, + 90: 5, + 91: 4, + 92: 12, + 93: 12, + 94: 1, + 95: 1, + 96: 5, + 97: 4, + 98: 12, + 99: 12, + 100: 3, + 101: 3, + 102: 8, + 103: 4, + 104: 12, + 105: 12, + 106: 2, + 107: 2, + 108: 2, + 109: 6, + 110: 12, + 111: 12, + 112: 10, + 113: 10, + 114: 10, + 115: 10, + 116: 14, + 117: 12, + 118: 10, + 119: 10, + 120: 10, + 121: 10, + 122: 10, + 123: 14, + 124: 1, + 125: 1, + 126: 1, + 127: 5, + 128: 12, + 129: 12, + 130: 1, + 131: 1, + 132: 1, + 133: 5, + 134: 12, + 135: 12, + 136: 1, + 137: 1, + 138: 1, + 139: 5, + 140: 12, + 141: 12, + 142: 3, + 143: 3, + 144: 3, + 145: 7, + 146: 12, + 147: 12, + 148: 10, + 149: 10, + 150: 10, + 151: 10, + 152: 14, + 153: 12, + 154: 10, + 155: 10, + 156: 10, + 157: 10, + 158: 10, + 159: 14, + 160: 9, + 161: 9, + 162: 9, + 163: 9, + 164: 13, + 165: 12, + 166: 9, + 167: 9, + 168: 9, + 169: 9, + 170: 13, + 171: 12, + 172: 9, + 173: 9, + 174: 9, + 175: 9, + 176: 13, + 177: 12, + 178: 9, + 179: 9, + 180: 9, + 181: 9, + 182: 13, + 183: 12, + 184: 11, + 185: 11, + 186: 11, + 187: 11, + 188: 7, + 189: 12, + 190: 10, + 191: 10, + 192: 10, + 193: 10, + 194: 10, + 195: 14, + 196: 9, + 197: 9, + 198: 9, + 199: 9, + 200: 9, + 201: 13, + 202: 9, + 203: 9, + 204: 9, + 205: 9, + 206: 9, + 207: 13, + 208: 9, + 209: 9, + 210: 9, + 211: 9, + 212: 9, + 213: 13, + 214: 9, + 215: 9, + 216: 9, + 217: 9, + 218: 9, + 219: 13, + 220: 9, + 221: 9, + 222: 9, + 223: 9, + 224: 9, + 225: 13, + 226: 11, + 227: 11, + 228: 11, + 229: 11, + 230: 11, + 231: 15, + 232: 0, + 233: 0, + 234: 0, + 235: 0, + 236: 0, + 237: 0, + 238: 8, + 239: 8, + 240: 8, + 241: 8, + 242: 8, + 243: 8, + 244: 7, + 245: 7, + 246: 7, + 247: 7, + 248: 7, + 249: 7, + 250: 15, + 251: 15, + 252: 15, + 253: 15, + 254: 15, + 255: 15, +} diff --git a/vendor/github.com/charmbracelet/x/ansi/cursor.go b/vendor/github.com/charmbracelet/x/ansi/cursor.go index 0c364d608a..2a74c483cb 100644 --- a/vendor/github.com/charmbracelet/x/ansi/cursor.go +++ b/vendor/github.com/charmbracelet/x/ansi/cursor.go @@ -1,6 +1,8 @@ package ansi -import "strconv" +import ( + "strconv" +) // SaveCursor (DECSC) is an escape sequence that saves the current cursor // position. @@ -260,7 +262,7 @@ func CHA(col int) string { // See: https://vt100.net/docs/vt510-rm/CUP.html func CursorPosition(col, row int) string { if row <= 0 && col <= 0 { - return HomeCursorPosition + return CursorHomePosition } var r, c string diff --git a/vendor/github.com/charmbracelet/x/ansi/finalterm.go b/vendor/github.com/charmbracelet/x/ansi/finalterm.go new file mode 100644 index 0000000000..2c28347284 --- /dev/null +++ b/vendor/github.com/charmbracelet/x/ansi/finalterm.go @@ -0,0 +1,67 @@ +package ansi + +import "strings" + +// FinalTerm returns an escape sequence that is used for shell integrations. +// Originally, FinalTerm designed the protocol hence the name. +// +// OSC 133 ; Ps ; Pm ST +// OSC 133 ; Ps ; Pm BEL +// +// See: https://iterm2.com/documentation-shell-integration.html +func FinalTerm(pm ...string) string { + return "\x1b]133;" + strings.Join(pm, ";") + "\x07" +} + +// FinalTermPrompt returns an escape sequence that is used for shell +// integrations prompt marks. This is sent just before the start of the shell +// prompt. +// +// This is an alias for FinalTerm("A"). +func FinalTermPrompt(pm ...string) string { + if len(pm) == 0 { + return FinalTerm("A") + } + return FinalTerm(append([]string{"A"}, pm...)...) +} + +// FinalTermCmdStart returns an escape sequence that is used for shell +// integrations command start marks. This is sent just after the end of the +// shell prompt, before the user enters a command. +// +// This is an alias for FinalTerm("B"). +func FinalTermCmdStart(pm ...string) string { + if len(pm) == 0 { + return FinalTerm("B") + } + return FinalTerm(append([]string{"B"}, pm...)...) +} + +// FinalTermCmdExecuted returns an escape sequence that is used for shell +// integrations command executed marks. This is sent just before the start of +// the command output. +// +// This is an alias for FinalTerm("C"). +func FinalTermCmdExecuted(pm ...string) string { + if len(pm) == 0 { + return FinalTerm("C") + } + return FinalTerm(append([]string{"C"}, pm...)...) +} + +// FinalTermCmdFinished returns an escape sequence that is used for shell +// integrations command finished marks. +// +// If the command was sent after +// [FinalTermCmdStart], it indicates that the command was aborted. If the +// command was sent after [FinalTermCmdExecuted], it indicates the end of the +// command output. If neither was sent, [FinalTermCmdFinished] should be +// ignored. +// +// This is an alias for FinalTerm("D"). +func FinalTermCmdFinished(pm ...string) string { + if len(pm) == 0 { + return FinalTerm("D") + } + return FinalTerm(append([]string{"D"}, pm...)...) +} diff --git a/vendor/github.com/charmbracelet/x/ansi/graphics.go b/vendor/github.com/charmbracelet/x/ansi/graphics.go index 604fef47cf..b5b1dc82f7 100644 --- a/vendor/github.com/charmbracelet/x/ansi/graphics.go +++ b/vendor/github.com/charmbracelet/x/ansi/graphics.go @@ -8,11 +8,49 @@ import ( "image" "io" "os" + "strconv" "strings" "github.com/charmbracelet/x/ansi/kitty" ) +// SixelGraphics returns a sequence that encodes the given sixel image payload to +// a DCS sixel sequence. +// +// DCS p1; p2; p3; q [sixel payload] ST +// +// p1 = pixel aspect ratio, deprecated and replaced by pixel metrics in the payload +// +// p2 = This is supposed to be 0 for transparency, but terminals don't seem to +// to use it properly. Value 0 leaves an unsightly black bar on all terminals +// I've tried and looks correct with value 1. +// +// p3 = Horizontal grid size parameter. Everyone ignores this and uses a fixed grid +// size, as far as I can tell. +// +// See https://shuford.invisible-island.net/all_about_sixels.txt +func SixelGraphics(p1, p2, p3 int, payload []byte) string { + var buf bytes.Buffer + + buf.WriteString("\x1bP") + if p1 >= 0 { + buf.WriteString(strconv.Itoa(p1)) + } + buf.WriteByte(';') + if p2 >= 0 { + buf.WriteString(strconv.Itoa(p2)) + } + if p3 > 0 { + buf.WriteByte(';') + buf.WriteString(strconv.Itoa(p3)) + } + buf.WriteByte('q') + buf.Write(payload) + buf.WriteString("\x1b\\") + + return buf.String() +} + // KittyGraphics returns a sequence that encodes the given image in the Kitty // graphics protocol. // @@ -43,7 +81,7 @@ var ( KittyGraphicsTempPattern = "tty-graphics-protocol-*" ) -// WriteKittyGraphics writes an image using the Kitty Graphics protocol with +// EncodeKittyGraphics writes an image using the Kitty Graphics protocol with // the given options to w. It chunks the written data if o.Chunk is true. // // You can omit m and use nil when rendering an image from a file. In this @@ -54,7 +92,7 @@ var ( // the terminal. // // See https://sw.kovidgoyal.net/kitty/graphics-protocol/ -func WriteKittyGraphics(w io.Writer, m image.Image, o *kitty.Options) error { +func EncodeKittyGraphics(w io.Writer, m image.Image, o *kitty.Options) error { if o == nil { o = &kitty.Options{} } diff --git a/vendor/github.com/charmbracelet/x/ansi/mode.go b/vendor/github.com/charmbracelet/x/ansi/mode.go index 57f3f0a8e3..b57b09cc73 100644 --- a/vendor/github.com/charmbracelet/x/ansi/mode.go +++ b/vendor/github.com/charmbracelet/x/ansi/mode.go @@ -243,6 +243,21 @@ const ( RequestInsertReplaceMode = "\x1b[4$p" ) +// BiDirectional Support Mode (BDSM) is a mode that determines whether the +// terminal supports bidirectional text. When enabled, the terminal supports +// bidirectional text and is set to implicit bidirectional mode. When disabled, +// the terminal does not support bidirectional text. +// +// See ECMA-48 7.2.1. +const ( + BiDirectionalSupportMode = ANSIMode(8) + BDSM = BiDirectionalSupportMode + + SetBiDirectionalSupportMode = "\x1b[8h" + ResetBiDirectionalSupportMode = "\x1b[8l" + RequestBiDirectionalSupportMode = "\x1b[8$p" +) + // Send Receive Mode (SRM) or Local Echo Mode is a mode that determines whether // the terminal echoes characters back to the host. When enabled, the terminal // sends characters to the host as they are typed. diff --git a/vendor/github.com/charmbracelet/x/ansi/modes.go b/vendor/github.com/charmbracelet/x/ansi/modes.go index 1bec5bc807..6856d35e48 100644 --- a/vendor/github.com/charmbracelet/x/ansi/modes.go +++ b/vendor/github.com/charmbracelet/x/ansi/modes.go @@ -4,12 +4,6 @@ package ansi // all modes are [ModeNotRecognized]. type Modes map[Mode]ModeSetting -// NewModes creates a new Modes map. By default, all modes are -// [ModeNotRecognized]. -func NewModes() Modes { - return make(Modes) -} - // Get returns the setting of a terminal mode. If the mode is not set, it // returns [ModeNotRecognized]. func (m Modes) Get(mode Mode) ModeSetting { diff --git a/vendor/github.com/charmbracelet/x/ansi/sgr.go b/vendor/github.com/charmbracelet/x/ansi/sgr.go index 1a18c98ef4..c4bd2afad3 100644 --- a/vendor/github.com/charmbracelet/x/ansi/sgr.go +++ b/vendor/github.com/charmbracelet/x/ansi/sgr.go @@ -1,7 +1,5 @@ package ansi -import "strconv" - // Select Graphic Rendition (SGR) is a command that sets display attributes. // // Default is 0. @@ -14,20 +12,7 @@ func SelectGraphicRendition(ps ...Attr) string { return ResetStyle } - var s Style - for _, p := range ps { - attr, ok := attrStrings[p] - if ok { - s = append(s, attr) - } else { - if p < 0 { - p = 0 - } - s = append(s, strconv.Itoa(p)) - } - } - - return s.String() + return NewStyle(ps...).String() } // SGR is an alias for [SelectGraphicRendition]. @@ -36,60 +21,59 @@ func SGR(ps ...Attr) string { } var attrStrings = map[int]string{ - ResetAttr: "0", - BoldAttr: "1", - FaintAttr: "2", - ItalicAttr: "3", - UnderlineAttr: "4", - SlowBlinkAttr: "5", - RapidBlinkAttr: "6", - ReverseAttr: "7", - ConcealAttr: "8", - StrikethroughAttr: "9", - NoBoldAttr: "21", - NormalIntensityAttr: "22", - NoItalicAttr: "23", - NoUnderlineAttr: "24", - NoBlinkAttr: "25", - NoReverseAttr: "27", - NoConcealAttr: "28", - NoStrikethroughAttr: "29", - BlackForegroundColorAttr: "30", - RedForegroundColorAttr: "31", - GreenForegroundColorAttr: "32", - YellowForegroundColorAttr: "33", - BlueForegroundColorAttr: "34", - MagentaForegroundColorAttr: "35", - CyanForegroundColorAttr: "36", - WhiteForegroundColorAttr: "37", - ExtendedForegroundColorAttr: "38", - DefaultForegroundColorAttr: "39", - BlackBackgroundColorAttr: "40", - RedBackgroundColorAttr: "41", - GreenBackgroundColorAttr: "42", - YellowBackgroundColorAttr: "43", - BlueBackgroundColorAttr: "44", - MagentaBackgroundColorAttr: "45", - CyanBackgroundColorAttr: "46", - WhiteBackgroundColorAttr: "47", - ExtendedBackgroundColorAttr: "48", - DefaultBackgroundColorAttr: "49", - ExtendedUnderlineColorAttr: "58", - DefaultUnderlineColorAttr: "59", - BrightBlackForegroundColorAttr: "90", - BrightRedForegroundColorAttr: "91", - BrightGreenForegroundColorAttr: "92", - BrightYellowForegroundColorAttr: "93", - BrightBlueForegroundColorAttr: "94", - BrightMagentaForegroundColorAttr: "95", - BrightCyanForegroundColorAttr: "96", - BrightWhiteForegroundColorAttr: "97", - BrightBlackBackgroundColorAttr: "100", - BrightRedBackgroundColorAttr: "101", - BrightGreenBackgroundColorAttr: "102", - BrightYellowBackgroundColorAttr: "103", - BrightBlueBackgroundColorAttr: "104", - BrightMagentaBackgroundColorAttr: "105", - BrightCyanBackgroundColorAttr: "106", - BrightWhiteBackgroundColorAttr: "107", + ResetAttr: resetAttr, + BoldAttr: boldAttr, + FaintAttr: faintAttr, + ItalicAttr: italicAttr, + UnderlineAttr: underlineAttr, + SlowBlinkAttr: slowBlinkAttr, + RapidBlinkAttr: rapidBlinkAttr, + ReverseAttr: reverseAttr, + ConcealAttr: concealAttr, + StrikethroughAttr: strikethroughAttr, + NormalIntensityAttr: normalIntensityAttr, + NoItalicAttr: noItalicAttr, + NoUnderlineAttr: noUnderlineAttr, + NoBlinkAttr: noBlinkAttr, + NoReverseAttr: noReverseAttr, + NoConcealAttr: noConcealAttr, + NoStrikethroughAttr: noStrikethroughAttr, + BlackForegroundColorAttr: blackForegroundColorAttr, + RedForegroundColorAttr: redForegroundColorAttr, + GreenForegroundColorAttr: greenForegroundColorAttr, + YellowForegroundColorAttr: yellowForegroundColorAttr, + BlueForegroundColorAttr: blueForegroundColorAttr, + MagentaForegroundColorAttr: magentaForegroundColorAttr, + CyanForegroundColorAttr: cyanForegroundColorAttr, + WhiteForegroundColorAttr: whiteForegroundColorAttr, + ExtendedForegroundColorAttr: extendedForegroundColorAttr, + DefaultForegroundColorAttr: defaultForegroundColorAttr, + BlackBackgroundColorAttr: blackBackgroundColorAttr, + RedBackgroundColorAttr: redBackgroundColorAttr, + GreenBackgroundColorAttr: greenBackgroundColorAttr, + YellowBackgroundColorAttr: yellowBackgroundColorAttr, + BlueBackgroundColorAttr: blueBackgroundColorAttr, + MagentaBackgroundColorAttr: magentaBackgroundColorAttr, + CyanBackgroundColorAttr: cyanBackgroundColorAttr, + WhiteBackgroundColorAttr: whiteBackgroundColorAttr, + ExtendedBackgroundColorAttr: extendedBackgroundColorAttr, + DefaultBackgroundColorAttr: defaultBackgroundColorAttr, + ExtendedUnderlineColorAttr: extendedUnderlineColorAttr, + DefaultUnderlineColorAttr: defaultUnderlineColorAttr, + BrightBlackForegroundColorAttr: brightBlackForegroundColorAttr, + BrightRedForegroundColorAttr: brightRedForegroundColorAttr, + BrightGreenForegroundColorAttr: brightGreenForegroundColorAttr, + BrightYellowForegroundColorAttr: brightYellowForegroundColorAttr, + BrightBlueForegroundColorAttr: brightBlueForegroundColorAttr, + BrightMagentaForegroundColorAttr: brightMagentaForegroundColorAttr, + BrightCyanForegroundColorAttr: brightCyanForegroundColorAttr, + BrightWhiteForegroundColorAttr: brightWhiteForegroundColorAttr, + BrightBlackBackgroundColorAttr: brightBlackBackgroundColorAttr, + BrightRedBackgroundColorAttr: brightRedBackgroundColorAttr, + BrightGreenBackgroundColorAttr: brightGreenBackgroundColorAttr, + BrightYellowBackgroundColorAttr: brightYellowBackgroundColorAttr, + BrightBlueBackgroundColorAttr: brightBlueBackgroundColorAttr, + BrightMagentaBackgroundColorAttr: brightMagentaBackgroundColorAttr, + BrightCyanBackgroundColorAttr: brightCyanBackgroundColorAttr, + BrightWhiteBackgroundColorAttr: brightWhiteBackgroundColorAttr, } diff --git a/vendor/github.com/charmbracelet/x/ansi/style.go b/vendor/github.com/charmbracelet/x/ansi/style.go index 46ddcaa99b..c8663f32b9 100644 --- a/vendor/github.com/charmbracelet/x/ansi/style.go +++ b/vendor/github.com/charmbracelet/x/ansi/style.go @@ -17,6 +17,26 @@ type Attr = int // Style represents an ANSI SGR (Select Graphic Rendition) style. type Style []string +// NewStyle returns a new style with the given attributes. +func NewStyle(attrs ...Attr) Style { + if len(attrs) == 0 { + return Style{} + } + s := make(Style, 0, len(attrs)) + for _, a := range attrs { + attr, ok := attrStrings[a] + if ok { + s = append(s, attr) + } else { + if a < 0 { + a = 0 + } + s = append(s, strconv.Itoa(a)) + } + } + return s +} + // String returns the ANSI SGR (Select Graphic Rendition) style sequence for // the given style. func (s Style) String() string { @@ -127,11 +147,6 @@ func (s Style) Strikethrough() Style { return append(s, strikethroughAttr) } -// NoBold appends the no bold style attribute to the style. -func (s Style) NoBold() Style { - return append(s, noBoldAttr) -} - // NormalIntensity appends the normal intensity style attribute to the style. func (s Style) NormalIntensity() Style { return append(s, normalIntensityAttr) @@ -236,7 +251,6 @@ const ( ReverseAttr Attr = 7 ConcealAttr Attr = 8 StrikethroughAttr Attr = 9 - NoBoldAttr Attr = 21 // Some terminals treat this as double underline. NormalIntensityAttr Attr = 22 NoItalicAttr Attr = 23 NoUnderlineAttr Attr = 24 @@ -298,7 +312,6 @@ const ( reverseAttr = "7" concealAttr = "8" strikethroughAttr = "9" - noBoldAttr = "21" normalIntensityAttr = "22" noItalicAttr = "23" noUnderlineAttr = "24" diff --git a/vendor/github.com/charmbracelet/x/ansi/title.go b/vendor/github.com/charmbracelet/x/ansi/title.go index 8fd8bf98da..54ef942355 100644 --- a/vendor/github.com/charmbracelet/x/ansi/title.go +++ b/vendor/github.com/charmbracelet/x/ansi/title.go @@ -30,3 +30,19 @@ func SetIconName(s string) string { func SetWindowTitle(s string) string { return "\x1b]2;" + s + "\x07" } + +// DECSWT is a sequence for setting the window title. +// +// This is an alias for [SetWindowTitle]("1;"). +// See: EK-VT520-RM 5–156 https://vt100.net/dec/ek-vt520-rm.pdf +func DECSWT(name string) string { + return SetWindowTitle("1;" + name) +} + +// DECSIN is a sequence for setting the icon name. +// +// This is an alias for [SetWindowTitle]("L;"). +// See: EK-VT520-RM 5–134 https://vt100.net/dec/ek-vt520-rm.pdf +func DECSIN(name string) string { + return SetWindowTitle("L;" + name) +} diff --git a/vendor/github.com/charmbracelet/x/ansi/truncate.go b/vendor/github.com/charmbracelet/x/ansi/truncate.go index 1fa3efefeb..3f541fa566 100644 --- a/vendor/github.com/charmbracelet/x/ansi/truncate.go +++ b/vendor/github.com/charmbracelet/x/ansi/truncate.go @@ -10,8 +10,7 @@ import ( // Cut the string, without adding any prefix or tail strings. This function is // aware of ANSI escape codes and will not break them, and accounts for -// wide-characters (such as East-Asian characters and emojis). Note that the -// [left] parameter is inclusive, while [right] isn't. +// wide-characters (such as East-Asian characters and emojis). // This treats the text as a sequence of graphemes. func Cut(s string, left, right int) string { return cut(GraphemeWidth, s, left, right) @@ -19,8 +18,10 @@ func Cut(s string, left, right int) string { // CutWc the string, without adding any prefix or tail strings. This function is // aware of ANSI escape codes and will not break them, and accounts for -// wide-characters (such as East-Asian characters and emojis). Note that the -// [left] parameter is inclusive, while [right] isn't. +// wide-characters (such as East-Asian characters and emojis). +// Note that the [left] parameter is inclusive, while [right] isn't, +// which is to say it'll return `[left, right)`. +// // This treats the text as a sequence of wide characters and runes. func CutWc(s string, left, right int) string { return cut(WcWidth, s, left, right) @@ -41,7 +42,7 @@ func cut(m Method, s string, left, right int) string { if left == 0 { return truncate(s, right, "") } - return truncateLeft(Truncate(s, right, ""), left, "") + return truncateLeft(truncate(s, right, ""), left, "") } // Truncate truncates a string to a given length, adding a tail to the end if @@ -99,6 +100,7 @@ func truncate(m Method, s string, length int, tail string) string { // increment the index by the length of the cluster i += len(cluster) + curWidth += width // Are we ignoring? Skip to the next byte if ignoring { @@ -107,16 +109,15 @@ func truncate(m Method, s string, length int, tail string) string { // Is this gonna be too wide? // If so write the tail and stop collecting. - if curWidth+width > length && !ignoring { + if curWidth > length && !ignoring { ignoring = true buf.WriteString(tail) } - if curWidth+width > length { + if curWidth > length { continue } - curWidth += width buf.Write(cluster) // Done collecting, now we're back in the ground state. @@ -142,6 +143,14 @@ func truncate(m Method, s string, length int, tail string) string { // collects printable ASCII curWidth++ fallthrough + case parser.ExecuteAction: + // execute action will be things like \n, which, if outside the cut, + // should be ignored. + if ignoring { + i++ + continue + } + fallthrough default: buf.WriteByte(b[i]) i++ @@ -214,14 +223,14 @@ func truncateLeft(m Method, s string, n int, prefix string) string { buf.WriteString(prefix) } - if ignoring { - continue - } - if curWidth > n { buf.Write(cluster) } + if ignoring { + continue + } + pstate = parser.GroundState continue } @@ -240,6 +249,14 @@ func truncateLeft(m Method, s string, n int, prefix string) string { continue } + fallthrough + case parser.ExecuteAction: + // execute action will be things like \n, which, if outside the cut, + // should be ignored. + if ignoring { + i++ + continue + } fallthrough default: buf.WriteByte(b[i]) diff --git a/vendor/github.com/charmbracelet/x/ansi/util.go b/vendor/github.com/charmbracelet/x/ansi/util.go index 301ef15ff8..0f5cea787a 100644 --- a/vendor/github.com/charmbracelet/x/ansi/util.go +++ b/vendor/github.com/charmbracelet/x/ansi/util.go @@ -10,7 +10,7 @@ import ( ) // colorToHexString returns a hex string representation of a color. -func colorToHexString(c color.Color) string { +func colorToHexString(c color.Color) string { //nolint:unused if c == nil { return "" } @@ -28,7 +28,7 @@ func colorToHexString(c color.Color) string { // rgbToHex converts red, green, and blue values to a hexadecimal value. // // hex := rgbToHex(0, 0, 255) // 0x0000FF -func rgbToHex(r, g, b uint32) uint32 { +func rgbToHex(r, g, b uint32) uint32 { //nolint:unused return r<<16 + g<<8 + b } diff --git a/vendor/github.com/cockroachdb/tokenbucket/token_bucket.go b/vendor/github.com/cockroachdb/tokenbucket/token_bucket.go index 6a8159fdd3..fa14daf450 100644 --- a/vendor/github.com/cockroachdb/tokenbucket/token_bucket.go +++ b/vendor/github.com/cockroachdb/tokenbucket/token_bucket.go @@ -176,6 +176,27 @@ func (tb *TokenBucket) Exhausted() time.Duration { return time.Duration(tb.exhaustedMicros+ongoingExhaustionMicros) * time.Microsecond } +// EnsureLowerBound ensures that the current number of tokens is at least +// minTokens. The value of minTokens can be negative. This is useful in +// scenarios where the use of Adjust can be used to subtract a large amount of +// tokens, resulting in a token bucket with a very low negative number of +// tokens which would take a long time to recover to zero. In such scenarios, +// a periodic call to EnsureLowerBound is useful to reset to a better state. +func (tb *TokenBucket) EnsureLowerBound(minTokens Tokens) { + tb.Update() + if tb.current >= minTokens { + return + } + // tb.current < minTokens. + tb.current = minTokens + if tb.current > tb.burst { + tb.current = tb.burst + } + if tb.current > 0 { + tb.updateExhaustedMicros() + } +} + // Available returns the currently available tokens (can be -ve). Exported only // for metrics. func (tb *TokenBucket) Available() Tokens { diff --git a/vendor/modernc.org/libc/Makefile b/vendor/modernc.org/libc/Makefile index a2ff9dacbe..59936c0d42 100644 --- a/vendor/modernc.org/libc/Makefile +++ b/vendor/modernc.org/libc/Makefile @@ -32,13 +32,12 @@ download: @if [ ! -f $(TAR) ]; then wget $(URL) ; fi edit: - @if [ -f "Session.vim" ]; then novim -S & else novim -p Makefile go.mod builder.json & fi + @if [ -f "Session.vim" ]; then gvim -S & else gvim -p Makefile go.mod builder.json & fi editor: gofmt -l -s -w *.go go test -c -o /dev/null - go install -v - go build -o /dev/null generator*.go + go build -o /dev/null -v generator*.go generate: download mkdir -p $(DIR) || true diff --git a/vendor/modernc.org/libc/libc_darwin.go b/vendor/modernc.org/libc/libc_darwin.go index c33cc6ba2a..86bcacc40d 100644 --- a/vendor/modernc.org/libc/libc_darwin.go +++ b/vendor/modernc.org/libc/libc_darwin.go @@ -7,8 +7,11 @@ package libc // import "modernc.org/libc" import ( crand "crypto/rand" "encoding/hex" + "errors" "fmt" "io" + "io/fs" + mbits "math/bits" "os" "os/exec" gosignal "os/signal" @@ -39,6 +42,7 @@ import ( "modernc.org/libc/unistd" "modernc.org/libc/uuid/uuid" "modernc.org/libc/wctype" + "modernc.org/memory" ) const ( @@ -55,10 +59,6 @@ type ( ulong = types.User_ulong_t ) -type pthreadAttr struct { - detachState int32 -} - // // Keep these outside of the var block otherwise go generate will miss them. var X__stderrp = Xstdout var X__stdinp = Xstdin @@ -94,6 +94,18 @@ func (f file) setErr() { (*stdio.FILE)(unsafe.Pointer(f)).F_flags |= 1 } +func (f file) clearErr() { + (*stdio.FILE)(unsafe.Pointer(f)).F_flags &^= 3 +} + +func (f file) eof() bool { + return (*stdio.FILE)(unsafe.Pointer(f)).F_flags&2 != 0 +} + +func (f file) setEOF() { + (*stdio.FILE)(unsafe.Pointer(f)).F_flags |= 2 +} + func (f file) close(t *TLS) int32 { r := Xclose(t, f.fd()) Xfree(t, uintptr(f)) @@ -125,6 +137,19 @@ func fwrite(fd int32, b []byte) (int, error) { return unix.Write(int(fd), b) } +func Xclearerr(tls *TLS, f uintptr) { + file(f).clearErr() +} + +func Xfeof(t *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("t=%v f=%v, (%v:)", t, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + r = BoolInt32(file(f).eof()) + return r +} + func X__inline_isnand(t *TLS, x float64) int32 { if __ccgo_strace { trc("t=%v x=%v, (%v:)", t, x, origin(2)) @@ -1539,6 +1564,9 @@ func Xfread(t *TLS, ptr uintptr, size, nmemb types.Size_t, stream uintptr) types n, err = unix.Read(int(fd), nil) default: n, err = unix.Read(int(fd), (*RawMem)(unsafe.Pointer(ptr))[:count:count]) + if n == 0 { + file(stream).setEOF() + } if dmesgs && err == nil { dmesg("%v: fd %v, n %#x\n%s", origin(1), fd, n, hex.Dump((*RawMem)(unsafe.Pointer(ptr))[:n:n])) } @@ -1670,12 +1698,11 @@ func Xfputs(t *TLS, s, stream uintptr) int32 { if __ccgo_strace { trc("t=%v stream=%v, (%v:)", t, stream, origin(2)) } - panic(todo("")) - // if _, _, err := unix.Syscall(unix.SYS_WRITE, uintptr(file(stream).fd()), s, uintptr(Xstrlen(t, s))); err != 0 { - // return -1 - // } + if _, _, err := unix.Syscall(unix.SYS_WRITE, uintptr(file(stream).fd()), s, uintptr(Xstrlen(t, s))); err != 0 { + return -1 + } - // return 0 + return 0 } var getservbynameStaticResult netdb.Servent @@ -2174,11 +2201,13 @@ func Xpthread_attr_getdetachstate(tls *TLS, a uintptr, state uintptr) int32 { panic(todo("")) } -func Xpthread_attr_setdetachstate(tls *TLS, a uintptr, state int32) int32 { - if __ccgo_strace { - trc("tls=%v a=%v state=%v, (%v:)", tls, a, state, origin(2)) +func Xpthread_attr_setdetachstate(tls *TLS, a uintptr, state int32) (r int32) { + if uint32(state) > 1 { + return errno.EINVAL } - panic(todo("")) + + (*pthreadAttr)(unsafe.Pointer(a)).detachState = state + return 0 } func Xpthread_mutexattr_destroy(tls *TLS, a uintptr) int32 { @@ -2447,11 +2476,20 @@ func Xnanosleep(t *TLS, req, rem uintptr) int32 { // } // size_t malloc_size(const void *ptr); -func Xmalloc_size(t *TLS, ptr uintptr) types.Size_t { +func Xmalloc_size(t *TLS, p uintptr) (r types.Size_t) { if __ccgo_strace { - trc("t=%v ptr=%v, (%v:)", t, ptr, origin(2)) + trc("t=%v p=%v, (%v:)", t, p, origin(2)) + defer func() { trc("-> %v", r) }() } - panic(todo("")) + if p == 0 { + return 0 + } + + allocMu.Lock() + + defer allocMu.Unlock() + + return types.Size_t(memory.UintptrUsableSize(p)) } // int open(const char *pathname, int flags, ...); @@ -2518,3 +2556,226 @@ func X__builtin_lround(tls *TLS, x float64) (r long) { func Xlround(tls *TLS, x float64) (r long) { return long(Xround(tls, x)) } + +// https://g.co/gemini/share/2c37d5b57994 + +// Constants mirroring C's ftw type flags +const ( + FTW_F = 0 // Regular file + FTW_D = 1 // Directory (visited pre-order) + FTW_DNR = 2 // Directory that cannot be read + FTW_NS = 4 // Stat failed (permissions, broken link, etc.) + FTW_SL = 4 // Symbolic link (lstat was used) + // Note: C's ftw might have other flags like FTW_DP (post-order dir) or FTW_SLN + // which are not directly supported by filepath.WalkDir's simple pre-order traversal. + // This emulation focuses on the most common flags associated with stat/lstat results. +) + +// ftwStopError is used internally to signal that the walk should stop +// because the user callback returned a non-zero value. +type ftwStopError struct { + stopValue int +} + +func (e *ftwStopError) Error() string { + return fmt.Sprintf("ftw walk stopped by callback with return value %d", e.stopValue) +} + +// goFtwFunc is the callback function type, mirroring the C ftw callback. +// It receives the path, file info (if available), and a type flag. +// Returning a non-zero value stops the walk and becomes the return value of Ftw. +// Returning 0 continues the walk. +type goFtwFunc func(path string, info os.FileInfo, typeflag int) int + +// Ftw emulates the C standard library function ftw(3). +// It walks the directory tree starting at 'dirpath' and calls the 'callback' +// function for each entry encountered. +// +// Parameters: +// - dirpath: The root directory path for the traversal. +// - callback: The goFtwFunc to call for each file system entry. +// - nopenfd: This parameter is part of the C ftw signature but is IGNORED +// in this Go implementation. Go's filepath.WalkDir manages concurrency +// and file descriptors internally. +// +// Returns: +// - 0 on successful completion of the walk. +// - The non-zero value returned by the callback, if the callback terminated the walk. +// - -1 if an error occurred during the walk that wasn't handled by calling +// the callback with FTW_DNR or FTW_NS (e.g., error accessing the initial dirpath). +func ftw(dirpath string, callback goFtwFunc, nopenfd int) int { + // nopenfd is ignored in this Go implementation. + + walkErr := filepath.WalkDir(dirpath, func(path string, d fs.DirEntry, err error) error { + var info os.FileInfo + var typeflag int + + // --- Handle errors passed by WalkDir --- + if err != nil { + // Check if the error is related to accessing a directory + if errors.Is(err, fs.ErrPermission) || errors.Is(err, unix.EACCES) { // Added syscall.EACCES check + // Try to determine if it's a directory we can't read + // We might not have 'd' if the error occurred trying to list 'path' contents + // Let's try a direct Lstat on the path itself if d is nil + lstatInfo, lstatErr := os.Lstat(path) + if lstatErr == nil && lstatInfo.IsDir() { + typeflag = FTW_DNR // Directory, but WalkDir errored (likely reading it) + info = lstatInfo // Provide the info we could get + } else { + // Can't confirm it's a directory, or Lstat itself failed + typeflag = FTW_NS // Treat as general stat failure + // info remains nil + } + } else { + // Other errors (e.g., broken symlink during traversal, I/O error) + typeflag = FTW_NS + // Attempt to get Lstat info even if WalkDir had an error, maybe it's available + lstatInfo, _ := os.Lstat(path) // Ignore error here, if it fails info stays nil + info = lstatInfo + } + // Even with errors, call the callback with the path and appropriate flag + stopVal := callback(path, info, typeflag) + if stopVal != 0 { + return &ftwStopError{stopValue: stopVal} + } + // If the error was on a directory, returning the error might stop WalkDir + // from descending. If it was fs.ErrPermission on a dir, WalkDir might + // pass filepath.SkipDir implicitly or continue depending on implementation. + // Let's return nil here to *try* to continue the walk for other siblings + // if the callback didn't stop it. The callback *was* notified. + // If the error prevents further progress WalkDir will stop anyway. + return nil // Allow walk to potentially continue elsewhere + } + + // --- No error from WalkDir, process the DirEntry --- + info, err = d.Info() // Get FileInfo (like C's stat/lstat result) + if err != nil { + // Error getting info for an entry WalkDir *could* list (rare, maybe permissions changed?) + typeflag = FTW_NS + // info remains nil + } else { + // Determine type flag based on file mode + mode := info.Mode() + if mode&fs.ModeSymlink != 0 { + typeflag = FTW_SL + } else if mode.IsDir() { + typeflag = FTW_D // Visited pre-order + } else if mode.IsRegular() { + typeflag = FTW_F + } else { + // Other types (device, socket, pipe, etc.) - C ftw usually lumps these under FTW_F + // or might have FTW_NS if stat fails. Let's treat non-dir, non-link, non-regular + // as FTW_F for simplicity, aligning with common C practice, or FTW_NS if stat failed above. + // Since we have info here, we know stat didn't fail. + // Let's be more specific, maybe treat others as FTW_NS? Or stick to FTW_F? + // C ftw man page isn't super specific about all types. FTW_F seems reasonable. + typeflag = FTW_F // Treat other valid types as 'files' for simplicity + } + } + + // --- Call the user callback --- + stopVal := callback(path, info, typeflag) + if stopVal != 0 { + // User wants to stop the walk + return &ftwStopError{stopValue: stopVal} + } + + return nil // Continue walk + }) + + // --- Handle WalkDir's final return value --- + if walkErr == nil { + return 0 // Success + } + + // Check if the error was our custom stop signal + var stopErr *ftwStopError + if errors.As(walkErr, &stopErr) { + return stopErr.stopValue // Return the value from the callback + } + + // Otherwise, it was an unhandled error during the walk + // (e.g., initial dirpath access error, or other error not mapped to FTW_NS/DNR) + return -1 // General error return +} + +func Xftw(tls *TLS, path uintptr, fn uintptr, fd_limit int32) (r int32) { + statp := tls.Alloc(int(unsafe.Sizeof(unix.Stat_t{}))) + + defer tls.Free(int(unsafe.Sizeof(unix.Stat_t{}))) + + return int32(ftw( + GoString(path), + func(path string, info os.FileInfo, typeflag int) int { + cs, _ := CString(path) + + defer Xfree(tls, cs) + + Xstat(tls, cs, statp) + return int((*(*func(*TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{fn})))(tls, cs, statp, int32(typeflag))) + }, + int(fd_limit), + )) +} + +func Xexecve(tls *TLS, path uintptr, argv uintptr, envp uintptr) (r int32) { + goPath := GoString(path) + var goArgv, goEnvp []string + for p := *(*uintptr)(unsafe.Pointer(argv)); p != 0; p = *(*uintptr)(unsafe.Pointer(argv)) { + goArgv = append(goArgv, GoString(p)) + argv += unsafe.Sizeof(uintptr(0)) + } + for p := *(*uintptr)(unsafe.Pointer(envp)); p != 0; p = *(*uintptr)(unsafe.Pointer(envp)) { + goEnvp = append(goEnvp, GoString(p)) + envp += unsafe.Sizeof(uintptr(0)) + } + if err := unix.Exec(goPath, goArgv, goEnvp); err != nil { + tls.setErrno(err) + return -1 + } + panic("unreachable") +} + +func Xsetuid(tls *TLS, uid uint32) (r int32) { + if __ccgo_strace { + trc("tls=%v uid=%v, (%v:)", tls, uid, origin(2)) + defer func() { trc("-> %v", r) }() + } + if err := unix.Setuid(int(uid)); err != nil { + tls.setErrno(err) + return -1 + } + + return 0 +} + +func Xsetgid(tls *TLS, gid uint32) (r int32) { + if __ccgo_strace { + trc("tls=%v gid=%v, (%v:)", tls, gid, origin(2)) + defer func() { trc("-> %v", r) }() + } + if err := unix.Setgid(int(gid)); err != nil { + tls.setErrno(err) + return -1 + } + + return 0 +} + +func Xdup(tls *TLS, fd int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + nfd, err := unix.Dup(int(fd)) + if err != nil { + tls.setErrno(err) + return -1 + } + + return int32(nfd) +} + +func X__builtin_ctz(t *TLS, n uint32) int32 { + return int32(mbits.TrailingZeros32(n)) +} diff --git a/vendor/modernc.org/libc/libc_darwin_amd64.go b/vendor/modernc.org/libc/libc_darwin_amd64.go index 0513b1e49d..dd94ebab3a 100644 --- a/vendor/modernc.org/libc/libc_darwin_amd64.go +++ b/vendor/modernc.org/libc/libc_darwin_amd64.go @@ -17,6 +17,11 @@ import ( "modernc.org/libc/utime" ) +// #define FE_DOWNWARD 0x0400 +// #define FE_UPWARD 0x0800 +const FE_DOWNWARD = 0x0400 +const FE_UPWARD = 0x0800 + // int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact); func Xsigaction(t *TLS, signum int32, act, oldact uintptr) int32 { if __ccgo_strace { diff --git a/vendor/modernc.org/libc/libc_darwin_arm64.go b/vendor/modernc.org/libc/libc_darwin_arm64.go index ecb7c911de..9e85e8911d 100644 --- a/vendor/modernc.org/libc/libc_darwin_arm64.go +++ b/vendor/modernc.org/libc/libc_darwin_arm64.go @@ -17,6 +17,11 @@ import ( "modernc.org/libc/utime" ) +// #define FE_UPWARD 0x00400000 +// #define FE_DOWNWARD 0x00800000 +const FE_UPWARD = 0x00400000 +const FE_DOWNWARD = 0x00800000 + // int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact); func Xsigaction(t *TLS, signum int32, act, oldact uintptr) int32 { if __ccgo_strace { diff --git a/vendor/modernc.org/libc/musl_darwin_amd64.go b/vendor/modernc.org/libc/musl_darwin_amd64.go index e0333fa3a9..29081e4502 100644 --- a/vendor/modernc.org/libc/musl_darwin_amd64.go +++ b/vendor/modernc.org/libc/musl_darwin_amd64.go @@ -357,7 +357,11 @@ type size_t = uint64 /* :9:23 */ type wchar_t = int32 /* :15:24 */ -var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ +// /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types/_fd_def.h:54 +// int __darwin_check_fd_set_overflow(int, const void *, int) __API_AVAILABLE(macosx(11.0), ios(14.0), tvos(14.0), watchos(7.0)); +func X__darwin_check_fd_set_overflow(tls *TLS, _ int32, _ uintptr, _ int32) int32 { + return 1 +} // pthread opaque structures diff --git a/vendor/modernc.org/libc/pthread_all.go b/vendor/modernc.org/libc/pthread_all.go index b5f0dfdcc7..be50411ec9 100644 --- a/vendor/modernc.org/libc/pthread_all.go +++ b/vendor/modernc.org/libc/pthread_all.go @@ -12,12 +12,16 @@ import ( "modernc.org/libc/pthread" ) +type pthreadAttr struct { + detachState int32 +} + // int pthread_attr_init(pthread_attr_t *attr); func Xpthread_attr_init(t *TLS, pAttr uintptr) int32 { if __ccgo_strace { trc("t=%v pAttr=%v, (%v:)", t, pAttr, origin(2)) } - *(*pthread.Pthread_attr_t)(unsafe.Pointer(pAttr)) = pthread.Pthread_attr_t{} + *(*pthreadAttr)(unsafe.Pointer(pAttr)) = pthreadAttr{} return 0 } diff --git a/vendor/modernc.org/libc/stdatomic.go b/vendor/modernc.org/libc/stdatomic.go index 7df65312ae..ecc323f7a1 100644 --- a/vendor/modernc.org/libc/stdatomic.go +++ b/vendor/modernc.org/libc/stdatomic.go @@ -6,6 +6,7 @@ package libc // import "modernc.org/libc" import ( "sync" + "sync/atomic" "unsafe" ) @@ -21,6 +22,10 @@ var ( // { tmp = *ptr; *ptr op= val; return tmp; } // { tmp = *ptr; *ptr = ~(*ptr & val); return tmp; } // nand +func X__c11_atomic_fetch_addInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) { + return X__atomic_fetch_addInt8(t, ptr, val, 0) +} + func X__atomic_fetch_addInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) { int8Mu.Lock() @@ -31,6 +36,10 @@ func X__atomic_fetch_addInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) { return r } +func X__c11_atomic_fetch_addUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) { + return X__atomic_fetch_addUint8(t, ptr, val, 0) +} + func X__atomic_fetch_addUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) { int8Mu.Lock() @@ -41,6 +50,10 @@ func X__atomic_fetch_addUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) return r } +func X__c11_atomic_fetch_addInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) { + return X__atomic_fetch_addInt16(t, ptr, val, 0) +} + func X__atomic_fetch_addInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) { int16Mu.Lock() @@ -51,6 +64,10 @@ func X__atomic_fetch_addInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) return r } +func X__c11_atomic_fetch_addUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) { + return X__atomic_fetch_addUint16(t, ptr, val, 0) +} + func X__atomic_fetch_addUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) { int16Mu.Lock() @@ -61,6 +78,10 @@ func X__atomic_fetch_addUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint return r } +func X__c11_atomic_fetch_addInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) { + return X__atomic_fetch_addInt32(t, ptr, val, 0) +} + func X__atomic_fetch_addInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) { int32Mu.Lock() @@ -71,6 +92,10 @@ func X__atomic_fetch_addInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) return r } +func X__c11_atomic_fetch_addUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) { + return X__atomic_fetch_addUint32(t, ptr, val, 0) +} + func X__atomic_fetch_addUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) { int32Mu.Lock() @@ -81,6 +106,10 @@ func X__atomic_fetch_addUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint return r } +func X__c11_atomic_fetch_addInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) { + return X__atomic_fetch_addInt64(t, ptr, val, 0) +} + func X__atomic_fetch_addInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) { int64Mu.Lock() @@ -91,6 +120,10 @@ func X__atomic_fetch_addInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) return r } +func X__c11_atomic_fetch_addUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) { + return X__atomic_fetch_addUint64(t, ptr, val, 0) +} + func X__atomic_fetch_addUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) { int64Mu.Lock() @@ -103,6 +136,10 @@ func X__atomic_fetch_addUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint // ---- +func X__c11_atomic_fetch_andInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) { + return X__atomic_fetch_andInt8(t, ptr, val, 0) +} + func X__atomic_fetch_andInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) { int8Mu.Lock() @@ -113,6 +150,10 @@ func X__atomic_fetch_andInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) { return r } +func X__c11_atomic_fetch_andUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) { + return X__atomic_fetch_andUint8(t, ptr, val, 0) +} + func X__atomic_fetch_andUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) { int8Mu.Lock() @@ -123,6 +164,10 @@ func X__atomic_fetch_andUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) return r } +func X__c11_atomic_fetch_andInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) { + return X__atomic_fetch_andInt16(t, ptr, val, 0) +} + func X__atomic_fetch_andInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) { int16Mu.Lock() @@ -133,6 +178,10 @@ func X__atomic_fetch_andInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) return r } +func X__c11_atomic_fetch_andUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) { + return X__atomic_fetch_andUint16(t, ptr, val, 0) +} + func X__atomic_fetch_andUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) { int16Mu.Lock() @@ -143,6 +192,10 @@ func X__atomic_fetch_andUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint return r } +func X__c11_atomic_fetch_andInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) { + return X__atomic_fetch_andInt32(t, ptr, val, 0) +} + func X__atomic_fetch_andInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) { int32Mu.Lock() @@ -153,6 +206,10 @@ func X__atomic_fetch_andInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) return r } +func X__c11_atomic_fetch_andUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) { + return X__atomic_fetch_andUint32(t, ptr, val, 0) +} + func X__atomic_fetch_andUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) { int32Mu.Lock() @@ -163,6 +220,10 @@ func X__atomic_fetch_andUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint return r } +func X__c11_atomic_fetch_andInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) { + return X__atomic_fetch_andInt64(t, ptr, val, 0) +} + func X__atomic_fetch_andInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) { int64Mu.Lock() @@ -173,6 +234,10 @@ func X__atomic_fetch_andInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) return r } +func X__c11_atomic_fetch_andUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) { + return X__atomic_fetch_andUint64(t, ptr, val, 0) +} + func X__atomic_fetch_andUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) { int64Mu.Lock() @@ -185,6 +250,10 @@ func X__atomic_fetch_andUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint // ---- +func X__c11_atomic_fetch_orInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) { + return X__atomic_fetch_orInt8(t, ptr, val, 0) +} + func X__atomic_fetch_orInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) { int8Mu.Lock() @@ -195,6 +264,10 @@ func X__atomic_fetch_orInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) { return r } +func X__c11_atomic_fetch_orUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) { + return X__atomic_fetch_orUint8(t, ptr, val, 0) +} + func X__atomic_fetch_orUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) { int8Mu.Lock() @@ -205,6 +278,10 @@ func X__atomic_fetch_orUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) return r } +func X__c11_atomic_fetch_orInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) { + return X__atomic_fetch_orInt16(t, ptr, val, 0) +} + func X__atomic_fetch_orInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) { int16Mu.Lock() @@ -215,6 +292,10 @@ func X__atomic_fetch_orInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) return r } +func X__c11_atomic_fetch_orUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) { + return X__atomic_fetch_orUint16(t, ptr, val, 0) +} + func X__atomic_fetch_orUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) { int16Mu.Lock() @@ -225,6 +306,10 @@ func X__atomic_fetch_orUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint1 return r } +func X__c11_atomic_fetch_orInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) { + return X__atomic_fetch_orInt32(t, ptr, val, 0) +} + func X__atomic_fetch_orInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) { int32Mu.Lock() @@ -235,6 +320,10 @@ func X__atomic_fetch_orInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) return r } +func X__c11_atomic_fetch_orUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) { + return X__atomic_fetch_orUint32(t, ptr, val, 0) +} + func X__atomic_fetch_orUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) { int32Mu.Lock() @@ -245,6 +334,10 @@ func X__atomic_fetch_orUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint3 return r } +func X__c11_atomic_fetch_orInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) { + return X__atomic_fetch_orInt64(t, ptr, val, 0) +} + func X__atomic_fetch_orInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) { int64Mu.Lock() @@ -255,6 +348,10 @@ func X__atomic_fetch_orInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) return r } +func X__c11_atomic_fetch_orUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) { + return X__atomic_fetch_orUint64(t, ptr, val, 0) +} + func X__atomic_fetch_orUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) { int64Mu.Lock() @@ -267,6 +364,10 @@ func X__atomic_fetch_orUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint6 // ---- +func X__c11_atomic_fetch_subInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) { + return X__atomic_fetch_subInt8(t, ptr, val, 0) +} + func X__atomic_fetch_subInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) { int8Mu.Lock() @@ -277,6 +378,10 @@ func X__atomic_fetch_subInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) { return r } +func X__c11_atomic_fetch_subUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) { + return X__atomic_fetch_subUint8(t, ptr, val, 0) +} + func X__atomic_fetch_subUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) { int8Mu.Lock() @@ -287,6 +392,10 @@ func X__atomic_fetch_subUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) return r } +func X__c11_atomic_fetch_subInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) { + return X__atomic_fetch_subInt16(t, ptr, val, 0) +} + func X__atomic_fetch_subInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) { int16Mu.Lock() @@ -297,6 +406,10 @@ func X__atomic_fetch_subInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) return r } +func X__c11_atomic_fetch_subUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) { + return X__atomic_fetch_subUint16(t, ptr, val, 0) +} + func X__atomic_fetch_subUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) { int16Mu.Lock() @@ -307,6 +420,10 @@ func X__atomic_fetch_subUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint return r } +func X__c11_atomic_fetch_subInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) { + return X__atomic_fetch_subInt32(t, ptr, val, 0) +} + func X__atomic_fetch_subInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) { int32Mu.Lock() @@ -317,6 +434,10 @@ func X__atomic_fetch_subInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) return r } +func X__c11_atomic_fetch_subUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) { + return X__atomic_fetch_subUint32(t, ptr, val, 0) +} + func X__atomic_fetch_subUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) { int32Mu.Lock() @@ -327,6 +448,10 @@ func X__atomic_fetch_subUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint return r } +func X__c11_atomic_fetch_subInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) { + return X__atomic_fetch_subInt64(t, ptr, val, 0) +} + func X__atomic_fetch_subInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) { int64Mu.Lock() @@ -337,6 +462,10 @@ func X__atomic_fetch_subInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) return r } +func X__c11_atomic_fetch_subUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) { + return X__atomic_fetch_subUint64(t, ptr, val, 0) +} + func X__atomic_fetch_subUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) { int64Mu.Lock() @@ -349,6 +478,10 @@ func X__atomic_fetch_subUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint // ---- +func X__c11_atomic_fetch_xorInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) { + return X__atomic_fetch_xorInt8(t, ptr, val, 0) +} + func X__atomic_fetch_xorInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) { int8Mu.Lock() @@ -359,6 +492,10 @@ func X__atomic_fetch_xorInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) { return r } +func X__c11_atomic_fetch_xorUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) { + return X__atomic_fetch_xorUint8(t, ptr, val, 0) +} + func X__atomic_fetch_xorUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) { int8Mu.Lock() @@ -369,6 +506,10 @@ func X__atomic_fetch_xorUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) return r } +func X__c11_atomic_fetch_xorInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) { + return X__atomic_fetch_xorInt16(t, ptr, val, 0) +} + func X__atomic_fetch_xorInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) { int16Mu.Lock() @@ -379,6 +520,10 @@ func X__atomic_fetch_xorInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) return r } +func X__c11_atomic_fetch_xorUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) { + return X__atomic_fetch_xorUint16(t, ptr, val, 0) +} + func X__atomic_fetch_xorUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) { int16Mu.Lock() @@ -389,6 +534,10 @@ func X__atomic_fetch_xorUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint return r } +func X__c11_atomic_fetch_xorInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) { + return X__atomic_fetch_xorInt32(t, ptr, val, 0) +} + func X__atomic_fetch_xorInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) { int32Mu.Lock() @@ -399,6 +548,10 @@ func X__atomic_fetch_xorInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) return r } +func X__c11_atomic_fetch_xorUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) { + return X__atomic_fetch_xorUint32(t, ptr, val, 0) +} + func X__atomic_fetch_xorUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) { int32Mu.Lock() @@ -409,6 +562,10 @@ func X__atomic_fetch_xorUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint return r } +func X__c11_atomic_fetch_xorInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) { + return X__atomic_fetch_xorInt64(t, ptr, val, 0) +} + func X__atomic_fetch_xorInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) { int64Mu.Lock() @@ -419,6 +576,10 @@ func X__atomic_fetch_xorInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) return r } +func X__c11_atomic_fetch_xorUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) { + return X__atomic_fetch_xorUint64(t, ptr, val, 0) +} + func X__atomic_fetch_xorUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) { int64Mu.Lock() @@ -433,6 +594,16 @@ func X__atomic_fetch_xorUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint // void __atomic_exchange (type *ptr, type *val, type *ret, int memorder) +func X__c11_atomic_exchangeInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) { + int8Mu.Lock() + + defer int8Mu.Unlock() + + r = *(*int8)(unsafe.Pointer(ptr)) + *(*int8)(unsafe.Pointer(ptr)) = val + return r +} + func X__atomic_exchangeInt8(t *TLS, ptr, val, ret uintptr, _ int32) { int8Mu.Lock() @@ -442,6 +613,16 @@ func X__atomic_exchangeInt8(t *TLS, ptr, val, ret uintptr, _ int32) { *(*int8)(unsafe.Pointer(ptr)) = *(*int8)(unsafe.Pointer(val)) } +func X__c11_atomic_exchangeUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) { + int8Mu.Lock() + + defer int8Mu.Unlock() + + r = *(*uint8)(unsafe.Pointer(ptr)) + *(*uint8)(unsafe.Pointer(ptr)) = val + return r +} + func X__atomic_exchangeUint8(t *TLS, ptr, val, ret uintptr, _ int32) { int8Mu.Lock() @@ -451,6 +632,16 @@ func X__atomic_exchangeUint8(t *TLS, ptr, val, ret uintptr, _ int32) { *(*uint8)(unsafe.Pointer(ptr)) = *(*uint8)(unsafe.Pointer(val)) } +func X__c11_atomic_exchangeInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) { + int16Mu.Lock() + + defer int16Mu.Unlock() + + r = *(*int16)(unsafe.Pointer(ptr)) + *(*int16)(unsafe.Pointer(ptr)) = val + return r +} + func X__atomic_exchangeInt16(t *TLS, ptr, val, ret uintptr, _ int32) { int16Mu.Lock() @@ -460,6 +651,16 @@ func X__atomic_exchangeInt16(t *TLS, ptr, val, ret uintptr, _ int32) { *(*int16)(unsafe.Pointer(ptr)) = *(*int16)(unsafe.Pointer(val)) } +func X__c11_atomic_exchangeUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) { + int16Mu.Lock() + + defer int16Mu.Unlock() + + r = *(*uint16)(unsafe.Pointer(ptr)) + *(*uint16)(unsafe.Pointer(ptr)) = val + return r +} + func X__atomic_exchangeUint16(t *TLS, ptr, val, ret uintptr, _ int32) { int16Mu.Lock() @@ -469,40 +670,36 @@ func X__atomic_exchangeUint16(t *TLS, ptr, val, ret uintptr, _ int32) { *(*uint16)(unsafe.Pointer(ptr)) = *(*uint16)(unsafe.Pointer(val)) } -func X__atomic_exchangeInt32(t *TLS, ptr, val, ret uintptr, _ int32) { - int32Mu.Lock() +func X__c11_atomic_exchangeInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) { + return atomic.SwapInt32((*int32)(unsafe.Pointer(ptr)), val) +} - defer int32Mu.Unlock() +func X__atomic_exchangeInt32(t *TLS, ptr, val, ret uintptr, _ int32) { + *(*int32)(unsafe.Pointer(ret)) = atomic.SwapInt32((*int32)(unsafe.Pointer(ptr)), *(*int32)(unsafe.Pointer(val))) +} - *(*int32)(unsafe.Pointer(ret)) = *(*int32)(unsafe.Pointer(ptr)) - *(*int32)(unsafe.Pointer(ptr)) = *(*int32)(unsafe.Pointer(val)) +func X__c11_atomic_exchangeUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) { + return uint32(atomic.SwapInt32((*int32)(unsafe.Pointer(ptr)), int32(val))) } func X__atomic_exchangeUint32(t *TLS, ptr, val, ret uintptr, _ int32) { - int32Mu.Lock() - - defer int32Mu.Unlock() + *(*uint32)(unsafe.Pointer(ret)) = atomic.SwapUint32((*uint32)(unsafe.Pointer(ptr)), *(*uint32)(unsafe.Pointer(val))) +} - *(*uint32)(unsafe.Pointer(ret)) = *(*uint32)(unsafe.Pointer(ptr)) - *(*uint32)(unsafe.Pointer(ptr)) = *(*uint32)(unsafe.Pointer(val)) +func X__c11_atomic_exchangeInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) { + return atomic.SwapInt64((*int64)(unsafe.Pointer(ptr)), val) } func X__atomic_exchangeInt64(t *TLS, ptr, val, ret uintptr, _ int32) { - int64Mu.Lock() - - defer int64Mu.Unlock() + *(*int64)(unsafe.Pointer(ret)) = atomic.SwapInt64((*int64)(unsafe.Pointer(ptr)), *(*int64)(unsafe.Pointer(val))) +} - *(*int64)(unsafe.Pointer(ret)) = *(*int64)(unsafe.Pointer(ptr)) - *(*int64)(unsafe.Pointer(ptr)) = *(*int64)(unsafe.Pointer(val)) +func X__c11_atomic_exchangeUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) { + return uint64(atomic.SwapInt64((*int64)(unsafe.Pointer(ptr)), int64(val))) } func X__atomic_exchangeUint64(t *TLS, ptr, val, ret uintptr, _ int32) { - int64Mu.Lock() - - defer int64Mu.Unlock() - - *(*uint64)(unsafe.Pointer(ret)) = *(*uint64)(unsafe.Pointer(ptr)) - *(*uint64)(unsafe.Pointer(ptr)) = *(*uint64)(unsafe.Pointer(val)) + *(*uint64)(unsafe.Pointer(ret)) = atomic.SwapUint64((*uint64)(unsafe.Pointer(ptr)), *(*uint64)(unsafe.Pointer(val))) } // ---- @@ -605,10 +802,94 @@ func X__atomic_compare_exchangeUint64(t *TLS, ptr, expected, desired uintptr, we return X__atomic_compare_exchangeInt64(t, ptr, expected, desired, weak, success, failure) } +func X__c11_atomic_compare_exchange_strongInt8(t *TLS, ptr, expected uintptr, desired int8, success, failure int32) int32 { + int8Mu.Lock() + + defer int8Mu.Unlock() + + have := *(*int8)(unsafe.Pointer(ptr)) + if have == *(*int8)(unsafe.Pointer(expected)) { + *(*int8)(unsafe.Pointer(ptr)) = desired + return 1 + } + + *(*int8)(unsafe.Pointer(expected)) = have + return 0 +} + +func X__c11_atomic_compare_exchange_strongUint8(t *TLS, ptr, expected uintptr, desired uint8, success, failure int32) int32 { + return X__c11_atomic_compare_exchange_strongInt8(t, ptr, expected, int8(desired), success, failure) +} + +func X__c11_atomic_compare_exchange_strongInt16(t *TLS, ptr, expected uintptr, desired int16, success, failure int32) int32 { + int16Mu.Lock() + + defer int16Mu.Unlock() + + have := *(*int16)(unsafe.Pointer(ptr)) + if have == *(*int16)(unsafe.Pointer(expected)) { + *(*int16)(unsafe.Pointer(ptr)) = desired + return 1 + } + + *(*int16)(unsafe.Pointer(expected)) = have + return 0 +} + +func X__c11_atomic_compare_exchange_strongUint16(t *TLS, ptr, expected uintptr, desired uint16, success, failure int32) int32 { + return X__c11_atomic_compare_exchange_strongInt16(t, ptr, expected, int16(desired), success, failure) +} + +func X__c11_atomic_compare_exchange_strongInt32(t *TLS, ptr, expected uintptr, desired, success, failure int32) int32 { + int32Mu.Lock() + + defer int32Mu.Unlock() + + have := *(*int32)(unsafe.Pointer(ptr)) + if have == *(*int32)(unsafe.Pointer(expected)) { + *(*int32)(unsafe.Pointer(ptr)) = desired + return 1 + } + + *(*int32)(unsafe.Pointer(expected)) = have + return 0 +} + +func X__c11_atomic_compare_exchange_strongUint32(t *TLS, ptr, expected uintptr, desired uint32, success, failure int32) int32 { + return X__c11_atomic_compare_exchange_strongInt32(t, ptr, expected, int32(desired), success, failure) +} + +func X__c11_atomic_compare_exchange_strongInt64(t *TLS, ptr, expected uintptr, desired int64, success, failure int32) int32 { + int64Mu.Lock() + + defer int64Mu.Unlock() + + have := *(*int64)(unsafe.Pointer(ptr)) + if have == *(*int64)(unsafe.Pointer(expected)) { + *(*int64)(unsafe.Pointer(ptr)) = desired + return 1 + } + + *(*int64)(unsafe.Pointer(expected)) = have + return 0 +} + +func X__c11_atomic_compare_exchange_strongUint64(t *TLS, ptr, expected uintptr, desired uint64, success, failure int32) int32 { + return X__c11_atomic_compare_exchange_strongInt64(t, ptr, expected, int64(desired), success, failure) +} + // ---- // void __atomic_load (type *ptr, type *ret, int memorder) +func X__c11_atomic_loadInt8(t *TLS, ptr uintptr, memorder int32) (r int8) { + int8Mu.Lock() + + defer int8Mu.Unlock() + + return *(*int8)(unsafe.Pointer(ptr)) +} + func X__atomic_loadInt8(t *TLS, ptr, ret uintptr, memorder int32) { int8Mu.Lock() @@ -617,10 +898,22 @@ func X__atomic_loadInt8(t *TLS, ptr, ret uintptr, memorder int32) { *(*int8)(unsafe.Pointer(ret)) = *(*int8)(unsafe.Pointer(ptr)) } +func X__c11_atomic_loadUint8(t *TLS, ptr uintptr, memorder int32) (r uint8) { + return uint8(X__c11_atomic_loadInt8(t, ptr, memorder)) +} + func X__atomic_loadUint8(t *TLS, ptr, ret uintptr, memorder int32) { X__atomic_loadInt8(t, ptr, ret, memorder) } +func X__c11_atomic_loadInt16(t *TLS, ptr uintptr, memorder int32) (r int16) { + int16Mu.Lock() + + defer int16Mu.Unlock() + + return *(*int16)(unsafe.Pointer(ptr)) +} + func X__atomic_loadInt16(t *TLS, ptr, ret uintptr, memorder int32) { int16Mu.Lock() @@ -629,28 +922,40 @@ func X__atomic_loadInt16(t *TLS, ptr, ret uintptr, memorder int32) { *(*int16)(unsafe.Pointer(ret)) = *(*int16)(unsafe.Pointer(ptr)) } +func X__c11_atomic_loadUint16(t *TLS, ptr uintptr, memorder int32) (r uint16) { + return uint16(X__c11_atomic_loadInt16(t, ptr, memorder)) +} + func X__atomic_loadUint16(t *TLS, ptr, ret uintptr, memorder int32) { X__atomic_loadInt16(t, ptr, ret, memorder) } -func X__atomic_loadInt32(t *TLS, ptr, ret uintptr, memorder int32) { - int32Mu.Lock() +func X__c11_atomic_loadInt32(t *TLS, ptr uintptr, memorder int32) (r int32) { + return atomic.LoadInt32((*int32)(unsafe.Pointer(ptr))) +} - defer int32Mu.Unlock() +func X__atomic_loadInt32(t *TLS, ptr, ret uintptr, memorder int32) { + *(*int32)(unsafe.Pointer(ret)) = atomic.LoadInt32((*int32)(unsafe.Pointer(ptr))) +} - *(*int32)(unsafe.Pointer(ret)) = *(*int32)(unsafe.Pointer(ptr)) +func X__c11_atomic_loadUint32(t *TLS, ptr uintptr, memorder int32) (r uint32) { + return uint32(X__c11_atomic_loadInt32(t, ptr, memorder)) } func X__atomic_loadUint32(t *TLS, ptr, ret uintptr, memorder int32) { X__atomic_loadInt32(t, ptr, ret, memorder) } -func X__atomic_loadInt64(t *TLS, ptr, ret uintptr, memorder int32) { - int64Mu.Lock() +func X__c11_atomic_loadInt64(t *TLS, ptr uintptr, memorder int32) (r int64) { + return atomic.LoadInt64((*int64)(unsafe.Pointer(ptr))) +} - defer int64Mu.Unlock() +func X__atomic_loadInt64(t *TLS, ptr, ret uintptr, memorder int32) { + *(*int64)(unsafe.Pointer(ret)) = atomic.LoadInt64((*int64)(unsafe.Pointer(ptr))) +} - *(*int64)(unsafe.Pointer(ret)) = *(*int64)(unsafe.Pointer(ptr)) +func X__c11_atomic_loadUint64(t *TLS, ptr uintptr, memorder int32) (r uint64) { + return uint64(X__c11_atomic_loadInt64(t, ptr, memorder)) } func X__atomic_loadUint64(t *TLS, ptr, ret uintptr, memorder int32) { @@ -661,6 +966,14 @@ func X__atomic_loadUint64(t *TLS, ptr, ret uintptr, memorder int32) { // void __atomic_store (type *ptr, type *val, int memorder) +func X__c11_atomic_storeInt8(t *TLS, ptr uintptr, val int8, memorder int32) { + int8Mu.Lock() + + defer int8Mu.Unlock() + + *(*int8)(unsafe.Pointer(ptr)) = val +} + func X__atomic_storeInt8(t *TLS, ptr, val uintptr, memorder int32) { int8Mu.Lock() @@ -669,10 +982,22 @@ func X__atomic_storeInt8(t *TLS, ptr, val uintptr, memorder int32) { *(*int8)(unsafe.Pointer(ptr)) = *(*int8)(unsafe.Pointer(val)) } +func X__c11_atomic_storeUint8(t *TLS, ptr uintptr, val uint8, memorder int32) { + X__c11_atomic_storeInt8(t, ptr, int8(val), memorder) +} + func X__atomic_storeUint8(t *TLS, ptr, val uintptr, memorder int32) { X__atomic_storeInt8(t, ptr, val, memorder) } +func X__c11_atomic_storeInt16(t *TLS, ptr uintptr, val int16, memorder int32) { + int16Mu.Lock() + + defer int16Mu.Unlock() + + *(*int16)(unsafe.Pointer(ptr)) = val +} + func X__atomic_storeInt16(t *TLS, ptr, val uintptr, memorder int32) { int16Mu.Lock() @@ -681,28 +1006,40 @@ func X__atomic_storeInt16(t *TLS, ptr, val uintptr, memorder int32) { *(*int16)(unsafe.Pointer(ptr)) = *(*int16)(unsafe.Pointer(val)) } +func X__c11_atomic_storeUint16(t *TLS, ptr uintptr, val uint16, memorder int32) { + X__c11_atomic_storeInt16(t, ptr, int16(val), memorder) +} + func X__atomic_storeUint16(t *TLS, ptr, val uintptr, memorder int32) { X__atomic_storeInt16(t, ptr, val, memorder) } -func X__atomic_storeInt32(t *TLS, ptr, val uintptr, memorder int32) { - int32Mu.Lock() +func X__c11_atomic_storeInt32(t *TLS, ptr uintptr, val int32, memorder int32) { + atomic.StoreInt32((*int32)(unsafe.Pointer(ptr)), val) +} - defer int32Mu.Unlock() +func X__atomic_storeInt32(t *TLS, ptr, val uintptr, memorder int32) { + atomic.StoreInt32((*int32)(unsafe.Pointer(ptr)), *(*int32)(unsafe.Pointer(val))) +} - *(*int32)(unsafe.Pointer(ptr)) = *(*int32)(unsafe.Pointer(val)) +func X__c11_atomic_storeUint32(t *TLS, ptr uintptr, val uint32, memorder int32) { + X__c11_atomic_storeInt32(t, ptr, int32(val), memorder) } func X__atomic_storeUint32(t *TLS, ptr, val uintptr, memorder int32) { X__atomic_storeInt32(t, ptr, val, memorder) } -func X__atomic_storeInt64(t *TLS, ptr, val uintptr, memorder int32) { - int64Mu.Lock() +func X__c11_atomic_storeInt64(t *TLS, ptr uintptr, val int64, memorder int32) { + atomic.StoreInt64((*int64)(unsafe.Pointer(ptr)), val) +} - defer int64Mu.Unlock() +func X__atomic_storeInt64(t *TLS, ptr, val uintptr, memorder int32) { + atomic.StoreInt64((*int64)(unsafe.Pointer(ptr)), *(*int64)(unsafe.Pointer(val))) +} - *(*int64)(unsafe.Pointer(ptr)) = *(*int64)(unsafe.Pointer(val)) +func X__c11_atomic_storeUint64(t *TLS, ptr uintptr, val uint64, memorder int32) { + X__c11_atomic_storeInt64(t, ptr, int64(val), memorder) } func X__atomic_storeUint64(t *TLS, ptr, val uintptr, memorder int32) { diff --git a/vendor/modules.txt b/vendor/modules.txt index b3dc592082..c71ff53a7c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -342,8 +342,8 @@ github.com/cespare/xxhash # github.com/cespare/xxhash/v2 v2.3.0 ## explicit; go 1.11 github.com/cespare/xxhash/v2 -# github.com/charmbracelet/bubbletea v1.3.4 -## explicit; go 1.18 +# github.com/charmbracelet/bubbletea v1.3.5 +## explicit; go 1.23.0 github.com/charmbracelet/bubbletea # github.com/charmbracelet/colorprofile v0.3.1 ## explicit; go 1.23.0 @@ -351,8 +351,8 @@ github.com/charmbracelet/colorprofile # github.com/charmbracelet/lipgloss v1.1.0 ## explicit; go 1.18 github.com/charmbracelet/lipgloss -# github.com/charmbracelet/x/ansi v0.8.0 -## explicit; go 1.18 +# github.com/charmbracelet/x/ansi v0.9.2 +## explicit; go 1.23.0 github.com/charmbracelet/x/ansi github.com/charmbracelet/x/ansi/kitty github.com/charmbracelet/x/ansi/parser @@ -439,7 +439,7 @@ github.com/cockroachdb/redact/internal/markers github.com/cockroachdb/redact/internal/redact github.com/cockroachdb/redact/internal/rfmt github.com/cockroachdb/redact/internal/rfmt/fmtsort -# github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 +# github.com/cockroachdb/tokenbucket v0.0.0-20250429170803-42689b6311bb ## explicit; go 1.19 github.com/cockroachdb/tokenbucket # github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be @@ -1349,7 +1349,7 @@ gopkg.in/yaml.v3 lukechampine.com/blake3 lukechampine.com/blake3/bao lukechampine.com/blake3/guts -# modernc.org/libc v1.64.0 +# modernc.org/libc v1.64.1 ## explicit; go 1.23.0 modernc.org/libc modernc.org/libc/errno