[ntp:bk-ntp-dev-send] BitKeeper patch

Harlan Stenn stenn at whimsy.udel.edu
Tue Jan 6 21:58:56 PST 2004


This BitKeeper patch contains the following changesets:
a115350 at y3111429.nh.ad.hydro.com|ChangeSet|20040106201951|18329
a115350 at y3111429.nh.ad.hydro.com|ChangeSet|20040106202022|26658
stenn at whimsy.udel.edu|ChangeSet|20040107055722|26666

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# ID:	stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
# User:	stenn
# Host:	whimsy.udel.edu
# Root:	/backroom/ntp-dev

#
#--- 1.41/BitKeeper/etc/logging_ok	Wed Nov 19 05:07:39 2003
#+++ 1.42/BitKeeper/etc/logging_ok	Tue Jan  6 15:19:51 2004
#@@ -1,3 +1,4 @@
#+a115350 at y3111429.nh.ad.hydro.com
# blu at corwin.
# blu at jedi.east.sun.com
# bruckman at pogo.udel.edu
#
#--- 1.4/libntp/caljulian.c	Sun Mar 24 19:24:57 2002
#+++ 1.5/libntp/caljulian.c	Tue Jan  6 15:14:58 2004
#@@ -24,6 +24,7 @@
# 	NOV
# };
# 
#+#if 0
# void
# caljulian(
# 	u_long		  		ntptime,
#@@ -113,3 +114,34 @@
# 	jt->monthday = (u_char) monthday;
# 	}
# }
#+#else
#+
#+/* Updated 2003-12-30 TMa
#+
#+   Uses common code with the *prettydate functions to convert an ntp
#+   seconds count into a calendar date.
#+   Will handle ntp epoch wraparound as long as the underlying os/library 
#+   does so for the unix epoch, i.e. works after 2038.
#+*/
#+
#+struct tm * ntp2unix_tm(u_long ntp, int local);
#+
#+void
#+caljulian(
#+	u_long		  		ntptime,
#+	register struct calendar	*jt
#+	)
#+{
#+	struct tm *tm;
#+
#+	tm = ntp2unix_tm(ntptime, 0);
#+
#+	jt->hour = (u_char) tm->tm_hour;
#+	jt->minute = (u_char) tm->tm_min;
#+	jt->month = (u_char) (tm->tm_mon + 1);
#+	jt->monthday = (u_char) tm->tm_mday;
#+	jt->second = (u_char) tm->tm_sec;
#+	jt->year = (u_short) (tm->tm_year + 1900);
#+	jt->yearday = (u_short) (tm->tm_yday + 1);  /* Assumes tm_yday starts with day 0! */
#+}
#+#endif
#
#--- 1.4/libntp/humandate.c	Wed Oct  8 03:41:54 2003
#+++ 1.5/libntp/humandate.c	Tue Jan  6 15:14:58 2004
#@@ -15,6 +15,8 @@
# 	"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
# };
# 
#+struct tm * ntp2unix_tm(u_long ntp, int local);
#+
# char *
# humandate(
# 	u_long ntptime
#@@ -22,10 +24,8 @@
# {
# 	char *bp;
# 	struct tm *tm;
#-	time_t sec;
# 
#-	sec = ntptime - JAN_1970;
#-	tm = localtime(&sec);
#+	tm = ntp2unix_tm(ntptime, 1);
# 
# 	if (!tm)
# 		return "--- --- -- ---- --:--:--";
#@@ -48,8 +48,9 @@
# {
# 	char *bp;
# 	time_t cursec = time((time_t *) 0);
#-	struct tm *tm = localtime(&cursec);
#+	struct tm *tm;
# 	
#+	tm = localtime(&cursec);
# 	if (!tm)
# 		return "-- --- --:--:--";
# 
#
#--- 1.3/libntp/prettydate.c	Mon Oct  8 21:18:12 2001
#+++ 1.4/libntp/prettydate.c	Tue Jan  6 15:14:58 2004
#@@ -17,6 +17,51 @@
#   "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
# };
# 
#+/* Helper function to handle possible wraparound of the ntp epoch.
#+
#+   Works by assuming that the localtime/gmtime library functions 
#+   have been updated so that they work
#+*/
#+
#+#define MAX_EPOCH_NR 1000
#+
#+struct tm *
#+ntp2unix_tm(
#+	u_long ntp, int local
#+	)
#+{
#+	time_t t, curr;
#+	struct tm *tm;
#+	int curr_year, epoch_nr;
#+
#+	/* First get the current year: */
#+	curr = time(NULL);
#+	tm = local ? localtime(&curr) : gmtime(&curr);
#+	if (!tm) return NULL;
#+
#+	curr_year = 1900 + tm->tm_year;
#+
#+	/* Convert the ntp timestamp to a unix utc seconds count: */
#+	t = (time_t) ntp - JAN_1970;
#+
#+	/* Check that the ntp timestamp is not before a 136 year window centered
#+	   around the current year:
#+
#+	   Failsafe in case of an infinite loop:
#+       Allow up to 1000 epochs of 136 years each!
#+	*/
#+    for (epoch_nr = 0; epoch_nr < MAX_EPOCH_NR; epoch_nr++) {
#+		tm = local ? localtime(&t) : gmtime(&t);
#+
#+		/* Check that the resulting year is in the correct epoch: */
#+		if (1900 + tm->tm_year > curr_year - 68) break;
#+
#+		/* Epoch wraparound: Add 2^32 seconds! */
#+		t += (time_t) 65536 << 16;
#+	}
#+	return tm;
#+}
#+
# char *
# prettydate(
# 	l_fp *ts
#@@ -29,15 +74,20 @@
# 
# 	LIB_GETBUF(bp);
# 	
#-	sec = ts->l_ui - JAN_1970;
#+	sec = ts->l_ui;
# 	msec = ts->l_uf / 4294967;	/* fract / (2 ** 32 / 1000) */
# 
#-	tm = localtime(&sec);
#-
#-	(void) sprintf(bp, "%08lx.%08lx  %s, %s %2d %4d %2d:%02d:%02d.%03lu",
#+	tm = ntp2unix_tm(sec, 1);
#+	if (!tm) {
#+		(void) sprintf(bp, "%08lx.%08lx  --- --- -- ---- --:--:--",
#+		       (u_long)ts->l_ui, (u_long)ts->l_uf);
#+	}
#+	else {
#+		(void) sprintf(bp, "%08lx.%08lx  %s, %s %2d %4d %2d:%02d:%02d.%03lu",
# 		       (u_long)ts->l_ui, (u_long)ts->l_uf, days[tm->tm_wday],
# 		       months[tm->tm_mon], tm->tm_mday, 1900 + tm->tm_year,
# 		       tm->tm_hour,tm->tm_min, tm->tm_sec, msec);
#+	}
# 	
# 	return bp;
# }
#@@ -54,15 +104,20 @@
# 
# 	LIB_GETBUF(bp);
# 	
#-	sec = ts->l_ui - JAN_1970;
#+	sec = ts->l_ui;
# 	msec = ts->l_uf / 4294967;	/* fract / (2 ** 32 / 1000) */
# 
#-	tm = gmtime(&sec);
#-
#-	(void) sprintf(bp, "%08lx.%08lx  %s, %s %2d %4d %2d:%02d:%02d.%03lu UTC",
#+	tm = ntp2unix_tm(sec, 0);
#+	if (!tm) {
#+		(void) sprintf(bp, "%08lx.%08lx  --- --- -- ---- --:--:--",
#+		       (u_long)ts->l_ui, (u_long)ts->l_uf);
#+	}
#+	else {
#+		(void) sprintf(bp, "%08lx.%08lx  %s, %s %2d %4d %2d:%02d:%02d.%03lu",
# 		       (u_long)ts->l_ui, (u_long)ts->l_uf, days[tm->tm_wday],
# 		       months[tm->tm_mon], tm->tm_mday, 1900 + tm->tm_year,
# 		       tm->tm_hour,tm->tm_min, tm->tm_sec, msec);
#-	
#+	}
#+
# 	return bp;
# }
#

