1
/* Set current context.
3
Copyright (C) 2009-2012 Free Software Foundation, Inc.
5
This file is part of the GNU C Library.
7
The GNU C Library is free software; you can redistribute it and/or
8
modify it under the terms of the GNU Lesser General Public License as
9
published by the Free Software Foundation; either version 2.1 of the
10
License, or (at your option) any later version.
12
The GNU C Library is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
Lesser General Public License for more details.
17
You should have received a copy of the GNU Lesser General Public
18
License along with the GNU C Library; if not, see
19
<http://www.gnu.org/licenses/>. */
22
#include "ucontext_i.h"
23
#include "ucontext-internal.h"
25
/* int setcontext (const ucontext_t *ucp) */
31
/* Create a signal frame on the stack:
39
stp x29, x30, [sp, -16]!
40
cfi_adjust_cfa_offset (16)
41
cfi_rel_offset (x29, 0)
42
cfi_rel_offset (x30, 8)
45
cfi_def_cfa_register (x29)
47
/* Allocate space for the sigcontext. */
48
mov w3, #((RT_SIGFRAME_SIZE + SP_ALIGN_SIZE) & SP_ALIGN_MASK)
51
/* Compute the base address of the ucontext structure. */
52
add x1, sp, #RT_SIGFRAME_UCONTEXT
54
/* Only ucontext is required in the frame, *copy* it in. */
56
#if UCONTEXT_SIZE % 16
57
#error The implementation of setcontext.S assumes sizeof(ucontext_t) % 16 == 0
60
mov x2, #UCONTEXT_SIZE / 16
67
/* rt_sigreturn () -- no arguments, sp points to struct rt_sigframe. */
68
mov x8, SYS_ify (rt_sigreturn)
71
/* Ooops we failed. Recover the stack */
74
cfi_def_cfa_register (sp)
76
ldp x29, x30, [sp], 16
77
cfi_adjust_cfa_offset (16)
80
b PLTJMP(C_SYMBOL_NAME(__syscall_error))
82
PSEUDO_END (__setcontext)
83
weak_alias (__setcontext, setcontext)
87
cbnz x0, PLTJMP(__setcontext)
88
1: b PLTJMP(HIDDEN_JUMPTARGET(_exit))