1 /* Copyright (C) 2011 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
21 #include "ucontext_i.h"
23 /* int swapcontext (ucontext_t *oucp, const ucontext_t *ucp) */
27 FEEDBACK_ENTER(__swapcontext)
28 /* Set up a frame and save r0 and r1. */
31 ADDI_PTR r11, sp, -(3 * REGSIZE)
34 ADDI_PTR sp, sp, -(4 * REGSIZE)
35 cfi_def_cfa_offset (4 * REGSIZE)
39 ADDI_PTR r10, sp, (2 * REGSIZE)
43 ADDI_PTR r10, sp, (3 * REGSIZE)
47 /* Save the current context. */
50 /* Tear down the frame and restore r0, r1, and lr. */
53 ADDI_PTR r1, sp, 3 * REGSIZE
57 ADDI_PTR r0, sp, 2 * REGSIZE
61 ADDI_PTR sp, sp, 4 * REGSIZE
63 cfi_def_cfa_offset (0)
66 ADDLI_PTR r10, r0, UC_REG(54)
69 /* Update the stored sp and lr. */
72 ADDLI_PTR r10, r0, UC_REG(55)
76 /* Tail-call setcontext to finish up. */
83 ADDI_PTR sp, sp, 4 * REGSIZE
84 cfi_def_cfa_offset (0)
89 weak_alias (__swapcontext, swapcontext)