Mercurial > hg > xemacs-beta
annotate src/getloadavg.c @ 5636:07256dcc0c8b
Add missing foreback specifier values to the GUI Element face.
They were missing for an unexplicable reason in my initial patch, leading to
nil color instances in the whole hierarchy of widget faces.
-------------------- ChangeLog entries follow: --------------------
src/ChangeLog addition:
2012-01-03 Didier Verna <didier@xemacs.org>
* faces.c (complex_vars_of_faces): Add missing foreback specifier
values to the GUI Element face.
author | Didier Verna <didier@lrde.epita.fr> |
---|---|
date | Tue, 03 Jan 2012 11:25:06 +0100 |
parents | 1f0b15040456 |
children | 574f0cded429 |
rev | line source |
---|---|
428 | 1 /* Get the system load averages. |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
2 Copyright (C) 1985-1989, 1991-1995, 1997, 2001-2008 |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
3 Free Software Foundation, Inc. |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
4 Copyright (C) 2010 Ben Wing. |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
5 |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
6 NOTE: The canonical source of this file is maintained with gnulib. |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
7 Bugs can be reported to bug-gnulib@gnu.org. |
428 | 8 |
9 This file is part of XEmacs. | |
10 | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4759
diff
changeset
|
11 XEmacs is free software: you can redistribute it and/or modify it |
428 | 12 under the terms of the GNU General Public License as published by the |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4759
diff
changeset
|
13 Free Software Foundation, either version 3 of the License, or (at your |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4759
diff
changeset
|
14 option) any later version. |
428 | 15 |
16 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
19 for more details. | |
20 | |
21 You should have received a copy of the GNU General Public License | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4759
diff
changeset
|
22 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */ |
428 | 23 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
24 /* Synced up with: FSF 23.1.92. */ |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
25 /* Synced by: Ben Wing. */ |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
26 |
428 | 27 /* Compile-time symbols that this file uses: |
28 | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
29 HAVE_SYS_PSTAT_H Defined if the pstat() function is available |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
30 (HPUX only); the GNU version uses |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
31 pstat_getdynamic() and HAVE_PSTAT_GETDYNAMIC. |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
32 |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
33 [[ GNU says: The best way to get the |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
34 definition is through the AC_FUNC_GETLOADAVG |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
35 macro that comes with autoconf 2.13 or newer. |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
36 If that isn't an option, then just put |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
37 AC_CHECK_FUNCS(pstat_getdynamic) in your |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
38 configure.in file. ]] But we don't do this, |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
39 apparently we do the equivalent of |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
40 AC_FUNC_GETLOADAVG dynamically. |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
41 |
428 | 42 FIXUP_KERNEL_SYMBOL_ADDR() Adjust address in returned struct nlist. |
43 KERNEL_FILE Pathname of the kernel to nlist. | |
44 LDAV_CVT() Scale the load average from the kernel. | |
45 Returns a double. | |
46 LDAV_SYMBOL Name of kernel symbol giving load average. | |
47 LOAD_AVE_TYPE Type of the load average array in the kernel. | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
48 Must be defined; or we have libkstat; |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
49 otherwise, no load average is available. |
428 | 50 NLIST_STRUCT Include nlist.h, not a.out.h, and |
51 the nlist n_name element is a pointer, | |
52 not an array. | |
53 LINUX_LDAV_FILE [__linux__]: File containing load averages. | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
54 HAVE_LOCALE_H locale.h is available. |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
55 HAVE_SETLOCALE The `setlocale' function is available. |
428 | 56 |
57 Specific system predefines this file uses, aside from setting | |
58 default values if not emacs: | |
59 | |
60 BSD Real BSD, not just BSD-like. | |
61 hpux | |
62 sgi | |
442 | 63 WIN32_NATIVE No-op for Windows9x/NT. |
64 CYGWIN No-op for Cygwin. | |
428 | 65 __linux__ Linux: assumes /proc filesystem mounted. |
66 Support from Michael K. Johnson. | |
67 __NetBSD__ NetBSD: assumes /kern filesystem mounted. | |
68 __OpenBSD__ OpenBSD: ditto. | |
69 | |
70 In addition, to avoid nesting many #ifdefs, we internally set | |
71 LDAV_DONE to indicate that the load average has been computed. | |
72 | |
73 We also #define LDAV_PRIVILEGED if a program will require | |
74 special installation to be able to call getloadavg. */ | |
75 | |
76 /* This should always be first. */ | |
77 #ifdef HAVE_CONFIG_H | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
78 # include <config.h> |
428 | 79 #endif |
80 | |
81 #include "lisp.h" | |
82 #include "sysfile.h" /* for encapsulated open, close, read, write */ | |
83 | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
84 #ifdef HAVE_LOCALE_H |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
85 # include <locale.h> |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
86 #endif |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
87 #ifndef HAVE_SETLOCALE |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
88 # define setlocale(Category, Locale) /* empty */ |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
89 #endif |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
90 |
428 | 91 #ifndef HAVE_GETLOADAVG |
92 | |
93 /* The existing Emacs configuration files define a macro called | |
94 LOAD_AVE_CVT, which accepts a value of type LOAD_AVE_TYPE, and | |
95 returns the load average multiplied by 100. What we actually want | |
96 is a macro called LDAV_CVT, which returns the load average as an | |
97 unmultiplied double. | |
98 | |
99 For backwards compatibility, we'll define LDAV_CVT in terms of | |
100 LOAD_AVE_CVT, but future machine config files should just define | |
101 LDAV_CVT directly. */ | |
102 | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
103 # if !defined(LDAV_CVT) && defined(LOAD_AVE_CVT) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
104 # define LDAV_CVT(n) (LOAD_AVE_CVT (n) / 100.0) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
105 # endif |
428 | 106 |
107 #if defined (HAVE_KSTAT_H) | |
108 #include <kstat.h> | |
109 #endif /* HAVE_KSTAT_H */ | |
110 | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
111 /* Same issues as for NeXT apply to the HURD-based GNU system. */ |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
112 # ifdef __GNU__ |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
113 # undef BSD |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
114 # undef FSCALE |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
115 # endif /* __GNU__ */ |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
116 |
428 | 117 /* Set values that are different from the defaults, which are |
118 set a little farther down with #ifndef. */ | |
119 | |
120 | |
121 /* Some shorthands. */ | |
122 | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
123 # if defined (HPUX) && !defined (hpux) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
124 # define hpux |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
125 # endif |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
126 |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
127 # if defined (__hpux) && !defined (hpux) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
128 # define hpux |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
129 # endif |
428 | 130 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
131 # if defined (__sun) && !defined (sun) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
132 # define sun |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
133 # endif |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
134 |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
135 # if defined (__SVR4) && !defined (SVR4) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
136 # define SVR4 |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
137 # endif |
428 | 138 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
139 # if (defined(sun) && defined(SVR4)) || defined (SOLARIS2) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
140 # define SUNOS_5 |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
141 # endif |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
142 |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
143 # if defined (__osf__) && (defined (__alpha) || defined (__alpha__)) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
144 # define OSF_ALPHA |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
145 # /* XEmacs: First three below from FSF 23.1.92. */ |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
146 # include <sys/mbuf.h> |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
147 # include <sys/socket.h> |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
148 # include <net/route.h> |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
149 # include <netdb.h> |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
150 # include <netinet/in.h> /* Needed for Digital UNIX V3 */ |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
151 # include <net/proto_net.h> |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
152 # include <sys/table.h> |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
153 # endif |
428 | 154 |
155 #if defined (__osf__) && (defined (mips) || defined (__mips__)) | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
156 # define OSF_MIPS |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
157 # include <sys/table.h> |
428 | 158 #endif |
159 | |
160 | |
161 /* VAX C can't handle multi-line #ifs, or lines longer than 256 chars. */ | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
162 # ifndef LOAD_AVE_TYPE |
428 | 163 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
164 # ifdef sun |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
165 # define LOAD_AVE_TYPE long |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
166 # endif |
428 | 167 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
168 # ifdef decstation |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
169 # define LOAD_AVE_TYPE long |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
170 # endif |
428 | 171 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
172 # ifdef sgi |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
173 # define LOAD_AVE_TYPE long |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
174 # endif |
428 | 175 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
176 # ifdef SVR4 |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
177 # define LOAD_AVE_TYPE long |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
178 # endif |
428 | 179 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
180 # ifdef sony_news |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
181 # define LOAD_AVE_TYPE long |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
182 # endif |
428 | 183 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
184 # ifdef OSF_ALPHA |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
185 # define LOAD_AVE_TYPE long |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
186 # endif |
428 | 187 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
188 # if defined (ardent) && defined (titan) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
189 # define LOAD_AVE_TYPE long |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
190 # endif |
428 | 191 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
192 # ifdef _AIX |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
193 # define LOAD_AVE_TYPE long |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
194 # endif |
428 | 195 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
196 # endif /* No LOAD_AVE_TYPE. */ |
428 | 197 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
198 # ifdef OSF_ALPHA |
428 | 199 /* <sys/param.h> defines an incorrect value for FSCALE on Alpha OSF/1, |
200 according to ghazi@noc.rutgers.edu. */ | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
201 # undef FSCALE |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
202 # define FSCALE 1024.0 |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
203 # endif |
428 | 204 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
205 # ifndef FSCALE |
428 | 206 |
207 /* SunOS and some others define FSCALE in sys/param.h. */ | |
208 | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
209 # if defined(MIPS) || defined(SVR4) || defined(decstation) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
210 # define FSCALE 256 |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
211 # endif |
428 | 212 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
213 # if defined (sgi) |
428 | 214 /* Sometimes both MIPS and sgi are defined, so FSCALE was just defined |
215 above under #ifdef MIPS. But we want the sgi value. */ | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
216 # undef FSCALE |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
217 # define FSCALE 1000.0 |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
218 # endif |
428 | 219 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
220 # if defined (ardent) && defined (titan) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
221 # define FSCALE 65536.0 |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
222 # endif |
428 | 223 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
224 # ifdef _AIX |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
225 # define FSCALE 65536.0 |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
226 # endif |
428 | 227 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
228 # endif /* Not FSCALE. */ |
428 | 229 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
230 # if !defined (LDAV_CVT) && defined (FSCALE) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
231 # define LDAV_CVT(n) (((double) (n)) / FSCALE) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
232 # endif |
428 | 233 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
234 #if 0 /* XEmacs change ... we check for nlist.h during configure and |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
235 automatically set NLIST_STRUCT if so; we have no HAVE_NLIST_H. */ |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
236 # ifndef NLIST_STRUCT |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
237 # if HAVE_NLIST_H |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
238 # define NLIST_STRUCT |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
239 # endif |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
240 # endif |
428 | 241 #endif |
242 | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
243 # if defined(sgi) || (defined(mips) && !defined(BSD)) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
244 # define FIXUP_KERNEL_SYMBOL_ADDR(nl) ((nl)[0].n_value &= ~(1 << 31)) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
245 # endif |
428 | 246 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
247 # if !defined (KERNEL_FILE) && defined (hpux) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
248 # define KERNEL_FILE "/hp-ux" |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
249 # endif |
428 | 250 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
251 # if !defined(KERNEL_FILE) && (defined(MIPS) || defined(SVR4) || defined(ISC) || defined (sgi) || (defined (ardent) && defined (titan))) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
252 # define KERNEL_FILE "/unix" |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
253 # endif |
428 | 254 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
255 # if !defined(LDAV_SYMBOL) && (defined(hpux) || defined(SVR4) || defined(ISC) || defined(sgi) || (defined (ardent) && defined (titan)) || defined (_AIX)) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
256 # define LDAV_SYMBOL "avenrun" |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
257 # endif |
428 | 258 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
259 # ifdef HAVE_UNISTD_H |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
260 # include <unistd.h> |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
261 # endif |
428 | 262 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
263 # include <stdio.h> |
428 | 264 |
265 /* LOAD_AVE_TYPE should only get defined if we're going to use the | |
266 nlist method. */ | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
267 # if !defined(LOAD_AVE_TYPE) && (defined(BSD) || defined(LDAV_CVT) || defined(KERNEL_FILE) || defined(LDAV_SYMBOL)) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
268 # define LOAD_AVE_TYPE double |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
269 # endif |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
270 |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
271 # ifdef LOAD_AVE_TYPE |
428 | 272 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
273 # ifndef __linux__ |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
274 # ifndef NLIST_STRUCT |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
275 # include <a.out.h> |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
276 # else /* NLIST_STRUCT */ |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
277 # include <nlist.h> |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
278 # endif /* NLIST_STRUCT */ |
428 | 279 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
280 # ifdef SUNOS_5 |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
281 # include <fcntl.h> |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
282 # include <kvm.h> |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
283 # include <kstat.h> |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
284 # endif |
428 | 285 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
286 /* XEmacs: GNU says: defined (hpux) && defined (HAVE_PSTAT_GETDYNAMIC) */ |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
287 # if defined (HAVE_SYS_PSTAT_H) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
288 # include <sys/pstat.h> |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
289 # endif /* HAVE_SYS_PSTAT_H (on HPUX) */ |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
290 |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
291 # ifndef KERNEL_FILE |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
292 # define KERNEL_FILE "/vmunix" |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
293 # endif /* KERNEL_FILE */ |
428 | 294 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
295 # ifndef LDAV_SYMBOL |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
296 # define LDAV_SYMBOL "_avenrun" |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
297 # endif /* LDAV_SYMBOL */ |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
298 # endif /* __linux__ */ |
428 | 299 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
300 # ifndef LDAV_CVT |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
301 # define LDAV_CVT(n) ((double) (n)) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
302 # endif /* !LDAV_CVT */ |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
303 |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
304 # endif /* LOAD_AVE_TYPE */ |
428 | 305 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
306 # if defined(__GNU__) && !defined (NeXT) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
307 /* XEmacs -- FSF added code for the HURD, which depends on some NeXT |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
308 code that we deleted as outdated. We hardly care about compiling |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
309 on the HURD, but I'm leaving this stuff here just in case; if someone |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
310 wants to get this working, figure out which NeXT code needs to be |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
311 restored. */ |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
312 # error "Code not working currently" |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
313 /* Note that NeXT Openstep defines __GNU__ even though it should not. */ |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
314 /* GNU system acts much like NeXT, for load average purposes, |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
315 but not exactly. */ |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
316 # define NeXT |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
317 # define host_self mach_host_self |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
318 # endif /* defined(__GNU__) && !defined (NeXT) */ |
428 | 319 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
320 /* (ifdef NeXT ... deleted) */ |
428 | 321 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
322 # ifdef sgi |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
323 # include <sys/sysmp.h> |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
324 # endif /* sgi */ |
428 | 325 |
326 | |
327 /* Avoid static vars inside a function since in HPUX they dump as pure. */ | |
328 | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
329 #if !defined(HAVE_LIBKSTAT) && defined(LOAD_AVE_TYPE) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
330 /* File descriptor open to /dev/kmem or VMS load ave driver. */ |
428 | 331 static int channel; |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
332 /* Nonzero if channel is valid. */ |
428 | 333 static int getloadavg_initialized; |
334 /* Offset in kmem to seek to read load average, or 0 means invalid. */ | |
335 static long offset; | |
336 | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
337 # if !defined(sgi) && !defined(__linux__) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
338 static struct nlist name_list[2]; |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
339 # endif /* Not Linux or sgi */ |
428 | 340 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
341 # ifdef SUNOS_5 |
428 | 342 static kvm_t *kd; |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
343 # endif /* SUNOS_5 */ |
428 | 344 |
345 #ifndef countof | |
346 # define countof(x) (sizeof (x) / sizeof (*(x))) | |
347 #endif | |
348 | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
349 #endif /* LOAD_AVE_TYPE && !HAVE_LIBKSTAT */ |
428 | 350 |
351 /* Put the 1 minute, 5 minute and 15 minute load averages | |
352 into the first NELEM elements of LOADAVG. | |
353 Return the number written (never more than 3, but may be less than NELEM), | |
354 or -1 if an error occurred. */ | |
355 | |
442 | 356 int getloadavg (double loadavg[], int nelem); |
357 | |
428 | 358 int |
359 getloadavg (double loadavg[], int nelem) | |
360 { | |
361 int elem = 0; /* Return value. */ | |
362 | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
363 # ifdef NO_GET_LOAD_AVG |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
364 # define LDAV_DONE |
428 | 365 /* Set errno to zero to indicate that there was no particular error; |
366 this function just can't work at all on this system. */ | |
367 errno = 0; | |
368 elem = -2; | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
369 # endif /* NO_GET_LOAD_AVG */ |
428 | 370 |
371 #if ! defined (LDAV_DONE) && defined (HAVE_KSTAT_H) && defined (HAVE_LIBKSTAT) | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
372 /* Use libkstat because we don't have to be root. */ |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
373 # define LDAV_DONE |
428 | 374 kstat_ctl_t *kc; |
375 kstat_t *ksp; | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
376 kstat_named_t *kn; |
428 | 377 |
378 kc = kstat_open (); | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
379 if (kc == 0) |
428 | 380 return -1; |
381 ksp = kstat_lookup (kc, "unix", 0, "system_misc"); | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
382 if (ksp == 0 ) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
383 return -1; |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
384 if (kstat_read (kc, ksp, 0) == -1) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
385 return -1; |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
386 |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
387 |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
388 kn = kstat_data_lookup (ksp, "avenrun_1min"); |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
389 if (kn == 0) |
428 | 390 { |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
391 /* Return -1 if no load average information is available. */ |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
392 nelem = 0; |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
393 elem = -1; |
428 | 394 } |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
395 |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
396 if (nelem >= 1) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
397 loadavg[elem++] = (double) kn->value.ul/FSCALE; |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
398 |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
399 if (nelem >= 2) |
428 | 400 { |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
401 kn = kstat_data_lookup (ksp, "avenrun_5min"); |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
402 if (kn != 0) |
428 | 403 { |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
404 loadavg[elem++] = (double) kn->value.ul/FSCALE; |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
405 |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
406 if (nelem >= 3) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
407 { |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
408 kn = kstat_data_lookup (ksp, "avenrun_15min"); |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
409 if (kn != 0) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
410 loadavg[elem++] = (double) kn->value.ul/FSCALE; |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
411 } |
428 | 412 } |
413 } | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
414 |
428 | 415 kstat_close (kc); |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
416 # endif /* HAVE_LIBKSTAT */ |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
417 # if !defined (LDAV_DONE) && defined (HAVE_SYS_PSTAT_H) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
418 /* GNU says: .... && defined (hpux) && defined (HAVE_PSTAT_GETDYNAMIC) */ |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
419 # define LDAV_DONE |
428 | 420 /* This is totally undocumented, and is not guaranteed to work, but |
421 mayhap it might .... If it does work, it will work only on HP-UX | |
422 8.0 or later. -- Darryl Okahata <darrylo@sr.hp.com> */ | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
423 # undef LOAD_AVE_TYPE |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
424 # undef LOAD_AVE_CVT |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
425 # undef LDAV_SYMBOL |
428 | 426 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
427 struct pst_dynamic dyn_info; |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
428 #if 0 /* GNU 23.1.92 */ |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
429 /* Use pstat_getdynamic() because we don't have to be root. */ |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
430 if (pstat_getdynamic (&dyn_info, sizeof (dyn_info), 0, 0) < 0) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
431 return -1; |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
432 #else |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
433 union pstun statbuf; |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
434 statbuf.pst_dynamic = &dyn_info; |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
435 if (pstat (PSTAT_DYNAMIC, statbuf, sizeof (dyn_info), 0, 0) == -1) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
436 return -1; |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
437 #endif |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
438 if (nelem > 0) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
439 loadavg[elem++] = dyn_info.psd_avg_1_min; |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
440 if (nelem > 1) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
441 loadavg[elem++] = dyn_info.psd_avg_5_min; |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
442 if (nelem > 2) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
443 loadavg[elem++] = dyn_info.psd_avg_15_min; |
428 | 444 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
445 # endif /* HAVE_SYS_PSTAT_H (GNU: hpux && HAVE_PSTAT_GETDYNAMIC) */ |
428 | 446 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
447 # if !defined (LDAV_DONE) && defined (__linux__) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
448 # define LDAV_DONE |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
449 # undef LOAD_AVE_TYPE |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
450 |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
451 # ifndef LINUX_LDAV_FILE |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
452 # define LINUX_LDAV_FILE "/proc/loadavg" |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
453 # endif |
428 | 454 |
455 char ldavgbuf[40]; | |
456 double load_ave[3]; | |
457 int fd, count; | |
458 | |
771 | 459 fd = retry_open (LINUX_LDAV_FILE, O_RDONLY); |
428 | 460 if (fd == -1) |
461 return -1; | |
771 | 462 count = retry_read (fd, ldavgbuf, 40); |
463 (void) retry_close (fd); | |
428 | 464 if (count <= 0) |
465 return -1; | |
466 | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
467 /* The following sscanf must use the C locale. */ |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
468 setlocale (LC_NUMERIC, "C"); |
428 | 469 count = sscanf (ldavgbuf, "%lf %lf %lf", |
470 &load_ave[0], &load_ave[1], &load_ave[2]); | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
471 setlocale (LC_NUMERIC, ""); |
428 | 472 if (count < 1) |
473 return -1; | |
474 | |
475 for (elem = 0; elem < nelem && elem < count; elem++) | |
476 loadavg[elem] = load_ave[elem]; | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
477 |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
478 return elem; |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
479 |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
480 # endif /* __linux__ */ |
428 | 481 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
482 # if !defined (LDAV_DONE) && (defined (__NetBSD__) || defined (__OpenBSD__)) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
483 # define LDAV_DONE |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
484 # undef LOAD_AVE_TYPE |
428 | 485 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
486 # ifndef NETBSD_LDAV_FILE |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
487 # define NETBSD_LDAV_FILE "/kern/loadavg" |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
488 # endif |
428 | 489 |
490 unsigned long int load_ave[3], scale; | |
491 int count; | |
492 FILE *fp; | |
493 | |
771 | 494 fp = retry_fopen (NETBSD_LDAV_FILE, "r"); |
428 | 495 if (fp == NULL) |
496 return -1; | |
497 count = fscanf (fp, "%lu %lu %lu %lu\n", | |
498 &load_ave[0], &load_ave[1], &load_ave[2], | |
499 &scale); | |
771 | 500 (void) retry_fclose (fp); |
428 | 501 if (count != 4) |
502 return -1; | |
503 | |
504 for (elem = 0; elem < nelem; elem++) | |
505 loadavg[elem] = (double) load_ave[elem] / (double) scale; | |
506 #endif /* __NetBSD__ or __OpenBSD__ */ | |
507 | |
1315 | 508 #if !defined (LDAV_DONE) && defined (WIN32_ANY) |
428 | 509 #define LDAV_DONE |
510 | |
511 /* A faithful emulation is going to have to be saved for a rainy day. */ | |
512 for ( ; elem < nelem; elem++) | |
513 { | |
514 loadavg[elem] = 0.0; | |
515 } | |
442 | 516 #endif /* WIN32_NATIVE or CYGWIN */ |
428 | 517 |
518 #if !defined (LDAV_DONE) && defined(LOAD_AVE_TYPE) | |
519 | |
520 /* UNIX-specific code -- read the average from /dev/kmem. */ | |
521 | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
522 # define LDAV_PRIVILEGED /* This code requires special installation. */ |
428 | 523 |
524 LOAD_AVE_TYPE load_ave[3]; | |
525 | |
526 /* Get the address of LDAV_SYMBOL. */ | |
527 if (offset == 0) | |
528 { | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
529 # ifndef sgi |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
530 # ifndef NLIST_STRUCT |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
531 strcpy (name_list[0].n_name, LDAV_SYMBOL); |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
532 strcpy (name_list[1].n_name, ""); |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
533 # else /* NLIST_STRUCT */ |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
534 /* #### XEmacs deletes HAVE_STRUCT_NLIST_N_UN_N_NAME code. Why? */ |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
535 name_list[0].n_name = (char *) LDAV_SYMBOL; |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
536 name_list[1].n_name = 0; |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
537 # endif /* NLIST_STRUCT */ |
428 | 538 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
539 # ifndef SUNOS_5 |
428 | 540 if ( |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
541 # if !(defined (_AIX) && !defined (ps2)) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
542 nlist (KERNEL_FILE, name_list) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
543 # else /* _AIX */ |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
544 knlist (name_list, 1, sizeof (name_list[0])) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
545 # endif |
428 | 546 >= 0) |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
547 /* Omit "&& name_list[0].n_type != 0 " -- it breaks on Sun386i. */ |
428 | 548 { |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
549 # ifdef FIXUP_KERNEL_SYMBOL_ADDR |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
550 FIXUP_KERNEL_SYMBOL_ADDR (name_list); |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
551 # endif |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
552 offset = name_list[0].n_value; |
428 | 553 } |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
554 # endif /* !SUNOS_5 */ |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
555 # else /* sgi */ |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
556 int ldav_off; |
428 | 557 |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
558 ldav_off = sysmp (MP_KERNADDR, MPKA_AVENRUN); |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
559 if (ldav_off != -1) |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
560 offset = (long) ldav_off & 0x7fffffff; |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
561 # endif /* sgi */ |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
562 } |
428 | 563 |
564 /* Make sure we have /dev/kmem open. */ | |
565 if (!getloadavg_initialized) | |
566 { | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
567 # ifndef SUNOS_5 |
771 | 568 channel = retry_open ("/dev/kmem", 0); |
428 | 569 if (channel >= 0) |
570 { | |
571 /* Set the channel to close on exec, so it does not | |
572 litter any child's descriptor table. */ | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
573 # ifdef F_SETFD |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
574 # ifndef FD_CLOEXEC |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
575 # define FD_CLOEXEC 1 |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
576 # endif |
428 | 577 (void) fcntl (channel, F_SETFD, FD_CLOEXEC); |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
578 # endif |
428 | 579 getloadavg_initialized = 1; |
580 } | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
581 # else /* SUNOS_5 */ |
428 | 582 /* We pass 0 for the kernel, corefile, and swapfile names |
583 to use the currently running kernel. */ | |
584 kd = kvm_open (0, 0, 0, O_RDONLY, 0); | |
585 if (kd != 0) | |
586 { | |
587 /* nlist the currently running kernel. */ | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
588 kvm_nlist (kd, name_list); |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
589 offset = name_list[0].n_value; |
428 | 590 getloadavg_initialized = 1; |
591 } | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
592 # endif /* SUNOS_5 */ |
428 | 593 } |
594 | |
595 /* If we can, get the load average values. */ | |
596 if (offset && getloadavg_initialized) | |
597 { | |
598 /* Try to read the load. */ | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
599 # ifndef SUNOS_5 |
428 | 600 if (lseek (channel, offset, 0) == -1L |
771 | 601 || retry_read (channel, (char *) load_ave, sizeof (load_ave)) |
428 | 602 != sizeof (load_ave)) |
603 { | |
771 | 604 retry_close (channel); |
428 | 605 getloadavg_initialized = 0; |
606 } | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
607 # else /* SUNOS_5 */ |
428 | 608 if (kvm_read (kd, offset, (char *) load_ave, sizeof (load_ave)) |
609 != sizeof (load_ave)) | |
610 { | |
611 kvm_close (kd); | |
612 getloadavg_initialized = 0; | |
613 } | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
614 # endif /* SUNOS_5 */ |
428 | 615 } |
616 | |
617 if (offset == 0 || !getloadavg_initialized) | |
618 return -1; | |
619 | |
620 if (nelem > 0) | |
621 loadavg[elem++] = LDAV_CVT (load_ave[0]); | |
622 if (nelem > 1) | |
623 loadavg[elem++] = LDAV_CVT (load_ave[1]); | |
624 if (nelem > 2) | |
625 loadavg[elem++] = LDAV_CVT (load_ave[2]); | |
626 | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
627 # define LDAV_DONE |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
628 # endif /* !LDAV_DONE && LOAD_AVE_TYPE */ |
428 | 629 |
630 return elem; | |
631 } | |
632 | |
633 #endif /* ! HAVE_GETLOADAVG */ | |
634 | |
635 #ifdef TEST | |
636 void | |
637 main (int argc, char **argv) | |
638 { | |
639 int naptime = 0; | |
640 | |
641 if (argc > 1) | |
642 naptime = atoi (argv[1]); | |
643 | |
644 while (1) | |
645 { | |
646 double avg[3]; | |
647 int loads; | |
648 | |
649 errno = 0; /* Don't be misled if it doesn't set errno. */ | |
650 loads = getloadavg (avg, 3); | |
651 if (loads == -1) | |
652 { | |
653 perror ("Error getting load average"); | |
654 exit (1); | |
655 } | |
656 if (loads > 0) | |
657 printf ("1-minute: %f ", avg[0]); | |
658 if (loads > 1) | |
659 printf ("5-minute: %f ", avg[1]); | |
660 if (loads > 2) | |
661 printf ("15-minute: %f ", avg[2]); | |
662 if (loads > 0) | |
663 putchar ('\n'); | |
664 | |
665 if (naptime == 0) | |
666 break; | |
667 sleep (naptime); | |
668 } | |
669 | |
670 exit (0); | |
671 } | |
672 #endif /* TEST */ | |
5494
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
673 |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
674 /* arch-tag: 2b37a242-6289-41f4-8cd5-0e73fd615db1 |
861f2601a38b
Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
675 (do not change this comment) */ |