]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/s390/s390-32/getcontext.S
4a0c358d6f7ce5f885f188218b4d1adcc47ea171
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / s390 / s390-32 / getcontext.S
1 /* Copyright (C) 2001-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
4
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.
9
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.
14
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 <https://www.gnu.org/licenses/>. */
18
19 #include <sysdep.h>
20 #include <features.h>
21
22 #include "ucontext_i.h"
23
24 #include <shlib-compat.h>
25
26 /* __getcontext (const ucontext_t *ucp)
27
28 Saves the machine context in UCP such that when it is activated,
29 it appears as if __getcontext() returned again.
30
31 This implementation is intended to be used for *synchronous* context
32 switches only. Therefore, it does not have to save anything
33 other than the PRESERVED state. */
34
35 ENTRY(__getcontext)
36 lr %r1,%r2
37
38 /* rt_sigprocmask (SIG_BLOCK, NULL, &sc->sc_mask, sigsetsize). */
39 la %r2,SIG_BLOCK
40 slr %r3,%r3
41 la %r4,SC_MASK(%r1)
42 lhi %r5,_NSIG8
43 svc SYS_ify(rt_sigprocmask)
44
45 /* Store fpu context. */
46 stfpc SC_FPC(%r1)
47 std %f0,SC_FPRS(%r1)
48 std %f1,SC_FPRS+8(%r1)
49 std %f2,SC_FPRS+16(%r1)
50 std %f3,SC_FPRS+24(%r1)
51 std %f4,SC_FPRS+32(%r1)
52 std %f5,SC_FPRS+40(%r1)
53 std %f6,SC_FPRS+48(%r1)
54 std %f7,SC_FPRS+56(%r1)
55 std %f8,SC_FPRS+64(%r1)
56 std %f9,SC_FPRS+72(%r1)
57 std %f10,SC_FPRS+80(%r1)
58 std %f11,SC_FPRS+88(%r1)
59 std %f12,SC_FPRS+96(%r1)
60 std %f13,SC_FPRS+104(%r1)
61 std %f14,SC_FPRS+112(%r1)
62 std %f15,SC_FPRS+120(%r1)
63
64 /* Set __getcontext return value to 0. */
65 slr %r2,%r2
66
67 /* Store access registers. */
68 stam %a0,%a15,SC_ACRS(%r1)
69
70 /* Store general purpose registers. */
71 stm %r0,%r15,SC_GPRS(%r1)
72
73 /* Return. */
74 br %r14
75 END(__getcontext)
76
77 #if defined SHARED && SHLIB_COMPAT (libc, GLIBC_2_19, GLIBC_2_20)
78 /* In glibc release 2.19 a new version of getcontext was introduced,
79 but was reverted before 2.20. Thus both versions are the same function. */
80 weak_alias (__getcontext, __v1__getcontext)
81 weak_alias (__getcontext, __v2__getcontext)
82 versioned_symbol (libc, __v1__getcontext, getcontext, GLIBC_2_1)
83 compat_symbol (libc, __v2__getcontext, getcontext, GLIBC_2_19)
84
85 #else
86
87 weak_alias (__getcontext, getcontext)
88
89 #endif /* !(defined SHARED && SHLIB_COMPAT (libc, GLIBC_2_19, GLIBC_2_20)) */