Commit d395932e authored by Alessandro Rubini's avatar Alessandro Rubini

time: fix bare ports

Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>

Conflicts:
	time-bare/bare-socket.c
parent f0fe7442
......@@ -12,7 +12,7 @@
/* FIXME: which socket we receive and send with? */
static int bare_net_recv(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t)
struct pp_time *t)
{
int ret;
if (t)
......@@ -28,7 +28,7 @@ static int bare_net_send(struct pp_instance *ppi, void *pkt, int len,
int msgtype)
{
struct bare_ethhdr *hdr = pkt;
TimeInternal *t = &ppi->last_snt_time;
struct pp_time *t = &ppi->last_snt_time;
static const uint8_t macaddr[2][ETH_ALEN] = {
[PP_E2E_MECH] = PP_MCAST_MACADDRESS,
[PP_P2P_MECH] = PP_PDELAY_MACADDRESS,
......
......@@ -8,7 +8,7 @@
#include <ppsi/ppsi.h>
#include "bare-linux.h"
static int bare_time_get(struct pp_instance *ppi, TimeInternal *t)
static int bare_time_get(struct pp_instance *ppi, struct pp_time *t)
{
struct bare_timeval tv;
......@@ -17,15 +17,15 @@ static int bare_time_get(struct pp_instance *ppi, TimeInternal *t)
sys_exit(1);
}
/* TAI = UTC + 35 */
t->seconds = tv.tv_sec + DSPRO(ppi)->currentUtcOffset;
t->nanoseconds = tv.tv_usec * 1000;
t->secs = tv.tv_sec + DSPRO(ppi)->currentUtcOffset;
t->scaled_nsecs = (tv.tv_usec * 1000LL) << 16;
if (!(pp_global_d_flags & PP_FLAG_NOTIMELOG))
pp_diag(ppi, time, 2, "%s: %9li.%06li\n", __func__,
tv.tv_sec, tv.tv_usec);
return 0;
}
static int bare_time_set(struct pp_instance *ppi, TimeInternal *t)
static int bare_time_set(struct pp_instance *ppi, const struct pp_time *t)
{
struct bare_timeval tv;
......@@ -43,8 +43,8 @@ static int bare_time_set(struct pp_instance *ppi, TimeInternal *t)
}
/* UTC = TAI - 35 */
tv.tv_sec = t->seconds - DSPRO(ppi)->currentUtcOffset;
tv.tv_usec = t->nanoseconds / 1000;
tv.tv_sec = t->secs - DSPRO(ppi)->currentUtcOffset;
tv.tv_usec = (int)(t->scaled_nsecs >> 16) / 1000;
if (sys_settimeofday(&tv, NULL) < 0) {
pp_error("%s:", __func__);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment