Annotation of embedaddon/ntp/util/testrs6000.c, revision 1.1
1.1 ! misho 1: /* Checks for the RS/6000 AIX adjtime() bug, in which if a negative
! 2: * offset is given, the system gets messed up and never completes the
! 3: * adjustment. If the problem is fixed, this program will print the
! 4: * time, sit there for 10 seconds, and exit. If the problem isn't fixed,
! 5: * the program will print an occasional "result=nnnnnn" (the residual
! 6: * slew from adjtime()).
! 7: *
! 8: * Compile this with bsdcc and run it as root!
! 9: */
! 10: #include <signal.h>
! 11: #include <sys/time.h>
! 12: #include <time.h>
! 13: #include <stdio.h>
! 14:
! 15: int timeout();
! 16: struct timeval adjustment, result;
! 17:
! 18: int
! 19: main (
! 20: int argc,
! 21: char *argv[]
! 22: )
! 23: {
! 24: struct itimerval value, oldvalue;
! 25: int i;
! 26: time_t curtime;
! 27:
! 28: curtime = time(0);
! 29: printf("Starting: %s", ctime(&curtime));
! 30: value.it_interval.tv_sec = value.it_value.tv_sec = 1;
! 31: value.it_interval.tv_usec = value.it_value.tv_usec = 0;
! 32: adjustment.tv_sec = 0;
! 33: adjustment.tv_usec = -2000;
! 34: signal(SIGALRM, timeout);
! 35: setitimer(ITIMER_REAL, &value, &oldvalue);
! 36: for (i=0; i<10; i++) {
! 37: pause();
! 38: }
! 39: }
! 40:
! 41: int
! 42: timeout(
! 43: int sig,
! 44: int code,
! 45: struct sigcontext *scp
! 46: )
! 47: {
! 48: signal (SIGALRM, timeout);
! 49: if (adjtime(&adjustment, &result))
! 50: printf("adjtime call failed\n");
! 51: if (result.tv_sec != 0 || result.tv_usec != 0) {
! 52: printf("result.u = %d.%06.6d ", (int) result.tv_sec,
! 53: (int) result.tv_usec);
! 54: }
! 55: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>