mirror of
https://github.com/golang/go
synced 2024-11-06 19:36:30 -07:00
syscall: use correct cmsg alignment for openbsd/arm
The OpenBSD armv7 port requires 64-bit alignment for cmsgs. Rework the cmsg alignment code to facilitate this. Change-Id: I52cf55a8a4cda46c6ef35b0f694862b842028b42 Reviewed-on: https://go-review.googlesource.com/c/153837 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
09da280157
commit
bbae8d5508
@ -8,17 +8,30 @@
|
|||||||
|
|
||||||
package syscall
|
package syscall
|
||||||
|
|
||||||
import "unsafe"
|
import (
|
||||||
|
"runtime"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
// Round the length of a raw sockaddr up to align it properly.
|
// Round the length of a raw sockaddr up to align it properly.
|
||||||
func cmsgAlignOf(salen int) int {
|
func cmsgAlignOf(salen int) int {
|
||||||
salign := sizeofPtr
|
salign := sizeofPtr
|
||||||
// NOTE: It seems like 64-bit Darwin, DragonFly BSD and
|
|
||||||
// Solaris kernels still require 32-bit aligned access to
|
switch runtime.GOOS {
|
||||||
// network subsystem.
|
case "darwin", "dragonfly", "solaris":
|
||||||
if darwin64Bit || dragonfly64Bit || solaris64Bit {
|
// NOTE: It seems like 64-bit Darwin, DragonFly BSD and
|
||||||
salign = 4
|
// Solaris kernels still require 32-bit aligned access to
|
||||||
|
// network subsystem.
|
||||||
|
if sizeofPtr == 8 {
|
||||||
|
salign = 4
|
||||||
|
}
|
||||||
|
case "openbsd":
|
||||||
|
// OpenBSD armv7 requires 64-bit alignment.
|
||||||
|
if runtime.GOARCH == "arm" {
|
||||||
|
salign = 8
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (salen + salign - 1) & ^(salign - 1)
|
return (salen + salign - 1) & ^(salign - 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user