Move runtime constants to dynamic facts render

PiperOrigin-RevId: 505172527
This commit is contained in:
Michael Pratt
2023-01-27 11:52:00 -08:00
committed by gVisor bot
parent 845fb007de
commit ee3a8735b5
3 changed files with 38 additions and 14 deletions
+9
View File
@@ -28,6 +28,14 @@ arch_genrule(
template = "runtime_spinning_impl_%s.s",
)
# Architecture-independent constants.
nogo_facts(
name = "runtime_constants_impl",
srcs = ["runtime.go"],
output = "runtime_constants_impl.go",
template = "runtime_constants.tmpl",
)
go_library(
name = "sync",
srcs = [
@@ -49,6 +57,7 @@ go_library(
"rwmutex_unsafe.go",
"seqcount.go",
"sync.go",
":runtime_constants_impl",
":runtime_spinning_impl_arch",
],
marshal = False,
+29
View File
@@ -0,0 +1,29 @@
// Copyright 2023 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 sync
// Values for the reason argument to gopark, from Go's src/runtime/runtime2.go.
const (
WaitReasonSelect uint8 = {{ .import.runtime.Constants.waitReasonSelect }}
WaitReasonChanReceive uint8 = {{ .import.runtime.Constants.waitReasonChanReceive }}
WaitReasonSemacquire uint8 = {{ .import.runtime.Constants.waitReasonSemacquire }}
)
// Values for the traceEv argument to gopark, from Go's src/runtime/trace.go.
const (
TraceEvGoBlockRecv byte = {{ .import.runtime.Constants.traceEvGoBlockRecv }}
TraceEvGoBlockSelect byte = {{ .import.runtime.Constants.traceEvGoBlockSelect }}
TraceEvGoBlockSync byte = {{ .import.runtime.Constants.traceEvGoBlockSync }}
)
-14
View File
@@ -78,20 +78,6 @@ func Goready(gp uintptr, traceskip int, wakep bool) {
}
}
// Values for the reason argument to gopark, from Go's src/runtime/runtime2.go.
const (
WaitReasonSelect uint8 = 9
WaitReasonChanReceive uint8 = 14
WaitReasonSemacquire uint8 = 18
)
// Values for the traceEv argument to gopark, from Go's src/runtime/trace.go.
const (
TraceEvGoBlockRecv byte = 23
TraceEvGoBlockSelect byte = 24
TraceEvGoBlockSync byte = 25
)
// Rand32 returns a non-cryptographically-secure random uint32.
func Rand32() uint32 {
return fastrand()