Code cleanup; remove all `#ifdef sgi' from the code... this clobbered the

code considerably and was mainly providing SGI specific logging facilities
and some hacks to improve the relyablility on SGI systems by increasing
priorities etc...
This commit is contained in:
reinoud 2001-09-02 00:13:05 +00:00
parent 0414d16837
commit ec98fbc0db
16 changed files with 32 additions and 438 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: acksend.c,v 1.5 1997/10/17 14:19:09 lukem Exp $ */
/* $NetBSD: acksend.c,v 1.6 2001/09/02 00:13:05 reinoud Exp $ */
/*-
* Copyright (c) 1985, 1993 The Regents of the University of California.
@ -38,14 +38,10 @@
#if 0
static char sccsid[] = "@(#)acksend.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: acksend.c,v 1.5 1997/10/17 14:19:09 lukem Exp $");
__RCSID("$NetBSD: acksend.c,v 1.6 2001/09/02 00:13:05 reinoud Exp $");
#endif
#endif /* not lint */
#ifdef sgi
#ident "$Revision: 1.5 $"
#endif
#include "globals.h"

View File

@ -36,14 +36,10 @@
#if 0
static char sccsid[] = "@(#)byteorder.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: byteorder.c,v 1.5 1997/10/17 14:19:12 lukem Exp $");
__RCSID("$NetBSD: byteorder.c,v 1.6 2001/09/02 00:13:05 reinoud Exp $");
#endif
#endif /* not lint */
#ifdef sgi
#ident "$Revision: 1.5 $"
#endif
#include "globals.h"
/*

View File

@ -36,14 +36,10 @@
#if 0
static char sccsid[] = "@(#)candidate.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: candidate.c,v 1.6 1997/10/17 14:19:17 lukem Exp $");
__RCSID("$NetBSD: candidate.c,v 1.7 2001/09/02 00:13:05 reinoud Exp $");
#endif
#endif /* not lint */
#ifdef sgi
#ident "$Revision: 1.6 $"
#endif
#include "globals.h"
/*

View File

@ -36,14 +36,10 @@
#if 0
static char sccsid[] = "@(#)cksum.c 5.2 (Berkeley) 5/11/93";
#else
__RCSID("$NetBSD: cksum.c,v 1.2 1997/10/17 14:19:20 lukem Exp $");
__RCSID("$NetBSD: cksum.c,v 1.3 2001/09/02 00:13:06 reinoud Exp $");
#endif
#endif /* not lint */
#ifdef sgi
#ident "$Revision: 1.2 $"
#endif
#include <sys/types.h>
#include "globals.h"

View File

@ -1,4 +1,4 @@
/* $NetBSD: correct.c,v 1.8 1997/10/17 14:19:23 lukem Exp $ */
/* $NetBSD: correct.c,v 1.9 2001/09/02 00:13:06 reinoud Exp $ */
/*-
* Copyright (c) 1985, 1993 The Regents of the University of California.
@ -38,21 +38,14 @@
#if 0
static char sccsid[] = "@(#)correct.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: correct.c,v 1.8 1997/10/17 14:19:23 lukem Exp $");
__RCSID("$NetBSD: correct.c,v 1.9 2001/09/02 00:13:06 reinoud Exp $");
#endif
#endif /* not lint */
#ifdef sgi
#ident "$Revision: 1.8 $"
#endif
#include "globals.h"
#include <math.h>
#include <sys/types.h>
#include <sys/times.h>
#ifdef sgi
#include <sys/syssgi.h>
#endif /* sgi */
static void adjclock(struct timeval*);
@ -181,105 +174,6 @@ adjclock(struct timeval *corr)
if (settimeofday(&now, 0) < 0)
syslog(LOG_ERR, "settimeofday: %m");
}
#ifdef sgi
/* Accumulate the total change, and use it to adjust the basic
* clock rate.
*/
if (++passes > 2) {
#define F_USEC_PER_SEC (1000000*1.0) /* reduce typos */
#define F_NSEC_PER_SEC (F_USEC_PER_SEC*1000.0)
extern char *timetrim_fn;
extern char *timetrim_wpat;
extern long timetrim;
extern double tot_adj, hr_adj; /* totals in nsec */
extern double tot_ticks, hr_ticks;
static double nag_tick;
double cur_ticks, hr_delta_ticks, tot_delta_ticks;
double tru_tot_adj, tru_hr_adj; /* nsecs of adjustment */
double tot_trim, hr_trim; /* nsec/sec */
struct tms tm;
FILE *timetrim_st;
cur_ticks = times(&tm);
tot_adj += delta*1000.0;
hr_adj += delta*1000.0;
tot_delta_ticks = cur_ticks-tot_ticks;
if (tot_delta_ticks >= 16*SECDAY*CLK_TCK) {
tot_adj -= rint(tot_adj/16);
tot_ticks += rint(tot_delta_ticks/16);
tot_delta_ticks = cur_ticks-tot_ticks;
}
hr_delta_ticks = cur_ticks-hr_ticks;
tru_hr_adj = hr_adj + timetrim*rint(hr_delta_ticks/CLK_TCK);
tru_tot_adj = (tot_adj
+ timetrim*rint(tot_delta_ticks/CLK_TCK));
if (hr_delta_ticks >= SECDAY*CLK_TCK
|| (tot_delta_ticks < 4*SECDAY*CLK_TCK
&& hr_delta_ticks >= SECHR*CLK_TCK)
|| (trace && hr_delta_ticks >= (SECHR/10)*CLK_TCK)) {
tot_trim = rint(tru_tot_adj*CLK_TCK/tot_delta_ticks);
hr_trim = rint(tru_hr_adj*CLK_TCK/hr_delta_ticks);
if (trace
|| (abs(timetrim - hr_trim) > 100000.0
&& 0 == timetrim_fn
&& ((cur_ticks - nag_tick)
>= 24*SECDAY*CLK_TCK))) {
nag_tick = cur_ticks;
syslog(LOG_NOTICE,
"%+.3f/%.2f or %+.3f/%.2f sec/hr; timetrim=%+.0f or %+.0f",
tru_tot_adj/F_NSEC_PER_SEC,
tot_delta_ticks/(SECHR*CLK_TCK*1.0),
tru_hr_adj/F_NSEC_PER_SEC,
hr_delta_ticks/(SECHR*CLK_TCK*1.0),
tot_trim,
hr_trim);
}
if (tot_trim < -MAX_TRIM || tot_trim > MAX_TRIM) {
tot_ticks = hr_ticks;
tot_adj = hr_adj;
} else if (0 > syssgi(SGI_SETTIMETRIM,
(long)tot_trim)) {
syslog(LOG_ERR, "SETTIMETRIM(%d): %m",
(long)tot_trim);
} else {
if (0 != timetrim_fn) {
timetrim_st = fopen(timetrim_fn, "w");
if (0 == timetrim_st) {
syslog(LOG_ERR, "fopen(%s): %m",
timetrim_fn);
} else {
if (0 > fprintf(timetrim_st,
timetrim_wpat,
(long)tot_trim,
tru_tot_adj,
tot_delta_ticks)) {
syslog(LOG_ERR,
"fprintf(%s): %m",
timetrim_fn);
}
(void)fclose(timetrim_st);
}
}
tot_adj -= ((tot_trim - timetrim)
* rint(tot_delta_ticks/CLK_TCK));
timetrim = tot_trim;
}
hr_ticks = cur_ticks;
hr_adj = 0;
}
}
#endif /* sgi */
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: globals.h,v 1.6 2001/03/07 21:46:04 garbled Exp $ */
/* $NetBSD: globals.h,v 1.7 2001/09/02 00:13:06 reinoud Exp $ */
/*-
* Copyright (c) 1985 The Regents of the University of California.
@ -35,10 +35,6 @@
* @(#)globals.h 8.1 (Berkeley) 6/6/93
*/
#ifdef sgi
#ident "$Revision: 1.6 $"
#endif
#include <sys/param.h>
#include <sys/time.h>
#include <sys/socket.h>
@ -57,16 +53,8 @@
#include <unistd.h>
#include <protocols/timed.h>
#ifdef sgi
#include <bstring.h>
#include <sys/clock.h>
/* use the constant HZ instead of the function CLK_TCK */
#undef CLK_TCK
#define CLK_TCK HZ
#else
#define SECHR (60*60)
#define SECDAY (24*SECHR)
#endif /* sgi */
extern int sock;

View File

@ -1,4 +1,4 @@
/* $NetBSD: master.c,v 1.8 1997/10/17 14:19:26 lukem Exp $ */
/* $NetBSD: master.c,v 1.9 2001/09/02 00:13:06 reinoud Exp $ */
/*-
* Copyright (c) 1985, 1993 The Regents of the University of California.
@ -38,25 +38,16 @@
#if 0
static char sccsid[] = "@(#)master.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: master.c,v 1.8 1997/10/17 14:19:26 lukem Exp $");
__RCSID("$NetBSD: master.c,v 1.9 2001/09/02 00:13:06 reinoud Exp $");
#endif
#endif /* not lint */
#ifdef sgi
#ident "$Revision: 1.8 $"
#endif
#include "globals.h"
#include <sys/file.h>
#include <sys/types.h>
#include <sys/times.h>
#include <setjmp.h>
#ifdef sgi
#include <sys/schedctl.h>
#include <utmpx.h> /* includes utmp.h */
#else
#include <utmp.h>
#endif /* sgi */
#include "pathnames.h"
@ -70,12 +61,7 @@ static int slvcount; /* slaves listening to our clock */
static void mchgdate(struct tsp*);
#ifdef sgi
extern void getutmpx(const struct utmp *, struct utmpx *);
extern void logwtmp(struct timeval*, struct timeval*);
#else
extern void logwtmp __P((char *, char *, char *));
#endif /* sgi */
@ -190,12 +176,8 @@ loop:
/*
* XXX check to see it is from ourself
*/
#ifdef sgi
(void)cftime(newdate, "%D %T", &msg->tsp_time.tv_sec);
#else
tmpt = msg->tsp_time.tv_sec;
(void)strcpy(newdate, ctime(&tmpt));
#endif /* sgi */
if (!good_host_name(msg->tsp_name)) {
syslog(LOG_NOTICE,
"attempted date change by %s to %s",
@ -212,12 +194,9 @@ loop:
case TSP_SETDATEREQ:
if (!fromnet || fromnet->status != MASTER)
break;
#ifdef sgi
(void)cftime(newdate, "%D %T", &msg->tsp_time.tv_sec);
#else
tmpt = msg->tsp_time.tv_sec;
(void)strcpy(newdate, ctime(&tmpt));
#endif /* sgi */
htp = findhost(msg->tsp_name);
if (htp == 0) {
syslog(LOG_ERR,
@ -397,18 +376,11 @@ mchgdate(struct tsp *msg)
dictate = 3;
synch(tvtomsround(ntime));
} else {
#ifdef sgi
if (0 > settimeofday(&msg->tsp_time, 0)) {
syslog(LOG_ERR, "settimeofday(): %m");
}
logwtmp(&otime, &msg->tsp_time);
#else
logwtmp("|", "date", "");
tmptv.tv_sec = msg->tsp_time.tv_sec;
tmptv.tv_usec = msg->tsp_time.tv_usec;
(void)settimeofday(&tmptv, 0);
logwtmp("}", "date", "");
#endif /* sgi */
spreadtime();
}
@ -426,20 +398,11 @@ synch(long mydelta)
struct hosttbl *htp;
int measure_status;
struct timeval check, stop, wait;
#ifdef sgi
int pri;
#endif /* sgi */
if (slvcount > 0) {
if (trace)
fprintf(fd, "measurements starting at %s\n", date());
(void)gettimeofday(&check, 0);
#ifdef sgi
/* run fast to get good time */
pri = schedctl(NDPRI,0,NDPHIMIN);
if (pri < 0)
syslog(LOG_ERR, "schedctl(): %m");
#endif /* sgi */
for (htp = self.l_fwd; htp != &self; htp = htp->l_fwd) {
if (htp->noanswer != 0) {
measure_status = measure(500, 100,
@ -483,10 +446,6 @@ synch(long mydelta)
(void)gettimeofday(&check, 0);
}
}
#ifdef sgi
if (pri >= 0)
(void)schedctl(NDPRI,0,pri);
#endif /* sgi */
if (trace)
fprintf(fd, "measurements finished at %s\n", date());
}
@ -889,42 +848,3 @@ traceoff(char *msg)
trace = OFF;
}
#ifdef sgi
void
logwtmp(struct timeval *otime, struct timeval *ntime)
{
static struct utmp wtmp[2] = {
{"","",OTIME_MSG,0,OLD_TIME,0,0,0},
{"","",NTIME_MSG,0,NEW_TIME,0,0,0}
};
static char *wtmpfile = WTMP_FILE;
static struct utmpx wtmpx[2];
int f;
wtmp[0].ut_time = otime->tv_sec + (otime->tv_usec + 500000) / 1000000;
wtmp[1].ut_time = ntime->tv_sec + (ntime->tv_usec + 500000) / 1000000;
if (wtmp[0].ut_time == wtmp[1].ut_time)
return;
setutent();
(void)pututline(&wtmp[0]);
(void)pututline(&wtmp[1]);
endutent();
if ((f = open(wtmpfile, O_WRONLY|O_APPEND)) >= 0) {
(void)write(f, (char *)wtmp, sizeof(wtmp));
(void)close(f);
}
/*
* convert the wtmp entries into utmpx format in wtmpx[0..1]
* and append to /var/adm/wtmpx to keep wtmp and wtmpx in sync.
*/
getutmpx(&wtmp[0], &wtmpx[0]);
getutmpx(&wtmp[1], &wtmpx[1]);
if ((f = open(WTMPX_FILE, O_WRONLY|O_APPEND)) >= 0) {
(void)write(f, (char *)wtmpx, sizeof(wtmpx));
(void)close(f);
}
}
#endif /* sgi */

View File

@ -1,4 +1,4 @@
/* $NetBSD: measure.c,v 1.7 1997/10/17 14:19:29 lukem Exp $ */
/* $NetBSD: measure.c,v 1.8 2001/09/02 00:13:06 reinoud Exp $ */
/*-
* Copyright (c) 1985, 1993 The Regents of the University of California.
@ -38,14 +38,10 @@
#if 0
static char sccsid[] = "@(#)measure.c 8.2 (Berkeley) 3/26/95";
#else
__RCSID("$NetBSD: measure.c,v 1.7 1997/10/17 14:19:29 lukem Exp $");
__RCSID("$NetBSD: measure.c,v 1.8 2001/09/02 00:13:06 reinoud Exp $");
#endif
#endif /* not lint */
#ifdef sgi
#ident "$Revision: 1.7 $"
#endif
#include "globals.h"
#include <netinet/in_systm.h>
#include <netinet/ip.h>
@ -140,10 +136,6 @@ measure(u_long maxmsec, /* wait this many msec at most */
FD_ZERO(&ready);
#ifdef sgi
sginap(1); /* start at a clock tick */
#endif /* sgi */
(void)gettimeofday(&tdone, 0);
mstotvround(&tout, maxmsec);
timeradd(&tdone, &tout, &tdone); /* when we give up */
@ -310,13 +302,12 @@ quit:
void
mstotvround(struct timeval *res, long x)
{
#ifndef sgi
if (x < 0)
x = -((-x + 3)/5);
else
x = (x+3)/5;
x *= 5;
#endif /* sgi */
res->tv_sec = x/1000;
res->tv_usec = (x-res->tv_sec*1000)*1000;
if (res->tv_usec < 0) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: networkdelta.c,v 1.8 1997/10/20 18:42:17 drochner Exp $ */
/* $NetBSD: networkdelta.c,v 1.9 2001/09/02 00:13:06 reinoud Exp $ */
/*-
* Copyright (c) 1985, 1993 The Regents of the University of California.
@ -38,14 +38,10 @@
#if 0
static char sccsid[] = "@(#)networkdelta.c 8.3 (Berkeley) 4/27/95";
#else
__RCSID("$NetBSD: networkdelta.c,v 1.8 1997/10/20 18:42:17 drochner Exp $");
__RCSID("$NetBSD: networkdelta.c,v 1.9 2001/09/02 00:13:06 reinoud Exp $");
#endif
#endif /* not lint */
#ifdef sgi
#ident "$Revision: 1.8 $"
#endif
#include "globals.h"
static long median(float, float*, long*, long*, unsigned int);

View File

@ -1,4 +1,4 @@
/* $NetBSD: pathnames.h,v 1.5 1998/01/09 08:12:05 perry Exp $ */
/* $NetBSD: pathnames.h,v 1.6 2001/09/02 00:13:06 reinoud Exp $ */
/*-
* Copyright (c) 1985 The Regents of the University of California.
@ -37,10 +37,5 @@
#include <paths.h>
#ifdef sgi
#define _PATH_MASTERLOG "/var/adm/timed.masterlog"
#define _PATH_TIMEDLOG "/var/adm/timed.log"
#else
#define _PATH_MASTERLOG "/var/log/timed.masterlog"
#define _PATH_TIMEDLOG "/var/log/timed.log"
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: readmsg.c,v 1.10 2001/03/13 00:14:39 itojun Exp $ */
/* $NetBSD: readmsg.c,v 1.11 2001/09/02 00:13:07 reinoud Exp $ */
/*-
* Copyright (c) 1985, 1993 The Regents of the University of California.
@ -38,14 +38,10 @@
#if 0
static char sccsid[] = "@(#)readmsg.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: readmsg.c,v 1.10 2001/03/13 00:14:39 itojun Exp $");
__RCSID("$NetBSD: readmsg.c,v 1.11 2001/09/02 00:13:07 reinoud Exp $");
#endif
#endif /* not lint */
#ifdef sgi
#ident "$Revision: 1.10 $"
#endif
#include "globals.h"
extern char *tsptype[];
@ -478,13 +474,9 @@ struct sockaddr_in *addr;
case TSP_SETTIME:
case TSP_SETDATE:
case TSP_SETDATEREQ:
#ifdef sgi
(void)cftime(tm, "%D %T", &msg->tsp_time.tv_sec);
#else
msgtime = msg->tsp_time.tv_sec;
strncpy(tm, ctime(&msgtime)+3+1, sizeof(tm));
tm[15] = '\0'; /* ugh */
#endif /* sgi */
fprintf(fd, "%s %d %-6u %s %-15s %s\n",
tsptype[msg->tsp_type],
msg->tsp_vers,

View File

@ -1,4 +1,4 @@
/* $NetBSD: slave.c,v 1.8 1997/10/17 14:19:40 lukem Exp $ */
/* $NetBSD: slave.c,v 1.9 2001/09/02 00:13:07 reinoud Exp $ */
/*-
* Copyright (c) 1985, 1993 The Regents of the University of California.
@ -38,14 +38,10 @@
#if 0
static char sccsid[] = "@(#)slave.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: slave.c,v 1.8 1997/10/17 14:19:40 lukem Exp $");
__RCSID("$NetBSD: slave.c,v 1.9 2001/09/02 00:13:07 reinoud Exp $");
#endif
#endif /* not lint */
#ifdef sgi
#ident "$Revision: 1.8 $"
#endif
#include "globals.h"
#include <setjmp.h>
#include "pathnames.h"
@ -64,11 +60,8 @@ static void schgdate(struct tsp *, char *);
static void setmaster(struct tsp *);
static void answerdelay(void);
#ifdef sgi
extern void logwtmp(struct timeval *, struct timeval *);
#else
extern void logwtmp(char *, char *, char *);
#endif /* sgi */
int
slave()
@ -264,10 +257,7 @@ loop:
/* adjust time for residence on the queue */
(void)gettimeofday(&otime, 0);
adj_msg_time(msg,&otime);
#ifdef sgi
(void)cftime(newdate, "%D %T", &msg->tsp_time.tv_sec);
(void)cftime(olddate, "%D %T", &otime.tv_sec);
#else
/*
* the following line is necessary due to syslog
* calling ctime() which clobbers the static buffer
@ -275,7 +265,6 @@ loop:
(void)strcpy(olddate, date());
tmpt = msg->tsp_time.tv_sec;
(void)strcpy(newdate, ctime(&tmpt));
#endif /* sgi */
if (!good_host_name(msg->tsp_name)) {
syslog(LOG_NOTICE,
@ -293,19 +282,12 @@ loop:
*/
synch(tvtomsround(ntime));
} else {
#ifdef sgi
if (0 > settimeofday(&msg->tsp_time, 0)) {
syslog(LOG_ERR,"settimeofdate(): %m");
break;
}
logwtmp(&otime, &msg->tsp_time);
#else
logwtmp("|", "date", "");
tmptv.tv_sec = msg->tsp_time.tv_sec;
tmptv.tv_usec = msg->tsp_time.tv_usec;
(void)settimeofday(&tmptv, 0);
logwtmp("}", "date", "");
#endif /* sgi */
syslog(LOG_NOTICE,
"date changed by %s from %s",
msg->tsp_name, olddate);
@ -364,24 +346,16 @@ loop:
break;
case TSP_SETDATE:
#ifdef sgi
(void)cftime(newdate, "%D %T", &msg->tsp_time.tv_sec);
#else
tmpt = msg->tsp_time.tv_sec;
(void)strcpy(newdate, ctime(&tmpt));
#endif /* sgi */
schgdate(msg, newdate);
break;
case TSP_SETDATEREQ:
if (fromnet->status != MASTER)
break;
#ifdef sgi
(void)cftime(newdate, "%D %T", &msg->tsp_time.tv_sec);
#else
tmpt = msg->tsp_time.tv_sec;
(void)strcpy(newdate, ctime(&tmpt));
#endif /* sgi */
htp = findhost(msg->tsp_name);
if (0 == htp) {
syslog(LOG_WARNING,
@ -709,9 +683,6 @@ schgdate(struct tsp *msg, char *newdate)
static void
answerdelay(void)
{
#ifdef sgi
sginap(delay1);
#else
struct timeval timeout;
timeout.tv_sec = 0;
@ -720,5 +691,4 @@ answerdelay(void)
(void)select(0, (fd_set *)NULL, (fd_set *)NULL, (fd_set *)NULL,
&timeout);
return;
#endif /* sgi */
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: timed.c,v 1.12 2001/01/11 02:46:43 lukem Exp $ */
/* $NetBSD: timed.c,v 1.13 2001/09/02 00:13:07 reinoud Exp $ */
/*-
* Copyright (c) 1985, 1993 The Regents of the University of California.
@ -44,14 +44,10 @@ __COPYRIGHT(
#if 0
static char sccsid[] = "@(#)timed.c 8.2 (Berkeley) 3/26/95";
#else
__RCSID("$NetBSD: timed.c,v 1.12 2001/01/11 02:46:43 lukem Exp $");
__RCSID("$NetBSD: timed.c,v 1.13 2001/09/02 00:13:07 reinoud Exp $");
#endif
#endif /* not lint */
#ifdef sgi
#ident "$Revision: 1.12 $"
#endif /* sgi */
#define TSPTYPES
#include "globals.h"
#include <net/if.h>
@ -62,11 +58,6 @@ __RCSID("$NetBSD: timed.c,v 1.12 2001/01/11 02:46:43 lukem Exp $");
#include <math.h>
#include <sys/types.h>
#include <sys/times.h>
#ifdef sgi
#include <unistd.h>
#include <sys/syssgi.h>
#include <sys/schedctl.h>
#endif /* sgi */
#include <util.h>
int trace = 0;
@ -110,17 +101,6 @@ static void checkignorednets(void);
static void pickslavenet(struct netinfo *);
static void add_good_host(char*,char);
#ifdef sgi
char *timetrim_fn;
char *timetrim_wpat = "long timetrim = %ld;\ndouble tot_adj = %.0f;\ndouble tot_ticks = %.0f;\n/* timed version 2 */\n";
char *timetrim_rpat = "long timetrim = %ld;\ndouble tot_adj = %lf;\ndouble tot_ticks = %lf;";
long timetrim;
double tot_adj, hr_adj; /* totals in nsec */
double tot_ticks, hr_ticks;
int bufspace = 60*1024;
#endif
/*
* The timedaemons synchronize the clocks of hosts in a local area network.
@ -134,9 +114,8 @@ int bufspace = 60*1024;
* network partition is fixed.
*
* Authors: Riccardo Gusella & Stefano Zatti
*
* overhauled at Silicon Graphics
*/
int
main(int argc, char **argv)
{
@ -158,21 +137,13 @@ main(int argc, char **argv)
int c;
extern char *optarg;
extern int optind, opterr;
#ifdef sgi
FILE *timetrim_st;
#endif
#define IN_MSG "timed: -i and -n make no sense together\n"
#ifdef sgi
struct tms tms;
#define USAGE "timed: [-dtM] [-i net|-n net] [-F host1 host2 ...] [-G netgp] [-P trimfile]\n"
#else
#ifdef HAVENIS
#define USAGE "timed: [-dtM] [-i net|-n net] [-F host1 host2 ...] [-G netgp]\n"
#else
#define USAGE "timed: [-dtM] [-i net|-n net] [-F host1 host2 ...]\n"
#endif /* HAVENIS */
#endif /* sgi */
ntip = NULL;
@ -180,14 +151,6 @@ main(int argc, char **argv)
nflag = OFF;
iflag = OFF;
#ifdef sgi
if (0 > syssgi(SGI_GETTIMETRIM, &timetrim)) {
perror("timed: syssgi(GETTIMETRIM)");
timetrim = 0;
}
tot_ticks = hr_ticks = times(&tms);
#endif /* sgi */
opterr = 0;
while ((c = getopt(argc, argv, "Mtdn:i:F:G:P:")) != -1) {
switch (c) {
@ -235,12 +198,6 @@ main(int argc, char **argv)
}
goodgroup = optarg;
break;
#ifdef sgi
case 'P':
timetrim_fn = optarg;
break;
#endif /* sgi */
default:
fprintf(stderr, USAGE);
exit(1);
@ -252,46 +209,6 @@ main(int argc, char **argv)
exit(1);
}
#ifdef sgi
if (timetrim_fn == 0) {
;
} else if (0 == (timetrim_st = fopen(timetrim_fn, "r+"))) {
if (errno != ENOENT) {
(void)fprintf(stderr,"timed: ");
perror(timetrim_fn);
timetrim_fn = 0;
}
} else {
int i;
long trim;
double adj, ticks;
i = fscanf(timetrim_st, timetrim_rpat,
&trim, &adj, &ticks);
if (i < 1
|| trim > MAX_TRIM
|| trim < -MAX_TRIM
|| i == 2
|| (i == 3
&& trim != rint(adj*CLK_TCK/ticks))) {
if (trace && i != EOF)
(void)fprintf(stderr,
"timed: unrecognized contents in %s\n",
timetrim_fn);
} else {
if (0 > syssgi(SGI_SETTIMETRIM,
trim)) {
perror("timed: syssgi(SETTIMETRIM)");
} else {
timetrim = trim;
}
if (i == 3)
tot_ticks -= ticks;
}
(void)fclose(timetrim_st);
}
#endif /* sgi */
/* If we care about which machine is the master, then we must
* be willing to be a master
*/
@ -339,16 +256,6 @@ main(int argc, char **argv)
perror("bind");
exit(1);
}
#ifdef sgi
/*
* handle many slaves with our buffer
*/
if (0 > setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (char*)&bufspace,
sizeof(bufspace))) {
perror("setsockopt");
exit(1);
}
#endif /* sgi */
/* choose a unique seed for random number generation */
(void)gettimeofday(&ntime, 0);
@ -356,12 +263,10 @@ main(int argc, char **argv)
sequence = random(); /* initial seq number */
#ifndef sgi
/* rounds kernel variable time to multiple of 5 ms. */
ntime.tv_sec = 0;
ntime.tv_usec = -((ntime.tv_usec/1000) % 5) * 1000;
(void)adjtime(&ntime, (struct timeval *)0);
#endif /* sgi */
for (nt = nets; nt; nt = nt->next) {
nentp = getnetbyname(nt->name);
@ -398,11 +303,7 @@ main(int argc, char **argv)
exit(1);
}
ntp = NULL;
#ifdef sgi
#define size(p) (sizeof(*ifr) - sizeof(ifr->ifr_name)) /* XXX hack. kludge */
#else
#define size(p) max((p).sa_len, sizeof(p))
#endif
cplim = buf + ifc.ifc_len; /*skip over if's with big ifr_addr's */
for (cp = buf; cp < cplim;
cp += sizeof (ifr->ifr_name) + size(ifr->ifr_addr)) {
@ -482,29 +383,17 @@ main(int argc, char **argv)
}
#ifdef sgi
(void)schedctl(RENICE,0,10); /* run fast to get good time */
/* ticks to delay before responding to a broadcast */
delay1 = casual(0, CLK_TCK/10);
#else
/* microseconds to delay before responding to a broadcast */
delay1 = casual(1, 100*1000);
#endif /* sgi */
/* election timer delay in secs. */
delay2 = casual(MINTOUT, MAXTOUT);
#ifdef sgi
(void)_daemonize(debug ? _DF_NOFORK|_DF_NOCHDIR : 0, sock, -1, -1);
#else
if (!debug) {
daemon(debug, 0);
pidfile(NULL);
}
#endif /* sgi */
if (trace)
traceon();
@ -831,21 +720,12 @@ casual(long inf, long sup)
char *
date()
{
#ifdef sgi
struct timeval tv;
static char tm[32];
(void)gettimeofday(&tv, (struct timezone *)0);
(void)cftime(tm, "%D %T", &tv.tv_sec);
return (tm);
#else
struct timeval tv;
time_t t;
(void)gettimeofday(&tv, (struct timezone *)0);
t = tv.tv_sec;
return (ctime(&t));
#endif /* sgi */
}
void

View File

@ -1,4 +1,4 @@
/* $NetBSD: cmds.c,v 1.9 1998/07/06 07:06:14 mrg Exp $ */
/* $NetBSD: cmds.c,v 1.10 2001/09/02 00:13:08 reinoud Exp $ */
/*-
* Copyright (c) 1985, 1993 The Regents of the University of California.
@ -38,14 +38,10 @@
#if 0
static char sccsid[] = "@(#)cmds.c 8.2 (Berkeley) 3/26/95";
#else
__RCSID("$NetBSD: cmds.c,v 1.9 1998/07/06 07:06:14 mrg Exp $");
__RCSID("$NetBSD: cmds.c,v 1.10 2001/09/02 00:13:08 reinoud Exp $");
#endif
#endif /* not lint */
#ifdef sgi
#ident "$Revision: 1.9 $"
#endif
#include "timedc.h"
#include <sys/file.h>
@ -60,13 +56,8 @@ __RCSID("$NetBSD: cmds.c,v 1.9 1998/07/06 07:06:14 mrg Exp $");
#define TSPTYPES
#include <protocols/timed.h>
#ifdef sgi
#include <bstring.h>
#include <sys/clock.h>
#else
#define SECHR (60*60)
#define SECDAY (24*SECHR)
#endif /* sgi */
# define DATE_PROTO "udp"
# define DATE_PORT "time"

View File

@ -1,4 +1,4 @@
/* $NetBSD: timedc.c,v 1.7 2001/01/11 03:05:42 lukem Exp $ */
/* $NetBSD: timedc.c,v 1.8 2001/09/02 00:13:08 reinoud Exp $ */
/*-
* Copyright (c) 1985, 1993 The Regents of the University of California.
@ -44,14 +44,10 @@ __COPYRIGHT(
#if 0
static char sccsid[] = "@(#)timedc.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: timedc.c,v 1.7 2001/01/11 03:05:42 lukem Exp $");
__RCSID("$NetBSD: timedc.c,v 1.8 2001/09/02 00:13:08 reinoud Exp $");
#endif
#endif /* not lint */
#ifdef sgi
#ident "$Revision: 1.7 $"
#endif
#include "timedc.h"
#include <ctype.h>
#include <setjmp.h>

View File

@ -1,4 +1,4 @@
/* $NetBSD: timedc.h,v 1.6 2000/01/21 17:08:39 mycroft Exp $ */
/* $NetBSD: timedc.h,v 1.7 2001/09/02 00:13:08 reinoud Exp $ */
/*-
* Copyright (c) 1985, 1993 The Regents of the University of California.
@ -37,9 +37,6 @@
#include <sys/param.h>
#include <sys/time.h>
#ifdef sgi
#include <sys/uio.h>
#endif
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>