diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/syscall/sockcmsg_unix.go | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/syscall/sockcmsg_unix.go b/src/syscall/sockcmsg_unix.go index 5020033bad..954148012f 100644 --- a/src/syscall/sockcmsg_unix.go +++ b/src/syscall/sockcmsg_unix.go @@ -8,17 +8,30 @@ package syscall -import "unsafe" +import ( + "runtime" + "unsafe" +) // Round the length of a raw sockaddr up to align it properly. func cmsgAlignOf(salen int) int { salign := sizeofPtr - // NOTE: It seems like 64-bit Darwin, DragonFly BSD and - // Solaris kernels still require 32-bit aligned access to - // network subsystem. - if darwin64Bit || dragonfly64Bit || solaris64Bit { - salign = 4 + + switch runtime.GOOS { + case "darwin", "dragonfly", "solaris": + // NOTE: It seems like 64-bit Darwin, DragonFly BSD and + // 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) } |