hjl / source-git / glibc

Forked from source-git/glibc 3 years ago
Clone

Blame sysdeps/htl/raise.c

Packit 6c4009
/* raise.c - Generic raise implementation.
Packit 6c4009
   Copyright (C) 2008-2018 Free Software Foundation, Inc.
Packit 6c4009
   Written by Neal H. Walfield <neal@gnu.org>.
Packit 6c4009
Packit 6c4009
   This file is part of the GNU Hurd.
Packit 6c4009
Packit 6c4009
   The GNU Hurd is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public License
Packit 6c4009
   as published by the Free Software Foundation; either version 3 of
Packit 6c4009
   the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU Hurd is distributed in the hope that it will be useful, but
Packit 6c4009
   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 this program.  If not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#include <pthreadP.h>
Packit 6c4009
#include <signal.h>
Packit 6c4009
#include <unistd.h>
Packit 6c4009
Packit 6c4009
#pragma weak __pthread_kill
Packit 6c4009
#pragma weak __pthread_self
Packit 6c4009
#pragma weak __pthread_threads
Packit 6c4009
int
Packit 6c4009
raise (int signo)
Packit 6c4009
{
Packit 6c4009
  /* According to POSIX, if we implement threads (and we do), then
Packit 6c4009
     "the effect of the raise() function shall be equivalent to
Packit 6c4009
     calling: pthread_kill(pthread_self(), sig);"  */
Packit 6c4009
Packit 6c4009
  if (__pthread_kill != NULL && __pthread_threads != NULL)
Packit 6c4009
    {
Packit 6c4009
      int err;
Packit 6c4009
      err = __pthread_kill (__pthread_self (), signo);
Packit 6c4009
      if (err)
Packit 6c4009
	{
Packit 6c4009
	  errno = err;
Packit 6c4009
	  return -1;
Packit 6c4009
	}
Packit 6c4009
      return 0;
Packit 6c4009
    }
Packit 6c4009
  else
Packit 6c4009
    return __kill (__getpid (), signo);
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
libc_hidden_def (raise)
Packit 6c4009
weak_alias (raise, gsignal)