Skip to content

Commit

Permalink
Support non-amd64 linux platforms (except 386)
Browse files Browse the repository at this point in the history
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
  • Loading branch information
AkihiroSuda committed Jun 28, 2017
1 parent d0ee52a commit a89bad6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,14 @@ go:
- 1.6
- 1.7
- 1.8

script:
- go test -v ./...
- GOOS=linux GOARCH=amd64 go build .
- GOOS=linux GOARCH=arm go build .
- GOOS=linux GOARCH=arm64 go build .
- GOOS=linux GOARCH=ppc64le go build .
- GOOS=linux GOARCH=s390x go build .
# can be compiled but not functional:
- GOOS=linux GOARCH=386 go build .
- GOOS=windows GOARCH=amd64 go build .
9 changes: 7 additions & 2 deletions sctp_linux_amd64.go → sctp_linux.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build amd64,linux
// +build linux,!386

package sctp

Expand All @@ -11,6 +11,7 @@ import (
)

func setsockopt(fd int, optname, optval, optlen uintptr) (uintptr, uintptr, error) {
// FIXME: syscall.SYS_SETSOCKOPT is undefined on 386
r0, r1, errno := syscall.Syscall6(syscall.SYS_SETSOCKOPT,
uintptr(fd),
SOL_SCTP,
Expand All @@ -25,6 +26,7 @@ func setsockopt(fd int, optname, optval, optlen uintptr) (uintptr, uintptr, erro
}

func getsockopt(fd int, optname, optval, optlen uintptr) (uintptr, uintptr, error) {
// FIXME: syscall.SYS_GETSOCKOPT is undefined on 386
r0, r1, errno := syscall.Syscall6(syscall.SYS_GETSOCKOPT,
uintptr(fd),
SOL_SCTP,
Expand All @@ -43,10 +45,13 @@ func (c *SCTPConn) SCTPWrite(b []byte, info *SndRcvInfo) (int, error) {
if info != nil {
cmsgBuf := toBuf(info)
hdr := &syscall.Cmsghdr{
Len: uint64(syscall.CmsgSpace(len(cmsgBuf))),
Level: syscall.IPPROTO_SCTP,
Type: SCTP_CMSG_SNDRCV,
}

// bitwidth of hdr.Len is platform-specific,
// so we use hdr.SetLen() rather than directly setting hdr.Len
hdr.SetLen(syscall.CmsgSpace(len(cmsgBuf)))
cbuf = append(toBuf(hdr), cmsgBuf...)
}
return syscall.SendmsgN(c.fd, b, cbuf, nil, 0)
Expand Down
2 changes: 1 addition & 1 deletion sctp_unsupported.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build !amd64,linux !linux
// +build !linux linux,386

package sctp

Expand Down

0 comments on commit a89bad6

Please sign in to comment.