From 9edd319f11c2ceb54905ac87d89e44d940250eb6 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Wed, 5 Sep 2012 17:00:30 +0200 Subject: [PATCH] Use clock_adjtime from glibc if available. Signed-off-by: Miroslav Lichvar --- makefile | 7 ++++++- missing.h | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/makefile b/makefile index fe0dcbd..fd032f5 100644 --- a/makefile +++ b/makefile @@ -17,10 +17,15 @@ KBUILD_OUTPUT ?= /lib/modules/$(shell uname -r)/build +FEAT_CFLAGS := +ifneq ($(shell grep clock_adjtime /usr/include/bits/time.h),) +FEAT_CFLAGS += -D_GNU_SOURCE -DHAVE_CLOCK_ADJTIME +endif + DEBUG = CC = $(CROSS_COMPILE)gcc INC = -I$(KBUILD_OUTPUT)/usr/include -CFLAGS = -Wall $(INC) $(DEBUG) $(EXTRA_CFLAGS) +CFLAGS = -Wall $(INC) $(DEBUG) $(FEAT_CFLAGS) $(EXTRA_CFLAGS) LDLIBS = -lm -lrt $(EXTRA_LDFLAGS) PRG = ptp4l pmc phc2sys hwstamp_ctl OBJ = bmc.o clock.o config.o fsm.o ptp4l.o mave.o msg.o phc.o pi.o port.o \ diff --git a/missing.h b/missing.h index bf82df5..fbd57d4 100644 --- a/missing.h +++ b/missing.h @@ -44,10 +44,12 @@ #define FD_TO_CLOCKID(fd) ((~(clockid_t) (fd) << 3) | CLOCKFD) #define CLOCKID_TO_FD(clk) ((unsigned int) ~((clk) >> 3)) +#ifndef HAVE_CLOCK_ADJTIME static inline int clock_adjtime(clockid_t id, struct timex *tx) { return syscall(__NR_clock_adjtime, id, tx); } +#endif #ifndef __uClinux__