Commit 3da985ce authored by Mikio Hara's avatar Mikio Hara

internal/socket: fix 386 emulation on amd64 for FreeBSD

Unlike routing messages, there's no need to tweak the alignment for
socket control messages on freebsd/386 emulation.

Change-Id: Iab4a2b05080868721f7e42cebd661d445f8c1030
Reviewed-on: https://go-review.googlesource.com/44391
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent 48359f4f
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build netbsd openbsd
// +build freebsd netbsd openbsd
package socket
......
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package socket
import (
"syscall"
"unsafe"
)
func probeProtocolStack() int {
var p uintptr
align := int(unsafe.Sizeof(p))
// In the case of kern.supported_archs="amd64 i386", we need
// to know the underlying kernel's architecture because the
// alignment for socket facilities are set at the build time
// of the kernel.
conf, _ := syscall.Sysctl("kern.conftxt")
for i, j := 0, 0; j < len(conf); j++ {
if conf[j] != '\n' {
continue
}
s := conf[i:j]
i = j + 1
if len(s) > len("machine") && s[:len("machine")] == "machine" {
s = s[len("machine"):]
for k := 0; k < len(s); k++ {
if s[k] == ' ' || s[k] == '\t' {
s = s[1:]
}
break
}
if s == "amd64" {
align = 8
}
break
}
}
return align
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment