aboutsummaryrefslogtreecommitdiff
path: root/contrib/ntp/util/hist.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ntp/util/hist.c')
-rw-r--r--contrib/ntp/util/hist.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/contrib/ntp/util/hist.c b/contrib/ntp/util/hist.c
index c9763ce1975c..9453b6c0dca4 100644
--- a/contrib/ntp/util/hist.c
+++ b/contrib/ntp/util/hist.c
@@ -7,24 +7,20 @@
* runs backwards.
*/
-#if 0
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "ntp_types.h"
-#endif
#include <stdio.h>
#include <stdlib.h>
-#include <time.h>
#define NBUF 100001 /* size of basic histogram */
#define NSRT 20000 /* size of overflow histogram */
#define NCNT (600 * 1000000) /* sample interval (us) */
-extern int col(hrtime_t *, hrtime_t *);
-extern hrtime_t gethrtime(void);
+int col P((long *, long *));
int
main(
@@ -32,8 +28,10 @@ main(
char *argv[]
)
{
+ struct timeval ts, tr, tp;
+ struct timezone tzp;
int i, j, n;
- hrtime_t t, u, v, w, gtod[NBUF], ovfl[NSRT];
+ long t, u, v, w, gtod[NBUF], ovfl[NSRT];
/*
* Force pages into memory
@@ -47,10 +45,12 @@ main(
* Construct histogram
*/
n = 0;
- t = gethrtime();
+ gettimeofday(&ts, &tzp);
+ t = ts.tv_sec * 1000000 + ts.tv_usec;
v = t;
while (1) {
- u = gethirestime();
+ gettimeofday(&tr, &tzp);
+ u = tr.tv_sec * 1000000 + tr.tv_usec;
if (u - v > NCNT)
break;
w = u - t;
@@ -66,6 +66,7 @@ main(
} else {
gtod[w]++;
}
+ ts = tr;
t = u;
}
@@ -78,7 +79,13 @@ main(
}
if (n == 0)
return;
- qsort((char *)ovfl, (size_t)n, sizeof(hrtime_t), col);
+ qsort(
+#ifdef QSORT_USES_VOID_P
+ (void *)
+#else
+ (char *)
+#endif
+ ovfl, (size_t)n, sizeof(long), col);
w = 0;
j = 0;
for (i = 0; i < n; i++) {
@@ -98,8 +105,8 @@ main(
int
col(
- hrtime_t *x,
- hrtime_t *y
+ long *x,
+ long *y
)
{
return (*x - *y);