summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibC
diff options
context:
space:
mode:
authorBrian Gianforcaro <bgianf@serenityos.org>2021-12-24 03:28:06 -0800
committerBrian Gianforcaro <b.gianfo@gmail.com>2021-12-24 05:26:21 -0800
commit49749e279aeab4a3da0e6e94333aaa8125ecb1a4 (patch)
tree70016656030ca8b3a27abfbaa4ff5364b3f3fb1a /Userland/Libraries/LibC
parenteefe471dce7cd7563fa83f20dd774ef1d6a5168a (diff)
downloadserenity-49749e279aeab4a3da0e6e94333aaa8125ecb1a4.zip
LibC: Implement _setjmp and _longjmp
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.
Diffstat (limited to 'Userland/Libraries/LibC')
-rw-r--r--Userland/Libraries/LibC/arch/i386/setjmp.S4
-rw-r--r--Userland/Libraries/LibC/setjmp.h12
2 files changed, 16 insertions, 0 deletions
diff --git a/Userland/Libraries/LibC/arch/i386/setjmp.S b/Userland/Libraries/LibC/arch/i386/setjmp.S
index 27c934f80e..dff0361ca4 100644
--- a/Userland/Libraries/LibC/arch/i386/setjmp.S
+++ b/Userland/Libraries/LibC/arch/i386/setjmp.S
@@ -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
@@ -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
diff --git a/Userland/Libraries/LibC/setjmp.h b/Userland/Libraries/LibC/setjmp.h
index f55eba523b..2c998b4237 100644
--- a/Userland/Libraries/LibC/setjmp.h
+++ b/Userland/Libraries/LibC/setjmp.h
@@ -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