Skip to content

Commit

Permalink
LibC: Implement _setjmp and _longjmp
Browse files Browse the repository at this point in the history
These are aliases to `setjmp()` and `longjmp()` on our system,
as our implementations don't modify the signal mask.

This is required for the syzkaller executor process.
  • Loading branch information
bgianfo committed Dec 24, 2021
1 parent eefe471 commit 49749e2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Userland/Libraries/LibC/arch/i386/setjmp.S
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
mov (%esp), %ebx
ret

.global _setjmp
.global setjmp
_setjmp:
setjmp:
xor %eax, %eax // Grab val argument (hardcoded to zero)
jmp .Lsigset_common
Expand Down Expand Up @@ -57,7 +59,9 @@ sigsetjmp:
xor %eax, %eax
ret

.global _longjmp
.global longjmp
_longjmp:
longjmp:
mov 4(%esp), %ecx // Grab jmp_buf argument
mov 8(%esp), %eax // Grab val argument
Expand Down
12 changes: 12 additions & 0 deletions Userland/Libraries/LibC/setjmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,16 @@ __attribute__((noreturn)) void longjmp(jmp_buf, int val);
int sigsetjmp(sigjmp_buf, int savesigs);
__attribute__((noreturn)) void siglongjmp(sigjmp_buf, int val);

/**
* _setjmp() and _longjmp() are specified as behaving the exactly the same as
* setjmp() and longjmp(), except they are not supposed to modify the signal mask.
*
* Our implementations already follow this restriction, so we just map them directly
* to the same functions.
*
* https://pubs.opengroup.org/onlinepubs/9699969599/functions/_setjmp.html
*/
int _setjmp(jmp_buf);
__attribute__((noreturn)) void _longjmp(jmp_buf, int val);

__END_DECLS

0 comments on commit 49749e2

Please sign in to comment.