|
Packit Service |
82fcde |
/* Emulate sigstack function using sigaltstack.
|
|
Packit Service |
82fcde |
Copyright (C) 1998-2018 Free Software Foundation, Inc.
|
|
Packit Service |
82fcde |
This file is part of the GNU C Library.
|
|
Packit Service |
82fcde |
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
82fcde |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License as published by the Free Software Foundation; either
|
|
Packit Service |
82fcde |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
82fcde |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
82fcde |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
82fcde |
Lesser General Public License for more details.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License along with the GNU C Library; if not, see
|
|
Packit Service |
82fcde |
<http://www.gnu.org/licenses/>. */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#include <signal.h>
|
|
Packit Service |
82fcde |
#include <stddef.h>
|
|
Packit Service |
82fcde |
#include <sys/syscall.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#ifdef __NR_sigaltstack
|
|
Packit Service |
82fcde |
int
|
|
Packit Service |
82fcde |
sigstack (struct sigstack *ss, struct sigstack *oss)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
stack_t sas;
|
|
Packit Service |
82fcde |
stack_t *sasp = NULL;
|
|
Packit Service |
82fcde |
stack_t osas;
|
|
Packit Service |
82fcde |
stack_t *osasp = oss == NULL ? NULL : &osa;;
|
|
Packit Service |
82fcde |
int result;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
if (ss != NULL)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
/* We have to convert the information. */
|
|
Packit Service |
82fcde |
sas.ss_sp = ss->ss_sp;
|
|
Packit Service |
82fcde |
sas.ss_flags = ss->ss_onstack ? SS_ONSTACK : 0;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* For the size of the stack we have no value we can pass to the
|
|
Packit Service |
82fcde |
kernel. This is why this function should not be used. We simply
|
|
Packit Service |
82fcde |
assume that all the memory down to address zero (in case the stack
|
|
Packit Service |
82fcde |
grows down) is available. */
|
|
Packit Service |
82fcde |
sas.ss_size = ss->ss_sp - NULL;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
sasp = &sas;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Call the kernel. */
|
|
Packit Service |
82fcde |
result = __sigaltstack (sasp, osasp);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Convert the result, if wanted and possible. */
|
|
Packit Service |
82fcde |
if (result == 0 && oss != NULL)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
oss->ss_sp = osas.ss_sp;
|
|
Packit Service |
82fcde |
oss->ss_onstack = (osas.ss_flags & SS_ONSTACK) != 0;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
return result;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
link_warning (sigstack, "the `sigstack' function is dangerous. `sigaltstack' should be used instead.")
|
|
Packit Service |
82fcde |
#else
|
|
Packit Service |
82fcde |
# include <signal/sigstack.c>
|
|
Packit Service |
82fcde |
#endif
|