[Git][NTPsec/ntpsec][master] vint64 -> time64_t. No logic changes.
Eric S. Raymond
gitlab at mg.gitlab.com
Mon Dec 12 20:39:20 UTC 2016
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
7ed3b296 by Eric S. Raymond at 2016-12-12T15:35:37-05:00
vint64 -> time64_t. No logic changes.
- - - - -
13 changed files:
- devel/tour.txt
- include/ntp_calendar.h
- include/ntp_types.h
- include/timespecops.h
- libntp/clocktime.c
- libntp/ntp_calendar.c
- libntp/prettydate.c
- ntpd/ntp_leapsec.c
- ntpd/ntp_leapsec.h
- ntpd/ntp_timer.c
- ntpd/refclock_nmea.c
- tests/libntp/calendar.c
- tests/libntp/vi64ops.c
Changes:
=====================================
devel/tour.txt
=====================================
--- a/devel/tour.txt
+++ b/devel/tour.txt
@@ -40,20 +40,20 @@ will be, by a factor of at least five million) we can map all incoming
timestamps from whatever cycle into the nearest time in modular
arithmetic relative to the cycle length.
-=== vint64 ===
+=== time64_t ===
-The vint64 type is a historical relic. NTP was written well before
+The time64_t type is a historical relic. NTP was written well before
the 64-bit word size became common. While compilers on 32-bit machines
sometimes have had "long long" as an integral 64-bit type, this was not
guaranteed before C99.
Thus, NTP carries a "variant 64-bit int" type that is actually a union
with several different interpretations. Support is mainly in
-libntp/vint64ops.c. If that code confuses you, don't feel slow; it
+libntp/time64_tops.c. If that code confuses you, don't feel slow; it
really is ugly and hard to understand, and would have been removed
already if it were not deeply intertwined with the calendar code.
-Someday all operations on vint64s will be replaced by code using
+Someday all operations on time64_ts will be replaced by code using
int64_t or uint64_t scalars, and this section will go away.
=== refid ===
=====================================
include/ntp_calendar.h
=====================================
--- a/include/ntp_calendar.h
+++ b/include/ntp_calendar.h
@@ -94,10 +94,10 @@ extern systime_func_ptr ntpcal_set_timefunc(systime_func_ptr);
#define SECSPERAVGYEAR 31556952 /* mean year length over 400yrs */
/*
- * Convert between 'time_t' and 'vint64'
+ * Convert between 'time_t' and 'time64_t'
*/
-extern vint64 time_to_vint64(const time_t *);
-extern time_t vint64_to_time(const vint64 *);
+extern time64_t time_to_time64_t(const time_t *);
+extern time_t time64_t_to_time(const time64_t *);
/*
* Get the build date & time. ATTENTION: The time zone is not specified!
@@ -113,7 +113,7 @@ ntpcal_get_build_date(struct calendar * /* jd */);
* scale with proper epoch unfolding around a given pivot or the
* current system time.
*/
-extern vint64
+extern time64_t
ntpcal_ntp_to_time(uint32_t /* ntp */, const time_t * /* pivot */);
/*
@@ -122,7 +122,7 @@ ntpcal_ntp_to_time(uint32_t /* ntp */, const time_t * /* pivot */);
* system time.
* Note: The pivot must be given in UN*X time scale!
*/
-extern vint64
+extern time64_t
ntpcal_ntp_to_ntp(uint32_t /* ntp */, const time_t * /* pivot */);
/*
@@ -130,13 +130,13 @@ ntpcal_ntp_to_ntp(uint32_t /* ntp */, const time_t * /* pivot */);
* since midnight.
*/
extern ntpcal_split
-ntpcal_daysplit(const vint64 *);
+ntpcal_daysplit(const time64_t *);
/*
* Merge a number of days and a number of seconds into seconds,
* expressed in 64 bits to avoid overflow.
*/
-extern vint64
+extern time64_t
ntpcal_dayjoin(int32_t /* days */, int32_t /* seconds */);
/*
@@ -284,20 +284,20 @@ ntpcal_daysplit_to_tm(struct tm * /* utm */, const ntpcal_split * /* ds */,
int32_t /* dof */);
extern int
-ntpcal_time_to_date(struct calendar * /* jd */, const vint64 * /* ts */);
+ntpcal_time_to_date(struct calendar * /* jd */, const time64_t * /* ts */);
extern int32_t
ntpcal_periodic_extend(int32_t /* pivot */, int32_t /* value */,
int32_t /* cycle */);
extern int
-ntpcal_ntp64_to_date(struct calendar * /* jd */, const vint64 * /* ntp */);
+ntpcal_ntp64_to_date(struct calendar * /* jd */, const time64_t * /* ntp */);
extern int
ntpcal_ntp_to_date(struct calendar * /* jd */, uint32_t /* ntp */,
const time_t * /* pivot */);
-extern vint64
+extern time64_t
ntpcal_date_to_ntp64(const struct calendar * /* jd */);
extern uint32_t
@@ -316,13 +316,13 @@ extern ntpcal_split
isocal_split_eraweeks(int32_t /* weeks */);
extern int
-isocal_ntp64_to_date(struct isodate * /* id */, const vint64 * /* ntp */);
+isocal_ntp64_to_date(struct isodate * /* id */, const time64_t * /* ntp */);
extern int
isocal_ntp_to_date(struct isodate * /* id */, uint32_t /* ntp */,
const time_t * /* pivot */);
-extern vint64
+extern time64_t
isocal_date_to_ntp64(const struct isodate * /* id */);
extern uint32_t
=====================================
include/ntp_types.h
=====================================
--- a/include/ntp_types.h
+++ b/include/ntp_types.h
@@ -46,24 +46,24 @@
* library wouldn't compile otherwise).
*/
-typedef uint64_t vint64;
+typedef uint64_t time64_t;
#define LAST32MASK 0x00000000ffffffffUL
#define FIRST32MASK 0xffffffff00000000UL
#define GET32LAST(n) ((n) & LAST32MASK)
#define SET32LAST(n, v) (n) = (((n) & FIRST32MASK) | ((v) & LAST32MASK))
#define GET32FIRST(n) ((n) >> 32)
#define SET32FIRST(n,v) (n) = ((((v) & LAST32MASK) << 32) | ((n) & LAST32MASK))
-#define vint64lo(n) ((uint32_t)GET32LAST(n))
-#define setvint64lo(n,v) SET32LAST(n,v)
-#define vint64his(n) ((int32_t)(GET32FIRST(n)))
-#define setvint64his(n,v) SET32FIRST(n,v)
-#define vint64hiu(n) ((uint32_t)(GET32FIRST(n)))
-#define setvint64hiu(n,v) SET32FIRST(n,v)
-#define vint64s(n) ((int64_t)(n))
-#define setvint64s(n,v) (n) = ((int64_t)(v))
-#define vint64u(n) (n)
-#define setvint64u(n,v) (n) = (v)
-#define negvint64(n) (n = ((uint64_t)((((int64_t)(n)) * -1))))
+#define time64_tlo(n) ((uint32_t)GET32LAST(n))
+#define settime64_tlo(n,v) SET32LAST(n,v)
+#define time64_this(n) ((int32_t)(GET32FIRST(n)))
+#define settime64_this(n,v) SET32FIRST(n,v)
+#define time64_thiu(n) ((uint32_t)(GET32FIRST(n)))
+#define settime64_thiu(n,v) SET32FIRST(n,v)
+#define time64_ts(n) ((int64_t)(n))
+#define settime64_ts(n,v) (n) = ((int64_t)(v))
+#define time64_tu(n) (n)
+#define settime64_tu(n,v) (n) = (v)
+#define negtime64_t(n) (n = ((uint64_t)((((int64_t)(n)) * -1))))
typedef uint16_t associd_t; /* association ID */
#define ASSOCID_MAX USHRT_MAX
=====================================
include/timespecops.h
=====================================
--- a/include/timespecops.h
+++ b/include/timespecops.h
@@ -372,16 +372,16 @@ lfp_stamp_to_tspec(
)
{
struct timespec out;
- vint64 sec;
+ time64_t sec;
sec = ntpcal_ntp_to_time(x.l_ui, p);
out.tv_nsec = FTOTVN(x.l_uf);
- /* copying a vint64 to a time_t needs some care... */
+ /* copying a time64_t to a time_t needs some care... */
#if NTP_SIZEOF_TIME_T <= 4
- out.tv_sec = (time_t)vint64lo(sec);
+ out.tv_sec = (time_t)time64_tlo(sec);
#else
- out.tv_sec = (time_t)vint64s(sec);
+ out.tv_sec = (time_t)time64_ts(sec);
#endif
return out;
=====================================
libntp/clocktime.c
=====================================
--- a/libntp/clocktime.c
+++ b/libntp/clocktime.c
@@ -129,7 +129,7 @@ static int32_t
ntp_to_year(
uint32_t ntp)
{
- vint64 t;
+ time64_t t;
ntpcal_split s;
t = ntpcal_ntp_to_ntp(ntp, NULL);
=====================================
libntp/ntp_calendar.c
=====================================
--- a/libntp/ntp_calendar.c
+++ b/libntp/ntp_calendar.c
@@ -50,30 +50,30 @@ now(void)
/*
*---------------------------------------------------------------------
- * Convert between 'time_t' and 'vint64'
+ * Convert between 'time_t' and 'time64_t'
*---------------------------------------------------------------------
*/
-vint64
-time_to_vint64(
+time64_t
+time_to_time64_t(
const time_t * ptt
)
{
- vint64 res;
+ time64_t res;
time_t tt;
tt = *ptt;
#if NTP_SIZEOF_TIME_T <= 4
- setvint64hiu(res, 0);
+ settime64_thiu(res, 0);
if (tt < 0) {
- setvint64lo(res, (uint32_t)-tt);
- negvint64(res);
+ settime64_tlo(res, (uint32_t)-tt);
+ negtime64_t(res);
} else {
- setvint64lo(res, (uint32_t)tt);
+ settime64_tlo(res, (uint32_t)tt);
}
#else
- setvint64s(res, tt);
+ settime64_ts(res, tt);
#endif
return res;
@@ -81,17 +81,17 @@ time_to_vint64(
time_t
-vint64_to_time(
- const vint64 *tv
+time64_t_to_time(
+ const time64_t *tv
)
{
time_t res;
#if NTP_SIZEOF_TIME_T <= 4
- res = (time_t)vint64lo(*tv);
+ res = (time_t)time64_tlo(*tv);
#else
- res = (time_t)vint64s(*tv);
+ res = (time_t)time64_ts(*tv);
#endif
return res;
@@ -374,19 +374,19 @@ ntpcal_periodic_extend(
* divisions.
*-------------------------------------------------------------------
*/
-vint64
+time64_t
ntpcal_ntp_to_time(
uint32_t ntp,
const time_t * pivot
)
{
- vint64 res;
+ time64_t res;
- setvint64s(res, (pivot != NULL) ? *pivot : now());
- setvint64u(res, vint64u(res)-0x80000000); /* unshift of half range */
+ settime64_ts(res, (pivot != NULL) ? *pivot : now());
+ settime64_tu(res, time64_tu(res)-0x80000000); /* unshift of half range */
ntp -= (uint32_t)JAN_1970; /* warp into UN*X domain */
- ntp -= vint64lo(res); /* cycle difference */
- setvint64u(res, vint64u(res)+(uint64_t)ntp); /* get expanded time */
+ ntp -= time64_tlo(res); /* cycle difference */
+ settime64_tu(res, time64_tu(res)+(uint64_t)ntp); /* get expanded time */
return res;
}
@@ -404,20 +404,20 @@ ntpcal_ntp_to_time(
* divisions.
*-------------------------------------------------------------------
*/
-vint64
+time64_t
ntpcal_ntp_to_ntp(
uint32_t ntp,
const time_t *pivot
)
{
- vint64 res;
+ time64_t res;
- setvint64s(res, (pivot) ? *pivot : now());
- setvint64u(res, vint64u(res) - 0x80000000); /* unshift of half range */
- setvint64u(res, vint64u(res) + (uint32_t)JAN_1970); /* warp into NTP domain */
+ settime64_ts(res, (pivot) ? *pivot : now());
+ settime64_tu(res, time64_tu(res) - 0x80000000); /* unshift of half range */
+ settime64_tu(res, time64_tu(res) + (uint32_t)JAN_1970); /* warp into NTP domain */
- ntp -= vint64lo(res); /* cycle difference */
- setvint64u(res, vint64u(res) + (uint64_t)ntp); /* get expanded time */
+ ntp -= time64_tlo(res); /* cycle difference */
+ settime64_tu(res, time64_tu(res) + (uint64_t)ntp); /* get expanded time */
return res;
}
@@ -441,14 +441,14 @@ ntpcal_ntp_to_ntp(
*/
ntpcal_split
ntpcal_daysplit(
- const vint64 *ts
+ const time64_t *ts
)
{
ntpcal_split res;
/* manual floor division by SECSPERDAY */
- res.hi = (int32_t)(vint64s(*ts) / SECSPERDAY);
- res.lo = (int32_t)(vint64s(*ts) % SECSPERDAY);
+ res.hi = (int32_t)(time64_ts(*ts) / SECSPERDAY);
+ res.lo = (int32_t)(time64_ts(*ts) % SECSPERDAY);
if (res.lo < 0) {
res.hi -= 1;
res.lo += SECSPERDAY;
@@ -761,7 +761,7 @@ ntpcal_daysplit_to_tm(
int
ntpcal_time_to_date(
struct calendar *jd,
- const vint64 *ts
+ const time64_t *ts
)
{
ntpcal_split ds;
@@ -788,17 +788,17 @@ ntpcal_time_to_date(
* expressed in 64 bits to avoid overflow.
*---------------------------------------------------------------------
*/
-vint64
+time64_t
ntpcal_dayjoin(
int32_t days,
int32_t secs
)
{
- vint64 res;
+ time64_t res;
- setvint64s(res, days);
- setvint64s(res, vint64s(res) * SECSPERDAY);
- setvint64s(res, vint64s(res) + secs);
+ settime64_ts(res, days);
+ settime64_ts(res, time64_ts(res) * SECSPERDAY);
+ settime64_ts(res, time64_ts(res) + secs);
return res;
}
@@ -1095,21 +1095,21 @@ ntpcal_date_to_time(
const struct calendar *jd
)
{
- vint64 join;
+ time64_t join;
int32_t days, secs;
days = ntpcal_date_to_rd(jd) - DAY_UNIX_STARTS;
secs = ntpcal_date_to_daysec(jd);
join = ntpcal_dayjoin(days, secs);
- return vint64_to_time(&join);
+ return time64_t_to_time(&join);
}
int
ntpcal_ntp64_to_date(
struct calendar *jd,
- const vint64 *ntp
+ const time64_t *ntp
)
{
ntpcal_split ds;
@@ -1127,7 +1127,7 @@ ntpcal_ntp_to_date(
const time_t *piv
)
{
- vint64 ntp64;
+ time64_t ntp64;
/*
* Unfold ntp time around current time into NTP domain. Split
@@ -1139,7 +1139,7 @@ ntpcal_ntp_to_date(
}
-vint64
+time64_t
ntpcal_date_to_ntp64(
const struct calendar *jd
)
@@ -1160,7 +1160,7 @@ ntpcal_date_to_ntp(
/*
* Get lower half of 64-bit NTP timestamp from date/time.
*/
- return vint64lo(ntpcal_date_to_ntp64(jd));
+ return time64_tlo(ntpcal_date_to_ntp64(jd));
}
@@ -1367,7 +1367,7 @@ isocal_split_eraweeks(
int
isocal_ntp64_to_date(
struct isodate *id,
- const vint64 *ntp
+ const time64_t *ntp
)
{
ntpcal_split ds;
@@ -1409,7 +1409,7 @@ isocal_ntp_to_date(
const time_t *piv
)
{
- vint64 ntp64;
+ time64_t ntp64;
/*
* Unfold ntp time around current time into NTP domain, then
@@ -1423,7 +1423,7 @@ isocal_ntp_to_date(
* Convert a ISO date spec into a second in the NTP time scale,
* properly truncated to 32 bit.
*/
-vint64
+time64_t
isocal_date_to_ntp64(
const struct isodate *id
)
@@ -1447,7 +1447,7 @@ isocal_date_to_ntp(
/*
* Get lower half of 64-bit NTP timestamp from date/time.
*/
- return vint64lo(isocal_date_to_ntp64(id));
+ return time64_tlo(isocal_date_to_ntp64(id));
}
/* -*-EOF-*- */
=====================================
libntp/prettydate.c
=====================================
--- a/libntp/prettydate.c
+++ b/libntp/prettydate.c
@@ -51,7 +51,7 @@ static char *common_prettydate(l_fp *, bool);
static struct tm *
get_struct_tm(
- const vint64 *stamp,
+ const time64_t *stamp,
int local,
struct tm *tmbuf)
{
@@ -60,7 +60,7 @@ get_struct_tm(
time_t ts;
int64_t tl;
- ts = tl = vint64s(*stamp);
+ ts = tl = time64_ts(*stamp);
/*
* If there is chance of truncation, try to fix it. Let the
@@ -127,7 +127,7 @@ common_prettydate(
struct tm *tm, tmbuf;
u_int msec;
uint32_t ntps;
- vint64 sec;
+ time64_t sec;
LIB_GETBUF(bp);
=====================================
ntpd/ntp_leapsec.c
=====================================
--- a/ntpd/ntp_leapsec.c
+++ b/ntpd/ntp_leapsec.c
@@ -38,7 +38,7 @@ static const char * const logPrefix = "leapsecond file";
#define MAX_HIST 10 /* history of leap seconds */
struct leap_info {
- vint64 ttime; /* transition time (after the step, ntp scale) */
+ time64_t ttime; /* transition time (after the step, ntp scale) */
uint32_t stime; /* schedule limit (a month before transition) */
int16_t taiof; /* TAI offset on and after the transition */
uint8_t dynls; /* dynamic: inserted on peer/clock request */
@@ -46,16 +46,16 @@ struct leap_info {
typedef struct leap_info leap_info_t;
struct leap_head {
- vint64 update; /* time of information update */
- vint64 expire; /* table expiration time */
+ time64_t update; /* time of information update */
+ time64_t expire; /* table expiration time */
uint16_t size; /* number of infos in table */
int16_t base_tai; /* total leaps before first entry */
int16_t this_tai; /* current TAI offset */
int16_t next_tai; /* TAI offset after 'when' */
- vint64 dtime; /* due time (current era end) */
- vint64 ttime; /* nominal transition time (next era start) */
- vint64 stime; /* schedule time (when we take notice) */
- vint64 ebase; /* base time of this leap era */
+ time64_t dtime; /* due time (current era end) */
+ time64_t ttime; /* nominal transition time (next era start) */
+ time64_t stime; /* schedule time (when we take notice) */
+ time64_t ebase; /* base time of this leap era */
uint8_t dynls; /* next leap is dynamic (by peer request) */
};
typedef struct leap_head leap_head_t;
@@ -75,12 +75,12 @@ static bool add_range(leap_table_t*, const leap_info_t*);
static char * get_line(leapsec_reader, void*, char*, size_t);
static char * skipws(char*);
static bool parsefail(const char * cp, const char * ep);
-static void reload_limits(leap_table_t*, const vint64);
+static void reload_limits(leap_table_t*, const time64_t);
static bool betweenu32(uint32_t, uint32_t, uint32_t);
static void reset_times(leap_table_t*);
-static bool leapsec_add(leap_table_t*, const vint64, int);
-static bool leapsec_raw(leap_table_t*, const vint64, int, int);
-static char * lstostr(const vint64 * ts);
+static bool leapsec_add(leap_table_t*, const time64_t, int);
+static bool leapsec_raw(leap_table_t*, const time64_t, int, int);
+static char * lstostr(const time64_t * ts);
/* =====================================================================
* Get & Set the current leap table
@@ -169,7 +169,7 @@ leapsec_load(
int use_build_limit)
{
char *cp, *ep, linebuf[50];
- vint64 ttime, limit;
+ time64_t ttime, limit;
long taiof;
struct calendar build;
@@ -185,18 +185,18 @@ leapsec_load(
cp++;
if (*cp == '@') {
cp = skipws(cp+1);
- setvint64u(pt->head.expire, strtoull(cp, &ep, 10));
+ settime64_tu(pt->head.expire, strtoull(cp, &ep, 10));
if (parsefail(cp, ep))
goto fail_read;
- pt->lsig.etime = vint64lo(pt->head.expire);
+ pt->lsig.etime = time64_tlo(pt->head.expire);
} else if (*cp == '$') {
cp = skipws(cp+1);
- setvint64u(pt->head.update, strtoull(cp, &ep, 10));
+ settime64_tu(pt->head.update, strtoull(cp, &ep, 10));
if (parsefail(cp, ep))
goto fail_read;
}
} else if (isdigit((uint8_t)*cp)) {
- setvint64u(ttime, strtoull(cp, &ep, 10));
+ settime64_tu(ttime, strtoull(cp, &ep, 10));
if (parsefail(cp, ep))
goto fail_read;
cp = skipws(ep);
@@ -211,7 +211,7 @@ leapsec_load(
} else {
pt->head.base_tai = (int16_t)taiof;
}
- pt->lsig.ttime = vint64lo(ttime);
+ pt->lsig.ttime = time64_tlo(ttime);
pt->lsig.taiof = (int16_t)taiof;
}
}
@@ -235,7 +235,7 @@ leapsec_dump(
void * farg)
{
int idx;
- vint64 ts;
+ time64_t ts;
struct calendar atb, ttb;
ntpcal_ntp64_to_date(&ttb, &pt->head.expire);
@@ -268,7 +268,7 @@ leapsec_query(
const time_t * pivot)
{
leap_table_t * pt;
- vint64 ts64, last, next;
+ time64_t ts64, last, next;
uint32_t due32;
bool fired;
@@ -294,14 +294,14 @@ leapsec_query(
* both modes is easier to maintain.
*/
last = pt->head.ttime;
- qr->warped = (int16_t)(vint64lo(last) -
- vint64lo(pt->head.dtime));
+ qr->warped = (int16_t)(time64_tlo(last) -
+ time64_tlo(pt->head.dtime));
next = ts64 + qr->warped;
reload_limits(pt, next);
fired = (pt->head.ebase == last);
if (fired) {
ts64 = next;
- ts32 = vint64lo(next);
+ ts32 = time64_tlo(next);
} else {
qr->warped = 0;
}
@@ -314,7 +314,7 @@ leapsec_query(
return fired;
/* now start to collect the remaining data */
- due32 = vint64lo(pt->head.dtime);
+ due32 = time64_tlo(pt->head.dtime);
qr->tai_diff = pt->head.next_tai - pt->head.this_tai;
qr->ttime = pt->head.ttime;
@@ -524,7 +524,7 @@ leapsec_expired(
const time_t * tpiv)
{
const leap_table_t * pt;
- vint64 limit;
+ time64_t limit;
pt = leapsec_get_table(false);
limit = ntpcal_ntp_to_ntp(when, tpiv);
@@ -538,7 +538,7 @@ leapsec_daystolive(
const time_t * tpiv)
{
const leap_table_t * pt;
- vint64 limit;
+ time64_t limit;
pt = leapsec_get_table(false);
limit = ntpcal_ntp_to_ntp(when, tpiv);
@@ -556,7 +556,7 @@ leapsec_add_fix(
{
time_t tpiv;
leap_table_t * pt;
- vint64 tt64, et64;
+ time64_t tt64, et64;
if (pivot == NULL) {
time(&tpiv);
@@ -588,7 +588,7 @@ leapsec_add_dyn(
const time_t * pivot )
{
leap_table_t * pt;
- vint64 now64;
+ time64_t now64;
pt = leapsec_get_table(true);
now64 = ntpcal_ntp_to_ntp(ntpnow, pivot);
@@ -611,7 +611,7 @@ static void
reset_times(
leap_table_t * pt)
{
- memset(&pt->head.ebase, 0xFF, sizeof(vint64));
+ memset(&pt->head.ebase, 0xFF, sizeof(time64_t));
pt->head.stime = pt->head.ebase;
pt->head.ttime = pt->head.ebase;
pt->head.dtime = pt->head.ebase;
@@ -719,7 +719,7 @@ parsefail(
static void
reload_limits(
leap_table_t * pt,
- const vint64 ts)
+ const time64_t ts)
{
int idx;
@@ -737,7 +737,7 @@ reload_limits(
* empty -- no undefined condition must arise from this code.
*/
if (idx >= pt->head.size) {
- memset(&pt->head.ebase, 0x00, sizeof(vint64));
+ memset(&pt->head.ebase, 0x00, sizeof(time64_t));
pt->head.this_tai = pt->head.base_tai;
} else {
pt->head.ebase = pt->info[idx].ttime;
@@ -757,7 +757,7 @@ reload_limits(
pt->head.stime = pt->head.ttime - pt->info[idx].stime;
} else {
- memset(&pt->head.ttime, 0xFF, sizeof(vint64));
+ memset(&pt->head.ttime, 0xFF, sizeof(time64_t));
pt->head.stime = pt->head.ttime;
pt->head.dtime = pt->head.ttime;
pt->head.next_tai = pt->head.this_tai;
@@ -778,10 +778,10 @@ reload_limits(
static bool
leapsec_add(
leap_table_t* pt ,
- const vint64 now64 ,
+ const time64_t now64 ,
int insert)
{
- vint64 ttime, starttime;
+ time64_t ttime, starttime;
struct calendar fts;
leap_info_t li;
@@ -814,7 +814,7 @@ leapsec_add(
ttime = ntpcal_date_to_ntp64(&fts);
li.ttime = ttime;
- li.stime = vint64lo(ttime) - vint64lo(starttime);
+ li.stime = time64_tlo(ttime) - time64_tlo(starttime);
li.taiof = (pt->head.size ? pt->info[0].taiof : pt->head.base_tai)
+ (insert ? 1 : -1);
li.dynls = 1;
@@ -829,11 +829,11 @@ leapsec_add(
bool
leapsec_raw(
leap_table_t * pt,
- const vint64 ttime,
+ const time64_t ttime,
int taiof,
int dynls)
{
- vint64 starttime;
+ time64_t starttime;
struct calendar fts;
leap_info_t li;
@@ -852,7 +852,7 @@ leapsec_raw(
fts.month--; /* was in range 1..12, no overflow here! */
starttime = ntpcal_date_to_ntp64(&fts);
li.ttime = ttime;
- li.stime = vint64lo(ttime) - vint64lo(starttime);
+ li.stime = time64_tlo(ttime) - time64_tlo(starttime);
li.taiof = (int16_t)taiof;
li.dynls = (dynls != 0);
return add_range(pt, &li);
@@ -986,7 +986,7 @@ leapsec_validate(
* lstostr - prettyprint NTP seconds
*/
static char * lstostr(
- const vint64 * ts)
+ const time64_t * ts)
{
char * buf;
struct calendar tm;
=====================================
ntpd/ntp_leapsec.h
=====================================
--- a/ntpd/ntp_leapsec.h
+++ b/ntpd/ntp_leapsec.h
@@ -85,7 +85,7 @@ extern bool leapsec_electric(electric_mode el);
* 'dynamic' != 0 if entry was requested by clock/peer
*/
struct leap_result {
- vint64 ttime;
+ time64_t ttime;
uint32_t ddist;
int16_t tai_offs;
int16_t tai_diff;
=====================================
ntpd/ntp_timer.c
=====================================
--- a/ntpd/ntp_timer.c
+++ b/ntpd/ntp_timer.c
@@ -426,7 +426,7 @@ check_leapsec(
if (lsdata.tai_diff) {
if (leap_smear.interval == 0) {
leap_smear.interval = leap_smear_intv;
- leap_smear.intv_end = vint64u(lsdata.ttime);
+ leap_smear.intv_end = time64_tu(lsdata.ttime);
leap_smear.intv_start = leap_smear.intv_end - leap_smear.interval;
DPRINTF(1, ("*** leapsec_query: setting leap_smear interval %li, begin %.0f, end %.0f\n",
leap_smear.interval, leap_smear.intv_start, leap_smear.intv_end));
=====================================
ntpd/refclock_nmea.c
=====================================
--- a/ntpd/refclock_nmea.c
+++ b/ntpd/refclock_nmea.c
@@ -1640,7 +1640,7 @@ unfold_day(
uint32_t rec_ui
)
{
- vint64 rec_qw;
+ time64_t rec_qw;
ntpcal_split rec_ds;
/*
@@ -1792,7 +1792,7 @@ eval_gps_time(
int32_t adj_day, weeks; /* adjusted GPS day and week shift */
/* some temporaries to shuffle data */
- vint64 vi64;
+ time64_t vi64;
ntpcal_split rs64;
/* evaluate time stamp from receiver. */
@@ -1806,7 +1806,7 @@ eval_gps_time(
/* If we fully trust the GPS receiver, just combine days and
* seconds and be done. */
if (peer->ttl & NMEA_DATETRUST_MASK) {
- retv.l_ui = vint64lo(ntpcal_dayjoin(gps_day, gps_sec));
+ retv.l_ui = time64_tlo(ntpcal_dayjoin(gps_day, gps_sec));
return retv;
}
@@ -1864,7 +1864,7 @@ eval_gps_time(
}
/* - build result and be done */
- retv.l_ui = vint64lo(ntpcal_dayjoin(adj_day, gps_sec));
+ retv.l_ui = time64_tlo(ntpcal_dayjoin(adj_day, gps_sec));
return retv;
}
=====================================
tests/libntp/calendar.c
=====================================
--- a/tests/libntp/calendar.c
+++ b/tests/libntp/calendar.c
@@ -122,14 +122,14 @@ static const u_short real_month_days[2][14] = {
// test the day/sec join & split ops, making sure that 32bit
// intermediate results would definitely overflow and the hi DWORD of
-// the 'vint64' is definitely needed.
+// the 'time64_t' is definitely needed.
TEST(calendar, DaySplitMerge) {
int32_t day;
int32_t sec;
for (day = -1000000; day <= 1000000; day += 100) {
for (sec = -100000; sec <= 186400; sec += 10000) {
- vint64 merge = ntpcal_dayjoin(day, sec);
+ time64_t merge = ntpcal_dayjoin(day, sec);
ntpcal_split split = ntpcal_daysplit(&merge);
int32_t eday = day;
int32_t esec = sec;
=====================================
tests/libntp/vi64ops.c
=====================================
--- a/tests/libntp/vi64ops.c
+++ b/tests/libntp/vi64ops.c
@@ -11,47 +11,47 @@ TEST_SETUP(vi64ops) {}
TEST_TEAR_DOWN(vi64ops) {}
TEST(vi64ops, HiLoVUI64uh) {
- vint64 exp = 0;
+ time64_t exp = 0;
- setvint64hiu(exp, 0x01234567);
- setvint64lo(exp, 0x89ABCDEF);
- TEST_ASSERT_EQUAL(vint64hiu(exp), 0x01234567);
+ settime64_thiu(exp, 0x01234567);
+ settime64_tlo(exp, 0x89ABCDEF);
+ TEST_ASSERT_EQUAL(time64_thiu(exp), 0x01234567);
}
TEST(vi64ops, HiLoVUI64ul) {
- vint64 exp = 0;
+ time64_t exp = 0;
- setvint64hiu(exp, 0x01234567);
- setvint64lo(exp, 0x89ABCDEF);
- TEST_ASSERT_EQUAL(vint64lo(exp), 0x89ABCDEF);
+ settime64_thiu(exp, 0x01234567);
+ settime64_tlo(exp, 0x89ABCDEF);
+ TEST_ASSERT_EQUAL(time64_tlo(exp), 0x89ABCDEF);
}
TEST(vi64ops, SetVUI64s_pos) {
- vint64 exp = 0;
+ time64_t exp = 0;
- setvint64s(exp, 0x0123456789ABCDEF);
- TEST_ASSERT_EQUAL(vint64s(exp), 81985529216486895);
+ settime64_ts(exp, 0x0123456789ABCDEF);
+ TEST_ASSERT_EQUAL(time64_ts(exp), 81985529216486895);
}
TEST(vi64ops, SetVUI64s_neg) {
- vint64 exp = 0;
+ time64_t exp = 0;
- setvint64s(exp, 0xFEDCBA9876543210);
- TEST_ASSERT_EQUAL(vint64s(exp), -81985529216486896);
+ settime64_ts(exp, 0xFEDCBA9876543210);
+ TEST_ASSERT_EQUAL(time64_ts(exp), -81985529216486896);
}
TEST(vi64ops, SetVUI64u) {
- vint64 exp = 0;
+ time64_t exp = 0;
- setvint64u(exp, 0xFEDCBA9876543210); /* sign bit is on */
- TEST_ASSERT_EQUAL(vint64s(exp), 18364758544493064720UL);
+ settime64_tu(exp, 0xFEDCBA9876543210); /* sign bit is on */
+ TEST_ASSERT_EQUAL(time64_ts(exp), 18364758544493064720UL);
}
TEST(vi64ops, NegVUI64) {
- vint64 exp = 0;
+ time64_t exp = 0;
- setvint64s(exp, 71985529216486896);
- TEST_ASSERT_EQUAL(negvint64(exp), -71985529216486896);
+ settime64_ts(exp, 71985529216486896);
+ TEST_ASSERT_EQUAL(negtime64_t(exp), -71985529216486896);
}
TEST_GROUP_RUNNER(vi64ops) {
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/7ed3b296bc0deb3201ba867e25385b1dc83ac727
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161212/f80df4a4/attachment.html>
More information about the vc
mailing list