pkg://adjtimex-1.20-2.1.src.rpm:61729/adjtimex-1.20.tar.gz
info downloads
adjtimex-1.20/ 0000755 0001750 0001750 00000000000 10123331561 012660 5 ustar jrv jrv 0000000 0000000 adjtimex-1.20/adjtimex.c 0000644 0001750 0001750 00000143075 10123323671 014646 0 ustar jrv jrv 0000000 0000000 /*
#define DEBUG
adjtimex - display or set the kernel time variables
AUTHORS
ssd@nevets.oau.org (Steven S. Dick)
jrv at comcast.net (Jim Van Zandt)
*/
#define _GNU_SOURCE /* strptime is a GNU extension */
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <mat.h>
#include <math.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/timex.h>
#include <sys/types.h>
#include <syscall.h>
#include <time.h>
#include <unistd.h>
#include <utmp.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/rtc.h>
#ifdef __alpha__
extern int adjtimex(struct timex *);
#else
#ifdef __ia64__
extern int adjtimex(struct timex *);
#else
_syscall1(int, adjtimex, struct timex *, txcp)
#endif
#endif
int F_print = 0;
#ifndef LOG_PATH
#define LOG_PATH "/var/log/clocks.log"
#endif
#ifndef WTMP_PATH
#define WTMP_PATH "/var/log/wtmp"
#endif
static unsigned long epoch = 1900; /* year corresponding to 0x00 */
/* Here the information for CMOS clock adjustments is kept. */
#define ADJPATH "/etc/adjtime"
/* used for debugging the code. */
/* #define DEBUG */
#define RTC_JITTER .000025 /* assumed error in reading CMOS clock (sec) */
#define SECONDSPERDAY 86400
#define BUFLEN 128
static int cmos_fd = -1;
/* to enable use of /dev/rtc interface, we would initialize
using_dev_rtc to -1. However, reading /dev/rtc does not wait until
the beginning of the next second. It only returns the current
timer value, so it's only accurate to 1 sec which isn't good enough
for us. I see this comment in drivers/char/rtc.c, function
rtc_get_rtc_time(), in the kernel sources:
* read RTC once any update in progress is done. The update
* can take just over 2ms. We wait 10 to 20ms. There is no need to
* to poll-wait (up to 1s - eeccch) for the falling edge of RTC_UIP.
* If you need to know *exactly* when a second has started, enable
* periodic update complete interrupts, (via ioctl) and then
* immediately read /dev/rtc which will block until you get the IRQ.
* Once the read clears, read the RTC time (again via ioctl). Easy.
However it doesn't say how to restore the interrupt setup. Until I
find out about that, I'll continue to use the poll-wait. */
static int using_dev_rtc = 0;
struct hack {
double ref; /* reference time for time hack */
double sigma_ref; /* expected error in above (or zero if
no reference time available) */
time_t log; /* reference time as time_t */
double sys; /* system time */
int tick; /* "tick" system parameter */
int freq; /* "freq" system parameter */
char sys_ok; /* nonzero if system clock undisturbed
during previous period */
double cmos; /* CMOS time */
char cmos_ok; /* nonzero if cmos clock undisturbed
during previous period */
char valid; /* bit flags (see below) */
double sys_rate, sys_sigma;
double cmos_rate, cmos_sigma;
double relative_rate, relative_sigma;
} prev;
/* constants for `valid' member of struct hack */
#define CMOS_VALID 1
#define SYS_VALID 2
#define REF_VALID 4
struct cmos_adj
{
double ca_factor;
long ca_adj_time;
double ca_remainder;
} ca;
struct timex txc;
#define HELP 131
struct option longopt[]=
{
{"adjust", 2, NULL, 'a'},
{"compare", 2, NULL, 'c'},
{"log", 2, NULL, 'l'},
{"esterror", 1, NULL, 'e'},
{"frequency", 1, NULL, 'f'},
{"host", 1, NULL, 'h'},
{"help", 0, NULL, HELP},
{"interval", 1, NULL, 'i'},
{"maxerror", 1, NULL, 'm'},
{"offset", 1, NULL, 'o'},
{"print", 0, NULL, 'p'},
{"review", 2, NULL, 'r'},
{"singleshot", 1, NULL, 's'},
{"status", 1, NULL, 'S'},
{"reset", 0, NULL, 'R'},
{"timeconstant", 1, NULL, 'T'},
{"tick", 1, NULL, 't'},
{"utc", 0, NULL, 'u'},
{"version", 0, NULL, 'v'},
{"watch", 0, NULL, 'w'},
{0,0,0,0}
};
int adjusting = 0;
int comparing = 0;
int logging = 0;
int reviewing = 0;
int resetting = 0; /* nonzero if need to call
reset_time_status() */
int interval = 10;
int count = 8;
int marked;
int universal = 0;
int watch; /* nonzero if time specified on command line */
int undisturbed_sys = 0;
int undisturbed_cmos = 0;
char *log_path = LOG_PATH;
char *timeserver; /* points to name of timeserver */
void compare(void);
void failntpdate();
void reset_time_status(void);
static double compare_cmos_sys(void);
struct cmos_adj *get_cmos_adjustment(void);
void log_times(void);
int valid_system_rate(double ftime_sys, double ftime_ref, double sigma_ref);
int valid_cmos_rate(double ftime_cmos, double ftime_ref, double sigma_ref);
void sethackent(void);
void endhackent(void);
struct hack *gethackent(void);
void puthackent(struct hack *ph);
time_t mkgmtime(struct tm *tp);
int compare_tm(struct tm *first, struct tm *second);
static void *xmalloc(int n);
static void *xrealloc(void *pv, int n);
void review(void);
void kalman_update(double *x, int xr, double *p, double *h,
double *z, int zr, double *r);
void
usage(void)
{
char msg[]=
"\n"
"Usage: adjtimex [OPTION]... \n"
"Mandatory or optional arguments to long options are mandatory or optional\n"
"for short options too.\n"
"\n"
"Get/Set Kernel Time Parameters:\n"
" -p, --print print values of kernel time variables\n"
" -t, --tick val set the kernel tick interval in usec\n"
" -f, --frequency newfreq set system clock frequency offset\n"
" -s, --singleshot adj slew the system clock by adj usec\n"
" -S, --status val set kernel clock status\n"
" -R, --reset reset status after setting parameters\n"
" (needed for early kernels)\n"
" -o, --offset adj add a time offset of adj usec\n"
" -m, --maxerror val set maximum error (usec)\n"
" -e, --esterror val set estimated error (usec)\n"
" -T, --timeconstant val set phase locked loop time constant\n"
" -a, --adjust[=count] set system clock parameters per CMOS \n"
" clock or (with --review) log file\n"
"\n"
"Estimate Systematic Drifts:\n"
" -c, --compare[=count] compare system and CMOS clocks\n"
" -i, --interval tim set clock comparison interval (sec)\n"
" -l, --log[=file] log current times to file\n"
" --host timeserver query the timeserver\n"
" -w, --watch get current time from user\n"
" -r, --review[=file] review clock log file, estimate drifts\n"
" -u, --utc the CMOS clock is set to UTC\n"
"\n"
"Informative Output:\n"
" --help print this help, then exit\n"
" -v, --version print adjtimex program version, then exit\n"
;
fputs(msg, stdout);
exit(0);
}
/* return apparent value of USER_HZ in HZ, minimum nominal and maximum
values for tick in TICK_MIN TICK_MID and TICK_MAX, and maximum
frequency offset in MAXFREQ */
void probe_time(int *hz, int *tick_min, int *tick_mid, int *tick_max,
long *maxfreq)
{
struct timex txc;
int tick_orig, tick_lo, tick_try, tick_hi, i;
txc.modes = 0;
adjtimex(&txc);
*maxfreq = txc.tolerance;
tick_orig = tick_hi = txc.tick;
tick_lo = tick_hi*2/3;
for (i = 0; i < 15; i++)
{ /* conduct binary search for minimum
accepted tick value */
// printf(" %d < minimum accepted tick value <= %d\n", tick_lo, tick_hi);
txc.tick = tick_try = (tick_lo + tick_hi)/2;
txc.modes = ADJ_TICK;
if (adjtimex(&txc) == -1) tick_lo = tick_try;
else tick_hi = tick_try;
}
*tick_min = tick_hi;
tick_lo = tick_orig;
tick_hi = tick_lo*4/3;
for (i = 0; i < 15; i++)
{ /* conduct binary search for maximum
accepted tick value */
// printf(" %d <= maximum accepted tick value < %d\n", tick_lo, tick_hi);
txc.tick = tick_try = (tick_lo + tick_hi)/2;
txc.modes = ADJ_TICK;
if (adjtimex(&txc) == -1) tick_hi = tick_try;
else tick_lo = tick_try;
}
*tick_max = tick_lo;
*tick_mid = (*tick_min + *tick_max)/2;
*hz = (900000/ *tick_min + 1100000/ *tick_max)/2;
txc.tick = tick_orig;
txc.modes = ADJ_TICK;
adjtimex(&txc); /* reset to original value */
}
int
main(int argc, char *argv[])
{
int ret, saveerr, changes;
extern char *optarg;
int c;
txc.modes = 0;
while((c = getopt_long_only(argc, argv,
"a::c::l::e:f:h:i:m:o:prPPsPS:RT:t:uvw",
longopt, NULL)) != -1)
{
switch(c)
{
case 'a':
adjusting = 1;
if (optarg)
count = atoi(optarg);
break;
case 'c':
comparing = 1;
if (optarg)
count = atoi(optarg);
break;
case 'l':
logging = 1;
if (optarg)
log_path = strdup(optarg);
if (!log_path)
{
fprintf (stderr, "insufficient memory\n");
exit(1);
}
break;
case 'h':
timeserver = strdup(optarg);
if (!timeserver)
{
fprintf (stderr, "insufficient memory\n");
exit(1);
}
logging = 1;
break;
case 'r':
reviewing = 1;
if (optarg)
log_path = strdup(optarg);
if (!log_path)
{
fprintf (stderr, "insufficient memory\n");
exit(1);
}
break;
case 'i':
interval = atoi (optarg);
if (interval <= 1 || interval > 1000)
{
fprintf (stderr, "repeat interval out of range\n");
exit (1);
}
break;
case 'p':
F_print = 1;
break;
case 'o':
txc.offset = atol(optarg);
txc.modes |= ADJ_OFFSET;
break;
case 's':
txc.offset = atol(optarg);
txc.modes |= ADJ_OFFSET_SINGLESHOT;
break;
case 'S':
txc.status = atol(optarg);
txc.modes |= ADJ_STATUS;
break;
case 'R': resetting = 1; break;
case 'f':
txc.freq = atol(optarg);
txc.modes |= ADJ_FREQUENCY;
break;
case 'm':
txc.maxerror = atol(optarg);
txc.modes |= ADJ_MAXERROR;
break;
case 'e':
txc.esterror = atol(optarg);
txc.modes |= ADJ_ESTERROR;
break;
case 'T':
txc.constant = atol(optarg);
txc.modes |= ADJ_TIMECONST;
break;
case 't':
txc.tick = atol(optarg);
txc.modes |= ADJ_TICK;
break;
case 'u':
universal = 1;
break;
case 'v':
{
printf("adjtimex %s\n", VERSION);
exit(0);
}
case 'w':
watch = 1;
logging = 1;
break;
case HELP:
usage();
break;
case '?':
default:
fprintf(stderr, "For valid options, try 'adjtimex --help'\n");
exit(1);
}
}
changes = txc.modes;
if (count <= 0 ) {
fprintf(stderr, "loop count out of range\n");
exit(1);
}
if (reviewing)
{
review();
exit(0);
}
if (adjusting || comparing)
{
if (changes || F_print)
{
fprintf(stderr,
"-adjust or -compare cannot be used with any other options that"
" set values\n");
exit(1);
}
compare();
}
if (logging)
{
/*
if (geteuid() != 0)
{
fprintf(stderr, "sorry, only root can record clock comparisons\n");
exit(1);
}
*/
log_times();
exit(0);
}
if ((txc.modes & ADJ_OFFSET_SINGLESHOT) == ADJ_OFFSET_SINGLESHOT &&
txc.modes != ADJ_OFFSET_SINGLESHOT)
{
fprintf(stderr, "-singleshot cannot be used with "
"any other option except -print\n");
usage();
}
errno = 0;
ret = adjtimex(&txc);
saveerr = errno;
if (F_print) {
printf(" mode: %d\n"
" offset: %ld\n"
" frequency: %ld\n"
" maxerror: %ld\n"
" esterror: %ld\n"
" status: %d\n"
"time_constant: %ld\n"
" precision: %ld\n"
" tolerance: %ld\n"
" tick: %ld\n"
" raw time: %ds %dus = %d.%06d\n",
txc.modes,
txc.offset,
txc.freq,
txc.maxerror,
txc.esterror,
txc.status,
txc.constant,
txc.precision,
txc.tolerance,
txc.tick,
(int)txc.time.tv_sec,
(int)txc.time.tv_usec,
(int)txc.time.tv_sec,
(int)txc.time.tv_usec);
if (saveerr == 0 && ret != 0)
printf(" return value = %d\n", ret);
}
if (ret != 0 && saveerr != 0) {
if (ret != -1)
fprintf(stderr, "%d ", ret);
errno = saveerr;
perror("adjtimex");
{
int hz, tick_min, tick_mid, tick_max;
long maxfreq;
probe_time(&hz, &tick_min, &tick_mid, &tick_max, &maxfreq);
printf("for this kernel:\n"
" USER_HZ = %d (nominally %d ticks per second)\n"
" %d <= tick <= %d\n"
" %ld <= frequency <= %ld\n",
hz, hz, tick_min, tick_max, -maxfreq, maxfreq);
}
exit(1);
}
if (changes && resetting)
reset_time_status();
return 0;
}
static inline void
outb (short port, char val)
{
#ifdef USE_INLINE_ASM_IO
__asm__ volatile ("out%B0 %0,%1"::"a" (val), "d" (port));
#else
lseek (cmos_fd, port, 0);
write (cmos_fd, &val, 1);
#endif
}
static inline unsigned char
inb (short port)
{
unsigned char ret;
#ifdef USE_INLINE_ASM_IO
__asm__ volatile ("in%B0 %1,%0":"=a" (ret):"d" (port));
#else
lseek (cmos_fd, port, 0);
read (cmos_fd, &ret, 1);
#endif
return ret;
}
void
cmos_init ()
{
if (using_dev_rtc < 0)
{
cmos_fd = open ("/dev/rtc", O_RDONLY);
if (cmos_fd >= 0)
{
using_dev_rtc = 1;
return;
}
using_dev_rtc = 0;
}
else if (using_dev_rtc > 0)
return;
#ifdef USE_INLINE_ASM_IO
if (ioperm (0x70, 2, 1))
{
fprintf (stderr, "clock: unable to get I/O port access\n");
exit (1);
}
#else
if (cmos_fd < 0)
cmos_fd = open ("/dev/port", O_RDWR);
if (cmos_fd < 0)
{
perror ("unable to open /dev/port read/write : ");
exit (1);
}
if (lseek (cmos_fd, 0x70, 0) < 0 || lseek (cmos_fd, 0x71, 0) < 0)
{
perror ("unable to seek port 0x70 in /dev/port : ");
exit (1);
}
#endif
}
#define CMOS_READ(addr) ({outb(0x70,(addr)|0x80); inb(0x71);})
static inline int
cmos_read_bcd (int addr)
{
int b;
b = CMOS_READ (addr);
return (b & 15) + (b >> 4) * 10;
}
static void
cmos_read_time (struct tm *tm)
{
if (using_dev_rtc > 0)
ioctl (cmos_fd, RTC_RD_TIME, tm);
else
{
long i;
/* read RTC exactly on falling edge of update flag */
/* Wait for rise.... (may take up to 1 second) */
for (i = 0; i < 10000000; i++)
if (CMOS_READ (10) & 0x80)
break;
/* Wait for fall.... (must try at least 2.228 ms) */
for (i = 0; i < 1000000; i++)
if (!(CMOS_READ (10) & 0x80))
break;
/* The "do" loop is "low-risk programming" */
/* In theory it should never run more than once */
do
{
tm->tm_sec = cmos_read_bcd (0);
tm->tm_min = cmos_read_bcd (2);
tm->tm_hour = cmos_read_bcd (4);
tm->tm_wday = cmos_read_bcd (6);
tm->tm_mday = cmos_read_bcd (7);
tm->tm_mon = cmos_read_bcd (8);
tm->tm_year = cmos_read_bcd (9);
}
while (tm->tm_sec != cmos_read_bcd (0));
}
}
static inline void
xusleep(long microseconds)
{
struct timespec ts;
ts.tv_sec = microseconds/1000000;
ts.tv_nsec = (microseconds - ts.tv_sec*1000000) * 1000;
while (nanosleep (&ts, &ts) < 0)
continue;
}
/* compare the system and CMOS clocks. If "adjusting" is nonzero,
adjust sytem time to match the CMOS clock. */
void
compare()
{
struct timex txc;
struct tm tm;
time_t cmos_time;
time_t last_time;
double cmos_sec, system_sec, dif, dif_prev = 0.;
FILE *adj;
double factor;
double cmos_adjustment;
double not_adjusted;
int loops = 0;
extern char *optarg;
struct timeval now;
int wrote_to_log = 0;
int hz, tick_min, tick_mid, tick_max;
long maxfreq;
probe_time(&hz, &tick_min, &tick_mid, &tick_max, &maxfreq);
/* Read adjustment parameters first */
if ((adj = fopen (ADJPATH, "r")) == NULL)
{
perror (ADJPATH);
exit (2);
}
if (fscanf (adj, "%lf %ld %lf", &factor, &last_time, ¬_adjusted) < 0)
{
perror (ADJPATH);
exit (2);
}
fclose (adj);
#ifdef DEBUG
/*
cmos clock last adjusted at Tue Aug 26 11:43:57 1997 (= 872610237)
current cmos time Tue Aug 26 21:27:05 1997 EDT (= 872645225)
*/
{
struct tm bdt;
if (universal)
{
bdt = *gmtime(&last_time);
(void)mkgmtime(&bdt); /* set tzname */
}
else
{
bdt = *localtime(&last_time);
(void)mktime(&bdt); /* set tzname */
}
printf ("cmos clock last adjusted %.24s %s "
"(= %ld)\n",
ctime(&last_time), tzname[tm.tm_isdst?1:0], (long) last_time);
}
#endif
cmos_init ();
while (count != 0)
{
if (count > 0) count--;
cmos_read_time (&tm);
/* fetch system time immediately */
gettimeofday (&now, NULL);
tm.tm_mon--; /* DOS uses 1 base */
tm.tm_wday -= 3; /* DOS uses 3 - 9 for week days */
tm.tm_isdst = -1; /* don't know whether it's daylight */
if ((tm.tm_year += (epoch - 1900)) <= 69)
tm.tm_year += 100;
if (universal)
cmos_time = mkgmtime(&tm);
else
cmos_time = mktime (&tm);
/* printf ("%s", asctime (&tm)); */
system_sec = now.tv_sec + .000001*now.tv_usec;
/* If we're adjusting time parameters, we want to make a log
entry only for the first two comparisons (before we change
the parameters). Otherwise, we want to log the first and last
comparisons in order to maximize the duration. */
if (logging && (wrote_to_log ^ (adjusting?(loops==0):(count!=0))))
{
struct hack h;
h.ref = 0;
h.sigma_ref = 0;
h.log = (time_t)system_sec;
h.sys = system_sec;
txc.modes = 0;
adjtimex(&txc);
h.tick = txc.tick;
h.freq = txc.freq;
h.sys_ok = wrote_to_log;
h.cmos = cmos_time;
h.cmos_ok = wrote_to_log;
puthackent(&h);
wrote_to_log = 1;
}
#ifdef DEBUG
printf (" current cmos time %.24s %s (= %ld)\n",
asctime(&tm), tzname[tm.tm_isdst?1:0], (long) cmos_time);
#endif
cmos_adjustment = ((double) (cmos_time - last_time))
* factor / SECONDSPERDAY
+ not_adjusted;
cmos_sec = cmos_time + cmos_adjustment;
#ifdef DEBUG
printf (
" time since last adjustment %10.6f days (= %9d sec)\n",
(int) (cmos_time - last_time) / (double)SECONDSPERDAY,
(int) (cmos_time - last_time));
printf (
" factor %10.6f sec/day\n",
factor);
printf (
" adjustment %10.6f + %7.6f = %7.6f sec\n",
((double) (cmos_time - last_time))*factor/SECONDSPERDAY,
not_adjusted, cmos_adjustment);
#endif
dif = system_sec - cmos_sec;
txc.modes = 0;
if (adjtimex (&txc) < 0) {perror ("adjtimex"); exit(1);}
/*
--- current --- -- suggested --
cmos time system-cmos error_ppm tick freq tick freq
1094939320 -14394.974188
1094939330 -14394.971203 298.5 10001 1290819
1094939340 -14394.968203 300.0 10001 1290819 9998 1289097
*/
if (! marked++ )
{
if (interval)
printf (
" --- current --- -- suggested --\n"
"cmos time system-cmos error_ppm tick freq tick freq\n");
else
printf (
"cmos time system-cmos error_ppm tick freq\n");
}
printf ("%9ld %11.6f",
(long) cmos_sec,
dif);
if (++loops > 1)
{ /* print difference in rates */
#define SHIFT (1<<16)
double second_diff, error_ppm;
second_diff = dif - dif_prev;
error_ppm = second_diff/interval*1000000;
printf ("%11.1f %6ld %9ld",
error_ppm,
txc.tick,
txc.freq);
if (loops > 2)
{ /* print suggested values */
long tick_delta = 0, freq_delta = 0;
tick_delta = ceil((-error_ppm + txc.freq/SHIFT - hz)/hz);
error_ppm += tick_delta*hz;
freq_delta = -error_ppm*SHIFT;
printf(" %6ld %9ld\n",
txc.tick + tick_delta, txc.freq + freq_delta);
if (loops > 4 && adjusting)
{
txc.modes = ADJ_FREQUENCY | ADJ_TICK;
txc.tick += tick_delta;
txc.freq += freq_delta;
if (adjtimex (&txc) < 0)
{
perror ("adjtimex");
exit(1);
}
if (resetting)
reset_time_status();
loops -= 3;
}
}
else
printf("\n");
}
else
printf("\n");
dif_prev = dif;
if (interval == 0)
break;
if (count) /* if it is not the last round */
xusleep (interval*1000000L - 900000); /* reading RTC takes 1 sec */
}
}
void reset_time_status()
{
/* Using the adjtimex(2) system call to set any time parameter makes
an early kernel (2.0.40 and 2.4.18 or later are reportedly okay)
think the clock is synchronized with an external time source, so
it sets the kernel variable time_status to TIME_OK. Thereafter,
it will periodically adjust the CMOS clock to match. We prevent
this by setting the clock, because that has the side effect of
resetting time_status to TIME_BAD. We try not to actually change
the clock setting. */
struct timeval tv1, tv2;
long carry_sec, overhead_usec;
if (gettimeofday(&tv1, NULL)) {perror("adjtimex"); exit(1);}
if (gettimeofday(&tv2, NULL)) {perror("adjtimex"); exit(1);}
overhead_usec = tv2.tv_usec - tv1.tv_usec +
1000000*(tv2.tv_sec - tv1.tv_sec);
tv2.tv_usec += overhead_usec;
carry_sec = tv2.tv_usec/1000000;
tv2.tv_sec += carry_sec;
tv2.tv_usec -= 1000000*carry_sec;
if (settimeofday(&tv2, NULL)) {perror("adjtimex"); exit(1);}
}
void log_times()
{
#ifdef NET_TIME_CLIENT
struct protoent proto;
int sockfd, val, len, c;
struct sockaddr sa={AF_INET, "127.0.0.1"};
struct hostent he;
#endif
double sigma_ref, cmos_ahead;
char ch, buf[64], *s;
int n, ret;
struct timeval tv_sys;
struct timezone tz;
struct tm bdt;
time_t when, tref;
double ftime_ref, ftime_sys, ftime_cmos;
if (watch)
{
while(1) {
printf("Please press <enter> when you know the time of day: ");
ch = getchar();
gettimeofday(&tv_sys, &tz);
when = tv_sys.tv_sec;
bdt = *localtime(&when); /* set default values for most fields */
strftime(buf, sizeof(buf), "%Z", &bdt);
printf(" system time then was %.24s %s\n", asctime(&bdt), buf);
ftime_sys = tv_sys.tv_sec + tv_sys.tv_usec*.000001;
printf("What time was that according to your reference (%s)?\n"
"(hh:mm:ss, or `r' to retry, or `q' to quit): ", buf);
if (fgets(buf, sizeof(buf), stdin) == NULL) exit(1);
s = buf;
while(isspace(*s)) s++;
if (*s == 'q') exit(0);
if (*s == 'r') continue;
strptime(buf, "%T", &bdt); /* set time fields from user input */
printf(" reference time is %s", asctime(&bdt));
tref = ftime_ref = mktime(&bdt); /* construct a time_t
corresponding to the user
input */
printf(" mktime returns time of %s", ctime(&tref));
printf("reference time - system time = %12.3f - %12.3f "
"= %4.3f sec\n",
ftime_ref, ftime_sys, ftime_ref - ftime_sys);
printf("How big could the error be in this, in seconds?\n"
"(or `r' to retry, or `q' to quit) [.5] : ");
if (fgets(buf, sizeof(buf), stdin) == NULL) exit(1);
s = buf;
while(isspace(*s)) s++;
if (*s == 'q') exit(0);
if (*s == 'r') continue;
n = sscanf(buf, "%lf", &sigma_ref);
if (n < 1)
sigma_ref = .5;
else if (sigma_ref < .02)
{
printf("You get credit for .02 sec.\n");
sigma_ref = .02;
}
break;
}
}
else if (timeserver)
{
FILE *ifile;
char command[128];
char buf[BUFLEN];
char *str[5];
int i, n=0;
double d, mean=0, val, var=0, num=0;
#ifdef NTPDATE_STUB
ifile = fopen("../ntpdate-sample", "r");
#else
sprintf(command, "ntpdate -d %.32s ", timeserver);
ifile = popen(command, "r");
#endif
if (ifile == NULL) failntpdate("call to ntpdate failed");
/* read and save the significant lines, which should look like this:
filter offset: -0.02800 -0.01354 -0.01026 -0.01385
offset -0.013543
1 Sep 11:51:23 ntpdate[598]: adjust time server 1.2.3.4 offset -0.013543 sec
*/
while(fgets(buf, BUFLEN, ifile))
if (strstr(buf, "offset") && n < 4)
str[n++] = strdup(buf);
fclose(ifile);
if (n != 3) failntpdate("cannot understand ntpdate output");
gettimeofday(&tv_sys, &tz);
ftime_sys = tv_sys.tv_sec;
/* ntpdate selects the offset from one of its samples (the one
with the shortest round-trip delay?) */
ftime_ref = ftime_sys + atof(strstr(str[2], "offset") + 6);
{
time_t now = (time_t)ftime_ref;
bdt = *gmtime(&now);
printf(" reference time is %s", ctime(&now));
printf("reference time - system time = %12.3f - %12.3f "
"= %4.3f sec\n",
ftime_ref, ftime_sys, ftime_ref - ftime_sys);
}
/* The first saved line shows the offsets for each of ntpdate's
samples. Find their variance, which we will use to indicate
the accuracy of the offset we're using. This is probably
conservative, since the offset we're using is probably not
close to the mean. */
s = strstr(str[0], ":");
if (s++ == NULL) failntpdate("cannot understand ntpdate output");
for (i = 0; i < 4; i++)
{
val = strtod(s, &s);
d = val - mean;
num += 1.;
var = (num-1)/num*(var + d*d/num);
mean = ((num-1.)*mean + val)/num;
}
sigma_ref = sqrt(var);
#ifdef OWN_IMPLEMENTATION
/* this is not even close to working yet */
proto = *getprotobyname("UDP");
sockfd = socket(AF_INET, SOCK_DGRAM, proto.p_proto);
he = *gethostbyname("localhost");
len = he.h_length;
memcpy(sa.sa_data, he.h_addr_list[0], len);
#ifdef SEND
val = connect(sockfd, &sa, len);
if (val == -1) {perror("connect"); exit(1);}
/*
int connect(int sockfd, struct sockaddr *serv_addr, int addrlen );
int send(int s, const void *msg, int len , unsigned int flags);
int sendto(int s, const void *msg, int len unsigned int
flags, const struct sockaddr *to, int tolen);
*/
#endif /* SEND */
val = sendto(sockfd, (const void *)" ", 1, 0, &sa, len);
if (val == -1) {perror("sendto"); exit(1);}
sigma_ref = .010;
#endif /* OWN_IMPLEMENTATION */
}
else /* no absolute time reference */
{
time_t now;
gettimeofday(&tv_sys, &tz);
now = (time_t)tv_sys.tv_sec;
bdt = *gmtime(&now);
ftime_sys = tv_sys.tv_sec + tv_sys.tv_usec*.000001;
ftime_ref = 0;
sigma_ref = 0;
}
cmos_ahead = compare_cmos_sys();
ftime_cmos = ftime_sys + cmos_ahead;
/*
-reference-time- --------system-time---------- --cmos-time----
1997-06-14 20:22 888888888.888 -3 888888888.888 10000 6666666 n 888888888.888 y
*/
{
struct hack h;
h.ref = ftime_ref;
h.sigma_ref = sigma_ref;
h.log = (time_t)ftime_ref;
h.sys = ftime_sys;
txc.modes = 0;
ret = adjtimex(&txc);
h.tick = txc.tick;
h.freq = txc.freq;
h.sys_ok = valid_system_rate(ftime_sys, ftime_ref, sigma_ref);
h.cmos = ftime_cmos;
h.cmos_ok = valid_cmos_rate(ftime_cmos, ftime_ref, sigma_ref);
puthackent(&h);
}
}
void failntpdate(char *s)
{
fprintf(stderr, "%s\n", s);
exit(1);
}
int valid_system_rate(double ftime_sys, double ftime_ref, double sigma_ref)
{
int n;
int default_answer;
int ch;
char buf[BUFLEN];
struct hack *ph;
struct cmos_adj *pca = get_cmos_adjustment();
sethackent();
for (n = 0; (ph = gethackent()); n++)
prev = *ph; /* fetch last line from logfile */
endhackent();
if (n == 0)
{
printf("No previous clock comparison in log file\n");
return 0;
}
undisturbed_sys = undisturbed_cmos = 1;
printf("Last clock comparison was at %.24s\n", ctime(&prev.log));
if (txc.tick == prev.tick && txc.freq == prev.freq)
printf("Kernel time variables are unchanged - good.\n");
else
{
printf("Kernel time variables have changed - bad.\n");
undisturbed_sys = 0;
}
if (txc.status & 64)
printf("System clock is currently not disciplined - good.\n");
else
{
printf("System clock is synchronized (by ntpd?) - bad.\n");
undisturbed_sys = 0;
}
{
time_t lastboot, newtime;
struct utmp *up;
lastboot = newtime = prev.sys - 1;
utmpname(WTMP_PATH);
setutent();
printf("Checking wtmp file...\n");
while((up = getutent()))
{
if (up->ut_type == BOOT_TIME)
lastboot = up->ut_time;
if (up->ut_type == NEW_TIME)
newtime = up->ut_time;
}
endutent();
if (lastboot < prev.sys)
printf("System has not booted since %.24s - good.\n",
ctime(&prev.log));
else
{
printf("System was booted at %.24s - bad.\n", ctime(&lastboot));
undisturbed_sys = 0;
}
if (newtime < prev.sys)
printf("System time has not been changed since %.24s - good.\n",
ctime(&prev.log));
else
{
printf("System time was reset at %.24s - bad.\n", ctime(&newtime));
undisturbed_sys = 0;
}
}
if (pca)
{
printf("Checking %s...\n", ADJPATH);
if (pca->ca_adj_time < prev.log)
printf(
"/sbin/clock has not set system time and adjusted the cmos clock \n"
"since %.24s - good.\n",
ctime(&prev.log));
else
{
printf("/sbin/clock set system time and adjusted the cmos clock \n"
"at %.24s - bad.\n",
ctime(&pca->ca_adj_time));
undisturbed_sys = undisturbed_cmos = 0;
}
}
do
{
default_answer = undisturbed_sys?'y':'n';
printf("\nAre you sure that, since %.24s,\n", ctime(&prev.log));
printf(" the system clock has run continuously,\n");
printf(" it has not been reset with `date' or `/sbin/clock`,\n");
printf(" the kernel time variables have not been changed, and\n");
printf(" the computer has not been suspended? (y/n) [%c] ",
default_answer);
fgets(buf, BUFLEN, stdin);
ch = buf[0];
if (ch == '\n') ch = default_answer;
} while (ch != 'n' && ch != 'y');
if ((undisturbed_sys = (ch == 'y')))
{
double drift_sys_ppm, err_sys_ppm;
int digits;
drift_sys_ppm = ((ftime_sys - ftime_ref) - (prev.sys - prev.ref))*
1.e6/(ftime_ref - prev.ref);
err_sys_ppm = (prev.sigma_ref + sigma_ref)*1.e6/
(ftime_ref - prev.ref);
digits = -(int)floor(log(.5*sigma_ref)/log(10.));
if (digits < 0) digits = 0;
printf("The estimated error in system time is %.*f +- %.*f ppm\n",
digits, drift_sys_ppm, digits, err_sys_ppm);
}
return undisturbed_sys;
}
int valid_cmos_rate(double ftime_cmos, double ftime_ref, double sigma_ref)
{
int default_answer;
int ch;
char buf[BUFLEN];
default_answer = undisturbed_cmos?'y':'n';
do
{
printf("\nAre you sure that, since %.24s,\n", ctime(&prev.log));
printf(" the real time clock (cmos clock) has run continuously,\n");
printf(" it has not been reset with `/sbin/clock',\n");
printf(" no operating system other than Linux has been running, and\n");
printf(" ntpd has not been running? (y/n) [%c] ", default_answer);
fgets(buf, BUFLEN, stdin);
ch = buf[0];
if (ch == '\n') ch = default_answer;
} while (ch != 'n' && ch != 'y');
if ((undisturbed_cmos = (ch == 'y')))
{
double drift_cmos_ppm, err_cmos_ppm;
int digits;
drift_cmos_ppm =
((ftime_cmos - ftime_ref) - (prev.cmos - prev.ref))*
1.e6/(ftime_ref - prev.ref);
err_cmos_ppm = (prev.sigma_ref + sigma_ref)*1.e6/
(ftime_ref - prev.ref);
digits = -(int)floor(log(.5*err_cmos_ppm)/log(10.));
if (digits < 0) digits = 0;
printf("The estimated error in the cmos clock is %.*f +- %.*f ppm\n",
digits, drift_cmos_ppm, digits, err_cmos_ppm);
}
return undisturbed_cmos;
}
struct cmos_adj *get_cmos_adjustment()
{
FILE *adj;
static struct cmos_adj ca;
if ((adj = fopen (ADJPATH, "r")) == NULL)
{
perror (ADJPATH);
exit (2);
}
if (fscanf (adj, "%lf %ld %lf",
&ca.ca_factor,
&ca.ca_adj_time,
&ca.ca_remainder) < 0)
{
perror (ADJPATH);
exit (2);
}
fclose (adj);
#ifdef DEBUG
printf ("CMOS clock was last adjusted %s", ctime(&ca.ca_adj_time));
#endif
return &ca;
}
/* return the difference in seconds: cmos_time - system_time */
static double
compare_cmos_sys()
{
struct tm tm;
time_t cmos_time;
double system_sec;
double dif;
int i;
extern char *optarg;
struct timeval now;
if (geteuid() != 0)
{
struct tm bdt;
char before[256], after[256];
int fd = open("/proc/rtc", O_RDONLY);
if (fd == -1)
{
fprintf(stderr, "kernel lacks enhanced real time clock support, "
"so only root can read RTC\n");
exit(1);
}
read(fd, before, sizeof(before));
close(fd);
do
{
fd = open("/proc/rtc", O_RDONLY);
read(fd, after, sizeof(after));
gettimeofday (&now, NULL);
close(fd);
} while (!strncmp(before, after, strlen(after)));
strptime(after, "rtc_time : %H:%M:%S\nrtc_date : %Y-%m-%d", &bdt);
if (universal) /* also set tm_wday and tm_yday */
cmos_time = mkgmtime(&bdt);
else
cmos_time = mktime(&bdt);
#ifdef DEBUG
printf("RTC says date & time are %.24s %s\n",
asctime(&bdt), tzname[bdt.tm_isdst?1:0]);
#endif
system_sec = now.tv_sec + .000001 * now.tv_usec;
dif = (double)cmos_time - system_sec;
return dif;
}
else /* I am superuser */
{
cmos_init ();
/* read RTC exactly on falling edge of update flag */
/* Wait for rise.... (may take up to 1 second) */
for (i = 0; i < 10000000; i++)
if (CMOS_READ (10) & 0x80)
break;
/* Wait for fall.... (must try at least 2.228 ms) */
for (i = 0; i < 1000000; i++)
if (!(CMOS_READ (10) & 0x80))
break;
/* The "do" loop is "low-risk programming" */
/* In theory it should never run more than once */
do
{
tm.tm_sec = cmos_read_bcd (0);
tm.tm_min = cmos_read_bcd (2);
tm.tm_hour = cmos_read_bcd (4);
tm.tm_wday = cmos_read_bcd (6);
tm.tm_mday = cmos_read_bcd (7);
tm.tm_mon = cmos_read_bcd (8);
tm.tm_year = cmos_read_bcd (9);
}
while (tm.tm_sec != cmos_read_bcd (0));
/* fetch system time immediately */
gettimeofday (&now, NULL);
tm.tm_mon--; /* DOS uses 1 base */
tm.tm_wday -= 3; /* DOS uses 3 - 9 for week days */
tm.tm_isdst = -1; /* don't know whether it's daylight */
if ((tm.tm_year += (epoch - 1900)) <= 69)
tm.tm_year += 100;
#ifdef DEBUG
printf (" mday=%d mon=%d wday=%d year=%d\n",
tm.tm_mday, tm.tm_mon, tm.tm_wday, tm.tm_year);
printf ("Cmos time %d:%02d:%02d\n", tm.tm_hour, tm.tm_min, tm.tm_sec);
#endif
}
/*
* Mktime assumes we're giving it local time. If the CMOS clock is in
* GMT, we have to set up TZ so mktime knows it. Tzset gets called
* implicitly by the time code, but only the first time. When
* changing the environment variable, better call tzset explicitly.
*/
if (universal)
{
#ifdef ZONESWITCH
zone = (char *) getenv ("TZ"); /* save original time zone */
(void) putenv ("TZ=");
tzset ();
cmos_time = mktime (&tm);
/* now put back the original zone */
if (zone)
{
if ((strlen (zone) + 4) > sizeof (zonebuf))
{
fprintf (stderr, "Size of TZ variable is too long\n");
exit (2);
}
strcpy (zonebuf, "TZ=");
strcat (zonebuf, zone);
putenv (zonebuf);
}
else
{ /* wasn't one, so clear it */
putenv ("TZ");
}
tzset ();
printf ("%s", ctime (&cmos_time));
#else /* !ZONESWITCH */
cmos_time = mkgmtime(&tm);
#endif
}
else
{
cmos_time = mktime (&tm);
/* printf ("%s", asctime (&tm)); */
}
system_sec = now.tv_sec + .000001 * now.tv_usec;
#ifdef DEBUG
printf ("Number of seconds since 1/1/1970 is %ld\n",
(long) cmos_time);
#endif
dif = (double)cmos_time - system_sec;
return dif;
}
static FILE *lfile; /* pointer to log file, or NULL if it
has not been opened yet */
void sethackent(void)
{
endhackent();
lfile = fopen(log_path, "r");
if (!lfile && logging)
{
lfile = fopen(log_path, "a+"); /* create it if it doesn't exist */
if (!lfile)
{
fprintf(stderr, "%s does not exist, and could not be created\n",
log_path);
exit(1);
}
fseek(lfile, 0L, 0); /* start at beginning */
}
}
void endhackent(void)
{
if (lfile) fclose(lfile);
lfile = NULL;
}
/* read next entry in clock comparison log, fill a struct hack from
it, and return a pointer to it. Ignore lines starting with `#'.
Return NULL when there are no more lines to read. */
struct hack *gethackent(void)
{
char buf[256], sys_flag, cmos_flag, junk[26];
static struct hack h;
if (!lfile) sethackent();
if (!lfile) return NULL;
while(fgets(buf, sizeof(buf), lfile))
{
int tokens;
if (buf[0] == '#')
continue;
tokens = sscanf(buf, "%25s %25s %lf %lf %lf %d %d %c %lf %c",
junk, junk, &h.ref, &h.sigma_ref,
&h.sys, &h.tick, &h.freq, &sys_flag,
&h.cmos, &cmos_flag);
if (tokens != 10)
continue;
h.sys_ok = (tolower(sys_flag) == 'y');
h.cmos_ok = (tolower(cmos_flag) == 'y');
if (h.ref)
h.log = (time_t)h.ref;
else if (h.sys)
h.log = (time_t)h.sys;
else
h.log = (time_t)h.cmos;
h.valid = 0;
return &h;
}
return NULL;
}
/* append an entry to the clock comparison log. */
void puthackent(struct hack *ph)
{
struct tm bdt;
char timestring[32];
int digits;
if (ph->sigma_ref)
ph->log = (time_t)ph->ref;
else
ph->log = (time_t)ph->sys;
bdt = *gmtime(&ph->log);
strftime(timestring, sizeof(timestring), "%Y-%m-%d %H:%M", &bdt);
if (ph->sigma_ref <= 0.) digits = 0;
else
{
digits = -(int)floor(log(.5*ph->sigma_ref)/log(10.));
if (digits < 0) digits = 0;
}
#ifdef DEBUG
fprintf(stdout, "\nlog entry:\n");
fprintf(stdout, "%s %.*f %.*f %13.3f %5d %7d %s %13.3f %s\n",
timestring,
digits, ph->ref, digits, ph->sigma_ref,
ph->sys, ph->tick, ph->freq, ph->sys_ok?"y":"n",
ph->cmos, ph->cmos_ok?"y":"n");
#endif /* DEBUG */
lfile = fopen(log_path, "a+");
if (!lfile)
{
fprintf(stderr, "cannot open %s for writing\n", log_path);
return;
}
fprintf(lfile, "%s %.*f %.*f %13.3f %5d %7d %s %13.3f %s\n",
timestring,
digits, ph->ref, digits, ph->sigma_ref,
ph->sys, ph->tick, ph->freq, ph->sys_ok?"y":"n",
ph->cmos, ph->cmos_ok?"y":"n");
fclose(lfile);
lfile = NULL;
}
/* convert a broken-down time representing UTC to calendar time
representation (time_t), and return it. As a side effect, set the
tm_wday and tm_yday members of the broken-down time. (like mktime) */
time_t mkgmtime(struct tm *tp)
{
time_t lt; /* local time */
long adj;
struct tm u;
static char timezone_name[]="UTC";
lt = mktime(tp);
if (lt == (time_t)(-1))
return (time_t)(-1);
adj = 131072; /* greater than the number of seconds
per day (even when daylight savings
time ends) */
lt -= adj;
while (adj)
{
lt += adj;
u = *gmtime(<);
if (compare_tm(&u, tp) > 0)
lt -= adj;
adj /= 2;
}
u = *gmtime(<);
if (compare_tm(&u, tp))
return (time_t)(-1);
tzname[0] = tzname[1] = timezone_name;
return lt;
}
int compare_tm(struct tm *first, struct tm *second)
{
if (first->tm_year < second->tm_year) return -1;
if (first->tm_year > second->tm_year) return 1;
if (first->tm_mon < second->tm_mon) return -1;
if (first->tm_mon > second->tm_mon) return 1;
if (first->tm_mday < second->tm_mday) return -1;
if (first->tm_mday > second->tm_mday) return 1;
if (first->tm_hour < second->tm_hour) return -1;
if (first->tm_hour > second->tm_hour) return 1;
if (first->tm_min < second->tm_min) return -1;
if (first->tm_min > second->tm_min) return 1;
if (first->tm_sec < second->tm_sec) return -1;
if (first->tm_sec > second->tm_sec) return 1;
return 0;
}
static void *xmalloc(int n)
{ void *p;
p = xrealloc(NULL, n);
return p;
}
static void *xrealloc(void *pv, int n)
{
void *p;
p = realloc(pv, n);
if (!p){perror("adjtimex"); exit(1);}
return p;
}
/*
review log file and find least-square estimates of drifts. If
"adjusting" is nonzero, set sytem time parameters to the
least-squares estimates. */
void review()
{
int i, n, nmax = 0, digits;
struct hack *ph, **hacks = NULL;
double diff_ppm, sigma_ppm, cmos_time, sys_time, s0, s1, ref_time;
time_t start, finish;
char startstring[26], finishstring[26];
double x[2], p[4], h[4], z[2], r[4], cmos_var, sys_var, ref_var;
long tick_delta = 0;
double error_ppm = 0;
int hz, tick_min, tick_mid, tick_max;
long maxfreq;
probe_time(&hz, &tick_min, &tick_mid, &tick_max, &maxfreq);
/* read all the previous time hacks in */
sethackent();
for (n = 0; (ph = gethackent()); n++)
{
if (nmax <= n)
{
hacks = xrealloc(hacks, (nmax = 2*nmax + 4)*sizeof(struct hack *));
}
hacks[n] = xmalloc(sizeof(struct hack));
*hacks[n] = *ph;
}
endhackent();
if (n == 0)
{
printf("No previous clock comparison in log file\n");
return;
}
/* compare cmos and system rates */
printf(
"start finish days sys - cmos (ppm)\n");
for (i = 1; i < n; i++)
{
if (hacks[i]->sys_ok &&
hacks[i]->cmos_ok &&
hacks[i]->sys > hacks[i-1]->sys &&
hacks[i]->cmos > hacks[i-1]->cmos)
{
sys_time = hacks[i]->sys - hacks[i-1]->sys;
cmos_time = hacks[i]->cmos - hacks[i-1]->cmos;
hacks[i]->relative_rate =
diff_ppm = 1.e6*(sys_time - cmos_time)*2/(sys_time + cmos_time)
- 100*(hacks[i]->tick - tick_mid) - hacks[i]->freq/SHIFT;
if (fabs(diff_ppm) > 10000.) /* agree within 1 percent? */
continue;
hacks[i]->valid = CMOS_VALID | SYS_VALID;
hacks[i]->relative_sigma =
sigma_ppm = 1.e6*RTC_JITTER*sqrt(2.)/(sys_time + cmos_time);
start = (time_t)hacks[i-1]->sys;
strcpy(startstring, ctime(&start));
finish = (time_t)hacks[i]->sys;
strcpy(finishstring, ctime(&finish));
digits = -(int)floor(log(.5*sigma_ppm)/log(10.));
if (digits < 0) digits = 0;
printf("%.24s %.24s %6.4f %.*f +- %.*f\n",
startstring, finishstring, sys_time/SECONDSPERDAY,
digits, diff_ppm, digits, sigma_ppm);
}
}
/* compare cmos and reference rates */
printf(
"start finish days cmos_error (ppm)\n");
for (i = 1; i < n; i++)
{
if (hacks[i]->sigma_ref != 0 &&
hacks[i-1]->sigma_ref != 0 &&
hacks[i]->cmos_ok &&
hacks[i]->cmos > hacks[i-1]->cmos &&
hacks[i]->ref > hacks[i-1]->ref)
{
ref_time = hacks[i]->ref - hacks[i-1]->ref;
cmos_time = hacks[i]->cmos - hacks[i-1]->cmos;
hacks[i]->cmos_rate =
diff_ppm = 1.e6*(cmos_time - ref_time)*2/(ref_time + cmos_time);
if (fabs(diff_ppm) > 10000.) /* agree within 1 percent? */
continue;
hacks[i]->valid |= CMOS_VALID | REF_VALID;
s0=hacks[i-1]->sigma_ref;
s1=hacks[i]->sigma_ref;
hacks[i]->cmos_sigma =
sigma_ppm = 1.e6*sqrt(s0*s0 + s1*s1)/ref_time;
start = (time_t)hacks[i-1]->sys;
strcpy(startstring, ctime(&start));
finish = (time_t)hacks[i]->sys;
strcpy(finishstring, ctime(&finish));
digits = -(int)floor(log(.5*sigma_ppm)/log(10.));
if (digits < 0) digits = 0;
printf("%.24s %.24s %6.4f %1.*f +- %1.*f\n",
startstring, finishstring, ref_time/SECONDSPERDAY,
digits, diff_ppm, digits, sigma_ppm);
}
}
/* compare sys and reference rates */
printf(
"start finish days sys_error (ppm)\n");
for (i = 1; i < n; i++)
{
if (hacks[i]->sigma_ref != 0 &&
hacks[i-1]->sigma_ref != 0 &&
hacks[i]->sys_ok &&
hacks[i]->sys > hacks[i-1]->sys &&
hacks[i]->ref > hacks[i-1]->ref)
{
ref_time = hacks[i]->ref - hacks[i-1]->ref;
sys_time = hacks[i]->sys - hacks[i-1]->sys;
hacks[i]->sys_rate =
diff_ppm = 1.e6*(sys_time - ref_time)*2/(ref_time + sys_time)
- 100*(hacks[i]->tick - tick_mid) - hacks[i]->freq/SHIFT;
if (fabs(diff_ppm) > 10000.) /* agree within 1 percent? */
continue;
hacks[i]->valid |= REF_VALID | SYS_VALID;
s0=hacks[i-1]->sigma_ref;
s1=hacks[i]->sigma_ref;
hacks[i]->sys_sigma =
sigma_ppm = 1.e6*sqrt(s0*s0 + s1*s1)/ref_time;
start = (time_t)hacks[i-1]->sys;
strcpy(startstring, ctime(&start));
finish = (time_t)hacks[i]->sys;
strcpy(finishstring, ctime(&finish));
digits = -(int)floor(log(.5*sigma_ppm)/log(10.));
if (digits < 0) digits = 0;
printf("%.24s %.24s %6.4f %1.*f +- %1.*f\n",
startstring, finishstring, ref_time/SECONDSPERDAY,
digits, diff_ppm, digits, sigma_ppm);
}
}
/* find least-squares solution incorporating all the data */
p[0] = 1.e10; p[1] = 0.;
p[2] = 0.; p[3] = 1.e10;
x[0] = 0.; x[1] = 0.;
for (i = 1; i < n; i++)
{
switch(hacks[i]->valid)
{
case 0:
break;
case (CMOS_VALID | REF_VALID):
/* update only the first component of the state (cmos rate) */
h[0] = 1.; h[1] = 0.;
z[0] = hacks[i]->cmos_rate;
r[0] = hacks[i]->cmos_sigma; r[0] *= r[0];
kalman_update(x, 2, p, h, z, 1, r);
break;
case (SYS_VALID | REF_VALID):
/* update only the second component of the state (system rate) */
h[0] = 0.; h[1] = 1.;
z[0] = hacks[i]->sys_rate;
r[0] = hacks[i]->sys_sigma; r[0] *= r[0];
kalman_update(x, 2, p, h, z, 1, r);
break;
case (CMOS_VALID | SYS_VALID):
/* update the difference between the system and cmos rates */
h[0] = -1.; h[1] = 1.;
z[0] = hacks[i]->relative_rate;
r[0] = hacks[i]->relative_sigma; r[0] *= r[0];
kalman_update(x, 2, p, h, z, 1, r);
break;
case (CMOS_VALID | SYS_VALID | REF_VALID):
/* This is the interesting case. We have estimates of the
cmos and system rates, but they are highly correlated
because they contain the same errors in the reference
times. Thus, we know the *difference* between the cmos
and system rates much better than we know either of them
independently. The r matrix describes the
correlation. */
h[0] = 1.; h[1] = 0.;
h[2] = 0.; h[3] = 1.;
ref_var = hacks[i]->cmos_sigma*hacks[i]->cmos_sigma;
cmos_var = hacks[i]->relative_sigma; cmos_var *= cmos_var;
sys_var = cmos_var;
r[0] = ref_var + 2.*cmos_var;
r[1] = r[2] = ref_var;
r[3] = ref_var + 2.*sys_var;
z[0] = hacks[i]->cmos_rate;
z[1] = hacks[i]->sys_rate;
kalman_update(x, 2, p, h, z, 2, r);
break;
}
}
sigma_ppm = sqrt(p[0]);
digits = -(int)floor(log(.5*sigma_ppm)/log(10.));
if (digits < 0) digits = 0;
printf("least-squares solution:\n"
" cmos_error = %.*f +- %.*f ppm",
digits, x[0], digits, sigma_ppm);
if (sigma_ppm < 100)
printf(" suggested adjustment = %6.4f sec/day\n",
-x[0]*SECONDSPERDAY/1.e6);
else
printf(" (no suggestion)\n");
{
struct cmos_adj *pca = get_cmos_adjustment();
printf(" "
"current adjustment = %6.4f sec/day\n", pca->ca_factor);
}
sigma_ppm = sqrt(p[3]);
digits = -(int)floor(log(.5*sigma_ppm)/log(10.));
if (digits < 0) digits = 0;
printf(" sys_error = %.*f +- %.*f ppm",
digits, x[1], digits, sigma_ppm);
if (sigma_ppm < hz)
{
error_ppm = x[1];
if (error_ppm > hz)
tick_delta = -(error_ppm + hz/2)/hz;
else if (error_ppm < -hz)
tick_delta = (-error_ppm + hz/2)/hz;
error_ppm += tick_delta*hz;
printf(" suggested tick = %5ld freq = %7.0f\n",
tick_mid + tick_delta, -error_ppm*SHIFT);
}
else
printf(" (no suggestion)\n");
{
txc.modes = 0;
adjtimex(&txc);
printf(" "
"current tick = %5ld freq = %7ld\n", txc.tick, txc.freq );
}
printf(
"note: clock variations and unstated data errors may mean that the\n"
"least squares solution has a bigger error than estimated here\n");
if (sigma_ppm < 100 && adjusting)
{
txc.modes = ADJ_FREQUENCY | ADJ_TICK;
txc.tick = tick_mid + tick_delta;
txc.freq = -error_ppm*SHIFT;
if (adjtimex (&txc) < 0)
{
perror ("adjtimex");
exit(1);
}
if (resetting)
reset_time_status();
printf(" "
"new tick = %5ld freq = %7ld\n", txc.tick, txc.freq );
}
for (i = 0; i < n; i++)
free(hacks[i]);
free(hacks);
}
/* Perform one update on a discrete linear Kalman filter. z is a
measurement related to the state x by
z = h x + v
where v is the measurement error, normally distributed, with
covariance r.
Because of the size of the temporary arrays, this particular
implementation is restricted to 2 states. There are no provisions
here for propagating the state or its covariance between updates,
because it is not required in this case (i.e. the state transition
matrix is a unit matrix). See, for example: Blackman, "Multitarget
Tracking with Radar Applications" */
void kalman_update(double *x, /* state vector */
int xr, /* rows in x (must be 1 or 2) */
double *p, /* covariance matrix for x (has xr
rows and columns) */
double *h, /* transforms from state space to
measurement space (has zr rows
and xr columns) */
double *z, /* measurement vector */
int zr, /* rows in z (must be 1 or 2) */
double *r) /* covariance matrix for z (has zr
rows and columns) */
{
static double k[4], num[4], denom[4], v[4], w[4];
int pr=xr, pc=xr,
hr=zr, hc=xr,
rr=zr, rc=zr,
kr=xr, kc=zr,
nr=xr, nc=zr,
dr=zr, dc=zr,
vr=xr, vc=1,
wr=zr, wc=1;
/* find the Kalman gain k:
k = p h' /(h p h' + r) */
mat_mul_nt(p,pr,pc, h,hr,hc, num,nr,nc);
mat_similarity(h,hr,hc, p,pr,pc, denom,dr,dc);
mat_add(denom,dr,dc, r,rr,rc, denom,dr,dc);
if (sym_factor(denom,dr,dc, denom,dr,dc))
return; /* failure - singular */
sym_rdiv(num,nr,nc, denom,dr,dc, k,kr,kc);
/* update the state x:
x <- x + k (z - h x) */
mat_mul(h,hr,hc, x,xr,1, w,wr,wc);
mat_sub(z,zr,1, w,wr,wc, w,wr,wc);
mat_mul(k,kr,kc, w,wr,wc, v,vr,vc);
mat_add(x,xr,1, v,vr,vc, x,xr,1);
/* update the covariance p:
p <- (I - k h) p */
mat_one(v,xr,xr);
mat_mul(k,kr,kc, h,hr,hc, w,xr,xr);
mat_sub(v,xr,xr, w,xr,xr, w,xr,xr);
mat_mul(w,xr,xr, p,xr,xr, v,xr,xr);
mat_copy(v,xr,xr, p,xr,xr);
}
adjtimex-1.20/adjtimex.8 0000644 0001750 0001750 00000031375 10120654536 014576 0 ustar jrv jrv 0000000 0000000 .\"{{{ Title Emacs major mode should be: -*- nroff -*-
.TH ADJTIMEX 8 "September 11, 2004"
.\"}}}
.\"{{{ Name
.SH NAME
adjtimex \- display or set the kernel time variables
.\"}}}
.\"{{{ Synopsis
.SH SYNOPSIS
.ad l
.\" commands only
\fBadjtimex\fP [\fIoption\fP]...
.\"}}}
.\"{{{ Config
.SH DESCRIPTION
This program gives you raw access to the kernel time variables.
Anyone may print out the time variables, but only the superuser
may change them.
.PP
Your computer has two clocks - the "hardware clock" that runs all the
time, and the system clock that runs only while the computer is on.
Normally, "hwclock --hctosys" should be run
at startup to initialize the system clock.
The system clock has much better precision (approximately 1 usec), but
the hardware clock probably has better long-term stability. There are
three basic strategies for managing these clocks.
.PP
For a machine connected to the Internet, or equipped with a precision
oscillator or radio clock, the best way is to regulate the system clock
with \fBntpd\fP(8). The kernel will
automatically update the hardware clock every eleven minutes.
.PP
In addition, \fBhwclock\fP(8) can be used to approximately correct for a
constant drift in the hardware clock. In this case, "hwclock
\-\-adjust" is run occasionally. \fBhwclock\fP notes how long it has
been since the last adjustment, and nudges the hardware clock forward
or back by the appropriate amount. The user needs to set the time
with "hwclock \-\-set" several times over the course of a few days so
\fBhwclock\fP can estimate the drift rate. During that time,
\fBntpd\fP should not be running, or else \fBhwclock\fP will conclude
the hardware clock does not drift at all. After you have run "hwclock
\-\-set" for the last time, it's okay to start \fBntpd\fP. Then,
"hwclock \-\-systohc" should be run when the machine is shut down. (To
see why, suppose the machine runs for a week with \fBntpd\fP, is shut
down for a day, is restarted, and "hwclock \-\-adjust" is run by a
startup script. It should only correct for one day's worth of drift.
However, it has no way of knowing that \fBntpd\fP has been adjusting
the hardware clock, so it bases its adjustment on the last time
\fBhwclock\fP was run.)
.PP
For a standalone or intermittently connected machine, where it's not
possible to run \fBntpd\fP, you may use \fBadjtimex\fP instead to
correct the system clock for systematic drift.
.PP
There are several ways to estimate the drift rate.
If your computer can be connected to the net, you might run \fBntpd\fP
for at least several hours and run "adjtimex \-\-print" to learn
what values of tick and freq it settled on. Alternately, you could
estimate values using as a reference the CMOS clock (see the
\fB\-\-compare\fP and \fB\-\-adjust\fP switches), another host (see
\fB\-\-host\fP and \fB\-\-review\fP), or some other source of time (see
\fB\-\-watch\fP and \fB\-\-review\fP). You could then add a line to
\fIrc.local\fP invoking \fBadjtimex\fP, or configure
\fI/etc/init.d/adjtimex\fP or \fI/etc/default/adjtimex\fP, to set
those parameters each time you reboot.
.\"}}}
.\"{{{ Options
.SH OPTIONS
Options may be introduced by either \fB\-\fP or \fB\-\-\fP, and unique
abbreviations may be used.
.pp
Here is a summary of the options, grouped by type. Explanations
follow.
.hy 0
.na
.TP
.B Get/Set Kernel Time Parameters
.br
\-p
\-\-print
\-t
.RI \-\-tick " val"
.RI \-f " newfreq"
.RI \-\-frequency " newfreq"
.RI \-o " val"
.RI \-\-offset " val"
.RI \-s " adjustment"
.RI \-\-singleshot " adjustment"
.RI \-S " status"
.RI \-\-status " status"
.RI \-m " val"
.RI \-R
.RI \-\-reset
.RI \-\-maxerror " val"
.RI \-e " val"
.RI \-\-esterror " val"
.RI \-T " val"
.RI \-\-timeconstant " val"
.RI \-a[ count ]
.RI \-\-adjust[= count ]
.TP
.B Estimate Systematic Drifts
.br
.RI \-c[ count ]
.RI \-\-compare[= count ]
.RI \-i " tim"
.RI \-\-interval " tim"
.RI \-l " file"
.RI \-\-logfile " file"
.RI \-h " timeserver"
.RI \-\-host " timeserver"
\-w
\-\-watch
\-r[\fIfile\fP]
\-\-review[=\fIfile\fP]
\-u
\-\-utc
.TP
\fBInformative Output\fP
\-\-help
\-v
\-\-version
.br
.IP "\fB\-p\fP, \fB\-\-print\fP"
Print the current values of the kernel time variables. NOTE: The time
is "raw", and may be off by up to one timer tick (10 msec). "status"
gives the value of the \fBtime_status\fP variable in the kernel. For
Linux 1.0 and 1.2 kernels, the value is as follows:
.nf
0 clock is synchronized (so the kernel should
periodically set the CMOS clock to match the
system clock)
1 inserting a leap second at midnight
2 deleting a leap second at midnight
3 leap second in progress
4 leap second has occurred
5 clock not externally synchronized (so the
kernel should leave the CMOS clock alone)
.fi
For Linux 2.0 kernels, the value is a sum of these:
.nf
1 PLL updates enabled
2 PPS freq discipline enabled
4 PPS time discipline enabled
8 frequency-lock mode enabled
16 inserting leap second
32 deleting leap second
64 clock unsynchronized
128 holding frequency
256 PPS signal present
512 PPS signal jitter exceeded
1024 PPS signal wander exceeded
2048 PPS signal calibration error
4096 clock hardware fault
.fi
.IP "\fB\-t\fP \fIval\fP, \fB\-\-tick\fP \fIval\fP"
Set the number of microseconds that should be added to the system time
for each kernel tick interrupt. For a kernel with USER_HZ=100, there
are supposed to be 100 ticks per second, so \fIval\fP should be close
to 10000. Increasing \fIval\fP by 1 speeds up the system clock by
about 100 ppm, or 8.64 sec/day. \fItick\fP must be in the range
900000/USER_HZ...1100000/USER_HZ. If \fIval\fP is rejected by the
kernel, \fBadjtimex\fP will determine the acceptable range through
trial and error and print it. (After completing the search, it will
restore the original value.)
.IP "\fB\-f\fP \fInewfreq\fP, \fB\-\-frequency\fP \fInewfreq\fP"
Set the system clock frequency offset to \fInewfreq\fP. \fInewfreq\fP
can be negative or positive, and gives a much finer adjustment than
the \fB\-\-tick\fP switch. When USER_HZ=100, the value is scaled such
that \fInewfreq\fP = 65536 speeds up the system clock by about 1 ppm,
or .0864 sec/day. Thus, all of these are about the same:
.nf
\fB\-\-tick 9995 \--frequency 32768000\fP
\fB\-\-tick 10000 \--frequency 6553600\fP
\fB\-\-tick 10001 \--frequency 0\fP
\fB\-\-tick 10002 \--frequency -6553600\fP
\fB\-\-tick 10005 \--frequency -32768000\fP
.fi
To see the acceptable range for \fInewfreq\fP, use \-\-print and look at
"tolerance", or try an illegal value (e.g. \-\-tick 0).
.IP "\fB\-s\fP \fIadj\fP, \fB\-\-singleshot\fP \fIadj\fP"
Slew the system clock by \fIadj\fP usec.
(Its rate is changed temporarily by about 1 part in 2000.)
.IP "\fB\-o\fP \fIadj\fP, \fB\-\-offset\fP \fIadj\fP"
Add a time offset of \fIadj\fP usec.
The kernel code adjusts the time gradually by \fIadj\fP,
notes how long it has been since the last time offset,
and then adjusts the frequency offset to correct for the apparent drift.
.\"The short range of this parameter makes it almost
.\"totally useless except for use with ntpd:
\fIadj\fP must be in the range -512000...512000.
.IP "\fB\-S\fP \fIstatus\fP, \fB\-\-status\fP \fIstatus\fP"
Set kernel system clock status register to value \fIstatus\fP. Look here
above at the \fB\-\-print\fP switch section for the meaning of
\fIstatus\fP, depending on your kernel.
.IP "\fB\-R\fP, \fB\-\-reset\fP"
Reset clock status after setting a clock parameter. For early Linux
kernels, using the adjtimex(2) system call to set any time parameter
the kernel think the clock is synchronized with an external time
source, so it sets the kernel variable time_status to TIME_OK.
Thereafter, at 11 minute intervals, it will adjust the CMOS clock to
match. We prevent this "eleven minute mode" by setting the clock,
because that has the side effect of resetting time_status to TIME_BAD.
We try not to actually change the clock setting. Kernel versions
2.0.40 and later apparently don't need this. If your kernel does
require it, use this option with:
\fB\-t\fP
\fB\-T\fP
\fB\-t\fP
\fB\-e\fP
\fB\-m\fP
\fB\-f\fP
\fB\-s\fP
\fB\-o\fP
\fB\-c\fP
\fB\-r\fP.
.IP "\fB\-m\fP \fIval\fP, \fB\-\-maxerror\fP \fIval\fP"
Set maximum error (usec).
.IP "\fB\-e\fP \fIval\fP, \fB\-\-esterror\fP \fIval\fP"
Set estimated error (usec).
The maximum and estimated error are not used by the kernel.
They are merely made available to user processes via the
\fBadjtimex\fP(2) system call.
.IP "\fB\-T\fP \fIval\fP, \fB\-\-timeconstant\fP \fIval\fP"
Set phase locked loop (PLL) time constant.
\fIval\fP determines the bandwidth or "stiffness"
of the PLL. The effective PLL time constant will be a multiple of (1
<< \fIval\fP). For room\-temperature quartz
oscillators, David Mills recommends the value 2,
which corresponds
to a PLL time constant of about 900 sec and a maximum update interval
of about 64 sec. The maximum update interval scales directly with the
time constant, so that at the maximum time constant of 6, the
update interval can be as large as 1024 sec.
Values of \fIval\fP between zero and 2 give quick convergence; values
between 2 and 6 can be used to reduce network load, but at a modest cost
in accuracy.
.IP "\fB\-c\fP[\fIcount\fP], \fB\-\-compare\fP[\fB=\fP\fIcount\fP]"
Periodically compare the system clock with the CMOS clock. After the
first two calls, print values for tick and frequency offset that would
bring the system clock into approximate agreement with the CMOS clock.
CMOS clock readings are adjusted for systematic drift using using the
correction in \fI/etc/adjtime\fP \(em see \fBhwclock\fP(8). The
interval between comparisons is 10 seconds, unless changed by the
\fB\-\-interval\fP switch. The optional argument is the number of
comparisons. (If the argument is supplied, the "\fB=\fP" is
required.)
.IP "\fB\-a\fP[\fP\fIcount\fP], \fB\-\-adjust\fP[\fB=\fP\fIcount\fP]"
By itself, same as \fB\-\-compare\fP, except the recommended values are
actually installed after every third comparison. With \fB\-\-review\fP,
the tick and frequency are set to the least\-squares estimates. (In
the latter case, any \fIcount\fP value is ignored.)
.IP "\fB\-i\fP \fItim\fP, \fB\-\-interval\fP \fItim\fP"
Set the interval in seconds between clock comparisons for the
\fB\-\-compare\fP and \fB\-\-adjust\fP options.
.IP "\fB\-u\fP, \fB\-\-utc\fP"
The CMOS clock is set to UTC (universal time) rather than local time.
.IP "\fB\-l\fP[\fIfile\fP], \fB\-\-log\fP[\fB=\fP\fIfile\fP]"
Save the current values of the system and CMOS clocks, and optionally
a reference time, to \fIfile\fP (default \fI/var/log/clocks.log\fP).
The reference time is taken from a network timeserver (see the
\fB\-\-host\fP switch) or supplied by the user (see the \fB\-\-watch\fP
switch).
.IP "\fB\-h\fP \fItimeserver\fP, \fB\-\-host\fP \fItimeserver\fP"
Use \fBntpdate\fP to query the given timeserver for the current time.
This will fail if \fItimeserver\fP is not running a Network Time
Protocol (NTP) server, or if that server is not synchronized. Implies
\fB\-\-log\fP.
.IP "\fB\-w\fP, \fB\-\-watch\fP"
Ask for a keypress when the user knows the time, then ask what that
time was, and its approximate accuracy. Implies \fB\-\-log\fP.
.IP "\fB\-r\fP[\fIfile\fP], \fB\-\-review\fP[\fB=\fP\fIfile\fP]"
Review the clock log \fIfile\fP (default \fI/var/log/clocks.log\fP)
and estimate, if possible, the rates of the CMOS and system clocks.
Calculate least\-squares rates using all suitable log entries. Suggest
corrections to adjust for systematic drift. With \fB\-\-adjust\fP, the
frequency and tick are set to the suggested values. (The CMOS clock
correction is not changed.)
.IP "\fB\-h\fP, \fB\-\-help\fP"
Print the program options.
.IP "\fB\-v\fP, \fB\-\-version\fP"
Print the program version.
.PP
.\"}}}
.\"{{{ Examples
.SH EXAMPLES
If your system clock gained 8 seconds in 24 hours, you
could set the tick to 9999, and then it would lose 0.64 seconds a day
(that is, 1 tick unit = 8.64 seconds per day).
To correct the rest of the error, you could set the frequency offset to
(2^16)*0.64/.0864 = 485452. Thus, putting the following
in rc.local would approximately correct the system clock:
.nf
adjtimex --tick 9999 --freq 485452
.fi
.PP
.\"}}}
.\"{{{ Notes
.SH NOTES
\fBadjtimex\fP adjusts only the system clock \(em the one that runs
while the computer is powered up. To set or regulate the CMOS clock,
see \fBhwclock\fP(8).
.\"}}}
.\"{{{ Author
.SH AUTHORS
Steven S. Dick <ssd@nevets.oau.org>,
Jim Van Zandt <jrv at comcast.net>.
.\"}}}
.\"{{{ See also
.SH "SEE ALSO"
.BR date "(1L), " gettimeofday "(2), " settimeofday "(2), "
.BR hwclock "(8), " ntpdate "(8), " ntpd "(8), "
\fI/usr/src/linux/include/linux/timex.h,
/usr/src/linux/include/linux/sched.h,
/usr/src/linux/kernel/time.c,
/usr/src/linux/kernel/sched.c\fP
.\"}}}
adjtimex-1.20/mat.c 0000644 0001750 0001750 00000017034 06402303441 013613 0 ustar jrv jrv 0000000 0000000 /*
mat - manipulation of matrices
c can equal:
mat_zero 0 -> c
mat_one I -> c
mat_copy a -> c a
mat_add a + b -> c a or b
mat_sub a - b -> c a or b
mat_mul a b -> c
mat_mul_tn a' b -> c
mat_mul_nt a b' -> c
mat_similarity a b a' -> c b
sym_factor lower triangular factor of a -> c a
sym_rdiv (b already factored) a / b = a inv(b) -> c a
sym_ldiv (a already factored) a \ b = inv(a) b -> c b
Every matrix parameter is followed by two integers, which give the
number of rows and the number of columns. The result is always
returned in the last matrix. a' is the transpose of a. */
#include <assert.h>
#include <math.h> /* for sqrt() */
#include <stdlib.h> /* for malloc() and free() */
/* set c to zero */
void mat_zero(void *c, int cr, int cc)
{
double *_c = (double *)c;
int i;
for (i = 0; i < cr*cc; i++)
_c[i] = 0.;
}
/* set c to the unit matrix */
void mat_one(void *_c, int cr, int cc)
{
double *c = (double *)_c;
int i;
assert(cr == cc);
mat_zero(c, cr, cc);
#define C(i,j) c[i*cc+j]
for (i = 0; i < cr; i++)
C(i,i) = 1.;
#undef C
}
/* copy a to c */
void mat_copy(void *a, int ar, int ac,
void *c, int cr, int cc)
{
double *_a = (double *)a;
double *_c = (double *)c;
int i;
assert(ar == cr && ac == cc);
for (i = 0; i < ar*ac; i++)
_c[i] = _a[i];
}
/* Add a and b, and put result in c. c may be the same as a and/or b. */
void mat_add(void *a, int ar, int ac,
void *b, int br, int bc,
void *c, int cr, int cc)
{
double *_a = (double *)a;
double *_b = (double *)b;
double *_c = (double *)c;
int i;
assert(ar == br && br == cr && ac == bc && bc == cc);
for (i = 0; i < ar*ac; i++)
_c[i] = _a[i] + _b[i];
}
/* subtract b from a, and put result in c. c may be the same as a
and/or b. */
void mat_sub(void *a, int ar, int ac,
void *b, int br, int bc,
void *c, int cr, int cc)
{
double *_a = (double *)a;
double *_b = (double *)b;
double *_c = (double *)c;
int i;
assert(ar == br && br == cr && ac == bc && bc == cc);
for (i = 0; i < ar*ac; i++)
_c[i] = _a[i] - _b[i];
}
/* multiply a by b, put result in c */
void mat_mul(void *a, int ar, int ac,
void *b, int br, int bc,
void *c, int cr, int cc)
{
double *_a = (double *)a;
double *_b = (double *)b;
double *_c = (double *)c;
double s;
int i, j, k;
#define A(i,j) _a[i*ac+j]
#define B(i,j) _b[i*bc+j]
#define C(i,j) _c[i*cc+j]
assert(ar == cr && ac == br && bc == cc);
for (i = 0; i < cr; i++)
for (j = 0; j < cc; j++)
{
s = 0.;
for (k = 0; k < ac; k++)
s += A(i,k)*B(k,j);
C(i,j) = s;
}
#undef A
#undef B
#undef C
}
/* multiply a' by b, put result in c */
void mat_mul_tn(void *a, int ar, int ac,
void *b, int br, int bc,
void *c, int cr, int cc)
{
double *_a = (double *)a;
double *_b = (double *)b;
double *_c = (double *)c;
double s;
int i, j, k;
#define A(i,j) _a[i*ac+j]
#define B(i,j) _b[i*bc+j]
#define C(i,j) _c[i*cc+j]
assert(ac == cr && ar == br && bc == cc);
for (i = 0; i < cr; i++)
for (j = 0; j < cc; j++)
{
s = 0.;
for (k = 0; k < ar; k++)
s += A(k,i)*B(k,j);
C(i,j) = s;
}
#undef A
#undef B
#undef C
}
/* Multiply a by b', put result in c. */
void mat_mul_nt(void *a, int ar, int ac,
void *b, int br, int bc,
void *c, int cr, int cc)
{
double *_a = (double *)a;
double *_b = (double *)b;
double *_c = (double *)c;
double s;
int i, j, k;
#define A(i,j) _a[i*ac+j]
#define B(i,j) _b[i*bc+j]
#define C(i,j) _c[i*cc+j]
assert(ar == cr && ac == bc && br == cc);
for (i = 0; i < cr; i++)
for (j = 0; j < cc; j++)
{
s = 0.;
for (k = 0; k < ac; k++)
s += A(i,k)*B(j,k);
C(i,j) = s;
}
#undef A
#undef B
#undef C
}
/* Form the product a*b*a', and leave the result in c. Return nonzero
on failure (insufficient memory). */
int mat_similarity(void *a, int ar, int ac,
void *b, int br, int bc,
void *c, int cr, int cc)
{
void *t;
assert(ac==br && br == bc && ar==cr && cr==cc);
t = malloc(ar*bc*sizeof(double));
if (!t) return 1; /* failure */
mat_mul(a,ar,ac, b,br,bc, t,ar,bc);
mat_mul_nt(t,ar,bc, a,ar,ac, c,cr,cc);
free(t);
return 0;
}
/* Perform Cholesky decomposition on the square, symmetric matrix a,
and leave the lower triangular factor in c. The part of c above the
diagonal is not disturbed. c may be the same as a. Returns nonzero
if a is singular. Afterwards: if l is the lower triangular part of
c, and l' is the transpose of l, then a = l l'. */
int sym_factor(void *a, int ar, int ac,
void *c, int cr, int cc)
{
double *_a = (double *)a;
double *_c = (double *)c;
double d, s;
int i, j, k;
#define A(i,j) _a[i*ac+j]
#define C(i,j) _c[i*cc+j]
assert(ar == ac && ac == cr && cr == cc); /* must be square */
for (j = 0; j < cc; j++) /* columns of c */
{
s = A(j,j);
for (i = 0; i < j; i++) /* rows of c */
s -= C(j,i)*C(j,i);
if (s < 0.) return 1; /* failure (singular matrix) */
d = C(j,j) = sqrt(s);
for (i = j+1; i < cc; i++) /* columns of c */
{
s = A(i,j);
for (k = 0; k < j; k++)
s -= C(j,k)*C(i,k);
C(i,j) = s/d;
}
}
return 0;
#undef A
#undef C
}
/* right divide a by b (that is, multiply a by inverse of b), and
leave the result in c. b must already have been Cholesky
decomposed, and only its lower triangle is used. c may be the same
as a. */
void sym_rdiv(void *a, int ar, int ac,
void *b, int br, int bc,
void *c, int cr, int cc)
{
double *_a = (double *)a;
double *_b = (double *)b;
double *_c = (double *)c;
double s;
int i, j, k;
#define A(i,j) _a[i*ac+j]
#define B(i,j) _b[i*bc+j]
#define C(i,j) _c[i*cc+j]
assert(ar == cr && ac == cc && br == bc && ac == br);
for (i = 0; i < ar; i++) /* rows of a */
{
for (j = 0; j < ac; j++) /* cols of a */
{
s = A(i,j);
for (k = 0; k < j; k++)
s -= C(i,k)*B(j,k);
C(i,j) = s/B(j,j);
}
}
for (i = 0; i < cr; i++) /* rows of c */
{
for (j = cc; j--; ) /* cols of c */
{
s = C(i,j);
for (k = j+1; k < cc; k++)
s -= C(i,k)*B(k,j);
C(i,j) = s/B(j,j);
}
}
#undef A
#undef B
#undef C
}
/* left divide b by a (that is, multiply inverse of a by b), and leave
the result in c. a must already have been Cholesky decomposed, and
only its lower triangle is used. c may be the same as b. */
void sym_ldiv(void *a, int ar, int ac,
void *b, int br, int bc,
void *c, int cr, int cc)
{
double *_a = (double *)a;
double *_b = (double *)b;
double *_c = (double *)c;
double s;
int i, j, k;
#define A(i,j) _a[i*ac+j]
#define B(i,j) _b[i*bc+j]
#define C(i,j) _c[i*cc+j]
assert(ar == cr && ac == br && ar == ac && bc == cc);
for (j = 0; j < cc; j++) /* columns of c */
for (i = 0; i < cr; i++) /* rows of c */
{
s = B(i,j);
for (k = 0; k < i; k++)
s -= A(i,k)*C(k,j);
s = C(i,j) = s/A(i,i);
}
for (j = 0; j < cc; j++) /* columns of c */
for (i = cr; i--; ) /* rows of c */
{
s = C(i,j);
for (k = i+1; k < cr; k++)
s -= A(k,i)*C(k,j);
C(i,j) = s/A(i,i);
}
#undef A
#undef B
#undef C
}
adjtimex-1.20/mat.h 0000644 0001750 0001750 00000001326 06402303441 013615 0 ustar jrv jrv 0000000 0000000 void mat_copy(void *, int, int, void *, int, int);
void mat_add(void *, int, int, void *, int, int, void *, int, int);
void mat_sub(void *, int, int, void *, int, int, void *, int, int);
void mat_zero(void *, int, int);
void mat_one(void *, int, int);
void mat_mul(void *, int, int, void *, int, int, void *, int, int);
void mat_mul_tn(void *, int, int, void *, int, int, void *, int, int);
void mat_mul_nt(void *, int, int, void *, int, int, void *, int, int);
int mat_similarity(void *, int, int, void *, int, int, void *, int, int);
int sym_factor(void *, int, int, void *, int, int);
void sym_rdiv(void *, int, int, void *, int, int, void *, int, int);
void sym_ldiv(void *, int, int, void *, int, int, void *, int, int);
adjtimex-1.20/install-sh 0000755 0001750 0001750 00000011245 06353525324 014703 0 ustar jrv jrv 0000000 0000000 #! /bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.
#
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
transformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""
while [ x"$1" != x ]; do
case $1 in
-c) instcmd="$cpprog"
shift
continue;;
-d) dir_arg=true
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-s) stripcmd="$stripprog"
shift
continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift
continue;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift
continue;;
*) if [ x"$src" = x ]
then
src=$1
else
# this colon is to work around a 386BSD /bin/sh bug
:
dst=$1
fi
shift
continue;;
esac
done
if [ x"$src" = x ]
then
echo "install: no input file specified"
exit 1
else
true
fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
if [ -d $dst ]; then
instcmd=:
else
instcmd=mkdir
fi
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ]
then
true
else
echo "install: $src does not exist"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
exit 1
else
true
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d $dst ]
then
dst="$dst"/`basename $src`
else
true
fi
fi
## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# this part is taken from Noah Friedman's mkinstalldirs script
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"
pathcomp=''
while [ $# -ne 0 ] ; do
pathcomp="${pathcomp}${1}"
shift
if [ ! -d "${pathcomp}" ] ;
then
$mkdirprog "${pathcomp}"
else
true
fi
pathcomp="${pathcomp}/"
done
fi
if [ x"$dir_arg" != x ]
then
$doit $instcmd $dst &&
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
else
# If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
true
fi
# Make a temp file name in the proper directory.
dsttmp=$dstdir/#inst.$$#
# Move or copy the file name to the temp name
$doit $instcmd $src $dsttmp &&
trap "rm -f ${dsttmp}" 0 &&
# and set any options; do chmod last to preserve setuid bits
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
$doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
exit 0
adjtimex-1.20/configure.in 0000644 0001750 0001750 00000000761 06353525324 015211 0 ustar jrv jrv 0000000 0000000 dnl Process this file with autoconf to produce a configure script.
AC_INIT(adjtimex.c)
dnl Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LN_S
dnl Checks for libraries.
dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(limits.h sys/time.h unistd.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_HEADER_TIME
AC_STRUCT_TM
dnl Checks for library functions.
AC_CHECK_FUNCS(gettimeofday mktime putenv select)
AC_OUTPUT(Makefile)
adjtimex-1.20/configure 0000755 0001750 0001750 00000137207 10033610266 014603 0 ustar jrv jrv 0000000 0000000 #! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated automatically using autoconf version 2.13
# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
#
# This configure script is free software; the Free Software Foundation
# gives unlimited permission to copy, distribute and modify it.
# Defaults:
ac_help=
ac_default_prefix=/usr/local
# Any additions from configure.in:
# Initialize some variables set by options.
# The variables have the same names as the options, with
# dashes changed to underlines.
build=NONE
cache_file=./config.cache
exec_prefix=NONE
host=NONE
no_create=
nonopt=NONE
no_recursion=
prefix=NONE
program_prefix=NONE
program_suffix=NONE
program_transform_name=s,x,x,
silent=
site=
srcdir=
target=NONE
verbose=
x_includes=NONE
x_libraries=NONE
bindir='${exec_prefix}/bin'
sbindir='${exec_prefix}/sbin'
libexecdir='${exec_prefix}/libexec'
datadir='${prefix}/share'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
libdir='${exec_prefix}/lib'
includedir='${prefix}/include'
oldincludedir='/usr/include'
infodir='${prefix}/info'
mandir='${prefix}/man'
# Initialize some other variables.
subdirs=
MFLAGS= MAKEFLAGS=
SHELL=${CONFIG_SHELL-/bin/sh}
# Maximum number of lines to put in a shell here document.
ac_max_here_lines=12
ac_prev=
for ac_option
do
# If the previous option needs an argument, assign it.
if test -n "$ac_prev"; then
eval "$ac_prev=\$ac_option"
ac_prev=
continue
fi
case "$ac_option" in
-*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) ac_optarg= ;;
esac
# Accept the important Cygnus configure options, so we can diagnose typos.
case "$ac_option" in
-bindir | --bindir | --bindi | --bind | --bin | --bi)
ac_prev=bindir ;;
-bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
bindir="$ac_optarg" ;;
-build | --build | --buil | --bui | --bu)
ac_prev=build ;;
-build=* | --build=* | --buil=* | --bui=* | --bu=*)
build="$ac_optarg" ;;
-cache-file | --cache-file | --cache-fil | --cache-fi \
| --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
ac_prev=cache_file ;;
-cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
| --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
cache_file="$ac_optarg" ;;
-datadir | --datadir | --datadi | --datad | --data | --dat | --da)
ac_prev=datadir ;;
-datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
| --da=*)
datadir="$ac_optarg" ;;
-disable-* | --disable-*)
ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
# Reject names that are not valid shell variable names.
if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
{ echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
fi
ac_feature=`echo $ac_feature| sed 's/-/_/g'`
eval "enable_${ac_feature}=no" ;;
-enable-* | --enable-*)
ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
# Reject names that are not valid shell variable names.
if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
{ echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
fi
ac_feature=`echo $ac_feature| sed 's/-/_/g'`
case "$ac_option" in
*=*) ;;
*) ac_optarg=yes ;;
esac
eval "enable_${ac_feature}='$ac_optarg'" ;;
-exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
| --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
| --exec | --exe | --ex)
ac_prev=exec_prefix ;;
-exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
| --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
| --exec=* | --exe=* | --ex=*)
exec_prefix="$ac_optarg" ;;
-gas | --gas | --ga | --g)
# Obsolete; use --with-gas.
with_gas=yes ;;
-help | --help | --hel | --he)
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat << EOF
Usage: configure [options] [host]
Options: [defaults in brackets after descriptions]
Configuration:
--cache-file=FILE cache test results in FILE
--help print this message
--no-create do not create output files
--quiet, --silent do not print \`checking...' messages
--version print the version of autoconf that created configure
Directory and file names:
--prefix=PREFIX install architecture-independent files in PREFIX
[$ac_default_prefix]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[same as prefix]
--bindir=DIR user executables in DIR [EPREFIX/bin]
--sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
--libexecdir=DIR program executables in DIR [EPREFIX/libexec]
--datadir=DIR read-only architecture-independent data in DIR
[PREFIX/share]
--sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data in DIR
[PREFIX/com]
--localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
--libdir=DIR object code libraries in DIR [EPREFIX/lib]
--includedir=DIR C header files in DIR [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
--infodir=DIR info documentation in DIR [PREFIX/info]
--mandir=DIR man documentation in DIR [PREFIX/man]
--srcdir=DIR find the sources in DIR [configure dir or ..]
--program-prefix=PREFIX prepend PREFIX to installed program names
--program-suffix=SUFFIX append SUFFIX to installed program names
--program-transform-name=PROGRAM
run sed PROGRAM on installed program names
EOF
cat << EOF
Host type:
--build=BUILD configure for building on BUILD [BUILD=HOST]
--host=HOST configure for HOST [guessed]
--target=TARGET configure for TARGET [TARGET=HOST]
Features and packages:
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--x-includes=DIR X include files are in DIR
--x-libraries=DIR X library files are in DIR
EOF
if test -n "$ac_help"; then
echo "--enable and --with options recognized:$ac_help"
fi
exit 0 ;;
-host | --host | --hos | --ho)
ac_prev=host ;;
-host=* | --host=* | --hos=* | --ho=*)
host="$ac_optarg" ;;
-includedir | --includedir | --includedi | --included | --include \
| --includ | --inclu | --incl | --inc)
ac_prev=includedir ;;
-includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
| --includ=* | --inclu=* | --incl=* | --inc=*)
includedir="$ac_optarg" ;;
-infodir | --infodir | --infodi | --infod | --info | --inf)
ac_prev=infodir ;;
-infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
infodir="$ac_optarg" ;;
-libdir | --libdir | --libdi | --libd)
ac_prev=libdir ;;
-libdir=* | --libdir=* | --libdi=* | --libd=*)
libdir="$ac_optarg" ;;
-libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
| --libexe | --libex | --libe)
ac_prev=libexecdir ;;
-libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
| --libexe=* | --libex=* | --libe=*)
libexecdir="$ac_optarg" ;;
-localstatedir | --localstatedir | --localstatedi | --localstated \
| --localstate | --localstat | --localsta | --localst \
| --locals | --local | --loca | --loc | --lo)
ac_prev=localstatedir ;;
-localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
| --localstate=* | --localstat=* | --localsta=* | --localst=* \
| --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
localstatedir="$ac_optarg" ;;
-mandir | --mandir | --mandi | --mand | --man | --ma | --m)
ac_prev=mandir ;;
-mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
mandir="$ac_optarg" ;;
-nfp | --nfp | --nf)
# Obsolete; use --without-fp.
with_fp=no ;;
-no-create | --no-create | --no-creat | --no-crea | --no-cre \
| --no-cr | --no-c)
no_create=yes ;;
-no-recursion | --no-recursion | --no-recursio | --no-recursi \
| --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
no_recursion=yes ;;
-oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
| --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
| --oldin | --oldi | --old | --ol | --o)
ac_prev=oldincludedir ;;
-oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
| --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
| --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
oldincludedir="$ac_optarg" ;;
-prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
ac_prev=prefix ;;
-prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
prefix="$ac_optarg" ;;
-program-prefix | --program-prefix | --program-prefi | --program-pref \
| --program-pre | --program-pr | --program-p)
ac_prev=program_prefix ;;
-program-prefix=* | --program-prefix=* | --program-prefi=* \
| --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
program_prefix="$ac_optarg" ;;
-program-suffix | --program-suffix | --program-suffi | --program-suff \
| --program-suf | --program-su | --program-s)
ac_prev=program_suffix ;;
-program-suffix=* | --program-suffix=* | --program-suffi=* \
| --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
program_suffix="$ac_optarg" ;;
-program-transform-name | --program-transform-name \
| --program-transform-nam | --program-transform-na \
| --program-transform-n | --program-transform- \
| --program-transform | --program-transfor \
| --program-transfo | --program-transf \
| --program-trans | --program-tran \
| --progr-tra | --program-tr | --program-t)
ac_prev=program_transform_name ;;
-program-transform-name=* | --program-transform-name=* \
| --program-transform-nam=* | --program-transform-na=* \
| --program-transform-n=* | --program-transform-=* \
| --program-transform=* | --program-transfor=* \
| --program-transfo=* | --program-transf=* \
| --program-trans=* | --program-tran=* \
| --progr-tra=* | --program-tr=* | --program-t=*)
program_transform_name="$ac_optarg" ;;
-q | -quiet | --quiet | --quie | --qui | --qu | --q \
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
| --sbi=* | --sb=*)
sbindir="$ac_optarg" ;;
-sharedstatedir | --sharedstatedir | --sharedstatedi \
| --sharedstated | --sharedstate | --sharedstat | --sharedsta \
| --sharedst | --shareds | --shared | --share | --shar \
| --sha | --sh)
ac_prev=sharedstatedir ;;
-sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
| --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
| --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
| --sha=* | --sh=*)
sharedstatedir="$ac_optarg" ;;
-site | --site | --sit)
ac_prev=site ;;
-site=* | --site=* | --sit=*)
site="$ac_optarg" ;;
-srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
ac_prev=srcdir ;;
-srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
srcdir="$ac_optarg" ;;
-sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
| --syscon | --sysco | --sysc | --sys | --sy)
ac_prev=sysconfdir ;;
-sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
| --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
sysconfdir="$ac_optarg" ;;
-target | --target | --targe | --targ | --tar | --ta | --t)
ac_prev=target ;;
-target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
target="$ac_optarg" ;;
-v | -verbose | --verbose | --verbos | --verbo | --verb)
verbose=yes ;;
-version | --version | --versio | --versi | --vers)
echo "configure generated by autoconf version 2.13"
exit 0 ;;
-with-* | --with-*)
ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
# Reject names that are not valid shell variable names.
if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
{ echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
fi
ac_package=`echo $ac_package| sed 's/-/_/g'`
case "$ac_option" in
*=*) ;;
*) ac_optarg=yes ;;
esac
eval "with_${ac_package}='$ac_optarg'" ;;
-without-* | --without-*)
ac_package=`echo $ac_option|sed -e 's/-*without-//'`
# Reject names that are not valid shell variable names.
if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
{ echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
fi
ac_package=`echo $ac_package| sed 's/-/_/g'`
eval "with_${ac_package}=no" ;;
--x)
# Obsolete; use --with-x.
with_x=yes ;;
-x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
| --x-incl | --x-inc | --x-in | --x-i)
ac_prev=x_includes ;;
-x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
| --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
x_includes="$ac_optarg" ;;
-x-libraries | --x-libraries | --x-librarie | --x-librari \
| --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
ac_prev=x_libraries ;;
-x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
| --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
x_libraries="$ac_optarg" ;;
-*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
;;
*)
if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
echo "configure: warning: $ac_option: invalid host type" 1>&2
fi
if test "x$nonopt" != xNONE; then
{ echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
fi
nonopt="$ac_option"
;;
esac
done
if test -n "$ac_prev"; then
{ echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
fi
trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
# File descriptor usage:
# 0 standard input
# 1 file creation
# 2 errors and warnings
# 3 some systems may open it to /dev/tty
# 4 used on the Kubota Titan
# 6 checking for... messages and results
# 5 compiler messages saved in config.log
if test "$silent" = yes; then
exec 6>/dev/null
else
exec 6>&1
fi
exec 5>./config.log
echo "\
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
" 1>&5
# Strip out --no-create and --no-recursion so they do not pile up.
# Also quote any args containing shell metacharacters.
ac_configure_args=
for ac_arg
do
case "$ac_arg" in
-no-create | --no-create | --no-creat | --no-crea | --no-cre \
| --no-cr | --no-c) ;;
-no-recursion | --no-recursion | --no-recursio | --no-recursi \
| --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
*" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
ac_configure_args="$ac_configure_args '$ac_arg'" ;;
*) ac_configure_args="$ac_configure_args $ac_arg" ;;
esac
done
# NLS nuisances.
# Only set these to C if already set. These must not be set unconditionally
# because not all systems understand e.g. LANG=C (notably SCO).
# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
# Non-C LC_CTYPE values break the ctype check.
if test "${LANG+set}" = set; then LANG=C; export LANG; fi
if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
# confdefs.h avoids OS command line length limits that DEFS can exceed.
rm -rf conftest* confdefs.h
# AIX cpp loses on an empty file, so make sure it contains at least a newline.
echo > confdefs.h
# A filename unique to this package, relative to the directory that
# configure is in, which we can look for to find out if srcdir is correct.
ac_unique_file=adjtimex.c
# Find the source files, if location was not specified.
if test -z "$srcdir"; then
ac_srcdir_defaulted=yes
# Try the directory containing this script, then its parent.
ac_prog=$0
ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
srcdir=$ac_confdir
if test ! -r $srcdir/$ac_unique_file; then
srcdir=..
fi
else
ac_srcdir_defaulted=no
fi
if test ! -r $srcdir/$ac_unique_file; then
if test "$ac_srcdir_defaulted" = yes; then
{ echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
else
{ echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
fi
fi
srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
# Prefer explicitly selected file to automatically selected ones.
if test -z "$CONFIG_SITE"; then
if test "x$prefix" != xNONE; then
CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
else
CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
fi
fi
for ac_site_file in $CONFIG_SITE; do
if test -r "$ac_site_file"; then
echo "loading site script $ac_site_file"
. "$ac_site_file"
fi
done
if test -r "$cache_file"; then
echo "loading cache $cache_file"
. $cache_file
else
echo "creating cache $cache_file"
> $cache_file
fi
ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
ac_cpp='$CPP $CPPFLAGS'
ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
cross_compiling=$ac_cv_prog_cc_cross
ac_exeext=
ac_objext=o
if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
# Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
ac_n= ac_c='
' ac_t=' '
else
ac_n=-n ac_c= ac_t=
fi
else
ac_n= ac_c='\c' ac_t=
fi
# Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:529: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
ac_cv_prog_CC="gcc"
break
fi
done
IFS="$ac_save_ifs"
fi
fi
CC="$ac_cv_prog_CC"
if test -n "$CC"; then
echo "$ac_t""$CC" 1>&6
else
echo "$ac_t""no" 1>&6
fi
if test -z "$CC"; then
# Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:559: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
ac_prog_rejected=no
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
ac_prog_rejected=yes
continue
fi
ac_cv_prog_CC="cc"
break
fi
done
IFS="$ac_save_ifs"
if test $ac_prog_rejected = yes; then
# We found a bogon in the path, so make sure we never use it.
set dummy $ac_cv_prog_CC
shift
if test $# -gt 0; then
# We chose a different compiler from the bogus one.
# However, it has the same basename, so the bogon will be chosen
# first if we set CC to just the basename; use the full file name.
shift
set dummy "$ac_dir/$ac_word" "$@"
shift
ac_cv_prog_CC="$@"
fi
fi
fi
fi
CC="$ac_cv_prog_CC"
if test -n "$CC"; then
echo "$ac_t""$CC" 1>&6
else
echo "$ac_t""no" 1>&6
fi
if test -z "$CC"; then
case "`uname -s`" in
*win32* | *WIN32*)
# Extract the first word of "cl", so it can be a program name with args.
set dummy cl; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:610: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
ac_cv_prog_CC="cl"
break
fi
done
IFS="$ac_save_ifs"
fi
fi
CC="$ac_cv_prog_CC"
if test -n "$CC"; then
echo "$ac_t""$CC" 1>&6
else
echo "$ac_t""no" 1>&6
fi
;;
esac
fi
test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
echo "configure:642: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
ac_cpp='$CPP $CPPFLAGS'
ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
cross_compiling=$ac_cv_prog_cc_cross
cat > conftest.$ac_ext << EOF
#line 653 "configure"
#include "confdefs.h"
main(){return(0);}
EOF
if { (eval echo configure:658: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
ac_cv_prog_cc_works=yes
# If we can't run a trivial program, we are probably using a cross compiler.
if (./conftest; exit) 2>/dev/null; then
ac_cv_prog_cc_cross=no
else
ac_cv_prog_cc_cross=yes
fi
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_prog_cc_works=no
fi
rm -fr conftest*
ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
ac_cpp='$CPP $CPPFLAGS'
ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
cross_compiling=$ac_cv_prog_cc_cross
echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
if test $ac_cv_prog_cc_works = no; then
{ echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
echo "configure:684: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
cross_compiling=$ac_cv_prog_cc_cross
echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
echo "configure:689: checking whether we are using GNU C" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.c <<EOF
#ifdef __GNUC__
yes;
#endif
EOF
if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:698: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
ac_cv_prog_gcc=yes
else
ac_cv_prog_gcc=no
fi
fi
echo "$ac_t""$ac_cv_prog_gcc" 1>&6
if test $ac_cv_prog_gcc = yes; then
GCC=yes
else
GCC=
fi
ac_test_CFLAGS="${CFLAGS+set}"
ac_save_CFLAGS="$CFLAGS"
CFLAGS=
echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
echo "configure:717: checking whether ${CC-cc} accepts -g" >&5
if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
echo 'void f(){}' > conftest.c
if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
ac_cv_prog_cc_g=yes
else
ac_cv_prog_cc_g=no
fi
rm -f conftest*
fi
echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
if test "$ac_test_CFLAGS" = set; then
CFLAGS="$ac_save_CFLAGS"
elif test $ac_cv_prog_cc_g = yes; then
if test "$GCC" = yes; then
CFLAGS="-g -O2"
else
CFLAGS="-g"
fi
else
if test "$GCC" = yes; then
CFLAGS="-O2"
else
CFLAGS=
fi
fi
ac_aux_dir=
for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
if test -f $ac_dir/install-sh; then
ac_aux_dir=$ac_dir
ac_install_sh="$ac_aux_dir/install-sh -c"
break
elif test -f $ac_dir/install.sh; then
ac_aux_dir=$ac_dir
ac_install_sh="$ac_aux_dir/install.sh -c"
break
fi
done
if test -z "$ac_aux_dir"; then
{ echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; }
fi
ac_config_guess=$ac_aux_dir/config.guess
ac_config_sub=$ac_aux_dir/config.sub
ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
# Find a good install program. We prefer a C program (faster),
# so one script is as good as another. But avoid the broken or
# incompatible versions:
# SysV /etc/install, /usr/sbin/install
# SunOS /usr/etc/install
# IRIX /sbin/install
# AIX /bin/install
# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
# AFS /usr/afsws/bin/install, which mishandles nonexistent args
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
echo "configure:779: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":"
for ac_dir in $PATH; do
# Account for people who put trailing slashes in PATH elements.
case "$ac_dir/" in
/|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
*)
# OSF1 and SCO ODT 3.0 have their own names for install.
# Don't use installbsd from OSF since it installs stuff as root
# by default.
for ac_prog in ginstall scoinst install; do
if test -f $ac_dir/$ac_prog; then
if test $ac_prog = install &&
grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
# AIX install. It has an incompatible calling convention.
:
else
ac_cv_path_install="$ac_dir/$ac_prog -c"
break 2
fi
fi
done
;;
esac
done
IFS="$ac_save_IFS"
fi
if test "${ac_cv_path_install+set}" = set; then
INSTALL="$ac_cv_path_install"
else
# As a last resort, use the slow shell script. We don't cache a
# path for INSTALL within a source directory, because that will
# break other packages using the cache if that directory is
# removed, or if the path is relative.
INSTALL="$ac_install_sh"
fi
fi
echo "$ac_t""$INSTALL" 1>&6
# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
# It thinks the first close brace ends the variable substitution.
test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
echo "configure:832: checking whether ln -s works" >&5
if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
rm -f conftestdata
if ln -s X conftestdata 2>/dev/null
then
rm -f conftestdata
ac_cv_prog_LN_S="ln -s"
else
ac_cv_prog_LN_S=ln
fi
fi
LN_S="$ac_cv_prog_LN_S"
if test "$ac_cv_prog_LN_S" = "ln -s"; then
echo "$ac_t""yes" 1>&6
else
echo "$ac_t""no" 1>&6
fi
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
echo "configure:855: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
fi
if test -z "$CPP"; then
if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
# This must be in double quotes, not single quotes, because CPP may get
# substituted into the Makefile and "${CC-cc}" will confuse make.
CPP="${CC-cc} -E"
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
#line 870 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:876: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
else
echo "$ac_err" >&5
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
#line 887 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:893: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
else
echo "$ac_err" >&5
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
CPP="${CC-cc} -nologo -E"
cat > conftest.$ac_ext <<EOF
#line 904 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:910: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
else
echo "$ac_err" >&5
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
CPP=/lib/cpp
fi
rm -f conftest*
fi
rm -f conftest*
fi
rm -f conftest*
ac_cv_prog_CPP="$CPP"
fi
CPP="$ac_cv_prog_CPP"
else
ac_cv_prog_CPP="$CPP"
fi
echo "$ac_t""$CPP" 1>&6
echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
echo "configure:935: checking for ANSI C header files" >&5
if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 940 "configure"
#include "confdefs.h"
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <float.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:948: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
ac_cv_header_stdc=yes
else
echo "$ac_err" >&5
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
ac_cv_header_stdc=no
fi
rm -f conftest*
if test $ac_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
#line 965 "configure"
#include "confdefs.h"
#include <string.h>
EOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
egrep "memchr" >/dev/null 2>&1; then
:
else
rm -rf conftest*
ac_cv_header_stdc=no
fi
rm -f conftest*
fi
if test $ac_cv_header_stdc = yes; then
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
#line 983 "configure"
#include "confdefs.h"
#include <stdlib.h>
EOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
egrep "free" >/dev/null 2>&1; then
:
else
rm -rf conftest*
ac_cv_header_stdc=no
fi
rm -f conftest*
fi
if test $ac_cv_header_stdc = yes; then
# /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
if test "$cross_compiling" = yes; then
:
else
cat > conftest.$ac_ext <<EOF
#line 1004 "configure"
#include "confdefs.h"
#include <ctype.h>
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
int main () { int i; for (i = 0; i < 256; i++)
if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
exit (0); }
EOF
if { (eval echo configure:1015: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
:
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -fr conftest*
ac_cv_header_stdc=no
fi
rm -fr conftest*
fi
fi
fi
echo "$ac_t""$ac_cv_header_stdc" 1>&6
if test $ac_cv_header_stdc = yes; then
cat >> confdefs.h <<\EOF
#define STDC_HEADERS 1
EOF
fi
for ac_hdr in limits.h sys/time.h unistd.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:1042: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1047 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1052: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
eval "ac_cv_header_$ac_safe=yes"
else
echo "$ac_err" >&5
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
eval "ac_cv_header_$ac_safe=no"
fi
rm -f conftest*
fi
if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
echo "$ac_t""yes" 1>&6
ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
cat >> confdefs.h <<EOF
#define $ac_tr_hdr 1
EOF
else
echo "$ac_t""no" 1>&6
fi
done
echo $ac_n "checking for working const""... $ac_c" 1>&6
echo "configure:1080: checking for working const" >&5
if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1085 "configure"
#include "confdefs.h"
int main() {
/* Ultrix mips cc rejects this. */
typedef int charset[2]; const charset x;
/* SunOS 4.1.1 cc rejects this. */
char const *const *ccp;
char **p;
/* NEC SVR4.0.2 mips cc rejects this. */
struct point {int x, y;};
static struct point const zero = {0,0};
/* AIX XL C 1.02.0.0 rejects this.
It does not let you subtract one const X* pointer from another in an arm
of an if-expression whose if-part is not a constant expression */
const char *g = "string";
ccp = &g + (g ? g-g : 0);
/* HPUX 7.0 cc rejects these. */
++ccp;
p = (char**) ccp;
ccp = (char const *const *) p;
{ /* SCO 3.2v4 cc rejects this. */
char *t;
char const *s = 0 ? (char *) 0 : (char const *) 0;
*t++ = 0;
}
{ /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
int x[] = {25, 17};
const int *foo = &x[0];
++foo;
}
{ /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
typedef const int *iptr;
iptr p = 0;
++p;
}
{ /* AIX XL C 1.02.0.0 rejects this saying
"k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
struct s { int j; const int *ap[3]; };
struct s *b; b->j = 5;
}
{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
const int foo = 10;
}
; return 0; }
EOF
if { (eval echo configure:1134: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_const=yes
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
ac_cv_c_const=no
fi
rm -f conftest*
fi
echo "$ac_t""$ac_cv_c_const" 1>&6
if test $ac_cv_c_const = no; then
cat >> confdefs.h <<\EOF
#define const
EOF
fi
echo $ac_n "checking for inline""... $ac_c" 1>&6
echo "configure:1155: checking for inline" >&5
if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_cv_c_inline=no
for ac_kw in inline __inline__ __inline; do
cat > conftest.$ac_ext <<EOF
#line 1162 "configure"
#include "confdefs.h"
int main() {
} $ac_kw foo() {
; return 0; }
EOF
if { (eval echo configure:1169: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_inline=$ac_kw; break
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
fi
rm -f conftest*
done
fi
echo "$ac_t""$ac_cv_c_inline" 1>&6
case "$ac_cv_c_inline" in
inline | yes) ;;
no) cat >> confdefs.h <<\EOF
#define inline
EOF
;;
*) cat >> confdefs.h <<EOF
#define inline $ac_cv_c_inline
EOF
;;
esac
echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
echo "configure:1195: checking whether time.h and sys/time.h may both be included" >&5
if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1200 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/time.h>
#include <time.h>
int main() {
struct tm *tp;
; return 0; }
EOF
if { (eval echo configure:1209: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_header_time=yes
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
ac_cv_header_time=no
fi
rm -f conftest*
fi
echo "$ac_t""$ac_cv_header_time" 1>&6
if test $ac_cv_header_time = yes; then
cat >> confdefs.h <<\EOF
#define TIME_WITH_SYS_TIME 1
EOF
fi
echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6
echo "configure:1230: checking whether struct tm is in sys/time.h or time.h" >&5
if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1235 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <time.h>
int main() {
struct tm *tp; tp->tm_sec;
; return 0; }
EOF
if { (eval echo configure:1243: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_struct_tm=time.h
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
ac_cv_struct_tm=sys/time.h
fi
rm -f conftest*
fi
echo "$ac_t""$ac_cv_struct_tm" 1>&6
if test $ac_cv_struct_tm = sys/time.h; then
cat >> confdefs.h <<\EOF
#define TM_IN_SYS_TIME 1
EOF
fi
for ac_func in gettimeofday mktime putenv select
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:1267: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1272 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
#include <assert.h>
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char $ac_func();
int main() {
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
choke me
#else
$ac_func();
#endif
; return 0; }
EOF
if { (eval echo configure:1295: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
eval "ac_cv_func_$ac_func=no"
fi
rm -f conftest*
fi
if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
echo "$ac_t""yes" 1>&6
ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
cat >> confdefs.h <<EOF
#define $ac_tr_func 1
EOF
else
echo "$ac_t""no" 1>&6
fi
done
trap '' 1 2 15
cat > confcache <<\EOF
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure
# scripts and configure runs. It is not useful on other systems.
# If it contains results you don't want to keep, you may remove or edit it.
#
# By default, configure uses ./config.cache as the cache file,
# creating it if it does not exist already. You can give configure
# the --cache-file=FILE option to use a different cache file; that is
# what configure does when it calls configure scripts in
# subdirectories, so they share the cache.
# Giving --cache-file=/dev/null disables caching, for debugging configure.
# config.status only pays attention to the cache file if you give it the
# --recheck option to rerun configure.
#
EOF
# The following way of writing the cache mishandles newlines in values,
# but we know of no workaround that is simple, portable, and efficient.
# So, don't put newlines in cache variables' values.
# Ultrix sh set writes to stderr and can't be redirected directly,
# and sets the high bit in the cache file unless we assign to the vars.
(set) 2>&1 |
case `(ac_space=' '; set | grep ac_space) 2>&1` in
*ac_space=\ *)
# `set' does not quote correctly, so add quotes (double-quote substitution
# turns \\\\ into \\, and sed turns \\ into \).
sed -n \
-e "s/'/'\\\\''/g" \
-e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
;;
*)
# `set' quotes correctly as required by POSIX, so do not add quotes.
sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
;;
esac >> confcache
if cmp -s $cache_file confcache; then
:
else
if test -w $cache_file; then
echo "updating cache $cache_file"
cat confcache > $cache_file
else
echo "not updating unwritable cache $cache_file"
fi
fi
rm -f confcache
trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
test "x$prefix" = xNONE && prefix=$ac_default_prefix
# Let make expand exec_prefix.
test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
# Any assignment to VPATH causes Sun make to only execute
# the first set of double-colon rules, so remove it if not needed.
# If there is a colon in the path, we need to keep it.
if test "x$srcdir" = x.; then
ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
fi
trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
# Transform confdefs.h into DEFS.
# Protect against shell expansion while executing Makefile rules.
# Protect against Makefile macro expansion.
cat > conftest.defs <<\EOF
s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g
s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g
s%\[%\\&%g
s%\]%\\&%g
s%\$%$$%g
EOF
DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '`
rm -f conftest.defs
# Without the "./", some shells look in PATH for config.status.
: ${CONFIG_STATUS=./config.status}
echo creating $CONFIG_STATUS
rm -f $CONFIG_STATUS
cat > $CONFIG_STATUS <<EOF
#! /bin/sh
# Generated automatically by configure.
# Run this file to recreate the current configuration.
# This directory was configured as follows,
# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
#
# $0 $ac_configure_args
#
# Compiler output produced by configure, useful for debugging
# configure, is in ./config.log if it exists.
ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
for ac_option
do
case "\$ac_option" in
-recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
-version | --version | --versio | --versi | --vers | --ver | --ve | --v)
echo "$CONFIG_STATUS generated by autoconf version 2.13"
exit 0 ;;
-help | --help | --hel | --he | --h)
echo "\$ac_cs_usage"; exit 0 ;;
*) echo "\$ac_cs_usage"; exit 1 ;;
esac
done
ac_given_srcdir=$srcdir
ac_given_INSTALL="$INSTALL"
trap 'rm -fr `echo "Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
EOF
cat >> $CONFIG_STATUS <<EOF
# Protect against being on the right side of a sed subst in config.status.
sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
$ac_vpsub
$extrasub
s%@SHELL@%$SHELL%g
s%@CFLAGS@%$CFLAGS%g
s%@CPPFLAGS@%$CPPFLAGS%g
s%@CXXFLAGS@%$CXXFLAGS%g
s%@FFLAGS@%$FFLAGS%g
s%@DEFS@%$DEFS%g
s%@LDFLAGS@%$LDFLAGS%g
s%@LIBS@%$LIBS%g
s%@exec_prefix@%$exec_prefix%g
s%@prefix@%$prefix%g
s%@program_transform_name@%$program_transform_name%g
s%@bindir@%$bindir%g
s%@sbindir@%$sbindir%g
s%@libexecdir@%$libexecdir%g
s%@datadir@%$datadir%g
s%@sysconfdir@%$sysconfdir%g
s%@sharedstatedir@%$sharedstatedir%g
s%@localstatedir@%$localstatedir%g
s%@libdir@%$libdir%g
s%@includedir@%$includedir%g
s%@oldincludedir@%$oldincludedir%g
s%@infodir@%$infodir%g
s%@mandir@%$mandir%g
s%@CC@%$CC%g
s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g
s%@INSTALL_DATA@%$INSTALL_DATA%g
s%@LN_S@%$LN_S%g
s%@CPP@%$CPP%g
CEOF
EOF
cat >> $CONFIG_STATUS <<\EOF
# Split the substitutions into bite-sized pieces for seds with
# small command number limits, like on Digital OSF/1 and HP-UX.
ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
ac_file=1 # Number of current file.
ac_beg=1 # First line for current file.
ac_end=$ac_max_sed_cmds # Line after last line for current file.
ac_more_lines=:
ac_sed_cmds=""
while $ac_more_lines; do
if test $ac_beg -gt 1; then
sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
else
sed "${ac_end}q" conftest.subs > conftest.s$ac_file
fi
if test ! -s conftest.s$ac_file; then
ac_more_lines=false
rm -f conftest.s$ac_file
else
if test -z "$ac_sed_cmds"; then
ac_sed_cmds="sed -f conftest.s$ac_file"
else
ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
fi
ac_file=`expr $ac_file + 1`
ac_beg=$ac_end
ac_end=`expr $ac_end + $ac_max_sed_cmds`
fi
done
if test -z "$ac_sed_cmds"; then
ac_sed_cmds=cat
fi
EOF
cat >> $CONFIG_STATUS <<EOF
CONFIG_FILES=\${CONFIG_FILES-"Makefile"}
EOF
cat >> $CONFIG_STATUS <<\EOF
for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
# Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
case "$ac_file" in
*:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
*) ac_file_in="${ac_file}.in" ;;
esac
# Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
# Remove last slash and all that follows it. Not all systems have dirname.
ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
# The file is in a subdirectory.
test ! -d "$ac_dir" && mkdir "$ac_dir"
ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
# A "../" for each directory in $ac_dir_suffix.
ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
else
ac_dir_suffix= ac_dots=
fi
case "$ac_given_srcdir" in
.) srcdir=.
if test -z "$ac_dots"; then top_srcdir=.
else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
/*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
*) # Relative path.
srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
top_srcdir="$ac_dots$ac_given_srcdir" ;;
esac
case "$ac_given_INSTALL" in
[/$]*) INSTALL="$ac_given_INSTALL" ;;
*) INSTALL="$ac_dots$ac_given_INSTALL" ;;
esac
echo creating "$ac_file"
rm -f "$ac_file"
configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
case "$ac_file" in
*Makefile*) ac_comsub="1i\\
# $configure_input" ;;
*) ac_comsub= ;;
esac
ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
sed -e "$ac_comsub
s%@configure_input@%$configure_input%g
s%@srcdir@%$srcdir%g
s%@top_srcdir@%$top_srcdir%g
s%@INSTALL@%$INSTALL%g
" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
fi; done
rm -f conftest.s*
EOF
cat >> $CONFIG_STATUS <<EOF
EOF
cat >> $CONFIG_STATUS <<\EOF
exit 0
EOF
chmod +x $CONFIG_STATUS
rm -fr confdefs* $ac_clean_files
test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
adjtimex-1.20/Makefile.in 0000644 0001750 0001750 00000003375 10123323064 014734 0 ustar jrv jrv 0000000 0000000 #### Start of system configuration section. -*-makefile-*- ####
srcdir = .
VPATH = .
VERSION=1.20
CFLAGS = @CFLAGS@ -Wall
prefix = @prefix@
man1dir=@mandir@/man1
exec_prefix = @exec_prefix@
bindir=/sbin
INSTALL=@INSTALL@
# Extension (not including `.') for the manual page filenames.
manext = 8
# Where to put the manual pages.
mandir = $(prefix)/share/man/man$(manext)
#### End of system configuration section. ####
SHELL = /bin/sh
SRC = adjtimex.c adjtimex.8 mat.c mat.h install-sh configure.in \
configure Makefile.in README README.ru adjtimex.lsm adjtimex.lsm.in \
COPYING COPYRIGHT ChangeLog
all: adjtimex adjtimex.lsm
adjtimex: adjtimex.c mat.o
$(CC) $(CFLAGS) -I. -DVERSION=\"$(VERSION)\" -o adjtimex adjtimex.c \
mat.o -lm
adjtimex.lsm: adjtimex.lsm.in Makefile.in
sed -e 's/@VERSION@/$(VERSION)/' \
-e "s/@DATE@/`date +%d%b%y|tr [a-z] [A-Z]`/" \
adjtimex.lsm.in >adjtimex.lsm
mat.o: mat.c
$(CC) $(CFLAGS) -c mat.c
install: all
$(INSTALL) -g bin -m 755 -o root adjtimex $(bindir)/adjtimex
$(INSTALL) -d -g root -m 755 -o root $(mandir)
-$(INSTALL) -g root -m 644 -o root $(srcdir)/adjtimex.8 \
$(mandir)/adjtimex.$(manext)
uninstall:
rm -f $(bindir)/adjtimex $(mandir)/adjtimex.$(manext)
clean:
rm -f core *.o
veryclean: clean
rm -f adjtimex
shar: $(SRC)
distname=adjtimex-$(VERSION); \
shar $(SRC) >$$distname.shar
dist: $(SRC)
distname=adjtimex-$(VERSION); \
rm -fr $$distname; \
mkdir $$distname; \
for file in $(SRC); do \
ln $$file $$distname/$$file \
|| { echo copying $$file instead; cp -p $$file $$distname/$$file;}; \
done; \
chmod -R a+rX $$distname; \
tar -chz -f $$distname.tar.gz $$distname; \
rm -fr $$distname
adjtimex-1.20/README 0000644 0001750 0001750 00000015312 10033612725 013546 0 ustar jrv jrv 0000000 0000000 ADJTIMEX
I will assume you have already read the man page for adjtimex :-)
BACKGROUND
You probably already know that your computer has two clocks - the "real
time clock" (RTC) that runs all the time, and the system clock that runs
only while the computer is on. The system clock has much better
precision (approximately 1 usec), but the RTC probably has better
long-term stability. adjtimex can be used to approximately correct the
system clock for drift.
The handiest reference clock is the RTC.
adjtimex --compare
shows the time, the difference between the two clocks, the first
difference (how much the system clock has gained or lost relative to
the RTC since the last check), and two kernel time parameters: tick
and frequency offset. After the first two comparisons, it also prints
suggested values of tick and frequency offset that will adjust the
system clock to approximately agree with the RTC. Of course, the RTC
may have a systematic error of its own. clock(8) or hwclock(8) use
the file /etc/adjtime to record the drift rate and the time since the
RTC was last set. adjtimex also consults this file and applies the
correction to the times from the RTC.
adjtimex can also record the times on both clocks, and optionally
another reference time, in a log. It can later compare the logged
time and estimate drift rates.
INSTALLATION
Type "./configure" to configure, "make" to compile, then "make
install" to copy the binary to /usr/local/bin, and the man page to
/usr/local/man/man8. If you want the program installed in /usr rather
than /usr/local, start with "./configure --prefix=/usr".
ASIDES
You will have to log in as root for most of the following.
The standard kernel will leave the RTC alone only until one of the
time parameters is set (using adjtimex, for example). Then it thinks
ntpd is regulating the system time, and it starts "correcting" the
RTC approximately every eleven minutes. adjtimex prevents this by
setting the time after setting any parameter. It does not actually
change the time.
USAGE
Create /etc/adjtime, which is used by clock(8) and hwclock(8) to
correct for systematic error in the RTC. Set it up as explained in
the man page for each program. clock is included (along with a lot of
other useful utilities) in Rik Faith's collection:
sunsite.unc.edu:pub/Linux/system/Misc/util-linux-1.10.tar.gz If your
RTC is already accurate enough to suit you, just create a file
/etc/adjtime containing as the first and only line: '0.0 0 0.0'.
I'll explain the manual procedure first.
Compile and run adjtimex with the --compare switch.
Suppose the result is:
# adjtimex --compare
794625929 -0.597638 -0.597638 ...
794625939 -0.602050 -0.004412 ...
^^^^^^^^^
This number says the system clock lost over 4 msec in just 10 sec with
respect to the RTC, or 4 parts in 10000. Therefore, we increase the
tick parameter to 10004, and repeat the comparison:
# adjtimex --tick 10004
# adjtimex --compare
794626037 -0.644860 -0.644860 ...
794626047 -0.645259 -0.000399 ...
Now the system clock is slow by about 39.9 parts per million. We can
change the frequency offset to fix this. Recall that the frequency
offset is in parts per million, with the fraction point in the center
(16 bits on either side). Therefore, we set the offset to 39.9*65536 =
2614886:
# adjtimex --frequency 2614886
# adjtimex --compare
794626313 -0.652147 -0.652147 ...
794626323 -0.652247 -0.000100 ...
It still seems to be off by about 10 ppm, so we increase the offset
by 10*65536, to 3270246:
# adjtimex --frequency 3270246
# adjtimex --compare
794627233 -0.795221 -0.795221 ...
794627243 -0.795231 -0.000009 ...
The entries in the "suggested" columns are calculated in this way.
Using the --adjust switch automates the process - periodically
installing the "suggested" values.
By the way, using the --offset or --singleshot options seems to have a
long-term effect on the clock. I suggest you determine the tick and
frequency settings before trying the other options.
You may already have an entry like this in /etc/rc.d/rc.S,
/etc/init.d/boot, or one of the other startup files:
# Adjust CMOS clock based on /etc/adjtime, then set system clock.
# Add -u switch if your system keeps GMT.
if [ -x /sbin/clock ]; then
/sbin/clock -a
fi
Just add an entry like this:
# Regulate the sytem clock
if [ -x /sbin/adjtimex ]; then
/sbin/adjtimex --tick 10004 --frequency 3270246
fi
LONG TERM COMPARISONS
You can use adjtimex to record the values of the CMOS and system
times, and optionally a reference time, so drift rates can be
determined over long periods. To enter a reference time manually, use
# adjtimex --log --watch
adjtimex will ask you to hit a key when you know the time, then will
ask the time and its approximate precision. It will then ask whether
either clock has been disturbed since the previous log entry. You can
take the time from an accurate clock, a radio time broadcast like WWV
or CHU, etc.
If you have ntpdate installed (part of the xntp package), and your
computer has network connectivity, use
# adjtimex --log --host www.xxx.yyy.zzz
and adjtimex will use ntpdate to request the time from the specified
host. (Ask your Internet Service Provider whether he has an NTP time
server, or can suggest one.)
After you have made several log entries, you can ask adjtimex to
review the log with
# adjtimex --review
It will take each pair of log entries in turn, and calculate the error
in each clock's rate in parts per million (ppm), with its estimated
uncertainty. It will also find over-all average errors, and will
suggest parameter values to correct for drift. Be sure to check the
outputs for consistency. One incorrect reference time can throw off
all the calculations.
FURTHER READING
For authoritative documentation on the kernel time software, see
the following, all by David L. Mills <mills@udel.edu>:
[MIL92a] Mills, D.L. Network Time Protocol (Version 3) specification,
implementation and analysis, RFC 1305, University of Delaware, March
1992, 113 pp.
[MIL92c] Mills, D.L. Simple Network Time Protocol (SNTP), RFC 1361,
University of Delaware, August 1992, 10 pp.
[MIL94a] Mills, D.L. A kernel model for precision timekeeping. ARPA
Network Working Group Report RFC-1589, University of Delaware, March
1994. 31 pp.
README.kern, which can be found in louie.udel.edu:/pub/ntp/kernel.tar.Z.
THANKS
to David Mills for the kernel timekeeping code, and Steven Dick
<ssd@nevets.oau.org> for writing adjtimex originally. (I've changed
the code a lot. Any problems are my responsibility.) Thanks also to
Michael Meskes <meskes@debian.org>, whose Debian installation script
inspired the "--compare" and "--adjust" options.
Enjoy!
- Jim Van Zandt <jrv at comcast.net>
adjtimex-1.20/README.ru 0000644 0001750 0001750 00000015745 10033612653 014205 0 ustar jrv jrv 0000000 0000000 ADJTIMEX
Я буду считать, что вы уже прочитали страничку man по adjtimex :-)
ВВЕДЕНИЕ
Возможно, вы уже знаете, что в вашем компьютере имеются двое часов -
"часы реального времени" (RTC - Real Time Clock), которые идут все время,
и системные часы, которые идут только при включенном компьютере. Точность
выше у системных часов (примерно 1 uсек), но у RTC, возможно, лучше
стабильность на длительном промежутке (long-term stability). adjtimex
предназначен для приблизительной коррекции ухода системных часов.
RTC являются удобными опорными часами
adjtimex --compare
показывает время, разницу между двумя часами, первое различие (как сильно
спешат или отстают системные часы по сравнению с последней сверкой с RTC),
и два временных параметра ядра: tick и сдвиг частоты. После первых двух
сравнений он также выводит рекомендуемые значения тиков и сдвига частоты,
которые подрегулируют системные часы с приблизительным значением RTC.
Конечно, RTC могут имеют собственную систематическую ошибку. clock(8) или
hwclock(8) используют файл /etc/adjtime для записи коэффициента ухода
(drift rate) и времени после последней установки RTC. adjtimex также
сверяется с этим файлом и использует коррекцию ко времени RTC.
Кроме того, adjtimex может записывать время обоих часов и дополнительное
опорное (reference) время, в лог. Затем это сравнивается с записанным
временем и рассчитываются величины ухода (drift rates).
УСТАНОВКА
Для конфигурирования наберите "./configure", для компиляции - "make",
затем "make install" для копирования бинарника в /usr/local/bin, а
страницы man в /usr/local/man/man8. Если вы хотите установить программу
в /usr вместо /usr/local, начните с "./configure --prefix=/usr".
КРОМЕ ТОГО
Для выполнения большинства нижеследующих действий вы должны войти как root.
Стандартное ядро не будет трогать RTC, пока не будет устанавливаться один
из временных параметров (например, с помощью adjtimex). Затем, предполагая,
что ntpd регулирует системное время, запускает "коррекцию" RTC примерно
каждые одиннадцать минут. adjtimex предотвращает это установкой времени
после изменения любого параметра. В действительности время не изменится.
ИСПОЛЬЗОВАНИЕ
Создайте /etc/adjtime, который используется clock(8) и hwclock(8) для
коррекции систематической ошибки в RTC. Установите его, как описано в
странице man, для каждой программы. clock включается (вместе с множеством
других полезных утилит) в коллекцию Рика Фэйта (Rik Faith):
sunsite.unc.edu:pub/Linux/system/Misc/util-linux-1.10.tar.gz Если ваш RTC
уже достаточно точен для вас, просто создайте файл /etc/adjtime, содержащий
только одну первую строчку: '0.0 0 0.0'.
Сначала я объясню ручную процедуру.
Скомпилируйте и запустите adjtimex с ключом --compare.
Ожидаемые результаты примерно такие:
# adjtimex --compare
794625929 -0.597638 -0.597638 ...
794625939 -0.602050 -0.004412 ...
^^^^^^^^^
Это число сообщает, что системные часы отстают более чем на 4 миллисекунды
за 10 секунд по сравнению с RTC, или 4 части на 10000. Следовательно,
мы увеличиваем параметр tick до 10004 и повторяем сравнение:
# adjtimex --tick 10004
# adjtimex --compare
794626037 -0.644860 -0.644860 ...
794626047 -0.645259 -0.000399 ...
Теперь системные часы отстают примерно на 39.9 частей на миллион. Для
коррекции этого мы можем изменить сдвиг частоты (frequency offset).
Вспомните, что сдвиг частоты - это в частях на миллион, с точкой деления
в центре (по 16 бит с каждой стороны). Следовательно, мы устанавливаем
сдвиг в 39.9*65536 = 2614886:
# adjtimex --frequency 2614886
# adjtimex --compare
794626313 -0.652147 -0.652147 ...
794626323 -0.652247 -0.000100 ...
Видно, что есть еще разница около 10 ppm, поэтому мы увеличим сдвиг на
10*65536, до 3270246:
# adjtimex --frequency 3270246
# adjtimex --compare
794627233 -0.795221 -0.795221 ...
794627243 -0.795231 -0.000009 ...
Таким же образом высчитываются значения в колонке "suggested" ("Рекомедновано").
Применение ключа --adjust автоматизирует процесс - периодически устанавливая
"рекомендуемые" значения.
Кстати, использование опций --offset или --singleshot кажется имеют
длительное действие на часы. Я рекомендую вам определить значения tick и
частоты до применения других опций.
У вас уже может быть запись, подобная этой, в /etc/rc.d/rc.S, /etc/init.d/boot
или одном из других стартовых файлов:
# Adjust CMOS clock based on /etc/adjtime, then set system clock.
# Add -u switch if your system keeps GMT.
if [ -x /sbin/clock ]; then
/sbin/clock -a
fi
Просто добавьте запись типа этой:
# Regulate the sytem clock
if [ -x /sbin/adjtimex ]; then
/sbin/adjtimex --tick 10004 --frequency 3270246
fi
ПРОДОЛЖИТЕЛЬНЫЕ СРАВНЕНИЯ
adjtimex можно использовать для записи значений времени CMOS и системы,
и дополнительного опорного (reference) времени, чтобы можно было определить
коэффициент ухода за длительные периоды. Для ручного ввода опорного
времени используйте
# adjtimex --log --watch
adjtimex попросит вас нажать клавишу, когда вы знаете время, затем
спросит время и приблизительную точность. Затем спросит был ли сбой каких
либо часов с момента последней записи в логе. Время вы можете взять с
точных часов, радиомаяка времени типа WWV или CHU и т.д.
Если у вас установлен ntpdate (часть пакета xntp) и компьютер подключен
к сети, используйте
# adjtimex --log --host www.xxx.yyy.zzz
и adjtimex будет использовать ntpdate для запроса времени с указанного
хоста. (Уточните у своего провайдера, имеет ли он сервер времени NTP,
или какой он может предложить.)
После того, как вы сделаете несколько записей в log, вы можете заставить
adjtimex просмотреть лог с помощью
# adjtimex --review
Он возьмет каждую пару записей лога в цикле и вычислит для них коэффициент
ошибки в частях на миллион (ppm) с заданной точностью. Также будут найдены
усредненные ошибки и предложены значения параметров для корректировки ухода.
Проверьте согласованность результата. Одна неправильная запись опорного
времени может погубить все вычисления.
ДАЛЬНЕЙШАЯ ИНФОРМАЦИЯ
Авторитетную документацию по программе времени ядра смотрите сдесь,
все написано David L. Mills <mills@udel.edu>:
[MIL92a] Mills, D.L. Network Time Protocol (Version 3) specification,
implementation and analysis, RFC 1305, University of Delaware, March
1992, 113 pp.
[MIL92c] Mills, D.L. Simple Network Time Protocol (SNTP), RFC 1361,
University of Delaware, August 1992, 10 pp.
[MIL94a] Mills, D.L. A kernel model for precision timekeeping. ARPA
Network Working Group Report RFC-1589, University of Delaware, March
1994. 31 pp.
README.kern, который можно найти на louie.udel.edu:/pub/ntp/kernel.tar.Z.
БЛАГОДАРНОСТИ
Дэвиду Миллсу (David Mills) за код сохранения времени ядра, и Стивену
Дику (Steven Dick) <ssd@nevets.oau.org> за первоначальное написание
adjtimex. (Я сильно изменил код. Любые проблемы - моя ответственность.)
Благодарность также Микаэлю Мескесу (Michael Meskes) <meskes@debian.org>,
чей инсталляционный скрипт в Debian вдохновил на опции "--compare" и
"--adjust".
Наслаждайтесь!
- Jim Van Zandt <jrv at comcast.net>
adjtimex-1.20/adjtimex.lsm 0000644 0001750 0001750 00000000643 10123323643 015207 0 ustar jrv jrv 0000000 0000000 Begin3
Title: adjtimex - display or set the kernel time variables
Version: 1.20
Entered-date: 19SEP04
Description: Adjusts the system clock
Keywords: time, system clock, hardware clock
Author: ssd@nevets.oau.org (Steven S. Dick)
Maintained-by: jrv@removeme.comcast.net (Jim Van Zandt)
Primary-site: sunsite.unc.edu /pub/Linux/utils/administration
47k adjtimex-1.20.tar.gz
Platforms: Linux
Copying-policy: GPL
End
adjtimex-1.20/adjtimex.lsm.in 0000644 0001750 0001750 00000000654 10033612367 015622 0 ustar jrv jrv 0000000 0000000 Begin3
Title: adjtimex - display or set the kernel time variables
Version: @VERSION@
Entered-date: @DATE@
Description: Adjusts the system clock
Keywords: time, system clock, hardware clock
Author: ssd@nevets.oau.org (Steven S. Dick)
Maintained-by: jrv@removeme.comcast.net (Jim Van Zandt)
Primary-site: sunsite.unc.edu /pub/Linux/utils/administration
47k adjtimex-@VERSION@.tar.gz
Platforms: Linux
Copying-policy: GPL
End
adjtimex-1.20/COPYING 0000644 0001750 0001750 00000043076 06516736677 013761 0 ustar jrv jrv 0000000 0000000 GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sam