summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0e8b1b2)
raw | patch | inline | side by side (parent: 0e8b1b2)
author | Florian Forster <ff@octo.it> | |
Sat, 18 Mar 2017 11:18:14 +0000 (12:18 +0100) | ||
committer | Florian Forster <ff@octo.it> | |
Sat, 18 Mar 2017 11:18:14 +0000 (12:18 +0100) |
clock_gettime is not available on Mac OS X :(
Fixes: #19
Fixes: #19
configure.ac | patch | blob | history | |
src/oping.c | patch | blob | history |
diff --git a/configure.ac b/configure.ac
index aea4efba1b9d9c0d92ad30af0d89dfe3692d5f06..1d05f24cdd963f6f4df82204d058611d500594fe 100644 (file)
--- a/configure.ac
+++ b/configure.ac
AC_SEARCH_LIBS([nanosleep],[rt],[],
[AC_MSG_ERROR([cannot find nanosleep])])
-AC_SEARCH_LIBS([clock_gettime],[rt],[],
- [AC_MSG_ERROR([cannot find clock_gettime])])
with_ncurses="no"
AC_CHECK_HEADERS(ncursesw/ncurses.h ncurses.h, [with_ncurses="yes"], [])
diff --git a/src/oping.c b/src/oping.c
index 0cfe64672065c0a99dd3a1d2e9ca8bc9bd5763ce..8c35f3b0c0182d444606261149ee7a660f8e170c 100644 (file)
--- a/src/oping.c
+++ b/src/oping.c
if (outfile != NULL)
{
- struct timespec ts = { 0, 0 };
-
- if (clock_gettime (CLOCK_REALTIME, &ts) == 0)
+ struct timeval tv = {0};
+ if (gettimeofday (&tv, NULL) == 0)
{
- double t = ((double) ts.tv_sec) + (((double) ts.tv_nsec) / 1000000000.0);
+ double t = ((double) tv.tv_sec) + (((double) tv.tv_usec) / 1000000.0);
if ((sequence % 32) == 0)
fprintf (outfile, "#time,host,latency[ms]\n");