diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-09-09 16:39:44 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-09-09 16:39:44 +0000 |
commit | e0e26b4b6e3deef337e7c603d6dde28e22ac7df5 (patch) | |
tree | b38452d48d41a4ced2a23d9cc03ac7fd867d297c /libgo/runtime/proc.c | |
parent | 5addc9d99073358c4e147d800639255fc3a69f03 (diff) | |
download | gcc-e0e26b4b6e3deef337e7c603d6dde28e22ac7df5.tar.gz |
runtime: use alignof to check alignment of ucontext_t
Use alignof rather than assuming a 16 byte alignment.
Reviewed-on: https://go-review.googlesource.com/28913
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@240047 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/runtime/proc.c')
-rw-r--r-- | libgo/runtime/proc.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libgo/runtime/proc.c b/libgo/runtime/proc.c index 7e2b172492e..6ac8857338b 100644 --- a/libgo/runtime/proc.c +++ b/libgo/runtime/proc.c @@ -166,7 +166,13 @@ static ucontext_t* ucontext_arg(void** go_ucontext) { uintptr_t p = (uintptr_t)go_ucontext; - p = (p + 15) &~ (uintptr_t)0xf; + size_t align = __alignof__(ucontext_t); + if(align > 16) { + // We only ensured space for up to a 16 byte alignment + // in libgo/go/runtime/runtime2.go. + runtime_throw("required alignment of ucontext_t too large"); + } + p = (p + align - 1) &~ (uintptr_t)(align - 1); return (ucontext_t*)p; } |