  THIS IS THE HISTORY OF THE HWCLOCK PROGRAM

  14.10.02 BJH   Version 2.45

  Accommodate new local/universal switch in Eleven Minute Mode - have
  --hctosys permanently set it according to whether Hardware Clock is in
  local or universal time at the time of --hctosys (but effective only if
  it isn't already permanently set).

  --hctosys sets the kernel timezone offset even with --slew (before,
  it silently left the kernel timezone offset unchanged with --slew, based
  on the idea that a timezone change is a discontinuous change of the local
  datetime).

  14.08.28 BJH   Version 2.44

  Adapt to recent GNU libc.  Without this change, Hwclock always assumes the
  Hardware Clock is kept in UTC.

  14.06.24 BJH   Version 2.43

  Fix: still incorrect drift calculation with --set when system time is
  wrong.  (Fix in Version 2.42 was wrong).

  14.05.28 BJH   Version 2.42

  Call 'configure' with 'perl configure' instead of './configure'.

  Fix: incorrect drift calculation with --set when system time is wrong.

  Fix: assertion failure with --test.

  Build: rebuild config.h if config.mk changes.

  13.03.17 BJH   Version 2.41

  Allow one second rather than one minute granularity in the local time
  offset for the Hardware Clock.  This continues to be recorded in the adjtime
  file, which continues to represent the offset as a number of seconds.  The
  difference is that that number is no longer required to be a multiple of
  60 seconds.

  Don't try to build direct I/O clock access method code if
  /usr/include/asm/io.h does not exist, which probably means it is a new
  system that does not consider inb/outb a kernel interface.

  12.06.04 BJH   Version 2.40

  Fix bug form 2.39: assertion failure nearly always.

  12.05.28 BJH   Version 2.39

  Add -tzoffset.

  Add debug messages.

  10.02.01 BJH   Version 2.38

  Use <sys/io.h> where available instead of <asm/io.h>.

  09.11.05 BJH   Version 2.37

  Fix bug: when adjtime file doesn't exist, uses arbitrary value for
  "correction" instead of zero.

  Don't remember --correct value in adjtime file if it is a second or more.
  (Because it is highly unlikely that the value is a true correction --
  rather, it's a mistake).

  Set "last setting miss" in adjtime file to zero when setting the clock
  with --fast, instead of leaving it whatever it was.

  Improve "clock ended up X seconds from intended set time" warning message.

  Work around bug in recent Linux <asm/io.h> (e.g. 2.6.29-2.6.31):
  Type "u32" et al used but not defined.

  Add debug tracing.

  09.10.11 BJH   Version 2.36

  Recognize a 1904 datetime in Hardware Clock as a dead battery on
  PowerPC iBook.

  09.04.01 BJH   Version 2.35

  Use locale.

  08.10.26 BJH   Version 2.34

  Remove CLI/STI.  Recent kernels notice this nonsense (disabling
  interrupts and then making a system call) and Oops.  Direct ISA
  continues to be broken and unfixable, though in a better way, wrt
  two processes accessing the hardware clock at exactly the same time.

  Make --directisa available for x86_64.

  Add --adjfile .

  Add --drift .

  Add warning for turning off 11 minute mode.

  Fix bogus overshoot warning with --fast .

  Fix some Gcc 4.1.2 compiler warnings.

  08.05.06 BJH   Version 2.33

  Recognize EINVAL from ioctl(RTC_RD_TIME) as meaning "clock does not
  contain valid time."

  Don't bother to read the hardware clock when doing --set or --systohc
  and --nodrift (saves time).

  08.02.20 BJH   Version 2.32

  Fix erroneous failure saying the adjtime file local timezone offset is
  invalid.  Introduced in 2.31.

  07.11.19 BJH   Version 2.31

  Improve accuracy in setting of last adjustment and calibration
  datetimes when we miss ticks while waiting for the verification tick
  after setting.

  Look for /var/lib/hwclock/adjtime in addition to other places.
  FHS 2.3 specifies this location.

  Fix bug with --utc/--local different from adjtime file on a read
  operation.  The option should take precedence and the adjtime file
  should not be updated; we were partially ignoring it and partially
  updating the adjtime file.

  Recognize rtc device interrupts of the wrong kind, such as when
  someone else is using the device (e.g. for its periodic interrupts).

  Work around rtc device driver bug by repeating read() when necessary.

  Remove delay of determining local time offset, and issuing debug
  message, from --hctosys error.  Thanks Alain Guibert
  <alguibert@free.fr> for the design.

  Fix use of last setting miss in calculating drift factor.

  Change safety margin, when sleeping to wait for a time of day to arrive,
  from 20 ms to 22 ms

  07.08.11 BJH   Version 2.30

  Add --nointerrupt

  Recognize Linux rtc device bug where read() returns immediately instead
  of waiting for the update interrupt.  Issue error message.

  Recognize ENOTTY, not just EINVAL, from the Enable Update Interrupt
  ioctl as indicating the clock has no interrupt function.

  Convert last set error (adjtime.last_set_err) to last set miss
  (adjtime.last_set_miss) (i.e. change sign).  Make --get and --hctosys
  use it.  Don't consider that time as drift when calculating drift factor.

  07.06.04 BJH   Version 2.29

  Add --nomlock.

  Add --reporterror.

  Add --get.

  Change original "not adjusted" field (now just zero) in adjtime file
  to "last setting error."

  When setting Hardware Clock, calibrate so drift is zero as of moment
  of verification tick, not moment of setting.  Thanks Alain Guibert
  <alguibert@free.fr> for the concept.

  Use --cpupriority and pinned memory while reading hardware clock
  to improve accuracy of datetime of tick.

  Don't wait longer than necessary for an odd half-second to set the
  hardware clock.

  Sleep instead of spinning while waiting for clock tick.  Thanks
  Alain Guibert <alguibert@free.fr> for the concept.

  Tiny improvement to precision of drift factor adjustment (don't ignore
  fractional seconds since last calibration).

  06.12.03 BJH   Version 2.28

  Do not recognize datetimes before the epoch (in particular, where
  mktime() returns a negative number).

  Clean up some system clock setting arithmetic that had become overly
  complex with some of the restructuring to eliminate execution time
  error.

  06.05.27 BJH   Version 2.27

  Fix defaulting of RTC device special file, broken in 2.26.

  Fix setting of clock with methods other than RTC, broken in 2.25.
  Hwclock did not wait for the appointed time to set the clock, causing
  it always to set it fast.

  Improve a debug message.

  06.04.23 BJH   Version 2.26

  Include /dev/rtc0 in list of default RTC device special file names.

  On setting functions, proceed with setting even if unable to read the 
  clock.  (In that case, skip any recalculation of drift factor).

  06.03.19 BJH   Version 2.25

  Record --correct value in adjtime file

  Add --cpupriority option.

  Pin memory during time-sensitive computations.

  Improve accuracy of drift rate calculation by using full precision
  drift instead of second precision.  I.e. a -.1 second drift used to
  be treated as a -1.0 second drift, now is treated as -.1.

  Improve accuracy of drift rate calculation by recording the actual
  time the clock was last calibrated (i.e. set) rather than a few
  seconds before that.

  Change from a day to an hour the minimum time for recomputing drift
  rate (because of above improvement in precision).

  Reduce execution time between observing clock tick and checking the
  time, for better accuracy.  Thanks Alain Guibert
  <alguibert@free.fr>.

  Reduce execution time between waiting for a certain time and setting
  the clock, for better accuracy.  Thanks Alain Guibert
  <alguibert@free.fr>.

  05.05.28 BJH   Version 2.24

  When the adjtime file says the hardware clock is in local time, but not
  which local time, assume the same local time that the current process uses
  for the time that the hardware clock was last set.  Used to assume the
  same local time that the current process uses for right now.

  Fix bug: when adjtime file doesn't exist, uses arbitrary local time zone
  offset.

  03.10.01 BJH   Version 2.23

  Add --slew option.  Thanks Scott Weikart <scott@benetech.org>.

  03.06.29 BJH   Version 2.22

  Fix bug: used to assume 'timezone' global variable contained timezone 
  offset.  In fact, it contains the non-DST-adjusted timezone offset, so
  Hwclock used the wrong timezone in setting/reading hardware clock in 
  local time format.

  Fix bug: used adjtime timezone offset for reading clock in local
  time format, but C library timezone offset for setting it.  Now uses
  adjtime timezone offset for both.

  03.06.20 BJH   Version 2.21

  Include <time.h> instead of <sys/time.h> because current GNU C library
  defines 'timezone' only via the former, and the former is right anyway.
          
  03.05.31 BJH   Version 2.20

  When hw clock in local time format, keep timezone of that local time in
  adjtime file.

  Don't require superuser real uid.  (Setuid installation no longer normal).

  Setting while in 11 minute mode generates warning.

  11 minute mode does same thing as --nodrift.

  adjtime file moved to /var/state/adjtime.  ADJTIME_PATH environment
  variable added.

  03.03.31 BJH   Version 2.19

  Add --nodrift option.

  02.11.28 BJH   Version 2.18

  Fix setting of kernel timezone value - use current dst information instead
  of 'daylight' environment variable.

  02.08.04 BJH   Version 2.17
  
  Fix crash when adjtime file specifies LOCAL.

  Fix invalid epoch calculation when /etc/adjtime does not exist.

  02.05.17 BJH   Version 2.16

  Add error messages to explain the failure when the hardware clock is not
  advancing.  Change timeout on busywait method of rtc tick detection to
  a time instead of a million iterations.

  02.01.22 BJH   Version 2.15

  Credibility check on drift is 5 minutes per day or 30 minutes total
  instead of just 30 minutes total.
                 
  User can have any zero year he wants for his hardware clock.
  --epoch option specifies explicitly; adjtime file remembers.
  (--epoch formerly just affected --setepoch).  Kernel epoch value no
  longer affects anythings (except --getepoch).  --arc makes zero year
  assumed to be 1952.

  01.08.18 BJH   Version 2.14

  Works on PCI (newer) sparcs.

  01.05.05 BJH   Version 2.13

  Add --fast option.

  Add --rtc option.

  Use /dev/misc/rtc instead of /dev/rtc if it exists.

  Validate that /dev/rtc, etc. is a character device special file.  
  
  Don't select direct ISA clock access method if not superuser.

  Improve error and debugging messages concerning the search for a clock
  access method.

  00.04.21 BJH   Version 2.12

  Put detailed explanation of failure of open(/dev/rtc) in --debug output.

  Fix bug in the 2 second timeout from Version 2.11.

  00.02.15 BJH   Version 2.11
                 
  Put 2 second timeout on wait for clock tick via /dev/rtc.  Some rtc drivers
  on some machines accept the "enable interrupt" ioctl, but aren't actually
  capable of delivering the interrupt, so this stops Hwclock from just 
  hanging.  When it times out, it reverts to a busywait for the clock tick.
  
  00.12.02 BJH   Version 2.10

  Add fractional part of last adjustment time to adjtime file to improve
  accuracy.  Thanks to James P Rutledge <jimrutledge@earthlink.net>.

  Fix compilation bug on Sparc (don't #include asm/io.h).

  Use tm_isdst instead of 'daylight' to determine if it's DST for
  --show.  In glibc 2, 'daylight' tells only if DST exists; not if it
  is in effect.

  00.05.29 BJH   Version 2.9

  Record System Time changes in utmp, wtmp.

  00.05.22 BJH   Version 2.8

  Account for Hardware Clock setting 500 ms retroactively, which made
  hwclock always set the clock 500 ms fast.  Also verify that the clock
  got set to the expected value.

  Add --correct option.

  Tell in man page how to interpret --show output.

  Put correct program name in NAME section of man page.

  Tell in README file about bug in Red Hat 6.0 that keeps distributed binary
  from working.
  
  Tell in man page where to get adjtimex, date, and tzset.

  Include version in all debug output.

  Add local time zone name to --show output.

  99.05.03 BJH   Version 2.7

  In --hctosys, account for uncorrected (accumulated) drift.

  Move tzset() so the possible slow reading of files it does does not
  impact timing.

  Correct check for improbably large drift so it checks the absolute
  value of the drift.  Thanks ao112@rgfn.epcc.edu (James P. Rutledge).

  Some debug output in days instead of seconds.  Thanks ao112@rgfn.epcc.edu 
  (James P. Rutledge).

  99.04.09 BJH   Version 2.6

  Fix compilation errors with some compilers and kernel and libc 
  interface headers.  Make it work with glibc 2.

  Work with KDHWCLK interface even if not compiled with kernel headers 
  that say it's in the kernel.  (As long as it's actually in the kernel
  at runtime!).

  99.04.08 BJH   Version 2.5

  Make it work on Alphas without /dev/rtc.  Thanks to David Mosberger
  <davidm@azstarnet.com>, Jay Estabrook <jestabro@amt.tay1.dec.com>,
  Martin Ostermann <ost@coments.rwth-aachen.de>, Andries Brouwer
  <aeb@cwi.nl>.  Most of this code is lifted from another program
  called "clock" (not the original ancestor of hwclock) that has 
  circulated for use on Alpha.

  Make it work on Sparc.

  Add --badyear option.  Thanks to David J Coffin (dcoffin@shore.net)
  for the design of this.

  Add --localtime option, local/UTC value in adjtime file, and defaults
  for local/utc.

  Don't set CMOS memory Byte 50 (century byte).  On some machines,
  that byte not only isn't used as a century byte, but it is used for
  something else.

  Don't update the drift factor if the variation is so huge that it 
  probably wasn't due to drift.

  Compute drift factor with better precision.

  98.08.12 BJH   Version 2.4 

  Don't use century byte from Hardware Clock.  Add comments telling why.


  98.06.20 BJH   Version 2.3.

  Make --hctosys set the kernel timezone from TZ environment variable
  and/or /usr/lib/zoneinfo.  From Klaus Ripke (klaus@ripke.com).

  98.03.05 BJH.  Version 2.2.  

  Add --getepoch and --setepoch.  

  Fix some word length things so it works on Alpha.

  Make it work when /dev/rtc doesn't have the interrupt functions.
  In this case, busywait for the top of a second instead of blocking and
  waiting for the update complete interrupt.

  Fix a bunch of bugs too numerous to mention.

  97.06.01: BJH.  Version 2.1.  Read and write the century byte (Byte
  50) of the ISA Hardware Clock when using direct ISA I/O.  Problem
  discovered by job (jei@iclnl.icl.nl).
  
  Use the rtc clock access method in preference to the KDGHWCLK method.
  Problem discovered by Andreas Schwab <schwab@LS5.informatik.uni-dortmund.de>.

  November 1996: Version 2.0.1.  Modifications by Nicolai Langfeldt
  (janl@math.uio.no) to make it compile on linux 1.2 machines as well
  as more recent versions of the kernel. Introduced the NO_CLOCK
  access method and wrote feature test code to detect absense of rtc
  headers.


  Bryan Henderson based hwclock on the program "clock", in September
  1996.  While remaining mostly backward compatible with clock,
  hwclock added the following:

    - You can set the hardware clock without also modifying the Linux
      system clock.

    - You can read and set the clock with finer than 1 second precision.

    - When you set the clock, hwclock automatically refigures the drift
      rate, based on how far off the clock was before you set it.  (This
      is the drift rate that is used with the --adjust function to 
      automatically adjust the clock periodically to compensate for drift).

    - More mnemonic GNU-style command line options.

    - Comments describing how the clock and program work to improve 
      maintainability.

    - Removed the old dead I/O code that worked without the inb/outb
      instructions and without the asm/io.h definitions.

  The first version of hwclock was Version 2.

  Here is the history section from the "clock" program at the time it was
  used as a basis for hwclock:

  V1.0

  
  V1.0 by Charles Hedrick, hedrick@cs.rutgers.edu, April 1992.
 
 ********************
  V1.1
  Modified for clock adjustments - Rob Hooft, hooft@chem.ruu.nl, Nov 1992
  Also moved error messages to stderr. The program now uses getopt.
  Changed some exit codes. Made 'gcc 2.3 -Wall' happy.
 
 *****
  V1.2
 
  Applied patches by Harald Koenig (koenig@nova.tat.physik.uni-tuebingen.de)
  Patched and indented by Rob Hooft (hooft@EMBL-Heidelberg.DE)
  
  A free quote from a MAIL-message (with spelling corrections):
 
  "I found the explanation and solution for the CMOS reading 0xff problem
   in the 0.99pl13c (ALPHA) kernel: the RTC goes offline for a small amount
   of time for updating. Solution is included in the kernel source 
   (linux/kernel/time.c)."
 
  "I modified clock.c to fix this problem and added an option (now default,
   look for USE_INLINE_ASM_IO) that I/O instructions are used as inline
   code and not via /dev/port (still possible via #undef ...)."
 
  With the new code, which is partially taken from the kernel sources, 
  the CMOS clock handling looks much more "official".
  Thanks Harald (and Torsten for the kernel code)!
 
 *****
  V1.3
  Canges from alan@spri.levels.unisa.edu.au (Alan Modra):
  a) Fix a few typos in comments and remove reference to making
     clock -u a cron job.  The kernel adjusts cmos time every 11
     minutes - see kernel/sched.c and kernel/time.c set_rtc_mmss().
     This means we should really have a cron job updating
     /etc/adjtime every 11 mins (set last_time to the current time
     and not_adjusted to ???).
  b) Swapped arguments of outb() to agree with asm/io.h macro of the
     same name.  Use outb() from asm/io.h as it's slightly better.
  c) Changed CMOS_READ and CMOS_WRITE to inline functions.  Inserted
     cli()..sti() pairs in appropriate places to prevent possible
     errors, and changed ioperm() call to iopl() to allow cli.
  d) Moved some variables around to localise them a bit.
  e) Fixed bug with clock -ua or clock -us that cleared environment
     variable TZ.  This fix also cured the annoying display of bogus
     day of week on a number of machines. (Use mktime(), ctime()
     rather than asctime() )
  f) Use settimeofday() rather than stime().  This one is important
     as it sets the kernel's timezone offset, which is returned by
     gettimeofday(), and used for display of MSDOS and OS2 file
     times.
  g) faith@cs.unc.edu added -D flag for debugging
 
  V1.4: alan@SPRI.Levels.UniSA.Edu.Au (Alan Modra)
        Wed Feb  8 12:29:08 1995, fix for years > 2000.
        faith@cs.unc.edu added -v option to print version.  */


