qemu/linux-user/signal-common.h
<<
>>
Prefs
   1/*
   2 *  Emulation of Linux signals
   3 *
   4 *  Copyright (c) 2003 Fabrice Bellard
   5 *
   6 *  This program is free software; you can redistribute it and/or modify
   7 *  it under the terms of the GNU General Public License as published by
   8 *  the Free Software Foundation; either version 2 of the License, or
   9 *  (at your option) any later version.
  10 *
  11 *  This program is distributed in the hope that it will be useful,
  12 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14 *  GNU General Public License for more details.
  15 *
  16 *  You should have received a copy of the GNU General Public License
  17 *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  18 */
  19
  20#ifndef SIGNAL_COMMON_H
  21#define SIGNAL_COMMON_H
  22
  23/* Fallback addresses into sigtramp page. */
  24extern abi_ulong default_sigreturn;
  25extern abi_ulong default_rt_sigreturn;
  26
  27void setup_sigtramp(abi_ulong tramp_page);
  28
  29int on_sig_stack(unsigned long sp);
  30int sas_ss_flags(unsigned long sp);
  31abi_ulong target_sigsp(abi_ulong sp, struct target_sigaction *ka);
  32void target_save_altstack(target_stack_t *uss, CPUArchState *env);
  33abi_long target_restore_altstack(target_stack_t *uss, CPUArchState *env);
  34
  35static inline void target_sigemptyset(target_sigset_t *set)
  36{
  37    memset(set, 0, sizeof(*set));
  38}
  39
  40void host_to_target_sigset_internal(target_sigset_t *d,
  41                                    const sigset_t *s);
  42void target_to_host_sigset_internal(sigset_t *d,
  43                                    const target_sigset_t *s);
  44void tswap_siginfo(target_siginfo_t *tinfo,
  45                   const target_siginfo_t *info);
  46void set_sigmask(const sigset_t *set);
  47void force_sig(int sig);
  48void force_sigsegv(int oldsig);
  49void force_sig_fault(int sig, int code, abi_ulong addr);
  50#if defined(TARGET_ARCH_HAS_SETUP_FRAME)
  51void setup_frame(int sig, struct target_sigaction *ka,
  52                 target_sigset_t *set, CPUArchState *env);
  53#endif
  54void setup_rt_frame(int sig, struct target_sigaction *ka,
  55                    target_siginfo_t *info,
  56                    target_sigset_t *set, CPUArchState *env);
  57
  58void process_pending_signals(CPUArchState *cpu_env);
  59void signal_init(void);
  60int queue_signal(CPUArchState *env, int sig, int si_type,
  61                 target_siginfo_t *info);
  62void host_to_target_siginfo(target_siginfo_t *tinfo, const siginfo_t *info);
  63void target_to_host_siginfo(siginfo_t *info, const target_siginfo_t *tinfo);
  64int target_to_host_signal(int sig);
  65int host_to_target_signal(int sig);
  66long do_sigreturn(CPUArchState *env);
  67long do_rt_sigreturn(CPUArchState *env);
  68abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr,
  69                        CPUArchState *env);
  70int do_sigprocmask(int how, const sigset_t *set, sigset_t *oldset);
  71abi_long do_swapcontext(CPUArchState *env, abi_ulong uold_ctx,
  72                        abi_ulong unew_ctx, abi_long ctx_size);
  73/**
  74 * block_signals: block all signals while handling this guest syscall
  75 *
  76 * Block all signals, and arrange that the signal mask is returned to
  77 * its correct value for the guest before we resume execution of guest code.
  78 * If this function returns non-zero, then the caller should immediately
  79 * return -TARGET_ERESTARTSYS to the main loop, which will take the pending
  80 * signal and restart execution of the syscall.
  81 * If block_signals() returns zero, then the caller can continue with
  82 * emulation of the system call knowing that no signals can be taken
  83 * (and therefore that no race conditions will result).
  84 * This should only be called once, because if it is called a second time
  85 * it will always return non-zero. (Think of it like a mutex that can't
  86 * be recursively locked.)
  87 * Signals will be unblocked again by process_pending_signals().
  88 *
  89 * Return value: non-zero if there was a pending signal, zero if not.
  90 */
  91int block_signals(void); /* Returns non zero if signal pending */
  92
  93#endif
  94