Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1154)

Delta Between Two Patch Sets: src/pkg/syscall/sockcmsg_unix.go

Issue 7406050: code review 7406050: syscall: fix FD passing on FreeBSD, NetBSD and OpenBSD (Closed)
Left Patch Set: Created 12 years ago
Right Patch Set: diff -r c28d9e5f42ff https://code.google.com/p/go Created 12 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/syscall/passfd_test.go ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
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 freebsd linux netbsd openbsd 5 // +build darwin freebsd linux netbsd openbsd
6 6
7 // Socket control messages 7 // Socket control messages
8 8
9 package syscall 9 package syscall
10 10
(...skipping 19 matching lines...) Expand all
30 return cmsgAlignOf(SizeofCmsghdr) + datalen 30 return cmsgAlignOf(SizeofCmsghdr) + datalen
31 } 31 }
32 32
33 // CmsgSpace returns the number of bytes an ancillary element with 33 // CmsgSpace returns the number of bytes an ancillary element with
34 // payload of the passed data length occupies. 34 // payload of the passed data length occupies.
35 func CmsgSpace(datalen int) int { 35 func CmsgSpace(datalen int) int {
36 return cmsgAlignOf(SizeofCmsghdr) + cmsgAlignOf(datalen) 36 return cmsgAlignOf(SizeofCmsghdr) + cmsgAlignOf(datalen)
37 } 37 }
38 38
39 func cmsgData(h *Cmsghdr) unsafe.Pointer { 39 func cmsgData(h *Cmsghdr) unsafe.Pointer {
40 » return unsafe.Pointer(uintptr(unsafe.Pointer(h)) + SizeofCmsghdr) 40 » return unsafe.Pointer(uintptr(unsafe.Pointer(h)) + uintptr(cmsgAlignOf(S izeofCmsghdr)))
41 } 41 }
42 42
43 // SocketControlMessage represents a socket control message. 43 // SocketControlMessage represents a socket control message.
44 type SocketControlMessage struct { 44 type SocketControlMessage struct {
45 Header Cmsghdr 45 Header Cmsghdr
46 Data []byte 46 Data []byte
47 } 47 }
48 48
49 // ParseSocketControlMessage parses b as an array of socket control 49 // ParseSocketControlMessage parses b as an array of socket control
50 // messages. 50 // messages.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 if m.Header.Type != SCM_RIGHTS { 96 if m.Header.Type != SCM_RIGHTS {
97 return nil, EINVAL 97 return nil, EINVAL
98 } 98 }
99 fds := make([]int, len(m.Data)>>2) 99 fds := make([]int, len(m.Data)>>2)
100 for i, j := 0, 0; i < len(m.Data); i += 4 { 100 for i, j := 0, 0; i < len(m.Data); i += 4 {
101 fds[j] = int(*(*int32)(unsafe.Pointer(&m.Data[i]))) 101 fds[j] = int(*(*int32)(unsafe.Pointer(&m.Data[i])))
102 j++ 102 j++
103 } 103 }
104 return fds, nil 104 return fds, nil
105 } 105 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b