usleep.c 461 B

123456789101112131415161718192021
  1. /*
  2. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  3. *
  4. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  5. */
  6. #include <time.h>
  7. #include <sys/time.h>
  8. #include <sys/types.h>
  9. #include <unistd.h>
  10. libc_hidden_proto(nanosleep)
  11. int usleep (__useconds_t usec)
  12. {
  13. const struct timespec ts = {
  14. .tv_sec = (long int) (usec / 1000000),
  15. .tv_nsec = (long int) (usec % 1000000) * 1000ul
  16. };
  17. return(nanosleep(&ts, NULL));
  18. }