usleep.c 313 B

123456789101112131415
  1. #define nanosleep __nanosleep
  2. #include <time.h>
  3. #include <sys/time.h>
  4. #include <sys/types.h>
  5. #include <unistd.h>
  6. int usleep (__useconds_t usec)
  7. {
  8. const struct timespec ts = {
  9. .tv_sec = (long int) (usec / 1000000),
  10. .tv_nsec = (long int) (usec % 1000000) * 1000ul
  11. };
  12. return(nanosleep(&ts, NULL));
  13. }