missing_d/usleep.c
raw| 1 | /* |
| 2 | * usleep - round microseconds up to an integral number of seconds. |
| 3 | * |
| 4 | * The real usleep() doesn't work this way; this is a hack for systems |
| 5 | * that don't have usleep(). |
| 6 | */ |
| 7 | |
| 8 | int |
| 9 | usleep(unsigned int usec) |
| 10 | { |
| 11 | unsigned int seconds = usec / 1000000; |
| 12 | |
| 13 | /* Round up: */ |
| 14 | seconds += (usec % 1000000 > 0); /* 1 or 0 */ |
| 15 | |
| 16 | return sleep(seconds); |
| 17 | } |