summaryrefslogtreecommitdiff
path: root/libc/unistd/usleep.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc/unistd/usleep.c')
-rw-r--r--libc/unistd/usleep.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/libc/unistd/usleep.c b/libc/unistd/usleep.c
new file mode 100644
index 000000000..25979681d
--- /dev/null
+++ b/libc/unistd/usleep.c
@@ -0,0 +1,13 @@
+#include <time.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+int usleep (__useconds_t usec)
+{
+ const struct timespec ts = {
+ tv_sec: (long int)(usec / 1000000),
+ tv_nsec: (long int) (usec % 1000000) * 1000ul };
+ return(nanosleep(&ts, NULL));
+}
+