Skip to content

runtime,reflect: merge select* const into internal/abi #65372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/internal/abi/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,16 @@ const (
TraceArgsMaxLen = (TraceArgsMaxDepth*3+2)*TraceArgsLimit + 1
)

// A SelectDir describes the communication direction of a select case.
type SelectDir int

const (
_ SelectDir = iota
SelectSend // case Chan <- Send
SelectRecv // case <-Chan:
SelectDefault // default
)

// Populate the data.
// The data is a stream of bytes, which contains the offsets and sizes of the
// non-aggregate arguments or non-aggregate fields/elements of aggregate-typed
Expand Down
8 changes: 4 additions & 4 deletions src/reflect/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -3038,15 +3038,15 @@ type runtimeSelect struct {
func rselect([]runtimeSelect) (chosen int, recvOK bool)

// A SelectDir describes the communication direction of a select case.
type SelectDir int
type SelectDir = abi.SelectDir

// NOTE: These values must match ../runtime/select.go:/selectDir.

const (
_ SelectDir = iota
SelectSend // case Chan <- Send
SelectRecv // case <-Chan:
SelectDefault // default
SelectSend = abi.SelectSend // case Chan <- Send
SelectRecv = abi.SelectRecv // case <-Chan:
SelectDefault = abi.SelectDefault // default
)

// A SelectCase describes a single case in a select operation.
Expand Down
18 changes: 4 additions & 14 deletions src/runtime/select.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,22 +522,12 @@ func (c *hchan) sortkey() uintptr {
// A runtimeSelect is a single case passed to rselect.
// This must match ../reflect/value.go:/runtimeSelect
type runtimeSelect struct {
dir selectDir
dir abi.SelectDir
typ unsafe.Pointer // channel type (not used here)
ch *hchan // channel
val unsafe.Pointer // ptr to data (SendDir) or ptr to receive buffer (RecvDir)
}

// These values must match ../reflect/value.go:/SelectDir.
type selectDir int

const (
_ selectDir = iota
selectSend // case Chan <- Send
selectRecv // case <-Chan:
selectDefault // default
)

//go:linkname reflect_rselect reflect.rselect
func reflect_rselect(cases []runtimeSelect) (int, bool) {
if len(cases) == 0 {
Expand All @@ -550,13 +540,13 @@ func reflect_rselect(cases []runtimeSelect) (int, bool) {
for i, rc := range cases {
var j int
switch rc.dir {
case selectDefault:
case abi.SelectDefault:
dflt = i
continue
case selectSend:
case abi.SelectSend:
j = nsends
nsends++
case selectRecv:
case abi.SelectRecv:
nrecvs++
j = len(cases) - nrecvs
}
Expand Down