summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2019-01-31 17:47:24 -0800
committerShentubot <shentubot@google.com>2019-01-31 17:49:14 -0800
commitfe1369ac98a4f1d8af5e8be6da71165339e52034 (patch)
tree89c1e4553a375b57e9999278613eb37f104e30a6
parent4e695adcd0c739101c3d50431ca18b1b911c9238 (diff)
Move package sync to third_party
PiperOrigin-RevId: 231889261 Change-Id: I482f1df055bcedf4edb9fe3fe9b8e9c80085f1a0
-rw-r--r--pkg/sentry/kernel/BUILD4
-rw-r--r--pkg/sentry/kernel/futex/BUILD2
-rw-r--r--pkg/sentry/kernel/task.go4
-rw-r--r--pkg/sentry/mm/BUILD2
-rw-r--r--pkg/sentry/mm/mm.go6
-rw-r--r--pkg/sentry/time/BUILD4
-rw-r--r--pkg/sync/atomicptrtest/atomicptr_test.go40
-rw-r--r--pkg/sync/memmove_unsafe.go32
-rw-r--r--pkg/sync/sync.go16
-rw-r--r--third_party/gvsync/BUILD (renamed from pkg/sync/BUILD)12
-rw-r--r--third_party/gvsync/LICENSE (renamed from pkg/sync/LICENSE)0
-rw-r--r--third_party/gvsync/README.md3
-rw-r--r--third_party/gvsync/atomicptr_unsafe.go (renamed from pkg/sync/atomicptr_unsafe.go)15
-rw-r--r--third_party/gvsync/atomicptrtest/BUILD (renamed from pkg/sync/atomicptrtest/BUILD)6
-rw-r--r--third_party/gvsync/atomicptrtest/atomicptr_test.go31
-rw-r--r--third_party/gvsync/downgradable_rwmutex_test.go (renamed from pkg/sync/downgradable_rwmutex_test.go)3
-rw-r--r--third_party/gvsync/downgradable_rwmutex_unsafe.go (renamed from pkg/sync/downgradable_rwmutex_unsafe.go)3
-rw-r--r--third_party/gvsync/gvsync.go7
-rw-r--r--third_party/gvsync/memmove_unsafe.go23
-rw-r--r--third_party/gvsync/norace_unsafe.go (renamed from pkg/sync/norace_unsafe.go)17
-rw-r--r--third_party/gvsync/race_unsafe.go (renamed from pkg/sync/race_unsafe.go)17
-rw-r--r--third_party/gvsync/seqatomic_unsafe.go (renamed from pkg/sync/seqatomic_unsafe.go)31
-rw-r--r--third_party/gvsync/seqatomictest/BUILD (renamed from pkg/sync/seqatomictest/BUILD)10
-rw-r--r--third_party/gvsync/seqatomictest/seqatomic_test.go (renamed from pkg/sync/seqatomictest/seqatomic_test.go)2
-rw-r--r--third_party/gvsync/seqcount.go (renamed from pkg/sync/seqcount.go)17
-rw-r--r--third_party/gvsync/seqcount_test.go (renamed from pkg/sync/seqcount_test.go)17
26 files changed, 124 insertions, 200 deletions
diff --git a/pkg/sentry/kernel/BUILD b/pkg/sentry/kernel/BUILD
index b230aff98..773cb8c91 100644
--- a/pkg/sentry/kernel/BUILD
+++ b/pkg/sentry/kernel/BUILD
@@ -34,7 +34,7 @@ go_template_instance(
out = "seqatomic_taskgoroutineschedinfo.go",
package = "kernel",
suffix = "TaskGoroutineSchedInfo",
- template = "//pkg/sync:generic_seqatomic",
+ template = "//third_party/gvsync:generic_seqatomic",
types = {
"Value": "TaskGoroutineSchedInfo",
},
@@ -183,12 +183,12 @@ go_library(
"//pkg/sentry/usermem",
"//pkg/state",
"//pkg/state/statefile",
- "//pkg/sync",
"//pkg/syserr",
"//pkg/syserror",
"//pkg/tcpip",
"//pkg/tcpip/stack",
"//pkg/waiter",
+ "//third_party/gvsync",
],
)
diff --git a/pkg/sentry/kernel/futex/BUILD b/pkg/sentry/kernel/futex/BUILD
index da24c36c1..91feeb5ed 100644
--- a/pkg/sentry/kernel/futex/BUILD
+++ b/pkg/sentry/kernel/futex/BUILD
@@ -8,7 +8,7 @@ go_template_instance(
out = "atomicptr_bucket.go",
package = "futex",
suffix = "Bucket",
- template = "//pkg/sync:generic_atomicptr",
+ template = "//third_party/gvsync:generic_atomicptr",
types = {
"Value": "bucket",
},
diff --git a/pkg/sentry/kernel/task.go b/pkg/sentry/kernel/task.go
index 2982bc5d1..702e40cce 100644
--- a/pkg/sentry/kernel/task.go
+++ b/pkg/sentry/kernel/task.go
@@ -34,7 +34,7 @@ import (
"gvisor.googlesource.com/gvisor/pkg/sentry/uniqueid"
"gvisor.googlesource.com/gvisor/pkg/sentry/usage"
"gvisor.googlesource.com/gvisor/pkg/sentry/usermem"
- ssync "gvisor.googlesource.com/gvisor/pkg/sync"
+ "gvisor.googlesource.com/gvisor/third_party/gvsync"
)
// Task represents a thread of execution in the untrusted app. It
@@ -81,7 +81,7 @@ type Task struct {
//
// gosched is protected by goschedSeq. gosched is owned by the task
// goroutine.
- goschedSeq ssync.SeqCount `state:"nosave"`
+ goschedSeq gvsync.SeqCount `state:"nosave"`
gosched TaskGoroutineSchedInfo
// yieldCount is the number of times the task goroutine has called
diff --git a/pkg/sentry/mm/BUILD b/pkg/sentry/mm/BUILD
index f679262d0..a85ffdef8 100644
--- a/pkg/sentry/mm/BUILD
+++ b/pkg/sentry/mm/BUILD
@@ -116,9 +116,9 @@ go_library(
"//pkg/sentry/safemem",
"//pkg/sentry/usage",
"//pkg/sentry/usermem",
- "//pkg/sync",
"//pkg/syserror",
"//pkg/tcpip/buffer",
+ "//third_party/gvsync",
],
)
diff --git a/pkg/sentry/mm/mm.go b/pkg/sentry/mm/mm.go
index 2154e7918..a69b8c7be 100644
--- a/pkg/sentry/mm/mm.go
+++ b/pkg/sentry/mm/mm.go
@@ -42,7 +42,7 @@ import (
"gvisor.googlesource.com/gvisor/pkg/sentry/platform"
"gvisor.googlesource.com/gvisor/pkg/sentry/safemem"
"gvisor.googlesource.com/gvisor/pkg/sentry/usermem"
- ssync "gvisor.googlesource.com/gvisor/pkg/sync"
+ "gvisor.googlesource.com/gvisor/third_party/gvsync"
)
// MemoryManager implements a virtual address space.
@@ -84,7 +84,7 @@ type MemoryManager struct {
users int32
// mappingMu is analogous to Linux's struct mm_struct::mmap_sem.
- mappingMu ssync.DowngradableRWMutex `state:"nosave"`
+ mappingMu gvsync.DowngradableRWMutex `state:"nosave"`
// vmas stores virtual memory areas. Since vmas are stored by value,
// clients should usually use vmaIterator.ValuePtr() instead of
@@ -121,7 +121,7 @@ type MemoryManager struct {
// activeMu is loosely analogous to Linux's struct
// mm_struct::page_table_lock.
- activeMu ssync.DowngradableRWMutex `state:"nosave"`
+ activeMu gvsync.DowngradableRWMutex `state:"nosave"`
// pmas stores platform mapping areas used to implement vmas. Since pmas
// are stored by value, clients should usually use pmaIterator.ValuePtr()
diff --git a/pkg/sentry/time/BUILD b/pkg/sentry/time/BUILD
index c4b6dcc63..b2f8f6832 100644
--- a/pkg/sentry/time/BUILD
+++ b/pkg/sentry/time/BUILD
@@ -9,7 +9,7 @@ go_template_instance(
out = "seqatomic_parameters.go",
package = "time",
suffix = "Parameters",
- template = "//pkg/sync:generic_seqatomic",
+ template = "//third_party/gvsync:generic_seqatomic",
types = {
"Value": "Parameters",
},
@@ -36,8 +36,8 @@ go_library(
deps = [
"//pkg/log",
"//pkg/metric",
- "//pkg/sync",
"//pkg/syserror",
+ "//third_party/gvsync",
],
)
diff --git a/pkg/sync/atomicptrtest/atomicptr_test.go b/pkg/sync/atomicptrtest/atomicptr_test.go
deleted file mode 100644
index 3262785ce..000000000
--- a/pkg/sync/atomicptrtest/atomicptr_test.go
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright 2018 Google LLC
-//
-// 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 atomicptr
-
-import (
- "testing"
-)
-
-func newInt(val int) *int {
- return &val
-}
-
-func TestAtomicPtr(t *testing.T) {
- var p AtomicPtrInt
- if got := p.Load(); got != nil {
- t.Errorf("initial value is %p (%v), wanted nil", got, got)
- }
- want := newInt(42)
- p.Store(want)
- if got := p.Load(); got != want {
- t.Errorf("wrong value: got %p (%v), wanted %p (%v)", got, got, want, want)
- }
- want = newInt(100)
- p.Store(want)
- if got := p.Load(); got != want {
- t.Errorf("wrong value: got %p (%v), wanted %p (%v)", got, got, want, want)
- }
-}
diff --git a/pkg/sync/memmove_unsafe.go b/pkg/sync/memmove_unsafe.go
deleted file mode 100644
index cd7a02dca..000000000
--- a/pkg/sync/memmove_unsafe.go
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright 2018 Google LLC
-//
-// 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 sync
-
-import (
- "unsafe"
-)
-
-// Memmove is exported for SeqAtomicLoad/SeqAtomicTryLoad<T>, which can't
-// define it because go_generics can't update the go:linkname annotation.
-// Furthermore, go:linkname silently doesn't work if the local name is exported
-// (this is of course undocumented), which is why this indirection is
-// necessary.
-func Memmove(to, from unsafe.Pointer, n uintptr) {
- memmove(to, from, n)
-}
-
-//go:linkname memmove runtime.memmove
-//go:noescape
-func memmove(to, from unsafe.Pointer, n uintptr)
diff --git a/pkg/sync/sync.go b/pkg/sync/sync.go
deleted file mode 100644
index 22c5348d7..000000000
--- a/pkg/sync/sync.go
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2018 Google LLC
-//
-// 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 sync provides synchronization primitives.
-package sync
diff --git a/pkg/sync/BUILD b/third_party/gvsync/BUILD
index 1624e681c..4764eaa83 100644
--- a/pkg/sync/BUILD
+++ b/third_party/gvsync/BUILD
@@ -1,4 +1,4 @@
-load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
+load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
package(
default_visibility = ["//:sandbox"],
@@ -27,24 +27,24 @@ go_template(
)
go_library(
- name = "sync",
+ name = "gvsync",
srcs = [
"downgradable_rwmutex_unsafe.go",
+ "gvsync.go",
"memmove_unsafe.go",
"norace_unsafe.go",
"race_unsafe.go",
"seqcount.go",
- "sync.go",
],
- importpath = "gvisor.googlesource.com/gvisor/pkg/sync",
+ importpath = "gvisor.googlesource.com/gvisor/third_party/gvsync",
)
go_test(
- name = "sync_test",
+ name = "gvsync_test",
size = "small",
srcs = [
"downgradable_rwmutex_test.go",
"seqcount_test.go",
],
- embed = [":sync"],
+ embed = [":gvsync"],
)
diff --git a/pkg/sync/LICENSE b/third_party/gvsync/LICENSE
index 6a66aea5e..6a66aea5e 100644
--- a/pkg/sync/LICENSE
+++ b/third_party/gvsync/LICENSE
diff --git a/third_party/gvsync/README.md b/third_party/gvsync/README.md
new file mode 100644
index 000000000..fcc7e6f44
--- /dev/null
+++ b/third_party/gvsync/README.md
@@ -0,0 +1,3 @@
+This package provides additional synchronization primitives not provided by the
+Go stdlib 'sync' package. It is partially derived from the upstream 'sync'
+package.
diff --git a/pkg/sync/atomicptr_unsafe.go b/third_party/gvsync/atomicptr_unsafe.go
index d943b7ff4..da9f16240 100644
--- a/pkg/sync/atomicptr_unsafe.go
+++ b/third_party/gvsync/atomicptr_unsafe.go
@@ -1,16 +1,7 @@
-// Copyright 2018 Google LLC
+// Copyright 2019 Google LLC
//
-// 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.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
// Package template doesn't exist. This file must be instantiated using the
// go_template_instance rule in tools/go_generics/defs.bzl.
diff --git a/pkg/sync/atomicptrtest/BUILD b/third_party/gvsync/atomicptrtest/BUILD
index 198fbb895..74c51fd18 100644
--- a/pkg/sync/atomicptrtest/BUILD
+++ b/third_party/gvsync/atomicptrtest/BUILD
@@ -1,4 +1,4 @@
-load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
+load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
package(licenses = ["notice"])
@@ -9,7 +9,7 @@ go_template_instance(
out = "atomicptr_int.go",
package = "atomicptr",
suffix = "Int",
- template = "//pkg/sync:generic_atomicptr",
+ template = "//third_party/gvsync:generic_atomicptr",
types = {
"Value": "int",
},
@@ -18,7 +18,7 @@ go_template_instance(
go_library(
name = "atomicptr",
srcs = ["atomicptr_int.go"],
- importpath = "gvisor.googlesource.com/gvisor/pkg/sync/atomicptr",
+ importpath = "gvisor.googlesource.com/gvisor/third_party/gvsync/atomicptr",
)
go_test(
diff --git a/third_party/gvsync/atomicptrtest/atomicptr_test.go b/third_party/gvsync/atomicptrtest/atomicptr_test.go
new file mode 100644
index 000000000..15d0936d4
--- /dev/null
+++ b/third_party/gvsync/atomicptrtest/atomicptr_test.go
@@ -0,0 +1,31 @@
+// Copyright 2019 Google LLC
+//
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package atomicptr
+
+import (
+ "testing"
+)
+
+func newInt(val int) *int {
+ return &val
+}
+
+func TestAtomicPtr(t *testing.T) {
+ var p AtomicPtrInt
+ if got := p.Load(); got != nil {
+ t.Errorf("initial value is %p (%v), wanted nil", got, got)
+ }
+ want := newInt(42)
+ p.Store(want)
+ if got := p.Load(); got != want {
+ t.Errorf("wrong value: got %p (%v), wanted %p (%v)", got, got, want, want)
+ }
+ want = newInt(100)
+ p.Store(want)
+ if got := p.Load(); got != want {
+ t.Errorf("wrong value: got %p (%v), wanted %p (%v)", got, got, want, want)
+ }
+}
diff --git a/pkg/sync/downgradable_rwmutex_test.go b/third_party/gvsync/downgradable_rwmutex_test.go
index 99c1c8be0..6517dd5dc 100644
--- a/pkg/sync/downgradable_rwmutex_test.go
+++ b/third_party/gvsync/downgradable_rwmutex_test.go
@@ -1,4 +1,5 @@
// Copyright 2009 The Go Authors. All rights reserved.
+// Copyright 2019 Google LLC
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
@@ -8,7 +9,7 @@
// addition of downgradingWriter and the renaming of num_iterations to
// numIterations to shut up Golint.
-package sync
+package gvsync
import (
"fmt"
diff --git a/pkg/sync/downgradable_rwmutex_unsafe.go b/third_party/gvsync/downgradable_rwmutex_unsafe.go
index 9a96056fc..a63a0d084 100644
--- a/pkg/sync/downgradable_rwmutex_unsafe.go
+++ b/third_party/gvsync/downgradable_rwmutex_unsafe.go
@@ -1,4 +1,5 @@
// Copyright 2009 The Go Authors. All rights reserved.
+// Copyright 2019 Google LLC
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
@@ -10,7 +11,7 @@
// - RUnlock -> Lock (via writerSem)
// - DowngradeLock -> RLock (via readerSem)
-package sync
+package gvsync
import (
"sync"
diff --git a/third_party/gvsync/gvsync.go b/third_party/gvsync/gvsync.go
new file mode 100644
index 000000000..46a2565fd
--- /dev/null
+++ b/third_party/gvsync/gvsync.go
@@ -0,0 +1,7 @@
+// Copyright 2019 Google LLC
+//
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package gvsync provides synchronization primitives.
+package gvsync
diff --git a/third_party/gvsync/memmove_unsafe.go b/third_party/gvsync/memmove_unsafe.go
new file mode 100644
index 000000000..d483fc739
--- /dev/null
+++ b/third_party/gvsync/memmove_unsafe.go
@@ -0,0 +1,23 @@
+// Copyright 2019 Google LLC
+//
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package gvsync
+
+import (
+ "unsafe"
+)
+
+// Memmove is exported for SeqAtomicLoad/SeqAtomicTryLoad<T>, which can't
+// define it because go_generics can't update the go:linkname annotation.
+// Furthermore, go:linkname silently doesn't work if the local name is exported
+// (this is of course undocumented), which is why this indirection is
+// necessary.
+func Memmove(to, from unsafe.Pointer, n uintptr) {
+ memmove(to, from, n)
+}
+
+//go:linkname memmove runtime.memmove
+//go:noescape
+func memmove(to, from unsafe.Pointer, n uintptr)
diff --git a/pkg/sync/norace_unsafe.go b/third_party/gvsync/norace_unsafe.go
index 1593b9e5d..f9c88d13f 100644
--- a/pkg/sync/norace_unsafe.go
+++ b/third_party/gvsync/norace_unsafe.go
@@ -1,20 +1,11 @@
-// Copyright 2018 Google LLC
+// Copyright 2019 Google LLC
//
-// 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.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
// +build !race
-package sync
+package gvsync
import (
"unsafe"
diff --git a/pkg/sync/race_unsafe.go b/third_party/gvsync/race_unsafe.go
index 473eaddc6..2cdcdf7f7 100644
--- a/pkg/sync/race_unsafe.go
+++ b/third_party/gvsync/race_unsafe.go
@@ -1,20 +1,11 @@
-// Copyright 2018 Google LLC
+// Copyright 2019 Google LLC
//
-// 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.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
// +build race
-package sync
+package gvsync
import (
"runtime"
diff --git a/pkg/sync/seqatomic_unsafe.go b/third_party/gvsync/seqatomic_unsafe.go
index bea31adc5..ef61503e2 100644
--- a/pkg/sync/seqatomic_unsafe.go
+++ b/third_party/gvsync/seqatomic_unsafe.go
@@ -1,16 +1,7 @@
-// Copyright 2018 Google LLC
+// Copyright 2019 Google LLC
//
-// 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.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
// Package template doesn't exist. This file must be instantiated using the
// go_template_instance rule in tools/go_generics/defs.bzl.
@@ -22,7 +13,7 @@ import (
"strings"
"unsafe"
- ssync "gvisor.googlesource.com/gvisor/pkg/sync"
+ "gvisor.googlesource.com/gvisor/third_party/gvsync"
)
// Value is a required type parameter.
@@ -35,17 +26,17 @@ type Value struct{}
// SeqAtomicLoad returns a copy of *ptr, ensuring that the read does not race
// with any writer critical sections in sc.
-func SeqAtomicLoad(sc *ssync.SeqCount, ptr *Value) Value {
+func SeqAtomicLoad(sc *gvsync.SeqCount, ptr *Value) Value {
// This function doesn't use SeqAtomicTryLoad because doing so is
// measurably, significantly (~20%) slower; Go is awful at inlining.
var val Value
for {
epoch := sc.BeginRead()
- if ssync.RaceEnabled {
+ if gvsync.RaceEnabled {
// runtime.RaceDisable() doesn't actually stop the race detector,
// so it can't help us here. Instead, call runtime.memmove
// directly, which is not instrumented by the race detector.
- ssync.Memmove(unsafe.Pointer(&val), unsafe.Pointer(ptr), unsafe.Sizeof(val))
+ gvsync.Memmove(unsafe.Pointer(&val), unsafe.Pointer(ptr), unsafe.Sizeof(val))
} else {
// This is ~40% faster for short reads than going through memmove.
val = *ptr
@@ -61,10 +52,10 @@ func SeqAtomicLoad(sc *ssync.SeqCount, ptr *Value) Value {
// in sc initiated by a call to sc.BeginRead() that returned epoch. If the read
// would race with a writer critical section, SeqAtomicTryLoad returns
// (unspecified, false).
-func SeqAtomicTryLoad(sc *ssync.SeqCount, epoch ssync.SeqCountEpoch, ptr *Value) (Value, bool) {
+func SeqAtomicTryLoad(sc *gvsync.SeqCount, epoch gvsync.SeqCountEpoch, ptr *Value) (Value, bool) {
var val Value
- if ssync.RaceEnabled {
- ssync.Memmove(unsafe.Pointer(&val), unsafe.Pointer(ptr), unsafe.Sizeof(val))
+ if gvsync.RaceEnabled {
+ gvsync.Memmove(unsafe.Pointer(&val), unsafe.Pointer(ptr), unsafe.Sizeof(val))
} else {
val = *ptr
}
@@ -75,7 +66,7 @@ func init() {
var val Value
typ := reflect.TypeOf(val)
name := typ.Name()
- if ptrs := ssync.PointersInType(typ, name); len(ptrs) != 0 {
+ if ptrs := gvsync.PointersInType(typ, name); len(ptrs) != 0 {
panic(fmt.Sprintf("SeqAtomicLoad<%s> is invalid since values %s of type %s contain pointers:\n%s", typ, name, typ, strings.Join(ptrs, "\n")))
}
}
diff --git a/pkg/sync/seqatomictest/BUILD b/third_party/gvsync/seqatomictest/BUILD
index 23132650a..d83149e81 100644
--- a/pkg/sync/seqatomictest/BUILD
+++ b/third_party/gvsync/seqatomictest/BUILD
@@ -1,4 +1,4 @@
-load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
+load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
package(licenses = ["notice"])
@@ -9,7 +9,7 @@ go_template_instance(
out = "seqatomic_int.go",
package = "seqatomic",
suffix = "Int",
- template = "//pkg/sync:generic_seqatomic",
+ template = "//third_party/gvsync:generic_seqatomic",
types = {
"Value": "int",
},
@@ -18,9 +18,9 @@ go_template_instance(
go_library(
name = "seqatomic",
srcs = ["seqatomic_int.go"],
- importpath = "gvisor.googlesource.com/gvisor/pkg/sync/seqatomic",
+ importpath = "gvisor.googlesource.com/gvisor/third_party/gvsync/seqatomic",
deps = [
- "//pkg/sync",
+ "//third_party/gvsync",
],
)
@@ -30,6 +30,6 @@ go_test(
srcs = ["seqatomic_test.go"],
embed = [":seqatomic"],
deps = [
- "//pkg/sync",
+ "//third_party/gvsync",
],
)
diff --git a/pkg/sync/seqatomictest/seqatomic_test.go b/third_party/gvsync/seqatomictest/seqatomic_test.go
index f5e1fbfff..d0c373bae 100644
--- a/pkg/sync/seqatomictest/seqatomic_test.go
+++ b/third_party/gvsync/seqatomictest/seqatomic_test.go
@@ -19,7 +19,7 @@ import (
"testing"
"time"
- gvsync "gvisor.googlesource.com/gvisor/pkg/sync"
+ "gvisor.googlesource.com/gvisor/third_party/gvsync"
)
func TestSeqAtomicLoadUncontended(t *testing.T) {
diff --git a/pkg/sync/seqcount.go b/third_party/gvsync/seqcount.go
index 732e856a4..c7ae91cfa 100644
--- a/pkg/sync/seqcount.go
+++ b/third_party/gvsync/seqcount.go
@@ -1,18 +1,9 @@
-// Copyright 2018 Google LLC
+// Copyright 2019 Google LLC
//
-// 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.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
-package sync
+package gvsync
import (
"fmt"
diff --git a/pkg/sync/seqcount_test.go b/third_party/gvsync/seqcount_test.go
index b14a8878e..ee6579ed8 100644
--- a/pkg/sync/seqcount_test.go
+++ b/third_party/gvsync/seqcount_test.go
@@ -1,18 +1,9 @@
-// Copyright 2018 Google LLC
+// Copyright 2019 Google LLC
//
-// 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.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
-package sync
+package gvsync
import (
"reflect"