Update dependencies
This commit is contained in:
26
vendor/gvisor.dev/gvisor/pkg/bits/bits.go
vendored
Normal file
26
vendor/gvisor.dev/gvisor/pkg/bits/bits.go
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
// Copyright 2018 The gVisor Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Package bits includes all bit related types and operations.
|
||||
package bits
|
||||
|
||||
// AlignUp rounds a length up to an alignment. align must be a power of 2.
|
||||
func AlignUp(length int, align uint) int {
|
||||
return (length + int(align) - 1) & ^(int(align) - 1)
|
||||
}
|
||||
|
||||
// AlignDown rounds a length down to an alignment. align must be a power of 2.
|
||||
func AlignDown(length int, align uint) int {
|
||||
return length & ^(int(align) - 1)
|
||||
}
|
||||
33
vendor/gvisor.dev/gvisor/pkg/bits/bits32.go
vendored
Normal file
33
vendor/gvisor.dev/gvisor/pkg/bits/bits32.go
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
package bits
|
||||
|
||||
// IsOn returns true if *all* bits set in 'bits' are set in 'mask'.
|
||||
func IsOn32(mask, bits uint32) bool {
|
||||
return mask&bits == bits
|
||||
}
|
||||
|
||||
// IsAnyOn returns true if *any* bit set in 'bits' is set in 'mask'.
|
||||
func IsAnyOn32(mask, bits uint32) bool {
|
||||
return mask&bits != 0
|
||||
}
|
||||
|
||||
// Mask returns a T with all of the given bits set.
|
||||
func Mask32(is ...int) uint32 {
|
||||
ret := uint32(0)
|
||||
for _, i := range is {
|
||||
ret |= MaskOf32(i)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
// MaskOf is like Mask, but sets only a single bit (more efficiently).
|
||||
func MaskOf32(i int) uint32 {
|
||||
return uint32(1) << uint32(i)
|
||||
}
|
||||
|
||||
// IsPowerOfTwo returns true if v is power of 2.
|
||||
func IsPowerOfTwo32(v uint32) bool {
|
||||
if v == 0 {
|
||||
return false
|
||||
}
|
||||
return v&(v-1) == 0
|
||||
}
|
||||
33
vendor/gvisor.dev/gvisor/pkg/bits/bits64.go
vendored
Normal file
33
vendor/gvisor.dev/gvisor/pkg/bits/bits64.go
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
package bits
|
||||
|
||||
// IsOn returns true if *all* bits set in 'bits' are set in 'mask'.
|
||||
func IsOn64(mask, bits uint64) bool {
|
||||
return mask&bits == bits
|
||||
}
|
||||
|
||||
// IsAnyOn returns true if *any* bit set in 'bits' is set in 'mask'.
|
||||
func IsAnyOn64(mask, bits uint64) bool {
|
||||
return mask&bits != 0
|
||||
}
|
||||
|
||||
// Mask returns a T with all of the given bits set.
|
||||
func Mask64(is ...int) uint64 {
|
||||
ret := uint64(0)
|
||||
for _, i := range is {
|
||||
ret |= MaskOf64(i)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
// MaskOf is like Mask, but sets only a single bit (more efficiently).
|
||||
func MaskOf64(i int) uint64 {
|
||||
return uint64(1) << uint64(i)
|
||||
}
|
||||
|
||||
// IsPowerOfTwo returns true if v is power of 2.
|
||||
func IsPowerOfTwo64(v uint64) bool {
|
||||
if v == 0 {
|
||||
return false
|
||||
}
|
||||
return v&(v-1) == 0
|
||||
}
|
||||
8
vendor/gvisor.dev/gvisor/pkg/bits/bits_state_autogen.go
vendored
Normal file
8
vendor/gvisor.dev/gvisor/pkg/bits/bits_state_autogen.go
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
// automatically generated by stateify.
|
||||
|
||||
//go:build (amd64 || arm64) && !amd64 && !arm64
|
||||
// +build amd64 arm64
|
||||
// +build !amd64
|
||||
// +build !arm64
|
||||
|
||||
package bits
|
||||
37
vendor/gvisor.dev/gvisor/pkg/bits/uint64_arch.go
vendored
Normal file
37
vendor/gvisor.dev/gvisor/pkg/bits/uint64_arch.go
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
// Copyright 2018 The gVisor Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//go:build amd64 || arm64
|
||||
// +build amd64 arm64
|
||||
|
||||
package bits
|
||||
|
||||
// TrailingZeros64 returns the number of bits before the least significant 1
|
||||
// bit in x; in other words, it returns the index of the least significant 1
|
||||
// bit in x. If x is 0, TrailingZeros64 returns 64.
|
||||
func TrailingZeros64(x uint64) int
|
||||
|
||||
// MostSignificantOne64 returns the index of the most significant 1 bit in
|
||||
// x. If x is 0, MostSignificantOne64 returns 64.
|
||||
func MostSignificantOne64(x uint64) int
|
||||
|
||||
// ForEachSetBit64 calls f once for each set bit in x, with argument i equal to
|
||||
// the set bit's index.
|
||||
func ForEachSetBit64(x uint64, f func(i int)) {
|
||||
for x != 0 {
|
||||
i := TrailingZeros64(x)
|
||||
f(i)
|
||||
x &^= MaskOf64(i)
|
||||
}
|
||||
}
|
||||
32
vendor/gvisor.dev/gvisor/pkg/bits/uint64_arch_amd64_asm.s
vendored
Normal file
32
vendor/gvisor.dev/gvisor/pkg/bits/uint64_arch_amd64_asm.s
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
// Copyright 2018 The gVisor Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//go:build amd64
|
||||
// +build amd64
|
||||
|
||||
TEXT ·TrailingZeros64(SB),$0-16
|
||||
BSFQ x+0(FP), AX
|
||||
JNZ end
|
||||
MOVQ $64, AX
|
||||
end:
|
||||
MOVQ AX, ret+8(FP)
|
||||
RET
|
||||
|
||||
TEXT ·MostSignificantOne64(SB),$0-16
|
||||
BSRQ x+0(FP), AX
|
||||
JNZ end
|
||||
MOVQ $64, AX
|
||||
end:
|
||||
MOVQ AX, ret+8(FP)
|
||||
RET
|
||||
34
vendor/gvisor.dev/gvisor/pkg/bits/uint64_arch_arm64_asm.s
vendored
Normal file
34
vendor/gvisor.dev/gvisor/pkg/bits/uint64_arch_arm64_asm.s
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
// Copyright 2019 The gVisor Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//go:build arm64
|
||||
// +build arm64
|
||||
|
||||
TEXT ·TrailingZeros64(SB),$0-16
|
||||
MOVD x+0(FP), R0
|
||||
RBIT R0, R0
|
||||
CLZ R0, R0 // return 64 if x == 0
|
||||
MOVD R0, ret+8(FP)
|
||||
RET
|
||||
|
||||
TEXT ·MostSignificantOne64(SB),$0-16
|
||||
MOVD x+0(FP), R0
|
||||
CLZ R0, R0 // return 64 if x == 0
|
||||
MOVD $63, R1
|
||||
SUBS R0, R1, R0 // ret = 63 - CLZ
|
||||
BPL end
|
||||
MOVD $64, R0 // x == 0
|
||||
end:
|
||||
MOVD R0, ret+8(FP)
|
||||
RET
|
||||
56
vendor/gvisor.dev/gvisor/pkg/bits/uint64_arch_generic.go
vendored
Normal file
56
vendor/gvisor.dev/gvisor/pkg/bits/uint64_arch_generic.go
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
// Copyright 2018 The gVisor Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//go:build !amd64 && !arm64
|
||||
// +build !amd64,!arm64
|
||||
|
||||
package bits
|
||||
|
||||
// TrailingZeros64 returns the number of bits before the least significant 1
|
||||
// bit in x; in other words, it returns the index of the least significant 1
|
||||
// bit in x. If x is 0, TrailingZeros64 returns 64.
|
||||
func TrailingZeros64(x uint64) int {
|
||||
if x == 0 {
|
||||
return 64
|
||||
}
|
||||
i := 0
|
||||
for ; x&1 == 0; i++ {
|
||||
x >>= 1
|
||||
}
|
||||
return i
|
||||
}
|
||||
|
||||
// MostSignificantOne64 returns the index of the most significant 1 bit in
|
||||
// x. If x is 0, MostSignificantOne64 returns 64.
|
||||
func MostSignificantOne64(x uint64) int {
|
||||
if x == 0 {
|
||||
return 64
|
||||
}
|
||||
i := 63
|
||||
for ; x&(1<<63) == 0; i-- {
|
||||
x <<= 1
|
||||
}
|
||||
return i
|
||||
}
|
||||
|
||||
// ForEachSetBit64 calls f once for each set bit in x, with argument i equal to
|
||||
// the set bit's index.
|
||||
func ForEachSetBit64(x uint64, f func(i int)) {
|
||||
for i := 0; x != 0; i++ {
|
||||
if x&1 != 0 {
|
||||
f(i)
|
||||
}
|
||||
x >>= 1
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user