aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/os_linux.go
diff options
context:
space:
mode:
authorRhys Hiltner <rhys@justin.tv>2021-09-29 17:35:27 -0700
committerMichael Pratt <mpratt@google.com>2021-10-04 21:10:16 +0000
commitf0db7eae74ea235e9fbc2598252bfd46c1cc5510 (patch)
tree049a87ed3f3bc9264c5942d99818e371371a5c72 /src/runtime/os_linux.go
parente8a85e90aca4adb472c66f8c42f6d4a41b8cca99 (diff)
downloadgo-f0db7eae74ea235e9fbc2598252bfd46c1cc5510.tar.xz
runtime: add padding to Linux kernel structures
Go exchanges siginfo and sigevent structures with the kernel. They contain unions, but Go's use is limited to the first few fields. Pad out the rest so the size Go sees is the same as what the Linux kernel sees. This is a follow-up to CL 342052 which added the sigevent struct without padding. It updates the siginfo struct as well so there are no bad examples in the defs_linux_*.go files. Change-Id: Id991d4a57826677dd7e6cc30ad113fa3b321cddf Reviewed-on: https://go-review.googlesource.com/c/go/+/353136 Run-TryBot: Rhys Hiltner <rhys@justin.tv> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> Trust: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/runtime/os_linux.go')
-rw-r--r--src/runtime/os_linux.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/runtime/os_linux.go b/src/runtime/os_linux.go
index 06773c2193..d5a5ff763b 100644
--- a/src/runtime/os_linux.go
+++ b/src/runtime/os_linux.go
@@ -440,6 +440,18 @@ func pipe() (r, w int32, errno int32)
func pipe2(flags int32) (r, w int32, errno int32)
func setNonblock(fd int32)
+const (
+ _si_max_size = 128
+ _sigev_max_size = 64
+)
+
+// Assert that the Go definitions of structures exchanged with the kernel are
+// the same size as what the kernel defines.
+var (
+ _ [_si_max_size]struct{} = [unsafe.Sizeof(siginfo{})]struct{}{}
+ _ [_sigev_max_size]struct{} = [unsafe.Sizeof(sigevent{})]struct{}{}
+)
+
//go:nosplit
//go:nowritebarrierrec
func setsig(i uint32, fn uintptr) {