[BACK]Return to display.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / top

Diff for /src/usr.bin/top/display.c between version 1.52 and 1.53

version 1.52, 2017/03/15 04:24:14 version 1.53, 2017/12/18 05:51:53
Line 57 
Line 57 
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
 #include <unistd.h>  #include <unistd.h>
 #include <sys/sysctl.h>  
   
 #include "screen.h"             /* interface to screen package */  #include "screen.h"             /* interface to screen package */
 #include "layout.h"             /* defines for screen position layout */  #include "layout.h"             /* defines for screen position layout */
Line 209 
Line 208 
 static void  static void
 format_uptime(char *buf, size_t buflen)  format_uptime(char *buf, size_t buflen)
 {  {
         time_t now, uptime;          time_t uptime;
         int days, hrs, mins;          int days, hrs, mins;
         int mib[2];          struct timespec boottime;
         size_t size;  
         struct timeval boottime;  
   
         now = time(NULL);  
         /*          /*
          * Print how long system has been up.           * Print how long system has been up.
          * (Found by getting "boottime" from the kernel)  
          */           */
         mib[0] = CTL_KERN;          if (clock_gettime(CLOCK_BOOTTIME, &boottime) != -1) {
         mib[1] = KERN_BOOTTIME;                  uptime = boottime.tv_sec;
         size = sizeof(boottime);  
         if (sysctl(mib, 2, &boottime, &size, NULL, 0) != -1) {  
                 uptime = now - boottime.tv_sec;  
                 uptime += 30;                  uptime += 30;
                 days = uptime / (3600 * 24);                  days = uptime / (3600 * 24);
                 uptime %= (3600 * 24);                  uptime %= (3600 * 24);

Legend:
Removed from v.1.52  
changed lines
  Added in v.1.53