home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / xntp3.zip / testrs6000.c < prev   
C/C++ Source or Header  |  1992-07-07  |  1KB  |  45 lines

  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. int timeout();
  15. struct timeval adjustment, result;
  16. main () {
  17.     struct itimerval value, oldvalue;
  18.     int i;
  19.     time_t curtime;
  20.     curtime = time(0);
  21.     printf("Starting: %s", ctime(&curtime));
  22.     value.it_interval.tv_sec = value.it_value.tv_sec = 1;
  23.     value.it_interval.tv_usec = value.it_value.tv_usec = 0;
  24.     adjustment.tv_sec = 0;
  25.     adjustment.tv_usec = -2000;
  26.     signal(SIGALRM, timeout);
  27.     setitimer(ITIMER_REAL, &value, &oldvalue);
  28.     for (i=0; i<10; i++) {
  29.         pause();
  30.     }
  31. }
  32.  
  33. int timeout(sig, code, scp)
  34. int sig,code;
  35. struct sigcontext *scp;
  36. {
  37.     signal (SIGALRM, timeout);
  38.     if (adjtime(&adjustment, &result)) 
  39.         printf("adjtime call failed\n");
  40.     if (result.tv_sec != 0 || result.tv_usec != 0) {
  41.         printf("result.u = %d.%06.6d  ", (int) result.tv_sec,
  42.             (int) result.tv_usec);
  43.     }
  44. }
  45.