Last change
on this file since 444 was
444,
checked in by satin@…, 6 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
430 bytes
|
Line | |
---|
1 | /* libc/posix/usleep.c - usleep function */ |
---|
2 | |
---|
3 | /* Written 2002 by Jeff Johnston */ |
---|
4 | |
---|
5 | #ifdef HAVE_NANOSLEEP |
---|
6 | |
---|
7 | #include <errno.h> |
---|
8 | #include <time.h> |
---|
9 | #include <unistd.h> |
---|
10 | |
---|
11 | int usleep(useconds_t useconds) |
---|
12 | { |
---|
13 | struct timespec ts; |
---|
14 | |
---|
15 | ts.tv_sec = (long int)useconds / 1000000; |
---|
16 | ts.tv_nsec = ((long int)useconds % 1000000) * 1000; |
---|
17 | if (!nanosleep(&ts,&ts)) return 0; |
---|
18 | if (errno == EINTR) return ts.tv_sec; |
---|
19 | return -1; |
---|
20 | } |
---|
21 | |
---|
22 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.