5 * "timetrim" allows setting and adjustment of the system clock frequency
6 * trim parameter on Silicon Graphics machines. The trim value native
7 * units are nanoseconds per second (10**-9), so a trim value of 1 makes
8 * the system clock step ahead 1 nanosecond more per second than a value
9 * of zero. Xntpd currently uses units of 2**-20 secs for its frequency
10 * offset (drift) values; to convert to a timetrim value, multiply by
11 * 1E9 / 2**20 (about 954).
13 * "timetrim" with no arguments just prints out the current kernel value.
14 * With a numeric argument, the kernel value is set to the supplied value.
15 * The "-i" flag causes the supplied value to be added to the kernel value.
16 * The "-n" option causes all input and output to be in xntpd units rather
17 * than timetrim native units.
19 * Note that there is a limit of +-3000000 (0.3%) on the timetrim value
20 * which is (silently?) enforced by the kernel.
31 #ifdef HAVE_SYS_SYSSGI_H
32 # include <sys/syssgi.h>
35 #define abs(X) (((X) < 0) ? -(X) : (X))
36 #define USAGE "usage: timetrim [-n] [[-i] value]\n"
37 #define SGITONTP(X) ((double)(X) * 1048576.0/1.0e9)
38 #define NTPTOSGI(X) ((long)((X) * 1.0e9/1048576.0))
47 int incremental = 0, ntpunits = 0;
51 while (--argc && **++argv == '-' && isalpha((int)argv[0][1])) {
60 fprintf(stderr, USAGE);
65 if (syssgi(SGI_GETTIMETRIM, &timetrim) < 0) {
72 fprintf(stdout, "%0.5f\n", SGITONTP(timetrim));
74 fprintf(stdout, "%ld\n", timetrim);
75 } else if (argc != 1) {
76 fprintf(stderr, USAGE);
79 value = strtod(argv[0], &rem);
81 fprintf(stderr, USAGE);
85 value = NTPTOSGI(value);
90 if (syssgi(SGI_SETTIMETRIM, timetrim) < 0) {