Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support non-amd64 linux platforms (except 386) #3

Merged
merged 1 commit into from
Jun 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 .
- (go version | grep go1.6 > /dev/null) || 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