Switch to using clock_gettime() rather than gettimeofday().
This commit is contained in:
parent
45c76dd548
commit
ab4a2e0b97
@ -2,8 +2,8 @@ project (ndhcp)
|
|||||||
|
|
||||||
cmake_minimum_required (VERSION 2.6)
|
cmake_minimum_required (VERSION 2.6)
|
||||||
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s -std=gnu99 -pedantic -Wall -lcap -D_GNU_SOURCE -DHAVE_CLEARENV -DLINUX")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s -std=gnu99 -pedantic -Wall -lrt -lcap -D_GNU_SOURCE -DHAVE_CLEARENV -DLINUX")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -s -std=gnu99 -pedantic -Wall -lcap -D_GNU_SOURCE -DHAVE_CLEARENV -DLINUX")
|
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -s -std=gnu99 -pedantic -Wall -lrt -lcap -D_GNU_SOURCE -DHAVE_CLEARENV -DLINUX")
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
"${PROJECT_SOURCE_DIR}/ncmlib"
|
"${PROJECT_SOURCE_DIR}/ncmlib"
|
||||||
|
4
Makefile
4
Makefile
@ -27,7 +27,7 @@ makedir:
|
|||||||
mkdir -p $(BUILD_DIR) $(OBJ_DIR)/ndhc $(OBJ_DIR)/ifchd $(OBJ_DIR)/ncmlib
|
mkdir -p $(BUILD_DIR) $(OBJ_DIR)/ndhc $(OBJ_DIR)/ifchd $(OBJ_DIR)/ncmlib
|
||||||
|
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
$(CC) $(CFLAGS) $(NCM_INC) -c -o $(OBJ_DIR)/$@ $<
|
$(CC) $(CFLAGS) $(IFCH_INC) $(NCM_INC) -c -o $(OBJ_DIR)/$@ $<
|
||||||
|
|
||||||
ncmlib.a: $(NCM_OBJS)
|
ncmlib.a: $(NCM_OBJS)
|
||||||
$(AR) rc $(BUILD_DIR)/$@ $(subst ncmlib/,$(OBJ_DIR)/ncmlib/,$(NCM_OBJS))
|
$(AR) rc $(BUILD_DIR)/$@ $(subst ncmlib/,$(OBJ_DIR)/ncmlib/,$(NCM_OBJS))
|
||||||
@ -37,7 +37,7 @@ ifchd: $(IFCHD_OBJS)
|
|||||||
$(CC) $(CFLAGS) $(NCM_INC) -o $(BUILD_DIR)/$@ $(subst ifchd/,$(OBJ_DIR)/ifchd/,$(IFCHD_OBJS)) $(BUILD_DIR)/ncmlib.a -lcap
|
$(CC) $(CFLAGS) $(NCM_INC) -o $(BUILD_DIR)/$@ $(subst ifchd/,$(OBJ_DIR)/ifchd/,$(IFCHD_OBJS)) $(BUILD_DIR)/ncmlib.a -lcap
|
||||||
|
|
||||||
ndhc: $(NDHC_OBJS)
|
ndhc: $(NDHC_OBJS)
|
||||||
$(CC) $(CFLAGS) $(IFCH_INC) $(NCM_INC) -o $(BUILD_DIR)/$@ $(subst ndhc/,$(OBJ_DIR)/ndhc/,$(NDHC_OBJS)) $(BUILD_DIR)/ncmlib.a -lcap
|
$(CC) $(CFLAGS) $(IFCH_INC) $(NCM_INC) -o $(BUILD_DIR)/$@ $(subst ndhc/,$(OBJ_DIR)/ndhc/,$(NDHC_OBJS)) $(BUILD_DIR)/ncmlib.a -lcap -lrt
|
||||||
|
|
||||||
.PHONY: all clean
|
.PHONY: all clean
|
||||||
|
|
||||||
|
@ -28,15 +28,15 @@
|
|||||||
#ifndef SYS_H_
|
#ifndef SYS_H_
|
||||||
#define SYS_H_
|
#define SYS_H_
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <time.h>
|
||||||
#include "ndhc-defines.h"
|
#include "ndhc-defines.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
static inline unsigned long long curms()
|
static inline unsigned long long curms()
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timespec ts;
|
||||||
gettimeofday(&tv, NULL);
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
return tv.tv_sec * 1000ULL + tv.tv_usec / 1000ULL;
|
return ts.tv_sec * 1000ULL + ts.tv_nsec / 1000000ULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern char pidfile[MAX_PATH_LENGTH];
|
extern char pidfile[MAX_PATH_LENGTH];
|
||||||
|
Loading…
Reference in New Issue
Block a user