Mercurial > hg > xemacs-beta
comparison src/getloadavg.c @ 398:74fd4e045ea6 r21-2-29
Import from CVS: tag r21-2-29
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:13:30 +0200 |
parents | 8626e4521993 |
children | de805c49cfc1 |
comparison
equal
deleted
inserted
replaced
397:f4aeb21a5bad | 398:74fd4e045ea6 |
---|---|
16 | 16 |
17 You should have received a copy of the GNU General Public License | 17 You should have received a copy of the GNU General Public License |
18 along with XEmacs; see the file COPYING. If not, write to | 18 along with XEmacs; see the file COPYING. If not, write to |
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 Boston, MA 02111-1307, USA. */ | 20 Boston, MA 02111-1307, USA. */ |
21 | |
22 #ifndef __CYGWIN32__ | |
23 | 21 |
24 /* Compile-time symbols that this file uses: | 22 /* Compile-time symbols that this file uses: |
25 | 23 |
26 FIXUP_KERNEL_SYMBOL_ADDR() Adjust address in returned struct nlist. | 24 FIXUP_KERNEL_SYMBOL_ADDR() Adjust address in returned struct nlist. |
27 KERNEL_FILE Pathname of the kernel to nlist. | 25 KERNEL_FILE Pathname of the kernel to nlist. |
69 /* This should always be first. */ | 67 /* This should always be first. */ |
70 #ifdef HAVE_CONFIG_H | 68 #ifdef HAVE_CONFIG_H |
71 #include <config.h> | 69 #include <config.h> |
72 #endif | 70 #endif |
73 | 71 |
72 #ifndef WINDOWSNT | |
73 #ifndef __CYGWIN32__ | |
74 | |
74 #include <sys/types.h> | 75 #include <sys/types.h> |
75 | 76 |
76 /* Both the Emacs and non-Emacs sections want this. Some | 77 /* Both the Emacs and non-Emacs sections want this. Some |
77 configuration files' definitions for the LOAD_AVE_CVT macro (like | 78 configuration files' definitions for the LOAD_AVE_CVT macro (like |
78 sparc.h's) use macros like FSCALE, defined here. */ | 79 sparc.h's) use macros like FSCALE, defined here. */ |
90 | 91 |
91 The declaration of `errno' is needed by the test program | 92 The declaration of `errno' is needed by the test program |
92 as well as the function itself, so it comes first. */ | 93 as well as the function itself, so it comes first. */ |
93 | 94 |
94 #include <errno.h> | 95 #include <errno.h> |
95 | |
96 #ifndef errno | |
97 extern int errno; | |
98 #endif | |
99 | 96 |
100 #ifndef HAVE_GETLOADAVG | 97 #ifndef HAVE_GETLOADAVG |
101 | 98 |
102 /* The existing Emacs configuration files define a macro called | 99 /* The existing Emacs configuration files define a macro called |
103 LOAD_AVE_CVT, which accepts a value of type LOAD_AVE_TYPE, and | 100 LOAD_AVE_CVT, which accepts a value of type LOAD_AVE_TYPE, and |
533 /* getloadavg is best implemented using kstat (kernel stats), on | 530 /* getloadavg is best implemented using kstat (kernel stats), on |
534 systems (like SunOS5) that support it, since you don't need special | 531 systems (like SunOS5) that support it, since you don't need special |
535 privileges to use it. | 532 privileges to use it. |
536 | 533 |
537 Initial implementation courtesy Zlatko Calusic <zcalusic@carnet.hr>. | 534 Initial implementation courtesy Zlatko Calusic <zcalusic@carnet.hr>. |
538 Integrated to XEmacs by Hrvoje Niksic <hniksic@srce.hr>. | 535 Integrated to XEmacs by Hrvoje Niksic <hniksic@xemacs.org>. |
539 Additional cleanup by Hrvoje Niksic, based on code published by | 536 Additional cleanup by Hrvoje Niksic, based on code published by |
540 Casper Dik <Casper.Dik@Holland.Sun.Com>. */ | 537 Casper Dik <Casper.Dik@Holland.Sun.Com>. */ |
541 kstat_ctl_t *kc; | 538 kstat_ctl_t *kc; |
542 kstat_t *ksp; | 539 kstat_t *ksp; |
543 static char *avestrings[] = { "avenrun_1min", | 540 static char *avestrings[] = { "avenrun_1min", |
768 if (nelem > 1) | 765 if (nelem > 1) |
769 loadavg[elem++] = load_info.five_minute; | 766 loadavg[elem++] = load_info.five_minute; |
770 if (nelem > 2) | 767 if (nelem > 2) |
771 loadavg[elem++] = load_info.fifteen_minute; | 768 loadavg[elem++] = load_info.fifteen_minute; |
772 #endif /* DGUX */ | 769 #endif /* DGUX */ |
773 | |
774 #if !defined (LDAV_DONE) && defined (apollo) | |
775 #define LDAV_DONE | |
776 /* Apollo code from lisch@mentorg.com (Ray Lischner). | |
777 | |
778 This system call is not documented. The load average is obtained as | |
779 three long integers, for the load average over the past minute, | |
780 five minutes, and fifteen minutes. Each value is a scaled integer, | |
781 with 16 bits of integer part and 16 bits of fraction part. | |
782 | |
783 I'm not sure which operating system first supported this system call, | |
784 but I know that SR10.2 supports it. */ | |
785 | |
786 extern void proc1_$get_loadav (); | |
787 unsigned long load_ave[3]; | |
788 | |
789 proc1_$get_loadav (load_ave); | |
790 | |
791 if (nelem > 0) | |
792 loadavg[elem++] = load_ave[0] / 65536.0; | |
793 if (nelem > 1) | |
794 loadavg[elem++] = load_ave[1] / 65536.0; | |
795 if (nelem > 2) | |
796 loadavg[elem++] = load_ave[2] / 65536.0; | |
797 #endif /* apollo */ | |
798 | 770 |
799 #if !defined (LDAV_DONE) && defined (OSF_MIPS) | 771 #if !defined (LDAV_DONE) && defined (OSF_MIPS) |
800 #define LDAV_DONE | 772 #define LDAV_DONE |
801 | 773 |
802 struct tbl_loadavg load_ave; | 774 struct tbl_loadavg load_ave; |
1004 } | 976 } |
1005 return i; | 977 return i; |
1006 } | 978 } |
1007 | 979 |
1008 #endif /*__GNUWIN32__*/ | 980 #endif /*__GNUWIN32__*/ |
1009 | 981 #endif /* WINDOWSNT */ |