Update copyright notices with scripts/update-copyrights
[glibc.git] / sysdeps / unix / sysv / linux / sh / sh3 / setcontext.S
blob2f3c5eb885fbdd4ea4d6e2469aaae53e105d6f9c
1 /* Install given context.
2    Copyright (C) 2005-2014 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
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/>.  */
19 #include <sysdep.h>
21 #include "ucontext_i.h"
23 /*  int __setcontext (const ucontext_t *uc);  */
25         .text
26         .align  5
27 ENTRY(__setcontext)
29         mov     r4, r8
31         /* sigprocmask (SIG_SETMASK, &uc->uc_sigmask, NULL).  */
32         mov     r4, r5
33         add     #oSIGMASK, r5
34         mov     #SIG_SETMASK, r4
35         mov     #0, r6
36         mov     #+SYS_ify(sigprocmask), r3
37         trapa   #0x13
38         mov     r0, r1
39         mov     #-12, r2
40         shad    r2, r1
41         not     r1, r1                  // r1=0 means r0 = -1 to -4095
42         tst     r1, r1                  // i.e. error in linux
43         bf      .Lsetcontext_restore
44 .Lsyscall_error:
45         SYSCALL_ERROR_HANDLER
46 .Lpseudo_end:
47         rts
48          nop
50 .Lsetcontext_restore:
51         mov     r8, r0
52         add     #(oPC), r0
53         mov.l   @r0+, r2
54         lds.l   @r0+, pr
56         /* Restore T frag.  */
57         mov.l   @r0+, r1
58         shlr    r1
59         /* Skip GBR which is used for thread pointer.  */
60         add     #4, r0
62         lds.l   @r0+, mach
63         lds.l   @r0+, macl
65         mov     r8, r0
66         add     #(oR9), r0
67         mov.l   @r0+, r9
68         mov.l   @r0+, r10
69         mov.l   @r0+, r11
70         mov.l   @r0+, r12
71         mov.l   @r0+, r13
72         mov.l   @r0+, r14
73         mov.l   @r0+, r15
75         mov     r8, r0
76         mov.l   @(oR0,r0), r1
77         mov.l   r1, @-r15
78         cfi_adjust_cfa_offset(4)
79         cfi_rel_offset (r1, 0)
80         mov.l   r2, @-r15
81         cfi_adjust_cfa_offset(4)
82         cfi_rel_offset (r2, 0)
84         mov.l   @(oR1,r0), r1
85         mov.l   @(oR2,r0), r2
86         mov.l   @(oR3,r0), r3
87         mov.l   @(oR4,r0), r4
88         mov.l   @(oR5,r0), r5
89         mov.l   @(oR6,r0), r6
90         mov.l   @(oR7,r0), r7
91         mov.l   @(oR8,r0), r8
92         mov.l   @r15+, r0
93         cfi_adjust_cfa_offset(-4)
94         jmp     @r0
95          mov.l  @r15+, r0
97 PSEUDO_END(__setcontext)
99 weak_alias (__setcontext, setcontext)