OLD | NEW |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // +build darwin dragonfly freebsd linux netbsd openbsd solaris | 5 // +build darwin dragonfly freebsd linux netbsd openbsd solaris |
6 | 6 |
7 // Socket control messages | 7 // Socket control messages |
8 | 8 |
9 package syscall | 9 package unix |
10 | 10 |
11 import "unsafe" | 11 import "unsafe" |
12 | 12 |
13 // Round the length of a raw sockaddr up to align it properly. | 13 // Round the length of a raw sockaddr up to align it properly. |
14 func cmsgAlignOf(salen int) int { | 14 func cmsgAlignOf(salen int) int { |
15 salign := sizeofPtr | 15 salign := sizeofPtr |
16 // NOTE: It seems like 64-bit Darwin and DragonFly BSD kernels | 16 // NOTE: It seems like 64-bit Darwin and DragonFly BSD kernels |
17 // still require 32-bit aligned access to network subsystem. | 17 // still require 32-bit aligned access to network subsystem. |
18 if darwin64Bit || dragonfly64Bit { | 18 if darwin64Bit || dragonfly64Bit { |
19 salign = 4 | 19 salign = 4 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 if m.Header.Type != SCM_RIGHTS { | 94 if m.Header.Type != SCM_RIGHTS { |
95 return nil, EINVAL | 95 return nil, EINVAL |
96 } | 96 } |
97 fds := make([]int, len(m.Data)>>2) | 97 fds := make([]int, len(m.Data)>>2) |
98 for i, j := 0, 0; i < len(m.Data); i += 4 { | 98 for i, j := 0, 0; i < len(m.Data); i += 4 { |
99 fds[j] = int(*(*int32)(unsafe.Pointer(&m.Data[i]))) | 99 fds[j] = int(*(*int32)(unsafe.Pointer(&m.Data[i]))) |
100 j++ | 100 j++ |
101 } | 101 } |
102 return fds, nil | 102 return fds, nil |
103 } | 103 } |
OLD | NEW |