1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

For #1537, #1282, use new algorithm for arm.

This commit is contained in:
winlin 2019-12-25 20:11:31 +08:00
parent 84f6f3d051
commit c5a8d21db6

View file

@ -466,6 +466,7 @@
#elif defined(__aarch64__) #elif defined(__aarch64__)
/****************************************************************/ /****************************************************************/
/* https://github.com/ossrs/srs/issues/1282#issuecomment-445539513 */
#define JB_X19 0 #define JB_X19 0
#define JB_X20 1 #define JB_X20 1
@ -560,42 +561,80 @@
#elif defined(__arm__) #elif defined(__arm__)
/****************************************************************/ /****************************************************************/
/* https://github.com/ossrs/srs/issues/1282#issuecomment-445539513 */
/* Register list for a ldm/stm instruction to load/store
the general registers from a __jmp_buf. */
# define JMP_BUF_REGLIST {v1-v6, sl, fp, sp, lr}
.file "md.S"
.text
/* _st_md_cxt_save(__jmp_buf env) */
.globl _st_md_cxt_save .globl _st_md_cxt_save
.type _st_md_cxt_save, %function .type _st_md_cxt_save, %function
.align 2 .align 2
_st_md_cxt_save: _st_md_cxt_save:
mov ip, r0 // r0 is the param jmpbuf ptr address. mov ip, r0
// Save registers like
// *ip++ = v1 /* Save registers */
// *ip++ = ... stmia ip!, JMP_BUF_REGLIST
// *ip++ = v6
// *ip++ = sl #ifdef __VFP_FP__
// *ip++ = fp /* Store the VFP registers. */
stmia ip!, {v1-v6, sl, fp} // TODO: compatible with other ARM version. /* Following instruction is vstmia ip!, {d8-d15}. */
movs r2, sp stc p11, cr8, [ip], #64
stmia ip!, {r2, lr} #endif
mov r0, #0 // r0 save the return value(0) of setjmp.
bx lr // return #ifdef __IWMMXT__
/* Save the call-preserved iWMMXt registers. */
/* Following instructions are wstrd wr10, [ip], #8 (etc.) */
stcl p1, cr10, [r12], #8
stcl p1, cr11, [r12], #8
stcl p1, cr12, [r12], #8
stcl p1, cr13, [r12], #8
stcl p1, cr14, [r12], #8
stcl p1, cr15, [r12], #8
#endif
mov r0, #0
bx lr
.size _st_md_cxt_save, .-_st_md_cxt_save .size _st_md_cxt_save, .-_st_md_cxt_save
/****************************************************************/ /****************************************************************/
/* _st_md_cxt_restore(__jmp_buf env, int val) */
.globl _st_md_cxt_restore .globl _st_md_cxt_restore
.type _st_md_cxt_restore, %function .type _st_md_cxt_restore, %function
.align 2 .align 2
_st_md_cxt_restore: _st_md_cxt_restore:
mov ip, r0 // r0 -> jmp_buf mov ip, r0
movs r0, r1 // r1 -> return value
// The bellow is a group, that is:
// if (r0 == 0) r0 =1;
ITT eq
moveq r0, #1 // long_jmp should never return 0
ldmia ip!, {v1-v6, sl, fp} // restore registers. /* Restore registers */
ldr sp, [ip], #4 // restore sp, like: sp=*ip; ip+=4; ldmia ip!, JMP_BUF_REGLIST
ldr lr, [ip], #4
#ifdef __VFP_FP__
/* Restore the VFP registers. */
/* Following instruction is vldmia ip!, {d8-d15}. */
ldc p11, cr8, [r12], #64
#endif
#ifdef __IWMMXT__
/* Restore the call-preserved iWMMXt registers. */
/* Following instructions are wldrd wr10, [ip], #8 (etc.) */
ldcl p1, cr10, [r12], #8
ldcl p1, cr11, [r12], #8
ldcl p1, cr12, [r12], #8
ldcl p1, cr13, [r12], #8
ldcl p1, cr14, [r12], #8
ldcl p1, cr15, [r12], #8
#endif
movs r0, r1 /* get the return value in place */
moveq r0, #1 /* can't let setjmp() return zero! */
bx lr bx lr
.size _st_md_cxt_restore, .-_st_md_cxt_restore .size _st_md_cxt_restore, .-_st_md_cxt_restore
/****************************************************************/ /****************************************************************/