2.9
[glibc/nacl-glibc.git] / sysdeps / unix / sysv / linux / sh / sh3 / setcontext.S
blob3136267aca993fc4785f72594761739926942e19
1 /* Install given context.
2    Copyright (C) 2005 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, write to the Free
17    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18    02111-1307 USA.  */
20 #include <sysdep.h>
22 #include "ucontext_i.h"
24 /*  int __setcontext (const ucontext_t *uc);  */
26         .text
27         .align  5
28 ENTRY(__setcontext)
30         mov     r4, r8
32         /* sigprocmask (SIG_SETMASK, &uc->uc_sigmask, NULL).  */
33         mov     r4, r5
34         add     #oSIGMASK, r5
35         mov     #SIG_SETMASK, r4
36         mov     #0, r6
37         mov     #+SYS_ify(sigprocmask), r3
38         trapa   #0x13
39         mov     r0, r1
40         mov     #-12, r2
41         shad    r2, r1
42         not     r1, r1                  // r1=0 means r0 = -1 to -4095
43         tst     r1, r1                  // i.e. error in linux
44         bf      .Lsetcontext_restore
45 .Lsyscall_error:        
46         SYSCALL_ERROR_HANDLER
47 .Lpseudo_end:
48         rts
49          nop
51 .Lsetcontext_restore:
52         mov     r8, r0
53         add     #(oPC), r0
54         mov.l   @r0+, r2
55         lds.l   @r0+, pr
57         /* Restore T frag.  */
58         mov.l   @r0+, r1
59         shlr    r1
60         /* Skip GBR which is used for thread pointer.  */
61         add     #4, r0
63         lds.l   @r0+, mach
64         lds.l   @r0+, macl
66         mov     r8, r0
67         add     #(oR9), r0
68         mov.l   @r0+, r9
69         mov.l   @r0+, r10
70         mov.l   @r0+, r11
71         mov.l   @r0+, r12
72         mov.l   @r0+, r13
73         mov.l   @r0+, r14
74         mov.l   @r0+, r15
76         mov     r8, r0
77         mov.l   @(oR0,r0), r1
78         mov.l   r1, @-r15
79         cfi_adjust_cfa_offset(4)
80         cfi_rel_offset (r1, 0)
81         mov.l   r2, @-r15
82         cfi_adjust_cfa_offset(4)
83         cfi_rel_offset (r2, 0)
85         mov.l   @(oR1,r0), r1
86         mov.l   @(oR2,r0), r2
87         mov.l   @(oR3,r0), r3
88         mov.l   @(oR4,r0), r4
89         mov.l   @(oR5,r0), r5
90         mov.l   @(oR6,r0), r6
91         mov.l   @(oR7,r0), r7
92         mov.l   @(oR8,r0), r8
93         mov.l   @r15+, r0
94         jmp     @r0
95          mov.l  @r15+, r0
97 PSEUDO_END(__setcontext)
99 weak_alias (__setcontext, setcontext)