From 6f4c090af6efd8ec9daa15b1e940864055d58059 Mon Sep 17 00:00:00 2001 From: deischen Date: Wed, 3 Aug 2005 00:47:31 +0000 Subject: Add a cancellation point for usleep(). While here, fix sleep() so that it is also a cancellation point (a missing weak reference prevented that). --- lib/libthr/thread/thr_syscalls.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'lib/libthr/thread/thr_syscalls.c') 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 -- cgit v1.1