aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/golang.org/x/sys/unix/sockcmsg_unix.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/golang.org/x/sys/unix/sockcmsg_unix.go')
-rw-r--r--vendor/golang.org/x/sys/unix/sockcmsg_unix.go28
1 files changed, 22 insertions, 6 deletions
diff --git a/vendor/golang.org/x/sys/unix/sockcmsg_unix.go b/vendor/golang.org/x/sys/unix/sockcmsg_unix.go
index 9dd2f32..062bcab 100644
--- a/vendor/golang.org/x/sys/unix/sockcmsg_unix.go
+++ b/vendor/golang.org/x/sys/unix/sockcmsg_unix.go
@@ -8,17 +8,33 @@
package unix
-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 "aix":
+ // There is no alignment on AIX.
+ salign = 1
+ case "darwin", "dragonfly", "solaris", "illumos":
+ // NOTE: It seems like 64-bit Darwin, DragonFly BSD,
+ // illumos, and Solaris kernels still require 32-bit
+ // aligned access to network subsystem.
+ if SizeofPtr == 8 {
+ salign = 4
+ }
+ case "netbsd", "openbsd":
+ // NetBSD and OpenBSD armv7 require 64-bit alignment.
+ if runtime.GOARCH == "arm" {
+ salign = 8
+ }
}
+
return (salen + salign - 1) & ^(salign - 1)
}