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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 /* Compile-time symbols that this file uses:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 FIXUP_KERNEL_SYMBOL_ADDR() Adjust address in returned struct nlist.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 KERNEL_FILE Pathname of the kernel to nlist.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 LDAV_CVT() Scale the load average from the kernel.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 Returns a double.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 LDAV_SYMBOL Name of kernel symbol giving load average.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 NLIST_STRUCT Include nlist.h, not a.out.h, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 the nlist n_name element is a pointer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 not an array.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 Specific system predefines this file uses, aside from setting
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 default values if not emacs:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 BSD Real BSD, not just BSD-like.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 hpux
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 sgi
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
63 WIN32_NATIVE No-op for Windows9x/NT.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
64 CYGWIN No-op for Cygwin.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 __linux__ Linux: assumes /proc filesystem mounted.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 Support from Michael K. Johnson.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 __NetBSD__ NetBSD: assumes /kern filesystem mounted.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 __OpenBSD__ OpenBSD: ditto.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 In addition, to avoid nesting many #ifdefs, we internally set
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 LDAV_DONE to indicate that the load average has been computed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 We also #define LDAV_PRIVILEGED if a program will require
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 special installation to be able to call getloadavg. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 /* This should always be first. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 #include "sysfile.h" /* for encapsulated open, close, read, write */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 #ifndef HAVE_GETLOADAVG
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 /* The existing Emacs configuration files define a macro called
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 LOAD_AVE_CVT, which accepts a value of type LOAD_AVE_TYPE, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 returns the load average multiplied by 100. What we actually want
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 is a macro called LDAV_CVT, which returns the load average as an
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 unmultiplied double.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 For backwards compatibility, we'll define LDAV_CVT in terms of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 LOAD_AVE_CVT, but future machine config files should just define
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 LDAV_CVT directly. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 #if defined (HAVE_KSTAT_H)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 #include <kstat.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 #endif /* HAVE_KSTAT_H */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 /* Set values that are different from the defaults, which are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 set a little farther down with #ifndef. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 /* Some shorthands. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 /* <sys/param.h> defines an incorrect value for FSCALE on Alpha OSF/1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 /* SunOS and some others define FSCALE in sys/param.h. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 /* Sometimes both MIPS and sgi are defined, so FSCALE was just defined
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 /* LOAD_AVE_TYPE should only get defined if we're going to use the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 /* Avoid static vars inside a function since in HPUX they dump as pure. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 static int getloadavg_initialized;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 /* Offset in kmem to seek to read load average, or 0 means invalid. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 static long offset;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 #ifndef countof
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 # define countof(x) (sizeof (x) / sizeof (*(x)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 /* Put the 1 minute, 5 minute and 15 minute load averages
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 into the first NELEM elements of LOADAVG.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 Return the number written (never more than 3, but may be less than NELEM),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 or -1 if an error occurred. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
356 int getloadavg (double loadavg[], int nelem);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
357
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 getloadavg (double loadavg[], int nelem)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 int elem = 0; /* Return value. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 /* Set errno to zero to indicate that there was no particular error;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 this function just can't work at all on this system. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 errno = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 kstat_ctl_t *kc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 /* This is totally undocumented, and is not guaranteed to work, but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 mayhap it might .... If it does work, it will work only on HP-UX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 char ldavgbuf[40];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 double load_ave[3];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 int fd, count;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
459 fd = retry_open (LINUX_LDAV_FILE, O_RDONLY);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 if (fd == -1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 return -1;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
462 count = retry_read (fd, ldavgbuf, 40);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
463 (void) retry_close (fd);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 if (count <= 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 count = sscanf (ldavgbuf, "%lf %lf %lf",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 if (count < 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 for (elem = 0; elem < nelem && elem < count; elem++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 unsigned long int load_ave[3], scale;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 int count;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 FILE *fp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
494 fp = retry_fopen (NETBSD_LDAV_FILE, "r");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 if (fp == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 count = fscanf (fp, "%lu %lu %lu %lu\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 &load_ave[0], &load_ave[1], &load_ave[2],
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 &scale);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
500 (void) retry_fclose (fp);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 if (count != 4)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 for (elem = 0; elem < nelem; elem++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 loadavg[elem] = (double) load_ave[elem] / (double) scale;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 #endif /* __NetBSD__ or __OpenBSD__ */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507
1315
70921960b980 [xemacs-hg @ 2003-02-20 08:19:28 by ben]
ben
parents: 978
diff changeset
508 #if !defined (LDAV_DONE) && defined (WIN32_ANY)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 #define LDAV_DONE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 /* A faithful emulation is going to have to be saved for a rainy day. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 for ( ; elem < nelem; elem++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 loadavg[elem] = 0.0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
516 #endif /* WIN32_NATIVE or CYGWIN */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 #if !defined (LDAV_DONE) && defined(LOAD_AVE_TYPE)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 /* UNIX-specific code -- read the average from /dev/kmem. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 LOAD_AVE_TYPE load_ave[3];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 /* Get the address of LDAV_SYMBOL. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 if (offset == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 /* Make sure we have /dev/kmem open. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 if (!getloadavg_initialized)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
568 channel = retry_open ("/dev/kmem", 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 if (channel >= 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 /* Set the channel to close on exec, so it does not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 getloadavg_initialized = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 /* We pass 0 for the kernel, corefile, and swapfile names
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 to use the currently running kernel. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 kd = kvm_open (0, 0, 0, O_RDONLY, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 if (kd != 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 getloadavg_initialized = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 /* If we can, get the load average values. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 if (offset && getloadavg_initialized)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 if (lseek (channel, offset, 0) == -1L
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
601 || retry_read (channel, (char *) load_ave, sizeof (load_ave))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 != sizeof (load_ave))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
604 retry_close (channel);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 getloadavg_initialized = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 if (kvm_read (kd, offset, (char *) load_ave, sizeof (load_ave))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 != sizeof (load_ave))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 kvm_close (kd);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 getloadavg_initialized = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 if (offset == 0 || !getloadavg_initialized)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 if (nelem > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 loadavg[elem++] = LDAV_CVT (load_ave[0]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 if (nelem > 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 loadavg[elem++] = LDAV_CVT (load_ave[1]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 if (nelem > 2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 loadavg[elem++] = LDAV_CVT (load_ave[2]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 return elem;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 #endif /* ! HAVE_GETLOADAVG */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 #ifdef TEST
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 main (int argc, char **argv)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 int naptime = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 if (argc > 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 naptime = atoi (argv[1]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 double avg[3];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 int loads;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 errno = 0; /* Don't be misled if it doesn't set errno. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 loads = getloadavg (avg, 3);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 if (loads == -1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 perror ("Error getting load average");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 exit (1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 if (loads > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 printf ("1-minute: %f ", avg[0]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 if (loads > 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 printf ("5-minute: %f ", avg[1]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 if (loads > 2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 printf ("15-minute: %f ", avg[2]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 if (loads > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 putchar ('\n');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 if (naptime == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 sleep (naptime);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 exit (0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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) */