diff options
author | Stefan O'Rear <sorear@fastmail.com> | 2020-09-03 05:54:44 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2024-02-29 16:36:55 -0500 |
commit | c34a8eedff904b7f3d8479bbec0be534e7a01fbb (patch) | |
tree | a7fe3d205d4ca457dc6947d3360a98ba61d8dcbf /src | |
parent | 11eee89e14ca7ea2ccc02385c3ab7875fb572d46 (diff) | |
download | musl-c34a8eedff904b7f3d8479bbec0be534e7a01fbb.zip musl-c34a8eedff904b7f3d8479bbec0be534e7a01fbb.tar.gz musl-c34a8eedff904b7f3d8479bbec0be534e7a01fbb.tar.bz2 |
riscv32: add setjmp/longjmp and sigreturn
Largely copied from riscv64 but required recalculation of offsets.
Diffstat (limited to 'src')
-rw-r--r-- | src/setjmp/riscv32/longjmp.S | 42 | ||||
-rw-r--r-- | src/setjmp/riscv32/setjmp.S | 41 | ||||
-rw-r--r-- | src/signal/riscv32/restore.s | 8 | ||||
-rw-r--r-- | src/signal/riscv32/sigsetjmp.s | 23 |
4 files changed, 114 insertions, 0 deletions
diff --git a/src/setjmp/riscv32/longjmp.S b/src/setjmp/riscv32/longjmp.S new file mode 100644 index 0000000..f9cb331 --- /dev/null +++ b/src/setjmp/riscv32/longjmp.S @@ -0,0 +1,42 @@ +.global __longjmp +.global _longjmp +.global longjmp +.type __longjmp, %function +.type _longjmp, %function +.type longjmp, %function +__longjmp: +_longjmp: +longjmp: + lw s0, 0(a0) + lw s1, 4(a0) + lw s2, 8(a0) + lw s3, 12(a0) + lw s4, 16(a0) + lw s5, 20(a0) + lw s6, 24(a0) + lw s7, 28(a0) + lw s8, 32(a0) + lw s9, 36(a0) + lw s10, 40(a0) + lw s11, 44(a0) + lw sp, 48(a0) + lw ra, 52(a0) + +#ifndef __riscv_float_abi_soft + fld fs0, 56(a0) + fld fs1, 64(a0) + fld fs2, 72(a0) + fld fs3, 80(a0) + fld fs4, 88(a0) + fld fs5, 96(a0) + fld fs6, 104(a0) + fld fs7, 112(a0) + fld fs8, 120(a0) + fld fs9, 128(a0) + fld fs10, 136(a0) + fld fs11, 144(a0) +#endif + + seqz a0, a1 + add a0, a0, a1 + ret diff --git a/src/setjmp/riscv32/setjmp.S b/src/setjmp/riscv32/setjmp.S new file mode 100644 index 0000000..8a75cf5 --- /dev/null +++ b/src/setjmp/riscv32/setjmp.S @@ -0,0 +1,41 @@ +.global __setjmp +.global _setjmp +.global setjmp +.type __setjmp, %function +.type _setjmp, %function +.type setjmp, %function +__setjmp: +_setjmp: +setjmp: + sw s0, 0(a0) + sw s1, 4(a0) + sw s2, 8(a0) + sw s3, 12(a0) + sw s4, 16(a0) + sw s5, 20(a0) + sw s6, 24(a0) + sw s7, 28(a0) + sw s8, 32(a0) + sw s9, 36(a0) + sw s10, 40(a0) + sw s11, 44(a0) + sw sp, 48(a0) + sw ra, 52(a0) + +#ifndef __riscv_float_abi_soft + fsd fs0, 56(a0) + fsd fs1, 64(a0) + fsd fs2, 72(a0) + fsd fs3, 80(a0) + fsd fs4, 88(a0) + fsd fs5, 96(a0) + fsd fs6, 104(a0) + fsd fs7, 112(a0) + fsd fs8, 120(a0) + fsd fs9, 128(a0) + fsd fs10, 136(a0) + fsd fs11, 144(a0) +#endif + + li a0, 0 + ret diff --git a/src/signal/riscv32/restore.s b/src/signal/riscv32/restore.s new file mode 100644 index 0000000..40012c7 --- /dev/null +++ b/src/signal/riscv32/restore.s @@ -0,0 +1,8 @@ +.global __restore +.type __restore, %function +__restore: +.global __restore_rt +.type __restore_rt, %function +__restore_rt: + li a7, 139 # SYS_rt_sigreturn + ecall diff --git a/src/signal/riscv32/sigsetjmp.s b/src/signal/riscv32/sigsetjmp.s new file mode 100644 index 0000000..c1caeab --- /dev/null +++ b/src/signal/riscv32/sigsetjmp.s @@ -0,0 +1,23 @@ +.global sigsetjmp +.global __sigsetjmp +.type sigsetjmp, %function +.type __sigsetjmp, %function +sigsetjmp: +__sigsetjmp: + bnez a1, 1f + tail setjmp +1: + + sw ra, 152(a0) + sw s0, 164(a0) + mv s0, a0 + + call setjmp + + mv a1, a0 + mv a0, s0 + lw s0, 164(a0) + lw ra, 152(a0) + +.hidden __sigsetjmp_tail + tail __sigsetjmp_tail |