Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
git-mirror
/
glibc
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
0
Security
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security
Insights
Files
3ddf714
Breadcrumbs
glibc
/
sysdeps
/
unix
/
sysv
/
linux
/
sh
/
sh3
/
swapcontext.S
Blame
Blame
Latest commit
History
History
132 lines (112 loc) · 2.88 KB
Breadcrumbs
glibc
/
sysdeps
/
unix
/
sysv
/
linux
/
sh
/
sh3
/
swapcontext.S
Top
File metadata and controls
Code
Blame
132 lines (112 loc) · 2.88 KB
Raw
/* Save current context and install the given one. Copyright (C) 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #include <sysdep.h> #include "ucontext_i.h" /* int __swapcontext (ucontext_t *ouc, const ucontext_t *uc); */ .text .align 5 ENTRY(__swapcontext) /* Return value of getcontext. R0 is the only register whose value is not preserved. */ mov #0, r0 mov.l r0, @(oR0,r4) mov.l r1, @(oR1,r4) mov.l r2, @(oR2,r4) mov.l r3, @(oR3,r4) mov.l r4, @(oR4,r4) mov.l r5, @(oR5,r4) mov.l r6, @(oR6,r4) mov.l r7, @(oR7,r4) mov r4, r0 add #(oMACL+4), r0 sts.l macl, @-r0 sts.l mach, @-r0 stc.l gbr, @-r0 /* Save T flag to SR. */ movt r1 mov.l r1, @-r0 sts.l pr, @-r0 /* The return address of getcontext is the restart pc. */ sts.l pr, @-r0 mov.l r15, @-r0 mov.l r14, @-r0 mov.l r13, @-r0 mov.l r12, @-r0 mov.l r11, @-r0 mov.l r10, @-r0 mov.l r9, @-r0 mov.l r8, @-r0 mov r5, r8 /* sigprocmask (SIG_SETMASK, &uc->uc_sigmask, &ouc->uc_sigmask). */ add #oSIGMASK, r5 mov r4, r6 add #oSIGMASK, r6 mov #SIG_SETMASK, r4 mov #+SYS_ify(sigprocmask), r3 trapa #0x13 mov r0, r1 mov #-12, r2 shad r2, r1 not r1, r1 // r1=0 means r0 = -1 to -4095 tst r1, r1 // i.e. error in linux bf .Lswapcontext_restore .Lsyscall_error: SYSCALL_ERROR_HANDLER .Lpseudo_end: rts nop .Lswapcontext_restore: mov r8, r0 add #(oPC), r0 mov.l @r0+, r2 lds.l @r0+, pr /* Restore T frag. */ mov.l @r0+, r1 shlr r1 /* Skip GBR which is used for thread pointer. */ add #4, r0 lds.l @r0+, mach lds.l @r0+, macl mov r8, r0 add #(oR9), r0 mov.l @r0+, r9 mov.l @r0+, r10 mov.l @r0+, r11 mov.l @r0+, r12 mov.l @r0+, r13 mov.l @r0+, r14 mov.l @r0+, r15 mov r8, r0 mov.l @(oR0,r0), r1 mov.l r1, @-r15 cfi_adjust_cfa_offset(4) cfi_rel_offset (r1, 0) mov.l r2, @-r15 cfi_adjust_cfa_offset(4) cfi_rel_offset (r2, 0) mov.l @(oR1,r0), r1 mov.l @(oR2,r0), r2 mov.l @(oR3,r0), r3 mov.l @(oR4,r0), r4 mov.l @(oR5,r0), r5 mov.l @(oR6,r0), r6 mov.l @(oR7,r0), r7 mov.l @(oR8,r0), r8 mov.l @r15+, r0 jmp @r0 mov.l @r15+, r0 PSEUDO_END(__swapcontext) weak_alias (__swapcontext, swapcontext)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
You can’t perform that action at this time.