3 #if defined(sgi) || defined(_UNICOSMP)
7 * "timetrim" allows setting and adjustment of the system clock frequency
8 * trim parameter on Silicon Graphics machines. The trim value native
9 * units are nanoseconds per second (10**-9), so a trim value of 1 makes
10 * the system clock step ahead 1 nanosecond more per second than a value
11 * of zero. Xntpd currently uses units of 2**-20 secs for its frequency
12 * offset (drift) values; to convert to a timetrim value, multiply by
13 * 1E9 / 2**20 (about 954).
15 * "timetrim" with no arguments just prints out the current kernel value.
16 * With a numeric argument, the kernel value is set to the supplied value.
17 * The "-i" flag causes the supplied value to be added to the kernel value.
18 * The "-n" option causes all input and output to be in xntpd units rather
19 * than timetrim native units.
21 * Note that there is a limit of +-3000000 (0.3%) on the timetrim value
22 * which is (silently?) enforced by the kernel.
33 #ifdef HAVE_SYS_SYSSGI_H
34 # include <sys/syssgi.h>
36 #ifdef HAVE_SYS_SYSTUNE_H
37 # include <sys/systune.h>
40 #define abs(X) (((X) < 0) ? -(X) : (X))
41 #define USAGE "usage: timetrim [-n] [[-i] value]\n"
42 #define SGITONTP(X) ((double)(X) * 1048576.0/1.0e9)
43 #define NTPTOSGI(X) ((long)((X) * 1.0e9/1048576.0))
52 int incremental
= 0, ntpunits
= 0;
56 while (--argc
&& **++argv
== '-' && isalpha((int)argv
[0][1])) {
65 fprintf(stderr
, USAGE
);
70 #ifdef HAVE_SYS_SYSSGI_H
71 if (syssgi(SGI_GETTIMETRIM
, &timetrim
) < 0) {
76 #ifdef HAVE_SYS_SYSTUNE_H
77 if (systune(SYSTUNE_GET
, "timetrim", &timetrim
) < 0) {
85 fprintf(stdout
, "%0.5f\n", SGITONTP(timetrim
));
87 fprintf(stdout
, "%ld\n", timetrim
);
88 } else if (argc
!= 1) {
89 fprintf(stderr
, USAGE
);
92 value
= strtod(argv
[0], &rem
);
94 fprintf(stderr
, USAGE
);
98 value
= NTPTOSGI(value
);
103 #ifdef HAVE_SYS_SYSSGI_H
104 if (syssgi(SGI_SETTIMETRIM
, timetrim
) < 0) {
109 #ifdef HAVE_SYS_SYSTUNE_H
110 if (systune(SYSTUNE_SET
, "timer", "timetrim", &timetrim
) < 0) {