URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
[/] [openrisc/] [trunk/] [gnu-stable/] [newlib-1.18.0/] [newlib/] [libc/] [sys/] [mmixware/] [setjmp.S] - Rev 829
Compare with Previous | Blame | View Log
/* Setjmp and longjmp for mmix.Copyright (C) 2001 Hans-Peter NilssonPermission to use, copy, modify, and distribute this software isfreely granted, provided that the above copyright notice, this noticeand the following disclaimer are preserved with no changes.THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS ORIMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIEDWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULARPURPOSE.jmp_buf[5]:0: fp1: rJ (return-address)2: sp3: rO *before* the setjmp call.4: temporary storage. Reserved between setjmp and longjmp. */#ifdef __MMIX_ABI_GNU__#define arg1 $231#define arg2 $232#define outret $231#define popval 0#else#define arg1 $0#define arg2 $1#define outret $0#define popval 1#endif.section .text.setjmp,"ax",@progbits.global setjmpsetjmp:% Store fp, sp and return address. Recycle the static-chain and% structure-return registers as temporary register, since we need to keep% the jmp_buf (parameter 1) and the return address across a "POP".SET $251,arg1STOU $253,$251,0GET $252,rJSTOU $252,$251,8STOU $254,$251,16SETL outret,0% Jump through hoops to get the value of rO *before* the setjmp call.GETA $255,0fPUT rJ,$255POP popval,00:GET $255,rOSTOU $255,$251,24GO $255,$252,0.size setjmp,.-setjmp.section .text.longjmp,"ax",@progbits.global longjmplongjmp:% Reset arg2 to 1 if it is 0 (see longjmp(2)) and store it in jmp_buf.% Save arg1 in a global register, since it will be destroyed by the POPs% (in the mmixware ABI).CSZ arg2,arg2,1STOU arg2,arg1,32SET $251,arg1% Loop and "POP 0,0" until rO is the expected value, like% the expansion of nonlocal_goto_receiver, except that we put the return% value in the right register and make sure that the POP causes it to% enter the right return-value register as seen by the caller. For the% GNU ABI, it is unnecessary to do this in the loop and perhaps the memory% access can be hoisted outside the loop, but this is safe and simple and% I see no need to optimize longjmps.GETA $255,0fPUT rJ,$255LDOU $255,$251,240:GET $252,rOCMPU $252,$252,$255BNP $252,1fLDOU outret,$251,32POP popval,01:LDOU $253,$251,0LDOU $255,$251,8LDOU $254,$251,16GO $255,$255,0.size longjmp,.-longjmp
