diff options
Diffstat (limited to 'vendor/golang.org/x/sys/unix/sockcmsg_unix.go')
-rw-r--r-- | vendor/golang.org/x/sys/unix/sockcmsg_unix.go | 28 |
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 @@ | |||
8 | 8 | ||
9 | package unix | 9 | package unix |
10 | 10 | ||
11 | import "unsafe" | 11 | import ( |
12 | "runtime" | ||
13 | "unsafe" | ||
14 | ) | ||
12 | 15 | ||
13 | // Round the length of a raw sockaddr up to align it properly. | 16 | // Round the length of a raw sockaddr up to align it properly. |
14 | func cmsgAlignOf(salen int) int { | 17 | func cmsgAlignOf(salen int) int { |
15 | salign := SizeofPtr | 18 | salign := SizeofPtr |
16 | // NOTE: It seems like 64-bit Darwin, DragonFly BSD and | 19 | |
17 | // Solaris kernels still require 32-bit aligned access to | 20 | switch runtime.GOOS { |
18 | // network subsystem. | 21 | case "aix": |
19 | if darwin64Bit || dragonfly64Bit || solaris64Bit { | 22 | // There is no alignment on AIX. |
20 | salign = 4 | 23 | salign = 1 |
24 | case "darwin", "dragonfly", "solaris", "illumos": | ||
25 | // NOTE: It seems like 64-bit Darwin, DragonFly BSD, | ||
26 | // illumos, and Solaris kernels still require 32-bit | ||
27 | // aligned access to network subsystem. | ||
28 | if SizeofPtr == 8 { | ||
29 | salign = 4 | ||
30 | } | ||
31 | case "netbsd", "openbsd": | ||
32 | // NetBSD and OpenBSD armv7 require 64-bit alignment. | ||
33 | if runtime.GOARCH == "arm" { | ||
34 | salign = 8 | ||
35 | } | ||
21 | } | 36 | } |
37 | |||
22 | return (salen + salign - 1) & ^(salign - 1) | 38 | return (salen + salign - 1) & ^(salign - 1) |
23 | } | 39 | } |
24 | 40 | ||