Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libpthread Add a pthread cancel stub for sigwait, follow...



details:   https://anonhg.NetBSD.org/src/rev/feb2d41b2408
branches:  trunk
changeset: 778548:feb2d41b2408
user:      agc <agc%NetBSD.org@localhost>
date:      Wed Apr 04 06:29:16 2012 +0000

description:
Add a pthread cancel stub for sigwait, following Onno van der Linden's
analysis in PR 45131.  Kindly tested by Hisashi T Fujinaka (using csup
as the test case) with a successful outcome.

OK martin@

diffstat:

 lib/libpthread/pthread_cancelstub.c |  29 +++++++++++++++++++++++++++--
 1 files changed, 27 insertions(+), 2 deletions(-)

diffs (71 lines):

diff -r db4492702931 -r feb2d41b2408 lib/libpthread/pthread_cancelstub.c
--- a/lib/libpthread/pthread_cancelstub.c       Wed Apr 04 01:40:57 2012 +0000
+++ b/lib/libpthread/pthread_cancelstub.c       Wed Apr 04 06:29:16 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_cancelstub.c,v 1.35 2011/04/22 14:18:34 joerg Exp $    */
+/*     $NetBSD: pthread_cancelstub.c,v 1.36 2012/04/04 06:29:16 agc Exp $      */
 
 /*-
  * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #undef _FORTIFY_SOURCE
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_cancelstub.c,v 1.35 2011/04/22 14:18:34 joerg Exp $");
+__RCSID("$NetBSD: pthread_cancelstub.c,v 1.36 2012/04/04 06:29:16 agc Exp $");
 
 #ifndef lint
 
@@ -58,6 +58,7 @@
 #include <sys/uio.h>
 #include <sys/wait.h>
 #include <aio.h>
+#include <errno.h>
 #include <fcntl.h>
 #include <mqueue.h>
 #include <poll.h>
@@ -577,6 +578,7 @@
        pthread_t self;
        int retval;
        struct timespec tout, *tp;
+
        if (timeout) {
                tout = *timeout;
                tp = &tout;
@@ -591,6 +593,28 @@
        return retval;
 }
 
+int                                                                                                                  
+sigwait(const sigset_t * __restrict set, int * __restrict sig)
+{
+       pthread_t       self;
+       int             saved_errno;
+       int             new_errno;
+       int             retval;
+
+       self = pthread__self();
+       saved_errno = errno;
+       TESTCANCEL(self);
+       retval = ____sigtimedwait50(set, NULL, NULL);
+       TESTCANCEL(self);
+       new_errno = errno;
+       errno = saved_errno;
+       if (retval < 0) {
+               return new_errno;
+       }
+       *sig = retval;
+       return 0;
+}
+
 __strong_alias(_close, close)
 __strong_alias(_fcntl, fcntl)
 __strong_alias(_fdatasync, fdatasync)
@@ -608,6 +632,7 @@
 __strong_alias(_pwrite, pwrite)
 __strong_alias(_read, read)
 __strong_alias(_readv, readv)
+__strong_alias(_sigwait, sigwait)
 __strong_alias(_write, write)
 __strong_alias(_writev, writev)
 



Home | Main Index | Thread Index | Old Index