On Sep 09 2016, Ian Lance Taylor <i...@golang.org> wrote:

> Index: libgo/runtime/proc.c
> ===================================================================
> --- libgo/runtime/proc.c      (revision 239872)
> +++ libgo/runtime/proc.c      (working copy)
> @@ -156,6 +156,20 @@ fixcontext(ucontext_t *c)
>  
>  #endif
>  
> +// ucontext_arg returns a properly aligned ucontext_t value.  On some
> +// systems a ucontext_t value must be aligned to a 16-byte boundary.
> +// The g structure that has fields of type ucontext_t is defined in
> +// Go, and Go has no simple way to align a field to such a boundary.
> +// So we make the field larger in runtime2.go and pick an appropriate
> +// offset within the field here.
> +static ucontext_t*
> +ucontext_arg(void** go_ucontext)
> +{
> +     uintptr_t p = (uintptr_t)go_ucontext;
> +     p = (p + 15) &~ (uintptr_t)0xf;
> +     return (ucontext_t*)p;
> +}
> +

You should use alignof(ucontext_t) instead of hardcoding 16.

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

Reply via email to