1 /* Copied from libc/posix/usleep.c, removed the check for HAVE_NANOSLEEP */ 2 3 /* Copyright (c) 2002 by Jeff Johnston */ 4 5 #include <picolibc.h> 6 7 #include <errno.h> 8 #include <time.h> 9 #include <unistd.h> 10 usleep(useconds_t useconds)11int 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