Commit 73deb1e2 authored by Ryan Jackson's avatar Ryan Jackson

Have frisbee use clock_getres() on Linux to figure out clock resolution

parent ce9b0771
......@@ -68,7 +68,7 @@ endif
endif
CLIENTFLAGS = $(CFLAGS)
CLIENTLIBS = -lz $(PTHREADLIBS)
CLIENTLIBS = -lz -lrt $(PTHREADLIBS)
CLIENTOBJS = client.o frisbee.o checksum.o disksize.o $(SHAREDOBJS)
SERVERFLAGS = $(CFLAGS)
......
......@@ -25,7 +25,7 @@ LINUXOPTS = -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE \
-D_XOPEN_SOURCE=500 -D_BSD_SOURCE=1
CLIENTFLAGS = $(CFLAGS)
CLIENTLIBS = -lz $(PTHREADLIBS)
CLIENTLIBS = -lz -lrt $(PTHREADLIBS)
CLIENTOBJS = client.o frisbee.o checksum.o disksize.o $(SHAREDOBJS)
SERVERFLAGS = $(CFLAGS)
......
......@@ -18,6 +18,8 @@
#include <sys/time.h>
#if !defined(linux) && !defined(__CYGWIN__)
#include <sys/sysctl.h>
#elif defined(linux)
#include <time.h>
#endif
#include <assert.h>
......@@ -72,6 +74,17 @@ sleeptime(unsigned int usecs, char *str, int doround)
ci.hz > 0)
clockres_us = ci.tick;
else
#elif defined(linux)
struct timespec res;
if (clock_getres(CLOCK_REALTIME, &res) == 0 && res.tv_sec == 0) {
/* Assume min resolution of 1000 usec, round to nearest usec */
if (res.tv_nsec < 1000000)
clockres_us = 1000;
else
clockres_us = (res.tv_nsec / 1000) * 1000;
}
else
#endif
{
warning("cannot get clock resolution, assuming 100HZ");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment