getcontext.s revision 2
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 2008 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A * getcontext() is written in assembler since it has to capture the correct 2N/A * machine state of the calle. 2N/A * As swapcontext() is actually equivalent to getcontext() + setcontext(), 2N/A * swapcontext() shares the most code with getcontext(). 2N/A /* call getcontext: syscall */ \
2N/A * fix up %rsp and %rip \ 2N/A /* &ucp->uc_mcontext.gregs */ \
2N/A /* read return PC from stack */ \
2N/A /* store ret PC in EIP of env var */ \
2N/A /* get caller's sp at time of call */ \
2N/A /* store the sp into UESP of env var */ \
2N/A /* getcontext returns 0 after setcontext */ 2N/A * getcontext(ucontext_t *ucp) 2N/A * swapcontext(ucontext_t *oucp, const ucontext_t *ucp) 2N/A /* call setcontext */