summaryrefslogtreecommitdiff
path: root/contrib/traceroute/usleep.c
diff options
context:
space:
mode:
authorBill Fenner <fenner@FreeBSD.org>2002-07-28 02:24:33 +0000
committerBill Fenner <fenner@FreeBSD.org>2002-07-28 02:24:33 +0000
commit35d3ea799b6d731974269ae8f9fd38f5244b57a6 (patch)
tree96fe0318fd552360a59a280db94c97c5c0a1adbc /contrib/traceroute/usleep.c
parent839b2e106ac510c78c9b54d15554663611c2fe37 (diff)
parent5f3a73ba3ad8f71a2584b90f4519eb0c3ffc69f6 (diff)
downloadsrc-test2-35d3ea799b6d731974269ae8f9fd38f5244b57a6.tar.gz
src-test2-35d3ea799b6d731974269ae8f9fd38f5244b57a6.zip
Notes
Diffstat (limited to 'contrib/traceroute/usleep.c')
-rw-r--r--contrib/traceroute/usleep.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/contrib/traceroute/usleep.c b/contrib/traceroute/usleep.c
new file mode 100644
index 000000000000..6c0716da3c75
--- /dev/null
+++ b/contrib/traceroute/usleep.c
@@ -0,0 +1,32 @@
+#ifndef lint
+static const char rcsid[] =
+ "@(#) $Id: usleep.c,v 1.1 2000/09/16 05:31:06 leres Exp $ (LBL)";
+#endif
+
+#include <sys/types.h>
+#include <sys/time.h>
+
+#include <stdio.h>
+
+#include "gnuc.h"
+#ifdef HAVE_OS_PROTO_H
+#include "os-proto.h"
+#endif
+
+int
+usleep(register u_int useconds)
+{
+#ifdef HAVE_NANOSLEEP
+ struct timespec ts;
+
+ ts.tv_sec = useconds / 1000000;
+ ts.tv_nsec = (useconds % 1000000) * 1000;
+ return (nanosleep(&ts, NULL));
+#else
+ struct timeval tv;
+
+ tv.tv_sec = useconds / 1000000;
+ tv.tv_usec = useconds % 1000000;
+ return (select(0, NULL, NULL, NULL, &tv));
+#endif
+}