Add a cancellation point for usleep().

This commit is contained in:
deischen 2005-08-03 00:48:13 +00:00
parent 761a1339b8
commit c0c21f6ca7
2 changed files with 32 additions and 2 deletions

View File

@ -33,9 +33,11 @@
#include <pthread.h>
#include "thr_private.h"
extern unsigned int __sleep(unsigned int);
extern unsigned int __sleep(unsigned int);
extern int __usleep(useconds_t);
__weak_reference(_sleep, sleep);
__weak_reference(_usleep, usleep);
unsigned int
_sleep(unsigned int seconds)
@ -49,3 +51,16 @@ _sleep(unsigned int seconds)
return (ret);
}
int
_usleep(useconds_t useconds)
{
struct pthread *curthread = _get_curthread();
unsigned int ret;
_thr_cancel_enter(curthread);
ret = __usleep(useconds);
_thr_cancel_leave(curthread, 1);
return (ret);
}

View File

@ -33,9 +33,11 @@
#include <pthread.h>
#include "thr_private.h"
extern unsigned int __sleep(unsigned int);
extern unsigned int __sleep(unsigned int);
extern int __usleep(useconds_t);
__weak_reference(_sleep, sleep);
__weak_reference(_usleep, usleep);
unsigned int
_sleep(unsigned int seconds)
@ -49,3 +51,16 @@ _sleep(unsigned int seconds)
return (ret);
}
int
_usleep(useconds_t useconds)
{
struct pthread *curthread = _get_curthread();
unsigned int ret;
_thr_cancel_enter(curthread);
ret = __usleep(useconds);
_thr_cancel_leave(curthread, 1);
return (ret);
}