Skip to content
This repository has been archived by the owner on Sep 19, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1645 from 18F/wml-cross-platform-syscalls
Browse files Browse the repository at this point in the history
Breakout syscalls based on build target so app can be built cross platform
  • Loading branch information
macrael authored May 7, 2019
2 parents 92440a8 + de80d18 commit d24b1d0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
8 changes: 8 additions & 0 deletions api/cmd/syscalls_bsd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// +build darwin freebsd netbsd openbsd solaris dragonfly

package cmd

import "syscall"

const ioctlReadTermios = syscall.TIOCGETA
const ioctlWriteTermios = syscall.TIOCSETA
8 changes: 8 additions & 0 deletions api/cmd/syscalls_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// +build linux

package cmd

import "syscall"

const ioctlReadTermios = syscall.TCGETS
const ioctlWriteTermios = syscall.TCSETS
4 changes: 2 additions & 2 deletions api/cmd/webclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func echo(visible bool) {
var termios = &syscall.Termios{}
var fd = os.Stdout.Fd()

if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, syscall.TCGETS, uintptr(unsafe.Pointer(termios))); err != 0 {
if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(termios))); err != 0 {
return
}

Expand All @@ -198,7 +198,7 @@ func echo(visible bool) {
termios.Lflag &^= syscall.ECHO
}

if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, syscall.TCSETS, uintptr(unsafe.Pointer(termios))); err != 0 {
if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, ioctlWriteTermios, uintptr(unsafe.Pointer(termios))); err != 0 {
return
}
}

0 comments on commit d24b1d0

Please sign in to comment.