File: setcontext.S

package info (click to toggle)
glibc 2.24-11+deb9u4
  • links: PTS, VCS
  • area: main
  • in suites: stretch, stretch-proposed-updates
  • size: 225,852 kB
  • sloc: ansic: 996,505; asm: 261,827; sh: 10,484; makefile: 9,856; cpp: 4,169; python: 3,971; perl: 2,254; awk: 1,753; pascal: 1,521; yacc: 291; sed: 80
file content (158 lines) | stat: -rw-r--r-- 4,036 bytes parent folder | download | duplicates (4)
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/* Install given context.
   Copyright (C) 2008-2016 Free Software Foundation, Inc.
   This file is part of the GNU C Library.
   Contributed by Helge Deller <deller@gmx.de>, 2008.

   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, see
   <http://www.gnu.org/licenses/>.  */

#include <sysdep.h>
#include <libc-symbols.h>

#include "ucontext_i.h"


ENTRY(__setcontext)
	/* Prologue */
	stwm	%r3, 64(%sp)
#ifdef PIC
	stw	%r19, -32(%sp)
#endif

	/* Save ucp.  */
	copy	%r26, %r3

.Lagain:
	/* Set the current signal mask.  */
	/* sigprocmask(SIG_BLOCK, &ucp->uc_sigmask, NULL);  */
	copy	%r0, %r24
	ldo	oSIGMASK(%r3), %r25
	bl	sigprocmask, %r2
	ldi	SIG_SETMASK, %r26

	comib,<>,n 0,%ret0,.Lerror

	/* Save %sp, %dp.  */
	copy	%sp, %r4
	copy	%dp, %r5
	copy	%r19, %r6

	/* Get the registers.  */
	ldw	oR1(%r3), %r1
	ldw	oR2(%r3), %r2
	/* ldw	oR3(%r3), %r3 - used for ucp pointer.	*/
	/* ldw	oR4(%r3), %r4 - used for original %sp.	*/
	/* ldw	oR5(%r3), %r5 - used for %dp / %r27.	*/
	/* ldw	oR6(%r3), %r6 - used for %r19.		*/
	ldw	oR7(%r3), %r7
	ldw	oR8(%r3), %r8
	ldw	oR9(%r3), %r9
	ldw	oR10(%r3), %r10
	ldw	oR11(%r3), %r11
	ldw	oR12(%r3), %r12
	ldw	oR13(%r3), %r13
	ldw	oR14(%r3), %r14
	ldw	oR15(%r3), %r15
	ldw	oR16(%r3), %r16
	ldw	oR17(%r3), %r17
	ldw	oR18(%r3), %r18
	ldw	oR19(%r3), %r19
	ldw	oR20(%r3), %r20
	ldw	oR21(%r3), %r21
	/* ldw	oR22(%r3), %r22 - dyncall arg.  */
	ldw	oR23(%r3), %r23
	ldw	oR24(%r3), %r24
	ldw	oR25(%r3), %r25
	ldw	oR26(%r3), %r26
	ldw	oR27(%r3), %r27
	ldw	oR28(%r3), %r28
	ldw	oR29(%r3), %r29
	ldw	oR30(%r3), %sp
	/* ldw	oR31(%r3), %r31 - dyncall scratch register */

	/* Restore floating-point registers.  */
	ldo	 oFPREGS31(%r3), %r22
	fldds	  0(%r22), %fr31
	fldds,mb -8(%r22), %fr30
	fldds,mb -8(%r22), %fr29
	fldds,mb -8(%r22), %fr28
	fldds,mb -8(%r22), %fr27
	fldds,mb -8(%r22), %fr26
	fldds,mb -8(%r22), %fr25
	fldds,mb -8(%r22), %fr24
	fldds,mb -8(%r22), %fr23
	fldds,mb -8(%r22), %fr22
	fldds,mb -8(%r22), %fr21
	fldds,mb -8(%r22), %fr20
	fldds,mb -8(%r22), %fr19
	fldds,mb -8(%r22), %fr18
	fldds,mb -8(%r22), %fr17
	fldds,mb -8(%r22), %fr16
	fldds,mb -8(%r22), %fr15
	fldds,mb -8(%r22), %fr14
	fldds,mb -8(%r22), %fr13
	fldds,mb -8(%r22), %fr12
	fldds,mb -8(%r22), %fr11
	fldds,mb -8(%r22), %fr10
	fldds,mb -8(%r22), %fr9
	fldds,mb -8(%r22), %fr8
	fldds,mb -8(%r22), %fr7
	fldds,mb -8(%r22), %fr6
	fldds,mb -8(%r22), %fr5
	fldds,mb -8(%r22), %fr4
	fldds,mb -8(%r22), %fr3
	fldds,mb -8(%r22), %fr2
	fldds,mb -8(%r22), %fr1
	fldds,mb -8(%r22), %fr0

	/* Do not load oSS_SP into %sp. The value of oSS_SP indicates
	   the start of the user allocated stack, but not the sp that
	   should be used by the new context. In fact makecontext
	   will create a frame, and adjust sp as required. We do not
	   support calling getcontext and modifying ss_sp without
	   a call to makecontext to synchronize ss_sp into the machine
	   context.  */

	/* Call external function.  */
	copy	%r2, %r22
	bl	$$dyncall, %r31
	copy	%r31, %r2

	/* We return here. Get new ucp in %r3, reload %sp.  */
	ldw	oUC_LINK(%r3), %r3
	copy	%r4, %sp
	copy	%r5, %dp
	copy	%r6, %r19

	/* Continue until ucp == NULL.  */
	comib,<> 0,%r3,.Lagain
	nop

	/* No further context available. Exit now.  */
	bl	HIDDEN_JUMPTARGET(exit), %r2
	ldi	0, %r26


.Lerror:
	/* Epilogue */
	ldw	-84(%r30), %r2
#ifdef PIC
	ldw	-96(%r30), %r19
#endif
	bv	%r0(%r2)
	ldwm	-64(%r30), %r3
L(pseudo_end):
PSEUDO_END(__setcontext)

weak_alias(__setcontext, setcontext)