Moved to atomicbitops and renamed files

This commit is contained in:
Kevin Krakauer 2021-03-19 13:44:26 -07:00
parent 4c9340fcbf
commit 1e2ba26661
8 changed files with 13 additions and 8 deletions

View File

@ -5,6 +5,8 @@ package(licenses = ["notice"])
go_library(
name = "atomicbitops",
srcs = [
"aligned_32bit_unsafe.go",
"aligned_64bit.go",
"atomicbitops.go",
"atomicbitops_amd64.s",
"atomicbitops_arm64.s",

View File

@ -14,7 +14,7 @@
// +build arm 386
package tcpip
package atomicbitops
import (
"sync/atomic"

View File

@ -14,7 +14,7 @@
// +build !arm,!386
package tcpip
package atomicbitops
import "sync/atomic"

View File

@ -19,8 +19,6 @@ go_template_instance(
go_library(
name = "tcpip",
srcs = [
"aligned.go",
"aligned_unsafe.go",
"errors.go",
"sock_err_list.go",
"socketops.go",
@ -31,6 +29,7 @@ go_library(
],
visibility = ["//visibility:public"],
deps = [
"//pkg/atomicbitops",
"//pkg/sync",
"//pkg/tcpip/buffer",
"//pkg/waiter",

View File

@ -18,6 +18,7 @@ import (
"math"
"sync/atomic"
"gvisor.dev/gvisor/pkg/atomicbitops"
"gvisor.dev/gvisor/pkg/sync"
)
@ -213,7 +214,7 @@ type SocketOptions struct {
getSendBufferLimits GetSendBufferLimits `state:"manual"`
// sendBufferSize determines the send buffer size for this socket.
sendBufferSize AlignedAtomicInt64
sendBufferSize atomicbitops.AlignedAtomicInt64
// getReceiveBufferLimits provides the handler to get the min, default and
// max size for receive buffer. It is initialized at the creation time and

View File

@ -73,6 +73,7 @@ go_library(
],
visibility = ["//visibility:public"],
deps = [
"//pkg/atomicbitops",
"//pkg/ilist",
"//pkg/log",
"//pkg/rand",

View File

@ -29,6 +29,7 @@ import (
"time"
"golang.org/x/time/rate"
"gvisor.dev/gvisor/pkg/atomicbitops"
"gvisor.dev/gvisor/pkg/rand"
"gvisor.dev/gvisor/pkg/sync"
"gvisor.dev/gvisor/pkg/tcpip"
@ -65,10 +66,10 @@ type ResumableEndpoint interface {
}
// uniqueIDGenerator is a default unique ID generator.
type uniqueIDGenerator uint64
type uniqueIDGenerator atomicbitops.AlignedAtomicUint64
func (u *uniqueIDGenerator) UniqueID() uint64 {
return atomic.AddUint64((*uint64)(u), 1)
return ((*atomicbitops.AlignedAtomicUint64)(u)).Add(1)
}
// Stack is a networking stack, with all supported protocols, NICs, and route

View File

@ -40,6 +40,7 @@ import (
"sync/atomic"
"time"
"gvisor.dev/gvisor/pkg/atomicbitops"
"gvisor.dev/gvisor/pkg/sync"
"gvisor.dev/gvisor/pkg/waiter"
)
@ -1220,7 +1221,7 @@ type NetworkProtocolNumber uint32
// A StatCounter keeps track of a statistic.
type StatCounter struct {
count AlignedAtomicUint64
count atomicbitops.AlignedAtomicUint64
}
// Increment adds one to the counter.