Date: Wed, 18 Apr 2007 11:12:43 GMT From: Oleksandr Tymoshenko <gonzo@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 118356 for review Message-ID: <200704181112.l3IBChvn013325@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=118356 Change 118356 by gonzo@gonzo_jeeves on 2007/04/18 11:12:02 o Organize things for _setjmp/setjmp/sigsetjmp calls family: - two magic numbers for _setjmp and setjmp - sigsetjmp calls either _setjmp or setjmp - siglongjmp calls either _longjmp or setjmp taking into account respective magic number. Affected files ... .. //depot/projects/mips2/src/lib/libc/mips/gen/_setjmp.S#4 edit .. //depot/projects/mips2/src/lib/libc/mips/gen/setjmp.S#3 edit .. //depot/projects/mips2/src/lib/libc/mips/gen/sigsetjmp.S#3 edit .. //depot/projects/mips2/src/sys/mips/include/asm.h#11 edit .. //depot/projects/mips2/src/sys/mips/include/setjmp.h#4 edit Differences ... ==== //depot/projects/mips2/src/lib/libc/mips/gen/_setjmp.S#4 (text+ko) ==== @@ -44,8 +44,6 @@ .abicalls #endif -#define SOFTFLOAT /* XXX */ - /* * C library -- _setjmp, _longjmp * @@ -57,94 +55,55 @@ * The previous signal state is NOT restored. */ - .set noreorder LEAF(_setjmp) #ifdef __ABICALLS__ - #.set noreorder + .set noreorder .cpload t9 - #.set reorder + .cprestore 16 #endif + li v0, _JB_MAGIC__SETJMP + sw v0, (_JB_MAGIC * SZREG)(a0) + sw ra, (_JB_REG_RA * SZREG)(a0) + sw s0, (_JB_REG_S0 * SZREG)(a0) + sw s1, (_JB_REG_S1 * SZREG)(a0) + sw s2, (_JB_REG_S2 * SZREG)(a0) + sw s3, (_JB_REG_S3 * SZREG)(a0) + sw s4, (_JB_REG_S4 * SZREG)(a0) + sw s5, (_JB_REG_S5 * SZREG)(a0) + sw s6, (_JB_REG_S6 * SZREG)(a0) + sw s7, (_JB_REG_S7 * SZREG)(a0) + sw sp, (_JB_REG_SP * SZREG)(a0) + sw s8, (_JB_REG_S8 * SZREG)(a0) - .set push - li v0, 0xACEDBADE - sw v0, (a0) - sw ra, (1 * SZREG)(a0) - sw s0, (2 * SZREG)(a0) - sw s1, (3 * SZREG)(a0) - sw s2, (4 * SZREG)(a0) - sw s3, (5 * SZREG)(a0) - sw s4, (6 * SZREG)(a0) - sw s5, (7 * SZREG)(a0) - sw s6, (8 * SZREG)(a0) - sw s7, (9 * SZREG)(a0) - sw sp, (10 * SZREG)(a0) - sw s8, (11 * SZREG)(a0) -#ifndef SOFTFLOAT - cfc1 v0, $31 # too bad cant check if FP used - swc1 $f20, (20 * 4 + _OFFSETOF_SC_FPREGS)(a0) - swc1 $f21, (21 * 4 + _OFFSETOF_SC_FPREGS)(a0) - swc1 $f22, (22 * 4 + _OFFSETOF_SC_FPREGS)(a0) - swc1 $f23, (23 * 4 + _OFFSETOF_SC_FPREGS)(a0) - swc1 $f24, (24 * 4 + _OFFSETOF_SC_FPREGS)(a0) - swc1 $f25, (25 * 4 + _OFFSETOF_SC_FPREGS)(a0) - swc1 $f26, (26 * 4 + _OFFSETOF_SC_FPREGS)(a0) - swc1 $f27, (27 * 4 + _OFFSETOF_SC_FPREGS)(a0) - swc1 $f28, (28 * 4 + _OFFSETOF_SC_FPREGS)(a0) - swc1 $f29, (29 * 4 + _OFFSETOF_SC_FPREGS)(a0) - swc1 $f30, (30 * 4 + _OFFSETOF_SC_FPREGS)(a0) - swc1 $f31, (31 * 4 + _OFFSETOF_SC_FPREGS)(a0) - sw v0, (32 * 4 + _OFFSETOF_SC_FPREGS)(a0) -#endif - .set pop j ra move v0, zero END(_setjmp) LEAF(_longjmp) #ifdef __ABICALLS__ - .set noreorder + .set noreorder .cpload t9 - .set reorder - subu sp, sp, 32 .cprestore 16 - .set noreorder #endif - .set push - lw v0, (a0) # get magic number - lw ra, (1 * SZREG)(a0) - li t0, 0xACEDBADE + lw v0, (_JB_MAGIC * SZREG)(a0) + lw ra, (_JB_REG_RA * SZREG)(a0) + li t0, _JB_MAGIC__SETJMP bne v0, t0, botch # jump if error - addu sp, sp, 32 # does not matter, sanity - lw s0, (2 * SZREG)(a0) - lw s1, (3 * SZREG)(a0) - lw s2, (4 * SZREG)(a0) - lw s3, (5 * SZREG)(a0) - lw s4, (6 * SZREG)(a0) - lw s5, (7 * SZREG)(a0) - lw s6, (8 * SZREG)(a0) - lw s7, (9 * SZREG)(a0) - lw sp, (10 * SZREG)(a0) - lw s8, (11 * SZREG)(a0) -#ifndef SOFTFLOAT - lw v0, (32 * 4 + _OFFSETOF_SC_FPREGS)(a0) # get fpu status - ctc1 v0, $31 - lwc1 $f20, (20 * 4 + _OFFSETOF_SC_FPREGS)(a0) - lwc1 $f21, (21 * 4 + _OFFSETOF_SC_FPREGS)(a0) - lwc1 $f22, (22 * 4 + _OFFSETOF_SC_FPREGS)(a0) - lwc1 $f23, (23 * 4 + _OFFSETOF_SC_FPREGS)(a0) - lwc1 $f24, (24 * 4 + _OFFSETOF_SC_FPREGS)(a0) - lwc1 $f25, (25 * 4 + _OFFSETOF_SC_FPREGS)(a0) - lwc1 $f26, (26 * 4 + _OFFSETOF_SC_FPREGS)(a0) - lwc1 $f27, (27 * 4 + _OFFSETOF_SC_FPREGS)(a0) - lwc1 $f28, (28 * 4 + _OFFSETOF_SC_FPREGS)(a0) - lwc1 $f29, (29 * 4 + _OFFSETOF_SC_FPREGS)(a0) - lwc1 $f30, (30 * 4 + _OFFSETOF_SC_FPREGS)(a0) - lwc1 $f31, (31 * 4 + _OFFSETOF_SC_FPREGS)(a0) -#endif + lw s0, (_JB_REG_S0 * SZREG)(a0) + lw s1, (_JB_REG_S1 * SZREG)(a0) + lw s2, (_JB_REG_S2 * SZREG)(a0) + lw s3, (_JB_REG_S3 * SZREG)(a0) + lw s4, (_JB_REG_S4 * SZREG)(a0) + lw s5, (_JB_REG_S5 * SZREG)(a0) + lw s6, (_JB_REG_S6 * SZREG)(a0) + lw s7, (_JB_REG_S7 * SZREG)(a0) + lw sp, (_JB_REG_SP * SZREG)(a0) + lw s8, (_JB_REG_S8 * SZREG)(a0) + j ra move v0, a1 - .set pop + botch: jal _C_LABEL(longjmperror) nop ==== //depot/projects/mips2/src/lib/libc/mips/gen/setjmp.S#3 (text+ko) ==== @@ -55,82 +55,105 @@ * and a struct sigcontext, see <signal.h> */ -#define SETJMP_FRAME_SIZE (CALLFRAME_SIZ + 12) +#define SETJMP_FRAME_SIZE (CALLFRAME_SIZ + SZREG) + NESTED(setjmp, SETJMP_FRAME_SIZE, ra) .mask 0x80000000, (CALLFRAME_RA - CALLFRAME_SIZ) + .set noreorder #ifdef __ABICALLS__ - .set noreorder .cpload t9 - .set reorder #endif subu sp, sp, SETJMP_FRAME_SIZE # allocate stack frame #ifdef __ABICALLS__ .cprestore 16 #endif sw ra, CALLFRAME_RA(sp) # save RA - sw a0, SETJMP_FRAME_SIZE(sp) # squirrel away sc + sw a0, CALLFRAME_SIZ(sp) # store env /* Get the signal mask. */ - addu a2, a0, _OFFSETOF_SC_MASK # &sc.sc_mask - move a1, zero - # XXXMIPS: jal _C_LABEL(__sigprocmask14) # get current signal mask - move a0, zero # (in delay slot) - - /* Get the signal stack. */ - move a0, zero - addu a1, sp, CALLFRAME_SIZ # pointer to struct sigaltstack - # XXXMIPS: jal _C_LABEL(__sigaltstack14) + addu a2, a0, _JB_SIGMASK * SZREG # &oenv + li a0, 1 # SIG_SETBLOCK + move a1, zero # &env == 0 + la t9, _C_LABEL(sigprocmask) # get current signal mask + jal t9 nop - lw v1, CALLFRAME_SIZ+8(sp) # get old ss_onstack - lw a0, SETJMP_FRAME_SIZE(sp) # restore sc pointer - and v1, v1, 1 # extract onstack flag - sw v1, 0(a0) # save it in sc_onstack + lw a0, CALLFRAME_SIZ(sp) # restore env pointer lw ra, CALLFRAME_RA(sp) # restore RA addu sp, sp, SETJMP_FRAME_SIZE # pop stack frame - blt v0, zero, botch # check for sigaltstack() error + li v0, _JB_MAGIC_SETJMP + sw v0, (_JB_MAGIC * SZREG)(a0) + sw ra, (_JB_REG_RA * SZREG)(a0) + sw s0, (_JB_REG_S0 * SZREG)(a0) + sw s1, (_JB_REG_S1 * SZREG)(a0) + sw s2, (_JB_REG_S2 * SZREG)(a0) + sw s3, (_JB_REG_S3 * SZREG)(a0) + sw s4, (_JB_REG_S4 * SZREG)(a0) + sw s5, (_JB_REG_S5 * SZREG)(a0) + sw s6, (_JB_REG_S6 * SZREG)(a0) + sw s7, (_JB_REG_S7 * SZREG)(a0) + sw sp, (_JB_REG_SP * SZREG)(a0) + sw s8, (_JB_REG_S8 * SZREG)(a0) - REG_PROLOGUE - REG_S ra, (2 * 4)(a0) # sc_pc = return address - REG_LI v0, 0xACEDBADE # sigcontext magic number - REG_S v0, (_OFFSETOF_SC_REGS + ZERO * SZREG)(a0) # saved in sc_regs[0] - REG_S s0, (_OFFSETOF_SC_REGS + S0 * SZREG)(a0) - REG_S s1, (_OFFSETOF_SC_REGS + S1 * SZREG)(a0) - REG_S s2, (_OFFSETOF_SC_REGS + S2 * SZREG)(a0) - REG_S s3, (_OFFSETOF_SC_REGS + S3 * SZREG)(a0) - REG_S s4, (_OFFSETOF_SC_REGS + S4 * SZREG)(a0) - REG_S s5, (_OFFSETOF_SC_REGS + S5 * SZREG)(a0) - REG_S s6, (_OFFSETOF_SC_REGS + S6 * SZREG)(a0) - REG_S s7, (_OFFSETOF_SC_REGS + S7 * SZREG)(a0) - REG_S gp, (_OFFSETOF_SC_REGS + GP * SZREG)(a0) - REG_S sp, (_OFFSETOF_SC_REGS + SP * SZREG)(a0) - REG_S s8, (_OFFSETOF_SC_REGS + S8 * SZREG)(a0) - li v0, 1 # be nice if we could tell - sw v0, (_OFFSETOF_SC_REGS + 34 * SZREG)(a0) # sc_fpused = 1 - cfc1 v0, $31 - swc1 $f20, (20 * 4 + _OFFSETOF_SC_FPREGS)(a0) - swc1 $f21, (21 * 4 + _OFFSETOF_SC_FPREGS)(a0) - swc1 $f22, (22 * 4 + _OFFSETOF_SC_FPREGS)(a0) - swc1 $f23, (23 * 4 + _OFFSETOF_SC_FPREGS)(a0) - swc1 $f24, (24 * 4 + _OFFSETOF_SC_FPREGS)(a0) - swc1 $f25, (25 * 4 + _OFFSETOF_SC_FPREGS)(a0) - swc1 $f26, (26 * 4 + _OFFSETOF_SC_FPREGS)(a0) - swc1 $f27, (27 * 4 + _OFFSETOF_SC_FPREGS)(a0) - swc1 $f28, (28 * 4 + _OFFSETOF_SC_FPREGS)(a0) - swc1 $f29, (29 * 4 + _OFFSETOF_SC_FPREGS)(a0) - swc1 $f30, (30 * 4 + _OFFSETOF_SC_FPREGS)(a0) - swc1 $f31, (31 * 4 + _OFFSETOF_SC_FPREGS)(a0) - sw v0, (32 * 4 + _OFFSETOF_SC_FPREGS)(a0) move v0, zero j ra - REG_EPILOGUE +END(setjmp) + +#define LONGJMP_FRAME_SIZE CALLFRAME_RA + SZREG * 2 + +NESTED(longjmp, LONGJMP_FRAME_SIZE, ra) + .mask 0x80000000, (CALLFRAME_RA - CALLFRAME_SIZ) + .set noreorder +#ifdef __ABICALLS__ + .cpload t9 +#endif + subu sp, sp, LONGJMP_FRAME_SIZE # allocate stack frame +#ifdef __ABICALLS__ + .cprestore 16 +#endif + sw ra, CALLFRAME_RA(sp) # save RA + lw v0, (_JB_MAGIC * SZREG)(a0) + li t0, _JB_MAGIC_SETJMP + bne v0, t0, botch # jump if error + nop + + sw a0, CALLFRAME_SIZ(sp) # save env + sw a1, (CALLFRAME_SIZ + SZREG)(sp) # save return value + + # set sigmask + addu a1, a0, _JB_SIGMASK * SZREG # &set + move a2, zero # &oset == NULL + li a0, 3 # SIG_SETMASK + la t9,_C_LABEL(sigprocmask) # set current signal mask + jal t9 + nop + + lw a0, CALLFRAME_SIZ(sp) # restore env + lw a1, (CALLFRAME_SIZ + SZREG)(sp) # restore return value + + lw ra, (_JB_REG_RA * SZREG)(a0) + lw s0, (_JB_REG_S0 * SZREG)(a0) + lw s1, (_JB_REG_S1 * SZREG)(a0) + lw s2, (_JB_REG_S2 * SZREG)(a0) + lw s3, (_JB_REG_S3 * SZREG)(a0) + lw s4, (_JB_REG_S4 * SZREG)(a0) + lw s5, (_JB_REG_S5 * SZREG)(a0) + lw s6, (_JB_REG_S6 * SZREG)(a0) + lw s7, (_JB_REG_S7 * SZREG)(a0) + lw sp, (_JB_REG_SP * SZREG)(a0) + lw s8, (_JB_REG_S8 * SZREG)(a0) + move v0, a1 + j ra + nop + botch: - jal _C_LABEL(abort) -END(setjmp) + la t9, _C_LABEL(longjmperror) + jal t9 + nop -WEAK_ALIAS(longjmp, __longjmp) -LEAF(__longjmp) - j ra -END(__longjmp) + la t9, _C_LABEL(abort) + jal t9 + nop +END(longjmp) ==== //depot/projects/mips2/src/lib/libc/mips/gen/sigsetjmp.S#3 (text+ko) ==== @@ -62,9 +62,7 @@ .cpload t9 .set reorder #endif - WEAK_ALIAS(__sigsetjmp, sigsetjmp) - # XXXMIPS: sw a1, (_JBLEN*4)(a0) # save "savemask" - # XXXMIPS: bne a1, 0x0, 1f # do saving of signal mask? + bne a1, 0x0, 1f # do saving of signal mask? la t9, _setjmp jr t9 @@ -78,11 +76,11 @@ .cpload t9 .set reorder #endif - WEAK_ALIAS(__siglongjmp, siglongjmp) - # XXXMIPS: lw t0, (_JBLEN * 4)(a0) # get "savemask" - # XXXMIPS: bne t0, 0x0, 1f # restore signal mask? + lw t0, (_JB_MAGIC * SZREG)(a0) + li t1, _JB_MAGIC__SETJMP + bne t0, t1, 1f # setjmp or _setjmp magic? la t9, _longjmp jr t9 -1: la t9, __longjmp +1: la t9, longjmp jr t9 END(siglongjmp) ==== //depot/projects/mips2/src/sys/mips/include/asm.h#11 (text+ko) ==== @@ -331,4 +331,52 @@ .stabs __STRING(_/**/sym),1,0,0,0 #endif /* __STDC__ */ +/* + * Description of the setjmp buffer + * + * word 0 magic number (dependant on creator) + * 1 RA + * 2 S0 + * 3 S1 + * 4 S2 + * 5 S3 + * 6 S4 + * 7 S5 + * 8 S6 + * 9 S7 + * 10 SP + * 11 S8 + * 12 signal mask (dependant on magic) + * 13 (con't) + * 14 (con't) + * 15 (con't) + * + * The magic number number identifies the jmp_buf and + * how the buffer was created as well as providing + * a sanity check + * + */ + +#define _JB_MAGIC__SETJMP 0xBADFACED +#define _JB_MAGIC_SETJMP 0xFACEDBAD + +/* Valid for all jmp_buf's */ + +#define _JB_MAGIC 0 +#define _JB_REG_RA 1 +#define _JB_REG_S0 2 +#define _JB_REG_S1 3 +#define _JB_REG_S2 4 +#define _JB_REG_S3 5 +#define _JB_REG_S4 6 +#define _JB_REG_S5 7 +#define _JB_REG_S6 8 +#define _JB_REG_S7 9 +#define _JB_REG_SP 10 +#define _JB_REG_S8 11 + +/* Only valid with the _JB_MAGIC_SETJMP magic */ + +#define _JB_SIGMASK 12 + #endif /* !_MACHINE_ASM_H_ */ ==== //depot/projects/mips2/src/sys/mips/include/setjmp.h#4 (text+ko) ==== @@ -37,7 +37,7 @@ #include <sys/types.h> -#define _JBLEN 12 /* Size of the jmp_buf on MIPS. */ +#define _JBLEN 16 /* Size of the jmp_buf on MIPS. */ /* * jmp_buf and sigjmp_buf are encapsulated in different structs to force
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200704181112.l3IBChvn013325>