diff options
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/gen/usleep.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/libc/gen/usleep.c b/lib/libc/gen/usleep.c index 5141d36..03df495 100644 --- a/lib/libc/gen/usleep.c +++ b/lib/libc/gen/usleep.c @@ -36,21 +36,27 @@ static char sccsid[] = "@(#)usleep.c 8.1 (Berkeley) 6/4/93"; #endif static char rcsid[] = - "$Id$"; + "$Id: usleep.c,v 1.19 1997/10/17 09:40:08 ache Exp $"; #endif /* LIBC_SCCS and not lint */ +#include <errno.h> #include <time.h> #include <unistd.h> -void +int usleep(useconds) unsigned int useconds; { struct timespec time_to_sleep; + if (useconds >= 1000000) { + errno = EINVAL; + return -1; + } if (useconds) { - time_to_sleep.tv_nsec = (useconds % 1000000) * 1000; - time_to_sleep.tv_sec = useconds / 1000000; - (void)nanosleep(&time_to_sleep, NULL); + time_to_sleep.tv_nsec = useconds * 1000; + time_to_sleep.tv_sec = 0; + return nanosleep(&time_to_sleep, NULL); } + return 0; } |