Commit 1dae227b authored by Alessandro Rubini's avatar Alessandro Rubini

time-wrs: declare your functions (unix one are back static)

We need to make WR-specific things while managing the time
and network operations (even if proto-ext-whiterabbit does most
of the stuff without calling the time operations).

Thus, open-code the wrs operation, even if temporary they
just call the unix ones (which, however, are static to their
own files, and only the overall data structure is exported).
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 5534c8fb
...@@ -27,7 +27,7 @@ include time-$(TIME)/Makefile ...@@ -27,7 +27,7 @@ include time-$(TIME)/Makefile
# Unix time operations are always included as a fallback # Unix time operations are always included as a fallback
include time-unix/Makefile include time-unix/Makefile
CFLAGS += -Itime-unix -Iproto-ext-whiterabbit CFLAGS += -Iproto-ext-whiterabbit
# mini-rpc directory contains minipc library # mini-rpc directory contains minipc library
MINIPC_DIR := $A/mini-rpc MINIPC_DIR := $A/mini-rpc
......
...@@ -16,7 +16,7 @@ static void clock_fatal_error(char *context) ...@@ -16,7 +16,7 @@ static void clock_fatal_error(char *context)
exit(1); exit(1);
} }
int unix_time_get(struct pp_instance *ppi, TimeInternal *t) static int unix_time_get(struct pp_instance *ppi, TimeInternal *t)
{ {
struct timespec tp; struct timespec tp;
if (clock_gettime(CLOCK_REALTIME, &tp) < 0) if (clock_gettime(CLOCK_REALTIME, &tp) < 0)
...@@ -29,7 +29,7 @@ int unix_time_get(struct pp_instance *ppi, TimeInternal *t) ...@@ -29,7 +29,7 @@ int unix_time_get(struct pp_instance *ppi, TimeInternal *t)
return 0; return 0;
} }
int32_t unix_time_set(struct pp_instance *ppi, TimeInternal *t) static int32_t unix_time_set(struct pp_instance *ppi, TimeInternal *t)
{ {
struct timespec tp; struct timespec tp;
...@@ -42,7 +42,7 @@ int32_t unix_time_set(struct pp_instance *ppi, TimeInternal *t) ...@@ -42,7 +42,7 @@ int32_t unix_time_set(struct pp_instance *ppi, TimeInternal *t)
return 0; return 0;
} }
int unix_time_adjust(struct pp_instance *ppi, long offset_ns, long freq_ppm) static int unix_time_adjust(struct pp_instance *ppi, long offset_ns, long freq_ppm)
{ {
struct timex t; struct timex t;
int ret; int ret;
...@@ -69,17 +69,17 @@ int unix_time_adjust(struct pp_instance *ppi, long offset_ns, long freq_ppm) ...@@ -69,17 +69,17 @@ int unix_time_adjust(struct pp_instance *ppi, long offset_ns, long freq_ppm)
return ret; return ret;
} }
int unix_time_adjust_offset(struct pp_instance *ppi, long offset_ns) static int unix_time_adjust_offset(struct pp_instance *ppi, long offset_ns)
{ {
return unix_time_adjust(ppi, offset_ns, 0); return unix_time_adjust(ppi, offset_ns, 0);
} }
int unix_time_adjust_freq(struct pp_instance *ppi, long freq_ppm) static int unix_time_adjust_freq(struct pp_instance *ppi, long freq_ppm)
{ {
return unix_time_adjust(ppi, 0, freq_ppm); return unix_time_adjust(ppi, 0, freq_ppm);
} }
unsigned long unix_calc_timeout(struct pp_instance *ppi, int millisec) static unsigned long unix_calc_timeout(struct pp_instance *ppi, int millisec)
{ {
struct timespec now; struct timespec now;
uint64_t now_ms; uint64_t now_ms;
......
/*
* Aurelio Colosimo for CERN, 2013 -- public domain
*/
/* Defined in unix-socket.c */
int unix_net_init(struct pp_instance *ppi);
int unix_net_exit(struct pp_instance *ppi);
int unix_net_recv(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t);
int unix_net_send(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t, int chtype, int use_pdelay_addr);
/* Defined in unix-time.c */
int unix_time_get(struct pp_instance *ppi, TimeInternal *t);
int32_t unix_time_set(struct pp_instance *ppi, TimeInternal *t);
int unix_time_adjust(struct pp_instance *ppi, long offset_ns,
long freq_ppm);
int unix_time_adjust_offset(struct pp_instance *ppi, long offset_ns);
int unix_time_adjust_freq(struct pp_instance *ppi, long freq_ppm);
unsigned long unix_calc_timeout(struct pp_instance *ppi,
int millisec);
...@@ -3,11 +3,36 @@ ...@@ -3,11 +3,36 @@
*/ */
#include <ppsi/ppsi.h> #include <ppsi/ppsi.h>
#include <unix-time.h>
static int wrs_net_init(struct pp_instance *ppi)
{
/* FIXME */
return unix_net_ops.init(ppi);
}
static int wrs_net_exit(struct pp_instance *ppi)
{
/* FIXME */
return unix_net_ops.exit(ppi);
}
static int wrs_net_recv(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t)
{
/* FIXME */
return unix_net_ops.recv(ppi, pkt, len, t);
}
static int wrs_net_send(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t, int chtype, int use_pdelay_addr)
{
/* FIXME */
return unix_net_ops.send(ppi, pkt, len, t, chtype, use_pdelay_addr);
}
struct pp_network_operations wrs_net_ops = { struct pp_network_operations wrs_net_ops = {
.init = unix_net_init, .init = wrs_net_init,
.exit = unix_net_exit, .exit = wrs_net_exit,
.recv = unix_net_recv, .recv = wrs_net_recv,
.send = unix_net_send, .send = wrs_net_send,
}; };
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
*/ */
#include <ppsi/ppsi.h> #include <ppsi/ppsi.h>
#include <unix-time.h>
#include <ppsi-wrs.h> #include <ppsi-wrs.h>
#include <hal_exports.h> #include <hal_exports.h>
...@@ -154,11 +153,52 @@ int wr_adjust_counters(int64_t adjust_sec, int32_t adjust_nsec) ...@@ -154,11 +153,52 @@ int wr_adjust_counters(int64_t adjust_sec, int32_t adjust_nsec)
int wr_adjust_phase(int32_t phase_ps) int wr_adjust_phase(int32_t phase_ps)
__attribute__((alias("wrs_adjust_phase"))); __attribute__((alias("wrs_adjust_phase")));
/*
* WRS time operations fall back on unix time operations, for some things
*/
static int wrs_time_get(struct pp_instance *ppi, TimeInternal *t)
{
/* FIXME */
return unix_time_ops.get(ppi, t);
}
static int32_t wrs_time_set(struct pp_instance *ppi, TimeInternal *t)
{
/* FIXME */
return unix_time_ops.set(ppi, t);
}
static int wrs_time_adjust(struct pp_instance *ppi, long offset_ns,
long freq_ppm)
{
/* FIXME */
return unix_time_ops.adjust(ppi, offset_ns, freq_ppm);
}
static int wrs_time_adjust_offset(struct pp_instance *ppi, long offset_ns)
{
/* FIXME */
return unix_time_ops.adjust_offset(ppi, offset_ns);
}
static int wrs_time_adjust_freq(struct pp_instance *ppi, long freq_ppm)
{
/* FIXME */
return unix_time_ops.adjust_freq(ppi, freq_ppm);
}
static unsigned long wrs_calc_timeout(struct pp_instance *ppi,
int millisec)
{
return unix_time_ops.calc_timeout(ppi, millisec);
}
struct pp_time_operations wrs_time_ops = { struct pp_time_operations wrs_time_ops = {
.get = unix_time_get, .get = wrs_time_get,
.set = unix_time_set, .set = wrs_time_set,
.adjust = unix_time_adjust, .adjust = wrs_time_adjust,
.adjust_offset = unix_time_adjust_offset, .adjust_offset = wrs_time_adjust_offset,
.adjust_freq = unix_time_adjust_freq, .adjust_freq = wrs_time_adjust_freq,
.calc_timeout = unix_calc_timeout, .calc_timeout = wrs_calc_timeout,
}; };
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