Use corrected system time internally, adjust old offsets after
[dragonfly.git] / usr.sbin / ntpd / patches / ntpd.c.patch
1 $DragonFly: src/usr.sbin/ntpd/patches/Attic/ntpd.c.patch,v 1.6 2005/04/14 10:31:27 joerg Exp $
2
3 --- ntpd.c.orig 2004-11-09 20:39:54.000000000 +0100
4 +++ ntpd.c      2004-11-09 20:40:48.000000000 +0100
5 @@ -18,6 +18,7 @@
6  
7  #include <sys/types.h>
8  #include <sys/socket.h>
9 +#include <sys/sysctl.h>
10  #include <sys/wait.h>
11  #include <netinet/in.h>
12  #include <arpa/inet.h>
13 @@ -34,7 +35,7 @@
14  #include "ntpd.h"
15  
16  void           sighdlr(int);
17 -__dead void    usage(void);
18 +void           usage(void) __dead2;
19  int            main(int, char *[]);
20  int            check_child(pid_t, const char *);
21  int            dispatch_imsg(struct ntpd_conf *);
22 @@ -63,12 +64,10 @@
23         }
24  }
25  
26 -__dead void
27 +void
28  usage(void)
29  {
30 -       extern char *__progname;
31 -
32 -       fprintf(stderr, "usage: %s [-dSs] [-f file]\n", __progname);
33 +       fprintf(stderr, "usage: %s [-dSs] [-f file]\n", getprogname());
34         exit(1);
35  }
36  
37 @@ -307,16 +306,18 @@
38  void
39  ntpd_adjtime(double d)
40  {
41 -       struct timeval  tv;
42 +       int64_t adjust;
43  
44         if (d >= (double)LOG_NEGLIGEE / 1000 ||
45             d <= -1 * (double)LOG_NEGLIGEE / 1000)
46                 log_info("adjusting local clock by %fs", d);
47         else
48                 log_debug("adjusting local clock by %fs", d);
49 -       d_to_tv(d, &tv);
50 -       if (adjtime(&tv, NULL) == -1)
51 -               log_warn("adjtime failed");
52 +       adjust = d * 1e9;
53 +
54 +       if (sysctlbyname("kern.ntp.adjust", NULL, NULL, &adjust,
55 +                        sizeof(adjust)))
56 +               log_info("adjtime failed");
57  }
58  
59  void