From 0248e6ae2796648f8446d1d35ce680d9c5c685bc Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Boric Date: Wed, 25 Aug 2021 17:11:34 +0200 Subject: [PATCH] LibC: Check for expected size of struct __jmp_buf This structure is accessed through assembly code inside setjmp.S, make some effort to ensure both header and assembly files are in sync. --- Userland/Libraries/LibC/setjmp.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Userland/Libraries/LibC/setjmp.h b/Userland/Libraries/LibC/setjmp.h index bb08783088..25e47d8703 100644 --- a/Userland/Libraries/LibC/setjmp.h +++ b/Userland/Libraries/LibC/setjmp.h @@ -45,6 +45,14 @@ struct __jmp_buf { typedef struct __jmp_buf jmp_buf[1]; typedef struct __jmp_buf sigjmp_buf[1]; +#ifdef __i386__ +static_assert(sizeof(struct __jmp_buf) == 32, "struct __jmp_buf unsynchronized with i386/setjmp.S"); +#elif __x86_64__ +static_assert(sizeof(struct __jmp_buf) == 72, "struct __jmp_buf unsynchronized with x86_64/setjmp.S"); +#else +# error +#endif + /** * Calling conventions mandates that sigsetjmp() cannot call setjmp(), * otherwise the restored calling environment will not be the original caller's