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
This commit is contained in:
Calin Juravle 2014-05-28 15:56:46 +01:00
parent 7fdde4a58b
commit bdca3802c9
1 changed files with 13 additions and 6 deletions

View File

@ -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;