diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2016-09-09 13:31:49 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2016-09-09 13:31:49 +0000 |
commit | 6f02c138136e54ec525d81e604427782cacec378 (patch) | |
tree | d4fd6aada5043cfd7bff984cbe0d0a5ef059bfde /libgo/go | |
parent | 0abcd6cc738c5afd131c232ddb6809e6ff8e8def (diff) | |
download | gcc-6f02c138136e54ec525d81e604427782cacec378.zip gcc-6f02c138136e54ec525d81e604427782cacec378.tar.gz gcc-6f02c138136e54ec525d81e604427782cacec378.tar.bz2 |
runtime: align ucontext_t argument to 16 byte boundary
Some systems, such as ia64 and PPC, require that a ucontext_t pointer
passed to getcontext and friends be aligned to a 16-byte boundary.
Currently the ucontext_t fields in the g structure are defined in Go,
and Go has no way to ensure a 16-byte alignment for a struct field.
The fields are currently represented by an array of unsafe.Pointer.
Enforce the alignment by making the array larger, and picking an offset
into the array that is 16-byte aligned.
Reviewed-on: https://go-review.googlesource.com/28910
From-SVN: r240044
Diffstat (limited to 'libgo/go')
-rw-r--r-- | libgo/go/runtime/runtime2.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libgo/go/runtime/runtime2.go b/libgo/go/runtime/runtime2.go index 05ce513..468d11e 100644 --- a/libgo/go/runtime/runtime2.go +++ b/libgo/go/runtime/runtime2.go @@ -805,7 +805,11 @@ var ( // _ucontext_t is a Go version of the C ucontext_t type, used by getcontext. // _sizeof_ucontext_t is defined by the Makefile from <ucontext.h>. -type _ucontext_t [_sizeof_ucontext_t / unsafe.Sizeof(uintptr(0))]unsafe.Pointer +// On some systems getcontext and friends require a value that is +// aligned to a 16-byte boundary. We implement this by increasing the +// required size and picking an appropriate offset when we use the +// array. +type _ucontext_t [(_sizeof_ucontext_t + 15) / unsafe.Sizeof(unsafe.Pointer(nil))]unsafe.Pointer // traceback is used to collect stack traces from other goroutines. type traceback struct { |