1117758Sdavidxu/* 2117758Sdavidxu * Copyright (C) 2003 David Xu<davidxu@freebsd.org>. 3117758Sdavidxu * All rights reserved. 4117758Sdavidxu * 5117758Sdavidxu * Redistribution and use in source and binary forms, with or without 6117758Sdavidxu * modification, are permitted provided that the following conditions 7117758Sdavidxu * are met: 8117758Sdavidxu * 1. Redistributions of source code must retain the above copyright 9117758Sdavidxu * notice(s), this list of conditions and the following disclaimer as 10117758Sdavidxu * the first lines of this file unmodified other than the possible 11117758Sdavidxu * addition of one or more copyright notices. 12117758Sdavidxu * 2. Redistributions in binary form must reproduce the above copyright 13117758Sdavidxu * notice(s), this list of conditions and the following disclaimer in 14117758Sdavidxu * the documentation and/or other materials provided with the 15117758Sdavidxu * distribution. 16117758Sdavidxu * 17117758Sdavidxu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY 18117758Sdavidxu * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19117758Sdavidxu * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 20117758Sdavidxu * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE 21117758Sdavidxu * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22117758Sdavidxu * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23117758Sdavidxu * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 24117758Sdavidxu * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25117758Sdavidxu * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 26117758Sdavidxu * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27117758Sdavidxu * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28117758Sdavidxu * 29117758Sdavidxu * $FreeBSD$ 30117758Sdavidxu */ 31117758Sdavidxu 32174112Sdeischen#include "namespace.h" 33174112Sdeischen#include <errno.h> 34117758Sdavidxu#include <pthread.h> 35174112Sdeischen#include "un-namespace.h" 36117758Sdavidxu#include "thr_private.h" 37117758Sdavidxu 38174112Sdeischenint _raise(int sig); 39174112Sdeischen 40117758Sdavidxu__weak_reference(_raise, raise); 41117758Sdavidxu 42117758Sdavidxuint 43117758Sdavidxu_raise(int sig) 44117758Sdavidxu{ 45117758Sdavidxu int ret; 46117758Sdavidxu 47117758Sdavidxu if (!_kse_isthreaded()) 48117758Sdavidxu ret = kill(getpid(), sig); 49117758Sdavidxu else { 50174112Sdeischen ret = _pthread_kill(_pthread_self(), sig); 51117758Sdavidxu if (ret != 0) { 52117758Sdavidxu errno = ret; 53117758Sdavidxu ret = -1; 54117758Sdavidxu } 55117758Sdavidxu } 56117758Sdavidxu return (ret); 57117758Sdavidxu} 58