From f3e2d36d6455e6d16aba833bdf64806377c8178f Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Thu, 26 Sep 2024 19:23:41 +0000 Subject: [PATCH] [chore] update go-sched pkg (#3357) * update go-sched to v1.2.4 which removes some now unused dependencies * whoops, remove test output --- go.mod | 6 +- go.sum | 14 +- vendor/codeberg.org/gruf/go-atomics/LICENSE | 9 - vendor/codeberg.org/gruf/go-atomics/README.md | 3 - .../codeberg.org/gruf/go-atomics/atomic.tpl | 57 - .../gruf/go-atomics/atomic_test.tpl | 60 - vendor/codeberg.org/gruf/go-atomics/bool.go | 47 - vendor/codeberg.org/gruf/go-atomics/bytes.go | 57 - vendor/codeberg.org/gruf/go-atomics/error.go | 57 - vendor/codeberg.org/gruf/go-atomics/flags.go | 97 - vendor/codeberg.org/gruf/go-atomics/int.go | 69 - .../codeberg.org/gruf/go-atomics/interface.go | 57 - vendor/codeberg.org/gruf/go-atomics/state.go | 58 - vendor/codeberg.org/gruf/go-atomics/string.go | 57 - vendor/codeberg.org/gruf/go-atomics/time.go | 58 - vendor/codeberg.org/gruf/go-atomics/uint.go | 69 - vendor/codeberg.org/gruf/go-bitutil/LICENSE | 9 - vendor/codeberg.org/gruf/go-bitutil/README.md | 3 - vendor/codeberg.org/gruf/go-bitutil/abs.go | 29 - vendor/codeberg.org/gruf/go-bitutil/flag.go | 3744 ----------------- vendor/codeberg.org/gruf/go-bitutil/flag.tpl | 117 - .../gruf/go-bitutil/flag_test.tpl | 98 - vendor/codeberg.org/gruf/go-bitutil/pack.go | 85 - vendor/codeberg.org/gruf/go-bitutil/test.tpl | 60 - vendor/codeberg.org/gruf/go-sched/job.go | 32 +- .../codeberg.org/gruf/go-sched/scheduler.go | 4 +- vendor/modules.txt | 10 +- 27 files changed, 33 insertions(+), 4933 deletions(-) delete mode 100644 vendor/codeberg.org/gruf/go-atomics/LICENSE delete mode 100644 vendor/codeberg.org/gruf/go-atomics/README.md delete mode 100644 vendor/codeberg.org/gruf/go-atomics/atomic.tpl delete mode 100644 vendor/codeberg.org/gruf/go-atomics/atomic_test.tpl delete mode 100644 vendor/codeberg.org/gruf/go-atomics/bool.go delete mode 100644 vendor/codeberg.org/gruf/go-atomics/bytes.go delete mode 100644 vendor/codeberg.org/gruf/go-atomics/error.go delete mode 100644 vendor/codeberg.org/gruf/go-atomics/flags.go delete mode 100644 vendor/codeberg.org/gruf/go-atomics/int.go delete mode 100644 vendor/codeberg.org/gruf/go-atomics/interface.go delete mode 100644 vendor/codeberg.org/gruf/go-atomics/state.go delete mode 100644 vendor/codeberg.org/gruf/go-atomics/string.go delete mode 100644 vendor/codeberg.org/gruf/go-atomics/time.go delete mode 100644 vendor/codeberg.org/gruf/go-atomics/uint.go delete mode 100644 vendor/codeberg.org/gruf/go-bitutil/LICENSE delete mode 100644 vendor/codeberg.org/gruf/go-bitutil/README.md delete mode 100644 vendor/codeberg.org/gruf/go-bitutil/abs.go delete mode 100644 vendor/codeberg.org/gruf/go-bitutil/flag.go delete mode 100644 vendor/codeberg.org/gruf/go-bitutil/flag.tpl delete mode 100644 vendor/codeberg.org/gruf/go-bitutil/flag_test.tpl delete mode 100644 vendor/codeberg.org/gruf/go-bitutil/pack.go delete mode 100644 vendor/codeberg.org/gruf/go-bitutil/test.tpl diff --git a/go.mod b/go.mod index e2b7c1821..a9e392ddb 100644 --- a/go.mod +++ b/go.mod @@ -19,8 +19,8 @@ require ( codeberg.org/gruf/go-mempool v0.0.0-20240507125005-cef10d64a760 codeberg.org/gruf/go-mimetypes v1.2.0 codeberg.org/gruf/go-mutexes v1.5.1 - codeberg.org/gruf/go-runners v1.6.2 - codeberg.org/gruf/go-sched v1.2.3 + codeberg.org/gruf/go-runners v1.6.3 + codeberg.org/gruf/go-sched v1.2.4 codeberg.org/gruf/go-storage v0.2.0 codeberg.org/gruf/go-structr v0.8.9 codeberg.org/superseriousbusiness/exif-terminator v0.9.0 @@ -85,8 +85,6 @@ require ( ) require ( - codeberg.org/gruf/go-atomics v1.1.0 // indirect - codeberg.org/gruf/go-bitutil v1.1.0 // indirect codeberg.org/gruf/go-fastpath/v2 v2.0.0 // indirect codeberg.org/gruf/go-mangler v1.4.1 // indirect codeberg.org/gruf/go-maps v1.0.3 // indirect diff --git a/go.sum b/go.sum index b8ad6028c..8d9281d5d 100644 --- a/go.sum +++ b/go.sum @@ -30,11 +30,6 @@ cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0Zeo cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= -codeberg.org/gruf/go-atomics v1.1.0 h1:ni9QXYoRUFYQMXE3akWaUb1wMcPBDc05Md6Rgml7W58= -codeberg.org/gruf/go-atomics v1.1.0/go.mod h1:a/4/y/LgvjxjQVnpoy1VVkOSzLS1W9i1g4SJ0nflAa4= -codeberg.org/gruf/go-bitutil v1.0.0/go.mod h1:sb8IjlDnjVTz8zPK/8lmHesKxY0Yb3iqHWjUM/SkphA= -codeberg.org/gruf/go-bitutil v1.1.0 h1:U1Q+A1mtnPk+npqYrlRBc9ar2C5hYiBd17l1Wrp2Bt8= -codeberg.org/gruf/go-bitutil v1.1.0/go.mod h1:rGibFevYTQfYKcPv0Df5KpG8n5xC3AfD4d/UgYeoNy0= codeberg.org/gruf/go-bytes v1.0.2 h1:malqE42Ni+h1nnYWBUAJaDDtEzF4aeN4uPN8DfMNNvo= codeberg.org/gruf/go-bytes v1.0.2/go.mod h1:1v/ibfaosfXSZtRdW2rWaVrDXMc9E3bsi/M9Ekx39cg= codeberg.org/gruf/go-bytesize v1.0.3 h1:Tz8tCxhPLeyM5VryuBNjUHgKmLj4Bx9RbPaUSA3qg6g= @@ -45,7 +40,6 @@ codeberg.org/gruf/go-cache/v3 v3.5.7 h1:5hut49a8Wp3hdwrCEJYj6pHY2aRR1hyTmkK4+wHV codeberg.org/gruf/go-cache/v3 v3.5.7/go.mod h1:Thahfuf3PgHSv2+1zHpvhRdX97tx1WXurVNGWpZucAM= codeberg.org/gruf/go-debug v1.3.0 h1:PIRxQiWUFKtGOGZFdZ3Y0pqyfI0Xr87j224IYe2snZs= codeberg.org/gruf/go-debug v1.3.0/go.mod h1:N+vSy9uJBQgpQcJUqjctvqFz7tBHJf+S/PIjLILzpLg= -codeberg.org/gruf/go-errors/v2 v2.0.0/go.mod h1:ZRhbdhvgoUA3Yw6e56kd9Ox984RrvbEFC2pOXyHDJP4= codeberg.org/gruf/go-errors/v2 v2.3.2 h1:8ItWaOMfhDaqrJK1Pw8MO0Nu+o/tVcQtR5cJ58Vc4zo= codeberg.org/gruf/go-errors/v2 v2.3.2/go.mod h1:LfzD9nkAAJpEDbkUqOZQ2jdaQ8VrK0pnR36zLOMFq6Y= codeberg.org/gruf/go-fastcopy v1.1.3 h1:Jo9VTQjI6KYimlw25PPc7YLA3Xm+XMQhaHwKnM7xD1g= @@ -72,10 +66,10 @@ codeberg.org/gruf/go-mimetypes v1.2.0 h1:3rZGXY/SkNYbamiddWXs2gETXIBkGIeWYnbWpp2 codeberg.org/gruf/go-mimetypes v1.2.0/go.mod h1:YiUWRj/nAdJQc+UFRvcsL6xXZsbc6b6Ic739ycEO8Yg= codeberg.org/gruf/go-mutexes v1.5.1 h1:xICU0WXhWr6wf+Iror4eE3xT+xnXNPrO6o77D/G6QuY= codeberg.org/gruf/go-mutexes v1.5.1/go.mod h1:rPEqQ/y6CmGITaZ3GPTMQVsoZAOzbsAHyIaLsJcOqVE= -codeberg.org/gruf/go-runners v1.6.2 h1:oQef9niahfHu/wch14xNxlRMP8i+ABXH1Cb9PzZ4oYo= -codeberg.org/gruf/go-runners v1.6.2/go.mod h1:Tq5PrZ/m/rBXbLZz0u5if+yP3nG5Sf6S8O/GnyEePeQ= -codeberg.org/gruf/go-sched v1.2.3 h1:H5ViDxxzOBR3uIyGBCf0eH8b1L8wMybOXcdtUUTXZHk= -codeberg.org/gruf/go-sched v1.2.3/go.mod h1:vT9uB6KWFIIwnG9vcPY2a0alYNoqdL1mSzRM8I+PK7A= +codeberg.org/gruf/go-runners v1.6.3 h1:To/AX7eTrWuXrTkA3RA01YTP5zha1VZ68LQ+0D4RY7E= +codeberg.org/gruf/go-runners v1.6.3/go.mod h1:oXAaUmG2VxoKttpCqZGv5nQBeSvZSR2BzIk7h1yTRlU= +codeberg.org/gruf/go-sched v1.2.4 h1:ddBB9o0D/2oU8NbQ0ldN5aWxogpXPRBATWi58+p++Hw= +codeberg.org/gruf/go-sched v1.2.4/go.mod h1:wad6l+OcYGWMA2TzNLMmLObsrbBDxdJfEy5WvTgBjNk= codeberg.org/gruf/go-storage v0.2.0 h1:mKj3Lx6AavEkuXXtxqPhdq+akW9YwrnP16yQBF7K5ZI= codeberg.org/gruf/go-storage v0.2.0/go.mod h1:o3GzMDE5QNUaRnm/daUzFqvuAaC4utlgXDXYO79sWKU= codeberg.org/gruf/go-structr v0.8.9 h1:OyiSspWYCeJOm356fFPd+bDRumPrard2VAUXAPqZiJ0= diff --git a/vendor/codeberg.org/gruf/go-atomics/LICENSE b/vendor/codeberg.org/gruf/go-atomics/LICENSE deleted file mode 100644 index e4163ae35..000000000 --- a/vendor/codeberg.org/gruf/go-atomics/LICENSE +++ /dev/null @@ -1,9 +0,0 @@ -MIT License - -Copyright (c) 2022 gruf - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/codeberg.org/gruf/go-atomics/README.md b/vendor/codeberg.org/gruf/go-atomics/README.md deleted file mode 100644 index 38ba53276..000000000 --- a/vendor/codeberg.org/gruf/go-atomics/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# go-atomics - -This library provides a variety of types for atomic operations on common Go types. \ No newline at end of file diff --git a/vendor/codeberg.org/gruf/go-atomics/atomic.tpl b/vendor/codeberg.org/gruf/go-atomics/atomic.tpl deleted file mode 100644 index 00134c1e8..000000000 --- a/vendor/codeberg.org/gruf/go-atomics/atomic.tpl +++ /dev/null @@ -1,57 +0,0 @@ -package atomics - -import ( - "sync/atomic" - "unsafe" -) - -// {{ .Name }} provides user-friendly means of performing atomic operations on {{ .Type }} types. -type {{ .Name }} struct{ ptr unsafe.Pointer } - -// New{{ .Name }} will return a new {{ .Name }} instance initialized with zero value. -func New{{ .Name }}() *{{ .Name }} { - var v {{ .Type }} - return &{{ .Name }}{ - ptr: unsafe.Pointer(&v), - } -} - -// Store will atomically store {{ .Type }} value in address contained within v. -func (v *{{ .Name }}) Store(val {{ .Type }}) { - atomic.StorePointer(&v.ptr, unsafe.Pointer(&val)) -} - -// Load will atomically load {{ .Type }} value at address contained within v. -func (v *{{ .Name }}) Load() {{ .Type }} { - return *(*{{ .Type }})(atomic.LoadPointer(&v.ptr)) -} - -// CAS performs a compare-and-swap for a(n) {{ .Type }} value at address contained within v. -func (v *{{ .Name }}) CAS(cmp, swp {{ .Type }}) bool { - for { - // Load current value at address - ptr := atomic.LoadPointer(&v.ptr) - cur := *(*{{ .Type }})(ptr) - - // Perform comparison against current - if !({{ call .Compare "cur" "cmp" }}) { - return false - } - - // Attempt to replace pointer - if atomic.CompareAndSwapPointer( - &v.ptr, - ptr, - unsafe.Pointer(&swp), - ) { - return true - } - } -} - -// Swap atomically stores new {{ .Type }} value into address contained within v, and returns previous value. -func (v *{{ .Name }}) Swap(swp {{ .Type }}) {{ .Type }} { - ptr := unsafe.Pointer(&swp) - ptr = atomic.SwapPointer(&v.ptr, ptr) - return *(*{{ .Type }})(ptr) -} diff --git a/vendor/codeberg.org/gruf/go-atomics/atomic_test.tpl b/vendor/codeberg.org/gruf/go-atomics/atomic_test.tpl deleted file mode 100644 index 4e659d81f..000000000 --- a/vendor/codeberg.org/gruf/go-atomics/atomic_test.tpl +++ /dev/null @@ -1,60 +0,0 @@ -package atomics_test - -import ( - "atomic" - "unsafe" - "testing" - - "codeberg.org/gruf/go-atomics" -) - -func Test{{ .Name }}StoreLoad(t *testing.T) { - for _, test := range {{ .Name }}Tests { - val := atomics.New{{ .Name }}() - - val.Store(test.V1) - - if !({{ call .Compare "val.Load()" "test.V1" }}) { - t.Fatalf("failed testing .Store and .Load: expect=%v actual=%v", val.Load(), test.V1) - } - - val.Store(test.V2) - - if !({{ call .Compare "val.Load()" "test.V2" }}) { - t.Fatalf("failed testing .Store and .Load: expect=%v actual=%v", val.Load(), test.V2) - } - } -} - -func Test{{ .Name }}CAS(t *testing.T) { - for _, test := range {{ .Name }}Tests { - val := atomics.New{{ .Name }}() - - val.Store(test.V1) - - if val.CAS(test.V2, test.V1) { - t.Fatalf("failed testing negative .CAS: test=%+v state=%v", test, val.Load()) - } - - if !val.CAS(test.V1, test.V2) { - t.Fatalf("failed testing positive .CAS: test=%+v state=%v", test, val.Load()) - } - } -} - -func Test{{ .Name }}Swap(t *testing.T) { - for _, test := range {{ .Name }}Tests { - val := atomics.New{{ .Name }}() - - val.Store(test.V1) - - if !({{ call .Compare "val.Swap(test.V2)" "test.V1" }}) { - t.Fatal("failed testing .Swap") - } - - if !({{ call .Compare "val.Swap(test.V1)" "test.V2" }}) { - t.Fatal("failed testing .Swap") - } - } -} - diff --git a/vendor/codeberg.org/gruf/go-atomics/bool.go b/vendor/codeberg.org/gruf/go-atomics/bool.go deleted file mode 100644 index 52660d356..000000000 --- a/vendor/codeberg.org/gruf/go-atomics/bool.go +++ /dev/null @@ -1,47 +0,0 @@ -package atomics - -import "sync/atomic" - -// Bool provides user-friendly means of performing atomic operations on bool types. -type Bool uint32 - -// NewBool will return a new Bool instance initialized with zero value. -func NewBool() *Bool { - return new(Bool) -} - -// Store will atomically store bool value in address contained within i. -func (b *Bool) Store(val bool) { - atomic.StoreUint32((*uint32)(b), fromBool(val)) -} - -// Load will atomically load bool value at address contained within i. -func (b *Bool) Load() bool { - return toBool(atomic.LoadUint32((*uint32)(b))) -} - -// CAS performs a compare-and-swap for a(n) bool value at address contained within i. -func (b *Bool) CAS(cmp, swp bool) bool { - return atomic.CompareAndSwapUint32((*uint32)(b), fromBool(cmp), fromBool(swp)) -} - -// Swap atomically stores new bool value into address contained within i, and returns previous value. -func (b *Bool) Swap(swp bool) bool { - return toBool(atomic.SwapUint32((*uint32)(b), fromBool(swp))) -} - -// toBool converts uint32 value to bool. -func toBool(u uint32) bool { - if u == 0 { - return false - } - return true -} - -// fromBool converts from bool to uint32 value. -func fromBool(b bool) uint32 { - if b { - return 1 - } - return 0 -} diff --git a/vendor/codeberg.org/gruf/go-atomics/bytes.go b/vendor/codeberg.org/gruf/go-atomics/bytes.go deleted file mode 100644 index 3e40d186c..000000000 --- a/vendor/codeberg.org/gruf/go-atomics/bytes.go +++ /dev/null @@ -1,57 +0,0 @@ -package atomics - -import ( - "sync/atomic" - "unsafe" -) - -// Bytes provides user-friendly means of performing atomic operations on []byte types. -type Bytes struct{ ptr unsafe.Pointer } - -// NewBytes will return a new Bytes instance initialized with zero value. -func NewBytes() *Bytes { - var v []byte - return &Bytes{ - ptr: unsafe.Pointer(&v), - } -} - -// Store will atomically store []byte value in address contained within v. -func (v *Bytes) Store(val []byte) { - atomic.StorePointer(&v.ptr, unsafe.Pointer(&val)) -} - -// Load will atomically load []byte value at address contained within v. -func (v *Bytes) Load() []byte { - return *(*[]byte)(atomic.LoadPointer(&v.ptr)) -} - -// CAS performs a compare-and-swap for a(n) []byte value at address contained within v. -func (v *Bytes) CAS(cmp, swp []byte) bool { - for { - // Load current value at address - ptr := atomic.LoadPointer(&v.ptr) - cur := *(*[]byte)(ptr) - - // Perform comparison against current - if !(string(cur) == string(cmp)) { - return false - } - - // Attempt to replace pointer - if atomic.CompareAndSwapPointer( - &v.ptr, - ptr, - unsafe.Pointer(&swp), - ) { - return true - } - } -} - -// Swap atomically stores new []byte value into address contained within v, and returns previous value. -func (v *Bytes) Swap(swp []byte) []byte { - ptr := unsafe.Pointer(&swp) - ptr = atomic.SwapPointer(&v.ptr, ptr) - return *(*[]byte)(ptr) -} diff --git a/vendor/codeberg.org/gruf/go-atomics/error.go b/vendor/codeberg.org/gruf/go-atomics/error.go deleted file mode 100644 index 0ecc4e9ad..000000000 --- a/vendor/codeberg.org/gruf/go-atomics/error.go +++ /dev/null @@ -1,57 +0,0 @@ -package atomics - -import ( - "sync/atomic" - "unsafe" -) - -// Error provides user-friendly means of performing atomic operations on error types. -type Error struct{ ptr unsafe.Pointer } - -// NewError will return a new Error instance initialized with zero value. -func NewError() *Error { - var v error - return &Error{ - ptr: unsafe.Pointer(&v), - } -} - -// Store will atomically store error value in address contained within v. -func (v *Error) Store(val error) { - atomic.StorePointer(&v.ptr, unsafe.Pointer(&val)) -} - -// Load will atomically load error value at address contained within v. -func (v *Error) Load() error { - return *(*error)(atomic.LoadPointer(&v.ptr)) -} - -// CAS performs a compare-and-swap for a(n) error value at address contained within v. -func (v *Error) CAS(cmp, swp error) bool { - for { - // Load current value at address - ptr := atomic.LoadPointer(&v.ptr) - cur := *(*error)(ptr) - - // Perform comparison against current - if !(cur == cmp) { - return false - } - - // Attempt to replace pointer - if atomic.CompareAndSwapPointer( - &v.ptr, - ptr, - unsafe.Pointer(&swp), - ) { - return true - } - } -} - -// Swap atomically stores new error value into address contained within v, and returns previous value. -func (v *Error) Swap(swp error) error { - ptr := unsafe.Pointer(&swp) - ptr = atomic.SwapPointer(&v.ptr, ptr) - return *(*error)(ptr) -} diff --git a/vendor/codeberg.org/gruf/go-atomics/flags.go b/vendor/codeberg.org/gruf/go-atomics/flags.go deleted file mode 100644 index 42176bece..000000000 --- a/vendor/codeberg.org/gruf/go-atomics/flags.go +++ /dev/null @@ -1,97 +0,0 @@ -package atomics - -import ( - "sync/atomic" - - "codeberg.org/gruf/go-bitutil" -) - -// Flags32 provides user-friendly means of performing atomic operations on bitutil.Flags32 types. -type Flags32 bitutil.Flags32 - -// NewFlags32 will return a new Flags32 instance initialized with zero value. -func NewFlags32() *Flags32 { - return new(Flags32) -} - -// Get will atomically load a(n) bitutil.Flags32 value contained within f, and check if bit value is set. -func (f *Flags32) Get(bit uint8) bool { - return f.Load().Get(bit) -} - -// Set performs a compare-and-swap for a(n) bitutil.Flags32 with bit value set, at address contained within f. -func (f *Flags32) Set(bit uint8) bool { - cur := f.Load() - return f.CAS(cur, cur.Set(bit)) -} - -// Unset performs a compare-and-swap for a(n) bitutil.Flags32 with bit value unset, at address contained within f. -func (f *Flags32) Unset(bit uint8) bool { - cur := f.Load() - return f.CAS(cur, cur.Unset(bit)) -} - -// Store will atomically store bitutil.Flags32 value in address contained within f. -func (f *Flags32) Store(val bitutil.Flags32) { - atomic.StoreUint32((*uint32)(f), uint32(val)) -} - -// Load will atomically load bitutil.Flags32 value at address contained within f. -func (f *Flags32) Load() bitutil.Flags32 { - return bitutil.Flags32(atomic.LoadUint32((*uint32)(f))) -} - -// CAS performs a compare-and-swap for a(n) bitutil.Flags32 value at address contained within f. -func (f *Flags32) CAS(cmp, swp bitutil.Flags32) bool { - return atomic.CompareAndSwapUint32((*uint32)(f), uint32(cmp), uint32(swp)) -} - -// Swap atomically stores new bitutil.Flags32 value into address contained within f, and returns previous value. -func (f *Flags32) Swap(swp bitutil.Flags32) bitutil.Flags32 { - return bitutil.Flags32(atomic.SwapUint32((*uint32)(f), uint32(swp))) -} - -// Flags64 provides user-friendly means of performing atomic operations on bitutil.Flags64 types. -type Flags64 bitutil.Flags64 - -// NewFlags64 will return a new Flags64 instance initialized with zero value. -func NewFlags64() *Flags64 { - return new(Flags64) -} - -// Get will atomically load a(n) bitutil.Flags64 value contained within f, and check if bit value is set. -func (f *Flags64) Get(bit uint8) bool { - return f.Load().Get(bit) -} - -// Set performs a compare-and-swap for a(n) bitutil.Flags64 with bit value set, at address contained within f. -func (f *Flags64) Set(bit uint8) bool { - cur := f.Load() - return f.CAS(cur, cur.Set(bit)) -} - -// Unset performs a compare-and-swap for a(n) bitutil.Flags64 with bit value unset, at address contained within f. -func (f *Flags64) Unset(bit uint8) bool { - cur := f.Load() - return f.CAS(cur, cur.Unset(bit)) -} - -// Store will atomically store bitutil.Flags64 value in address contained within f. -func (f *Flags64) Store(val bitutil.Flags64) { - atomic.StoreUint64((*uint64)(f), uint64(val)) -} - -// Load will atomically load bitutil.Flags64 value at address contained within f. -func (f *Flags64) Load() bitutil.Flags64 { - return bitutil.Flags64(atomic.LoadUint64((*uint64)(f))) -} - -// CAS performs a compare-and-swap for a(n) bitutil.Flags64 value at address contained within f. -func (f *Flags64) CAS(cmp, swp bitutil.Flags64) bool { - return atomic.CompareAndSwapUint64((*uint64)(f), uint64(cmp), uint64(swp)) -} - -// Swap atomically stores new bitutil.Flags64 value into address contained within f, and returns previous value. -func (f *Flags64) Swap(swp bitutil.Flags64) bitutil.Flags64 { - return bitutil.Flags64(atomic.SwapUint64((*uint64)(f), uint64(swp))) -} diff --git a/vendor/codeberg.org/gruf/go-atomics/int.go b/vendor/codeberg.org/gruf/go-atomics/int.go deleted file mode 100644 index 019ca1034..000000000 --- a/vendor/codeberg.org/gruf/go-atomics/int.go +++ /dev/null @@ -1,69 +0,0 @@ -package atomics - -import "sync/atomic" - -// Int32 provides user-friendly means of performing atomic operations on int32 types. -type Int32 int32 - -// NewInt32 will return a new Int32 instance initialized with zero value. -func NewInt32() *Int32 { - return new(Int32) -} - -// Add will atomically add int32 delta to value in address contained within i, returning new value. -func (i *Int32) Add(delta int32) int32 { - return atomic.AddInt32((*int32)(i), delta) -} - -// Store will atomically store int32 value in address contained within i. -func (i *Int32) Store(val int32) { - atomic.StoreInt32((*int32)(i), val) -} - -// Load will atomically load int32 value at address contained within i. -func (i *Int32) Load() int32 { - return atomic.LoadInt32((*int32)(i)) -} - -// CAS performs a compare-and-swap for a(n) int32 value at address contained within i. -func (i *Int32) CAS(cmp, swp int32) bool { - return atomic.CompareAndSwapInt32((*int32)(i), cmp, swp) -} - -// Swap atomically stores new int32 value into address contained within i, and returns previous value. -func (i *Int32) Swap(swp int32) int32 { - return atomic.SwapInt32((*int32)(i), swp) -} - -// Int64 provides user-friendly means of performing atomic operations on int64 types. -type Int64 int64 - -// NewInt64 will return a new Int64 instance initialized with zero value. -func NewInt64() *Int64 { - return new(Int64) -} - -// Add will atomically add int64 delta to value in address contained within i, returning new value. -func (i *Int64) Add(delta int64) int64 { - return atomic.AddInt64((*int64)(i), delta) -} - -// Store will atomically store int64 value in address contained within i. -func (i *Int64) Store(val int64) { - atomic.StoreInt64((*int64)(i), val) -} - -// Load will atomically load int64 value at address contained within i. -func (i *Int64) Load() int64 { - return atomic.LoadInt64((*int64)(i)) -} - -// CAS performs a compare-and-swap for a(n) int64 value at address contained within i. -func (i *Int64) CAS(cmp, swp int64) bool { - return atomic.CompareAndSwapInt64((*int64)(i), cmp, swp) -} - -// Swap atomically stores new int64 value into address contained within i, and returns previous value. -func (i *Int64) Swap(swp int64) int64 { - return atomic.SwapInt64((*int64)(i), swp) -} diff --git a/vendor/codeberg.org/gruf/go-atomics/interface.go b/vendor/codeberg.org/gruf/go-atomics/interface.go deleted file mode 100644 index f0d1c4355..000000000 --- a/vendor/codeberg.org/gruf/go-atomics/interface.go +++ /dev/null @@ -1,57 +0,0 @@ -package atomics - -import ( - "sync/atomic" - "unsafe" -) - -// Interface provides user-friendly means of performing atomic operations on interface{} types. -type Interface struct{ ptr unsafe.Pointer } - -// NewInterface will return a new Interface instance initialized with zero value. -func NewInterface() *Interface { - var v interface{} - return &Interface{ - ptr: unsafe.Pointer(&v), - } -} - -// Store will atomically store interface{} value in address contained within v. -func (v *Interface) Store(val interface{}) { - atomic.StorePointer(&v.ptr, unsafe.Pointer(&val)) -} - -// Load will atomically load interface{} value at address contained within v. -func (v *Interface) Load() interface{} { - return *(*interface{})(atomic.LoadPointer(&v.ptr)) -} - -// CAS performs a compare-and-swap for a(n) interface{} value at address contained within v. -func (v *Interface) CAS(cmp, swp interface{}) bool { - for { - // Load current value at address - ptr := atomic.LoadPointer(&v.ptr) - cur := *(*interface{})(ptr) - - // Perform comparison against current - if !(cur == cmp) { - return false - } - - // Attempt to replace pointer - if atomic.CompareAndSwapPointer( - &v.ptr, - ptr, - unsafe.Pointer(&swp), - ) { - return true - } - } -} - -// Swap atomically stores new interface{} value into address contained within v, and returns previous value. -func (v *Interface) Swap(swp interface{}) interface{} { - ptr := unsafe.Pointer(&swp) - ptr = atomic.SwapPointer(&v.ptr, ptr) - return *(*interface{})(ptr) -} diff --git a/vendor/codeberg.org/gruf/go-atomics/state.go b/vendor/codeberg.org/gruf/go-atomics/state.go deleted file mode 100644 index 21892f378..000000000 --- a/vendor/codeberg.org/gruf/go-atomics/state.go +++ /dev/null @@ -1,58 +0,0 @@ -package atomics - -import "sync" - -// State provides user-friendly means of performing atomic-like -// operations on a uint32 state, and allowing callbacks on successful -// state change. This is a bit of a misnomer being where it is, as it -// actually uses a mutex under-the-hood. -type State struct { - mutex sync.Mutex - state uint32 -} - -// Store will update State value safely within mutex lock. -func (st *State) Store(val uint32) { - st.mutex.Lock() - st.state = val - st.mutex.Unlock() -} - -// Load will get value of State safely within mutex lock. -func (st *State) Load() uint32 { - st.mutex.Lock() - state := st.state - st.mutex.Unlock() - return state -} - -// WithLock performs fn within State mutex lock, useful if you want -// to just use State's mutex for locking instead of creating another. -func (st *State) WithLock(fn func()) { - st.mutex.Lock() - defer st.mutex.Unlock() - fn() -} - -// Update performs fn within State mutex lock, with the current state -// value provided as an argument, and return value used to update state. -func (st *State) Update(fn func(state uint32) uint32) { - st.mutex.Lock() - defer st.mutex.Unlock() - st.state = fn(st.state) -} - -// CAS performs a compare-and-swap on State, calling fn on success. Success value is also returned. -func (st *State) CAS(cmp, swp uint32, fn func()) (ok bool) { - // Acquire lock - st.mutex.Lock() - defer st.mutex.Unlock() - - // Perform CAS operation, fn() on success - if ok = (st.state == cmp); ok { - st.state = swp - fn() - } - - return -} diff --git a/vendor/codeberg.org/gruf/go-atomics/string.go b/vendor/codeberg.org/gruf/go-atomics/string.go deleted file mode 100644 index a0a6e115f..000000000 --- a/vendor/codeberg.org/gruf/go-atomics/string.go +++ /dev/null @@ -1,57 +0,0 @@ -package atomics - -import ( - "sync/atomic" - "unsafe" -) - -// String provides user-friendly means of performing atomic operations on string types. -type String struct{ ptr unsafe.Pointer } - -// NewString will return a new String instance initialized with zero value. -func NewString() *String { - var v string - return &String{ - ptr: unsafe.Pointer(&v), - } -} - -// Store will atomically store string value in address contained within v. -func (v *String) Store(val string) { - atomic.StorePointer(&v.ptr, unsafe.Pointer(&val)) -} - -// Load will atomically load string value at address contained within v. -func (v *String) Load() string { - return *(*string)(atomic.LoadPointer(&v.ptr)) -} - -// CAS performs a compare-and-swap for a(n) string value at address contained within v. -func (v *String) CAS(cmp, swp string) bool { - for { - // Load current value at address - ptr := atomic.LoadPointer(&v.ptr) - cur := *(*string)(ptr) - - // Perform comparison against current - if !(cur == cmp) { - return false - } - - // Attempt to replace pointer - if atomic.CompareAndSwapPointer( - &v.ptr, - ptr, - unsafe.Pointer(&swp), - ) { - return true - } - } -} - -// Swap atomically stores new string value into address contained within v, and returns previous value. -func (v *String) Swap(swp string) string { - ptr := unsafe.Pointer(&swp) - ptr = atomic.SwapPointer(&v.ptr, ptr) - return *(*string)(ptr) -} diff --git a/vendor/codeberg.org/gruf/go-atomics/time.go b/vendor/codeberg.org/gruf/go-atomics/time.go deleted file mode 100644 index 4bf20cc74..000000000 --- a/vendor/codeberg.org/gruf/go-atomics/time.go +++ /dev/null @@ -1,58 +0,0 @@ -package atomics - -import ( - "sync/atomic" - "time" - "unsafe" -) - -// Time provides user-friendly means of performing atomic operations on time.Time types. -type Time struct{ ptr unsafe.Pointer } - -// NewTime will return a new Time instance initialized with zero value. -func NewTime() *Time { - var v time.Time - return &Time{ - ptr: unsafe.Pointer(&v), - } -} - -// Store will atomically store time.Time value in address contained within v. -func (v *Time) Store(val time.Time) { - atomic.StorePointer(&v.ptr, unsafe.Pointer(&val)) -} - -// Load will atomically load time.Time value at address contained within v. -func (v *Time) Load() time.Time { - return *(*time.Time)(atomic.LoadPointer(&v.ptr)) -} - -// CAS performs a compare-and-swap for a(n) time.Time value at address contained within v. -func (v *Time) CAS(cmp, swp time.Time) bool { - for { - // Load current value at address - ptr := atomic.LoadPointer(&v.ptr) - cur := *(*time.Time)(ptr) - - // Perform comparison against current - if !(cur.Equal(cmp)) { - return false - } - - // Attempt to replace pointer - if atomic.CompareAndSwapPointer( - &v.ptr, - ptr, - unsafe.Pointer(&swp), - ) { - return true - } - } -} - -// Swap atomically stores new time.Time value into address contained within v, and returns previous value. -func (v *Time) Swap(swp time.Time) time.Time { - ptr := unsafe.Pointer(&swp) - ptr = atomic.SwapPointer(&v.ptr, ptr) - return *(*time.Time)(ptr) -} diff --git a/vendor/codeberg.org/gruf/go-atomics/uint.go b/vendor/codeberg.org/gruf/go-atomics/uint.go deleted file mode 100644 index 087e231d1..000000000 --- a/vendor/codeberg.org/gruf/go-atomics/uint.go +++ /dev/null @@ -1,69 +0,0 @@ -package atomics - -import "sync/atomic" - -// Uint32 provides user-friendly means of performing atomic operations on uint32 types. -type Uint32 uint32 - -// NewUint32 will return a new Uint32 instance initialized with zero value. -func NewUint32() *Uint32 { - return new(Uint32) -} - -// Add will atomically add uint32 delta to value in address contained within i, returning new value. -func (u *Uint32) Add(delta uint32) uint32 { - return atomic.AddUint32((*uint32)(u), delta) -} - -// Store will atomically store uint32 value in address contained within i. -func (u *Uint32) Store(val uint32) { - atomic.StoreUint32((*uint32)(u), val) -} - -// Load will atomically load uint32 value at address contained within i. -func (u *Uint32) Load() uint32 { - return atomic.LoadUint32((*uint32)(u)) -} - -// CAS performs a compare-and-swap for a(n) uint32 value at address contained within i. -func (u *Uint32) CAS(cmp, swp uint32) bool { - return atomic.CompareAndSwapUint32((*uint32)(u), cmp, swp) -} - -// Swap atomically stores new uint32 value into address contained within i, and returns previous value. -func (u *Uint32) Swap(swp uint32) uint32 { - return atomic.SwapUint32((*uint32)(u), swp) -} - -// Uint64 provides user-friendly means of performing atomic operations on uint64 types. -type Uint64 uint64 - -// NewUint64 will return a new Uint64 instance initialized with zero value. -func NewUint64() *Uint64 { - return new(Uint64) -} - -// Add will atomically add uint64 delta to value in address contained within i, returning new value. -func (u *Uint64) Add(delta uint64) uint64 { - return atomic.AddUint64((*uint64)(u), delta) -} - -// Store will atomically store uint64 value in address contained within i. -func (u *Uint64) Store(val uint64) { - atomic.StoreUint64((*uint64)(u), val) -} - -// Load will atomically load uint64 value at address contained within i. -func (u *Uint64) Load() uint64 { - return atomic.LoadUint64((*uint64)(u)) -} - -// CAS performs a compare-and-swap for a(n) uint64 value at address contained within i. -func (u *Uint64) CAS(cmp, swp uint64) bool { - return atomic.CompareAndSwapUint64((*uint64)(u), cmp, swp) -} - -// Swap atomically stores new uint64 value into address contained within i, and returns previous value. -func (u *Uint64) Swap(swp uint64) uint64 { - return atomic.SwapUint64((*uint64)(u), swp) -} diff --git a/vendor/codeberg.org/gruf/go-bitutil/LICENSE b/vendor/codeberg.org/gruf/go-bitutil/LICENSE deleted file mode 100644 index e4163ae35..000000000 --- a/vendor/codeberg.org/gruf/go-bitutil/LICENSE +++ /dev/null @@ -1,9 +0,0 @@ -MIT License - -Copyright (c) 2022 gruf - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/codeberg.org/gruf/go-bitutil/README.md b/vendor/codeberg.org/gruf/go-bitutil/README.md deleted file mode 100644 index a71c1aa0b..000000000 --- a/vendor/codeberg.org/gruf/go-bitutil/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# go-bitutil - -This library provides helpful methods and types for performing typical bitwise operations on integers, e.g. packing/unpacking, bit flags. \ No newline at end of file diff --git a/vendor/codeberg.org/gruf/go-bitutil/abs.go b/vendor/codeberg.org/gruf/go-bitutil/abs.go deleted file mode 100644 index f4ce8ad75..000000000 --- a/vendor/codeberg.org/gruf/go-bitutil/abs.go +++ /dev/null @@ -1,29 +0,0 @@ -package bitutil - -// Abs8 returns the absolute value of i (calculated without branching). -func Abs8(i int8) int8 { - const bits = 8 - u := uint64(i >> (bits - 1)) - return (i ^ int8(u)) + int8(u&1) -} - -// Abs16 returns the absolute value of i (calculated without branching). -func Abs16(i int16) int16 { - const bits = 16 - u := uint64(i >> (bits - 1)) - return (i ^ int16(u)) + int16(u&1) -} - -// Abs32 returns the absolute value of i (calculated without branching). -func Abs32(i int32) int32 { - const bits = 32 - u := uint64(i >> (bits - 1)) - return (i ^ int32(u)) + int32(u&1) -} - -// Abs64 returns the absolute value of i (calculated without branching). -func Abs64(i int64) int64 { - const bits = 64 - u := uint64(i >> (bits - 1)) - return (i ^ int64(u)) + int64(u&1) -} diff --git a/vendor/codeberg.org/gruf/go-bitutil/flag.go b/vendor/codeberg.org/gruf/go-bitutil/flag.go deleted file mode 100644 index 6a5b20d11..000000000 --- a/vendor/codeberg.org/gruf/go-bitutil/flag.go +++ /dev/null @@ -1,3744 +0,0 @@ -package bitutil - -import ( - "unsafe" -) - -// Flags8 is a type-casted unsigned integer with helper -// methods for easily managing up to 8 bit-flags. -type Flags8 uint8 - -// Get will fetch the flag bit value at index 'bit'. -func (f Flags8) Get(bit uint8) bool { - mask := Flags8(1) << bit - return (f&mask != 0) -} - -// Set will set the flag bit value at index 'bit'. -func (f Flags8) Set(bit uint8) Flags8 { - mask := Flags8(1) << bit - return f | mask -} - -// Unset will unset the flag bit value at index 'bit'. -func (f Flags8) Unset(bit uint8) Flags8 { - mask := Flags8(1) << bit - return f & ^mask -} - -// Get0 will fetch the flag bit value at index 0. -func (f Flags8) Get0() bool { - const mask = Flags8(1) << 0 - return (f&mask != 0) -} - -// Set0 will set the flag bit value at index 0. -func (f Flags8) Set0() Flags8 { - const mask = Flags8(1) << 0 - return f | mask -} - -// Unset0 will unset the flag bit value at index 0. -func (f Flags8) Unset0() Flags8 { - const mask = Flags8(1) << 0 - return f & ^mask -} - -// Get1 will fetch the flag bit value at index 1. -func (f Flags8) Get1() bool { - const mask = Flags8(1) << 1 - return (f&mask != 0) -} - -// Set1 will set the flag bit value at index 1. -func (f Flags8) Set1() Flags8 { - const mask = Flags8(1) << 1 - return f | mask -} - -// Unset1 will unset the flag bit value at index 1. -func (f Flags8) Unset1() Flags8 { - const mask = Flags8(1) << 1 - return f & ^mask -} - -// Get2 will fetch the flag bit value at index 2. -func (f Flags8) Get2() bool { - const mask = Flags8(1) << 2 - return (f&mask != 0) -} - -// Set2 will set the flag bit value at index 2. -func (f Flags8) Set2() Flags8 { - const mask = Flags8(1) << 2 - return f | mask -} - -// Unset2 will unset the flag bit value at index 2. -func (f Flags8) Unset2() Flags8 { - const mask = Flags8(1) << 2 - return f & ^mask -} - -// Get3 will fetch the flag bit value at index 3. -func (f Flags8) Get3() bool { - const mask = Flags8(1) << 3 - return (f&mask != 0) -} - -// Set3 will set the flag bit value at index 3. -func (f Flags8) Set3() Flags8 { - const mask = Flags8(1) << 3 - return f | mask -} - -// Unset3 will unset the flag bit value at index 3. -func (f Flags8) Unset3() Flags8 { - const mask = Flags8(1) << 3 - return f & ^mask -} - -// Get4 will fetch the flag bit value at index 4. -func (f Flags8) Get4() bool { - const mask = Flags8(1) << 4 - return (f&mask != 0) -} - -// Set4 will set the flag bit value at index 4. -func (f Flags8) Set4() Flags8 { - const mask = Flags8(1) << 4 - return f | mask -} - -// Unset4 will unset the flag bit value at index 4. -func (f Flags8) Unset4() Flags8 { - const mask = Flags8(1) << 4 - return f & ^mask -} - -// Get5 will fetch the flag bit value at index 5. -func (f Flags8) Get5() bool { - const mask = Flags8(1) << 5 - return (f&mask != 0) -} - -// Set5 will set the flag bit value at index 5. -func (f Flags8) Set5() Flags8 { - const mask = Flags8(1) << 5 - return f | mask -} - -// Unset5 will unset the flag bit value at index 5. -func (f Flags8) Unset5() Flags8 { - const mask = Flags8(1) << 5 - return f & ^mask -} - -// Get6 will fetch the flag bit value at index 6. -func (f Flags8) Get6() bool { - const mask = Flags8(1) << 6 - return (f&mask != 0) -} - -// Set6 will set the flag bit value at index 6. -func (f Flags8) Set6() Flags8 { - const mask = Flags8(1) << 6 - return f | mask -} - -// Unset6 will unset the flag bit value at index 6. -func (f Flags8) Unset6() Flags8 { - const mask = Flags8(1) << 6 - return f & ^mask -} - -// Get7 will fetch the flag bit value at index 7. -func (f Flags8) Get7() bool { - const mask = Flags8(1) << 7 - return (f&mask != 0) -} - -// Set7 will set the flag bit value at index 7. -func (f Flags8) Set7() Flags8 { - const mask = Flags8(1) << 7 - return f | mask -} - -// Unset7 will unset the flag bit value at index 7. -func (f Flags8) Unset7() Flags8 { - const mask = Flags8(1) << 7 - return f & ^mask -} - -// String returns a human readable representation of Flags8. -func (f Flags8) String() string { - var ( - i int - val bool - buf []byte - ) - - // Make a prealloc est. based on longest-possible value - const prealloc = 1 + (len("false ") * 8) - 1 + 1 - buf = make([]byte, prealloc) - - buf[i] = '{' - i++ - - val = f.Get0() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get1() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get2() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get3() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get4() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get5() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get6() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get7() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - buf[i-1] = '}' - buf = buf[:i] - - return *(*string)(unsafe.Pointer(&buf)) -} - -// GoString returns a more verbose human readable representation of Flags8. -func (f Flags8) GoString() string { - var ( - i int - val bool - buf []byte - ) - - // Make a prealloc est. based on longest-possible value - const prealloc = len("bitutil.Flags8{") + (len("7=false ") * 8) - 1 + 1 - buf = make([]byte, prealloc) - - i += copy(buf[i:], "bitutil.Flags8{") - - val = f.Get0() - i += copy(buf[i:], "0=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get1() - i += copy(buf[i:], "1=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get2() - i += copy(buf[i:], "2=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get3() - i += copy(buf[i:], "3=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get4() - i += copy(buf[i:], "4=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get5() - i += copy(buf[i:], "5=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get6() - i += copy(buf[i:], "6=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get7() - i += copy(buf[i:], "7=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - buf[i-1] = '}' - buf = buf[:i] - - return *(*string)(unsafe.Pointer(&buf)) -} - -// Flags16 is a type-casted unsigned integer with helper -// methods for easily managing up to 16 bit-flags. -type Flags16 uint16 - -// Get will fetch the flag bit value at index 'bit'. -func (f Flags16) Get(bit uint8) bool { - mask := Flags16(1) << bit - return (f&mask != 0) -} - -// Set will set the flag bit value at index 'bit'. -func (f Flags16) Set(bit uint8) Flags16 { - mask := Flags16(1) << bit - return f | mask -} - -// Unset will unset the flag bit value at index 'bit'. -func (f Flags16) Unset(bit uint8) Flags16 { - mask := Flags16(1) << bit - return f & ^mask -} - -// Get0 will fetch the flag bit value at index 0. -func (f Flags16) Get0() bool { - const mask = Flags16(1) << 0 - return (f&mask != 0) -} - -// Set0 will set the flag bit value at index 0. -func (f Flags16) Set0() Flags16 { - const mask = Flags16(1) << 0 - return f | mask -} - -// Unset0 will unset the flag bit value at index 0. -func (f Flags16) Unset0() Flags16 { - const mask = Flags16(1) << 0 - return f & ^mask -} - -// Get1 will fetch the flag bit value at index 1. -func (f Flags16) Get1() bool { - const mask = Flags16(1) << 1 - return (f&mask != 0) -} - -// Set1 will set the flag bit value at index 1. -func (f Flags16) Set1() Flags16 { - const mask = Flags16(1) << 1 - return f | mask -} - -// Unset1 will unset the flag bit value at index 1. -func (f Flags16) Unset1() Flags16 { - const mask = Flags16(1) << 1 - return f & ^mask -} - -// Get2 will fetch the flag bit value at index 2. -func (f Flags16) Get2() bool { - const mask = Flags16(1) << 2 - return (f&mask != 0) -} - -// Set2 will set the flag bit value at index 2. -func (f Flags16) Set2() Flags16 { - const mask = Flags16(1) << 2 - return f | mask -} - -// Unset2 will unset the flag bit value at index 2. -func (f Flags16) Unset2() Flags16 { - const mask = Flags16(1) << 2 - return f & ^mask -} - -// Get3 will fetch the flag bit value at index 3. -func (f Flags16) Get3() bool { - const mask = Flags16(1) << 3 - return (f&mask != 0) -} - -// Set3 will set the flag bit value at index 3. -func (f Flags16) Set3() Flags16 { - const mask = Flags16(1) << 3 - return f | mask -} - -// Unset3 will unset the flag bit value at index 3. -func (f Flags16) Unset3() Flags16 { - const mask = Flags16(1) << 3 - return f & ^mask -} - -// Get4 will fetch the flag bit value at index 4. -func (f Flags16) Get4() bool { - const mask = Flags16(1) << 4 - return (f&mask != 0) -} - -// Set4 will set the flag bit value at index 4. -func (f Flags16) Set4() Flags16 { - const mask = Flags16(1) << 4 - return f | mask -} - -// Unset4 will unset the flag bit value at index 4. -func (f Flags16) Unset4() Flags16 { - const mask = Flags16(1) << 4 - return f & ^mask -} - -// Get5 will fetch the flag bit value at index 5. -func (f Flags16) Get5() bool { - const mask = Flags16(1) << 5 - return (f&mask != 0) -} - -// Set5 will set the flag bit value at index 5. -func (f Flags16) Set5() Flags16 { - const mask = Flags16(1) << 5 - return f | mask -} - -// Unset5 will unset the flag bit value at index 5. -func (f Flags16) Unset5() Flags16 { - const mask = Flags16(1) << 5 - return f & ^mask -} - -// Get6 will fetch the flag bit value at index 6. -func (f Flags16) Get6() bool { - const mask = Flags16(1) << 6 - return (f&mask != 0) -} - -// Set6 will set the flag bit value at index 6. -func (f Flags16) Set6() Flags16 { - const mask = Flags16(1) << 6 - return f | mask -} - -// Unset6 will unset the flag bit value at index 6. -func (f Flags16) Unset6() Flags16 { - const mask = Flags16(1) << 6 - return f & ^mask -} - -// Get7 will fetch the flag bit value at index 7. -func (f Flags16) Get7() bool { - const mask = Flags16(1) << 7 - return (f&mask != 0) -} - -// Set7 will set the flag bit value at index 7. -func (f Flags16) Set7() Flags16 { - const mask = Flags16(1) << 7 - return f | mask -} - -// Unset7 will unset the flag bit value at index 7. -func (f Flags16) Unset7() Flags16 { - const mask = Flags16(1) << 7 - return f & ^mask -} - -// Get8 will fetch the flag bit value at index 8. -func (f Flags16) Get8() bool { - const mask = Flags16(1) << 8 - return (f&mask != 0) -} - -// Set8 will set the flag bit value at index 8. -func (f Flags16) Set8() Flags16 { - const mask = Flags16(1) << 8 - return f | mask -} - -// Unset8 will unset the flag bit value at index 8. -func (f Flags16) Unset8() Flags16 { - const mask = Flags16(1) << 8 - return f & ^mask -} - -// Get9 will fetch the flag bit value at index 9. -func (f Flags16) Get9() bool { - const mask = Flags16(1) << 9 - return (f&mask != 0) -} - -// Set9 will set the flag bit value at index 9. -func (f Flags16) Set9() Flags16 { - const mask = Flags16(1) << 9 - return f | mask -} - -// Unset9 will unset the flag bit value at index 9. -func (f Flags16) Unset9() Flags16 { - const mask = Flags16(1) << 9 - return f & ^mask -} - -// Get10 will fetch the flag bit value at index 10. -func (f Flags16) Get10() bool { - const mask = Flags16(1) << 10 - return (f&mask != 0) -} - -// Set10 will set the flag bit value at index 10. -func (f Flags16) Set10() Flags16 { - const mask = Flags16(1) << 10 - return f | mask -} - -// Unset10 will unset the flag bit value at index 10. -func (f Flags16) Unset10() Flags16 { - const mask = Flags16(1) << 10 - return f & ^mask -} - -// Get11 will fetch the flag bit value at index 11. -func (f Flags16) Get11() bool { - const mask = Flags16(1) << 11 - return (f&mask != 0) -} - -// Set11 will set the flag bit value at index 11. -func (f Flags16) Set11() Flags16 { - const mask = Flags16(1) << 11 - return f | mask -} - -// Unset11 will unset the flag bit value at index 11. -func (f Flags16) Unset11() Flags16 { - const mask = Flags16(1) << 11 - return f & ^mask -} - -// Get12 will fetch the flag bit value at index 12. -func (f Flags16) Get12() bool { - const mask = Flags16(1) << 12 - return (f&mask != 0) -} - -// Set12 will set the flag bit value at index 12. -func (f Flags16) Set12() Flags16 { - const mask = Flags16(1) << 12 - return f | mask -} - -// Unset12 will unset the flag bit value at index 12. -func (f Flags16) Unset12() Flags16 { - const mask = Flags16(1) << 12 - return f & ^mask -} - -// Get13 will fetch the flag bit value at index 13. -func (f Flags16) Get13() bool { - const mask = Flags16(1) << 13 - return (f&mask != 0) -} - -// Set13 will set the flag bit value at index 13. -func (f Flags16) Set13() Flags16 { - const mask = Flags16(1) << 13 - return f | mask -} - -// Unset13 will unset the flag bit value at index 13. -func (f Flags16) Unset13() Flags16 { - const mask = Flags16(1) << 13 - return f & ^mask -} - -// Get14 will fetch the flag bit value at index 14. -func (f Flags16) Get14() bool { - const mask = Flags16(1) << 14 - return (f&mask != 0) -} - -// Set14 will set the flag bit value at index 14. -func (f Flags16) Set14() Flags16 { - const mask = Flags16(1) << 14 - return f | mask -} - -// Unset14 will unset the flag bit value at index 14. -func (f Flags16) Unset14() Flags16 { - const mask = Flags16(1) << 14 - return f & ^mask -} - -// Get15 will fetch the flag bit value at index 15. -func (f Flags16) Get15() bool { - const mask = Flags16(1) << 15 - return (f&mask != 0) -} - -// Set15 will set the flag bit value at index 15. -func (f Flags16) Set15() Flags16 { - const mask = Flags16(1) << 15 - return f | mask -} - -// Unset15 will unset the flag bit value at index 15. -func (f Flags16) Unset15() Flags16 { - const mask = Flags16(1) << 15 - return f & ^mask -} - -// String returns a human readable representation of Flags16. -func (f Flags16) String() string { - var ( - i int - val bool - buf []byte - ) - - // Make a prealloc est. based on longest-possible value - const prealloc = 1 + (len("false ") * 16) - 1 + 1 - buf = make([]byte, prealloc) - - buf[i] = '{' - i++ - - val = f.Get0() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get1() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get2() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get3() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get4() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get5() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get6() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get7() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get8() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get9() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get10() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get11() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get12() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get13() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get14() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get15() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - buf[i-1] = '}' - buf = buf[:i] - - return *(*string)(unsafe.Pointer(&buf)) -} - -// GoString returns a more verbose human readable representation of Flags16. -func (f Flags16) GoString() string { - var ( - i int - val bool - buf []byte - ) - - // Make a prealloc est. based on longest-possible value - const prealloc = len("bitutil.Flags16{") + (len("15=false ") * 16) - 1 + 1 - buf = make([]byte, prealloc) - - i += copy(buf[i:], "bitutil.Flags16{") - - val = f.Get0() - i += copy(buf[i:], "0=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get1() - i += copy(buf[i:], "1=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get2() - i += copy(buf[i:], "2=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get3() - i += copy(buf[i:], "3=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get4() - i += copy(buf[i:], "4=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get5() - i += copy(buf[i:], "5=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get6() - i += copy(buf[i:], "6=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get7() - i += copy(buf[i:], "7=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get8() - i += copy(buf[i:], "8=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get9() - i += copy(buf[i:], "9=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get10() - i += copy(buf[i:], "10=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get11() - i += copy(buf[i:], "11=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get12() - i += copy(buf[i:], "12=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get13() - i += copy(buf[i:], "13=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get14() - i += copy(buf[i:], "14=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get15() - i += copy(buf[i:], "15=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - buf[i-1] = '}' - buf = buf[:i] - - return *(*string)(unsafe.Pointer(&buf)) -} - -// Flags32 is a type-casted unsigned integer with helper -// methods for easily managing up to 32 bit-flags. -type Flags32 uint32 - -// Get will fetch the flag bit value at index 'bit'. -func (f Flags32) Get(bit uint8) bool { - mask := Flags32(1) << bit - return (f&mask != 0) -} - -// Set will set the flag bit value at index 'bit'. -func (f Flags32) Set(bit uint8) Flags32 { - mask := Flags32(1) << bit - return f | mask -} - -// Unset will unset the flag bit value at index 'bit'. -func (f Flags32) Unset(bit uint8) Flags32 { - mask := Flags32(1) << bit - return f & ^mask -} - -// Get0 will fetch the flag bit value at index 0. -func (f Flags32) Get0() bool { - const mask = Flags32(1) << 0 - return (f&mask != 0) -} - -// Set0 will set the flag bit value at index 0. -func (f Flags32) Set0() Flags32 { - const mask = Flags32(1) << 0 - return f | mask -} - -// Unset0 will unset the flag bit value at index 0. -func (f Flags32) Unset0() Flags32 { - const mask = Flags32(1) << 0 - return f & ^mask -} - -// Get1 will fetch the flag bit value at index 1. -func (f Flags32) Get1() bool { - const mask = Flags32(1) << 1 - return (f&mask != 0) -} - -// Set1 will set the flag bit value at index 1. -func (f Flags32) Set1() Flags32 { - const mask = Flags32(1) << 1 - return f | mask -} - -// Unset1 will unset the flag bit value at index 1. -func (f Flags32) Unset1() Flags32 { - const mask = Flags32(1) << 1 - return f & ^mask -} - -// Get2 will fetch the flag bit value at index 2. -func (f Flags32) Get2() bool { - const mask = Flags32(1) << 2 - return (f&mask != 0) -} - -// Set2 will set the flag bit value at index 2. -func (f Flags32) Set2() Flags32 { - const mask = Flags32(1) << 2 - return f | mask -} - -// Unset2 will unset the flag bit value at index 2. -func (f Flags32) Unset2() Flags32 { - const mask = Flags32(1) << 2 - return f & ^mask -} - -// Get3 will fetch the flag bit value at index 3. -func (f Flags32) Get3() bool { - const mask = Flags32(1) << 3 - return (f&mask != 0) -} - -// Set3 will set the flag bit value at index 3. -func (f Flags32) Set3() Flags32 { - const mask = Flags32(1) << 3 - return f | mask -} - -// Unset3 will unset the flag bit value at index 3. -func (f Flags32) Unset3() Flags32 { - const mask = Flags32(1) << 3 - return f & ^mask -} - -// Get4 will fetch the flag bit value at index 4. -func (f Flags32) Get4() bool { - const mask = Flags32(1) << 4 - return (f&mask != 0) -} - -// Set4 will set the flag bit value at index 4. -func (f Flags32) Set4() Flags32 { - const mask = Flags32(1) << 4 - return f | mask -} - -// Unset4 will unset the flag bit value at index 4. -func (f Flags32) Unset4() Flags32 { - const mask = Flags32(1) << 4 - return f & ^mask -} - -// Get5 will fetch the flag bit value at index 5. -func (f Flags32) Get5() bool { - const mask = Flags32(1) << 5 - return (f&mask != 0) -} - -// Set5 will set the flag bit value at index 5. -func (f Flags32) Set5() Flags32 { - const mask = Flags32(1) << 5 - return f | mask -} - -// Unset5 will unset the flag bit value at index 5. -func (f Flags32) Unset5() Flags32 { - const mask = Flags32(1) << 5 - return f & ^mask -} - -// Get6 will fetch the flag bit value at index 6. -func (f Flags32) Get6() bool { - const mask = Flags32(1) << 6 - return (f&mask != 0) -} - -// Set6 will set the flag bit value at index 6. -func (f Flags32) Set6() Flags32 { - const mask = Flags32(1) << 6 - return f | mask -} - -// Unset6 will unset the flag bit value at index 6. -func (f Flags32) Unset6() Flags32 { - const mask = Flags32(1) << 6 - return f & ^mask -} - -// Get7 will fetch the flag bit value at index 7. -func (f Flags32) Get7() bool { - const mask = Flags32(1) << 7 - return (f&mask != 0) -} - -// Set7 will set the flag bit value at index 7. -func (f Flags32) Set7() Flags32 { - const mask = Flags32(1) << 7 - return f | mask -} - -// Unset7 will unset the flag bit value at index 7. -func (f Flags32) Unset7() Flags32 { - const mask = Flags32(1) << 7 - return f & ^mask -} - -// Get8 will fetch the flag bit value at index 8. -func (f Flags32) Get8() bool { - const mask = Flags32(1) << 8 - return (f&mask != 0) -} - -// Set8 will set the flag bit value at index 8. -func (f Flags32) Set8() Flags32 { - const mask = Flags32(1) << 8 - return f | mask -} - -// Unset8 will unset the flag bit value at index 8. -func (f Flags32) Unset8() Flags32 { - const mask = Flags32(1) << 8 - return f & ^mask -} - -// Get9 will fetch the flag bit value at index 9. -func (f Flags32) Get9() bool { - const mask = Flags32(1) << 9 - return (f&mask != 0) -} - -// Set9 will set the flag bit value at index 9. -func (f Flags32) Set9() Flags32 { - const mask = Flags32(1) << 9 - return f | mask -} - -// Unset9 will unset the flag bit value at index 9. -func (f Flags32) Unset9() Flags32 { - const mask = Flags32(1) << 9 - return f & ^mask -} - -// Get10 will fetch the flag bit value at index 10. -func (f Flags32) Get10() bool { - const mask = Flags32(1) << 10 - return (f&mask != 0) -} - -// Set10 will set the flag bit value at index 10. -func (f Flags32) Set10() Flags32 { - const mask = Flags32(1) << 10 - return f | mask -} - -// Unset10 will unset the flag bit value at index 10. -func (f Flags32) Unset10() Flags32 { - const mask = Flags32(1) << 10 - return f & ^mask -} - -// Get11 will fetch the flag bit value at index 11. -func (f Flags32) Get11() bool { - const mask = Flags32(1) << 11 - return (f&mask != 0) -} - -// Set11 will set the flag bit value at index 11. -func (f Flags32) Set11() Flags32 { - const mask = Flags32(1) << 11 - return f | mask -} - -// Unset11 will unset the flag bit value at index 11. -func (f Flags32) Unset11() Flags32 { - const mask = Flags32(1) << 11 - return f & ^mask -} - -// Get12 will fetch the flag bit value at index 12. -func (f Flags32) Get12() bool { - const mask = Flags32(1) << 12 - return (f&mask != 0) -} - -// Set12 will set the flag bit value at index 12. -func (f Flags32) Set12() Flags32 { - const mask = Flags32(1) << 12 - return f | mask -} - -// Unset12 will unset the flag bit value at index 12. -func (f Flags32) Unset12() Flags32 { - const mask = Flags32(1) << 12 - return f & ^mask -} - -// Get13 will fetch the flag bit value at index 13. -func (f Flags32) Get13() bool { - const mask = Flags32(1) << 13 - return (f&mask != 0) -} - -// Set13 will set the flag bit value at index 13. -func (f Flags32) Set13() Flags32 { - const mask = Flags32(1) << 13 - return f | mask -} - -// Unset13 will unset the flag bit value at index 13. -func (f Flags32) Unset13() Flags32 { - const mask = Flags32(1) << 13 - return f & ^mask -} - -// Get14 will fetch the flag bit value at index 14. -func (f Flags32) Get14() bool { - const mask = Flags32(1) << 14 - return (f&mask != 0) -} - -// Set14 will set the flag bit value at index 14. -func (f Flags32) Set14() Flags32 { - const mask = Flags32(1) << 14 - return f | mask -} - -// Unset14 will unset the flag bit value at index 14. -func (f Flags32) Unset14() Flags32 { - const mask = Flags32(1) << 14 - return f & ^mask -} - -// Get15 will fetch the flag bit value at index 15. -func (f Flags32) Get15() bool { - const mask = Flags32(1) << 15 - return (f&mask != 0) -} - -// Set15 will set the flag bit value at index 15. -func (f Flags32) Set15() Flags32 { - const mask = Flags32(1) << 15 - return f | mask -} - -// Unset15 will unset the flag bit value at index 15. -func (f Flags32) Unset15() Flags32 { - const mask = Flags32(1) << 15 - return f & ^mask -} - -// Get16 will fetch the flag bit value at index 16. -func (f Flags32) Get16() bool { - const mask = Flags32(1) << 16 - return (f&mask != 0) -} - -// Set16 will set the flag bit value at index 16. -func (f Flags32) Set16() Flags32 { - const mask = Flags32(1) << 16 - return f | mask -} - -// Unset16 will unset the flag bit value at index 16. -func (f Flags32) Unset16() Flags32 { - const mask = Flags32(1) << 16 - return f & ^mask -} - -// Get17 will fetch the flag bit value at index 17. -func (f Flags32) Get17() bool { - const mask = Flags32(1) << 17 - return (f&mask != 0) -} - -// Set17 will set the flag bit value at index 17. -func (f Flags32) Set17() Flags32 { - const mask = Flags32(1) << 17 - return f | mask -} - -// Unset17 will unset the flag bit value at index 17. -func (f Flags32) Unset17() Flags32 { - const mask = Flags32(1) << 17 - return f & ^mask -} - -// Get18 will fetch the flag bit value at index 18. -func (f Flags32) Get18() bool { - const mask = Flags32(1) << 18 - return (f&mask != 0) -} - -// Set18 will set the flag bit value at index 18. -func (f Flags32) Set18() Flags32 { - const mask = Flags32(1) << 18 - return f | mask -} - -// Unset18 will unset the flag bit value at index 18. -func (f Flags32) Unset18() Flags32 { - const mask = Flags32(1) << 18 - return f & ^mask -} - -// Get19 will fetch the flag bit value at index 19. -func (f Flags32) Get19() bool { - const mask = Flags32(1) << 19 - return (f&mask != 0) -} - -// Set19 will set the flag bit value at index 19. -func (f Flags32) Set19() Flags32 { - const mask = Flags32(1) << 19 - return f | mask -} - -// Unset19 will unset the flag bit value at index 19. -func (f Flags32) Unset19() Flags32 { - const mask = Flags32(1) << 19 - return f & ^mask -} - -// Get20 will fetch the flag bit value at index 20. -func (f Flags32) Get20() bool { - const mask = Flags32(1) << 20 - return (f&mask != 0) -} - -// Set20 will set the flag bit value at index 20. -func (f Flags32) Set20() Flags32 { - const mask = Flags32(1) << 20 - return f | mask -} - -// Unset20 will unset the flag bit value at index 20. -func (f Flags32) Unset20() Flags32 { - const mask = Flags32(1) << 20 - return f & ^mask -} - -// Get21 will fetch the flag bit value at index 21. -func (f Flags32) Get21() bool { - const mask = Flags32(1) << 21 - return (f&mask != 0) -} - -// Set21 will set the flag bit value at index 21. -func (f Flags32) Set21() Flags32 { - const mask = Flags32(1) << 21 - return f | mask -} - -// Unset21 will unset the flag bit value at index 21. -func (f Flags32) Unset21() Flags32 { - const mask = Flags32(1) << 21 - return f & ^mask -} - -// Get22 will fetch the flag bit value at index 22. -func (f Flags32) Get22() bool { - const mask = Flags32(1) << 22 - return (f&mask != 0) -} - -// Set22 will set the flag bit value at index 22. -func (f Flags32) Set22() Flags32 { - const mask = Flags32(1) << 22 - return f | mask -} - -// Unset22 will unset the flag bit value at index 22. -func (f Flags32) Unset22() Flags32 { - const mask = Flags32(1) << 22 - return f & ^mask -} - -// Get23 will fetch the flag bit value at index 23. -func (f Flags32) Get23() bool { - const mask = Flags32(1) << 23 - return (f&mask != 0) -} - -// Set23 will set the flag bit value at index 23. -func (f Flags32) Set23() Flags32 { - const mask = Flags32(1) << 23 - return f | mask -} - -// Unset23 will unset the flag bit value at index 23. -func (f Flags32) Unset23() Flags32 { - const mask = Flags32(1) << 23 - return f & ^mask -} - -// Get24 will fetch the flag bit value at index 24. -func (f Flags32) Get24() bool { - const mask = Flags32(1) << 24 - return (f&mask != 0) -} - -// Set24 will set the flag bit value at index 24. -func (f Flags32) Set24() Flags32 { - const mask = Flags32(1) << 24 - return f | mask -} - -// Unset24 will unset the flag bit value at index 24. -func (f Flags32) Unset24() Flags32 { - const mask = Flags32(1) << 24 - return f & ^mask -} - -// Get25 will fetch the flag bit value at index 25. -func (f Flags32) Get25() bool { - const mask = Flags32(1) << 25 - return (f&mask != 0) -} - -// Set25 will set the flag bit value at index 25. -func (f Flags32) Set25() Flags32 { - const mask = Flags32(1) << 25 - return f | mask -} - -// Unset25 will unset the flag bit value at index 25. -func (f Flags32) Unset25() Flags32 { - const mask = Flags32(1) << 25 - return f & ^mask -} - -// Get26 will fetch the flag bit value at index 26. -func (f Flags32) Get26() bool { - const mask = Flags32(1) << 26 - return (f&mask != 0) -} - -// Set26 will set the flag bit value at index 26. -func (f Flags32) Set26() Flags32 { - const mask = Flags32(1) << 26 - return f | mask -} - -// Unset26 will unset the flag bit value at index 26. -func (f Flags32) Unset26() Flags32 { - const mask = Flags32(1) << 26 - return f & ^mask -} - -// Get27 will fetch the flag bit value at index 27. -func (f Flags32) Get27() bool { - const mask = Flags32(1) << 27 - return (f&mask != 0) -} - -// Set27 will set the flag bit value at index 27. -func (f Flags32) Set27() Flags32 { - const mask = Flags32(1) << 27 - return f | mask -} - -// Unset27 will unset the flag bit value at index 27. -func (f Flags32) Unset27() Flags32 { - const mask = Flags32(1) << 27 - return f & ^mask -} - -// Get28 will fetch the flag bit value at index 28. -func (f Flags32) Get28() bool { - const mask = Flags32(1) << 28 - return (f&mask != 0) -} - -// Set28 will set the flag bit value at index 28. -func (f Flags32) Set28() Flags32 { - const mask = Flags32(1) << 28 - return f | mask -} - -// Unset28 will unset the flag bit value at index 28. -func (f Flags32) Unset28() Flags32 { - const mask = Flags32(1) << 28 - return f & ^mask -} - -// Get29 will fetch the flag bit value at index 29. -func (f Flags32) Get29() bool { - const mask = Flags32(1) << 29 - return (f&mask != 0) -} - -// Set29 will set the flag bit value at index 29. -func (f Flags32) Set29() Flags32 { - const mask = Flags32(1) << 29 - return f | mask -} - -// Unset29 will unset the flag bit value at index 29. -func (f Flags32) Unset29() Flags32 { - const mask = Flags32(1) << 29 - return f & ^mask -} - -// Get30 will fetch the flag bit value at index 30. -func (f Flags32) Get30() bool { - const mask = Flags32(1) << 30 - return (f&mask != 0) -} - -// Set30 will set the flag bit value at index 30. -func (f Flags32) Set30() Flags32 { - const mask = Flags32(1) << 30 - return f | mask -} - -// Unset30 will unset the flag bit value at index 30. -func (f Flags32) Unset30() Flags32 { - const mask = Flags32(1) << 30 - return f & ^mask -} - -// Get31 will fetch the flag bit value at index 31. -func (f Flags32) Get31() bool { - const mask = Flags32(1) << 31 - return (f&mask != 0) -} - -// Set31 will set the flag bit value at index 31. -func (f Flags32) Set31() Flags32 { - const mask = Flags32(1) << 31 - return f | mask -} - -// Unset31 will unset the flag bit value at index 31. -func (f Flags32) Unset31() Flags32 { - const mask = Flags32(1) << 31 - return f & ^mask -} - -// String returns a human readable representation of Flags32. -func (f Flags32) String() string { - var ( - i int - val bool - buf []byte - ) - - // Make a prealloc est. based on longest-possible value - const prealloc = 1 + (len("false ") * 32) - 1 + 1 - buf = make([]byte, prealloc) - - buf[i] = '{' - i++ - - val = f.Get0() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get1() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get2() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get3() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get4() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get5() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get6() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get7() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get8() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get9() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get10() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get11() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get12() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get13() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get14() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get15() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get16() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get17() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get18() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get19() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get20() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get21() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get22() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get23() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get24() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get25() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get26() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get27() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get28() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get29() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get30() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get31() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - buf[i-1] = '}' - buf = buf[:i] - - return *(*string)(unsafe.Pointer(&buf)) -} - -// GoString returns a more verbose human readable representation of Flags32. -func (f Flags32) GoString() string { - var ( - i int - val bool - buf []byte - ) - - // Make a prealloc est. based on longest-possible value - const prealloc = len("bitutil.Flags32{") + (len("31=false ") * 32) - 1 + 1 - buf = make([]byte, prealloc) - - i += copy(buf[i:], "bitutil.Flags32{") - - val = f.Get0() - i += copy(buf[i:], "0=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get1() - i += copy(buf[i:], "1=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get2() - i += copy(buf[i:], "2=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get3() - i += copy(buf[i:], "3=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get4() - i += copy(buf[i:], "4=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get5() - i += copy(buf[i:], "5=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get6() - i += copy(buf[i:], "6=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get7() - i += copy(buf[i:], "7=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get8() - i += copy(buf[i:], "8=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get9() - i += copy(buf[i:], "9=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get10() - i += copy(buf[i:], "10=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get11() - i += copy(buf[i:], "11=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get12() - i += copy(buf[i:], "12=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get13() - i += copy(buf[i:], "13=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get14() - i += copy(buf[i:], "14=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get15() - i += copy(buf[i:], "15=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get16() - i += copy(buf[i:], "16=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get17() - i += copy(buf[i:], "17=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get18() - i += copy(buf[i:], "18=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get19() - i += copy(buf[i:], "19=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get20() - i += copy(buf[i:], "20=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get21() - i += copy(buf[i:], "21=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get22() - i += copy(buf[i:], "22=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get23() - i += copy(buf[i:], "23=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get24() - i += copy(buf[i:], "24=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get25() - i += copy(buf[i:], "25=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get26() - i += copy(buf[i:], "26=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get27() - i += copy(buf[i:], "27=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get28() - i += copy(buf[i:], "28=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get29() - i += copy(buf[i:], "29=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get30() - i += copy(buf[i:], "30=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get31() - i += copy(buf[i:], "31=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - buf[i-1] = '}' - buf = buf[:i] - - return *(*string)(unsafe.Pointer(&buf)) -} - -// Flags64 is a type-casted unsigned integer with helper -// methods for easily managing up to 64 bit-flags. -type Flags64 uint64 - -// Get will fetch the flag bit value at index 'bit'. -func (f Flags64) Get(bit uint8) bool { - mask := Flags64(1) << bit - return (f&mask != 0) -} - -// Set will set the flag bit value at index 'bit'. -func (f Flags64) Set(bit uint8) Flags64 { - mask := Flags64(1) << bit - return f | mask -} - -// Unset will unset the flag bit value at index 'bit'. -func (f Flags64) Unset(bit uint8) Flags64 { - mask := Flags64(1) << bit - return f & ^mask -} - -// Get0 will fetch the flag bit value at index 0. -func (f Flags64) Get0() bool { - const mask = Flags64(1) << 0 - return (f&mask != 0) -} - -// Set0 will set the flag bit value at index 0. -func (f Flags64) Set0() Flags64 { - const mask = Flags64(1) << 0 - return f | mask -} - -// Unset0 will unset the flag bit value at index 0. -func (f Flags64) Unset0() Flags64 { - const mask = Flags64(1) << 0 - return f & ^mask -} - -// Get1 will fetch the flag bit value at index 1. -func (f Flags64) Get1() bool { - const mask = Flags64(1) << 1 - return (f&mask != 0) -} - -// Set1 will set the flag bit value at index 1. -func (f Flags64) Set1() Flags64 { - const mask = Flags64(1) << 1 - return f | mask -} - -// Unset1 will unset the flag bit value at index 1. -func (f Flags64) Unset1() Flags64 { - const mask = Flags64(1) << 1 - return f & ^mask -} - -// Get2 will fetch the flag bit value at index 2. -func (f Flags64) Get2() bool { - const mask = Flags64(1) << 2 - return (f&mask != 0) -} - -// Set2 will set the flag bit value at index 2. -func (f Flags64) Set2() Flags64 { - const mask = Flags64(1) << 2 - return f | mask -} - -// Unset2 will unset the flag bit value at index 2. -func (f Flags64) Unset2() Flags64 { - const mask = Flags64(1) << 2 - return f & ^mask -} - -// Get3 will fetch the flag bit value at index 3. -func (f Flags64) Get3() bool { - const mask = Flags64(1) << 3 - return (f&mask != 0) -} - -// Set3 will set the flag bit value at index 3. -func (f Flags64) Set3() Flags64 { - const mask = Flags64(1) << 3 - return f | mask -} - -// Unset3 will unset the flag bit value at index 3. -func (f Flags64) Unset3() Flags64 { - const mask = Flags64(1) << 3 - return f & ^mask -} - -// Get4 will fetch the flag bit value at index 4. -func (f Flags64) Get4() bool { - const mask = Flags64(1) << 4 - return (f&mask != 0) -} - -// Set4 will set the flag bit value at index 4. -func (f Flags64) Set4() Flags64 { - const mask = Flags64(1) << 4 - return f | mask -} - -// Unset4 will unset the flag bit value at index 4. -func (f Flags64) Unset4() Flags64 { - const mask = Flags64(1) << 4 - return f & ^mask -} - -// Get5 will fetch the flag bit value at index 5. -func (f Flags64) Get5() bool { - const mask = Flags64(1) << 5 - return (f&mask != 0) -} - -// Set5 will set the flag bit value at index 5. -func (f Flags64) Set5() Flags64 { - const mask = Flags64(1) << 5 - return f | mask -} - -// Unset5 will unset the flag bit value at index 5. -func (f Flags64) Unset5() Flags64 { - const mask = Flags64(1) << 5 - return f & ^mask -} - -// Get6 will fetch the flag bit value at index 6. -func (f Flags64) Get6() bool { - const mask = Flags64(1) << 6 - return (f&mask != 0) -} - -// Set6 will set the flag bit value at index 6. -func (f Flags64) Set6() Flags64 { - const mask = Flags64(1) << 6 - return f | mask -} - -// Unset6 will unset the flag bit value at index 6. -func (f Flags64) Unset6() Flags64 { - const mask = Flags64(1) << 6 - return f & ^mask -} - -// Get7 will fetch the flag bit value at index 7. -func (f Flags64) Get7() bool { - const mask = Flags64(1) << 7 - return (f&mask != 0) -} - -// Set7 will set the flag bit value at index 7. -func (f Flags64) Set7() Flags64 { - const mask = Flags64(1) << 7 - return f | mask -} - -// Unset7 will unset the flag bit value at index 7. -func (f Flags64) Unset7() Flags64 { - const mask = Flags64(1) << 7 - return f & ^mask -} - -// Get8 will fetch the flag bit value at index 8. -func (f Flags64) Get8() bool { - const mask = Flags64(1) << 8 - return (f&mask != 0) -} - -// Set8 will set the flag bit value at index 8. -func (f Flags64) Set8() Flags64 { - const mask = Flags64(1) << 8 - return f | mask -} - -// Unset8 will unset the flag bit value at index 8. -func (f Flags64) Unset8() Flags64 { - const mask = Flags64(1) << 8 - return f & ^mask -} - -// Get9 will fetch the flag bit value at index 9. -func (f Flags64) Get9() bool { - const mask = Flags64(1) << 9 - return (f&mask != 0) -} - -// Set9 will set the flag bit value at index 9. -func (f Flags64) Set9() Flags64 { - const mask = Flags64(1) << 9 - return f | mask -} - -// Unset9 will unset the flag bit value at index 9. -func (f Flags64) Unset9() Flags64 { - const mask = Flags64(1) << 9 - return f & ^mask -} - -// Get10 will fetch the flag bit value at index 10. -func (f Flags64) Get10() bool { - const mask = Flags64(1) << 10 - return (f&mask != 0) -} - -// Set10 will set the flag bit value at index 10. -func (f Flags64) Set10() Flags64 { - const mask = Flags64(1) << 10 - return f | mask -} - -// Unset10 will unset the flag bit value at index 10. -func (f Flags64) Unset10() Flags64 { - const mask = Flags64(1) << 10 - return f & ^mask -} - -// Get11 will fetch the flag bit value at index 11. -func (f Flags64) Get11() bool { - const mask = Flags64(1) << 11 - return (f&mask != 0) -} - -// Set11 will set the flag bit value at index 11. -func (f Flags64) Set11() Flags64 { - const mask = Flags64(1) << 11 - return f | mask -} - -// Unset11 will unset the flag bit value at index 11. -func (f Flags64) Unset11() Flags64 { - const mask = Flags64(1) << 11 - return f & ^mask -} - -// Get12 will fetch the flag bit value at index 12. -func (f Flags64) Get12() bool { - const mask = Flags64(1) << 12 - return (f&mask != 0) -} - -// Set12 will set the flag bit value at index 12. -func (f Flags64) Set12() Flags64 { - const mask = Flags64(1) << 12 - return f | mask -} - -// Unset12 will unset the flag bit value at index 12. -func (f Flags64) Unset12() Flags64 { - const mask = Flags64(1) << 12 - return f & ^mask -} - -// Get13 will fetch the flag bit value at index 13. -func (f Flags64) Get13() bool { - const mask = Flags64(1) << 13 - return (f&mask != 0) -} - -// Set13 will set the flag bit value at index 13. -func (f Flags64) Set13() Flags64 { - const mask = Flags64(1) << 13 - return f | mask -} - -// Unset13 will unset the flag bit value at index 13. -func (f Flags64) Unset13() Flags64 { - const mask = Flags64(1) << 13 - return f & ^mask -} - -// Get14 will fetch the flag bit value at index 14. -func (f Flags64) Get14() bool { - const mask = Flags64(1) << 14 - return (f&mask != 0) -} - -// Set14 will set the flag bit value at index 14. -func (f Flags64) Set14() Flags64 { - const mask = Flags64(1) << 14 - return f | mask -} - -// Unset14 will unset the flag bit value at index 14. -func (f Flags64) Unset14() Flags64 { - const mask = Flags64(1) << 14 - return f & ^mask -} - -// Get15 will fetch the flag bit value at index 15. -func (f Flags64) Get15() bool { - const mask = Flags64(1) << 15 - return (f&mask != 0) -} - -// Set15 will set the flag bit value at index 15. -func (f Flags64) Set15() Flags64 { - const mask = Flags64(1) << 15 - return f | mask -} - -// Unset15 will unset the flag bit value at index 15. -func (f Flags64) Unset15() Flags64 { - const mask = Flags64(1) << 15 - return f & ^mask -} - -// Get16 will fetch the flag bit value at index 16. -func (f Flags64) Get16() bool { - const mask = Flags64(1) << 16 - return (f&mask != 0) -} - -// Set16 will set the flag bit value at index 16. -func (f Flags64) Set16() Flags64 { - const mask = Flags64(1) << 16 - return f | mask -} - -// Unset16 will unset the flag bit value at index 16. -func (f Flags64) Unset16() Flags64 { - const mask = Flags64(1) << 16 - return f & ^mask -} - -// Get17 will fetch the flag bit value at index 17. -func (f Flags64) Get17() bool { - const mask = Flags64(1) << 17 - return (f&mask != 0) -} - -// Set17 will set the flag bit value at index 17. -func (f Flags64) Set17() Flags64 { - const mask = Flags64(1) << 17 - return f | mask -} - -// Unset17 will unset the flag bit value at index 17. -func (f Flags64) Unset17() Flags64 { - const mask = Flags64(1) << 17 - return f & ^mask -} - -// Get18 will fetch the flag bit value at index 18. -func (f Flags64) Get18() bool { - const mask = Flags64(1) << 18 - return (f&mask != 0) -} - -// Set18 will set the flag bit value at index 18. -func (f Flags64) Set18() Flags64 { - const mask = Flags64(1) << 18 - return f | mask -} - -// Unset18 will unset the flag bit value at index 18. -func (f Flags64) Unset18() Flags64 { - const mask = Flags64(1) << 18 - return f & ^mask -} - -// Get19 will fetch the flag bit value at index 19. -func (f Flags64) Get19() bool { - const mask = Flags64(1) << 19 - return (f&mask != 0) -} - -// Set19 will set the flag bit value at index 19. -func (f Flags64) Set19() Flags64 { - const mask = Flags64(1) << 19 - return f | mask -} - -// Unset19 will unset the flag bit value at index 19. -func (f Flags64) Unset19() Flags64 { - const mask = Flags64(1) << 19 - return f & ^mask -} - -// Get20 will fetch the flag bit value at index 20. -func (f Flags64) Get20() bool { - const mask = Flags64(1) << 20 - return (f&mask != 0) -} - -// Set20 will set the flag bit value at index 20. -func (f Flags64) Set20() Flags64 { - const mask = Flags64(1) << 20 - return f | mask -} - -// Unset20 will unset the flag bit value at index 20. -func (f Flags64) Unset20() Flags64 { - const mask = Flags64(1) << 20 - return f & ^mask -} - -// Get21 will fetch the flag bit value at index 21. -func (f Flags64) Get21() bool { - const mask = Flags64(1) << 21 - return (f&mask != 0) -} - -// Set21 will set the flag bit value at index 21. -func (f Flags64) Set21() Flags64 { - const mask = Flags64(1) << 21 - return f | mask -} - -// Unset21 will unset the flag bit value at index 21. -func (f Flags64) Unset21() Flags64 { - const mask = Flags64(1) << 21 - return f & ^mask -} - -// Get22 will fetch the flag bit value at index 22. -func (f Flags64) Get22() bool { - const mask = Flags64(1) << 22 - return (f&mask != 0) -} - -// Set22 will set the flag bit value at index 22. -func (f Flags64) Set22() Flags64 { - const mask = Flags64(1) << 22 - return f | mask -} - -// Unset22 will unset the flag bit value at index 22. -func (f Flags64) Unset22() Flags64 { - const mask = Flags64(1) << 22 - return f & ^mask -} - -// Get23 will fetch the flag bit value at index 23. -func (f Flags64) Get23() bool { - const mask = Flags64(1) << 23 - return (f&mask != 0) -} - -// Set23 will set the flag bit value at index 23. -func (f Flags64) Set23() Flags64 { - const mask = Flags64(1) << 23 - return f | mask -} - -// Unset23 will unset the flag bit value at index 23. -func (f Flags64) Unset23() Flags64 { - const mask = Flags64(1) << 23 - return f & ^mask -} - -// Get24 will fetch the flag bit value at index 24. -func (f Flags64) Get24() bool { - const mask = Flags64(1) << 24 - return (f&mask != 0) -} - -// Set24 will set the flag bit value at index 24. -func (f Flags64) Set24() Flags64 { - const mask = Flags64(1) << 24 - return f | mask -} - -// Unset24 will unset the flag bit value at index 24. -func (f Flags64) Unset24() Flags64 { - const mask = Flags64(1) << 24 - return f & ^mask -} - -// Get25 will fetch the flag bit value at index 25. -func (f Flags64) Get25() bool { - const mask = Flags64(1) << 25 - return (f&mask != 0) -} - -// Set25 will set the flag bit value at index 25. -func (f Flags64) Set25() Flags64 { - const mask = Flags64(1) << 25 - return f | mask -} - -// Unset25 will unset the flag bit value at index 25. -func (f Flags64) Unset25() Flags64 { - const mask = Flags64(1) << 25 - return f & ^mask -} - -// Get26 will fetch the flag bit value at index 26. -func (f Flags64) Get26() bool { - const mask = Flags64(1) << 26 - return (f&mask != 0) -} - -// Set26 will set the flag bit value at index 26. -func (f Flags64) Set26() Flags64 { - const mask = Flags64(1) << 26 - return f | mask -} - -// Unset26 will unset the flag bit value at index 26. -func (f Flags64) Unset26() Flags64 { - const mask = Flags64(1) << 26 - return f & ^mask -} - -// Get27 will fetch the flag bit value at index 27. -func (f Flags64) Get27() bool { - const mask = Flags64(1) << 27 - return (f&mask != 0) -} - -// Set27 will set the flag bit value at index 27. -func (f Flags64) Set27() Flags64 { - const mask = Flags64(1) << 27 - return f | mask -} - -// Unset27 will unset the flag bit value at index 27. -func (f Flags64) Unset27() Flags64 { - const mask = Flags64(1) << 27 - return f & ^mask -} - -// Get28 will fetch the flag bit value at index 28. -func (f Flags64) Get28() bool { - const mask = Flags64(1) << 28 - return (f&mask != 0) -} - -// Set28 will set the flag bit value at index 28. -func (f Flags64) Set28() Flags64 { - const mask = Flags64(1) << 28 - return f | mask -} - -// Unset28 will unset the flag bit value at index 28. -func (f Flags64) Unset28() Flags64 { - const mask = Flags64(1) << 28 - return f & ^mask -} - -// Get29 will fetch the flag bit value at index 29. -func (f Flags64) Get29() bool { - const mask = Flags64(1) << 29 - return (f&mask != 0) -} - -// Set29 will set the flag bit value at index 29. -func (f Flags64) Set29() Flags64 { - const mask = Flags64(1) << 29 - return f | mask -} - -// Unset29 will unset the flag bit value at index 29. -func (f Flags64) Unset29() Flags64 { - const mask = Flags64(1) << 29 - return f & ^mask -} - -// Get30 will fetch the flag bit value at index 30. -func (f Flags64) Get30() bool { - const mask = Flags64(1) << 30 - return (f&mask != 0) -} - -// Set30 will set the flag bit value at index 30. -func (f Flags64) Set30() Flags64 { - const mask = Flags64(1) << 30 - return f | mask -} - -// Unset30 will unset the flag bit value at index 30. -func (f Flags64) Unset30() Flags64 { - const mask = Flags64(1) << 30 - return f & ^mask -} - -// Get31 will fetch the flag bit value at index 31. -func (f Flags64) Get31() bool { - const mask = Flags64(1) << 31 - return (f&mask != 0) -} - -// Set31 will set the flag bit value at index 31. -func (f Flags64) Set31() Flags64 { - const mask = Flags64(1) << 31 - return f | mask -} - -// Unset31 will unset the flag bit value at index 31. -func (f Flags64) Unset31() Flags64 { - const mask = Flags64(1) << 31 - return f & ^mask -} - -// Get32 will fetch the flag bit value at index 32. -func (f Flags64) Get32() bool { - const mask = Flags64(1) << 32 - return (f&mask != 0) -} - -// Set32 will set the flag bit value at index 32. -func (f Flags64) Set32() Flags64 { - const mask = Flags64(1) << 32 - return f | mask -} - -// Unset32 will unset the flag bit value at index 32. -func (f Flags64) Unset32() Flags64 { - const mask = Flags64(1) << 32 - return f & ^mask -} - -// Get33 will fetch the flag bit value at index 33. -func (f Flags64) Get33() bool { - const mask = Flags64(1) << 33 - return (f&mask != 0) -} - -// Set33 will set the flag bit value at index 33. -func (f Flags64) Set33() Flags64 { - const mask = Flags64(1) << 33 - return f | mask -} - -// Unset33 will unset the flag bit value at index 33. -func (f Flags64) Unset33() Flags64 { - const mask = Flags64(1) << 33 - return f & ^mask -} - -// Get34 will fetch the flag bit value at index 34. -func (f Flags64) Get34() bool { - const mask = Flags64(1) << 34 - return (f&mask != 0) -} - -// Set34 will set the flag bit value at index 34. -func (f Flags64) Set34() Flags64 { - const mask = Flags64(1) << 34 - return f | mask -} - -// Unset34 will unset the flag bit value at index 34. -func (f Flags64) Unset34() Flags64 { - const mask = Flags64(1) << 34 - return f & ^mask -} - -// Get35 will fetch the flag bit value at index 35. -func (f Flags64) Get35() bool { - const mask = Flags64(1) << 35 - return (f&mask != 0) -} - -// Set35 will set the flag bit value at index 35. -func (f Flags64) Set35() Flags64 { - const mask = Flags64(1) << 35 - return f | mask -} - -// Unset35 will unset the flag bit value at index 35. -func (f Flags64) Unset35() Flags64 { - const mask = Flags64(1) << 35 - return f & ^mask -} - -// Get36 will fetch the flag bit value at index 36. -func (f Flags64) Get36() bool { - const mask = Flags64(1) << 36 - return (f&mask != 0) -} - -// Set36 will set the flag bit value at index 36. -func (f Flags64) Set36() Flags64 { - const mask = Flags64(1) << 36 - return f | mask -} - -// Unset36 will unset the flag bit value at index 36. -func (f Flags64) Unset36() Flags64 { - const mask = Flags64(1) << 36 - return f & ^mask -} - -// Get37 will fetch the flag bit value at index 37. -func (f Flags64) Get37() bool { - const mask = Flags64(1) << 37 - return (f&mask != 0) -} - -// Set37 will set the flag bit value at index 37. -func (f Flags64) Set37() Flags64 { - const mask = Flags64(1) << 37 - return f | mask -} - -// Unset37 will unset the flag bit value at index 37. -func (f Flags64) Unset37() Flags64 { - const mask = Flags64(1) << 37 - return f & ^mask -} - -// Get38 will fetch the flag bit value at index 38. -func (f Flags64) Get38() bool { - const mask = Flags64(1) << 38 - return (f&mask != 0) -} - -// Set38 will set the flag bit value at index 38. -func (f Flags64) Set38() Flags64 { - const mask = Flags64(1) << 38 - return f | mask -} - -// Unset38 will unset the flag bit value at index 38. -func (f Flags64) Unset38() Flags64 { - const mask = Flags64(1) << 38 - return f & ^mask -} - -// Get39 will fetch the flag bit value at index 39. -func (f Flags64) Get39() bool { - const mask = Flags64(1) << 39 - return (f&mask != 0) -} - -// Set39 will set the flag bit value at index 39. -func (f Flags64) Set39() Flags64 { - const mask = Flags64(1) << 39 - return f | mask -} - -// Unset39 will unset the flag bit value at index 39. -func (f Flags64) Unset39() Flags64 { - const mask = Flags64(1) << 39 - return f & ^mask -} - -// Get40 will fetch the flag bit value at index 40. -func (f Flags64) Get40() bool { - const mask = Flags64(1) << 40 - return (f&mask != 0) -} - -// Set40 will set the flag bit value at index 40. -func (f Flags64) Set40() Flags64 { - const mask = Flags64(1) << 40 - return f | mask -} - -// Unset40 will unset the flag bit value at index 40. -func (f Flags64) Unset40() Flags64 { - const mask = Flags64(1) << 40 - return f & ^mask -} - -// Get41 will fetch the flag bit value at index 41. -func (f Flags64) Get41() bool { - const mask = Flags64(1) << 41 - return (f&mask != 0) -} - -// Set41 will set the flag bit value at index 41. -func (f Flags64) Set41() Flags64 { - const mask = Flags64(1) << 41 - return f | mask -} - -// Unset41 will unset the flag bit value at index 41. -func (f Flags64) Unset41() Flags64 { - const mask = Flags64(1) << 41 - return f & ^mask -} - -// Get42 will fetch the flag bit value at index 42. -func (f Flags64) Get42() bool { - const mask = Flags64(1) << 42 - return (f&mask != 0) -} - -// Set42 will set the flag bit value at index 42. -func (f Flags64) Set42() Flags64 { - const mask = Flags64(1) << 42 - return f | mask -} - -// Unset42 will unset the flag bit value at index 42. -func (f Flags64) Unset42() Flags64 { - const mask = Flags64(1) << 42 - return f & ^mask -} - -// Get43 will fetch the flag bit value at index 43. -func (f Flags64) Get43() bool { - const mask = Flags64(1) << 43 - return (f&mask != 0) -} - -// Set43 will set the flag bit value at index 43. -func (f Flags64) Set43() Flags64 { - const mask = Flags64(1) << 43 - return f | mask -} - -// Unset43 will unset the flag bit value at index 43. -func (f Flags64) Unset43() Flags64 { - const mask = Flags64(1) << 43 - return f & ^mask -} - -// Get44 will fetch the flag bit value at index 44. -func (f Flags64) Get44() bool { - const mask = Flags64(1) << 44 - return (f&mask != 0) -} - -// Set44 will set the flag bit value at index 44. -func (f Flags64) Set44() Flags64 { - const mask = Flags64(1) << 44 - return f | mask -} - -// Unset44 will unset the flag bit value at index 44. -func (f Flags64) Unset44() Flags64 { - const mask = Flags64(1) << 44 - return f & ^mask -} - -// Get45 will fetch the flag bit value at index 45. -func (f Flags64) Get45() bool { - const mask = Flags64(1) << 45 - return (f&mask != 0) -} - -// Set45 will set the flag bit value at index 45. -func (f Flags64) Set45() Flags64 { - const mask = Flags64(1) << 45 - return f | mask -} - -// Unset45 will unset the flag bit value at index 45. -func (f Flags64) Unset45() Flags64 { - const mask = Flags64(1) << 45 - return f & ^mask -} - -// Get46 will fetch the flag bit value at index 46. -func (f Flags64) Get46() bool { - const mask = Flags64(1) << 46 - return (f&mask != 0) -} - -// Set46 will set the flag bit value at index 46. -func (f Flags64) Set46() Flags64 { - const mask = Flags64(1) << 46 - return f | mask -} - -// Unset46 will unset the flag bit value at index 46. -func (f Flags64) Unset46() Flags64 { - const mask = Flags64(1) << 46 - return f & ^mask -} - -// Get47 will fetch the flag bit value at index 47. -func (f Flags64) Get47() bool { - const mask = Flags64(1) << 47 - return (f&mask != 0) -} - -// Set47 will set the flag bit value at index 47. -func (f Flags64) Set47() Flags64 { - const mask = Flags64(1) << 47 - return f | mask -} - -// Unset47 will unset the flag bit value at index 47. -func (f Flags64) Unset47() Flags64 { - const mask = Flags64(1) << 47 - return f & ^mask -} - -// Get48 will fetch the flag bit value at index 48. -func (f Flags64) Get48() bool { - const mask = Flags64(1) << 48 - return (f&mask != 0) -} - -// Set48 will set the flag bit value at index 48. -func (f Flags64) Set48() Flags64 { - const mask = Flags64(1) << 48 - return f | mask -} - -// Unset48 will unset the flag bit value at index 48. -func (f Flags64) Unset48() Flags64 { - const mask = Flags64(1) << 48 - return f & ^mask -} - -// Get49 will fetch the flag bit value at index 49. -func (f Flags64) Get49() bool { - const mask = Flags64(1) << 49 - return (f&mask != 0) -} - -// Set49 will set the flag bit value at index 49. -func (f Flags64) Set49() Flags64 { - const mask = Flags64(1) << 49 - return f | mask -} - -// Unset49 will unset the flag bit value at index 49. -func (f Flags64) Unset49() Flags64 { - const mask = Flags64(1) << 49 - return f & ^mask -} - -// Get50 will fetch the flag bit value at index 50. -func (f Flags64) Get50() bool { - const mask = Flags64(1) << 50 - return (f&mask != 0) -} - -// Set50 will set the flag bit value at index 50. -func (f Flags64) Set50() Flags64 { - const mask = Flags64(1) << 50 - return f | mask -} - -// Unset50 will unset the flag bit value at index 50. -func (f Flags64) Unset50() Flags64 { - const mask = Flags64(1) << 50 - return f & ^mask -} - -// Get51 will fetch the flag bit value at index 51. -func (f Flags64) Get51() bool { - const mask = Flags64(1) << 51 - return (f&mask != 0) -} - -// Set51 will set the flag bit value at index 51. -func (f Flags64) Set51() Flags64 { - const mask = Flags64(1) << 51 - return f | mask -} - -// Unset51 will unset the flag bit value at index 51. -func (f Flags64) Unset51() Flags64 { - const mask = Flags64(1) << 51 - return f & ^mask -} - -// Get52 will fetch the flag bit value at index 52. -func (f Flags64) Get52() bool { - const mask = Flags64(1) << 52 - return (f&mask != 0) -} - -// Set52 will set the flag bit value at index 52. -func (f Flags64) Set52() Flags64 { - const mask = Flags64(1) << 52 - return f | mask -} - -// Unset52 will unset the flag bit value at index 52. -func (f Flags64) Unset52() Flags64 { - const mask = Flags64(1) << 52 - return f & ^mask -} - -// Get53 will fetch the flag bit value at index 53. -func (f Flags64) Get53() bool { - const mask = Flags64(1) << 53 - return (f&mask != 0) -} - -// Set53 will set the flag bit value at index 53. -func (f Flags64) Set53() Flags64 { - const mask = Flags64(1) << 53 - return f | mask -} - -// Unset53 will unset the flag bit value at index 53. -func (f Flags64) Unset53() Flags64 { - const mask = Flags64(1) << 53 - return f & ^mask -} - -// Get54 will fetch the flag bit value at index 54. -func (f Flags64) Get54() bool { - const mask = Flags64(1) << 54 - return (f&mask != 0) -} - -// Set54 will set the flag bit value at index 54. -func (f Flags64) Set54() Flags64 { - const mask = Flags64(1) << 54 - return f | mask -} - -// Unset54 will unset the flag bit value at index 54. -func (f Flags64) Unset54() Flags64 { - const mask = Flags64(1) << 54 - return f & ^mask -} - -// Get55 will fetch the flag bit value at index 55. -func (f Flags64) Get55() bool { - const mask = Flags64(1) << 55 - return (f&mask != 0) -} - -// Set55 will set the flag bit value at index 55. -func (f Flags64) Set55() Flags64 { - const mask = Flags64(1) << 55 - return f | mask -} - -// Unset55 will unset the flag bit value at index 55. -func (f Flags64) Unset55() Flags64 { - const mask = Flags64(1) << 55 - return f & ^mask -} - -// Get56 will fetch the flag bit value at index 56. -func (f Flags64) Get56() bool { - const mask = Flags64(1) << 56 - return (f&mask != 0) -} - -// Set56 will set the flag bit value at index 56. -func (f Flags64) Set56() Flags64 { - const mask = Flags64(1) << 56 - return f | mask -} - -// Unset56 will unset the flag bit value at index 56. -func (f Flags64) Unset56() Flags64 { - const mask = Flags64(1) << 56 - return f & ^mask -} - -// Get57 will fetch the flag bit value at index 57. -func (f Flags64) Get57() bool { - const mask = Flags64(1) << 57 - return (f&mask != 0) -} - -// Set57 will set the flag bit value at index 57. -func (f Flags64) Set57() Flags64 { - const mask = Flags64(1) << 57 - return f | mask -} - -// Unset57 will unset the flag bit value at index 57. -func (f Flags64) Unset57() Flags64 { - const mask = Flags64(1) << 57 - return f & ^mask -} - -// Get58 will fetch the flag bit value at index 58. -func (f Flags64) Get58() bool { - const mask = Flags64(1) << 58 - return (f&mask != 0) -} - -// Set58 will set the flag bit value at index 58. -func (f Flags64) Set58() Flags64 { - const mask = Flags64(1) << 58 - return f | mask -} - -// Unset58 will unset the flag bit value at index 58. -func (f Flags64) Unset58() Flags64 { - const mask = Flags64(1) << 58 - return f & ^mask -} - -// Get59 will fetch the flag bit value at index 59. -func (f Flags64) Get59() bool { - const mask = Flags64(1) << 59 - return (f&mask != 0) -} - -// Set59 will set the flag bit value at index 59. -func (f Flags64) Set59() Flags64 { - const mask = Flags64(1) << 59 - return f | mask -} - -// Unset59 will unset the flag bit value at index 59. -func (f Flags64) Unset59() Flags64 { - const mask = Flags64(1) << 59 - return f & ^mask -} - -// Get60 will fetch the flag bit value at index 60. -func (f Flags64) Get60() bool { - const mask = Flags64(1) << 60 - return (f&mask != 0) -} - -// Set60 will set the flag bit value at index 60. -func (f Flags64) Set60() Flags64 { - const mask = Flags64(1) << 60 - return f | mask -} - -// Unset60 will unset the flag bit value at index 60. -func (f Flags64) Unset60() Flags64 { - const mask = Flags64(1) << 60 - return f & ^mask -} - -// Get61 will fetch the flag bit value at index 61. -func (f Flags64) Get61() bool { - const mask = Flags64(1) << 61 - return (f&mask != 0) -} - -// Set61 will set the flag bit value at index 61. -func (f Flags64) Set61() Flags64 { - const mask = Flags64(1) << 61 - return f | mask -} - -// Unset61 will unset the flag bit value at index 61. -func (f Flags64) Unset61() Flags64 { - const mask = Flags64(1) << 61 - return f & ^mask -} - -// Get62 will fetch the flag bit value at index 62. -func (f Flags64) Get62() bool { - const mask = Flags64(1) << 62 - return (f&mask != 0) -} - -// Set62 will set the flag bit value at index 62. -func (f Flags64) Set62() Flags64 { - const mask = Flags64(1) << 62 - return f | mask -} - -// Unset62 will unset the flag bit value at index 62. -func (f Flags64) Unset62() Flags64 { - const mask = Flags64(1) << 62 - return f & ^mask -} - -// Get63 will fetch the flag bit value at index 63. -func (f Flags64) Get63() bool { - const mask = Flags64(1) << 63 - return (f&mask != 0) -} - -// Set63 will set the flag bit value at index 63. -func (f Flags64) Set63() Flags64 { - const mask = Flags64(1) << 63 - return f | mask -} - -// Unset63 will unset the flag bit value at index 63. -func (f Flags64) Unset63() Flags64 { - const mask = Flags64(1) << 63 - return f & ^mask -} - -// String returns a human readable representation of Flags64. -func (f Flags64) String() string { - var ( - i int - val bool - buf []byte - ) - - // Make a prealloc est. based on longest-possible value - const prealloc = 1 + (len("false ") * 64) - 1 + 1 - buf = make([]byte, prealloc) - - buf[i] = '{' - i++ - - val = f.Get0() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get1() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get2() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get3() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get4() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get5() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get6() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get7() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get8() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get9() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get10() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get11() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get12() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get13() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get14() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get15() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get16() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get17() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get18() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get19() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get20() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get21() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get22() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get23() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get24() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get25() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get26() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get27() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get28() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get29() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get30() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get31() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get32() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get33() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get34() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get35() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get36() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get37() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get38() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get39() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get40() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get41() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get42() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get43() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get44() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get45() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get46() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get47() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get48() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get49() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get50() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get51() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get52() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get53() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get54() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get55() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get56() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get57() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get58() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get59() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get60() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get61() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get62() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get63() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - buf[i-1] = '}' - buf = buf[:i] - - return *(*string)(unsafe.Pointer(&buf)) -} - -// GoString returns a more verbose human readable representation of Flags64. -func (f Flags64) GoString() string { - var ( - i int - val bool - buf []byte - ) - - // Make a prealloc est. based on longest-possible value - const prealloc = len("bitutil.Flags64{") + (len("63=false ") * 64) - 1 + 1 - buf = make([]byte, prealloc) - - i += copy(buf[i:], "bitutil.Flags64{") - - val = f.Get0() - i += copy(buf[i:], "0=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get1() - i += copy(buf[i:], "1=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get2() - i += copy(buf[i:], "2=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get3() - i += copy(buf[i:], "3=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get4() - i += copy(buf[i:], "4=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get5() - i += copy(buf[i:], "5=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get6() - i += copy(buf[i:], "6=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get7() - i += copy(buf[i:], "7=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get8() - i += copy(buf[i:], "8=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get9() - i += copy(buf[i:], "9=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get10() - i += copy(buf[i:], "10=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get11() - i += copy(buf[i:], "11=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get12() - i += copy(buf[i:], "12=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get13() - i += copy(buf[i:], "13=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get14() - i += copy(buf[i:], "14=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get15() - i += copy(buf[i:], "15=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get16() - i += copy(buf[i:], "16=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get17() - i += copy(buf[i:], "17=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get18() - i += copy(buf[i:], "18=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get19() - i += copy(buf[i:], "19=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get20() - i += copy(buf[i:], "20=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get21() - i += copy(buf[i:], "21=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get22() - i += copy(buf[i:], "22=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get23() - i += copy(buf[i:], "23=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get24() - i += copy(buf[i:], "24=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get25() - i += copy(buf[i:], "25=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get26() - i += copy(buf[i:], "26=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get27() - i += copy(buf[i:], "27=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get28() - i += copy(buf[i:], "28=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get29() - i += copy(buf[i:], "29=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get30() - i += copy(buf[i:], "30=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get31() - i += copy(buf[i:], "31=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get32() - i += copy(buf[i:], "32=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get33() - i += copy(buf[i:], "33=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get34() - i += copy(buf[i:], "34=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get35() - i += copy(buf[i:], "35=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get36() - i += copy(buf[i:], "36=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get37() - i += copy(buf[i:], "37=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get38() - i += copy(buf[i:], "38=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get39() - i += copy(buf[i:], "39=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get40() - i += copy(buf[i:], "40=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get41() - i += copy(buf[i:], "41=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get42() - i += copy(buf[i:], "42=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get43() - i += copy(buf[i:], "43=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get44() - i += copy(buf[i:], "44=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get45() - i += copy(buf[i:], "45=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get46() - i += copy(buf[i:], "46=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get47() - i += copy(buf[i:], "47=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get48() - i += copy(buf[i:], "48=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get49() - i += copy(buf[i:], "49=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get50() - i += copy(buf[i:], "50=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get51() - i += copy(buf[i:], "51=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get52() - i += copy(buf[i:], "52=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get53() - i += copy(buf[i:], "53=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get54() - i += copy(buf[i:], "54=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get55() - i += copy(buf[i:], "55=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get56() - i += copy(buf[i:], "56=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get57() - i += copy(buf[i:], "57=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get58() - i += copy(buf[i:], "58=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get59() - i += copy(buf[i:], "59=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get60() - i += copy(buf[i:], "60=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get61() - i += copy(buf[i:], "61=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get62() - i += copy(buf[i:], "62=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get63() - i += copy(buf[i:], "63=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - buf[i-1] = '}' - buf = buf[:i] - - return *(*string)(unsafe.Pointer(&buf)) -} - -func bool2str(b bool) string { - if b { - return "true" - } - return "false" -} diff --git a/vendor/codeberg.org/gruf/go-bitutil/flag.tpl b/vendor/codeberg.org/gruf/go-bitutil/flag.tpl deleted file mode 100644 index ac00bfa97..000000000 --- a/vendor/codeberg.org/gruf/go-bitutil/flag.tpl +++ /dev/null @@ -1,117 +0,0 @@ -package bitutil - -import ( - "strings" - "unsafe" -) - -{{ range $idx, $size := . }} - -// Flags{{ $size.Size }} is a type-casted unsigned integer with helper -// methods for easily managing up to {{ $size.Size }} bit-flags. -type Flags{{ $size.Size }} uint{{ $size.Size }} - -// Get will fetch the flag bit value at index 'bit'. -func (f Flags{{ $size.Size }}) Get(bit uint8) bool { - mask := Flags{{ $size.Size }}(1) << bit - return (f & mask != 0) -} - -// Set will set the flag bit value at index 'bit'. -func (f Flags{{ $size.Size }}) Set(bit uint8) Flags{{ $size.Size }} { - mask := Flags{{ $size.Size }}(1) << bit - return f | mask -} - -// Unset will unset the flag bit value at index 'bit'. -func (f Flags{{ $size.Size }}) Unset(bit uint8) Flags{{ $size.Size }} { - mask := Flags{{ $size.Size }}(1) << bit - return f & ^mask -} - -{{ range $idx := $size.Bits }} - -// Get{{ $idx }} will fetch the flag bit value at index {{ $idx }}. -func (f Flags{{ $size.Size }}) Get{{ $idx }}() bool { - const mask = Flags{{ $size.Size }}(1) << {{ $idx }} - return (f & mask != 0) -} - -// Set{{ $idx }} will set the flag bit value at index {{ $idx }}. -func (f Flags{{ $size.Size }}) Set{{ $idx }}() Flags{{ $size.Size }} { - const mask = Flags{{ $size.Size }}(1) << {{ $idx }} - return f | mask -} - -// Unset{{ $idx }} will unset the flag bit value at index {{ $idx }}. -func (f Flags{{ $size.Size }}) Unset{{ $idx }}() Flags{{ $size.Size }} { - const mask = Flags{{ $size.Size }}(1) << {{ $idx }} - return f & ^mask -} - -{{ end }} - -// String returns a human readable representation of Flags{{ $size.Size }}. -func (f Flags{{ $size.Size }}) String() string { - var ( - i int - val bool - buf []byte - ) - - // Make a prealloc est. based on longest-possible value - const prealloc = 1+(len("false ")*{{ $size.Size }})-1+1 - buf = make([]byte, prealloc) - - buf[i] = '{' - i++ - - {{ range $idx := .Bits }} - val = f.Get{{ $idx }}() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - {{ end }} - - buf[i-1] = '}' - buf = buf[:i] - - return *(*string)(unsafe.Pointer(&buf)) -} - -// GoString returns a more verbose human readable representation of Flags{{ $size.Size }}. -func (f Flags{{ $size.Size }})GoString() string { - var ( - i int - val bool - buf []byte - ) - - // Make a prealloc est. based on longest-possible value - const prealloc = len("bitutil.Flags{{ $size.Size }}{")+(len("{{ sub $size.Size 1 }}=false ")*{{ $size.Size }})-1+1 - buf = make([]byte, prealloc) - - i += copy(buf[i:], "bitutil.Flags{{ $size.Size }}{") - - {{ range $idx := .Bits }} - val = f.Get{{ $idx }}() - i += copy(buf[i:], "{{ $idx }}=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - {{ end }} - - buf[i-1] = '}' - buf = buf[:i] - - return *(*string)(unsafe.Pointer(&buf)) -} - -{{ end }} - -func bool2str(b bool) string { - if b { - return "true" - } - return "false" -} \ No newline at end of file diff --git a/vendor/codeberg.org/gruf/go-bitutil/flag_test.tpl b/vendor/codeberg.org/gruf/go-bitutil/flag_test.tpl deleted file mode 100644 index e85cc2dff..000000000 --- a/vendor/codeberg.org/gruf/go-bitutil/flag_test.tpl +++ /dev/null @@ -1,98 +0,0 @@ -package bitutil_test - -import ( - "strings" - "testing" - - "codeberg.org/gruf/go-bytes" -) - -{{ range $idx, $size := . }} - -func TestFlags{{ $size.Size }}Get(t *testing.T) { - var mask, flags bitutil.Flags{{ $size.Size }} - - {{ range $idx := $size.Bits }} - - mask = bitutil.Flags{{ $size.Size }}(1) << {{ $idx }} - - flags = 0 - - flags |= mask - if !flags.Get({{ $idx }}) { - t.Error("failed .Get() set Flags{{ $size.Size }} bit at index {{ $idx }}") - } - - flags = ^bitutil.Flags{{ $size.Size }}(0) - - flags &= ^mask - if flags.Get({{ $idx }}) { - t.Error("failed .Get() unset Flags{{ $size.Size }} bit at index {{ $idx }}") - } - - flags = 0 - - flags |= mask - if !flags.Get{{ $idx }}() { - t.Error("failed .Get{{ $idx }}() set Flags{{ $size.Size }} bit at index {{ $idx }}") - } - - flags = ^bitutil.Flags{{ $size.Size }}(0) - - flags &= ^mask - if flags.Get{{ $idx }}() { - t.Error("failed .Get{{ $idx }}() unset Flags{{ $size.Size }} bit at index {{ $idx }}") - } - - {{ end }} -} - -func TestFlags{{ $size.Size }}Set(t *testing.T) { - var mask, flags bitutil.Flags{{ $size.Size }} - - {{ range $idx := $size.Bits }} - - mask = bitutil.Flags{{ $size.Size }}(1) << {{ $idx }} - - flags = 0 - - flags = flags.Set({{ $idx }}) - if flags & mask == 0 { - t.Error("failed .Set() Flags{{ $size.Size }} bit at index {{ $idx }}") - } - - flags = 0 - - flags = flags.Set{{ $idx }}() - if flags & mask == 0 { - t.Error("failed .Set{{ $idx }}() Flags{{ $size.Size }} bit at index {{ $idx }}") - } - - {{ end }} -} - -func TestFlags{{ $size.Size }}Unset(t *testing.T) { - var mask, flags bitutil.Flags{{ $size.Size }} - - {{ range $idx := $size.Bits }} - - mask = bitutil.Flags{{ $size.Size }}(1) << {{ $idx }} - - flags = ^bitutil.Flags{{ $size.Size }}(0) - - flags = flags.Unset({{ $idx }}) - if flags & mask != 0 { - t.Error("failed .Unset() Flags{{ $size.Size }} bit at index {{ $idx }}") - } - - flags = ^bitutil.Flags{{ $size.Size }}(0) - - flags = flags.Unset{{ $idx }}() - if flags & mask != 0 { - t.Error("failed .Unset{{ $idx }}() Flags{{ $size.Size }} bit at index {{ $idx }}") - } - - {{ end }} -} - -{{ end }} \ No newline at end of file diff --git a/vendor/codeberg.org/gruf/go-bitutil/pack.go b/vendor/codeberg.org/gruf/go-bitutil/pack.go deleted file mode 100644 index 2a57d3294..000000000 --- a/vendor/codeberg.org/gruf/go-bitutil/pack.go +++ /dev/null @@ -1,85 +0,0 @@ -package bitutil - -// PackInt8s will pack two signed 8bit integers into an unsigned 16bit integer. -func PackInt8s(i1, i2 int8) uint16 { - const bits = 8 - const mask = (1 << bits) - 1 - return uint16(i1)<> bits), int8(i & mask) -} - -// PackInt16s will pack two signed 16bit integers into an unsigned 32bit integer. -func PackInt16s(i1, i2 int16) uint32 { - const bits = 16 - const mask = (1 << bits) - 1 - return uint32(i1)<> bits), int16(i & mask) -} - -// PackInt32s will pack two signed 32bit integers into an unsigned 64bit integer. -func PackInt32s(i1, i2 int32) uint64 { - const bits = 32 - const mask = (1 << bits) - 1 - return uint64(i1)<> bits), int32(i & mask) -} - -// PackUint8s will pack two unsigned 8bit integers into an unsigned 16bit integer. -func PackUint8s(u1, u2 uint8) uint16 { - const bits = 8 - const mask = (1 << bits) - 1 - return uint16(u1)<> bits), uint8(u & mask) -} - -// PackUint16s will pack two unsigned 16bit integers into an unsigned 32bit integer. -func PackUint16s(u1, u2 uint16) uint32 { - const bits = 16 - const mask = (1 << bits) - 1 - return uint32(u1)<> bits), uint16(u & mask) -} - -// PackUint32s will pack two unsigned 32bit integers into an unsigned 64bit integer. -func PackUint32s(u1, u2 uint32) uint64 { - const bits = 32 - const mask = (1 << bits) - 1 - return uint64(u1)<> bits), uint32(u & mask) -} diff --git a/vendor/codeberg.org/gruf/go-bitutil/test.tpl b/vendor/codeberg.org/gruf/go-bitutil/test.tpl deleted file mode 100644 index 4e659d81f..000000000 --- a/vendor/codeberg.org/gruf/go-bitutil/test.tpl +++ /dev/null @@ -1,60 +0,0 @@ -package atomics_test - -import ( - "atomic" - "unsafe" - "testing" - - "codeberg.org/gruf/go-atomics" -) - -func Test{{ .Name }}StoreLoad(t *testing.T) { - for _, test := range {{ .Name }}Tests { - val := atomics.New{{ .Name }}() - - val.Store(test.V1) - - if !({{ call .Compare "val.Load()" "test.V1" }}) { - t.Fatalf("failed testing .Store and .Load: expect=%v actual=%v", val.Load(), test.V1) - } - - val.Store(test.V2) - - if !({{ call .Compare "val.Load()" "test.V2" }}) { - t.Fatalf("failed testing .Store and .Load: expect=%v actual=%v", val.Load(), test.V2) - } - } -} - -func Test{{ .Name }}CAS(t *testing.T) { - for _, test := range {{ .Name }}Tests { - val := atomics.New{{ .Name }}() - - val.Store(test.V1) - - if val.CAS(test.V2, test.V1) { - t.Fatalf("failed testing negative .CAS: test=%+v state=%v", test, val.Load()) - } - - if !val.CAS(test.V1, test.V2) { - t.Fatalf("failed testing positive .CAS: test=%+v state=%v", test, val.Load()) - } - } -} - -func Test{{ .Name }}Swap(t *testing.T) { - for _, test := range {{ .Name }}Tests { - val := atomics.New{{ .Name }}() - - val.Store(test.V1) - - if !({{ call .Compare "val.Swap(test.V2)" "test.V1" }}) { - t.Fatal("failed testing .Swap") - } - - if !({{ call .Compare "val.Swap(test.V1)" "test.V2" }}) { - t.Fatal("failed testing .Swap") - } - } -} - diff --git a/vendor/codeberg.org/gruf/go-sched/job.go b/vendor/codeberg.org/gruf/go-sched/job.go index e94c00024..2531769d6 100644 --- a/vendor/codeberg.org/gruf/go-sched/job.go +++ b/vendor/codeberg.org/gruf/go-sched/job.go @@ -4,9 +4,9 @@ "reflect" "strconv" "strings" + "sync/atomic" "time" - - "codeberg.org/gruf/go-atomics" + "unsafe" ) // Job encapsulates logic for a scheduled job to be run according @@ -14,7 +14,7 @@ // holding onto a next execution time safely in a concurrent environment. type Job struct { id uint64 - next atomics.Time + next unsafe.Pointer // *time.Time timing Timing call func(time.Time) panic func(interface{}) @@ -33,9 +33,6 @@ func NewJob(fn func(now time.Time)) *Job { panic: func(i interface{}) { panic(i) }, } - // Init next time ptr - j.next.Store(zerotime) - return j } @@ -99,14 +96,20 @@ func (job *Job) OnPanic(fn func(interface{})) *Job { // Next returns the next time this Job is expected to run. func (job *Job) Next() time.Time { - return job.next.Load() + return loadTime(&job.next) } // Run will execute this Job and pass through given now time. func (job *Job) Run(now time.Time) { defer func() { - if r := recover(); r != nil { + switch r := recover(); { + case r == nil: + // no panic + case job != nil && + job.panic != nil: job.panic(r) + default: + panic(r) } }() job.call(now) @@ -120,10 +123,21 @@ func (job *Job) String() string { buf.WriteString(strconv.FormatUint(job.id, 10)) buf.WriteByte(' ') buf.WriteString("next=") - buf.WriteString(job.next.Load().Format(time.StampMicro)) + buf.WriteString(loadTime(&job.next).Format(time.StampMicro)) buf.WriteByte(' ') buf.WriteString("timing=") buf.WriteString(reflect.TypeOf(job.timing).String()) buf.WriteByte('}') return buf.String() } + +func loadTime(p *unsafe.Pointer) time.Time { + if p := atomic.LoadPointer(p); p != nil { + return *(*time.Time)(p) + } + return zerotime +} + +func storeTime(p *unsafe.Pointer, t time.Time) { + atomic.StorePointer(p, unsafe.Pointer(&t)) +} diff --git a/vendor/codeberg.org/gruf/go-sched/scheduler.go b/vendor/codeberg.org/gruf/go-sched/scheduler.go index 537e588fe..79913a9b3 100644 --- a/vendor/codeberg.org/gruf/go-sched/scheduler.go +++ b/vendor/codeberg.org/gruf/go-sched/scheduler.go @@ -225,7 +225,7 @@ func (sch *Scheduler) handle(v interface{}) { // Update the next call time next := v.timing.Next(now) - v.next.Store(next) + storeTime(&v.next, next) // Append this job to queued sch.jobs = append(sch.jobs, v) @@ -261,7 +261,7 @@ func (sch *Scheduler) schedule(now time.Time) { // Update the next call time next := job.timing.Next(now) - job.next.Store(next) + storeTime(&job.next, next) if next.IsZero() { // Zero time, this job is done and can be dropped diff --git a/vendor/modules.txt b/vendor/modules.txt index 26cd7850d..888895cad 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,9 +1,3 @@ -# codeberg.org/gruf/go-atomics v1.1.0 -## explicit; go 1.16 -codeberg.org/gruf/go-atomics -# codeberg.org/gruf/go-bitutil v1.1.0 -## explicit; go 1.19 -codeberg.org/gruf/go-bitutil # codeberg.org/gruf/go-bytes v1.0.2 ## explicit; go 1.14 codeberg.org/gruf/go-bytes @@ -59,10 +53,10 @@ codeberg.org/gruf/go-mimetypes # codeberg.org/gruf/go-mutexes v1.5.1 ## explicit; go 1.22.2 codeberg.org/gruf/go-mutexes -# codeberg.org/gruf/go-runners v1.6.2 +# codeberg.org/gruf/go-runners v1.6.3 ## explicit; go 1.19 codeberg.org/gruf/go-runners -# codeberg.org/gruf/go-sched v1.2.3 +# codeberg.org/gruf/go-sched v1.2.4 ## explicit; go 1.19 codeberg.org/gruf/go-sched # codeberg.org/gruf/go-storage v0.2.0