summaryrefslogtreecommitdiff
path: root/lib/libpthread
diff options
context:
space:
mode:
authorenami <enami@NetBSD.org>2009-08-12 23:51:23 +0000
committerenami <enami@NetBSD.org>2009-08-12 23:51:23 +0000
commitcc63c84008a301263b67bb83539f268d628d9f71 (patch)
tree678ae60761eadf5ec9210cd06ea49871fe7e534a /lib/libpthread
parent28623809e320832ce86f39928e7097ef6d015a55 (diff)
Make nanosleep cancelable again.
Diffstat (limited to 'lib/libpthread')
-rw-r--r--lib/libpthread/pthread_cancelstub.c25
-rw-r--r--lib/libpthread/pthread_misc.c19
2 files changed, 25 insertions, 19 deletions
diff --git a/lib/libpthread/pthread_cancelstub.c b/lib/libpthread/pthread_cancelstub.c
index e5dd1011211..acbb4fa4985 100644
--- a/lib/libpthread/pthread_cancelstub.c
+++ b/lib/libpthread/pthread_cancelstub.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pthread_cancelstub.c,v 1.26 2009/01/13 01:50:04 christos Exp $ */
+/* $NetBSD: pthread_cancelstub.c,v 1.27 2009/08/12 23:51:23 enami Exp $ */
/*-
* Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_cancelstub.c,v 1.26 2009/01/13 01:50:04 christos Exp $");
+__RCSID("$NetBSD: pthread_cancelstub.c,v 1.27 2009/08/12 23:51:23 enami Exp $");
#ifndef lint
@@ -98,6 +98,8 @@ ssize_t _sys___mq_timedreceive50(mqd_t, char *, size_t, unsigned *,
ssize_t _sys_msgrcv(int, void *, size_t, long, int);
int _sys_msgsnd(int, const void *, size_t, int);
int _sys___msync13(void *, size_t, int);
+int _sys___nanosleep50(const struct timespec *, struct timespec *);
+int __nanosleep50(const struct timespec *, struct timespec *);
int _sys_open(const char *, int, ...);
int _sys_poll(struct pollfd *, nfds_t, int);
int _sys___pollts50(struct pollfd *, nfds_t, const struct timespec *,
@@ -357,6 +359,24 @@ open(const char *path, int flags, ...)
}
int
+__nanosleep50(const struct timespec *rqtp, struct timespec *rmtp)
+{
+ int retval;
+ pthread_t self;
+
+ self = pthread__self();
+ TESTCANCEL(self);
+ /*
+ * For now, just nanosleep. In the future, maybe pass a ucontext_t
+ * to _lwp_nanosleep() and allow it to recycle our kernel stack.
+ */
+ retval = _sys___nanosleep50(rqtp, rmtp);
+ TESTCANCEL(self);
+
+ return retval;
+}
+
+int
poll(struct pollfd *fds, nfds_t nfds, int timeout)
{
int retval;
@@ -563,6 +583,7 @@ __strong_alias(_mq_receive, mq_receive)
__strong_alias(_msgrcv, msgrcv)
__strong_alias(_msgsnd, msgsnd)
__strong_alias(___msync13, __msync13)
+__strong_alias(___nanosleep50, __nanosleep50)
__strong_alias(_open, open)
__strong_alias(_poll, poll)
__strong_alias(_pread, pread)
diff --git a/lib/libpthread/pthread_misc.c b/lib/libpthread/pthread_misc.c
index 6f943a6ac5a..726cf182c42 100644
--- a/lib/libpthread/pthread_misc.c
+++ b/lib/libpthread/pthread_misc.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pthread_misc.c,v 1.13 2009/01/11 02:46:48 christos Exp $ */
+/* $NetBSD: pthread_misc.c,v 1.14 2009/08/12 23:51:23 enami Exp $ */
/*-
* Copyright (c) 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_misc.c,v 1.13 2009/01/11 02:46:48 christos Exp $");
+__RCSID("$NetBSD: pthread_misc.c,v 1.14 2009/08/12 23:51:23 enami Exp $");
#include <errno.h>
#include <string.h>
@@ -50,9 +50,7 @@ __RCSID("$NetBSD: pthread_misc.c,v 1.13 2009/01/11 02:46:48 christos Exp $");
int pthread__sched_yield(void);
int _sys___sigprocmask14(int, const sigset_t *, sigset_t *);
-int _sys___nanosleep50(const struct timespec *, struct timespec *);
int _sys_sched_yield(void);
-int __nanosleep50(const struct timespec *, struct timespec *);
__strong_alias(__libc_thr_sigsetmask,pthread_sigmask)
__strong_alias(__sigprocmask14,pthread_sigmask)
@@ -150,19 +148,6 @@ pthread_sigmask(int how, const sigset_t *set, sigset_t *oset)
return 0;
}
-#ifndef lint
-int
-__nanosleep50(const struct timespec *rqtp, struct timespec *rmtp)
-{
-
- /*
- * For now, just nanosleep. In the future, maybe pass a ucontext_t
- * to _lwp_nanosleep() and allow it to recycle our kernel stack.
- */
- return _sys___nanosleep50(rqtp, rmtp);
-}
-#endif
-
int
pthread__sched_yield(void)
{