1 #if defined(sgi) || defined(_UNICOSMP)
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>
34 #ifdef HAVE_SYS_SYSTUNE_H
35 # include <sys/systune.h>
38 #define abs(X) (((X) < 0) ? -(X) : (X))
39 #define USAGE "usage: timetrim [-n] [[-i] value]\n"
40 #define SGITONTP(X) ((double)(X) * 1048576.0/1.0e9)
41 #define NTPTOSGI(X) ((long)((X) * 1.0e9/1048576.0))
50 int incremental = 0, ntpunits = 0;
54 while (--argc && **++argv == '-' && isalpha((int)argv[0][1])) {
63 fprintf(stderr, USAGE);
68 #ifdef HAVE_SYS_SYSSGI_H
69 if (syssgi(SGI_GETTIMETRIM, &timetrim) < 0) {
74 #ifdef HAVE_SYS_SYSTUNE_H
75 if (systune(SYSTUNE_GET, "timetrim", &timetrim) < 0) {
83 fprintf(stdout, "%0.5f\n", SGITONTP(timetrim));
85 fprintf(stdout, "%ld\n", timetrim);
86 } else if (argc != 1) {
87 fprintf(stderr, USAGE);
90 value = strtod(argv[0], &rem);
92 fprintf(stderr, USAGE);
96 value = NTPTOSGI(value);
101 #ifdef HAVE_SYS_SYSSGI_H
102 if (syssgi(SGI_SETTIMETRIM, timetrim) < 0) {
107 #ifdef HAVE_SYS_SYSTUNE_H
108 if (systune(SYSTUNE_SET, "timer", "timetrim", &timetrim) < 0) {