diff -r c040f992052f -r 1c52a0eeb952 vendor/golang.org/x/sys/unix/sockcmsg_unix.go --- a/vendor/golang.org/x/sys/unix/sockcmsg_unix.go Wed Sep 18 19:17:42 2019 +0200 +++ b/vendor/golang.org/x/sys/unix/sockcmsg_unix.go Sun Feb 16 18:54:01 2020 +0100 @@ -8,19 +8,9 @@ package unix -import "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 - } - return (salen + salign - 1) & ^(salign - 1) -} +import ( + "unsafe" +) // CmsgLen returns the value to store in the Len field of the Cmsghdr // structure, taking into account any necessary alignment. @@ -34,8 +24,8 @@ return cmsgAlignOf(SizeofCmsghdr) + cmsgAlignOf(datalen) } -func cmsgData(h *Cmsghdr) unsafe.Pointer { - return unsafe.Pointer(uintptr(unsafe.Pointer(h)) + uintptr(cmsgAlignOf(SizeofCmsghdr))) +func (h *Cmsghdr) data(offset uintptr) unsafe.Pointer { + return unsafe.Pointer(uintptr(unsafe.Pointer(h)) + uintptr(cmsgAlignOf(SizeofCmsghdr)) + offset) } // SocketControlMessage represents a socket control message. @@ -78,10 +68,8 @@ h.Level = SOL_SOCKET h.Type = SCM_RIGHTS h.SetLen(CmsgLen(datalen)) - data := cmsgData(h) - for _, fd := range fds { - *(*int32)(data) = int32(fd) - data = unsafe.Pointer(uintptr(data) + 4) + for i, fd := range fds { + *(*int32)(h.data(4 * uintptr(i))) = int32(fd) } return b }