-
Notifications
You must be signed in to change notification settings - Fork 17.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
syscall: don't use 32-bit aligned access for cmsgAlignOf on dragonfly…
… after ABI change Use 32-bit alignment for versions before the September 2019 ABI changes http://lists.dragonflybsd.org/pipermail/users/2019-September/358280.html Fixes #34958 Change-Id: Iab4b23083a7c9ca7e96a737b03e75cd36d98ee24 Reviewed-on: https://go-review.googlesource.com/c/go/+/201977 Run-TryBot: Tobias Klauser <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
- Loading branch information
Showing
4 changed files
with
73 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright 2019 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package syscall | ||
|
||
// Round the length of a raw sockaddr up to align it properly. | ||
func cmsgAlignOf(salen int) int { | ||
salign := sizeofPtr | ||
if sizeofPtr == 8 && !supportsABI(_dragonflyABIChangeVersion) { | ||
// 64-bit Dragonfly before the September 2019 ABI changes still requires | ||
// 32-bit aligned access to network subsystem. | ||
salign = 4 | ||
} | ||
return (salen + salign - 1) & ^(salign - 1) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2019 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// +build aix darwin freebsd linux netbsd openbsd solaris | ||
|
||
package syscall | ||
|
||
import ( | ||
"runtime" | ||
) | ||
|
||
// Round the length of a raw sockaddr up to align it properly. | ||
func cmsgAlignOf(salen int) int { | ||
salign := sizeofPtr | ||
|
||
// dragonfly needs to check ABI version at runtime, see cmsgAlignOf in | ||
// sockcmsg_dragonfly.go | ||
switch runtime.GOOS { | ||
case "aix": | ||
// There is no alignment on AIX. | ||
salign = 1 | ||
case "darwin", "illumos", "solaris": | ||
// NOTE: It seems like 64-bit Darwin, 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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters