mirror of
https://gitlab.com/chrony/chrony.git
synced 2026-03-10 16:49:38 -04:00
local: require clock_gettime()
Make clock_gettime() a hard requirement of chrony. It should be available on all reasonably recent versions of the supported systems. This enables adoption of the clockid_t type (CLOCK_* identifiers).
This commit is contained in:
9
configure
vendored
9
configure
vendored
@@ -666,18 +666,18 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $try_clock_gettime = "1" ]; then
|
if [ $try_clock_gettime = "1" ]; then
|
||||||
if test_code 'clock_gettime()' 'time.h' '' '' '
|
if ! test_code 'clock_gettime()' 'time.h' '' '' '
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
clock_gettime(CLOCK_REALTIME, &ts);'
|
clock_gettime(CLOCK_REALTIME, &ts);'
|
||||||
then
|
then
|
||||||
add_def HAVE_CLOCK_GETTIME
|
|
||||||
else
|
|
||||||
if test_code 'clock_gettime() in -lrt' 'time.h' '' '-lrt' '
|
if test_code 'clock_gettime() in -lrt' 'time.h' '' '-lrt' '
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
clock_gettime(CLOCK_REALTIME, &ts);'
|
clock_gettime(CLOCK_REALTIME, &ts);'
|
||||||
then
|
then
|
||||||
add_def HAVE_CLOCK_GETTIME
|
|
||||||
EXTRA_LIBS="$EXTRA_LIBS -lrt"
|
EXTRA_LIBS="$EXTRA_LIBS -lrt"
|
||||||
|
else
|
||||||
|
echo "error: clock_gettime() not found"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -829,7 +829,6 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $feat_refclock = "1" ] && [ $feat_phc = "1" ] && [ $try_phc = "1" ] && \
|
if [ $feat_refclock = "1" ] && [ $feat_phc = "1" ] && [ $try_phc = "1" ] && \
|
||||||
grep '#define HAVE_CLOCK_GETTIME' config.h > /dev/null && \
|
|
||||||
test_code '<linux/ptp_clock.h>' 'sys/ioctl.h linux/ptp_clock.h' '' '' \
|
test_code '<linux/ptp_clock.h>' 'sys/ioctl.h linux/ptp_clock.h' '' '' \
|
||||||
'ioctl(1, PTP_CLOCK_GETCAPS + PTP_SYS_OFFSET, 0);'
|
'ioctl(1, PTP_CLOCK_GETCAPS + PTP_SYS_OFFSET, 0);'
|
||||||
then
|
then
|
||||||
|
|||||||
13
local.c
13
local.c
@@ -109,7 +109,7 @@ static double max_clock_error;
|
|||||||
static int
|
static int
|
||||||
get_clock_resolution(void)
|
get_clock_resolution(void)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_CLOCK_GETTIME) && !defined(LINUX)
|
#ifndef LINUX
|
||||||
struct timespec res;
|
struct timespec res;
|
||||||
|
|
||||||
if (clock_getres(CLOCK_REALTIME, &res) < 0)
|
if (clock_getres(CLOCK_REALTIME, &res) < 0)
|
||||||
@@ -123,7 +123,7 @@ get_clock_resolution(void)
|
|||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
#if defined(LINUX) && defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC_RAW)
|
#if defined(LINUX) && defined(CLOCK_MONOTONIC_RAW)
|
||||||
|
|
||||||
static int
|
static int
|
||||||
compare_ints(const void *a, const void *b)
|
compare_ints(const void *a, const void *b)
|
||||||
@@ -499,17 +499,8 @@ void LCL_RemoveDispersionNotifyHandler(LCL_DispersionNotifyHandler handler, void
|
|||||||
void
|
void
|
||||||
LCL_ReadRawTime(struct timespec *ts)
|
LCL_ReadRawTime(struct timespec *ts)
|
||||||
{
|
{
|
||||||
#if HAVE_CLOCK_GETTIME
|
|
||||||
if (clock_gettime(CLOCK_REALTIME, ts) < 0)
|
if (clock_gettime(CLOCK_REALTIME, ts) < 0)
|
||||||
LOG_FATAL("clock_gettime() failed : %s", strerror(errno));
|
LOG_FATAL("clock_gettime() failed : %s", strerror(errno));
|
||||||
#else
|
|
||||||
struct timeval tv;
|
|
||||||
|
|
||||||
if (gettimeofday(&tv, NULL) < 0)
|
|
||||||
LOG_FATAL("gettimeofday() failed : %s", strerror(errno));
|
|
||||||
|
|
||||||
UTI_TimevalToTimespec(&tv, ts);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|||||||
Reference in New Issue
Block a user