2009-04-18 17:32:04 +00:00
|
|
|
/* Save current context.
|
2021-01-02 19:32:25 +00:00
|
|
|
Copyright (C) 2009-2021 Free Software Foundation, Inc.
|
2009-04-18 17:32:04 +00:00
|
|
|
This file is part of the GNU C Library.
|
|
|
|
Contributed by Maciej W. Rozycki <macro@codesourcery.com>.
|
|
|
|
|
|
|
|
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
|
2012-03-09 23:56:38 +00:00
|
|
|
License along with the GNU C Library. If not, see
|
Prefer https to http for gnu.org and fsf.org URLs
Also, change sources.redhat.com to sourceware.org.
This patch was automatically generated by running the following shell
script, which uses GNU sed, and which avoids modifying files imported
from upstream:
sed -ri '
s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g
s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g
' \
$(find $(git ls-files) -prune -type f \
! -name '*.po' \
! -name 'ChangeLog*' \
! -path COPYING ! -path COPYING.LIB \
! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \
! -path manual/texinfo.tex ! -path scripts/config.guess \
! -path scripts/config.sub ! -path scripts/install-sh \
! -path scripts/mkinstalldirs ! -path scripts/move-if-change \
! -path INSTALL ! -path locale/programs/charmap-kw.h \
! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \
! '(' -name configure \
-execdir test -f configure.ac -o -f configure.in ';' ')' \
! '(' -name preconfigure \
-execdir test -f preconfigure.ac ';' ')' \
-print)
and then by running 'make dist-prepare' to regenerate files built
from the altered files, and then executing the following to cleanup:
chmod a+x sysdeps/unix/sysv/linux/riscv/configure
# Omit irrelevant whitespace and comment-only changes,
# perhaps from a slightly-different Autoconf version.
git checkout -f \
sysdeps/csky/configure \
sysdeps/hppa/configure \
sysdeps/riscv/configure \
sysdeps/unix/sysv/linux/csky/configure
# Omit changes that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines
git checkout -f \
sysdeps/powerpc/powerpc64/ppc-mcount.S \
sysdeps/unix/sysv/linux/s390/s390-64/syscall.S
# Omit change that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline
git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
2019-09-07 05:40:42 +00:00
|
|
|
<https://www.gnu.org/licenses/>. */
|
2009-04-18 17:32:04 +00:00
|
|
|
|
|
|
|
#include <sysdep.h>
|
|
|
|
#include <sys/asm.h>
|
|
|
|
#include <sys/fpregdef.h>
|
|
|
|
#include <sys/regdef.h>
|
|
|
|
|
|
|
|
#include "ucontext_i.h"
|
|
|
|
|
|
|
|
/* int getcontext (ucontext_t *ucp) */
|
|
|
|
|
|
|
|
.text
|
2013-02-27 23:45:07 +00:00
|
|
|
.set nomips16
|
2009-04-18 17:32:04 +00:00
|
|
|
LOCALSZ = 0
|
|
|
|
MASK = 0x00000000
|
|
|
|
#ifdef __PIC__
|
|
|
|
LOCALSZ = 1 /* save gp */
|
|
|
|
# if _MIPS_SIM != _ABIO32
|
|
|
|
MASK = 0x10000000
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
FRAMESZ = ((LOCALSZ * SZREG) + ALSZ) & ALMASK
|
|
|
|
GPOFF = FRAMESZ - (1 * SZREG)
|
2017-06-13 21:34:45 +00:00
|
|
|
MCONTEXT_GREGSZ = 8
|
|
|
|
#if _MIPS_SIM == _ABIO32 && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
|
|
|
MCONTEXT_GREGOFF = 4
|
|
|
|
#else
|
|
|
|
MCONTEXT_GREGOFF = 0
|
|
|
|
#endif
|
2009-04-18 17:32:04 +00:00
|
|
|
|
|
|
|
NESTED (__getcontext, FRAMESZ, ra)
|
|
|
|
.mask MASK, 0
|
|
|
|
.fmask 0x00000000, 0
|
|
|
|
|
|
|
|
#ifdef __PIC__
|
|
|
|
SETUP_GP
|
|
|
|
|
|
|
|
move a2, sp
|
|
|
|
# define _SP a2
|
|
|
|
|
|
|
|
# if _MIPS_SIM != _ABIO32
|
|
|
|
move a3, gp
|
|
|
|
# define _GP a3
|
|
|
|
# endif
|
|
|
|
|
|
|
|
PTR_ADDIU sp, -FRAMESZ
|
2013-02-11 18:19:14 +00:00
|
|
|
cfi_adjust_cfa_offset (FRAMESZ)
|
|
|
|
SETUP_GP64_STACK (GPOFF, __getcontext)
|
2009-04-18 17:32:04 +00:00
|
|
|
SAVE_GP (GPOFF)
|
|
|
|
|
|
|
|
#else /* ! __PIC__ */
|
|
|
|
# define _SP sp
|
|
|
|
# define _GP gp
|
|
|
|
|
|
|
|
#endif /* ! __PIC__ */
|
|
|
|
|
|
|
|
#ifdef PROF
|
|
|
|
.set noat
|
|
|
|
move AT, ra
|
|
|
|
jal _mcount
|
|
|
|
.set at
|
|
|
|
#endif
|
|
|
|
|
2017-06-13 21:34:45 +00:00
|
|
|
REG_S s0, (MCONTEXT_GREGOFF + 16 * MCONTEXT_GREGSZ + MCONTEXT_GREGS)(a0)
|
|
|
|
REG_S s1, (MCONTEXT_GREGOFF + 17 * MCONTEXT_GREGSZ + MCONTEXT_GREGS)(a0)
|
|
|
|
REG_S s2, (MCONTEXT_GREGOFF + 18 * MCONTEXT_GREGSZ + MCONTEXT_GREGS)(a0)
|
|
|
|
REG_S s3, (MCONTEXT_GREGOFF + 19 * MCONTEXT_GREGSZ + MCONTEXT_GREGS)(a0)
|
|
|
|
REG_S s4, (MCONTEXT_GREGOFF + 20 * MCONTEXT_GREGSZ + MCONTEXT_GREGS)(a0)
|
|
|
|
REG_S s5, (MCONTEXT_GREGOFF + 21 * MCONTEXT_GREGSZ + MCONTEXT_GREGS)(a0)
|
|
|
|
REG_S s6, (MCONTEXT_GREGOFF + 22 * MCONTEXT_GREGSZ + MCONTEXT_GREGS)(a0)
|
|
|
|
REG_S s7, (MCONTEXT_GREGOFF + 23 * MCONTEXT_GREGSZ + MCONTEXT_GREGS)(a0)
|
2009-04-18 17:32:04 +00:00
|
|
|
#if ! defined (__PIC__) || _MIPS_SIM != _ABIO32
|
2017-06-13 21:34:45 +00:00
|
|
|
REG_S _GP, (MCONTEXT_GREGOFF + 28 * MCONTEXT_GREGSZ + MCONTEXT_GREGS)(a0)
|
2009-04-18 17:32:04 +00:00
|
|
|
#endif
|
2017-06-13 21:34:45 +00:00
|
|
|
REG_S _SP, (MCONTEXT_GREGOFF + 29 * MCONTEXT_GREGSZ + MCONTEXT_GREGS)(a0)
|
|
|
|
REG_S fp, (MCONTEXT_GREGOFF + 30 * MCONTEXT_GREGSZ + MCONTEXT_GREGS)(a0)
|
|
|
|
REG_S ra, (MCONTEXT_GREGOFF + 31 * MCONTEXT_GREGSZ + MCONTEXT_GREGS)(a0)
|
|
|
|
REG_S ra, (MCONTEXT_GREGOFF + MCONTEXT_PC)(a0)
|
2009-04-18 17:32:04 +00:00
|
|
|
|
|
|
|
#ifdef __mips_hard_float
|
|
|
|
# if _MIPS_SIM == _ABI64
|
|
|
|
s.d fs0, (24 * SZREG + MCONTEXT_FPREGS)(a0)
|
|
|
|
s.d fs1, (25 * SZREG + MCONTEXT_FPREGS)(a0)
|
|
|
|
s.d fs2, (26 * SZREG + MCONTEXT_FPREGS)(a0)
|
|
|
|
s.d fs3, (27 * SZREG + MCONTEXT_FPREGS)(a0)
|
|
|
|
s.d fs4, (28 * SZREG + MCONTEXT_FPREGS)(a0)
|
|
|
|
s.d fs5, (29 * SZREG + MCONTEXT_FPREGS)(a0)
|
|
|
|
s.d fs6, (30 * SZREG + MCONTEXT_FPREGS)(a0)
|
|
|
|
s.d fs7, (31 * SZREG + MCONTEXT_FPREGS)(a0)
|
|
|
|
|
|
|
|
# else /* _MIPS_SIM != _ABI64 */
|
|
|
|
s.d fs0, (20 * SZREG + MCONTEXT_FPREGS)(a0)
|
|
|
|
s.d fs1, (22 * SZREG + MCONTEXT_FPREGS)(a0)
|
|
|
|
s.d fs2, (24 * SZREG + MCONTEXT_FPREGS)(a0)
|
|
|
|
s.d fs3, (26 * SZREG + MCONTEXT_FPREGS)(a0)
|
|
|
|
s.d fs4, (28 * SZREG + MCONTEXT_FPREGS)(a0)
|
|
|
|
s.d fs5, (30 * SZREG + MCONTEXT_FPREGS)(a0)
|
|
|
|
|
|
|
|
# endif /* _MIPS_SIM != _ABI64 */
|
|
|
|
|
|
|
|
cfc1 v1, fcr31
|
|
|
|
sw v1, MCONTEXT_FPC_CSR(a0)
|
|
|
|
#endif /* __mips_hard_float */
|
|
|
|
|
|
|
|
/* rt_sigprocmask (SIG_BLOCK, NULL, &ucp->uc_sigmask, _NSIG8) */
|
|
|
|
li a3, _NSIG8
|
|
|
|
PTR_ADDU a2, a0, UCONTEXT_SIGMASK
|
|
|
|
move a1, zero
|
|
|
|
li a0, SIG_BLOCK
|
|
|
|
|
|
|
|
li v0, SYS_ify (rt_sigprocmask)
|
|
|
|
syscall
|
|
|
|
bnez a3, 99f
|
2013-02-11 18:19:14 +00:00
|
|
|
cfi_remember_state
|
2009-04-18 17:32:04 +00:00
|
|
|
|
|
|
|
#ifdef __PIC__
|
2013-02-11 18:19:14 +00:00
|
|
|
RESTORE_GP64_STACK
|
2009-04-18 17:32:04 +00:00
|
|
|
PTR_ADDIU sp, FRAMESZ
|
2013-02-11 18:19:14 +00:00
|
|
|
cfi_adjust_cfa_offset (-FRAMESZ)
|
2009-04-18 17:32:04 +00:00
|
|
|
#endif
|
|
|
|
move v0, zero
|
|
|
|
jr ra
|
|
|
|
|
|
|
|
99:
|
2013-02-11 18:19:14 +00:00
|
|
|
cfi_restore_state
|
2009-04-18 17:32:04 +00:00
|
|
|
#ifdef __PIC__
|
|
|
|
PTR_LA t9, JUMPTARGET (__syscall_error)
|
2013-02-11 18:19:14 +00:00
|
|
|
RESTORE_GP64_STACK
|
2009-04-18 17:32:04 +00:00
|
|
|
PTR_ADDIU sp, FRAMESZ
|
2013-02-11 18:19:14 +00:00
|
|
|
cfi_adjust_cfa_offset (-FRAMESZ)
|
2009-04-18 17:32:04 +00:00
|
|
|
jr t9
|
|
|
|
|
|
|
|
#else /* ! __PIC__ */
|
|
|
|
|
|
|
|
j JUMPTARGET (__syscall_error)
|
|
|
|
#endif /* ! __PIC__ */
|
|
|
|
PSEUDO_END (__getcontext)
|
|
|
|
|
|
|
|
weak_alias (__getcontext, getcontext)
|