]> Zhao Yanbai Git Server - minix.git/commitdiff
Usleep implementation based on select.
authorPhilip Homburg <philip@cs.vu.nl>
Mon, 11 Jul 2005 13:08:00 +0000 (13:08 +0000)
committerPhilip Homburg <philip@cs.vu.nl>
Mon, 11 Jul 2005 13:08:00 +0000 (13:08 +0000)
lib/posix/Makefile
lib/posix/usleep.c [new file with mode: 0644]

index 56b0f258ad514656b4c2a1b0f1a42b3233bb31b6..a985633a7d38feb218eb8937206be4d7f6cb7ef2 100755 (executable)
@@ -101,6 +101,7 @@ OBJECTS     = \
        $(LIBRARY)(priority.o) \
        $(LIBRARY)(readlink.o) \
        $(LIBRARY)(symlink.o) \
+       $(LIBRARY)(usleep.o) \
 
 $(LIBRARY):    $(OBJECTS)
        aal cr $@ *.o
@@ -388,3 +389,6 @@ $(LIBRARY)(lstat.o):        lstat.c
 $(LIBRARY)(symlink.o): symlink.c
        $(CC1) symlink.c
 
+$(LIBRARY)(usleep.o):  usleep.c
+       $(CC1) usleep.c
+
diff --git a/lib/posix/usleep.c b/lib/posix/usleep.c
new file mode 100644 (file)
index 0000000..964e2aa
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+lib/posix/usleep.c
+*/
+
+#include <unistd.h>
+#include <sys/select.h>
+#include <sys/time.h>
+
+int usleep(useconds_t useconds)
+{
+       int r;
+       struct timeval tv;
+
+       tv.tv_sec= useconds/1000000;
+       tv.tv_usec= useconds % 1000000;
+       r= select(0, NULL, NULL, NULL, &tv);
+       return r;
+}