海思平台移植ntpclient

1、源码下载

      http://doolittle.icarus.com/ntpclient/  

代码结构
total 52
-rwx------ 1 root root 1286 May  7 15:44 Makefile
-rwx------ 1 root root 19817 Jan  1  2016 ntpclient.c
-rwx------ 1 root root 353 Dec 28  2010 ntpclient.h
-rwx------ 1 root root 11267 Dec 30  2015 phaselock.c
-rwx------ 1 root root 10431 Jan  1  2016 README

2、编译源码(aarch64-himix100-linux-gcc)

     修改Makefile如下

# A long time ago, far, far away, under Solaris, you needed to
#    CFLAGS += -xO2 -Xc
#    LDLIBS += -lnsl -lsocket
# To cross-compile
    CC = aarch64-himix100-linux-gcc
# To use clang
#    CC = clang
# To check for lint
#    CFLAGS += -Wpointer-arith -Wcast-align -Wcast-qual -Wshadow -Wundef \
#     -Waggregate-return -Wnested-externs -Winline -Wwrite-strings \
#     -Wstrict-prototypes -Wmissing-prototypes -pedantic

# This was old-school networking code, making the traditional cast between
# struct sockaddr* and struct sockaddr_in*.  Thus a modern gcc needed:
#CFLAGS += -fno-strict-aliasing
# but as of ntpclient-2015, I cleaned up those casts enough to make both
# gcc-4.9.2 and clang-3.5.0 happy without it.

CFLAGS += -std=c99  # should also still work with -std=c89
CFLAGS += -D_POSIX_C_SOURCE=199309 -D_BSD_SOURCE
CFLAGS += -W -Wall  # -W is spelled -Wextra these days, but -W is stilli
                    # valid and works with older compilers.
CFLAGS += -O2
CFLAGS += -DPRECISION_SIOCGSTAMP
CFLAGS += -DENABLE_DEBUG
CFLAGS += -DENABLE_REPLAY
CFLAGS += -DUSE_OBSOLETE_GETTIMEOFDAY

LOADLIBES += -lrt

all: ntpclient

test: ntpclient
	./ntpclient -d -r <test.dat

ntpclient: ntpclient.o phaselock.o

ntpclient.o phaselock.o: ntpclient.h


clean:
	rm -f ntpclient  *.o

     编译makefile,生成ntpclient

3、用法

Usage: ntpclient [options]
options:
 -c count     stop after count time measurements (default 0 means go forever)
 -d           print diagnostics (feature can be disabled at compile time)
 -g goodness  causes ntpclient to stop after getting a result more accurate
                   than goodness (microseconds, default 0 means go forever)
 -h hostname  (mandatory) NTP server, against which to measure system time
 -i interval  check time every interval seconds (default 600)
 -l           attempt to lock local clock to server using adjtimex(2)
 -p port      local NTP client UDP port (default 0 means "any available")
 -q min_delay minimum packet delay for transaction (default 800 microseconds)
 -r           replay analysis code based on stdin
 -s           simple clock set (implies -c 1)
 -t           trust network and server, no RFC-4330 recommended cross-checks

./ntpclient -s -d -c 1 -i 5  -h 202.108.6.95

     

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值