diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 13:54:38 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 13:54:38 +0000 |
commit | 8c1ab65c0f548d20b7f177bdb736daaf603340e1 (patch) | |
tree | df55b7e75bf43f2bf500845b105afe3ac3a5157e /libc-top-half/musl/src/setjmp | |
parent | Initial commit. (diff) | |
download | wasi-libc-upstream/0.0_git20221206.8b7148f.tar.xz wasi-libc-upstream/0.0_git20221206.8b7148f.zip |
Adding upstream version 0.0~git20221206.8b7148f.upstream/0.0_git20221206.8b7148f
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libc-top-half/musl/src/setjmp')
34 files changed, 1174 insertions, 0 deletions
diff --git a/libc-top-half/musl/src/setjmp/aarch64/longjmp.s b/libc-top-half/musl/src/setjmp/aarch64/longjmp.s new file mode 100644 index 0000000..0af9c50 --- /dev/null +++ b/libc-top-half/musl/src/setjmp/aarch64/longjmp.s @@ -0,0 +1,23 @@ +.global _longjmp +.global longjmp +.type _longjmp,%function +.type longjmp,%function +_longjmp: +longjmp: + // IHI0055B_aapcs64.pdf 5.1.1, 5.1.2 callee saved registers + ldp x19, x20, [x0,#0] + ldp x21, x22, [x0,#16] + ldp x23, x24, [x0,#32] + ldp x25, x26, [x0,#48] + ldp x27, x28, [x0,#64] + ldp x29, x30, [x0,#80] + ldr x2, [x0,#104] + mov sp, x2 + ldp d8 , d9, [x0,#112] + ldp d10, d11, [x0,#128] + ldp d12, d13, [x0,#144] + ldp d14, d15, [x0,#160] + + cmp w1, 0 + csinc w0, w1, wzr, ne + br x30 diff --git a/libc-top-half/musl/src/setjmp/aarch64/setjmp.s b/libc-top-half/musl/src/setjmp/aarch64/setjmp.s new file mode 100644 index 0000000..f49288a --- /dev/null +++ b/libc-top-half/musl/src/setjmp/aarch64/setjmp.s @@ -0,0 +1,24 @@ +.global __setjmp +.global _setjmp +.global setjmp +.type __setjmp,@function +.type _setjmp,@function +.type setjmp,@function +__setjmp: +_setjmp: +setjmp: + // IHI0055B_aapcs64.pdf 5.1.1, 5.1.2 callee saved registers + stp x19, x20, [x0,#0] + stp x21, x22, [x0,#16] + stp x23, x24, [x0,#32] + stp x25, x26, [x0,#48] + stp x27, x28, [x0,#64] + stp x29, x30, [x0,#80] + mov x2, sp + str x2, [x0,#104] + stp d8, d9, [x0,#112] + stp d10, d11, [x0,#128] + stp d12, d13, [x0,#144] + stp d14, d15, [x0,#160] + mov x0, #0 + ret diff --git a/libc-top-half/musl/src/setjmp/arm/longjmp.S b/libc-top-half/musl/src/setjmp/arm/longjmp.S new file mode 100644 index 0000000..8df0b81 --- /dev/null +++ b/libc-top-half/musl/src/setjmp/arm/longjmp.S @@ -0,0 +1,50 @@ +.syntax unified +.global _longjmp +.global longjmp +.type _longjmp,%function +.type longjmp,%function +_longjmp: +longjmp: + mov ip,r0 + movs r0,r1 + moveq r0,#1 + ldmia ip!, {v1,v2,v3,v4,v5,v6,sl,fp} + ldmia ip!, {r2,lr} + mov sp,r2 + + adr r1,1f + ldr r2,1f + ldr r1,[r1,r2] + +#if __ARM_ARCH < 8 + tst r1,#0x260 + beq 3f + // HWCAP_ARM_FPA + tst r1,#0x20 + beq 2f + ldc p2, cr4, [ip], #48 +#endif +2: tst r1,#0x40 + beq 2f + .fpu vfp + vldmia ip!, {d8-d15} + .fpu softvfp + .eabi_attribute 10, 0 + .eabi_attribute 27, 0 +#if __ARM_ARCH < 8 + // HWCAP_ARM_IWMMXT +2: tst r1,#0x200 + beq 3f + ldcl p1, cr10, [ip], #8 + ldcl p1, cr11, [ip], #8 + ldcl p1, cr12, [ip], #8 + ldcl p1, cr13, [ip], #8 + ldcl p1, cr14, [ip], #8 + ldcl p1, cr15, [ip], #8 +#endif +2: +3: bx lr + +.hidden __hwcap +.align 2 +1: .word __hwcap-1b diff --git a/libc-top-half/musl/src/setjmp/arm/setjmp.S b/libc-top-half/musl/src/setjmp/arm/setjmp.S new file mode 100644 index 0000000..45731d2 --- /dev/null +++ b/libc-top-half/musl/src/setjmp/arm/setjmp.S @@ -0,0 +1,52 @@ +.syntax unified +.global __setjmp +.global _setjmp +.global setjmp +.type __setjmp,%function +.type _setjmp,%function +.type setjmp,%function +__setjmp: +_setjmp: +setjmp: + mov ip,r0 + stmia ip!,{v1,v2,v3,v4,v5,v6,sl,fp} + mov r2,sp + stmia ip!,{r2,lr} + mov r0,#0 + + adr r1,1f + ldr r2,1f + ldr r1,[r1,r2] + +#if __ARM_ARCH < 8 + tst r1,#0x260 + beq 3f + // HWCAP_ARM_FPA + tst r1,#0x20 + beq 2f + stc p2, cr4, [ip], #48 +#endif +2: tst r1,#0x40 + beq 2f + .fpu vfp + vstmia ip!, {d8-d15} + .fpu softvfp + .eabi_attribute 10, 0 + .eabi_attribute 27, 0 +#if __ARM_ARCH < 8 + // HWCAP_ARM_IWMMXT +2: tst r1,#0x200 + beq 3f + stcl p1, cr10, [ip], #8 + stcl p1, cr11, [ip], #8 + stcl p1, cr12, [ip], #8 + stcl p1, cr13, [ip], #8 + stcl p1, cr14, [ip], #8 + stcl p1, cr15, [ip], #8 +#endif +2: +3: bx lr + +.hidden __hwcap +.align 2 +1: .word __hwcap-1b diff --git a/libc-top-half/musl/src/setjmp/i386/longjmp.s b/libc-top-half/musl/src/setjmp/i386/longjmp.s new file mode 100644 index 0000000..8188f06 --- /dev/null +++ b/libc-top-half/musl/src/setjmp/i386/longjmp.s @@ -0,0 +1,16 @@ +.global _longjmp +.global longjmp +.type _longjmp,@function +.type longjmp,@function +_longjmp: +longjmp: + mov 4(%esp),%edx + mov 8(%esp),%eax + cmp $1,%eax + adc $0, %al + mov (%edx),%ebx + mov 4(%edx),%esi + mov 8(%edx),%edi + mov 12(%edx),%ebp + mov 16(%edx),%esp + jmp *20(%edx) diff --git a/libc-top-half/musl/src/setjmp/i386/setjmp.s b/libc-top-half/musl/src/setjmp/i386/setjmp.s new file mode 100644 index 0000000..4d19cf8 --- /dev/null +++ b/libc-top-half/musl/src/setjmp/i386/setjmp.s @@ -0,0 +1,23 @@ +.global ___setjmp +.hidden ___setjmp +.global __setjmp +.global _setjmp +.global setjmp +.type __setjmp,@function +.type _setjmp,@function +.type setjmp,@function +___setjmp: +__setjmp: +_setjmp: +setjmp: + mov 4(%esp), %eax + mov %ebx, (%eax) + mov %esi, 4(%eax) + mov %edi, 8(%eax) + mov %ebp, 12(%eax) + lea 4(%esp), %ecx + mov %ecx, 16(%eax) + mov (%esp), %ecx + mov %ecx, 20(%eax) + xor %eax, %eax + ret diff --git a/libc-top-half/musl/src/setjmp/longjmp.c b/libc-top-half/musl/src/setjmp/longjmp.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/libc-top-half/musl/src/setjmp/longjmp.c diff --git a/libc-top-half/musl/src/setjmp/m68k/longjmp.s b/libc-top-half/musl/src/setjmp/m68k/longjmp.s new file mode 100644 index 0000000..cdb05fb --- /dev/null +++ b/libc-top-half/musl/src/setjmp/m68k/longjmp.s @@ -0,0 +1,14 @@ +.global _longjmp +.global longjmp +.type _longjmp,@function +.type longjmp,@function +_longjmp: +longjmp: + movea.l 4(%sp),%a0 + move.l 8(%sp),%d0 + bne 1f + move.l #1,%d0 +1: movem.l (%a0),%d2-%d7/%a2-%a7 + fmovem.x 52(%a0),%fp2-%fp7 + move.l 48(%a0),(%sp) + rts diff --git a/libc-top-half/musl/src/setjmp/m68k/setjmp.s b/libc-top-half/musl/src/setjmp/m68k/setjmp.s new file mode 100644 index 0000000..15e549b --- /dev/null +++ b/libc-top-half/musl/src/setjmp/m68k/setjmp.s @@ -0,0 +1,18 @@ +.global ___setjmp +.hidden ___setjmp +.global __setjmp +.global _setjmp +.global setjmp +.type __setjmp,@function +.type _setjmp,@function +.type setjmp,@function +___setjmp: +__setjmp: +_setjmp: +setjmp: + movea.l 4(%sp),%a0 + movem.l %d2-%d7/%a2-%a7,(%a0) + move.l (%sp),48(%a0) + fmovem.x %fp2-%fp7,52(%a0) + clr.l %d0 + rts diff --git a/libc-top-half/musl/src/setjmp/microblaze/longjmp.s b/libc-top-half/musl/src/setjmp/microblaze/longjmp.s new file mode 100644 index 0000000..c076028 --- /dev/null +++ b/libc-top-half/musl/src/setjmp/microblaze/longjmp.s @@ -0,0 +1,29 @@ +.global _longjmp +.global longjmp +.type _longjmp,@function +.type longjmp,@function +_longjmp: +longjmp: + addi r3, r6, 0 + bnei r3, 1f + addi r3, r3, 1 +1: lwi r1, r5, 0 + lwi r15, r5, 4 + lwi r2, r5, 8 + lwi r13, r5, 12 + lwi r18, r5, 16 + lwi r19, r5, 20 + lwi r20, r5, 24 + lwi r21, r5, 28 + lwi r22, r5, 32 + lwi r23, r5, 36 + lwi r24, r5, 40 + lwi r25, r5, 44 + lwi r26, r5, 48 + lwi r27, r5, 52 + lwi r28, r5, 56 + lwi r29, r5, 60 + lwi r30, r5, 64 + lwi r31, r5, 68 + rtsd r15, 8 + nop diff --git a/libc-top-half/musl/src/setjmp/microblaze/setjmp.s b/libc-top-half/musl/src/setjmp/microblaze/setjmp.s new file mode 100644 index 0000000..605ab20 --- /dev/null +++ b/libc-top-half/musl/src/setjmp/microblaze/setjmp.s @@ -0,0 +1,32 @@ +.global ___setjmp +.hidden ___setjmp +.global __setjmp +.global _setjmp +.global setjmp +.type __setjmp,@function +.type _setjmp,@function +.type setjmp,@function +___setjmp: +__setjmp: +_setjmp: +setjmp: + swi r1, r5, 0 + swi r15, r5, 4 + swi r2, r5, 8 + swi r13, r5, 12 + swi r18, r5, 16 + swi r19, r5, 20 + swi r20, r5, 24 + swi r21, r5, 28 + swi r22, r5, 32 + swi r23, r5, 36 + swi r24, r5, 40 + swi r25, r5, 44 + swi r26, r5, 48 + swi r27, r5, 52 + swi r28, r5, 56 + swi r29, r5, 60 + swi r30, r5, 64 + swi r31, r5, 68 + rtsd r15, 8 + ori r3, r0, 0 diff --git a/libc-top-half/musl/src/setjmp/mips/longjmp.S b/libc-top-half/musl/src/setjmp/mips/longjmp.S new file mode 100644 index 0000000..ecf4085 --- /dev/null +++ b/libc-top-half/musl/src/setjmp/mips/longjmp.S @@ -0,0 +1,34 @@ +.set noreorder + +.global _longjmp +.global longjmp +.type _longjmp,@function +.type longjmp,@function +_longjmp: +longjmp: + move $2, $5 + bne $2, $0, 1f + nop + addu $2, $2, 1 +1: +#ifndef __mips_soft_float + l.d $f20, 56($4) + l.d $f22, 64($4) + l.d $f24, 72($4) + l.d $f26, 80($4) + l.d $f28, 88($4) + l.d $f30, 96($4) +#endif + lw $ra, 0($4) + lw $sp, 4($4) + lw $16, 8($4) + lw $17, 12($4) + lw $18, 16($4) + lw $19, 20($4) + lw $20, 24($4) + lw $21, 28($4) + lw $22, 32($4) + lw $23, 36($4) + lw $30, 40($4) + jr $ra + lw $28, 44($4) diff --git a/libc-top-half/musl/src/setjmp/mips/setjmp.S b/libc-top-half/musl/src/setjmp/mips/setjmp.S new file mode 100644 index 0000000..7ae8832 --- /dev/null +++ b/libc-top-half/musl/src/setjmp/mips/setjmp.S @@ -0,0 +1,33 @@ +.set noreorder + +.global __setjmp +.global _setjmp +.global setjmp +.type __setjmp,@function +.type _setjmp,@function +.type setjmp,@function +__setjmp: +_setjmp: +setjmp: + sw $ra, 0($4) + sw $sp, 4($4) + sw $16, 8($4) + sw $17, 12($4) + sw $18, 16($4) + sw $19, 20($4) + sw $20, 24($4) + sw $21, 28($4) + sw $22, 32($4) + sw $23, 36($4) + sw $30, 40($4) + sw $28, 44($4) +#ifndef __mips_soft_float + s.d $f20, 56($4) + s.d $f22, 64($4) + s.d $f24, 72($4) + s.d $f26, 80($4) + s.d $f28, 88($4) + s.d $f30, 96($4) +#endif + jr $ra + li $2, 0 diff --git a/libc-top-half/musl/src/setjmp/mips64/longjmp.S b/libc-top-half/musl/src/setjmp/mips64/longjmp.S new file mode 100644 index 0000000..3db8a88 --- /dev/null +++ b/libc-top-half/musl/src/setjmp/mips64/longjmp.S @@ -0,0 +1,37 @@ +.set noreorder +.global _longjmp +.global longjmp +.type _longjmp,@function +.type longjmp,@function +_longjmp: +longjmp: + move $2, $5 + + bne $2, $0, 1f + nop + daddu $2, $2, 1 +1: +#ifndef __mips_soft_float + ldc1 $24, 96($4) + ldc1 $25, 104($4) + ldc1 $26, 112($4) + ldc1 $27, 120($4) + ldc1 $28, 128($4) + ldc1 $29, 136($4) + ldc1 $30, 144($4) + ldc1 $31, 152($4) +#endif + ld $ra, 0($4) + ld $sp, 8($4) + ld $gp, 16($4) + ld $16, 24($4) + ld $17, 32($4) + ld $18, 40($4) + ld $19, 48($4) + ld $20, 56($4) + ld $21, 64($4) + ld $22, 72($4) + ld $23, 80($4) + ld $30, 88($4) + jr $ra + nop diff --git a/libc-top-half/musl/src/setjmp/mips64/setjmp.S b/libc-top-half/musl/src/setjmp/mips64/setjmp.S new file mode 100644 index 0000000..b9646c2 --- /dev/null +++ b/libc-top-half/musl/src/setjmp/mips64/setjmp.S @@ -0,0 +1,34 @@ +.set noreorder +.global __setjmp +.global _setjmp +.global setjmp +.type __setjmp,@function +.type _setjmp,@function +.type setjmp,@function +__setjmp: +_setjmp: +setjmp: + sd $ra, 0($4) + sd $sp, 8($4) + sd $gp, 16($4) + sd $16, 24($4) + sd $17, 32($4) + sd $18, 40($4) + sd $19, 48($4) + sd $20, 56($4) + sd $21, 64($4) + sd $22, 72($4) + sd $23, 80($4) + sd $30, 88($4) +#ifndef __mips_soft_float + sdc1 $24, 96($4) + sdc1 $25, 104($4) + sdc1 $26, 112($4) + sdc1 $27, 120($4) + sdc1 $28, 128($4) + sdc1 $29, 136($4) + sdc1 $30, 144($4) + sdc1 $31, 152($4) +#endif + jr $ra + li $2, 0 diff --git a/libc-top-half/musl/src/setjmp/mipsn32/longjmp.S b/libc-top-half/musl/src/setjmp/mipsn32/longjmp.S new file mode 100644 index 0000000..30c3ee0 --- /dev/null +++ b/libc-top-half/musl/src/setjmp/mipsn32/longjmp.S @@ -0,0 +1,36 @@ +.set noreorder +.global _longjmp +.global longjmp +.type _longjmp,@function +.type longjmp,@function +_longjmp: +longjmp: + move $2, $5 + bne $2, $0, 1f + nop + addu $2, $2, 1 +1: +#ifndef __mips_soft_float + ldc1 $24, 96($4) + ldc1 $25, 104($4) + ldc1 $26, 112($4) + ldc1 $27, 120($4) + ldc1 $28, 128($4) + ldc1 $29, 136($4) + ldc1 $30, 144($4) + ldc1 $31, 152($4) +#endif + ld $ra, 0($4) + ld $sp, 8($4) + ld $gp, 16($4) + ld $16, 24($4) + ld $17, 32($4) + ld $18, 40($4) + ld $19, 48($4) + ld $20, 56($4) + ld $21, 64($4) + ld $22, 72($4) + ld $23, 80($4) + ld $30, 88($4) + jr $ra + nop diff --git a/libc-top-half/musl/src/setjmp/mipsn32/setjmp.S b/libc-top-half/musl/src/setjmp/mipsn32/setjmp.S new file mode 100644 index 0000000..b9646c2 --- /dev/null +++ b/libc-top-half/musl/src/setjmp/mipsn32/setjmp.S @@ -0,0 +1,34 @@ +.set noreorder +.global __setjmp +.global _setjmp +.global setjmp +.type __setjmp,@function +.type _setjmp,@function +.type setjmp,@function +__setjmp: +_setjmp: +setjmp: + sd $ra, 0($4) + sd $sp, 8($4) + sd $gp, 16($4) + sd $16, 24($4) + sd $17, 32($4) + sd $18, 40($4) + sd $19, 48($4) + sd $20, 56($4) + sd $21, 64($4) + sd $22, 72($4) + sd $23, 80($4) + sd $30, 88($4) +#ifndef __mips_soft_float + sdc1 $24, 96($4) + sdc1 $25, 104($4) + sdc1 $26, 112($4) + sdc1 $27, 120($4) + sdc1 $28, 128($4) + sdc1 $29, 136($4) + sdc1 $30, 144($4) + sdc1 $31, 152($4) +#endif + jr $ra + li $2, 0 diff --git a/libc-top-half/musl/src/setjmp/or1k/longjmp.s b/libc-top-half/musl/src/setjmp/or1k/longjmp.s new file mode 100644 index 0000000..1db9fd9 --- /dev/null +++ b/libc-top-half/musl/src/setjmp/or1k/longjmp.s @@ -0,0 +1,25 @@ +.global _longjmp +.global longjmp +.type _longjmp,@function +.type longjmp,@function +_longjmp: +longjmp: + l.sfeqi r4, 0 + l.bnf 1f + l.addi r11, r4,0 + l.ori r11, r0, 1 +1: l.lwz r1, 0(r3) + l.lwz r2, 4(r3) + l.lwz r9, 8(r3) + l.lwz r10, 12(r3) + l.lwz r14, 16(r3) + l.lwz r16, 20(r3) + l.lwz r18, 24(r3) + l.lwz r20, 28(r3) + l.lwz r22, 32(r3) + l.lwz r24, 36(r3) + l.lwz r26, 40(r3) + l.lwz r28, 44(r3) + l.lwz r30, 48(r3) + l.jr r9 + l.nop diff --git a/libc-top-half/musl/src/setjmp/or1k/setjmp.s b/libc-top-half/musl/src/setjmp/or1k/setjmp.s new file mode 100644 index 0000000..0677033 --- /dev/null +++ b/libc-top-half/musl/src/setjmp/or1k/setjmp.s @@ -0,0 +1,27 @@ +.global ___setjmp +.hidden ___setjmp +.global __setjmp +.global _setjmp +.global setjmp +.type __setjmp,@function +.type _setjmp,@function +.type setjmp,@function +___setjmp: +__setjmp: +_setjmp: +setjmp: + l.sw 0(r3), r1 + l.sw 4(r3), r2 + l.sw 8(r3), r9 + l.sw 12(r3), r10 + l.sw 16(r3), r14 + l.sw 20(r3), r16 + l.sw 24(r3), r18 + l.sw 28(r3), r20 + l.sw 32(r3), r22 + l.sw 36(r3), r24 + l.sw 40(r3), r26 + l.sw 44(r3), r28 + l.sw 48(r3), r30 + l.jr r9 + l.ori r11,r0,0 diff --git a/libc-top-half/musl/src/setjmp/powerpc/longjmp.S b/libc-top-half/musl/src/setjmp/powerpc/longjmp.S new file mode 100644 index 0000000..611389f --- /dev/null +++ b/libc-top-half/musl/src/setjmp/powerpc/longjmp.S @@ -0,0 +1,99 @@ + .global _longjmp + .global longjmp + .type _longjmp,@function + .type longjmp,@function +_longjmp: +longjmp: + /* + * void longjmp(jmp_buf env, int val); + * put val into return register and restore the env saved in setjmp + * if val(r4) is 0, put 1 there. + */ + /* 0) move old return address into r0 */ + lwz 0, 0(3) + /* 1) put it into link reg */ + mtlr 0 + /* 2 ) restore stack ptr */ + lwz 1, 4(3) + /* 3) restore control reg */ + lwz 0, 8(3) + mtcr 0 + /* 4) restore r14-r31 */ + lwz 14, 12(3) + lwz 15, 16(3) + lwz 16, 20(3) + lwz 17, 24(3) + lwz 18, 28(3) + lwz 19, 32(3) + lwz 20, 36(3) + lwz 21, 40(3) + lwz 22, 44(3) + lwz 23, 48(3) + lwz 24, 52(3) + lwz 25, 56(3) + lwz 26, 60(3) + lwz 27, 64(3) + lwz 28, 68(3) + lwz 29, 72(3) + lwz 30, 76(3) + lwz 31, 80(3) +#if defined(_SOFT_FLOAT) || defined(__NO_FPRS__) + mflr 0 + bl 1f + .hidden __hwcap + .long __hwcap-. +1: mflr 4 + lwz 5, 0(4) + lwzx 4, 4, 5 + andis. 4, 4, 0x80 + beq 1f + .long 0x11c35b01 /* evldd 14,88(3) */ + .long 0x11e36301 /* ... */ + .long 0x12036b01 + .long 0x12237301 + .long 0x12437b01 + .long 0x12638301 + .long 0x12838b01 + .long 0x12a39301 + .long 0x12c39b01 + .long 0x12e3a301 + .long 0x1303ab01 + .long 0x1323b301 + .long 0x1343bb01 + .long 0x1363c301 + .long 0x1383cb01 + .long 0x13a3d301 + .long 0x13c3db01 + .long 0x13e3e301 /* evldd 31,224(3) */ + .long 0x11a3eb01 /* evldd 13,232(3) */ +1: mtlr 0 +#else + lfd 14,88(3) + lfd 15,96(3) + lfd 16,104(3) + lfd 17,112(3) + lfd 18,120(3) + lfd 19,128(3) + lfd 20,136(3) + lfd 21,144(3) + lfd 22,152(3) + lfd 23,160(3) + lfd 24,168(3) + lfd 25,176(3) + lfd 26,184(3) + lfd 27,192(3) + lfd 28,200(3) + lfd 29,208(3) + lfd 30,216(3) + lfd 31,224(3) +#endif + /* 5) put val into return reg r3 */ + mr 3, 4 + + /* 6) check if return value is 0, make it 1 in that case */ + cmpwi cr7, 4, 0 + bne cr7, 1f + li 3, 1 +1: + blr + diff --git a/libc-top-half/musl/src/setjmp/powerpc/setjmp.S b/libc-top-half/musl/src/setjmp/powerpc/setjmp.S new file mode 100644 index 0000000..f1fcce3 --- /dev/null +++ b/libc-top-half/musl/src/setjmp/powerpc/setjmp.S @@ -0,0 +1,93 @@ + .global ___setjmp + .hidden ___setjmp + .global __setjmp + .global _setjmp + .global setjmp + .type __setjmp,@function + .type _setjmp,@function + .type setjmp,@function +___setjmp: +__setjmp: +_setjmp: +setjmp: + /* 0) store IP int 0, then into the jmpbuf pointed to by r3 (first arg) */ + mflr 0 + stw 0, 0(3) + /* 1) store reg1 (SP) */ + stw 1, 4(3) + /* 2) store cr */ + mfcr 0 + stw 0, 8(3) + /* 3) store r14-31 */ + stw 14, 12(3) + stw 15, 16(3) + stw 16, 20(3) + stw 17, 24(3) + stw 18, 28(3) + stw 19, 32(3) + stw 20, 36(3) + stw 21, 40(3) + stw 22, 44(3) + stw 23, 48(3) + stw 24, 52(3) + stw 25, 56(3) + stw 26, 60(3) + stw 27, 64(3) + stw 28, 68(3) + stw 29, 72(3) + stw 30, 76(3) + stw 31, 80(3) +#if defined(_SOFT_FLOAT) || defined(__NO_FPRS__) + mflr 0 + bl 1f + .hidden __hwcap + .long __hwcap-. +1: mflr 4 + lwz 5, 0(4) + lwzx 4, 4, 5 + andis. 4, 4, 0x80 + beq 1f + .long 0x11c35b21 /* evstdd 14,88(3) */ + .long 0x11e36321 /* ... */ + .long 0x12036b21 + .long 0x12237321 + .long 0x12437b21 + .long 0x12638321 + .long 0x12838b21 + .long 0x12a39321 + .long 0x12c39b21 + .long 0x12e3a321 + .long 0x1303ab21 + .long 0x1323b321 + .long 0x1343bb21 + .long 0x1363c321 + .long 0x1383cb21 + .long 0x13a3d321 + .long 0x13c3db21 + .long 0x13e3e321 /* evstdd 31,224(3) */ + .long 0x11a3eb21 /* evstdd 13,232(3) */ +1: mtlr 0 +#else + stfd 14,88(3) + stfd 15,96(3) + stfd 16,104(3) + stfd 17,112(3) + stfd 18,120(3) + stfd 19,128(3) + stfd 20,136(3) + stfd 21,144(3) + stfd 22,152(3) + stfd 23,160(3) + stfd 24,168(3) + stfd 25,176(3) + stfd 26,184(3) + stfd 27,192(3) + stfd 28,200(3) + stfd 29,208(3) + stfd 30,216(3) + stfd 31,224(3) +#endif + /* 4) set return value to 0 */ + li 3, 0 + /* 5) return */ + blr diff --git a/libc-top-half/musl/src/setjmp/powerpc64/longjmp.s b/libc-top-half/musl/src/setjmp/powerpc64/longjmp.s new file mode 100644 index 0000000..81d45ff --- /dev/null +++ b/libc-top-half/musl/src/setjmp/powerpc64/longjmp.s @@ -0,0 +1,81 @@ + .global _longjmp + .global longjmp + .type _longjmp,@function + .type longjmp,@function +_longjmp: +longjmp: + # 0) move old return address into the link register + ld 0, 0*8(3) + mtlr 0 + # 1) restore cr + ld 0, 1*8(3) + mtcr 0 + # 2) restore SP + ld 1, 2*8(3) + # 3) restore TOC into both r2 and the caller's stack. + # Which location is required depends on whether setjmp was called + # locally or non-locally, but it's always safe to restore to both. + ld 2, 3*8(3) + std 2, 24(1) + # 4) restore r14-r31 + ld 14, 4*8(3) + ld 15, 5*8(3) + ld 16, 6*8(3) + ld 17, 7*8(3) + ld 18, 8*8(3) + ld 19, 9*8(3) + ld 20, 10*8(3) + ld 21, 11*8(3) + ld 22, 12*8(3) + ld 23, 13*8(3) + ld 24, 14*8(3) + ld 25, 15*8(3) + ld 26, 16*8(3) + ld 27, 17*8(3) + ld 28, 18*8(3) + ld 29, 19*8(3) + ld 30, 20*8(3) + ld 31, 21*8(3) + # 5) restore floating point registers f14-f31 + lfd 14, 22*8(3) + lfd 15, 23*8(3) + lfd 16, 24*8(3) + lfd 17, 25*8(3) + lfd 18, 26*8(3) + lfd 19, 27*8(3) + lfd 20, 28*8(3) + lfd 21, 29*8(3) + lfd 22, 30*8(3) + lfd 23, 31*8(3) + lfd 24, 32*8(3) + lfd 25, 33*8(3) + lfd 26, 34*8(3) + lfd 27, 35*8(3) + lfd 28, 36*8(3) + lfd 29, 37*8(3) + lfd 30, 38*8(3) + lfd 31, 39*8(3) + + # 6) restore vector registers v20-v31 + addi 3, 3, 40*8 + lvx 20, 0, 3 ; addi 3, 3, 16 + lvx 21, 0, 3 ; addi 3, 3, 16 + lvx 22, 0, 3 ; addi 3, 3, 16 + lvx 23, 0, 3 ; addi 3, 3, 16 + lvx 24, 0, 3 ; addi 3, 3, 16 + lvx 25, 0, 3 ; addi 3, 3, 16 + lvx 26, 0, 3 ; addi 3, 3, 16 + lvx 27, 0, 3 ; addi 3, 3, 16 + lvx 28, 0, 3 ; addi 3, 3, 16 + lvx 29, 0, 3 ; addi 3, 3, 16 + lvx 30, 0, 3 ; addi 3, 3, 16 + lvx 31, 0, 3 + + # 7) return r4 ? r4 : 1 + mr 3, 4 + cmpwi cr7, 4, 0 + bne cr7, 1f + li 3, 1 +1: + blr + diff --git a/libc-top-half/musl/src/setjmp/powerpc64/setjmp.s b/libc-top-half/musl/src/setjmp/powerpc64/setjmp.s new file mode 100644 index 0000000..37683fd --- /dev/null +++ b/libc-top-half/musl/src/setjmp/powerpc64/setjmp.s @@ -0,0 +1,89 @@ + .global __setjmp + .global _setjmp + .global setjmp + .type __setjmp,@function + .type _setjmp,@function + .type setjmp,@function +__setjmp: +_setjmp: +setjmp: + ld 5, 24(1) # load from the TOC slot in the caller's stack frame + b __setjmp_toc + + .localentry __setjmp,.-__setjmp + .localentry _setjmp,.-_setjmp + .localentry setjmp,.-setjmp + mr 5, 2 + + .global __setjmp_toc + .hidden __setjmp_toc + # same as normal setjmp, except TOC pointer to save is provided in r5. + # r4 would normally be the 2nd parameter, but we're using r5 to simplify calling from sigsetjmp. + # solves the problem of knowing whether to save the TOC pointer from r2 or the caller's stack frame. +__setjmp_toc: + # 0) store IP into 0, then into the jmpbuf pointed to by r3 (first arg) + mflr 0 + std 0, 0*8(3) + # 1) store cr + mfcr 0 + std 0, 1*8(3) + # 2) store SP and TOC + std 1, 2*8(3) + std 5, 3*8(3) + # 3) store r14-31 + std 14, 4*8(3) + std 15, 5*8(3) + std 16, 6*8(3) + std 17, 7*8(3) + std 18, 8*8(3) + std 19, 9*8(3) + std 20, 10*8(3) + std 21, 11*8(3) + std 22, 12*8(3) + std 23, 13*8(3) + std 24, 14*8(3) + std 25, 15*8(3) + std 26, 16*8(3) + std 27, 17*8(3) + std 28, 18*8(3) + std 29, 19*8(3) + std 30, 20*8(3) + std 31, 21*8(3) + # 4) store floating point registers f14-f31 + stfd 14, 22*8(3) + stfd 15, 23*8(3) + stfd 16, 24*8(3) + stfd 17, 25*8(3) + stfd 18, 26*8(3) + stfd 19, 27*8(3) + stfd 20, 28*8(3) + stfd 21, 29*8(3) + stfd 22, 30*8(3) + stfd 23, 31*8(3) + stfd 24, 32*8(3) + stfd 25, 33*8(3) + stfd 26, 34*8(3) + stfd 27, 35*8(3) + stfd 28, 36*8(3) + stfd 29, 37*8(3) + stfd 30, 38*8(3) + stfd 31, 39*8(3) + + # 5) store vector registers v20-v31 + addi 3, 3, 40*8 + stvx 20, 0, 3 ; addi 3, 3, 16 + stvx 21, 0, 3 ; addi 3, 3, 16 + stvx 22, 0, 3 ; addi 3, 3, 16 + stvx 23, 0, 3 ; addi 3, 3, 16 + stvx 24, 0, 3 ; addi 3, 3, 16 + stvx 25, 0, 3 ; addi 3, 3, 16 + stvx 26, 0, 3 ; addi 3, 3, 16 + stvx 27, 0, 3 ; addi 3, 3, 16 + stvx 28, 0, 3 ; addi 3, 3, 16 + stvx 29, 0, 3 ; addi 3, 3, 16 + stvx 30, 0, 3 ; addi 3, 3, 16 + stvx 31, 0, 3 + + # 6) return 0 + li 3, 0 + blr diff --git a/libc-top-half/musl/src/setjmp/riscv64/longjmp.S b/libc-top-half/musl/src/setjmp/riscv64/longjmp.S new file mode 100644 index 0000000..41e2d21 --- /dev/null +++ b/libc-top-half/musl/src/setjmp/riscv64/longjmp.S @@ -0,0 +1,42 @@ +.global __longjmp +.global _longjmp +.global longjmp +.type __longjmp, %function +.type _longjmp, %function +.type longjmp, %function +__longjmp: +_longjmp: +longjmp: + ld s0, 0(a0) + ld s1, 8(a0) + ld s2, 16(a0) + ld s3, 24(a0) + ld s4, 32(a0) + ld s5, 40(a0) + ld s6, 48(a0) + ld s7, 56(a0) + ld s8, 64(a0) + ld s9, 72(a0) + ld s10, 80(a0) + ld s11, 88(a0) + ld sp, 96(a0) + ld ra, 104(a0) + +#ifndef __riscv_float_abi_soft + fld fs0, 112(a0) + fld fs1, 120(a0) + fld fs2, 128(a0) + fld fs3, 136(a0) + fld fs4, 144(a0) + fld fs5, 152(a0) + fld fs6, 160(a0) + fld fs7, 168(a0) + fld fs8, 176(a0) + fld fs9, 184(a0) + fld fs10, 192(a0) + fld fs11, 200(a0) +#endif + + seqz a0, a1 + add a0, a0, a1 + ret diff --git a/libc-top-half/musl/src/setjmp/riscv64/setjmp.S b/libc-top-half/musl/src/setjmp/riscv64/setjmp.S new file mode 100644 index 0000000..5124967 --- /dev/null +++ b/libc-top-half/musl/src/setjmp/riscv64/setjmp.S @@ -0,0 +1,41 @@ +.global __setjmp +.global _setjmp +.global setjmp +.type __setjmp, %function +.type _setjmp, %function +.type setjmp, %function +__setjmp: +_setjmp: +setjmp: + sd s0, 0(a0) + sd s1, 8(a0) + sd s2, 16(a0) + sd s3, 24(a0) + sd s4, 32(a0) + sd s5, 40(a0) + sd s6, 48(a0) + sd s7, 56(a0) + sd s8, 64(a0) + sd s9, 72(a0) + sd s10, 80(a0) + sd s11, 88(a0) + sd sp, 96(a0) + sd ra, 104(a0) + +#ifndef __riscv_float_abi_soft + fsd fs0, 112(a0) + fsd fs1, 120(a0) + fsd fs2, 128(a0) + fsd fs3, 136(a0) + fsd fs4, 144(a0) + fsd fs5, 152(a0) + fsd fs6, 160(a0) + fsd fs7, 168(a0) + fsd fs8, 176(a0) + fsd fs9, 184(a0) + fsd fs10, 192(a0) + fsd fs11, 200(a0) +#endif + + li a0, 0 + ret diff --git a/libc-top-half/musl/src/setjmp/s390x/longjmp.s b/libc-top-half/musl/src/setjmp/s390x/longjmp.s new file mode 100644 index 0000000..b2310f8 --- /dev/null +++ b/libc-top-half/musl/src/setjmp/s390x/longjmp.s @@ -0,0 +1,23 @@ + .global _longjmp + .global longjmp + .type _longjmp,@function + .type longjmp,@function +_longjmp: +longjmp: + +1: + lmg %r6, %r15, 0(%r2) + + ld %f8, 10*8(%r2) + ld %f9, 11*8(%r2) + ld %f10, 12*8(%r2) + ld %f11, 13*8(%r2) + ld %f12, 14*8(%r2) + ld %f13, 15*8(%r2) + ld %f14, 16*8(%r2) + ld %f15, 17*8(%r2) + + ltgr %r2, %r3 + bnzr %r14 + lhi %r2, 1 + br %r14 diff --git a/libc-top-half/musl/src/setjmp/s390x/setjmp.s b/libc-top-half/musl/src/setjmp/s390x/setjmp.s new file mode 100644 index 0000000..afae1b6 --- /dev/null +++ b/libc-top-half/musl/src/setjmp/s390x/setjmp.s @@ -0,0 +1,25 @@ + .global ___setjmp + .hidden ___setjmp + .global __setjmp + .global _setjmp + .global setjmp + .type __setjmp,@function + .type _setjmp,@function + .type setjmp,@function +___setjmp: +__setjmp: +_setjmp: +setjmp: + stmg %r6, %r15, 0(%r2) + + std %f8, 10*8(%r2) + std %f9, 11*8(%r2) + std %f10, 12*8(%r2) + std %f11, 13*8(%r2) + std %f12, 14*8(%r2) + std %f13, 15*8(%r2) + std %f14, 16*8(%r2) + std %f15, 17*8(%r2) + + lghi %r2, 0 + br %r14 diff --git a/libc-top-half/musl/src/setjmp/setjmp.c b/libc-top-half/musl/src/setjmp/setjmp.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/libc-top-half/musl/src/setjmp/setjmp.c diff --git a/libc-top-half/musl/src/setjmp/sh/longjmp.S b/libc-top-half/musl/src/setjmp/sh/longjmp.S new file mode 100644 index 0000000..08f668b --- /dev/null +++ b/libc-top-half/musl/src/setjmp/sh/longjmp.S @@ -0,0 +1,28 @@ +.global _longjmp +.global longjmp +.type _longjmp, @function +.type longjmp, @function +_longjmp: +longjmp: + mov.l @r4+, r8 + mov.l @r4+, r9 + mov.l @r4+, r10 + mov.l @r4+, r11 + mov.l @r4+, r12 + mov.l @r4+, r13 + mov.l @r4+, r14 + mov.l @r4+, r15 + lds.l @r4+, pr +#if __SH_FPU_ANY__ || __SH4__ + fmov.s @r4+, fr12 + fmov.s @r4+, fr13 + fmov.s @r4+, fr14 + fmov.s @r4+, fr15 +#endif + + tst r5, r5 + movt r0 + add r5, r0 + + rts + nop diff --git a/libc-top-half/musl/src/setjmp/sh/setjmp.S b/libc-top-half/musl/src/setjmp/sh/setjmp.S new file mode 100644 index 0000000..d476e63 --- /dev/null +++ b/libc-top-half/musl/src/setjmp/sh/setjmp.S @@ -0,0 +1,32 @@ +.global ___setjmp +.hidden ___setjmp +.global __setjmp +.global _setjmp +.global setjmp +.type __setjmp, @function +.type _setjmp, @function +.type setjmp, @function +___setjmp: +__setjmp: +_setjmp: +setjmp: +#if __SH_FPU_ANY__ || __SH4__ + add #52, r4 + fmov.s fr15, @-r4 + fmov.s fr14, @-r4 + fmov.s fr13, @-r4 + fmov.s fr12, @-r4 +#else + add #36, r4 +#endif + sts.l pr, @-r4 + mov.l r15, @-r4 + mov.l r14, @-r4 + mov.l r13, @-r4 + mov.l r12, @-r4 + mov.l r11, @-r4 + mov.l r10, @-r4 + mov.l r9, @-r4 + mov.l r8, @-r4 + rts + mov #0, r0 diff --git a/libc-top-half/musl/src/setjmp/x32/longjmp.s b/libc-top-half/musl/src/setjmp/x32/longjmp.s new file mode 100644 index 0000000..1b2661c --- /dev/null +++ b/libc-top-half/musl/src/setjmp/x32/longjmp.s @@ -0,0 +1,18 @@ +/* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */ +.global _longjmp +.global longjmp +.type _longjmp,@function +.type longjmp,@function +_longjmp: +longjmp: + xor %eax,%eax + cmp $1,%esi /* CF = val ? 0 : 1 */ + adc %esi,%eax /* eax = val + !val */ + mov (%rdi),%rbx /* rdi is the jmp_buf, restore regs from it */ + mov 8(%rdi),%rbp + mov 16(%rdi),%r12 + mov 24(%rdi),%r13 + mov 32(%rdi),%r14 + mov 40(%rdi),%r15 + mov 48(%rdi),%rsp + jmp *56(%rdi) /* goto saved address without altering rsp */ diff --git a/libc-top-half/musl/src/setjmp/x32/setjmp.s b/libc-top-half/musl/src/setjmp/x32/setjmp.s new file mode 100644 index 0000000..d95e485 --- /dev/null +++ b/libc-top-half/musl/src/setjmp/x32/setjmp.s @@ -0,0 +1,22 @@ +/* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */ +.global __setjmp +.global _setjmp +.global setjmp +.type __setjmp,@function +.type _setjmp,@function +.type setjmp,@function +__setjmp: +_setjmp: +setjmp: + mov %rbx,(%rdi) /* rdi is jmp_buf, move registers onto it */ + mov %rbp,8(%rdi) + mov %r12,16(%rdi) + mov %r13,24(%rdi) + mov %r14,32(%rdi) + mov %r15,40(%rdi) + lea 8(%rsp),%rdx /* this is our rsp WITHOUT current ret addr */ + mov %rdx,48(%rdi) + mov (%rsp),%rdx /* save return addr ptr for new rip */ + mov %rdx,56(%rdi) + xor %eax,%eax /* always return 0 */ + ret diff --git a/libc-top-half/musl/src/setjmp/x86_64/longjmp.s b/libc-top-half/musl/src/setjmp/x86_64/longjmp.s new file mode 100644 index 0000000..1b2661c --- /dev/null +++ b/libc-top-half/musl/src/setjmp/x86_64/longjmp.s @@ -0,0 +1,18 @@ +/* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */ +.global _longjmp +.global longjmp +.type _longjmp,@function +.type longjmp,@function +_longjmp: +longjmp: + xor %eax,%eax + cmp $1,%esi /* CF = val ? 0 : 1 */ + adc %esi,%eax /* eax = val + !val */ + mov (%rdi),%rbx /* rdi is the jmp_buf, restore regs from it */ + mov 8(%rdi),%rbp + mov 16(%rdi),%r12 + mov 24(%rdi),%r13 + mov 32(%rdi),%r14 + mov 40(%rdi),%r15 + mov 48(%rdi),%rsp + jmp *56(%rdi) /* goto saved address without altering rsp */ diff --git a/libc-top-half/musl/src/setjmp/x86_64/setjmp.s b/libc-top-half/musl/src/setjmp/x86_64/setjmp.s new file mode 100644 index 0000000..d95e485 --- /dev/null +++ b/libc-top-half/musl/src/setjmp/x86_64/setjmp.s @@ -0,0 +1,22 @@ +/* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */ +.global __setjmp +.global _setjmp +.global setjmp +.type __setjmp,@function +.type _setjmp,@function +.type setjmp,@function +__setjmp: +_setjmp: +setjmp: + mov %rbx,(%rdi) /* rdi is jmp_buf, move registers onto it */ + mov %rbp,8(%rdi) + mov %r12,16(%rdi) + mov %r13,24(%rdi) + mov %r14,32(%rdi) + mov %r15,40(%rdi) + lea 8(%rsp),%rdx /* this is our rsp WITHOUT current ret addr */ + mov %rdx,48(%rdi) + mov (%rsp),%rdx /* save return addr ptr for new rip */ + mov %rdx,56(%rdi) + xor %eax,%eax /* always return 0 */ + ret |