- now depend on libpidutil [1] instead of FreeBSD specific libutil

- cleanup Makefile and respect PREFIX
- now builds on OS X on which clock_gettime() is not implemented
This commit is contained in:
Babak Farrokhi 2015-10-21 11:29:05 +03:30
parent 01d25ecb39
commit 1fb260d101
2 changed files with 27 additions and 4 deletions

View File

@ -1,7 +1,7 @@
PREFIX=/usr/local PREFIX?=/usr/local
INC=-I$(PREFIX)/include INC=-I$(PREFIX)/include
LIB=-L$(PREFIX)/lib -lutil LIB=-L$(PREFIX)/lib -lpidutil
FLAGS=-Wall -O2 -pipe -funroll-loops -ffast-math -fno-strict-aliasing -mssse3 FLAGS=-Wall -Wextra -O2 -pipe -funroll-loops -ffast-math -fno-strict-aliasing -mssse3
CC?=cc CC?=cc
all: ifstatd_ all: ifstatd_

View File

@ -46,7 +46,13 @@
#include <string.h> #include <string.h>
#include <sysexits.h> #include <sysexits.h>
#include <unistd.h> #include <unistd.h>
#include <libutil.h> #include <time.h>
#include <pidutil.h>
#ifdef __MACH__
#include <sys/time.h>
#define CLOCK_REALTIME 0
#endif
#define IFA_STAT(s) (((struct if_data *)ifa->ifa_data)->ifi_ ## s) #define IFA_STAT(s) (((struct if_data *)ifa->ifa_data)->ifi_ ## s)
#define RESOLUTION 10 #define RESOLUTION 10
@ -70,6 +76,23 @@ char *pid_filename;
char *cache_filename; char *cache_filename;
struct pidfh *pfh; 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 * Prepare for a clean shutdown
*/ */