# Diff checksum=264c4ca1


# Patch vers:	1.3
# Patch type:	REGULAR

== ChangeSet ==
stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
stenn at whimsy.udel.edu|ChangeSet|20031218075014|17242
D 1.1195.1.1 04/01/06 21:19:51+01:00 a115350 at y3111429.nh.ad.hydro.com +4 -0
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Fix for NTP Epoch rollover
K 18329
P ChangeSet
------------------------------------------------

0a0
> stenn at whimsy.udel.edu|libntp/prettydate.c|19990526004816|01635|3aed0663 a115350 at y3111429.nh.ad.hydro.com|libntp/prettydate.c|20040106201458|08884
> stenn at whimsy.udel.edu|libntp/humandate.c|19990526004816|01635|3aed0663 a115350 at y3111429.nh.ad.hydro.com|libntp/humandate.c|20040106201458|35234
> stenn at whimsy.udel.edu|libntp/caljulian.c|19990526004815|01635|3aed0663 a115350 at y3111429.nh.ad.hydro.com|libntp/caljulian.c|20040106201458|38911
> stenn at whimsy.udel.edu|BitKeeper/etc/logging_ok|20010815091324|19348|bebb84d857254496 a115350 at y3111429.nh.ad.hydro.com|BitKeeper/etc/logging_ok|20040106201951|52176

