summaryrefslogtreecommitdiffstats
path: root/lib/libthr
diff options
context:
space:
mode:
authordeischen <deischen@FreeBSD.org>2005-08-03 00:47:31 +0000
committerdeischen <deischen@FreeBSD.org>2005-08-03 00:47:31 +0000
commit6f4c090af6efd8ec9daa15b1e940864055d58059 (patch)
tree9c3949262ca2d40ae5afcbabae2ffa39071465cb /lib/libthr
parentb6d33128d9242b8331d36ecea9d4193c2904539b (diff)
downloadFreeBSD-src-6f4c090af6efd8ec9daa15b1e940864055d58059.zip
FreeBSD-src-6f4c090af6efd8ec9daa15b1e940864055d58059.tar.gz
Add a cancellation point for usleep().
While here, fix sleep() so that it is also a cancellation point (a missing weak reference prevented that).
Diffstat (limited to 'lib/libthr')
-rw-r--r--lib/libthr/thread/thr_syscalls.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/libthr/thread/thr_syscalls.c b/lib/libthr/thread/thr_syscalls.c
index b67eeb8..89cc836 100644
--- a/lib/libthr/thread/thr_syscalls.c
+++ b/lib/libthr/thread/thr_syscalls.c
@@ -97,6 +97,7 @@ extern int __pselect(int count, fd_set *rfds, fd_set *wfds, fd_set *efds,
extern unsigned int __sleep(unsigned int);
extern int __system(const char *);
extern int __tcdrain(int);
+extern int __usleep(useconds_t);
extern pid_t __wait(int *);
extern pid_t __sys_wait4(pid_t, int *, int, struct rusage *);
extern pid_t __waitpid(pid_t, int *, int);
@@ -473,6 +474,8 @@ __sendto(int s, const void *m, size_t l, int f, const struct sockaddr *t,
return (ret);
}
+__weak_reference(_sleep, sleep);
+
unsigned int
_sleep(unsigned int seconds)
{
@@ -519,6 +522,22 @@ _tcdrain(int fd)
return (ret);
}
+__weak_reference(_usleep, usleep);
+
+int
+_usleep(useconds_t useconds)
+{
+ struct pthread *curthread = _get_curthread();
+ int oldcancel;
+ int ret;
+
+ oldcancel = _thr_cancel_enter(curthread);
+ ret = __usleep(useconds);
+ _thr_cancel_leave(curthread, oldcancel);
+
+ return (ret);
+}
+
__weak_reference(_vfork, vfork);
int
OpenPOWER on IntegriCloud