1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:27:35 +00:00

LibC: Fix sigsetjmp and siglongjmp

This commit is contained in:
Jean-Baptiste Boric 2021-08-14 00:32:19 +02:00 committed by Andreas Kling
parent 6165811081
commit c972afbea6
4 changed files with 139 additions and 61 deletions

View file

@ -14,25 +14,51 @@
__BEGIN_DECLS
//
// /!\ This structure is accessed inside setjmp.S, keep both files in sync!
//
struct __jmp_buf {
#ifdef __i386__
uint32_t regs[6];
uint32_t ebx;
uint32_t esi;
uint32_t edi;
uint32_t ebp;
uint32_t esp;
uint32_t eip;
#elif __x86_64__
uint64_t regs[8];
uint64_t rbx;
uint64_t r12;
uint64_t r13;
uint64_t r14;
uint64_t r15;
uint64_t rbp;
uint64_t rsp;
uint64_t rip;
#else
# error
#endif
bool did_save_signal_mask;
int did_save_signal_mask;
sigset_t saved_signal_mask;
};
typedef struct __jmp_buf jmp_buf[1];
typedef struct __jmp_buf sigjmp_buf[1];
/**
* Calling conventions mandates that sigsetjmp() cannot call setjmp(),
* otherwise the restored calling environment will not be the original caller's
* but sigsetjmp()'s and we'll return to the wrong call site on siglongjmp().
*
* The setjmp(), sigsetjmp() and longjmp() functions have to be implemented in
* assembly because they touch the call stack and registers in non-portable
* ways. However, we *can* implement siglongjmp() as a standard C function.
*/
int setjmp(jmp_buf);
void longjmp(jmp_buf, int val);
__attribute__((noreturn)) void longjmp(jmp_buf, int val);
int sigsetjmp(sigjmp_buf, int savesigs);
void siglongjmp(sigjmp_buf, int val);
__attribute__((noreturn)) void siglongjmp(sigjmp_buf, int val);
__END_DECLS