Blame hurd/hurd-raise.c

Packit 6c4009
/* Copyright (C) 1994-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#include <hurd.h>
Packit 6c4009
#include <hurd/signal.h>
Packit 6c4009
#include <hurd/msg.h>
Packit 6c4009
#include <setjmp.h>
Packit 6c4009
Packit 6c4009
/* Handle signal SIGNO in the calling thread.
Packit 6c4009
   If SS is not NULL it is the sigstate for the calling thread;
Packit 6c4009
   SS->lock is held on entry and released before return.  */
Packit 6c4009
Packit 6c4009
int
Packit 6c4009
_hurd_raise_signal (struct hurd_sigstate *ss,
Packit 6c4009
		    int signo, const struct hurd_signal_detail *detail)
Packit 6c4009
{
Packit 6c4009
  if (ss == NULL)
Packit 6c4009
    {
Packit 6c4009
      ss = _hurd_self_sigstate ();
Packit 6c4009
      __spin_lock (&ss->lock);
Packit 6c4009
    }
Packit 6c4009
Packit 6c4009
  /* Mark SIGNO as pending to be delivered.  */
Packit 6c4009
  __sigaddset (&ss->pending, signo);
Packit 6c4009
  ss->pending_data[signo] = *detail;
Packit 6c4009
Packit 6c4009
  __spin_unlock (&ss->lock);
Packit 6c4009
Packit 6c4009
  /* Send a message to the signal thread so it will wake up and check for
Packit 6c4009
     pending signals.  This is a generic "poll request" message (SIGNO==0)
Packit 6c4009
     rather than delivering this signal and its detail, because we have
Packit 6c4009
     already marked the signal as pending for the particular thread we
Packit 6c4009
     want.  Generating the signal with an RPC might deliver it to some
Packit 6c4009
     other thread.  */
Packit 6c4009
  return __msg_sig_post (_hurd_msgport, 0, 0, __mach_task_self ());
Packit 6c4009
}
Packit 6c4009
libc_hidden_def (_hurd_raise_signal)