Skip to content

Commit

Permalink
fix: linux-386 support
Browse files Browse the repository at this point in the history
  • Loading branch information
ssgreg committed Dec 25, 2018
1 parent 8b7d855 commit 9eedcb4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion write_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"net"
"syscall"
"unsafe"

"golang.org/x/sys/unix"
)

// Go implementation of sendmsg (UnixConn.WriteMsgUnix) is not suitable
Expand Down Expand Up @@ -39,9 +41,10 @@ func writeMsgUnix(c *net.UnixConn, oob []byte, addr *net.UnixAddr) (oobn int, er
}
defer f.Close()

_, n, errno := syscall.Syscall(syscall.SYS_SENDMSG, f.Fd(), uintptr(unsafe.Pointer(&msg)), 0)
_, n, errno := syscall.Syscall(unix.SYS_SENDMSG, f.Fd(), uintptr(unsafe.Pointer(&msg)), 0)
if errno != 0 {
return int(n), errno
}

return int(n), nil
}
5 changes: 4 additions & 1 deletion write_msg_go1.9.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"net"
"syscall"
"unsafe"

"golang.org/x/sys/unix"
)

// Check function description in write_msg.go
Expand All @@ -26,13 +28,14 @@ func writeMsgUnix(c *net.UnixConn, oob []byte, addr *net.UnixAddr) (oobn int, er
var n uintptr
var errno syscall.Errno
err = rawConn.Write(func(fd uintptr) bool {
_, n, errno = syscall.Syscall(syscall.SYS_SENDMSG, fd, uintptr(unsafe.Pointer(&msg)), 0)
_, n, errno = syscall.Syscall(unix.SYS_SENDMSG, fd, uintptr(unsafe.Pointer(&msg)), 0)
return true
})
if err == nil {
if errno != 0 {
err = errno
}
}

return int(n), err
}

0 comments on commit 9eedcb4

Please sign in to comment.