Mercurial > hg > xemacs-beta
comparison src/getloadavg.c @ 84:ac0620f6398e r20-0b92
Import from CVS: tag r20-0b92
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:08:29 +0200 |
parents | 6a378aca36af |
children | 59463afc5666 |
comparison
equal
deleted
inserted
replaced
83:ba3ba6e17456 | 84:ac0620f6398e |
---|---|
1 /* Get the system load averages. | 1 /* Get the system load averages. |
2 Copyright (C) 1985, 86, 87, 88, 89, 91, 92, 93, 1994, 1995 | 2 Copyright (C) 1985, 86, 87, 88, 89, 91, 92, 93, 1994, 1995 |
3 Free Software Foundation, Inc. | 3 Free Software Foundation, Inc. |
4 | 4 |
5 This program is free software; you can redistribute it and/or modify | 5 This file is part of XEmacs. |
6 it under the terms of the GNU General Public License as published by | 6 |
7 the Free Software Foundation; either version 2, or (at your option) | 7 XEmacs is free software; you can redistribute it and/or modify it |
8 any later version. | 8 under the terms of the GNU General Public License as published by the |
9 | 9 Free Software Foundation; either version 2, or (at your option) any |
10 This program is distributed in the hope that it will be useful, | 10 later version. |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 XEmacs is distributed in the hope that it will be useful, but WITHOUT |
13 GNU General Public License for more details. | 13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
14 | 14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
15 You should have received a copy of the GNU General Public License | 15 for more details. |
16 along with this program; if not, write to the Free Software | 16 |
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | 17 You should have received a copy of the GNU General Public License |
18 USA. */ | 18 along with XEmacs; see the file COPYING. If not, write to |
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
20 Boston, MA 02111-1307, USA. */ | |
21 | |
19 | 22 |
20 /* Compile-time symbols that this file uses: | 23 /* Compile-time symbols that this file uses: |
21 | 24 |
22 FIXUP_KERNEL_SYMBOL_ADDR() Adjust address in returned struct nlist. | 25 FIXUP_KERNEL_SYMBOL_ADDR() Adjust address in returned struct nlist. |
23 KERNEL_FILE Pathname of the kernel to nlist. | 26 KERNEL_FILE Pathname of the kernel to nlist. |
93 extern int errno; | 96 extern int errno; |
94 #endif | 97 #endif |
95 | 98 |
96 #ifndef HAVE_GETLOADAVG | 99 #ifndef HAVE_GETLOADAVG |
97 | 100 |
98 | |
99 /* The existing Emacs configuration files define a macro called | 101 /* The existing Emacs configuration files define a macro called |
100 LOAD_AVE_CVT, which accepts a value of type LOAD_AVE_TYPE, and | 102 LOAD_AVE_CVT, which accepts a value of type LOAD_AVE_TYPE, and |
101 returns the load average multiplied by 100. What we actually want | 103 returns the load average multiplied by 100. What we actually want |
102 is a macro called LDAV_CVT, which returns the load average as an | 104 is a macro called LDAV_CVT, which returns the load average as an |
103 unmultiplied double. | 105 unmultiplied double. |
515 into the first NELEM elements of LOADAVG. | 517 into the first NELEM elements of LOADAVG. |
516 Return the number written (never more than 3, but may be less than NELEM), | 518 Return the number written (never more than 3, but may be less than NELEM), |
517 or -1 if an error occurred. */ | 519 or -1 if an error occurred. */ |
518 | 520 |
519 int | 521 int |
520 getloadavg (loadavg, nelem) | 522 getloadavg (double loadavg[], int nelem) |
521 double loadavg[]; | |
522 int nelem; | |
523 { | 523 { |
524 int elem = 0; /* Return value. */ | 524 int elem = 0; /* Return value. */ |
525 | 525 |
526 #ifdef NO_GET_LOAD_AVG | 526 #ifdef NO_GET_LOAD_AVG |
527 #define LDAV_DONE | 527 #define LDAV_DONE |
888 #else /* NLIST_STRUCT */ | 888 #else /* NLIST_STRUCT */ |
889 #ifdef NLIST_NAME_UNION | 889 #ifdef NLIST_NAME_UNION |
890 nl[0].n_un.n_name = LDAV_SYMBOL; | 890 nl[0].n_un.n_name = LDAV_SYMBOL; |
891 nl[1].n_un.n_name = 0; | 891 nl[1].n_un.n_name = 0; |
892 #else /* not NLIST_NAME_UNION */ | 892 #else /* not NLIST_NAME_UNION */ |
893 nl[0].n_name = LDAV_SYMBOL; | 893 nl[0].n_name = (char *) LDAV_SYMBOL; |
894 nl[1].n_name = 0; | 894 nl[1].n_name = 0; |
895 #endif /* not NLIST_NAME_UNION */ | 895 #endif /* not NLIST_NAME_UNION */ |
896 #endif /* NLIST_STRUCT */ | 896 #endif /* NLIST_STRUCT */ |
897 | 897 |
898 #ifndef SUNOS_5 | 898 #ifndef SUNOS_5 |
1000 | 1000 |
1001 #endif /* ! HAVE_GETLOADAVG */ | 1001 #endif /* ! HAVE_GETLOADAVG */ |
1002 | 1002 |
1003 #ifdef TEST | 1003 #ifdef TEST |
1004 void | 1004 void |
1005 main (argc, argv) | 1005 main (int argc, char **argv) |
1006 int argc; | |
1007 char **argv; | |
1008 { | 1006 { |
1009 int naptime = 0; | 1007 int naptime = 0; |
1010 | 1008 |
1011 if (argc > 1) | 1009 if (argc > 1) |
1012 naptime = atoi (argv[1]); | 1010 naptime = atoi (argv[1]); |