From 6a8fa7ea16d9870b21c82af67a2053cb47ed1fb4 Mon Sep 17 00:00:00 2001 From: Vitaliy Gusev Date: Mon, 20 Jul 2020 13:58:21 -0700 Subject: 12747 sigsetjmp should allow for 8 byte aligned buffer on amd64 Reviewed by: Robert Mustacchi Reviewed by: Joshua M. Clulow Approved by: Joshua M. Clulow --- usr/src/lib/libc/inc/sigjmp_struct.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'usr/src/lib/libc/inc/sigjmp_struct.h') diff --git a/usr/src/lib/libc/inc/sigjmp_struct.h b/usr/src/lib/libc/inc/sigjmp_struct.h index 988e6ca14c..7d347c2d3c 100644 --- a/usr/src/lib/libc/inc/sigjmp_struct.h +++ b/usr/src/lib/libc/inc/sigjmp_struct.h @@ -32,6 +32,7 @@ extern "C" { #include #include +#include #include #include @@ -73,6 +74,20 @@ typedef struct { #endif /* __sparc */ +#if defined(__amd64) +/* + * The "sigjmp_buf" type is an array of long and thus can have 8-byte alignment + * on AMD64 systems. The "ucontext_t" type has a stricter 16-byte alignment + * requirement, so we must round the pointer up when casting. + * + * This is not required on other architectures: + * - SPARC does not store the ucontext_t in the sigjmp_buf + * - i386 only requires 4-byte alignment for ucontext_t + */ +#define SIGJMP2UCONTEXT(x) \ + ((ucontext_t *)P2ROUNDUP((uintptr_t)(x), sizeof (upad128_t))) +#endif + #ifdef __cplusplus } #endif -- cgit v1.2.3