8b8da0870d
* [Sec 2956] small-step/big-step. Close the panic gate earlier. HStenn. * CID 1339955: Free allocated memory in caljulian test. HStenn. * CID 1339962: Explicitly initialize variable in caljulian test. HStenn. * CID 1341527: Quiet a CHECKED_RETURN in sntp/tests/t-log.c. HStenn. * CID 1341533: Missing assertion in sntp/tests/t-log.c. HStenn. * CID 1341534: Resource leak in tests/ntpd/t-ntp_signd.c. HStenn. * CID 1341535: Resource leak in tests/ntpd/t-ntp_signd.c. HStenn. * CID 1341536: Resource leak in tests/ntpd/t-ntp_signd.c. HStenn. * CID 1341537: Resource leak in tests/ntpd/t-ntp_signd.c. HStenn. * CID 1341538: Memory leak in tests/ntpd/ntp_prio_q.c:262. HStenn. * CID 1341677: Nits in sntp/tests/keyFile.c. HStenn. * CID 1341678: Nits in sntp/tests/keyFile.c. HStenn. * CID 1341679: Nits in sntp/tests/keyFile.c. HStenn. * CID 1341680: Nits in sntp/tests/keyFile.c. HStenn. * CID 1341681: Nits in sntp/tests/keyFile.c. HStenn. * CID 1341682: Nit in libntp/authreadkeys.c. HStenn. * CID 1341684: Nit in tests/ntpd/t-ntp_signd.c. HStenn. * [Bug 2829] Look at pipe_fds in ntpd.c (did so. perlinger@ntp.org) * [Bug 2887] stratum -1 config results as showing value 99 - fudge stratum should only accept values [0..16]. perlinger@ntp.org * [Bug 2932] Update leapsecond file info in miscopt.html. CWoodbury, HStenn. * [Bug 2934] tests/ntpd/t-ntp_scanner.c has a magic constant wired in. HMurray * [Bug 2944] errno is not preserved properly in ntpdate after sendto call. - applied patch by Christos Zoulas. perlinger@ntp.org * [Bug 2952] Symmetric active/passive mode is broken. HStenn. * [Bug 2954] Version 4.2.8p4 crashes on startup with sig fault - fixed data race conditions in threaded DNS worker. perlinger@ntp.org - limit threading warm-up to linux; FreeBSD bombs on it. perlinger@ntp.org * [Bug 2957] 'unsigned int' vs 'size_t' format clash. perlinger@ntp.org - accept key file only if there are no parsing errors - fixed size_t/u_int format clash - fixed wrong use of 'strlcpy' * [Bug 2958] ntpq: fatal error messages need a final newline. Craig Leres. * [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets. perlinger@ntp.org - fixed several other warnings (cast-alignment, missing const, missing prototypes) - promote use of 'size_t' for values that express a size - use ptr-to-const for read-only arguments - make sure SOCKET values are not truncated (win32-specific) - format string fixes * [Bug 2965] Local clock didn't work since 4.2.8p4. Martin Burnicki. * [Bug 2967] ntpdate command suffers an assertion failure - fixed ntp_rfc2553.c to return proper address length. perlinger@ntp.org * [Bug 2969] Seg fault from ntpq/mrulist when looking at server with lots of clients. perlinger@ntp.org * [Bug 2971] ntpq bails on ^C: select fails: Interrupted system call - changed stacked/nested handling of CTRL-C. perlinger@ntp.org * Unity cleanup for FreeBSD-6.4. Harlan Stenn. * Unity test cleanup. Harlan Stenn. * Libevent autoconf pthread fixes for FreeBSD-10. Harlan Stenn. * Header cleanup in tests/sandbox/uglydate.c. Harlan Stenn. * Header cleanup in tests/libntp/sfptostr.c. Harlan Stenn. * Quiet a warning from clang. Harlan Stenn. * Update the NEWS file. Harlan Stenn. * Update scripts/calc_tickadj/Makefile.am. Harlan Stenn.
119 lines
2.7 KiB
C
119 lines
2.7 KiB
C
/* $NetBSD: timetrim.c,v 1.4 2016/01/08 21:35:42 christos Exp $ */
|
|
|
|
#if defined(sgi) || defined(_UNICOSMP)
|
|
/*
|
|
* timetrim.c
|
|
*
|
|
* "timetrim" allows setting and adjustment of the system clock frequency
|
|
* trim parameter on Silicon Graphics machines. The trim value native
|
|
* units are nanoseconds per second (10**-9), so a trim value of 1 makes
|
|
* the system clock step ahead 1 nanosecond more per second than a value
|
|
* of zero. Xntpd currently uses units of 2**-20 secs for its frequency
|
|
* offset (drift) values; to convert to a timetrim value, multiply by
|
|
* 1E9 / 2**20 (about 954).
|
|
*
|
|
* "timetrim" with no arguments just prints out the current kernel value.
|
|
* With a numeric argument, the kernel value is set to the supplied value.
|
|
* The "-i" flag causes the supplied value to be added to the kernel value.
|
|
* The "-n" option causes all input and output to be in xntpd units rather
|
|
* than timetrim native units.
|
|
*
|
|
* Note that there is a limit of +-3000000 (0.3%) on the timetrim value
|
|
* which is (silently?) enforced by the kernel.
|
|
*
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
#include <config.h>
|
|
#endif
|
|
|
|
#include <stdio.h>
|
|
#include <ctype.h>
|
|
#include <stdlib.h>
|
|
#ifdef HAVE_SYS_SYSSGI_H
|
|
# include <sys/syssgi.h>
|
|
#endif
|
|
#ifdef HAVE_SYS_SYSTUNE_H
|
|
# include <sys/systune.h>
|
|
#endif
|
|
|
|
#define abs(X) (((X) < 0) ? -(X) : (X))
|
|
#define USAGE "usage: timetrim [-n] [[-i] value]\n"
|
|
#define SGITONTP(X) ((double)(X) * 1048576.0/1.0e9)
|
|
#define NTPTOSGI(X) ((long)((X) * 1.0e9/1048576.0))
|
|
|
|
int
|
|
main(
|
|
int argc,
|
|
char *argv[]
|
|
)
|
|
{
|
|
char *rem;
|
|
int incremental = 0, ntpunits = 0;
|
|
long timetrim;
|
|
double value;
|
|
|
|
while (--argc && **++argv == '-' && isalpha((int)argv[0][1])) {
|
|
switch (argv[0][1]) {
|
|
case 'i':
|
|
incremental++;
|
|
break;
|
|
case 'n':
|
|
ntpunits++;
|
|
break;
|
|
default:
|
|
fprintf(stderr, USAGE);
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
#ifdef HAVE_SYS_SYSSGI_H
|
|
if (syssgi(SGI_GETTIMETRIM, &timetrim) < 0) {
|
|
perror("syssgi");
|
|
exit(2);
|
|
}
|
|
#endif
|
|
#ifdef HAVE_SYS_SYSTUNE_H
|
|
if (systune(SYSTUNE_GET, "timetrim", &timetrim) < 0) {
|
|
perror("systune");
|
|
exit(2);
|
|
}
|
|
#endif
|
|
|
|
if (argc == 0) {
|
|
if (ntpunits)
|
|
fprintf(stdout, "%0.5f\n", SGITONTP(timetrim));
|
|
else
|
|
fprintf(stdout, "%ld\n", timetrim);
|
|
} else if (argc != 1) {
|
|
fprintf(stderr, USAGE);
|
|
exit(1);
|
|
} else {
|
|
value = strtod(argv[0], &rem);
|
|
if (*rem != '\0') {
|
|
fprintf(stderr, USAGE);
|
|
exit(1);
|
|
}
|
|
if (ntpunits)
|
|
value = NTPTOSGI(value);
|
|
if (incremental)
|
|
timetrim += value;
|
|
else
|
|
timetrim = value;
|
|
#ifdef HAVE_SYS_SYSSGI_H
|
|
if (syssgi(SGI_SETTIMETRIM, timetrim) < 0) {
|
|
perror("syssgi");
|
|
exit(2);
|
|
}
|
|
#endif
|
|
#ifdef HAVE_SYS_SYSTUNE_H
|
|
if (systune(SYSTUNE_SET, "timer", "timetrim", &timetrim) < 0) {
|
|
perror("systune");
|
|
exit(2);
|
|
}
|
|
#endif
|
|
}
|
|
return 0;
|
|
}
|
|
#endif
|