1999-11-11 Harlan Stenn <stenn@whimsy.udel.edu>
+ * configure.in:
+ * ntpd/ntpd.c:
+ DEC OSF cleanup (editorial comments by HMS)
+ From: Tom Smith <smith@cag.lkg.dec.com>
+
+ * ntpd/ntp_refclock.c: MAXUNIT bugfix
+ From: Marc.Brett@westgeo.com
+
+ * ntpd/ntp_refclock.c:
+ * ntpd/ntpd.c:
+ * ntpd/refclock_arc.c:
+ * ntpd/refclock_as2201.c:
+ * ntpd/refclock_atom.c:
+ * ntpdc/ntpdc.c:
+ * ntpq/ntpq.c:
+ Code cleanup.
+ From: Marc.Brett@westgeo.com
+
+ * include/ntp_stdlib.h:
+ * libntp/systime.c:
+ * ntpd/ntp_proto.c:
+ Replaced the 'sco5_oldclock' variable with 'systime_10ms_ticks'.
+ Cleared libntp/systime.c and include/ntp_stdlib.h of references
+ to SCO5_CLOCK and RELIANTUNIX_CLOCK (moved to ntpd/ntp_proto.c).
+ From: Kamal A Mostafa <kamal@whence.com>
+
* configure.in: alpha-dec-osf4* -> alpha*-dec-osf4*|alpha*-dec-osf5*
From: Tom Smith <smith@cag.lkg.dec.com>
#endif
/* systime.c */
-#if defined SCO5_CLOCK
-extern int sco5_oldclock; /* runtime detection of new clock */
-#endif /* SCO5_CLOCK */
+extern int systime_10ms_ticks; /* adj sysclock in 10ms increments */
extern double sys_maxfreq; /* max frequency correction */
static long last_Adj = 0;
#endif
-#if defined SCO5_CLOCK
-int sco5_oldclock; /* runtime detection of new clock */
-#endif /* SCO5_CLOCK */
+int systime_10ms_ticks = 0; /* adj sysclock in 10ms increments */
#define MAXFREQ 500e-6
(void) GETTIMEOFDAY(&tv, (struct timezone *)0);
now->l_i = tv.tv_sec + JAN_1970;
-#if defined(SCO5_CLOCK) || defined(RELIANTUNIX_CLOCK)
-#if defined(SCO5_CLOCK)
- if (sco5_oldclock == 1) {
-#endif /* SCO5_CLOCK */
+ if (systime_10ms_ticks) {
/* fake better than 10ms resolution by interpolating
accumulated residual (in adj_systime(), see below) */
dtemp = tv.tv_usec / 1e6;
}
}
dtemp *= FRAC;
-#if defined(SCO5_CLOCK)
- }
- else /* HEY!!! Watch this "else" statement ... */
-#endif /* SCO5_CLOCK */
-#endif /* SCO5_CLOCK || RELIANTUNIX_CLOCK */
- { /* HEY!!! See that "else" statement up there??? */
+ } else {
dtemp = tv.tv_usec * FRAC / 1e6;
}
dtemp = -dtemp;
}
-#if defined(SCO5_CLOCK) || defined(RELIANTUNIX_CLOCK)
-#if defined(SCO5_CLOCK)
- if (sco5_oldclock == 1) {
-#endif /* SCO5_CLOCK */
+ if (systime_10ms_ticks) {
/* accumulate changes until we have enough to adjust a tick */
if (dtemp < 5000e-6) {
if (isneg) sys_residual = -dtemp;
else sys_residual = dtemp;
dtemp = 0;
- }
- else {
+ } else {
if (isneg) sys_residual = 10000e-6 - dtemp;
else sys_residual = dtemp - 10000e-6;
dtemp = 10000e-6;
}
-#if defined(SCO5_CLOCK)
- }
- else {
+ } else {
if (dtemp > sys_maxfreq)
dtemp = sys_maxfreq;
}
-#endif /* SCO5_CLOCK */
-#else /* SCO5_CLOCK || RELIANTUNIX_CLOCK */
- if (dtemp > sys_maxfreq)
- dtemp = sys_maxfreq;
-#endif /* SCO5_CLOCK */
#ifdef SYS_WINNT
dtemp = dtemp * 1000000.0;
#endif
msyslog(LOG_DEBUG, "kern_enable is %d", kern_enable);
stats_control = 1;
-#if defined SCO5_CLOCK
- if ((int) sys_precision < -10) {
- sco5_oldclock = 0;
- msyslog(LOG_INFO, "new SCO clock detected");
- }
- else {
- sco5_oldclock = 1;
- msyslog(LOG_INFO, "old SCO clock; using ntp patches");
- }
-#endif /* SCO5_CLOCK */
+ /*
+ * Some system clocks should only be adjusted in 10ms increments.
+ */
+#if defined RELIANTUNIX_CLOCK
+ systime_10ms_ticks = 1; /* Reliant UNIX */
+#elif defined SCO5_CLOCK
+ if (sys_precision >= (s_char)-10) /* pre- SCO OpenServer 5.0.6 */
+ systime_10ms_ticks = 1;
+#endif
+ if (systime_10ms_ticks)
+ msyslog(LOG_INFO, "using 10ms tick adjustments");
}
}
clktype = (u_char)REFCLOCKTYPE(&peer->srcadr);
unit = REFCLOCKUNIT(&peer->srcadr);
- if (clktype >= num_refclock_conf || unit > MAXUNIT ||
+ if (clktype >= num_refclock_conf || unit >= MAXUNIT ||
refclock_conf[clktype]->clock_start == noentry) {
msyslog(LOG_ERR,
"refclock_newpeer: clock type %d invalid\n",
struct peer *peer /* peer structure pointer */
)
{
- struct refclockproc *pp;
u_char clktype;
int unit;
int hpoll;
u_long next;
- pp = peer->procptr;
clktype = peer->refclktype;
unit = peer->refclkunit;
peer->sent++;
return;
clktype = (u_char)REFCLOCKTYPE(srcadr);
unit = REFCLOCKUNIT(srcadr);
- if (clktype >= num_refclock_conf || unit > MAXUNIT)
+ if (clktype >= num_refclock_conf || unit >= MAXUNIT)
return;
if (!(peer = typeunit[clktype][unit]))
return;
return;
clktype = (u_char) REFCLOCKTYPE(srcadr);
unit = REFCLOCKUNIT(srcadr);
- if (clktype >= num_refclock_conf || unit > MAXUNIT)
+ if (clktype >= num_refclock_conf || unit >= MAXUNIT)
return;
if (!(peer = typeunit[clktype][unit]))
return;
*/
}
# endif /* HAVE_IO_COMPLETION_PORT */
- exit(0);
+ exit(1); /* unreachable */
+ return 1; /* DEC OSF cc braindamage */
}
struct peer *peer;
char c;
int i, n, wday, month, bst, status;
- int last_offset;
+ int arc_last_offset;
/*
* Initialize pointers and read the timecode and timestamp
}
/*
- The `last_offset' is the offset in lastcode[] of the last byte
+ The `arc_last_offset' is the offset in lastcode[] of the last byte
received, and which we assume actually received the input
timestamp.
trailing \r, and that that \r will be timestamped. But this
assumption also works if receive the characters one-by-one.)
*/
- last_offset = pp->lencode+rbufp->recv_length - 1;
+ arc_last_offset = pp->lencode+rbufp->recv_length - 1;
/*
We catch a timestamp iff:
(pp->lencode == 1) &&
#endif
((pp->lencode != 1) || (c != '\r')) &&
- (last_offset >= 1)) {
+ (arc_last_offset >= 1)) {
/* Note that the timestamp should be corrected if >1 char rcvd. */
l_fp timestamp;
timestamp = rbufp->recv_time;
allow for the trailing \r, normally not used but a good
handle for tty_clk or somesuch kernel timestamper.
*/
- if(last_offset > LENARC) {
+ if(arc_last_offset > LENARC) {
#ifdef ARCRON_DEBUG
if(debug) {
printf("arc: input code too long (%d cf %d); rejected.\n",
- last_offset, LENARC);
+ arc_last_offset, LENARC);
}
#endif
pp->lencode = 0;
return;
}
- L_SUBUF(×tamp, charoffsets[last_offset]);
+ L_SUBUF(×tamp, charoffsets[arc_last_offset]);
#ifdef ARCRON_DEBUG
if(debug > 1) {
printf(
"arc: %s%d char(s) rcvd, the last for lastcode[%d]; -%sms offset applied.\n",
((rbufp->recv_length > 1) ? "*** " : ""),
rbufp->recv_length,
- last_offset,
+ arc_last_offset,
mfptoms((unsigned long)0,
- charoffsets[last_offset],
+ charoffsets[arc_last_offset],
1));
}
#endif
struct peer *peer
)
{
- register struct as2201unit *up;
struct refclockproc *pp;
/*
* eavesdropper watching the radio.
*/
pp = peer->procptr;
- up = (struct as2201unit *)pp->unitptr;
if (write(pp->io.fd, "\r*toc\r", 6) != 6) {
refclock_report(peer, CEVNT_FAULT);
} else {
struct peer *peer
)
{
+#if defined(PPS) || defined(HAVE_PPSAPI)
register struct atomunit *up;
+#endif /* PPS || HAVE_PPSAPI */
struct refclockproc *pp;
/*
* samples.
*/
pp = peer->procptr;
- up = (struct atomunit *)pp->unitptr;
#if defined(PPS) || defined(HAVE_PPSAPI)
+ up = (struct atomunit *)pp->unitptr;
if (!(up->flags & !(FLAG_AUX | FLAG_TTY))) {
int err;
*/
static int
getnetnum(
- const char *host,
+ const char *hname,
u_int32 *num,
char *fullhost
)
{
struct hostent *hp;
- if (decodenetnum(host, num)) {
+ if (decodenetnum(hname, num)) {
if (fullhost != 0) {
(void) sprintf(fullhost,
"%u.%u.%u.%u", (u_int)((htonl(*num)>>24)&0xff),
(u_int)(htonl(*num)&0xff));
}
return 1;
- } else if ((hp = gethostbyname(host)) != 0) {
+ } else if ((hp = gethostbyname(hname)) != 0) {
memmove((char *)num, hp->h_addr, sizeof(u_int32));
if (fullhost != 0)
(void) strcpy(fullhost, hp->h_name);
return 1;
} else {
- (void) fprintf(stderr, "***Can't find host %s\n", host);
+ (void) fprintf(stderr, "***Can't find host %s\n", hname);
return 0;
}
/*NOTREACHED*/
*/
static u_long
getkeyid(
- const char *prompt
+ const char *keyprompt
)
{
register char *p;
fi = stdin;
else
setbuf(fi, (char *)NULL);
- fprintf(stderr, "%s", prompt); fflush(stderr);
+ fprintf(stderr, "%s", keyprompt); fflush(stderr);
for (p=pbuf; (c = getc(fi))!='\n' && c!=EOF;) {
if (p < &pbuf[18])
*p++ = c;
*/
int
getnetnum(
- const char *host,
+ const char *hname,
u_int32 *num,
char *fullhost
)
{
struct hostent *hp;
- if (decodenetnum(host, num)) {
+ if (decodenetnum(hname, num)) {
if (fullhost != 0) {
(void) sprintf(fullhost, "%lu.%lu.%lu.%lu",
(u_long)((htonl(*num) >> 24) & 0xff),
(u_long)(htonl(*num) & 0xff));
}
return 1;
- } else if ((hp = gethostbyname(host)) != 0) {
+ } else if ((hp = gethostbyname(hname)) != 0) {
memmove((char *)num, hp->h_addr, sizeof(u_int32));
if (fullhost != 0)
(void) strcpy(fullhost, hp->h_name);
return 1;
} else {
- (void) fprintf(stderr, "***Can't find host %s\n", host);
+ (void) fprintf(stderr, "***Can't find host %s\n", hname);
return 0;
}
/*NOTREACHED*/
*/
static u_long
getkeyid(
- const char *prompt
+ const char *keyprompt
)
{
register char *p;
fi = stdin;
else
setbuf(fi, (char *)NULL);
- fprintf(stderr, "%s", prompt); fflush(stderr);
+ fprintf(stderr, "%s", keyprompt); fflush(stderr);
for (p=pbuf; (c = getc(fi))!='\n' && c!=EOF;) {
if (p < &pbuf[18])
*p++ = c;