From f0db7eae74ea235e9fbc2598252bfd46c1cc5510 Mon Sep 17 00:00:00 2001 From: Rhys Hiltner Date: Wed, 29 Sep 2021 17:35:27 -0700 Subject: 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 TryBot-Result: Go Bot Reviewed-by: Michael Pratt Trust: Michael Knyszek --- src/runtime/os_linux.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/runtime/os_linux.go') 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) { -- cgit v1.3-5-g9baa