From owner-svn-src-all@FreeBSD.ORG Sat Oct 1 11:59:45 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A4FD9106566C; Sat, 1 Oct 2011 11:59:45 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 932A98FC17; Sat, 1 Oct 2011 11:59:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p91BxjqG016153; Sat, 1 Oct 2011 11:59:45 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p91Bxj1N016147; Sat, 1 Oct 2011 11:59:45 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201110011159.p91Bxj1N016147@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 1 Oct 2011 11:59:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225896 - in stable/8/lib: libc/stdlib libc/sys libthr/thread X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 01 Oct 2011 11:59:45 -0000 Author: kib Date: Sat Oct 1 11:59:45 2011 New Revision: 225896 URL: http://svn.freebsd.org/changeset/base/225896 Log: MFC r212405 (by davidxu): Because POSIX does not allow EINTR to be returned from sigwait(), add a wrapper for it in libc and rework the code in libthr, the system call still can return EINTR, we keep this feature. Discussed with: davidxu Added: stable/8/lib/libc/sys/sigwait.c - copied unchanged from r212405, head/lib/libc/sys/sigwait.c Modified: stable/8/lib/libc/stdlib/Makefile.inc stable/8/lib/libc/sys/Makefile.inc stable/8/lib/libc/sys/Symbol.map stable/8/lib/libthr/thread/thr_sig.c Directory Properties: stable/8/lib/libc/ (props changed) stable/8/lib/libc/stdtime/ (props changed) stable/8/lib/libthr/ (props changed) Modified: stable/8/lib/libc/stdlib/Makefile.inc ============================================================================== --- stable/8/lib/libc/stdlib/Makefile.inc Sat Oct 1 11:49:24 2011 (r225895) +++ stable/8/lib/libc/stdlib/Makefile.inc Sat Oct 1 11:59:45 2011 (r225896) @@ -9,7 +9,7 @@ MISRCS+=_Exit.c a64l.c abort.c abs.c ate getsubopt.c hcreate.c heapsort.c imaxabs.c imaxdiv.c \ insque.c l64a.c labs.c ldiv.c llabs.c lldiv.c lsearch.c malloc.c \ merge.c ptsname.c qsort.c qsort_r.c radixsort.c rand.c random.c \ - reallocf.c realpath.c remque.c strfmon.c strtoimax.c \ + reallocf.c realpath.c remque.c sigwait.c strfmon.c strtoimax.c \ strtol.c strtoll.c strtoq.c strtoul.c strtonum.c strtoull.c \ strtoumax.c strtouq.c system.c tdelete.c tfind.c tsearch.c twalk.c Modified: stable/8/lib/libc/sys/Makefile.inc ============================================================================== --- stable/8/lib/libc/sys/Makefile.inc Sat Oct 1 11:49:24 2011 (r225895) +++ stable/8/lib/libc/sys/Makefile.inc Sat Oct 1 11:59:45 2011 (r225896) @@ -23,6 +23,9 @@ SRCS+= stack_protector.c stack_protector SRCS+= fcntl.c ftruncate.c lseek.c mmap.c pread.c pwrite.c truncate.c PSEUDO+= _fcntl.o .endif +SRCS+= sigwait.c +NOASM+= sigwait.o +PSEUDO+= _sigwait.o # Add machine dependent asm sources: SRCS+=${MDASM} Modified: stable/8/lib/libc/sys/Symbol.map ============================================================================== --- stable/8/lib/libc/sys/Symbol.map Sat Oct 1 11:49:24 2011 (r225895) +++ stable/8/lib/libc/sys/Symbol.map Sat Oct 1 11:59:45 2011 (r225896) @@ -917,6 +917,7 @@ FBSDprivate_1.0 { _sigtimedwait; __sys_sigtimedwait; _sigwait; + __sigwait; __sys_sigwait; _sigwaitinfo; __sys_sigwaitinfo; Copied: stable/8/lib/libc/sys/sigwait.c (from r212405, head/lib/libc/sys/sigwait.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/lib/libc/sys/sigwait.c Sat Oct 1 11:59:45 2011 (r225896, copy of r212405, head/lib/libc/sys/sigwait.c) @@ -0,0 +1,46 @@ +/*- + * Copyright (c) 2010 davidxu@freebsd.org + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +int __sys_sigwait(const sigset_t * restrict, int * restrict); + +__weak_reference(__sigwait, sigwait); + +int +__sigwait(const sigset_t * restrict set, int * restrict sig) +{ + int ret; + + /* POSIX does not allow EINTR to be returned */ + do { + ret = __sys_sigwait(set, sig); + } while (ret == EINTR); + return (ret); +} Modified: stable/8/lib/libthr/thread/thr_sig.c ============================================================================== --- stable/8/lib/libthr/thread/thr_sig.c Sat Oct 1 11:49:24 2011 (r225895) +++ stable/8/lib/libthr/thread/thr_sig.c Sat Oct 1 11:59:45 2011 (r225896) @@ -56,7 +56,7 @@ int _sigtimedwait(const sigset_t *set, s const struct timespec * timeout); int __sigwaitinfo(const sigset_t *set, siginfo_t *info); int _sigwaitinfo(const sigset_t *set, siginfo_t *info); -int __sigwait(const sigset_t *set, int *sig); +int ___sigwait(const sigset_t *set, int *sig); int _sigwait(const sigset_t *set, int *sig); int __sigsuspend(const sigset_t *sigmask); @@ -269,7 +269,7 @@ __sigsuspend(const sigset_t * set) return (ret); } -__weak_reference(__sigwait, sigwait); +__weak_reference(___sigwait, sigwait); __weak_reference(__sigtimedwait, sigtimedwait); __weak_reference(__sigwaitinfo, sigwaitinfo); @@ -328,14 +328,16 @@ _sigwait(const sigset_t *set, int *sig) } int -__sigwait(const sigset_t *set, int *sig) +___sigwait(const sigset_t *set, int *sig) { struct pthread *curthread = _get_curthread(); sigset_t newset; int ret; - _thr_cancel_enter(curthread); - ret = __sys_sigwait(thr_remove_thr_signals(set, &newset), sig); - _thr_cancel_leave(curthread); + do { + _thr_cancel_enter(curthread); + ret = __sys_sigwait(thr_remove_thr_signals(set, &newset), sig); + _thr_cancel_leave(curthread); + } while (ret == EINTR); return (ret); }