2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A/* Copyright (c) 1988 AT&T */ 2N/A/* All Rights Reserved */ 2N/A * Flag telling longjmp to set curthread->ul_siglink to NULL. 2N/A * buf_ptr points to a twelve word array (jmp_buf) 2N/A add %o7, 8, %o1 ! compute return pc 2N/A st %o1, [%o0 + JB_PC] ! save pc 2N/A st %fp, [%o0 + JB_FP] ! save fp 2N/A st %i7, [%o0 + JB_I7] ! save %i7 2N/A clr %o0 ! return (0) 2N/A * longjmp(buf_ptr, val) 2N/A * buf_ptr points to a jmpbuf which has been initialized by setjmp. 2N/A * val is the value we wish to return to setjmp's
caller 2N/A * to the values they had at the time of the call to setjmp(). All 2N/A * other locals, ins and outs are set to potentially random values 2N/A * (as per the man page). This is sufficient to permit the correct 2N/A * operation of normal code. 2N/A * Actually, the above description is not quite correct. If the routine 2N/A * that called setjmp() has not altered the sp value of their frame we 2N/A * will restore the remaining locals and ins to the values these 2N/A * registers had in the this frame at the time of the call to longjmp() 2N/A * (not setjmp()!). This is intended to help compilers, typically not 2N/A * C compilers, that have some registers assigned to fixed purposes, 2N/A * and that only alter the values of these registers on function entry 2N/A * Since a C routine could call setjmp() followed by alloca() and thus 2N/A * alter the sp this feature will typically not be helpful for a C 2N/A * Note also that because the caller of a routine compiled "flat" (without 2N/A * register windows) assumes that their ins and locals are preserved, 2N/A * routines that call setjmp() must not be flat. 2N/A ta ST_FLUSH_WINDOWS ! flush all reg windows to the stack. 2N/A ld [%o0 + JB_SP], %o2 ! sp in %o2 until safe to puke there 2N/A ldd [%o2 + (0*8)], %l0 ! restore locals and ins if we can 2N/A ldd [%o2 + (1*8)], %l2 2N/A ldd [%o2 + (2*8)], %l4 2N/A ldd [%o2 + (3*8)], %l6 2N/A ldd [%o2 + (4*8)], %i0 2N/A ldd [%o2 + (5*8)], %i2 2N/A ldd [%o2 + (6*8)], %i4 2N/A ld [%o0 + JB_FP], %fp ! restore fp 2N/A mov %o2, %sp ! restore sp 2N/A ld [%o0 + JB_FLAGS], %o2 2N/A btst JB_CLEARLINK, %o2 ! test JB_CLEARLINK flag 2N/A clr [%g7 + UL_SIGLINK] ! if set, clear ul_siglink 2N/A ld [%o0 + JB_I7], %i7 ! restore %i7 2N/A ld [%o0 + JB_PC], %o3 ! get new return pc 2N/A tst %o1 ! is return value 0? 2N/A bnz 1f ! no - leave it alone 2N/A sub %o3, 8, %o7 ! normalize return (for adb) (dly slot) 2N/A mov 1, %o1 ! yes - set it to one 2N/A mov %o1, %o0 ! return (val)