Replace T_SECOND etc. by DDS_ equivalents

Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
Erik Boasson 2020-03-09 14:13:59 +01:00 committed by eboasson
parent 763ed67958
commit 1611adc20a
15 changed files with 59 additions and 65 deletions

View file

@ -55,7 +55,7 @@ extern "C" {
"thread_cputime %d.%09d\n", \ "thread_cputime %d.%09d\n", \
(int)(usage.stime / DDS_NSECS_IN_SEC), \ (int)(usage.stime / DDS_NSECS_IN_SEC), \
(int)(usage.stime % DDS_NSECS_IN_SEC)); \ (int)(usage.stime % DDS_NSECS_IN_SEC)); \
(guard).v = tnowlt.v + T_SECOND; \ (guard).v = tnowlt.v + DDS_NSECS_IN_SEC; \
} \ } \
} \ } \
} \ } \

View file

@ -20,10 +20,6 @@
extern "C" { extern "C" {
#endif #endif
#define T_MILLISECOND 1000000ll
#define T_SECOND (1000 * T_MILLISECOND)
#define T_MICROSECOND (T_MILLISECOND/1000)
typedef struct { typedef struct {
int32_t seconds; int32_t seconds;
uint32_t fraction; uint32_t fraction;

View file

@ -2893,7 +2893,7 @@ void ddsi_xqos_init_default_writer (dds_qos_t *xqos)
xqos->present |= QP_RELIABILITY; xqos->present |= QP_RELIABILITY;
xqos->reliability.kind = DDS_RELIABILITY_RELIABLE; xqos->reliability.kind = DDS_RELIABILITY_RELIABLE;
xqos->reliability.max_blocking_time = 100 * T_MILLISECOND; xqos->reliability.max_blocking_time = DDS_MSECS (100);
xqos->present |= QP_OWNERSHIP_STRENGTH; xqos->present |= QP_OWNERSHIP_STRENGTH;
xqos->ownership_strength.value = 0; xqos->ownership_strength.value = 0;
@ -2928,7 +2928,7 @@ void ddsi_xqos_init_default_topic (dds_qos_t *xqos)
xqos->present |= QP_RELIABILITY; xqos->present |= QP_RELIABILITY;
xqos->reliability.kind = DDS_RELIABILITY_BEST_EFFORT; xqos->reliability.kind = DDS_RELIABILITY_BEST_EFFORT;
xqos->reliability.max_blocking_time = 100 * T_MILLISECOND; xqos->reliability.max_blocking_time = DDS_MSECS (100);
xqos->present |= QP_TRANSPORT_PRIORITY; xqos->present |= QP_TRANSPORT_PRIORITY;
xqos->transport_priority.value = 0; xqos->transport_priority.value = 0;

View file

@ -860,12 +860,12 @@ static const struct cfgelem root_cfgelem = {
static const struct unit unittab_duration[] = { static const struct unit unittab_duration[] = {
{ "ns", 1 }, { "ns", 1 },
{ "us", 1000 }, { "us", DDS_USECS (1) },
{ "ms", T_MILLISECOND }, { "ms", DDS_MSECS (1) },
{ "s", T_SECOND }, { "s", DDS_SECS (1) },
{ "min", 60 * T_SECOND }, { "min", DDS_SECS (60) },
{ "hr", 3600 * T_SECOND }, { "hr", DDS_SECS (3600) },
{ "day", 24 * 3600 * T_SECOND }, { "day", DDS_SECS (24 * 3600) },
{ NULL, 0 } { NULL, 0 }
}; };
@ -1919,22 +1919,22 @@ static enum update_result uf_duration_inf (struct cfgst *cfgst, void *parent, st
static enum update_result uf_duration_ms_1hr (struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, UNUSED_ARG (int first), const char *value) static enum update_result uf_duration_ms_1hr (struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, UNUSED_ARG (int first), const char *value)
{ {
return uf_duration_gen (cfgst, parent, cfgelem, value, T_MILLISECOND, 0, 3600 * T_SECOND); return uf_duration_gen (cfgst, parent, cfgelem, value, DDS_MSECS (1), 0, DDS_SECS (3600));
} }
static enum update_result uf_duration_ms_1s (struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, UNUSED_ARG (int first), const char *value) static enum update_result uf_duration_ms_1s (struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, UNUSED_ARG (int first), const char *value)
{ {
return uf_duration_gen (cfgst, parent, cfgelem, value, T_MILLISECOND, 0, T_SECOND); return uf_duration_gen (cfgst, parent, cfgelem, value, DDS_MSECS (1), 0, DDS_SECS (1));
} }
static enum update_result uf_duration_us_1s (struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, UNUSED_ARG (int first), const char *value) static enum update_result uf_duration_us_1s (struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, UNUSED_ARG (int first), const char *value)
{ {
return uf_duration_gen (cfgst, parent, cfgelem, value, 1000, 0, T_SECOND); return uf_duration_gen (cfgst, parent, cfgelem, value, DDS_USECS (1), 0, DDS_SECS (1));
} }
static enum update_result uf_duration_100ms_1hr (struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, UNUSED_ARG (int first), const char *value) static enum update_result uf_duration_100ms_1hr (struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, UNUSED_ARG (int first), const char *value)
{ {
return uf_duration_gen (cfgst, parent, cfgelem, value, 0, 100 * T_MILLISECOND, 3600 * T_SECOND); return uf_duration_gen (cfgst, parent, cfgelem, value, 0, DDS_MSECS (100), DDS_SECS (3600));
} }
static void pf_duration (struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, uint32_t sources) static void pf_duration (struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, uint32_t sources)
@ -2578,7 +2578,7 @@ static int set_default_channel (struct config *cfg)
c->next = NULL; c->next = NULL;
c->name = ddsrt_strdup ("user"); c->name = ddsrt_strdup ("user");
c->priority = 0; c->priority = 0;
c->resolution = 1 * T_MILLISECOND; c->resolution = DDS_MSECS (1);
#ifdef DDSI_INCLUDE_BANDWIDTH_LIMITING #ifdef DDSI_INCLUDE_BANDWIDTH_LIMITING
c->data_bandwidth_limit = 0; c->data_bandwidth_limit = 0;
c->auxiliary_bandwidth_limit = 0; c->auxiliary_bandwidth_limit = 0;

View file

@ -628,7 +628,7 @@ static int handle_SPDP_alive (const struct receiver_state *rst, seqno_t seq, nn_
else else
{ {
GVLOGDISC (" (PARTICIPANT_LEASE_DURATION defaulting to 100s)"); GVLOGDISC (" (PARTICIPANT_LEASE_DURATION defaulting to 100s)");
lease_duration = 100 * T_SECOND; lease_duration = DDS_SECS (100);
} }
if (datap->present & PP_PRISMTECH_PARTICIPANT_VERSION_INFO) { if (datap->present & PP_PRISMTECH_PARTICIPANT_VERSION_INFO) {

View file

@ -806,7 +806,7 @@ dds_return_t new_participant_guid (const ddsi_guid_t *ppguid, struct ddsi_domain
fire before the calls return. If the initial sample wasn't fire before the calls return. If the initial sample wasn't
accepted, all is lost, but we continue nonetheless, even though accepted, all is lost, but we continue nonetheless, even though
the participant won't be able to discover or be discovered. */ the participant won't be able to discover or be discovered. */
pp->spdp_xevent = qxev_spdp (gv->xevents, add_duration_to_mtime (now_mt (), 100 * T_MILLISECOND), &pp->e.guid, NULL); pp->spdp_xevent = qxev_spdp (gv->xevents, add_duration_to_mtime (now_mt (), DDS_MSECS (100)), &pp->e.guid, NULL);
} }
{ {
@ -1908,7 +1908,7 @@ static void writer_add_connection (struct writer *wr, struct proxy_reader *prd)
ensure a heartbeat is scheduled soon. */ ensure a heartbeat is scheduled soon. */
if (wr->heartbeat_xevent) if (wr->heartbeat_xevent)
{ {
const int64_t delta = 1 * T_MILLISECOND; const int64_t delta = DDS_MSECS (1);
const nn_mtime_t tnext = add_duration_to_mtime (now_mt (), delta); const nn_mtime_t tnext = add_duration_to_mtime (now_mt (), delta);
ddsrt_mutex_lock (&wr->e.lock); ddsrt_mutex_lock (&wr->e.lock);
/* To make sure that we keep sending heartbeats at a higher rate /* To make sure that we keep sending heartbeats at a higher rate
@ -2185,11 +2185,10 @@ static void proxy_writer_add_connection (struct proxy_writer *pwr, struct reader
} }
m->count = init_count; m->count = init_count;
/* Spec says we may send a pre-emptive AckNack (8.4.2.3.4), hence we /* Spec says we may send a pre-emptive AckNack (8.4.2.3.4), hence we
schedule it for the configured delay * T_MILLISECOND. From then schedule it for the configured delay. From then on it it'll keep
on it it'll keep sending pre-emptive ones until the proxy writer sending pre-emptive ones until the proxy writer receives a heartbeat.
receives a heartbeat. (We really only need a pre-emptive AckNack (We really only need a pre-emptive AckNack per proxy writer, but
per proxy writer, but hopefully it won't make that much of a hopefully it won't make that much of a difference in practice.) */
difference in practice.) */
if (rd->reliable) if (rd->reliable)
{ {
m->acknack_xevent = qxev_acknack (pwr->evq, add_duration_to_mtime (tnow, pwr->e.gv->config.preemptive_ack_delay), &pwr->e.guid, &rd->e.guid); m->acknack_xevent = qxev_acknack (pwr->evq, add_duration_to_mtime (tnow, pwr->e.gv->config.preemptive_ack_delay), &pwr->e.guid, &rd->e.guid);

View file

@ -91,8 +91,8 @@ static uint32_t gcreq_queue_thread (struct gcreq_queue *q)
struct thread_state1 * const ts1 = lookup_thread_state (); struct thread_state1 * const ts1 = lookup_thread_state ();
nn_mtime_t next_thread_cputime = { 0 }; nn_mtime_t next_thread_cputime = { 0 };
nn_mtime_t t_trigger_recv_threads = { 0 }; nn_mtime_t t_trigger_recv_threads = { 0 };
int64_t shortsleep = 1 * T_MILLISECOND; int64_t shortsleep = DDS_MSECS (1);
int64_t delay = T_MILLISECOND; /* force evaluation after startup */ int64_t delay = DDS_MSECS (1); /* force evaluation after startup */
struct gcreq *gcreq = NULL; struct gcreq *gcreq = NULL;
int trace_shortsleep = 1; int trace_shortsleep = 1;
ddsrt_mutex_lock (&q->lock); ddsrt_mutex_lock (&q->lock);

View file

@ -130,7 +130,7 @@ static void make_builtin_endpoint_xqos (dds_qos_t *q, const dds_qos_t *template)
{ {
ddsi_xqos_copy (q, template); ddsi_xqos_copy (q, template);
q->reliability.kind = DDS_RELIABILITY_RELIABLE; q->reliability.kind = DDS_RELIABILITY_RELIABLE;
q->reliability.max_blocking_time = 100 * T_MILLISECOND; q->reliability.max_blocking_time = DDS_MSECS (100);
q->durability.kind = DDS_DURABILITY_TRANSIENT_LOCAL; q->durability.kind = DDS_DURABILITY_TRANSIENT_LOCAL;
} }
@ -734,7 +734,7 @@ static void wait_for_receive_threads_helper (struct xevent *xev, void *varg, nn_
if (arg->count++ == arg->gv->config.recv_thread_stop_maxretries) if (arg->count++ == arg->gv->config.recv_thread_stop_maxretries)
abort (); abort ();
trigger_recv_threads (arg->gv); trigger_recv_threads (arg->gv);
(void) resched_xevent_if_earlier (xev, add_duration_to_mtime (tnow, T_SECOND)); (void) resched_xevent_if_earlier (xev, add_duration_to_mtime (tnow, DDS_SECS (1)));
} }
static void wait_for_receive_threads (struct ddsi_domaingv *gv) static void wait_for_receive_threads (struct ddsi_domaingv *gv)
@ -743,7 +743,7 @@ static void wait_for_receive_threads (struct ddsi_domaingv *gv)
struct wait_for_receive_threads_helper_arg cbarg; struct wait_for_receive_threads_helper_arg cbarg;
cbarg.gv = gv; cbarg.gv = gv;
cbarg.count = 0; cbarg.count = 0;
if ((trigev = qxev_callback (gv->xevents, add_duration_to_mtime (now_mt (), T_SECOND), wait_for_receive_threads_helper, &cbarg)) == NULL) if ((trigev = qxev_callback (gv->xevents, add_duration_to_mtime (now_mt (), DDS_SECS (1)), wait_for_receive_threads_helper, &cbarg)) == NULL)
{ {
/* retrying is to deal a packet geting lost because the socket buffer is full or because the /* retrying is to deal a packet geting lost because the socket buffer is full or because the
macOS firewall (and perhaps others) likes to ask if the process is allowed to receive data, macOS firewall (and perhaps others) likes to ask if the process is allowed to receive data,

View file

@ -273,7 +273,7 @@ int64_t check_and_handle_lease_expiration (struct ddsi_domaingv *gv, nn_etime_t
entidx_lookup_proxy_participant_guid (gv->entity_index, &proxypp->privileged_pp_guid) != NULL) entidx_lookup_proxy_participant_guid (gv->entity_index, &proxypp->privileged_pp_guid) != NULL)
{ {
GVLOGDISC ("but postponing because privileged pp "PGUIDFMT" is still live\n", PGUID (proxypp->privileged_pp_guid)); GVLOGDISC ("but postponing because privileged pp "PGUIDFMT" is still live\n", PGUID (proxypp->privileged_pp_guid));
l->tsched = add_duration_to_etime (tnowE, 200 * T_MILLISECOND); l->tsched = add_duration_to_etime (tnowE, DDS_MSECS (200));
ddsrt_fibheap_insert (&lease_fhdef, &gv->leaseheap, l); ddsrt_fibheap_insert (&lease_fhdef, &gv->leaseheap, l);
continue; continue;
} }

View file

@ -603,7 +603,7 @@ static int accept_ack_or_hb_w_timeout (nn_count_t new_count, nn_count_t *exp_cou
This combined procedure should give the best of all worlds, and This combined procedure should give the best of all worlds, and
is not more expensive in the common case. */ is not more expensive in the common case. */
const int64_t timeout = 2 * T_SECOND; const int64_t timeout = DDS_SECS (2);
if (new_count < *exp_count && tnow.v - t_last_accepted->v < timeout && !force_accept) if (new_count < *exp_count && tnow.v - t_last_accepted->v < timeout && !force_accept)
return 0; return 0;
@ -714,7 +714,7 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac
{ {
nn_wctime_t tstamp_now = now (); nn_wctime_t tstamp_now = now ();
nn_lat_estim_update (&rn->hb_to_ack_latency, tstamp_now.v - timestamp.v); nn_lat_estim_update (&rn->hb_to_ack_latency, tstamp_now.v - timestamp.v);
if ((rst->gv->logconfig.c.mask & DDS_LC_TRACE) && tstamp_now.v > rn->hb_to_ack_latency_tlastlog.v + 10 * T_SECOND) if ((rst->gv->logconfig.c.mask & DDS_LC_TRACE) && tstamp_now.v > rn->hb_to_ack_latency_tlastlog.v + DDS_SECS (10))
{ {
nn_lat_estim_log (DDS_LC_TRACE, &rst->gv->logconfig, NULL, &rn->hb_to_ack_latency); nn_lat_estim_log (DDS_LC_TRACE, &rst->gv->logconfig, NULL, &rn->hb_to_ack_latency);
rn->hb_to_ack_latency_tlastlog = tstamp_now; rn->hb_to_ack_latency_tlastlog = tstamp_now;

View file

@ -49,8 +49,8 @@ nn_etime_t now_et (void)
static void time_to_sec_usec (int32_t * __restrict sec, int32_t * __restrict usec, int64_t t) static void time_to_sec_usec (int32_t * __restrict sec, int32_t * __restrict usec, int64_t t)
{ {
*sec = (int32_t) (t / T_SECOND); *sec = (int32_t) (t / DDS_NSECS_IN_SEC);
*usec = (int32_t) (t % T_SECOND) / 1000; *usec = (int32_t) (t % DDS_NSECS_IN_SEC) / 1000;
} }
void mtime_to_sec_usec (int32_t * __restrict sec, int32_t * __restrict usec, nn_mtime_t t) void mtime_to_sec_usec (int32_t * __restrict sec, int32_t * __restrict usec, nn_mtime_t t)
@ -142,9 +142,9 @@ static ddsi_time_t nn_to_ddsi_time (int64_t t)
because that would break backwards compatibility, but round-to-nearest because that would break backwards compatibility, but round-to-nearest
of the inverse is correctly rounded anyway, so it shouldn't ever matter. */ of the inverse is correctly rounded anyway, so it shouldn't ever matter. */
ddsi_time_t x; ddsi_time_t x;
int ns = (int) (t % T_SECOND); int ns = (int) (t % DDS_NSECS_IN_SEC);
x.seconds = (int) (t / T_SECOND); x.seconds = (int) (t / DDS_NSECS_IN_SEC);
x.fraction = (unsigned) (((T_SECOND-1) + ((int64_t) ns << 32)) / T_SECOND); x.fraction = (unsigned) (((DDS_NSECS_IN_SEC-1) + ((int64_t) ns << 32)) / DDS_NSECS_IN_SEC);
return x; return x;
} }
} }
@ -161,8 +161,8 @@ static int64_t nn_from_ddsi_time (ddsi_time_t x)
else else
{ {
/* Round-to-nearest conversion of DDSI time fraction to nanoseconds */ /* Round-to-nearest conversion of DDSI time fraction to nanoseconds */
int ns = (int) (((int64_t) 2147483648u + (int64_t) x.fraction * T_SECOND) >> 32); int ns = (int) (((int64_t) 2147483648u + (int64_t) x.fraction * DDS_NSECS_IN_SEC) >> 32);
return x.seconds * (int64_t) T_SECOND + ns; return x.seconds * DDS_NSECS_IN_SEC + ns;
} }
} }

View file

@ -1072,7 +1072,7 @@ static int maybe_grow_whc (struct writer *wr)
if (!wr->retransmitting && gv->config.whc_adaptive && wr->whc_high < gv->config.whc_highwater_mark) if (!wr->retransmitting && gv->config.whc_adaptive && wr->whc_high < gv->config.whc_highwater_mark)
{ {
nn_etime_t tnow = now_et(); nn_etime_t tnow = now_et();
nn_etime_t tgrow = add_duration_to_etime (wr->t_whc_high_upd, 10 * T_MILLISECOND); nn_etime_t tgrow = add_duration_to_etime (wr->t_whc_high_upd, DDS_MSECS (10));
if (tnow.v >= tgrow.v) if (tnow.v >= tgrow.v)
{ {
uint32_t m = (gv->config.whc_highwater_mark - wr->whc_high) / 32; uint32_t m = (gv->config.whc_highwater_mark - wr->whc_high) / 32;

View file

@ -913,12 +913,12 @@ static void handle_xevk_acknack (UNUSED_ARG (struct nn_xpack *xp), struct xevent
msg = NULL; msg = NULL;
} }
if (!pwr->have_seen_heartbeat && tnow.v - rwn->tcreate.v <= 300 * T_SECOND) if (!pwr->have_seen_heartbeat && tnow.v - rwn->tcreate.v <= DDS_SECS (300))
{ {
/* Force pre-emptive AckNacks out until we receive a heartbeat, /* Force pre-emptive AckNacks out until we receive a heartbeat,
but let the frequency drop over time and stop after a couple but let the frequency drop over time and stop after a couple
of minutes. */ of minutes. */
int intv, age = (int) ((tnow.v - rwn->tcreate.v) / T_SECOND + 1); int intv, age = (int) ((tnow.v - rwn->tcreate.v) / DDS_NSECS_IN_SEC + 1);
if (age <= 10) if (age <= 10)
intv = 1; intv = 1;
else if (age <= 60) else if (age <= 60)
@ -927,7 +927,7 @@ static void handle_xevk_acknack (UNUSED_ARG (struct nn_xpack *xp), struct xevent
intv = 5; intv = 5;
else else
intv = 10; intv = 10;
(void) resched_xevent_if_earlier (ev, add_duration_to_mtime (tnow, intv * T_SECOND)); (void) resched_xevent_if_earlier (ev, add_duration_to_mtime (tnow, intv * DDS_NSECS_IN_SEC));
} }
ddsrt_mutex_unlock (&pwr->e.lock); ddsrt_mutex_unlock (&pwr->e.lock);
@ -940,7 +940,7 @@ static void handle_xevk_acknack (UNUSED_ARG (struct nn_xpack *xp), struct xevent
outofmem: outofmem:
/* What to do if out of memory? Crash or burn? */ /* What to do if out of memory? Crash or burn? */
ddsrt_mutex_unlock (&pwr->e.lock); ddsrt_mutex_unlock (&pwr->e.lock);
(void) resched_xevent_if_earlier (ev, add_duration_to_mtime (tnow, 100 * T_MILLISECOND)); (void) resched_xevent_if_earlier (ev, add_duration_to_mtime (tnow, DDS_MSECS (100)));
} }
static bool resend_spdp_sample_by_guid_key (struct writer *wr, const ddsi_guid_t *guid, struct proxy_reader *prd) static bool resend_spdp_sample_by_guid_key (struct writer *wr, const ddsi_guid_t *guid, struct proxy_reader *prd)
@ -1056,11 +1056,11 @@ static void handle_xevk_spdp (UNUSED_ARG (struct nn_xpack *xp), struct xevent *e
{ {
/* Directed events are used to send SPDP packets to newly /* Directed events are used to send SPDP packets to newly
discovered peers, and used just once. */ discovered peers, and used just once. */
if (--ev->u.spdp.directed == 0 || gv->config.spdp_interval < T_SECOND || pp->lease_duration < T_SECOND) if (--ev->u.spdp.directed == 0 || gv->config.spdp_interval < DDS_SECS (1) || pp->lease_duration < DDS_SECS (1))
delete_xevent (ev); delete_xevent (ev);
else else
{ {
nn_mtime_t tnext = add_duration_to_mtime (tnow, T_SECOND); nn_mtime_t tnext = add_duration_to_mtime (tnow, DDS_SECS (1));
GVTRACE ("xmit spdp "PGUIDFMT" to %"PRIx32":%"PRIx32":%"PRIx32":%x (resched %gs)\n", GVTRACE ("xmit spdp "PGUIDFMT" to %"PRIx32":%"PRIx32":%"PRIx32":%x (resched %gs)\n",
PGUID (pp->e.guid), PGUID (pp->e.guid),
PGUIDPREFIX (ev->u.spdp.dest_proxypp_guid_prefix), NN_ENTITYID_SPDP_BUILTIN_PARTICIPANT_READER, PGUIDPREFIX (ev->u.spdp.dest_proxypp_guid_prefix), NN_ENTITYID_SPDP_BUILTIN_PARTICIPANT_READER,
@ -1073,17 +1073,17 @@ static void handle_xevk_spdp (UNUSED_ARG (struct nn_xpack *xp), struct xevent *e
/* schedule next when 80% of the interval has elapsed, or 2s /* schedule next when 80% of the interval has elapsed, or 2s
before the lease ends, whichever comes first (similar to PMD), before the lease ends, whichever comes first (similar to PMD),
but never wait longer than spdp_interval */ but never wait longer than spdp_interval */
const dds_duration_t mindelta = 10 * T_MILLISECOND; const dds_duration_t mindelta = DDS_MSECS (10);
const dds_duration_t ldur = pp->lease_duration; const dds_duration_t ldur = pp->lease_duration;
nn_mtime_t tnext; nn_mtime_t tnext;
int64_t intv; int64_t intv;
if (ldur < 5 * mindelta / 4) if (ldur < 5 * mindelta / 4)
intv = mindelta; intv = mindelta;
else if (ldur < 10 * T_SECOND) else if (ldur < DDS_SECS (10))
intv = 4 * ldur / 5; intv = 4 * ldur / 5;
else else
intv = ldur - 2 * T_SECOND; intv = ldur - DDS_SECS (2);
if (intv > gv->config.spdp_interval) if (intv > gv->config.spdp_interval)
intv = gv->config.spdp_interval; intv = gv->config.spdp_interval;
@ -1120,8 +1120,8 @@ static void handle_xevk_pmd_update (struct thread_state1 * const ts1, struct nn_
{ {
/* schedule next when 80% of the interval has elapsed, or 2s /* schedule next when 80% of the interval has elapsed, or 2s
before the lease ends, whichever comes first */ before the lease ends, whichever comes first */
if (intv >= 10 * T_SECOND) if (intv >= DDS_SECS (10))
tnext.v = tnow.v + intv - 2 * T_SECOND; tnext.v = tnow.v + intv - DDS_SECS (2);
else else
tnext.v = tnow.v + 4 * intv / 5; tnext.v = tnow.v + 4 * intv / 5;
GVTRACE ("resched pmd("PGUIDFMT"): %gs\n", PGUID (pp->e.guid), (double)(tnext.v - tnow.v) / 1e9); GVTRACE ("resched pmd("PGUIDFMT"): %gs\n", PGUID (pp->e.guid), (double)(tnext.v - tnow.v) / 1e9);

View file

@ -885,8 +885,8 @@ static void nn_xmsg_chain_add (struct nn_xmsg_chain *chain, struct nn_xmsg *m)
* If data is send too fast, a sleep is inserted to get the used bandwidth at the configured rate. * If data is send too fast, a sleep is inserted to get the used bandwidth at the configured rate.
*/ */
#define NN_BW_LIMIT_MAX_BUFFER (-30 * T_MILLISECOND) #define NN_BW_LIMIT_MAX_BUFFER (DDS_MSECS (-30))
#define NN_BW_LIMIT_MIN_SLEEP (2 * T_MILLISECOND) #define NN_BW_LIMIT_MIN_SLEEP (DDS_MSECS (2))
static void nn_bw_limit_sleep_if_needed (struct ddsi_domaingv const * const gv, struct nn_bw_limiter *this, ssize_t size) static void nn_bw_limit_sleep_if_needed (struct ddsi_domaingv const * const gv, struct nn_bw_limiter *this, ssize_t size)
{ {
if ( this->bandwidth > 0 ) { if ( this->bandwidth > 0 ) {
@ -898,7 +898,7 @@ static void nn_bw_limit_sleep_if_needed (struct ddsi_domaingv const * const gv,
actual_interval = tnow.v - this->last_update.v; actual_interval = tnow.v - this->last_update.v;
this->last_update = tnow; this->last_update = tnow;
target_interval = T_SECOND*size/this->bandwidth; target_interval = DDS_NSECS_IN_SEC*size/this->bandwidth;
this->balance += (target_interval - actual_interval); this->balance += (target_interval - actual_interval);

View file

@ -77,7 +77,6 @@ static enum tgprint_mode printmode = TGPM_FIELDS;
static unsigned print_metadata = PM_STATE; static unsigned print_metadata = PM_STATE;
static int printtype = 0; static int printtype = 0;
#define T_SECOND ((int64_t) 1000000000)
struct tstamp_t { struct tstamp_t {
int isabs; int isabs;
int64_t t; int64_t t;
@ -351,7 +350,7 @@ static int read_int_w_tstamp(struct tstamp_t *tstamp, char *buf, int bufsize, in
posoff = 1; posoff = 1;
} }
if (read_int(buf, bufsize, pos + posoff, 1)) if (read_int(buf, bufsize, pos + posoff, 1))
tstamp->t = atoi(buf + pos) * T_SECOND; tstamp->t = atoi(buf + pos) * DDS_NSECS_IN_SEC;
else else
return 0; return 0;
while ((c = getc(stdin)) != EOF && isspace((unsigned char) c)) while ((c = getc(stdin)) != EOF && isspace((unsigned char) c))
@ -1256,7 +1255,7 @@ static char *pub_do_nonarb(const struct writerspec *spec, uint32_t *seq) {
tstamp = dds_time(); tstamp = dds_time();
tstamp_spec.t += tstamp; tstamp_spec.t += tstamp;
} }
tstamp = (tstamp_spec.t % T_SECOND) + ((int) (tstamp_spec.t / T_SECOND) * DDS_NSECS_IN_SEC); tstamp = (tstamp_spec.t % DDS_NSECS_IN_SEC) + ((int) (tstamp_spec.t / DDS_NSECS_IN_SEC) * DDS_NSECS_IN_SEC);
if ((result = fn(spec->wr, &d, tstamp)) != DDS_RETCODE_OK) { if ((result = fn(spec->wr, &d, tstamp)) != DDS_RETCODE_OK) {
printf ("%s %d: error %d (%s)\n", get_write_operstr(command), k, (int) result, dds_err_str(result)); printf ("%s %d: error %d (%s)\n", get_write_operstr(command), k, (int) result, dds_err_str(result));
if (flushflag) { if (flushflag) {
@ -1360,7 +1359,7 @@ static char *pub_do_nonarb(const struct writerspec *spec, uint32_t *seq) {
// command = *line++; // command = *line++;
// if (*line == '@') { // if (*line == '@') {
// if (*++line == '=') { ++line; tstamp_spec.isabs = 1; } // if (*++line == '=') { ++line; tstamp_spec.isabs = 1; }
// tstamp_spec.t = T_SECOND * strtol(line, (char **) &line, 10); // tstamp_spec.t = DDS_NSECS_IN_SEC * strtol(line, (char **) &line, 10);
// } // }
// case '{': { // case '{': {
// write_oper_t fn = get_write_oper(command); // write_oper_t fn = get_write_oper(command);
@ -1373,10 +1372,10 @@ static char *pub_do_nonarb(const struct writerspec *spec, uint32_t *seq) {
// int diddodup = 0; // int diddodup = 0;
// if (!tstamp_spec.isabs) { // if (!tstamp_spec.isabs) {
// DDS_DomainParticipant_get_current_time(dp, &tstamp); // DDS_DomainParticipant_get_current_time(dp, &tstamp);
// tstamp_spec.t += tstamp.sec * T_SECOND + tstamp.nanosec; // tstamp_spec.t += tstamp.sec * DDS_NSECS_IN_SEC + tstamp.nanosec;
// } // }
// tstamp.sec = (int) (tstamp_spec.t / T_SECOND); // tstamp.sec = (int) (tstamp_spec.t / DDS_NSECS_IN_SEC);
// tstamp.nanosec = (unsigned) (tstamp_spec.t % T_SECOND); // tstamp.nanosec = (unsigned) (tstamp_spec.t % DDS_NSECS_IN_SEC);
// line = endp; // line = endp;
// result = fn(spec->wr, arb, DDS_HANDLE_NIL, &tstamp); // result = fn(spec->wr, arb, DDS_HANDLE_NIL, &tstamp);
// if (result == DDS_RETCODE_OK && spec->dupwr) { // if (result == DDS_RETCODE_OK && spec->dupwr) {
@ -2684,8 +2683,8 @@ int main(int argc, char *argv[]) {
// } // }
// tnow = dds_time(); // tnow = dds_time();
// if (m != 0 && tnow < tend) { // if (m != 0 && tnow < tend) {
// uint64_t tdelta = (tend-tnow) < T_SECOND/10 ? tend-tnow : T_SECOND/10; // uint64_t tdelta = (tend-tnow) < DDS_NSECS_IN_SEC/10 ? tend-tnow : DDS_NSECS_IN_SEC/10;
// os_time delay = { (os_timeSec) (tdelta / T_SECOND), (os_int32) (tdelta % T_SECOND)}; // os_time delay = { (os_timeSec) (tdelta / DDS_NSECS_IN_SEC), (os_int32) (tdelta % DDS_NSECS_IN_SEC)};
// os_nanoSleep(delay); // os_nanoSleep(delay);
// tnow = dds_time(); // tnow = dds_time();
// } // }