Skip to content

x/sys/unix: add portable speed accessor methods to Termios #18866

@smithwinston

Description

@smithwinston

Attempting to use the Ispeed and Ospeed members of syscall.Termios on mipsle fails with a compile error using go1.8rc3, compiling on Darwin:

bash-3.2$ export GOOS=linux GOARCH=mipsle
bash-3.2$ go1.8rc3 build termios.go
# command-line-arguments
./termios.go:10: unknown field 'Ispeed' in struct literal of type syscall.Termios
./termios.go:11: unknown field 'Ospeed' in struct literal of type syscall.Termios

Using this example program:

package main

import (
	"fmt"
	"syscall"
)

func main() {
	t := &syscall.Termios{
		Ispeed: 115200,
		Ospeed: 115200,
	}

	fmt.Printf("%#v\n", t)
}

However compilation is successful for arm, ppc64le and darwin using the same toolchain.

If I comment out the Ispeed and Ospeed initializers compile and run on a mipsle platform (an Omega2 from Onion), the program produces the following output:

&syscall.Termios{Iflag:0x0, Oflag:0x0, Cflag:0x0, Lflag:0x0, Line:0x0, Cc:[32]uint8{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, Pad_cgo_0:[3]uint8{0x0, 0x0, 0x0}}

Compared to this on darwin:

&syscall.Termios{Iflag:0x0, Oflag:0x0, Cflag:0x0, Lflag:0x0, Cc:[20]uint8{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, Pad_cgo_0:[4]uint8{0x0, 0x0, 0x0, 0x0}, Ispeed:0x1c200, Ospeed:0x1c200}

For reference, this is the output of go1.8rc3 env:

GOARCH="mipsle"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="linux"
GOPATH="/Users/wsmith/golang"
GORACE=""
GOROOT="/Users/wsmith/sdk/go1.8rc3"
GOTOOLDIR="/Users/wsmith/sdk/go1.8rc3/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -mabi=32 -march=mips32 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/1j/_g9fzmm10vg7c10647c58wcm0000gn/T/go-build637432098=/tmp/go-build -gno-record-gcc-switches"
CXX="clang++"
CGO_ENABLED="0"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions