Merge lp:~dave-cheney/goetveld/003-fix-syscall-constants-for-gccgo into lp:goetveld

Proposed by Dave Cheney
Status: Merged
Merged at revision: 43
Proposed branch: lp:~dave-cheney/goetveld/003-fix-syscall-constants-for-gccgo
Merge into: lp:goetveld
Diff against target: 38 lines (+11/-3)
1 file modified
terminal_linux.go (+11/-3)
To merge this branch: bzr merge lp:~dave-cheney/goetveld/003-fix-syscall-constants-for-gccgo
Reviewer Review Type Date Requested Status
The Go Language Gophers Pending
Review via email: mp+212961@code.launchpad.net

Description of the change

Define local syscall constants so gccgo+ppc works

The gccgo syscall package is missing two constants that goetveld needs.

After discussion with niemeyer on IRC we decided to define
them locally and be done with it.

To post a comment you must log in.
Revision history for this message
Dave Cheney (dave-cheney) wrote :

Please take a look.

Revision history for this message
Gustavo Niemeyer (niemeyer) wrote :

*** Submitted:

Define local syscall constants so gccgo+ppc works

The gccgo syscall package is missing two constants that goetveld needs.

After discussion with niemeyer on IRC we decided to define
them locally and be done with it.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'terminal_linux.go'
2--- terminal_linux.go 2012-09-25 02:04:48 +0000
3+++ terminal_linux.go 2014-03-26 23:38:13 +0000
4@@ -12,23 +12,31 @@
5
6 // This was copied from package exp/terminal
7
8+// The gccgo version of the syscall package lacks these constants.
9+// Declare them here to work around gccgo.
10+// TODO(dfc) revert this if/when the gccgo syscall package is fixed.
11+const (
12+ ioctlTCGETS = 0x5401 // syscall.TCGETS
13+ ioctlTCSETS = 0x5402 // syscall.TCSETS
14+)
15+
16 // readPassword reads a line of input from a terminal without local echo. This
17 // is commonly used for inputting passwords and other sensitive data. The slice
18 // returned does not include the \n.
19 func readPassword(fd uintptr) ([]byte, error) {
20 var oldState syscall.Termios
21- if _, _, e := syscall.Syscall6(syscall.SYS_IOCTL, fd, uintptr(syscall.TCGETS), uintptr(unsafe.Pointer(&oldState)), 0, 0, 0); e != 0 {
22+ if _, _, e := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlTCGETS, uintptr(unsafe.Pointer(&oldState)), 0, 0, 0); e != 0 {
23 return nil, syscall.Errno(e)
24 }
25
26 newState := oldState
27 newState.Lflag &^= syscall.ECHO
28- if _, _, e := syscall.Syscall6(syscall.SYS_IOCTL, fd, uintptr(syscall.TCSETS), uintptr(unsafe.Pointer(&newState)), 0, 0, 0); e != 0 {
29+ if _, _, e := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlTCSETS, uintptr(unsafe.Pointer(&newState)), 0, 0, 0); e != 0 {
30 return nil, syscall.Errno(e)
31 }
32
33 defer func() {
34- syscall.Syscall6(syscall.SYS_IOCTL, fd, uintptr(syscall.TCSETS), uintptr(unsafe.Pointer(&oldState)), 0, 0, 0)
35+ syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlTCSETS, uintptr(unsafe.Pointer(&oldState)), 0, 0, 0)
36 }()
37
38 var buf [16]byte

Subscribers

People subscribed via source and target branches