From bdca3802c9c9d033fbc553ed24b92ac78859a463 Mon Sep 17 00:00:00 2001 From: Calin Juravle Date: Wed, 28 May 2014 15:56:46 +0100 Subject: Remove unnecessary padding in ucontext_t - removed extra padding from ucontex_t on x86, x86_64 and mips - force ucontext_t struct to use 64 bits for the sigmask on all arches (previsouly wrong since sigset_t on arm and x86 is only 32 bits) - arm and arm64 continue to use padding to match glibc sigset_t This brings Bionic on par with the kernel w.r.t ucontext padding. Bug: 12828904 Change-Id: Ia8915ace694ecb4695603a334e697985f4c3e7aa --- libc/include/sys/ucontext.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/libc/include/sys/ucontext.h b/libc/include/sys/ucontext.h index d6c6b43..f62380d 100644 --- a/libc/include/sys/ucontext.h +++ b/libc/include/sys/ucontext.h @@ -68,8 +68,13 @@ typedef struct ucontext { struct ucontext* uc_link; stack_t uc_stack; mcontext_t uc_mcontext; - sigset_t uc_sigmask; - char __padding[128 - sizeof(sigset_t)]; + // Android has a wrong (smaller) sigset_t on ARM. + union { + sigset_t bionic; + uint32_t kernel[2]; + } uc_sigmask; + // The kernel adds extra padding after uc_sigmask to match glibc sigset_t on ARM. + char __padding[120]; unsigned long uc_regspace[128] __attribute__((__aligned__(8))); } ucontext_t; @@ -83,6 +88,7 @@ typedef struct ucontext { struct ucontext *uc_link; stack_t uc_stack; sigset_t uc_sigmask; + // The kernel adds extra padding after uc_sigmask to match glibc sigset_t on ARM64. char __padding[128 - sizeof(sigset_t)]; mcontext_t uc_mcontext; } ucontext_t; @@ -146,8 +152,11 @@ typedef struct ucontext { struct ucontext* uc_link; stack_t uc_stack; mcontext_t uc_mcontext; - sigset_t uc_sigmask; - char __padding[128 - sizeof(sigset_t)]; + // Android has a wrong (smaller) sigset_t on x86. + union { + sigset_t bionic; + uint32_t kernel[2]; + } uc_sigmask; struct _libc_fpstate __fpregs_mem; } ucontext_t; @@ -198,7 +207,6 @@ typedef struct ucontext { stack_t uc_stack; mcontext_t uc_mcontext; sigset_t uc_sigmask; - char __padding[128 - sizeof(sigset_t)]; } ucontext_t; #elif defined(__mips64__) @@ -275,7 +283,6 @@ typedef struct ucontext { stack_t uc_stack; mcontext_t uc_mcontext; sigset_t uc_sigmask; - char __padding[128 - sizeof(sigset_t)]; struct _libc_fpstate __fpregs_mem; } ucontext_t; -- cgit v1.1