stenn at whimsy.udel.edu|ChangeSet|20040102213550|25571
D 1.1205 04/01/06 21:20:22+01:00 a115350 at y3111429.nh.ad.hydro.com +0 -0
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Merge http://ntp.bkbits.net/ntp-dev
c into y3111429.nh.ad.hydro.com:D:/cygwin/home/a115350/ntp-dev
i a115350 at y3111429.nh.ad.hydro.com|ChangeSet|20040106201951|18329
K 26658
M a115350 at y3111429.nh.ad.hydro.com|ChangeSet|20040106201951|18329
P ChangeSet
------------------------------------------------


a115350 at y3111429.nh.ad.hydro.com|ChangeSet|20040106202022|26658
D 1.1206 04/01/07 00:57:22-05:00 stenn at whimsy.udel.edu +0 -0
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Merge whimsy.udel.edu:/backroom/ntp-dev-46
c into whimsy.udel.edu:/backroom/ntp-dev
i stenn at whimsy.udel.edu|ChangeSet|20040107040649|25579
K 26666
M stenn at whimsy.udel.edu|ChangeSet|20040107040649|25579
P ChangeSet
------------------------------------------------


== BitKeeper/etc/logging_ok ==
stenn at whimsy.udel.edu|BitKeeper/etc/logging_ok|20010815091324|19348|bebb84d857254496
harlanst at time.usno.navy.mil|BitKeeper/etc/logging_ok|20031119100739|49760
D 1.42 04/01/06 21:19:51+01:00 a115350 at y3111429.nh.ad.hydro.com +1 -0
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Logging to logging at openlogging.org accepted
K 52176
O -rw-rw-r--
P BitKeeper/etc/logging_ok
------------------------------------------------

I0 1
a115350 at y3111429.nh.ad.hydro.com

== libntp/caljulian.c ==
stenn at whimsy.udel.edu|libntp/caljulian.c|19990526004815|01635|3aed0663
mayer at tecotoo.myibg.com|libntp/caljulian.c|20020325002457|41026
D 1.5 04/01/06 21:14:58+01:00 a115350 at y3111429.nh.ad.hydro.com +32 -0
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Fix for NTP epoch rollover: Uses time_t and 
c localtime/gmtime for conversion
K 38911
O -rw-rw-r--
P libntp/caljulian.c
------------------------------------------------

I26 1
#if 0
I115 31
#else
\
/* Updated 2003-12-30 TMa
\
   Uses common code with the *prettydate functions to convert an ntp
   seconds count into a calendar date.
   Will handle ntp epoch wraparound as long as the underlying os/library 
   does so for the unix epoch, i.e. works after 2038.
*/
\
struct tm * ntp2unix_tm(u_long ntp, int local);
\
void
caljulian(
	u_long		  		ntptime,
	register struct calendar	*jt
	)
{
	struct tm *tm;
\
	tm = ntp2unix_tm(ntptime, 0);
\
	jt->hour = (u_char) tm->tm_hour;
	jt->minute = (u_char) tm->tm_min;
	jt->month = (u_char) (tm->tm_mon + 1);
	jt->monthday = (u_char) tm->tm_mday;
	jt->second = (u_char) tm->tm_sec;
	jt->year = (u_short) (tm->tm_year + 1900);
	jt->yearday = (u_short) (tm->tm_yday + 1);  /* Assumes tm_yday starts with day 0! */
}
#endif

