]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - contrib/traceroute/usleep.c
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / contrib / traceroute / usleep.c
1 #ifndef lint
2 static const char rcsid[] =
3     "@(#) $Id: usleep.c,v 1.1 2000/09/16 05:31:06 leres Exp $ (LBL)";
4 #endif
5
6 #include <sys/types.h>
7 #include <sys/time.h>
8
9 #include <stdio.h>
10
11 #include "gnuc.h"
12 #ifdef HAVE_OS_PROTO_H
13 #include "os-proto.h"
14 #endif
15
16 int
17 usleep(register u_int useconds)
18 {
19 #ifdef HAVE_NANOSLEEP
20         struct timespec ts;
21
22         ts.tv_sec = useconds / 1000000;
23         ts.tv_nsec = (useconds % 1000000) * 1000;
24         return (nanosleep(&ts, NULL));
25 #else
26         struct timeval tv;
27
28         tv.tv_sec = useconds / 1000000;
29         tv.tv_usec = useconds % 1000000;
30         return (select(0, NULL, NULL, NULL, &tv));
31 #endif
32 }