Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

options/ansi: provide _setjmp and _longjmp in setjmp.h #1233

Merged
merged 1 commit into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions options/ansi/include/setjmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ typedef struct __jmp_buf {
__attribute__((__returns_twice__)) int setjmp(jmp_buf __buffer);
__attribute__((__noreturn__)) void longjmp(jmp_buf __buffer, int __value);

/* setjmp is defined as a function macro in the ISO C standard */
#define setjmp(env) setjmp(env)
mintsuki marked this conversation as resolved.
Show resolved Hide resolved

#if __MLIBC_POSIX_OPTION
__attribute__((__returns_twice__)) int _setjmp(jmp_buf __buffer);
/* POSIX-2017.1 says _longjmp shall be declared as a function */
__attribute__((__noreturn__)) void _longjmp(jmp_buf __buffer, int __value);
#endif /* __MLIBC_POSIX_OPTION */

#endif /* !__MLIBC_ABI_ONLY */

/* POSIX Non-local jumps signal extensions */
Expand Down
6 changes: 6 additions & 0 deletions options/internal/aarch64/setjmp.S
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ __setjmp:

.global setjmp
.type setjmp, "function"
.global _setjmp
.type _setjmp, "function"
setjmp:
_setjmp:
mov x2, xzr
b __setjmp

Expand All @@ -39,7 +42,10 @@ sigsetjmp:

.global longjmp
.type longjmp, "function"
.global _longjmp
.type _longjmp, "function"
longjmp:
_longjmp:
ldp x19, x20, [x0, #0]
ldp x21, x22, [x0, #16]
ldp x23, x24, [x0, #32]
Expand Down
6 changes: 6 additions & 0 deletions options/internal/m68k/setjmp.S
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ __setjmp:

.global setjmp
.type setjmp, "function"
.global _setjmp
.type _setjmp, "function"
setjmp:
_setjmp:
clr.l %d0
jmp __setjmp

Expand All @@ -31,7 +34,10 @@ sigsetjmp:

.global longjmp
.type longjmp, "function"
.global _longjmp
.type _longjmp, "function"
longjmp:
_longjmp:
movea.l 4(%sp),%a0
move.l 8(%sp),%d0
bne 1f
Expand Down
6 changes: 6 additions & 0 deletions options/internal/riscv64/setjmp.S
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
.global setjmp
.type setjmp, "function"
.global _setjmp
.type _setjmp, "function"
setjmp:
_setjmp:
sd ra, 0(a0)
sd s0, 8(a0)
sd s1, 16(a0)
Expand Down Expand Up @@ -37,7 +40,10 @@ sigsetjmp:

.global longjmp
.type longjmp, "function"
.global _longjmp
.type _longjmp, "function"
longjmp:
_longjmp:
ld ra,0(a0)
ld s0,8(a0)
ld s1,16(a0)
Expand Down
6 changes: 6 additions & 0 deletions options/internal/x86/setjmp.S
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ __setjmp:

.global setjmp
.type setjmp, "function"
.global _setjmp
.type _setjmp, "function"
setjmp:
_setjmp:
xor %edx, %edx
jmp __setjmp

Expand All @@ -34,7 +37,10 @@ sigsetjmp:

.global longjmp
.type longjmp, "function"
.global _longjmp
.type _longjmp, "function"
longjmp:
_longjmp:
mov 4(%esp), %ecx
mov 0x00(%ecx), %ebx
mov 0x04(%ecx), %ebp
Expand Down
6 changes: 6 additions & 0 deletions options/internal/x86_64/setjmp.S
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ __setjmp:

.global setjmp
.type setjmp, "function"
.global _setjmp
.type _setjmp, "function"
setjmp:
_setjmp:
xor %rdx, %rdx
jmp __setjmp

Expand All @@ -35,7 +38,10 @@ sigsetjmp:

.global longjmp
.type longjmp, "function"
.global _longjmp
.type _longjmp, "function"
longjmp:
_longjmp:
mov 0x00(%rdi), %rbx
mov 0x08(%rdi), %rbp
mov 0x10(%rdi), %r12
Expand Down
Loading