diff options
| author | Rhys Hiltner <rhys@justin.tv> | 2021-09-29 17:35:27 -0700 |
|---|---|---|
| committer | Ian Lance Taylor <iant@golang.org> | 2021-11-02 05:43:05 +0000 |
| commit | a97c527ac491cc13f6778010a2a81c84642ea1ca (patch) | |
| tree | c42e74ac36841f3ae0b439ef44243f9a2fcd0502 /src/runtime/os_linux.go | |
| parent | 6f327f7b889b81549d551ce6963067267578bd70 (diff) | |
| download | go-a97c527ac491cc13f6778010a2a81c84642ea1ca.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, and to CL 353136 which added the padding but with an assertion
that confused several type-checkers. It updates the siginfo struct as
well so there are no bad examples in the defs_linux_*.go files.
Reviewed-on: https://go-review.googlesource.com/c/go/+/353136
Change-Id: I9610632ff0ec43eba91f560536f5441fa907b36f
Reviewed-on: https://go-review.googlesource.com/c/go/+/360094
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/runtime/os_linux.go')
| -rw-r--r-- | src/runtime/os_linux.go | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/runtime/os_linux.go b/src/runtime/os_linux.go index 06773c2193..32a1e1b4f7 100644 --- a/src/runtime/os_linux.go +++ b/src/runtime/os_linux.go @@ -440,6 +440,11 @@ 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 +) + //go:nosplit //go:nowritebarrierrec func setsig(i uint32, fn uintptr) { @@ -636,12 +641,11 @@ func setThreadCPUProfiler(hz int32) { spec.it_interval.setNsec(1e9 / int64(hz)) var timerid int32 - sevp := &sigevent{ - notify: _SIGEV_THREAD_ID, - signo: _SIGPROF, - sigev_notify_thread_id: int32(mp.procid), - } - ret := timer_create(_CLOCK_THREAD_CPUTIME_ID, sevp, &timerid) + var sevp sigevent + sevp.notify = _SIGEV_THREAD_ID + sevp.signo = _SIGPROF + sevp.sigev_notify_thread_id = int32(mp.procid) + ret := timer_create(_CLOCK_THREAD_CPUTIME_ID, &sevp, &timerid) if ret != 0 { // If we cannot create a timer for this M, leave profileTimerValid false // to fall back to the process-wide setitimer profiler. |
