On Fri, Sep 9, 2016 at 6:52 AM, Andreas Schwab <sch...@linux-m68k.org> wrote:
>
> You should use alignof(ucontext_t) instead of hardcoding 16.

Fair enough.  Done like so.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu, committed to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE     (revision 240045)
+++ gcc/go/gofrontend/MERGE     (working copy)
@@ -1,4 +1,4 @@
-b37a9e66ea584885043240f8f6f1d1c0284eadec
+6c1f159cdcb56ebff617f6bbc6c97943a1a8a34d
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/runtime/proc.c
===================================================================
--- libgo/runtime/proc.c        (revision 240045)
+++ libgo/runtime/proc.c        (working copy)
@@ -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;
 }
 

Reply via email to