usleep.c 282 B

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