- 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:
parent
01d25ecb39
commit
1fb260d101
6
Makefile
6
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_
|
||||
|
25
ifstatd.c
25
ifstatd.c
@ -46,7 +46,13 @@
|
||||
#include <string.h>
|
||||
#include <sysexits.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 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
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user