[comp.protocols.time.ntp] More xntp patches for SGI IRIS

rbthomas@frogpond.rutgers.edu (Rick Thomas) (06/28/91)

I sent this to U of Toronto to be "vetted" by the gurus, but
things seem to be going more slowly than I had hoped with getting an
"official" version of my patches available to the world.

Soooo.....

Here is a preliminary version (It works fine, it just hasn't been
vetted.  We've had it up here for several months.)

I solicit your comments, especially anything you can suggest to improve
the usefulness of the "EXPLANATION" file.  I will post again if there
are any significant changes in the final version.

Enjoy!

========================================================================
Rick Thomas, Manager
Supercomputer Remote Access Center, Rm D117
Rutgers University, College of Engineering
Brett and Bowser Roads
Piscataway, NJ 08855-0909

Phone: (908) 932-4301
Internet: rbthomas@jove.rutgers.edu
UUCP: {any backbone site}!rutgers!rbthomas

"Soap and education are not as sudden as a massacre,
	but they are more deadly in the long run."  -- Mark Twain
========================================================================
#	This is a shell archive.
#	Remove everything above and including the cut line.
#	Then run the rest of the file through sh.
#----cut here-----cut here-----cut here-----cut here----#
#!/bin/sh
# shar:    Shell Archiver
#	Run the following text with /bin/sh to create:
#	./EXPLANATION
#	./Config.Convex
#	./Config.README
#	./Config.SGI
#	./Config.Sun
#	./Config.Sun386
#	./Makefile.diff
#	./Patch.sh
#	./clockstuff/Makefile.diff
#	./gizmo/Makefile.diff
#	./include/ntp.h.diff
#	./install
#	./lib/Makefile.diff
#	./lib/getopt.c.diff
#	./make-Config-usage
#	./ntpdate/Makefile.diff
#	./ntpq/Makefile.diff
#	./util/Makefile.diff
#	./util/tickadj.c.diff
#	./xntpd/Makefile.diff
#	./xntpd/ntp_io.c.diff
#	./xntpd/ntp_loopfilter.c.diff
#	./xntpd/ntp_unixclock.c.diff
#	./xntpdc/Makefile.diff
#	./xntpres/Makefile.diff
# This archive created: Mon Mar  4 14:27:46 1991
# By:	Rick Thomas (Rutgers Engineering Supercomputer Lab)
echo shar: extracting ./EXPLANATION
sed 's/^XX//' << \SHAR_EOF > ./EXPLANATION
XXThe enclosed shell archive contains a collection of modifications to
XXthe "released" version of xntpd dated Dec 11, 1990, located in
XX
XX	louie.udel.edu:/pub/ntp/xntp/xntp.tar.Z
XX
XXThis preamble is an attempt to explain what the changes do and why I made them.
XX
XXMy primary motivation was to get xntpd running on our Silicon-Graphics
XXIRIS machines running IRIX 3.3.1 and our Convex C1/XP running ConvexOS
XXRelease V8.1, as well as our collection of Sun3's and Sun4's.  In the
XXprocess, I have paramaeterized and generalized the Makefile and Config
XXfiles, so that all system dependent parameters and flags are
XXcentralized in the Config file as much as possible.  One single,
XXcommon, set of source code files now can generate running xntp
XXversions for all of our machines.  As a result, porting xntpd to
XXadditional architectures should now be somewhat easier as well.
XX
XXWhat follows is commentary on each of the individual changes.
XX
XXConfig:
XX	I added configuration variables: "RANLIB", "KMEMGRP", ALIBS",
XXand "INSTALL".  See the commentary in Config.README for a detailed
XXexplanation of these.  The purpose was to avoid the necessity of doing
XXsurgery on the Makefile's to get things to compile and install on a
XXvariety of architectures.
XX
XXConfig.*:
XX	I added sample Config files for all the architectures I had
XXhandy.  Other people are encouraged to add more. (Config.Sun386 is from
XXMatthias Ernst <maer@nmr.lpc.ethz.ch> of the Institut fuer
XXphysikalische Chemie, ETH-Zentrum Zuerich)  In order to keep the size
XXof the shar file of changes to a minimum, I moved all the commentary
XXinto Config.README .
XX
XXinstall:
XX	Unfortunately, some systems (specifically SGI's IRIX) use a
XXdifferent syntax for the "install" command than the makefiles expect.
XXFortunately, for such cases, I have written a shell script that does
XXwhat is needed.  (It is not a full blown "install", but it does the job
XXwe need done.)  Unfortunately, this script needs the 'getopts' shell
XXbuiltin, which is not supported on the Convex standard /bin/sh shell.
XXFortunately, the standard Convex /usr/bin/install program works just
XXfine with the makefiles.
XX
XXPatch.sh:
XX	This is a little shell script written by Matthias Ernst to
XXapply all these patches.
XX
XXMakefile:
XX	I added a line to install 'util/tickadj' since it is sometimes
XXneeded to patch the running kernel at boot time, and therefor needs to
XXbe in the BINDIR directory.
XX
XXmake-config-usage:
XX	I wrote a little shell script that finds all configuration
XXvariables and makes a file called 'config-usage' that lists which
XXfiles reference which config variables.  This is very useful in
XXtracking down inconsistent usage of config variables.
XX
XX*/Makefile:
XX	I made several modifications to have the Makefile's use the
XXnew Config variables.  In some cases (notably gizmo/Makefile) it was
XXnecessary to change some make variable names where they conflicted
XXwith Config variable names.  No substantive changes were made in such
XXcases.
XX
XXinclude/ntp.h
XX	For the SGI and Convex versions, it was necessary to open up
XXthe window in which xntpd would try to slew rather than step the time.
XXFor these machines the window is set to 350 ms, as opposed to the
XXconventional value of 128 ms.  This may not be strictly necessary for
XXthe Convex, but in the case of the SGIs, there seems to be a bug in the
XXIRIX 3.3.1 implementation of adjtime and settimeofday when large
XXchanges are made to the time, which makes the clock much "stiffer" than
XXit should be.  (It seems to want to resist large time changes.  Calling
XX"settimeofday" or "adjtime" completes normally, and the adjustment is
XXmade, but the clock soon drifts back to its original offset.)  If the
XX"ntp.drift" value is zero on one of these machines, the clock will
XXnever sync up.  What happens is that in the 8 minutes and 32 seconds
XXthat it takes xntp to initially get a fix on the server's clock, the
XXlocal clock has drifted more than 128 ms, and a step is deemed to be
XXnecessary.  Since "drift" computations are not done by the loopfilter
XXfor a step correction, the drift value never changes from its initial
XXvalue of zero, and the clock never syncs up.  We end up making step
XXcorrections every 8 minutes and 32 seconds.  If a reasonably accurate
XXestimate of the local clock's drift value is available, and can be put
XXinto the ntp.drift file, then the small adjustments for wander (for
XXwhich the IRIX "stiffness" bug seems not to appear) are enough to keep
XXthe clock in sync.  By opening up the window to 350 ms, it was possible
XXto get a few slew adjustments after each step adjustment, and thus
XXfinally get sufficient data to get a fix on the drift.  SGI has been
XXinformed of the bug, and it may be fixed soon.
XX
XXlib/getopt.c:
XX	There is a bug in the Convex linker (for some reason it seems
XXonly to affect getopt.c) that requires that all variables in getopt.c
XXbe initialized.  Since these changes are transparent on other systems,
XXI did not parameterize them on "#ifdef convex".  Convex has been
XXinformed of the bug.
XX
XXutil/Makefile:
XX	I changed the Makefile to install tickadj with the set-gid bit
XXon, and an appropriate group to allow it to read /dev/kmem, so that it
XXcan be used for read-only purposes without being root.
XX
XXutil/tickadj.c:
XX	Most of the changes here are not original with me.  They
XXoriginated with Matthias Ernst.  They add an 'S' option to tickadj that
XXsets the "dosynctodr" kernel variable to 1, whereas the 's' option sets
XXit to zero.  This is useful for debugging on machines like Sun's that
XXhave a "dosynctodr" variable to set.  SGI's and Convex's do not.  I
XXdid, however, add some changes to try to make tickadj useful on all the
XXarchitectures I had access to.  That job is only partly done.  Diddling
XXwith low level OS clock handling code is extremely architecture
XXdependent.  It almost has to be done over from scratch for each new
XXmachine.  There is only so much of this kind of thing I am willing to
XXundertake.
XX
XXxntpd/ntp_io.c:
XX	For the Convex, I added "#include"s for a couple of header
XXfiles that were needed only on the Convex.  They are parameterized on
XX"#ifdef convex".
XX
XXxntpd/ntp_loopfilter.c:
XX	The IRIX 3.3.1 kernel clock handler has a parameter variable
XXcalled "timetrim" that can be set at sysgen time and reset at run
XXtime.  It's purpose is to trim up the local clock to compensate for
XXintrinsic drift caused by SGI using lousy crystals.  It represents the
XXnumber of nanoseconds of drift in the crystal per 10ms clock-tick.
XXWith a proper setting of timetrim, the SGI clock can be made to keep
XXexcellent time.  Without it, its terrible.  The above mentioned
XX"stiffness" bug fortunately does not affect the timetrim calculations.
XXBy adjusting timetrim to follow the calculated drift, it is possible to
XXkeep the adjtime values small enough that they are not affected by the
XXstiffness bug either.  In order to do this, it was necessary to pass
XXthe drift compensation value separately to the OS specific routines in
XXntp_unixclock.c.  The net effect for non SGI machines is that the
XXaddition of "drift_adjust" into "adjustment" gets done in
XXntp_unixclock.c rather than in ntp_loopfilter.c, and adj_systime has
XXtwo arguments instead of one.  The details of setting the timetrim
XXvalue are discussed later.
XX	In addition, I felt that only logging messages that said you
XXwere doing a STEP adjustment when you were running in "debug" mode was
XXtantamount to leaving the life-preserver at home when you headed out
XXinto deep water.  You would never be notified if you had a problem with
XXkeeping your clock in sync.  I changed "syslog(LOG_DEBUG,..." to
XX"syslog(LOG_INFO,..." for the "STEP" case.  I did not change the
XXmessage priority for the "SLEW" case, though, to keep log file
XXpollution to a minimum.  After all, a series of small slews are normal
XXbehavior.  Steps are not normal.  Also, I fixed a bug in the printing
XXof the STEP log message.  lfptoa was being called with too few arguments.
XX
XXxntpd/ntp_unixclock.c:
XX	Here is where the bulk of the work of getting xntpd to run on
XXIRIX 3.3.1 takes place.  As noted above, adj_systime now has two
XXarguments instead of one.  I changed the debug printout to show both
XXarguments.  Ifdef'ed on not being on SGI hardware, I add the drift into
XXthe offset, to compensate for the fact that it is no longer being done
XXin ntp_loopfilter.c.  Ifdef'ed on being on SGI hardware, I convert the
XX"drift_adj" argument to appropriate units and set timetrim via the
XX"syssgi" system call.  The conversion involves an integer multiply and
XXinteger divide, but the IRIS hardware does those operations in a few
XXcycles, so I did not bother to try to avoid them.  The conversion needs
XXthe value of the cpp variable "CLOCK_ADJ" from "include/ntp.h".
XXUnfortunately, this name was used in ntp_unixclock.c for something
XXelse, so there are a flurry of non-substantive changes to introduce a
XXnew variable, "CLOCK_ADJ_SEC", to take it's place.  For some reason,
XX"include/ntp.h" wants <netinet/in.h> to be included as well, so I did
XXthat too.
XX	The SGI manual claims that adjtime is accurate and independent
XXof implementation parameters of the clock driver (and it probably would
XXbe too, if the "stiffness" bug were fixed), so I defined
XX"ADJTIME_IS_ACCURATE" in Config.SGI.  Implicit in that statement is
XXthe conclusion that one can slew the clock as much as one wants, and
XXthere are no artificial limitations.  Therefor, I set tvu_maxslew to
XX999990 if ADJTIME_IS_ACCURATE is defined.
XX	The variables "tick" and "tickadj" have no meaning in the SGI
XXclock driver implementation, so, ifdef'ed on sgi hardware, I
XXshort-circuited the routine that mucks around in /dev/kmem trying to
XXfind them.  (This idea originated with Matthias Ernst, with help from
XXScott Henry <scotth@sgi.com>.  Also from Matthias are some changes that
XXattempt to make things work on Sun 386i machines.  I don't have access
XXto any 386i's, so I have not tested this code.  Mathias reports that
XX"On the 386 everything except the resolver works fine. In the resolver
XXlibrary a variable `extern int h_errno' is used, which the linker can't
XXfind. I don't have the time to find the error, it's probably a bug in
XXthe SunOS for the 386.")
XX	I have been warned by Tom Mitchell <mitch@sgi.com> that setting
XXthe "timetrim" variable every 4 seconds may not be good for the SGI
XXclock driver, and it would be better to set it less frequently (once
XXper hour was suggested), but I have seen no ill effects from setting it
XXevery time adj_systime is called.
XX
XX========================================================================
XXRick Thomas, Manager
XXSupercomputer Remote Access Center, Rm D117
XXRutgers University, College of Engineering
XXBrett and Bowser Roads
XXPiscataway, NJ 08855-0909
XX
XXPhone: (908) 932-4301
XXInternet: rbthomas@jove.rutgers.edu
XXUUCP: {any backbone site}!rutgers!rbthomas
XXAlternate UUCP: {convex|c1apple|karna}!kingtut!rbthomas
XX
XX"Soap and education are not as sudden as a massacre,
XX	but they are more deadly in the long run."  -- Mark Twain
XX========================================================================
SHAR_EOF
if test 10950 -ne "`wc -c ./EXPLANATION`"
then
echo shar: error transmitting ./EXPLANATION '(should have been 10950 characters)'
fi
echo shar: extracting ./Config.Convex
sed 's/^XX//' << \SHAR_EOF > ./Config.Convex
XXLIBDEFS=	-DBIG_ENDIAN
XXDEFS= -DDEBUG -DCONFIG_FILE=\\"/usr/local/etc/xntp/ntp.conf\\" -DNO_SIGNED_CHAR_DECL -Dconvex
XXCLOCKDEFS=
XXDAEMONLIBS=
XXRESLIB=
XXCOPTS= -O
XXCOMPILER= pcc
XXBINDIR=	/usr/local/etc/xntp
XXRANLIB= ranlib
XXKMEMGRP= sys
XXALIBS= 
XXINSTALL= /usr/bin/install
SHAR_EOF
if test 261 -ne "`wc -c ./Config.Convex`"
then
echo shar: error transmitting ./Config.Convex '(should have been 261 characters)'
fi
echo shar: extracting ./Config.README
sed 's/^XX//' << \SHAR_EOF > ./Config.README
XX# Edit this file to reflect information specific to your installation.
XX# Then run 'make makefiles' to propagate the information to all the makefiles,
XX
XX#
XX# Definitions for the library:
XX#
XX# You must define *either* -DBIG_ENDIAN *or* -DLITTLE_ENDIAN depending
XX#	on which way your machine's bytes go for the benefit of the
XX#	DES routine.  Most things sold by DEC, the NS32x32 and the 80386
XX#	deserve a -DLITTLE_ENDIAN.  Most of the rest of the world does it
XX#	the other way.  If in doubt, pick one, compile everything and run
XX#	authstuff/authcert < authstuff/certdata.  If everything fails,
XX#	do it the other way.
XX#
XXLIBDEFS=	-DBIG_ENDIAN
XX
XX#
XX# Definitions for programs:
XX# 
XX# If your compiler doesn't understand the declaration `signed char',
XX#       add -DNO_SIGNED_CHAR_DECL.  Your `char' data type had better be
XX#	signed.  If you don't know what the compiler knows, try it
XX#	without the flag.  If you get a syntax error on line 13 of
XX#	ntp.h, add it.  Note that `signed char' is an ANSIism.  Most
XX#	older, pcc-derived compilers will need this flag.
XX#
XX# For SunOS 3.x, add -DSUN_3_3_STINKS (otherwise it will complain
XX#	about broadaddr and will hang if you run without a -d flag
XX#	on the command line.  I actually can't believe the latter
XX#	bug.  If it hangs on your system with the flag defined, peruse
XX#	xntpd/ntp_io.c for some rude comments about SunOS 3.5 and try it
XX#	the other way).  This flag affects xntpd only.
XX#
XX# For Ultrix 2.0, add -DULT_2_0_SUCKS.  This OS has the same hanging
XX#	bug as SunOS 3.5 (is this an original 4.2 bug?) and in addition
XX#	has some strangeness concerning signal masks.  Ultrix 2.3 doesn't
XX#	have these problems.  If you're running something in between
XX#	you're on your own.  This flag affects xntpd only.
XX#
XX# If your gethostbyname() routine isn't based on the DNS resolver (and,
XX#	in particular, h_errno doesn't exist) add a -DNODNS.  There
XX#	doesn't seem to be a good way to detect this automatically which
XX#	works in all cases.  This flag affects xntpres only.
XX#
XX# The flag -DDEBUG includes some debugging code.
XX#
XX# The flag -DREFCLOCK causes the basic reference clock support to be
XX#	compiled into the daemon.  If you set this you will also want
XX#	to configure the particular clock drivers you want in the
XX#	CLOCKDEFS= line below.  This flag affects xntpd only.
XX#
XX# There is an occurance of a call to rindex() in the daemon.  You may
XX#	have to include a -Drindex=strrchr to get this to load right.
XX#
XX# To change the location of the configuration file, use a
XX#	-DCONFIG_FILE=\\"/local/etc/ntp.conf\\" or something similar.
XX#
XXDEFS= # -DNO_SIGNED_CHAR_DECL
XX
XX#
XX# Clock support definitions (these only make sense if -DREFCLOCK used):
XX#
XX# Define -DLOCAL_CLOCK to include local pseudo-clock support
XX#
XX# Define -DPST to include support for the PST 1020 WWV/H receiver.
XX#
XX# Define -DWWVB to include support for the Spectracom 8170 WWVB receiver.
XX#
XX# Define -DCHU to include support for a driver to receive the CHU
XX#	timecode.  Note that to compile in CHU support you must
XX#	previously have installed the CHU serial line discipline in
XX#	the kernel of the machine you are doing the compile on.
XX#
XXCLOCKDEFS=
XX
XX#
XX# For MIPS 4.3BSD or RISCos 4.0, include a -lmld to get the nlist() routine
XX#
XXDAEMONLIBS= # -lmld
XX
XX#
XX# Name resolver library.  Included when loading xntpres, which calls
XX# gethostbyname().  Define this if you would rather use a different
XX# version of the routine than the one in libc.a
XX#
XXRESLIB=
XX
XX#
XX# Option flags for the C compiler.  A -g if you are uncomfortable
XX#
XXCOPTS= -O
XX
XX#
XX# C compiler to use.  gcc will work, but avoid the -fstrength-reduce option
XX# if the version is 1.35 or earlier (using this option caused incorrect
XX# code to be generated in the DES key permutation code, and perhaps
XX# elsewhere).
XX#
XXCOMPILER= cc
XX
XX#
XX# Directory into which binaries should be installed
XX#
XXBINDIR=	/local/etc
XX
XX#
XX# Use RANLIB= : for System V and related Unix's, such as SGI's IRIX,
XX# where ranlib is not needed.  Otherwise use RANLIB= ranlib
XX#
XXRANLIB= ranlib
XX
XX#
XX# the name of the group that can read /dev/kmem
XX#
XXKMEMGRP= sys
XX
XX#
XX# any additional libraries that are needed to make things link correctly
XX# For example, on SGI machines, "-lsun" is required here
XX#
XXALIBS= 
XX
XX#
XX# Unfortunately, some systems use a different syntax for the "install"
XX# command than the makefiles expect.  Fortunately, for such cases, I have
XX# written a shell script that does what is needed.  (It is not a full
XX# blown "install", but it does the job we need done.)  Unfortunately,
XX# this script needs the 'getopts' shell builtin, which is not supported on
XX# the Convex standard /bin/sh shell.  Fortunately, the standard Convex
XX# /usr/bin/install program works just fine with the makefiles.
XX# 
XX# So...  Set this variable to a version of "install" that does what the
XX# makefiles want.  If you want to use my script, use "../install"
XX#
XXINSTALL= /bin/install
SHAR_EOF
if test 4855 -ne "`wc -c ./Config.README`"
then
echo shar: error transmitting ./Config.README '(should have been 4855 characters)'
fi
echo shar: extracting ./Config.SGI
sed 's/^XX//' << \SHAR_EOF > ./Config.SGI
XXLIBDEFS=	-DBIG_ENDIAN
XXDEFS=  -D_BSD_COMPAT -DDEBUG -DCONFIG_FILE=\\"/usr/local/etc/xntp/ntp.conf\\" -DADJTIME_IS_ACCURATE -Dsgi
XXCLOCKDEFS=
XXDAEMONLIBS= -lmld
XXRESLIB=
XXCOPTS= -O
XXCOMPILER= cc
XXBINDIR=	/usr/local/etc/xntp
XXRANLIB= :
XXKMEMGRP= sys
XXALIBS= -lsun
XXINSTALL= ../install
SHAR_EOF
if test 272 -ne "`wc -c ./Config.SGI`"
then
echo shar: error transmitting ./Config.SGI '(should have been 272 characters)'
fi
echo shar: extracting ./Config.Sun
sed 's/^XX//' << \SHAR_EOF > ./Config.Sun
XXLIBDEFS=	-DBIG_ENDIAN
XXDEFS= -DNO_SIGNED_CHAR_DECL -DDEBUG -DCONFIG_FILE=\\"/usr/local/etc/xntp/ntp.conf\\" -Dsun
XXCLOCKDEFS=
XXDAEMONLIBS=
XXRESLIB=
XXCOPTS= -O
XXCOMPILER= cc
XXBINDIR=	/usr/local/etc/xntp
XXRANLIB= ranlib
XXKMEMGRP= sys
XXALIBS= 
XXINSTALL= /bin/install
SHAR_EOF
if test 253 -ne "`wc -c ./Config.Sun`"
then
echo shar: error transmitting ./Config.Sun '(should have been 253 characters)'
fi
echo shar: extracting ./Config.Sun386
sed 's/^XX//' << \SHAR_EOF > ./Config.Sun386
XXLIBDEFS=       -DLITTLE_ENDIAN
XXDEFS= -DNO_SIGNED_CHAR_DECL -DDEBUG -DCONFIG_FILE=\\"/usr/local/etc/xntp/ntp.conf\\" -Dsun -Dsun386
XXCLOCKDEFS=
XXDAEMONLIBS=
XXRESLIB=
XXCOPTS= -O
XXCOMPILER= cc
XXBINDIR=        /usr/local/etc/xntp
XXRANLIB= ranlib
XXKMEMGRP= sys
XXALIBS= 
XXINSTALL= /bin/install
SHAR_EOF
if test 278 -ne "`wc -c ./Config.Sun386`"
then
echo shar: error transmitting ./Config.Sun386 '(should have been 278 characters)'
fi
echo shar: extracting ./Makefile.diff
sed 's/^XX//' << \SHAR_EOF > ./Makefile.diff
XX52a53
XX> 	cd util ; $(MAKE) $(MFLAGS) install
SHAR_EOF
if test 45 -ne "`wc -c ./Makefile.diff`"
then
echo shar: error transmitting ./Makefile.diff '(should have been 45 characters)'
fi
echo shar: extracting ./Patch.sh
sed 's/^XX//' << \SHAR_EOF > ./Patch.sh
XX#!/bin/sh
XX# Patch all the required files with the diff's.
XXpatch Makefile                 Makefile.diff
XXpatch clockstuff/Makefile      clockstuff/Makefile.diff
XXpatch gizmo/Makefile           gizmo/Makefile.diff
XXpatch include/ntp.h            include/ntp.h.diff
XXpatch lib/Makefile             lib/Makefile.diff
XXpatch lib/getopt.c             lib/getopt.c.diff
XXpatch ntpdate/Makefile         ntpdate/Makefile.diff
XXpatch ntpq/Makefile            ntpq/Makefile.diff
XXpatch util/Makefile            util/Makefile.diff
XXpatch util/tickadj.c           util/tickadj.c.diff
XXpatch xntpd/Makefile           xntpd/Makefile.diff
XXpatch xntpd/ntp_io.c           xntpd/ntp_io.c.diff
XXpatch xntpd/ntp_loopfilter.c   xntpd/ntp_loopfilter.c.diff
XXpatch xntpd/ntp_unixclock.c    xntpd/ntp_unixclock.c.diff
XXpatch xntpdc/Makefile          xntpdc/Makefile.diff
XXpatch xntpres/Makefile         xntpres/Makefile.diff
SHAR_EOF
if test 886 -ne "`wc -c ./Patch.sh`"
then
echo shar: error transmitting ./Patch.sh '(should have been 886 characters)'
fi
echo shar: extracting ./clockstuff/Makefile.diff
sed 's/^XX//' << \SHAR_EOF > ./clockstuff/Makefile.diff
XX8a9
XX> INSTALL=
XX34c35
XX< #	install -c -m 0755 $(PROGRAM) $(BINDIR)
XX---
XX> #	$(INSTALL) -c -m 0755 $(PROGRAM) $(BINDIR)
SHAR_EOF
if test 116 -ne "`wc -c ./clockstuff/Makefile.diff`"
then
echo shar: error transmitting ./clockstuff/Makefile.diff '(should have been 116 characters)'
fi
echo shar: extracting ./gizmo/Makefile.diff
sed 's/^XX//' << \SHAR_EOF > ./gizmo/Makefile.diff
XX8a9
XX> INSTALL=
XX39c40
XX< NTPLIB=		../lib/libntp.a
XX---
XX> LIB=		../lib/libntp.a
XX46c47
XX< LIB=		libgizmontp.a
XX---
XX> GIZLIB=		libgizmontp.a
XX50c51
XX< LIBNTP=		../lib/libntp.a
XX---
XX> LIB=		../lib/libntp.a
XX73,74c74,75
XX< $(PROGRAM): $(LIB) $(OBJS) version.o
XX< 	$(CC) $(CCFLAGS) $(LDFLAGS) -o $@ $(OBJS) version.o $(LIB) $(CLIB)
XX---
XX> $(PROGRAM): $(GIZLIB) $(OBJS) version.o
XX> 	$(CC) $(CCFLAGS) $(LDFLAGS) -o $@ $(OBJS) version.o $(GIZLIB) $(CLIB)
XX76,77c77,78
XX< gizconf: $(COBJS) $(LIBNTP)
XX< 	$(CC) $(COPTS) -o $@ $(COBJS) $(LIBNTP)
XX---
XX> gizconf: $(COBJS) $(LIB)
XX> 	$(CC) $(COPTS) -o $@ $(COBJS) $(LIB)
XX80,81c81,82
XX< 	install -c -m 0755 $(PROGRAM) $(CONFDIR)
XX< 	install -c -m 0755 gizconf $(CONFDIR)
XX---
XX> 	$(INSTALL) -c -m 0755 $(PROGRAM) $(CONFDIR)
XX> 	$(INSTALL) -c -m 0755 gizconf $(CONFDIR)
XX90c91
XX< 	rm -f $(PROGRAM) gizconf $(LIB) $(LINTLIB) *.o *.out
XX---
XX> 	rm -f $(PROGRAM) gizconf $(GIZLIB) $(LINTLIB) *.o *.out
XX102c103
XX< $(LIB):
XX---
XX> $(GIZLIB):
SHAR_EOF
if test 942 -ne "`wc -c ./gizmo/Makefile.diff`"
then
echo shar: error transmitting ./gizmo/Makefile.diff '(should have been 942 characters)'
fi
echo shar: extracting ./include/ntp.h.diff
sed 's/^XX//' << \SHAR_EOF > ./include/ntp.h.diff
XX58a59,61
XX> #if defined(sgi) || defined(convex)
XX> #define	CLOCK_MAX_F	0x5999999a	/* 350 ms, in time stamp format */
XX> #else
XX59a63
XX> #endif
SHAR_EOF
if test 138 -ne "`wc -c ./include/ntp.h.diff`"
then
echo shar: error transmitting ./include/ntp.h.diff '(should have been 138 characters)'
fi
echo shar: extracting ./install
sed 's/^XX//' << \SHAR_EOF > ./install
XX#!/bin/sh
XXPATH=/usr/sbin:/usr/bsd:/bin:/usr/bin:/etc:/usr/etc
XXmode=""
XXgroup=""
XXwhile getopts 'cm:g:' op "$@"
XXdo
XX	case "$op"
XX	in
XX	c) ;;
XX	m) mode="$OPTARG" ;;
XX	g) group="$OPTARG" ;;
XX	\?) echo "usage: $0 [-c] [-m mode] [-g group] file directory"
XX	    exit 1 ;;
XX	esac
XXdone
XXshift `expr $OPTIND - 1`
XXprog=$1
XXdir=$2
XXif [ -f $prog -a -d $dir ]
XXthen
XX	cp $prog $dir
XX	if  [ -n "$mode" ]
XX	then
XX		chmod $mode $dir/$prog
XX	fi
XX	if  [ -n "$group" ]
XX	then
XX		chgrp $group $dir/$prog
XX	fi
XXelse
XX	echo "usage: $0 [-c] [-m mode] [-g group] file directory"
XX	exit 2
XXfi
XXexit 0
SHAR_EOF
if test 550 -ne "`wc -c ./install`"
then
echo shar: error transmitting ./install '(should have been 550 characters)'
fi
echo shar: extracting ./lib/Makefile.diff
sed 's/^XX//' << \SHAR_EOF > ./lib/Makefile.diff
XX38,39c38,39
XX< 	rm -f $?
XX< 	ranlib $@
XX---
XX> 	: rm -f $?
XX> 	$(RANLIB) $@
SHAR_EOF
if test 71 -ne "`wc -c ./lib/Makefile.diff`"
then
echo shar: error transmitting ./lib/Makefile.diff '(should have been 71 characters)'
fi
echo shar: extracting ./lib/getopt.c.diff
sed 's/^XX//' << \SHAR_EOF > ./lib/getopt.c.diff
XX21c21
XX< char	*optarg;	/* Global argument pointer. */
XX---
XX> char	*optarg = NULL;	/* Global argument pointer. */
XX28c28
XX< int	optopt;		/* for compatibility, option character checked */
XX---
XX> int	optopt = 0;		/* for compatibility, option character checked */
SHAR_EOF
if test 255 -ne "`wc -c ./lib/getopt.c.diff`"
then
echo shar: error transmitting ./lib/getopt.c.diff '(should have been 255 characters)'
fi
echo shar: extracting ./make-Config-usage
sed 's/^XX//' << \SHAR_EOF > ./make-Config-usage
XX#!/bin/sh
XXT="/tmp"
XXfind . -name '*.[ch]' -print | xargs -l1 egrep '^#[ 	]*(if|define|undef)' |
XX	tr -sc '[A-Z][a-z][0-9]_' '[\012*]' |
XX	grep -v '^[ 	0-9]*$' |
XX	sort -u |
XX	egrep -v '^(defined|if|ifdef|ifndef|lint|notdef)$' >$T/config-vars
XXfor i in `cat $T/config-vars`
XXdo
XXgrep -l $i `find . -name '*.[ch]' -print` | sed "s/^/$i	/"
XXdone >Config-usage
SHAR_EOF
if test 348 -ne "`wc -c ./make-Config-usage`"
then
echo shar: error transmitting ./make-Config-usage '(should have been 348 characters)'
fi
echo shar: extracting ./ntpdate/Makefile.diff
sed 's/^XX//' << \SHAR_EOF > ./ntpdate/Makefile.diff
XX8a9
XX> INSTALL=
XX26c27
XX< 	install -c -m 0755 $(PROGRAM) $(BINDIR)
XX---
XX> 	$(INSTALL) -c -m 0755 $(PROGRAM) $(BINDIR)
SHAR_EOF
if test 114 -ne "`wc -c ./ntpdate/Makefile.diff`"
then
echo shar: error transmitting ./ntpdate/Makefile.diff '(should have been 114 characters)'
fi
echo shar: extracting ./ntpq/Makefile.diff
sed 's/^XX//' << \SHAR_EOF > ./ntpq/Makefile.diff
XX8a9,10
XX> ALIBS=
XX> INSTALL=
XX23c25
XX< 	$(CC) $(COPTS) -o $@ $(OBJS) version.o $(LIB)
XX---
XX> 	$(CC) $(COPTS) -o $@ $(OBJS) version.o $(LIB) $(ALIBS)
XX26c28
XX< 	install -c -m 0755 $(PROGRAM) $(BINDIR)
XX---
XX> 	$(INSTALL) -c -m 0755 $(PROGRAM) $(BINDIR)
SHAR_EOF
if test 243 -ne "`wc -c ./ntpq/Makefile.diff`"
then
echo shar: error transmitting ./ntpq/Makefile.diff '(should have been 243 characters)'
fi
echo shar: extracting ./util/Makefile.diff
sed 's/^XX//' << \SHAR_EOF > ./util/Makefile.diff
XX8a9
XX> ALIBS=
XX9a11,12
XX> KMEMGRP=
XX> INSTALL=
XX27c30
XX< 	install -c -m 0755 $(PROGRAM) $(BINDIR)
XX---
XX> 	$(INSTALL) -c -g $(KMEMGRP) -m 02755 $(PROGRAM) $(BINDIR)
SHAR_EOF
if test 157 -ne "`wc -c ./util/Makefile.diff`"
then
echo shar: error transmitting ./util/Makefile.diff '(should have been 157 characters)'
fi
echo shar: extracting ./util/tickadj.c.diff
sed 's/^XX//' << \SHAR_EOF > ./util/tickadj.c.diff
XX23a24
XX> int setdosync = 0;
XX59c60
XX< 	while ((c = getopt(argc, argv, "a:Adkqst:")) != EOF)
XX---
XX> 	while ((c = getopt(argc, argv, "a:AdkqsSt:")) != EOF)
XX81a83,85
XX> 		case 'S':
XX> 			setdosync = 1;
XX> 			break;
XX100c104
XX< 		    "usage: %s [-Aqs] [-a newadj] [-t newtick]\n", progname);
XX---
XX> 		    "usage: %s [-AqsS] [-a newadj] [-t newtick]\n", progname);
XX104a109,115
XX> 
XX> #ifdef sgi
XX> 	tickadj_offset = tickadj_offset & 0x7fffffff;
XX> 	tick_offset = tick_offset & 0x7fffffff;
XX> 	dosync_offset = dosync_offset & 0x7fffffff;
XX> #endif
XX> 
XX106,108c117,119
XX< 		(void) printf("tick offset = %lu\n", tick_offset);
XX< 		(void) printf("tickadj offset = %lu\n", tickadj_offset);
XX< 		(void) printf("dosynctodr offset = %lu\n", dosync_offset);
XX---
XX> 		(void) printf("tick offset = %lx\n", tick_offset);
XX> 		(void) printf("tickadj offset = %lx\n", tickadj_offset);
XX> 		(void) printf("dosynctodr offset = %lx\n", dosync_offset);
XX117a129,131
XX> 	if (!quiet) {
XX> 		(void) printf("tickadj = %d us\n", tickadj);
XX> 	}
XX119c133,136
XX< 	if (dosync_offset != 0)
XX---
XX> 	if (!quiet) {
XX> 		(void) printf("tick = %d us\n", tick);
XX> 	}
XX> 	if (dosync_offset != 0) {
XX120a138,142
XX> 		if (!quiet) {
XX> 			(void) printf( "dosynctodr is %s(%d)\n",
XX> 				dosynctodr ? "on" : "off",dosynctodr);
XX> 		}
XX> 	}
XX129,137d150
XX< 	if (!quiet) {
XX< 		if (dosync_offset == 0)
XX< 			(void) printf("tick = %d us, tickadj = %d us\n",
XX< 			     tick, tickadj);
XX< 		else
XX< 			(void) printf(
XX< 			    "tick = %d us, tickadj = %d us, dosynctodr is %s\n",
XX< 			     tick, tickadj, dosynctodr ? "on" : "off");
XX< 	}
XX158c171
XX< 	    !unsetdosync && writetick == 0)
XX---
XX> 	    !unsetdosync && !setdosync && writetick == 0)
XX184a198,206
XX> 	if (setdosync) {
XX> 		if (!quiet) {
XX> 			(void) fprintf(stderr, "setting dosynctodr: ");
XX> 			(void) fflush(stderr);
XX> 		}
XX> 		writevar(fd, dosync_offset, 1);
XX> 		if (!quiet)
XX> 			(void) fprintf(stderr, "done!\n");
XX> 	}
XX211c233,240
XX< 	{	{"_tickadj"},
XX---
XX> 	{
XX> #ifdef sgi
XX> 		{"tickdelta"},
XX> 		{"tick"},
XX> 		{"dosynctodr"},
XX> 		{""},
XX> #else
XX> 		{"_tickadj"},
XX214a244
XX> #endif
XX240,241c270,273
XX< 		(void) fprintf(stderr, "%s: namelist can't find `_tickadj'\n",
XX< 		    progname);
XX---
XX> 		(void) fprintf(stderr, "%s: namelist can't find `%s'\n",
XX> 		    progname,
XX> 		    nl[K_TICKADJ].n_name
XX> 		    );
XX245,246c277,280
XX< 		(void) fprintf(stderr, "%s: namelist can't find `_tick'\n",
XX< 		    progname);
XX---
XX> 		(void) fprintf(stderr, "%s: namelist can't find `%s'\n",
XX> 		    progname,
XX> 		    nl[K_TICK].n_name
XX> 		    );
XX247a282,287
XX> 	}
XX> 	if (nl[K_DOSYNC].n_value == 0) {
XX> 		(void) fprintf(stderr, "%s: namelist can't find `%s'\n",
XX> 		    progname,
XX> 		    nl[K_DOSYNC].n_name
XX> 		    );
SHAR_EOF
if test 2657 -ne "`wc -c ./util/tickadj.c.diff`"
then
echo shar: error transmitting ./util/tickadj.c.diff '(should have been 2657 characters)'
fi
echo shar: extracting ./xntpd/Makefile.diff
sed 's/^XX//' << \SHAR_EOF > ./xntpd/Makefile.diff
XX8a9
XX> ALIBS=
XX10a12
XX> INSTALL=
XX36c38
XX< 	$(CC) $(COPTS) -o $@ $(OBJS) version.o $(LIB) $(DAEMONLIBS)
XX---
XX> 	$(CC) $(COPTS) -o $@ $(OBJS) version.o $(LIB) $(DAEMONLIBS) $(ALIBS)
XX39c41
XX< 	install -c -m 0755 $(PROGRAM) $(BINDIR)
XX---
XX> 	$(INSTALL) -c -m 0755 $(PROGRAM) $(BINDIR)
SHAR_EOF
if test 274 -ne "`wc -c ./xntpd/Makefile.diff`"
then
echo shar: error transmitting ./xntpd/Makefile.diff '(should have been 274 characters)'
fi
echo shar: extracting ./xntpd/ntp_io.c.diff
sed 's/^XX//' << \SHAR_EOF > ./xntpd/ntp_io.c.diff
XX4a5,8
XX> #ifdef convex
XX> #include <unistd.h>
XX> #include <fcntl.h>
XX> #endif
SHAR_EOF
if test 74 -ne "`wc -c ./xntpd/ntp_io.c.diff`"
then
echo shar: error transmitting ./xntpd/ntp_io.c.diff '(should have been 74 characters)'
fi
echo shar: extracting ./xntpd/ntp_loopfilter.c.diff
sed 's/^XX//' << \SHAR_EOF > ./xntpd/ntp_loopfilter.c.diff
XX119,120c119,120
XX< 		syslog(LOG_DEBUG, "adjust: STEP %s offset %s\n",
XX< 		    ntoa(from), lfptoa(fp_offset));
XX---
XX> 		syslog(LOG_INFO, "adjust: STEP %s offset %s\n",
XX> 		    ntoa(from), lfptoa(fp_offset,9));
XX250,251c250,256
XX< 	adjustment += drift_adjust;
XX< 	adj_systime(adjustment);
XX---
XX> 
XX> 	/*
XX> 	 * Pass current clock adjustment and drift clock adjustment separately
XX> 	 * to the OS interface, so it can deal separately with them,
XX> 	 * if the OS has provision for doing so, as does IRIX v3.3 on SGI's
XX> 	 */
XX> 	adj_systime(adjustment, drift_adjust);
SHAR_EOF
if test 553 -ne "`wc -c ./xntpd/ntp_loopfilter.c.diff`"
then
echo shar: error transmitting ./xntpd/ntp_loopfilter.c.diff '(should have been 553 characters)'
fi
echo shar: extracting ./xntpd/ntp_unixclock.c.diff
sed 's/^XX//' << \SHAR_EOF > ./xntpd/ntp_unixclock.c.diff
XX11a12,15
XX> #include <netinet/in.h>
XX> #ifdef sgi
XX> #include <sys/syssgi.h>
XX> #endif /* sgi */
XX16c20,21
XX< #define	CLOCK_ADJ	4
XX---
XX> #include "ntp.h"
XX> #define	CLOCK_ADJ_SEC	(1<<CLOCK_ADJ)
XX45c50
XX< long tvu_maxslew;	/* maximum adjust doable in CLOCK_ADJ sec (usec) */
XX---
XX> long tvu_maxslew;	/* maximum adjust doable in CLOCK_ADJ_SEC sec (usec) */
XX117c122
XX< 	 * insurance that all slews requested will complete in CLOCK_ADJ
XX---
XX> 	 * insurance that all slews requested will complete in CLOCK_ADJ_SEC
XX121a127
XX> 	tvu_maxslew = 999990;
XX124,125c130
XX< #endif /* ADJTIME_IS_ACCURATE */
XX< 	tvu_maxslew = tickadj * (hz-1) * CLOCK_ADJ;
XX---
XX> 	tvu_maxslew = tickadj * (hz-1) * CLOCK_ADJ_SEC;
XX133a139
XX> #endif /* ADJTIME_IS_ACCURATE */
XX251c257
XX<  * adj_systime - called once every CLOCK_ADJ seconds to make system time
XX---
XX>  * adj_systime - called once every CLOCK_ADJ_SEC seconds to make system time
XX255,256c261,262
XX< adj_systime(adj)
XX< 	long adj;
XX---
XX> adj_systime(adj, drift_adj)
XX> 	long adj, drift_adj;
XX278a285,292
XX> #ifndef sgi
XX> 	/*
XX> 	 * If not on SGI machine, combine the drift and other
XX> 	 * adjustment together.  SGI has this neat Time-Trim facility
XX> 	 * that allows us to handle clock drift directly.
XX> 	*/
XX> 	M_ADDF(offset_i, offset_f, drift_adj);
XX> #endif
XX285,287c299,302
XX< 		printf("adj_systime(%s): offset = %s%s\n",
XX< 		    mfptoa((adj<0?-1:0), adj, 9), isneg?"-":"",
XX< 		    umfptoa(offset_i, offset_f, 9));
XX---
XX> 		printf("adj_systime(%s,%s): offset = %s%s\n",
XX> 		    mfptoa((adj<0?-1:0), adj, 9),
XX> 		    mfptoa((drift_adj<0?-1:0), drift_adj, 9),
XX> 		    isneg?"-":"", umfptoa(offset_i, offset_f, 9));
XX350a366,394
XX> #ifdef sgi
XX> 	/* use the SGI Time-Trim facility to handle drift */
XX> 
XX> 	/* convert to seconds-of-drift per second-of-real time x 2**32 */
XX> 	drift_adj >>= CLOCK_ADJ;
XX> 
XX> 	/*
XX> 	 * magic fudge to approximate conversion to nano-sec per sec
XX> 	 * without causing integer overflow
XX> 	 * 10**9 / 2**32 == 0.2328306...
XX> 	 * SGI 4D machines all have fast hardware multipliers and dividers
XX> 	 * so putting this in the inner loop is not *so* evil.
XX> 	 *
XX> 	 * If it's big, do the divide first; if it's small, do the multiply.
XX> 	 * That way we simultaneously preserve precision and avoid overflow.
XX> 	 */
XX> 
XX> 	if (drift_adj & 0xfff00000)
XX> 		drift_adj = (drift_adj / 1000) * 233;
XX> 	else
XX> 		drift_adj = (drift_adj * 233) / 1000;
XX> #ifdef DEBUG
XX> 	if (debug > 4)
XX> 		printf("set TimeTrim to %d\n",drift_adj);
XX> #endif /* DEBUG */
XX> 	if ( 0 > syssgi(SGI_SETTIMETRIM,drift_adj) )
XX> 		syslog(LOG_ERR, "Can't do time-trim adjustment: %m");
XX> #endif /* sgi */
XX> 
XX379a424,430
XX> #ifdef sgi
XX> 	/* fake it */
XX> 	*tick = 10000;
XX> 	*tickadj = 5;
XX> 	return;
XX> #else /* not sgi */
XX> 	/* we have to do it the hard way! */
XX381a433
XX> #ifndef sun386
XX386a439,445
XX> #else /* not sun386 */
XX> 	static struct nlist nl[] =
XX> 	{	{"tickadj"},
XX> 		{"tick"},
XX> 		{""},
XX> 	};
XX> #endif /* sun386 */
XX453a513
XX> #endif /* sgi */
SHAR_EOF
if test 2917 -ne "`wc -c ./xntpd/ntp_unixclock.c.diff`"
then
echo shar: error transmitting ./xntpd/ntp_unixclock.c.diff '(should have been 2917 characters)'
fi
echo shar: extracting ./xntpdc/Makefile.diff
sed 's/^XX//' << \SHAR_EOF > ./xntpdc/Makefile.diff
XX8a9,10
XX> ALIBS=
XX> INSTALL=
XX23c25
XX< 	$(CC) $(COPTS) -o $@ $(OBJS) version.o $(LIB)
XX---
XX> 	$(CC) $(COPTS) -o $@ $(OBJS) version.o $(LIB) $(ALIBS)
XX26c28
XX< 	install -c -m 0755 $(PROGRAM) $(BINDIR)
XX---
XX> 	$(INSTALL) -c -m 0755 $(PROGRAM) $(BINDIR)
SHAR_EOF
if test 243 -ne "`wc -c ./xntpdc/Makefile.diff`"
then
echo shar: error transmitting ./xntpdc/Makefile.diff '(should have been 243 characters)'
fi
echo shar: extracting ./xntpres/Makefile.diff
sed 's/^XX//' << \SHAR_EOF > ./xntpres/Makefile.diff
XX9a10
XX> INSTALL=
XX27c28
XX< 	install -c -m 0755 $(PROGRAM) $(BINDIR)
XX---
XX> 	$(INSTALL) -c -m 0755 $(PROGRAM) $(BINDIR)
SHAR_EOF
if test 115 -ne "`wc -c ./xntpres/Makefile.diff`"
then
echo shar: error transmitting ./xntpres/Makefile.diff '(should have been 115 characters)'
fi
#	End of shell archive
exit 0