Discussion:
[Linuxptp-devel] clock_adjtime() function
Daniel Le
2015-06-23 22:06:20 UTC
Permalink
My Linux kernel version is 2.6.35.7 and it doesn't seem to have the implementation of syscall for __NR_clock_adjtime. In which kernel version was it initially introduced?

I changed the function clock_adjtime() to use adjtimex() as shown in the following. Would that work fine when it's called to perform a clock step (with the modes ADJ_SETOFFSET bit set) and slewing? Is it better to use settimeofday() to step the clock? My system runs ptp4l in software timestamping mode.

#ifndef HAVE_CLOCK_ADJTIME
static inline int clock_adjtime(clockid_t id, struct timex *tx)
{
// return syscall(__NR_clock_adjtime, id, tx);
return adjtimex(tx);
}
#endif

The adjtimex() function does not have the clock id parameter. I'm unclear how to deal with it. In my debugging messages, I've only seen CLOCK_REALTIME whose Id is 0 which is the clock that adjtimex() applies to. Is clock_adjtime() executed in some case for other clock id such as CLOCK_MONOTONIC?

Thanks,
Daniel
Keller, Jacob E
2015-06-23 22:16:29 UTC
Permalink
Post by Daniel Le
My Linux kernel version is 2.6.35.7 and it doesn't seem to have the
implementation of syscall for __NR_clock_adjtime. In which kernel
version was it initially introduced?
I changed the function clock_adjtime() to use adjtimex() as shown in
the following. Would that work fine when it's called to perform a
clock step (with the modes ADJ_SETOFFSET bit set) and slewing? Is it
better to use settimeofday() to step the clock? My system runs ptp4l
in software timestamping mode.
#ifndef HAVE_CLOCK_ADJTIME
static inline int clock_adjtime(clockid_t id, struct timex *tx)
{
// return syscall(__NR_clock_adjtime, id, tx);
return adjtimex(tx);
}
#endif
The adjtimex() function does not have the clock id parameter. I'm
unclear how to deal with it. In my debugging messages, I've only seen
CLOCK_REALTIME whose Id is 0 which is the clock that adjtimex()
applies to. Is clock_adjtime() executed in some case for other clock
id such as CLOCK_MONOTONIC?
In hardware timestamping mode it is executed on the PHC clocks exposed
by the PTP infrastructure, which is why clockid is needed. Your kernel
does not (fully?) support the PTP core infrastructure which is the
intended use of ptp4l.

Regards,
Jake
Post by Daniel Le
Thanks,
Daniel
Loading...