Mercurial > hg > xemacs-beta
comparison src/getloadavg.c @ 280:7df0dd720c89 r21-0b38
Import from CVS: tag r21-0b38
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:32:22 +0200 |
parents | 90d73dddcdc4 |
children | c42ec1d1cded |
comparison
equal
deleted
inserted
replaced
279:c20b2fb5bb0a | 280:7df0dd720c89 |
---|---|
523 #define LDAV_DONE | 523 #define LDAV_DONE |
524 /* Set errno to zero to indicate that there was no particular error; | 524 /* Set errno to zero to indicate that there was no particular error; |
525 this function just can't work at all on this system. */ | 525 this function just can't work at all on this system. */ |
526 errno = 0; | 526 errno = 0; |
527 elem = -2; | 527 elem = -2; |
528 #endif | 528 #endif /* NO_GET_LOAD_AVG */ |
529 | 529 |
530 #if ! defined (LDAV_DONE) && defined (HAVE_KSTAT_H) && defined (HAVE_LIBKSTAT) | 530 #if ! defined (LDAV_DONE) && defined (HAVE_KSTAT_H) && defined (HAVE_LIBKSTAT) |
531 #define LDAV_DONE | 531 #define LDAV_DONE |
532 /* getloadavg is best implemented using kstat (kernel stats), on | 532 /* getloadavg is best implemented using kstat (kernel stats), on |
533 systems (like SunOS5) that support it, since you don't need special | 533 systems (like SunOS5) that support it, since you don't need special |
544 "avenrun_15min" }; | 544 "avenrun_15min" }; |
545 | 545 |
546 if (nelem > countof (avestrings)) | 546 if (nelem > countof (avestrings)) |
547 nelem = countof (avestrings); | 547 nelem = countof (avestrings); |
548 | 548 |
549 kc = kstat_open(); | 549 kc = kstat_open (); |
550 if (!kc) | 550 if (!kc) |
551 return -1; | 551 return -1; |
552 ksp = kstat_lookup (kc, "unix", 0, "system_misc"); | 552 ksp = kstat_lookup (kc, "unix", 0, "system_misc"); |
553 if (!ksp) | 553 if (!ksp) |
554 { | 554 { |
566 if (!kn) | 566 if (!kn) |
567 { | 567 { |
568 kstat_close (kc); | 568 kstat_close (kc); |
569 return -1; | 569 return -1; |
570 } | 570 } |
571 loadavg[elem] = (double)kn->value.ul/FSCALE; | 571 loadavg[elem] = (double)kn->value.ul / FSCALE; |
572 } | 572 } |
573 kstat_close (kc); | 573 kstat_close (kc); |
574 #endif /* HAVE_KSTAT_H && HAVE_LIBKSTAT */ | 574 #endif /* HAVE_KSTAT_H && HAVE_LIBKSTAT */ |
575 | 575 |
576 #if !defined (LDAV_DONE) && defined (HAVE_SYS_PSTAT_H) | 576 #if !defined (LDAV_DONE) && defined (HAVE_SYS_PSTAT_H) |
941 loadavg[elem++] = LDAV_CVT (load_ave[2]); | 941 loadavg[elem++] = LDAV_CVT (load_ave[2]); |
942 | 942 |
943 #define LDAV_DONE | 943 #define LDAV_DONE |
944 #endif /* !LDAV_DONE && LOAD_AVE_TYPE */ | 944 #endif /* !LDAV_DONE && LOAD_AVE_TYPE */ |
945 | 945 |
946 #ifdef LDAV_DONE | |
947 return elem; | 946 return elem; |
948 #else | |
949 /* Set errno to zero to indicate that there was no particular error; | |
950 this function just can't work at all on this system. */ | |
951 errno = 0; | |
952 return -2; | |
953 #endif | |
954 } | 947 } |
955 | 948 |
956 #endif /* ! HAVE_GETLOADAVG */ | 949 #endif /* ! HAVE_GETLOADAVG */ |
957 | 950 |
958 #ifdef TEST | 951 #ifdef TEST |