== libntp/humandate.c ==
stenn at whimsy.udel.edu|libntp/humandate.c|19990526004816|01635|3aed0663
peda at sectra.se|libntp/humandate.c|20031008074154|32832
D 1.5 04/01/06 21:14:58+01:00 a115350 at y3111429.nh.ad.hydro.com +5 -4
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Fix for NTP epoch rollover: Uses time_t and 
c localtime/gmtime for conversion
K 35234
O -rw-rw-r--
P libntp/humandate.c
------------------------------------------------

I17 2
struct tm * ntp2unix_tm(u_long ntp, int local);
\
D25 1
D27 2
I28 1
	tm = ntp2unix_tm(ntptime, 1);
D51 1
I51 1
	struct tm *tm;
I52 1
	tm = localtime(&cursec);

== libntp/prettydate.c ==
stenn at whimsy.udel.edu|libntp/prettydate.c|19990526004816|01635|3aed0663
stenn at whimsy.udel.edu|libntp/prettydate.c|20011009011812|59675
D 1.4 04/01/06 21:14:58+01:00 a115350 at y3111429.nh.ad.hydro.com +64 -9
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Use common helper function
K 8884
O -rw-rw-r--
P libntp/prettydate.c
------------------------------------------------

I19 45
/* Helper function to handle possible wraparound of the ntp epoch.
\
   Works by assuming that the localtime/gmtime library functions 
   have been updated so that they work
*/
\
#define MAX_EPOCH_NR 1000
\
struct tm *
ntp2unix_tm(
	u_long ntp, int local
	)
{
	time_t t, curr;
	struct tm *tm;
	int curr_year, epoch_nr;
\
	/* First get the current year: */
	curr = time(NULL);
	tm = local ? localtime(&curr) : gmtime(&curr);
	if (!tm) return NULL;
\
	curr_year = 1900 + tm->tm_year;
\
	/* Convert the ntp timestamp to a unix utc seconds count: */
	t = (time_t) ntp - JAN_1970;
\
	/* Check that the ntp timestamp is not before a 136 year window centered
	   around the current year:
\
	   Failsafe in case of an infinite loop:
       Allow up to 1000 epochs of 136 years each!
	*/
    for (epoch_nr = 0; epoch_nr < MAX_EPOCH_NR; epoch_nr++) {
		tm = local ? localtime(&t) : gmtime(&t);
\
		/* Check that the resulting year is in the correct epoch: */
		if (1900 + tm->tm_year > curr_year - 68) break;
\
		/* Epoch wraparound: Add 2^32 seconds! */
		t += (time_t) 65536 << 16;
	}
	return tm;
}
\
D32 1
I32 1
	sec = ts->l_ui;
D35 3
I37 7
	tm = ntp2unix_tm(sec, 1);
	if (!tm) {
		(void) sprintf(bp, "%08lx.%08lx  --- --- -- ---- --:--:--",
		       (u_long)ts->l_ui, (u_long)ts->l_uf);
	}
	else {
		(void) sprintf(bp, "%08lx.%08lx  %s, %s %2d %4d %2d:%02d:%02d.%03lu",
I40 1
	}
D57 1
I57 1
	sec = ts->l_ui;
D60 3
I62 7
	tm = ntp2unix_tm(sec, 0);
	if (!tm) {
		(void) sprintf(bp, "%08lx.%08lx  --- --- -- ---- --:--:--",
		       (u_long)ts->l_ui, (u_long)ts->l_uf);
	}
	else {
		(void) sprintf(bp, "%08lx.%08lx  %s, %s %2d %4d %2d:%02d:%02d.%03lu",
D66 1
I66 2
	}
\

# Patch checksum=06be87d8



More information about the bk-ntp-dev-send mailing list