git: 6e48e160ae93 - main - powerpc: Add static asssert for context size

From: Warner Losh <imp_at_FreeBSD.org>
Date: Thu, 10 Feb 2022 21:34:02 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=6e48e160ae935a3fde656c975c3f38aaae54707c

commit 6e48e160ae935a3fde656c975c3f38aaae54707c
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2022-02-10 21:27:08 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2022-02-10 21:32:20 +0000

    powerpc: Add static asssert for context size
    
    Add a static assert for the siginfo_t, mcontext_t and ucontext_t
    sizes. These are de-facto ABI options and cannot change size ever. For
    powerpc64, also add asserts for {u,m}mcontext32_t and siginfo32.
    
    Reviewed by:            andrew
    Differential Revision:  https://reviews.freebsd.org/D34213
---
 sys/powerpc/powerpc/exec_machdep.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/sys/powerpc/powerpc/exec_machdep.c b/sys/powerpc/powerpc/exec_machdep.c
index 66bc951fc545..572ddfa44d1f 100644
--- a/sys/powerpc/powerpc/exec_machdep.c
+++ b/sys/powerpc/powerpc/exec_machdep.c
@@ -130,6 +130,21 @@ static void	cleanup_power_extras(struct thread *);
 extern struct sysentvec elf64_freebsd_sysvec_v2;
 #endif
 
+#ifdef __powerpc64__
+_Static_assert(sizeof(mcontext_t) == 1392, "mcontext_t size incorrect");
+_Static_assert(sizeof(ucontext_t) == 1472, "ucontext_t size incorrect");
+_Static_assert(sizeof(siginfo_t) == 80, "siginfo_t size incorrect");
+#ifdef COMPAT_FREEBSD32
+_Static_assert(sizeof(mcontext32_t) == 1224, "mcontext32_t size incorrect");
+_Static_assert(sizeof(ucontext32_t) == 1280, "ucontext32_t size incorrect");
+_Static_assert(sizeof(struct siginfo32) == 64, "struct siginfo32 size incorrect");
+#endif /* COMPAT_FREEBSD32 */
+#else /* powerpc */
+_Static_assert(sizeof(mcontext_t) == 1224, "mcontext_t size incorrect");
+_Static_assert(sizeof(ucontext_t) == 1280, "ucontext_t size incorrect");
+_Static_assert(sizeof(siginfo_t) == 64, "siginfo_t size incorrect");
+#endif
+
 void
 sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
 {