Move sync generics to their own packages

The presence of multiple packages in a single directory sometimes
confuses `go mod`, producing output like:
  go: downloading gvisor.dev/gvisor v0.0.0-20210601174640-77dc0f5bc94d
  $GOMODCACHE/gvisor.dev/gvisor@v0.0.0-20210601174640-77dc0f5bc94d/pkg/linewriter/linewriter.go:21:2: found packages sync (aliases.go) and seqatomic (generic_atomicptr_unsafe.go) in $GOMODCACHE/gvisor.dev/gvisor@v0.0.0-20210601174640-77dc0f5bc94d/pkg/sync
  imports.go:67:2: found packages tcp (accept.go) and rcv (rcv_test.go) in $GOMODCACHE/gvisor.dev/gvisor@v0.0.0-20210601174640-77dc0f5bc94d/pkg/tcpip/transport/tcp

PiperOrigin-RevId: 376956213
This commit is contained in:
Tamir Duberstein
2021-06-01 17:47:32 -07:00
committed by gVisor bot
parent d7d8a0a5ae
commit 12f4118437
15 changed files with 52 additions and 51 deletions
+1 -1
View File
@@ -32,7 +32,7 @@ go_template_instance(
out = "seqatomic_taskgoroutineschedinfo_unsafe.go",
package = "kernel",
suffix = "TaskGoroutineSchedInfo",
template = "//pkg/sync:generic_seqatomic",
template = "//pkg/sync/seqatomic:generic_seqatomic",
types = {
"Value": "TaskGoroutineSchedInfo",
},
+1 -1
View File
@@ -8,7 +8,7 @@ go_template_instance(
out = "atomicptr_credentials_unsafe.go",
package = "auth",
suffix = "Credentials",
template = "//pkg/sync:generic_atomicptr",
template = "//pkg/sync/atomicptr:generic_atomicptr",
types = {
"Value": "Credentials",
},
+1 -1
View File
@@ -8,7 +8,7 @@ go_template_instance(
out = "atomicptr_bucket_unsafe.go",
package = "futex",
suffix = "Bucket",
template = "//pkg/sync:generic_atomicptr",
template = "//pkg/sync/atomicptr:generic_atomicptr",
types = {
"Value": "bucket",
},
+1 -1
View File
@@ -8,7 +8,7 @@ go_template_instance(
out = "seqatomic_parameters_unsafe.go",
package = "time",
suffix = "Parameters",
template = "//pkg/sync:generic_seqatomic",
template = "//pkg/sync/seqatomic:generic_seqatomic",
types = {
"Value": "Parameters",
},
-40
View File
@@ -1,5 +1,4 @@
load("//tools:defs.bzl", "go_library", "go_test")
load("//tools/go_generics:defs.bzl", "go_template")
package(
default_visibility = ["//:sandbox"],
@@ -8,45 +7,6 @@ package(
exports_files(["LICENSE"])
go_template(
name = "generic_atomicptr",
srcs = ["generic_atomicptr_unsafe.go"],
types = [
"Value",
],
)
go_template(
name = "generic_atomicptrmap",
srcs = ["generic_atomicptrmap_unsafe.go"],
opt_consts = [
"ShardOrder",
],
opt_types = [
"Hasher",
],
types = [
"Key",
"Value",
],
deps = [
":sync",
"//pkg/gohacks",
],
)
go_template(
name = "generic_seqatomic",
srcs = ["generic_seqatomic_unsafe.go"],
types = [
"Value",
],
deps = [
":sync",
"//pkg/gohacks",
],
)
go_library(
name = "sync",
srcs = [
@@ -1,14 +1,23 @@
load("//tools:defs.bzl", "go_library", "go_test")
load("//tools/go_generics:defs.bzl", "go_template_instance")
load("//tools/go_generics:defs.bzl", "go_template", "go_template_instance")
package(licenses = ["notice"])
go_template(
name = "generic_atomicptr",
srcs = ["generic_atomicptr_unsafe.go"],
types = [
"Value",
],
visibility = ["//:sandbox"],
)
go_template_instance(
name = "atomicptr_int",
out = "atomicptr_int_unsafe.go",
package = "atomicptr",
suffix = "Int",
template = "//pkg/sync:generic_atomicptr",
template = ":generic_atomicptr",
types = {
"Value": "int",
},
@@ -1,17 +1,36 @@
load("//tools:defs.bzl", "go_library", "go_test")
load("//tools/go_generics:defs.bzl", "go_template_instance")
load("//tools/go_generics:defs.bzl", "go_template", "go_template_instance")
package(
default_visibility = ["//visibility:private"],
licenses = ["notice"],
)
go_template(
name = "generic_atomicptrmap",
srcs = ["generic_atomicptrmap_unsafe.go"],
opt_consts = [
"ShardOrder",
],
opt_types = [
"Hasher",
],
types = [
"Key",
"Value",
],
deps = [
"//pkg/gohacks",
"//pkg/sync",
],
)
go_template_instance(
name = "test_atomicptrmap",
out = "test_atomicptrmap_unsafe.go",
package = "atomicptrmap",
prefix = "test",
template = "//pkg/sync:generic_atomicptrmap",
template = ":generic_atomicptrmap",
types = {
"Key": "int64",
"Value": "testValue",
@@ -27,7 +46,7 @@ go_template_instance(
package = "atomicptrmap",
prefix = "test",
suffix = "Sharded",
template = "//pkg/sync:generic_atomicptrmap",
template = ":generic_atomicptrmap",
types = {
"Key": "int64",
"Value": "testValue",
@@ -1,14 +1,27 @@
load("//tools:defs.bzl", "go_library", "go_test")
load("//tools/go_generics:defs.bzl", "go_template_instance")
load("//tools/go_generics:defs.bzl", "go_template", "go_template_instance")
package(licenses = ["notice"])
go_template(
name = "generic_seqatomic",
srcs = ["generic_seqatomic_unsafe.go"],
types = [
"Value",
],
visibility = ["//:sandbox"],
deps = [
":sync",
"//pkg/gohacks",
],
)
go_template_instance(
name = "seqatomic_int",
out = "seqatomic_int_unsafe.go",
package = "seqatomic",
suffix = "Int",
template = "//pkg/sync:generic_seqatomic",
template = ":generic_seqatomic",
types = {
"Value": "int",
},