Update copyright notices with scripts/update-copyrights
[glibc.git] / ports / sysdeps / unix / sysv / linux / arm / swapcontext.S
blob65a36d2a4cb6d07284693cecc3fb85c14b4072f9
1 /* Copyright (C) 2012-2014 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
4    The GNU C Library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Lesser General Public
6    License as published by the Free Software Foundation; either
7    version 2.1 of the License, or (at your option) any later version.
9    The GNU C Library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Lesser General Public License for more details.
14    You should have received a copy of the GNU Lesser General Public
15    License along with the GNU C Library; if not, see
16    <http://www.gnu.org/licenses/>.  */
18 #include <sysdep.h>
20 #include "ucontext_i.h"
22         .syntax unified
23         .text
25 /* int swapcontext (ucontext_t *oucp, const ucontext_t *ucp) */
27 ENTRY(swapcontext)
29         /* Have getcontext() do most of the work then fix up
30            LR afterwards.  Save R3 to keep the stack aligned.  */
31         push    {r0,r1,r3,r14}
32         cfi_adjust_cfa_offset (16)
33         cfi_rel_offset (r0,0)
34         cfi_rel_offset (r1,4)
35         cfi_rel_offset (r3,8)
36         cfi_rel_offset (r14,12)
38         bl      __getcontext
39         mov     r4, r0
41         pop     {r0,r1,r3,r14}
42         cfi_adjust_cfa_offset (-16)
43         cfi_restore (r0)
44         cfi_restore (r1)
45         cfi_restore (r3)
46         cfi_restore (r14)
48         /* Exit if getcontext() failed.  */
49         cmp     r4, #0
50         itt     ne
51         movne   r0, r4
52         RETINSTR(ne, r14)
54         /* Fix up LR and the PC.  */
55         str     r13,[r0, #MCONTEXT_ARM_SP]
56         str     r14,[r0, #MCONTEXT_ARM_LR]
57         str     r14,[r0, #MCONTEXT_ARM_PC]
59         /* And swap using swapcontext().  */
60         mov     r0, r1
61         b       __setcontext
63 END(swapcontext)