diff options
Diffstat (limited to 'libgo/go')
-rw-r--r-- | libgo/go/exp/terminal/terminal.go | 15 | ||||
-rw-r--r-- | libgo/go/syscall/libcall_linux.go | 15 | ||||
-rw-r--r-- | libgo/go/syscall/libcall_posix.go | 6 |
3 files changed, 22 insertions, 14 deletions
diff --git a/libgo/go/exp/terminal/terminal.go b/libgo/go/exp/terminal/terminal.go index aacd90905f5..05a8990b041 100644 --- a/libgo/go/exp/terminal/terminal.go +++ b/libgo/go/exp/terminal/terminal.go @@ -17,7 +17,6 @@ package terminal import ( "os" "syscall" - "unsafe" ) // State contains the state of a terminal. @@ -28,7 +27,7 @@ type State struct { // IsTerminal returns true if the given file descriptor is a terminal. func IsTerminal(fd int) bool { var termios syscall.Termios - _, _, e := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), uintptr(syscall.TCGETS), uintptr(unsafe.Pointer(&termios)), 0, 0, 0) + e := syscall.Tcgetattr(fd, &termios) return e == 0 } @@ -37,14 +36,14 @@ func IsTerminal(fd int) bool { // restored. func MakeRaw(fd int) (*State, os.Error) { var oldState State - if _, _, e := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), uintptr(syscall.TCGETS), uintptr(unsafe.Pointer(&oldState.termios)), 0, 0, 0); e != 0 { + if e := syscall.Tcgetattr(fd, &oldState.termios); e != 0 { return nil, os.Errno(e) } newState := oldState.termios newState.Iflag &^= syscall.ISTRIP | syscall.INLCR | syscall.ICRNL | syscall.IGNCR | syscall.IXON | syscall.IXOFF newState.Lflag &^= syscall.ECHO | syscall.ICANON | syscall.ISIG - if _, _, e := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), uintptr(syscall.TCSETS), uintptr(unsafe.Pointer(&newState)), 0, 0, 0); e != 0 { + if e := syscall.Tcsetattr(fd, syscall.TCSANOW, &newState); e != 0 { return nil, os.Errno(e) } @@ -54,7 +53,7 @@ func MakeRaw(fd int) (*State, os.Error) { // Restore restores the terminal connected to the given file descriptor to a // previous state. func Restore(fd int, state *State) os.Error { - _, _, e := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), uintptr(syscall.TCSETS), uintptr(unsafe.Pointer(&state.termios)), 0, 0, 0) + e := syscall.Tcsetattr(fd, syscall.TCSANOW, &state.termios) return os.Errno(e) } @@ -63,18 +62,18 @@ func Restore(fd int, state *State) os.Error { // returned does not include the \n. func ReadPassword(fd int) ([]byte, os.Error) { var oldState syscall.Termios - if _, _, e := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), uintptr(syscall.TCGETS), uintptr(unsafe.Pointer(&oldState)), 0, 0, 0); e != 0 { + if e := syscall.Tcgetattr(fd, &oldState); e != 0 { return nil, os.Errno(e) } newState := oldState newState.Lflag &^= syscall.ECHO - if _, _, e := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), uintptr(syscall.TCSETS), uintptr(unsafe.Pointer(&newState)), 0, 0, 0); e != 0 { + if e := syscall.Tcsetattr(fd, syscall.TCSANOW, &newState); e != 0 { return nil, os.Errno(e) } defer func() { - syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), uintptr(syscall.TCSETS), uintptr(unsafe.Pointer(&oldState)), 0, 0, 0) + syscall.Tcsetattr(fd, syscall.TCSANOW, &oldState) }() var buf [16]byte diff --git a/libgo/go/syscall/libcall_linux.go b/libgo/go/syscall/libcall_linux.go index a78af36f70d..3948e51ae28 100644 --- a/libgo/go/syscall/libcall_linux.go +++ b/libgo/go/syscall/libcall_linux.go @@ -186,8 +186,9 @@ func PtraceDetach(pid int) (errno int) { return ptrace(PTRACE_DETACH, pid, 0, 0) //sys Faccessat(dirfd int, path string, mode uint32, flags int) (errno int) //faccessat(dirfd int, pathname *byte, mode int, flags int) int -//sys Fallocate(fd int, mode uint32, off int64, len int64) (errno int) -//fallocate(fd int, mode int, offset Offset_t, len Offset_t) int +// FIXME: Only in glibc 2.10 and later. +// //sys Fallocate(fd int, mode uint32, off int64, len int64) (errno int) +// //fallocate(fd int, mode int, offset Offset_t, len Offset_t) int //sys Fchmodat(dirfd int, path string, mode uint32, flags int) (errno int) //fchmodat(dirfd int, pathname *byte, mode Mode_t, flags int) int @@ -223,8 +224,9 @@ func PtraceDetach(pid int) (errno int) { return ptrace(PTRACE_DETACH, pid, 0, 0) //sysnb InotifyInit() (fd int, errno int) //inotify_init() int -//sysnb InotifyInit1(flags int) (fd int, errno int) -//inotify_init1(flags int) int +// FIXME: Only in glibc 2.9 and later. +// //sysnb InotifyInit1(flags int) (fd int, errno int) +// //inotify_init1(flags int) int //sysnb InotifyRmWatch(fd int, watchdesc uint32) (success int, errno int) //inotify_rm_watch(fd int, wd uint32) int @@ -298,8 +300,9 @@ func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n i // //sys Statfs(path string, buf *Statfs_t) (errno int) // //statfs(path *byte, buf *Statfs_t) int -//sys SyncFileRange(fd int, off int64, n int64, flags int) (errno int) -//sync_file_range(fd int, off Offset_t, n Offset_t, flags uint) int +// FIXME: Only in glibc 2.6 and later. +// //sys SyncFileRange(fd int, off int64, n int64, flags int) (errno int) +// //sync_file_range(fd int, off Offset_t, n Offset_t, flags uint) int // FIXME: mksysinfo Sysinfo_t // //sysnb Sysinfo(info *Sysinfo_t) (errno int) diff --git a/libgo/go/syscall/libcall_posix.go b/libgo/go/syscall/libcall_posix.go index 5d7c98f9d26..87ed4e628fd 100644 --- a/libgo/go/syscall/libcall_posix.go +++ b/libgo/go/syscall/libcall_posix.go @@ -377,3 +377,9 @@ func NsecToTimeval(nsec int64) (tv Timeval) { tv.Usec = Timeval_usec_t(nsec % 1e9 / 1e3) return } + +//sysnb Tcgetattr(fd int, p *Termios) (errno int) +//tcgetattr(fd int, p *Termios) int + +//sys Tcsetattr(fd int, actions int, p *Termios) (errno int) +//tcsetattr(fd int, actions int, p *Termios) int |