diff --git a/Makefile b/Makefile index 862f713..6e5b675 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ -PREFIX=/usr/local +PREFIX?=/usr/local INC=-I$(PREFIX)/include -LIB=-L$(PREFIX)/lib -lutil -FLAGS=-Wall -O2 -pipe -funroll-loops -ffast-math -fno-strict-aliasing -mssse3 +LIB=-L$(PREFIX)/lib -lpidutil +FLAGS=-Wall -Wextra -O2 -pipe -funroll-loops -ffast-math -fno-strict-aliasing -mssse3 CC?=cc all: ifstatd_ diff --git a/ifstatd.c b/ifstatd.c index 1ccaef9..24d6bd0 100644 --- a/ifstatd.c +++ b/ifstatd.c @@ -46,7 +46,13 @@ #include #include #include -#include +#include +#include + +#ifdef __MACH__ +#include +#define CLOCK_REALTIME 0 +#endif #define IFA_STAT(s) (((struct if_data *)ifa->ifa_data)->ifi_ ## s) #define RESOLUTION 10 @@ -70,6 +76,23 @@ char *pid_filename; char *cache_filename; struct pidfh *pfh; +#ifdef __MACH__ +/* clock_gettime is not implemented on OSX */ +int +clock_gettime(int clk_id, struct timespec *t) +{ + struct timeval now; + int rv = gettimeofday(&now, NULL); + + if (rv) + return rv; + t->tv_sec = now.tv_sec; + t->tv_nsec = now.tv_usec * 1000; + return 0; +} + +#endif + /* * Prepare for a clean shutdown */