Mercurial > hg > xemacs-beta
comparison src/getloadavg.c @ 4759:aa5ed11f473b
Remove support for obsolete systems. See xemacs-patches message with ID
<870180fe0911101613m6b8efa4bpf083fd9013950807@mail.gmail.com>.
author | Jerry James <james@xemacs.org> |
---|---|
date | Wed, 18 Nov 2009 08:49:14 -0700 |
parents | 70921960b980 |
children | 308d34e9f07d 861f2601a38b |
comparison
equal
deleted
inserted
replaced
4758:75975fd0b7fc | 4759:aa5ed11f473b |
---|---|
25 KERNEL_FILE Pathname of the kernel to nlist. | 25 KERNEL_FILE Pathname of the kernel to nlist. |
26 LDAV_CVT() Scale the load average from the kernel. | 26 LDAV_CVT() Scale the load average from the kernel. |
27 Returns a double. | 27 Returns a double. |
28 LDAV_SYMBOL Name of kernel symbol giving load average. | 28 LDAV_SYMBOL Name of kernel symbol giving load average. |
29 LOAD_AVE_TYPE Type of the load average array in the kernel. | 29 LOAD_AVE_TYPE Type of the load average array in the kernel. |
30 Must be defined unless one of | 30 Must be defined; otherwise, no load average |
31 apollo, DGUX, NeXT, or UMAX is defined; | 31 is available. |
32 otherwise, no load average is available. | |
33 NLIST_STRUCT Include nlist.h, not a.out.h, and | 32 NLIST_STRUCT Include nlist.h, not a.out.h, and |
34 the nlist n_name element is a pointer, | 33 the nlist n_name element is a pointer, |
35 not an array. | 34 not an array. |
36 NLIST_NAME_UNION struct nlist has an n_un member, not n_name. | |
37 LINUX_LDAV_FILE [__linux__]: File containing load averages. | 35 LINUX_LDAV_FILE [__linux__]: File containing load averages. |
38 | 36 |
39 Specific system predefines this file uses, aside from setting | 37 Specific system predefines this file uses, aside from setting |
40 default values if not emacs: | 38 default values if not emacs: |
41 | 39 |
42 apollo | |
43 BSD Real BSD, not just BSD-like. | 40 BSD Real BSD, not just BSD-like. |
44 convex | |
45 DGUX | |
46 hpux | 41 hpux |
47 NeXT | |
48 sgi | 42 sgi |
49 sequent Sequent Dynix 3.x.x (BSD) | |
50 _SEQUENT_ Sequent DYNIX/ptx 1.x.x (SYSV) | |
51 sony_news NEWS-OS (works at least for 4.1C) | |
52 UMAX | |
53 UMAX4_3 | |
54 WIN32_NATIVE No-op for Windows9x/NT. | 43 WIN32_NATIVE No-op for Windows9x/NT. |
55 CYGWIN No-op for Cygwin. | 44 CYGWIN No-op for Cygwin. |
56 __linux__ Linux: assumes /proc filesystem mounted. | 45 __linux__ Linux: assumes /proc filesystem mounted. |
57 Support from Michael K. Johnson. | 46 Support from Michael K. Johnson. |
58 __NetBSD__ NetBSD: assumes /kern filesystem mounted. | 47 __NetBSD__ NetBSD: assumes /kern filesystem mounted. |
90 | 79 |
91 #if defined (HAVE_KSTAT_H) | 80 #if defined (HAVE_KSTAT_H) |
92 #include <kstat.h> | 81 #include <kstat.h> |
93 #endif /* HAVE_KSTAT_H */ | 82 #endif /* HAVE_KSTAT_H */ |
94 | 83 |
95 #if !defined (BSD) && defined (ultrix) | |
96 /* Ultrix behaves like BSD on Vaxen. */ | |
97 #define BSD | |
98 #endif | |
99 | |
100 #ifdef NeXT | |
101 /* NeXT in the 2.{0,1,2} releases defines BSD in <sys/param.h>, which | |
102 conflicts with the definition understood in this file, that this | |
103 really is BSD. */ | |
104 #undef BSD | |
105 | |
106 /* NeXT defines FSCALE in <sys/param.h>. However, we take FSCALE being | |
107 defined to mean that the nlist method should be used, which is not true. */ | |
108 #undef FSCALE | |
109 #endif | |
110 | |
111 /* Set values that are different from the defaults, which are | 84 /* Set values that are different from the defaults, which are |
112 set a little farther down with #ifndef. */ | 85 set a little farther down with #ifndef. */ |
113 | 86 |
114 | 87 |
115 /* Some shorthands. */ | 88 /* Some shorthands. */ |
116 | 89 |
117 #if defined (HPUX) && !defined (hpux) | 90 #if defined (HPUX) && !defined (hpux) |
118 #define hpux | 91 #define hpux |
119 #endif | |
120 | |
121 #if defined(hp300) && !defined(hpux) | |
122 #define MORE_BSD | |
123 #endif | |
124 | |
125 #if defined(ultrix) && defined(mips) | |
126 #define decstation | |
127 #endif | 92 #endif |
128 | 93 |
129 #if (defined(sun) && defined(SVR4)) || defined (SOLARIS2) | 94 #if (defined(sun) && defined(SVR4)) || defined (SOLARIS2) |
130 #define SUNOS_5 | 95 #define SUNOS_5 |
131 #endif | 96 #endif |
141 #if defined (__osf__) && (defined (mips) || defined (__mips__)) | 106 #if defined (__osf__) && (defined (mips) || defined (__mips__)) |
142 #define OSF_MIPS | 107 #define OSF_MIPS |
143 #include <sys/table.h> | 108 #include <sys/table.h> |
144 #endif | 109 #endif |
145 | 110 |
146 /* UTek's /bin/cc on the 4300 has no architecture specific cpp define by | |
147 default, but _MACH_IND_SYS_TYPES is defined in <sys/types.h>. Combine | |
148 that with a couple of other things and we'll have a unique match. */ | |
149 #if !defined (tek4300) && defined (unix) && defined (m68k) && defined (mc68000) && defined (mc68020) && defined (_MACH_IND_SYS_TYPES) | |
150 #define tek4300 /* Define by emacs, but not by other users. */ | |
151 #endif | |
152 | |
153 | 111 |
154 /* VAX C can't handle multi-line #ifs, or lines longer than 256 chars. */ | 112 /* VAX C can't handle multi-line #ifs, or lines longer than 256 chars. */ |
155 #ifndef LOAD_AVE_TYPE | 113 #ifndef LOAD_AVE_TYPE |
156 | 114 |
157 #ifdef MORE_BSD | |
158 #define LOAD_AVE_TYPE long | |
159 #endif | |
160 | |
161 #ifdef sun | 115 #ifdef sun |
162 #define LOAD_AVE_TYPE long | 116 #define LOAD_AVE_TYPE long |
163 #endif | 117 #endif |
164 | 118 |
165 #ifdef decstation | 119 #ifdef decstation |
166 #define LOAD_AVE_TYPE long | 120 #define LOAD_AVE_TYPE long |
167 #endif | 121 #endif |
168 | 122 |
169 #ifdef _SEQUENT_ | |
170 #define LOAD_AVE_TYPE long | |
171 #endif | |
172 | |
173 #ifdef sgi | 123 #ifdef sgi |
174 #define LOAD_AVE_TYPE long | 124 #define LOAD_AVE_TYPE long |
175 #endif | 125 #endif |
176 | 126 |
177 #ifdef SVR4 | 127 #ifdef SVR4 |
180 | 130 |
181 #ifdef sony_news | 131 #ifdef sony_news |
182 #define LOAD_AVE_TYPE long | 132 #define LOAD_AVE_TYPE long |
183 #endif | 133 #endif |
184 | 134 |
185 #ifdef sequent | |
186 #define LOAD_AVE_TYPE long | |
187 #endif | |
188 | |
189 #ifdef OSF_ALPHA | 135 #ifdef OSF_ALPHA |
190 #define LOAD_AVE_TYPE long | 136 #define LOAD_AVE_TYPE long |
191 #endif | 137 #endif |
192 | 138 |
193 #if defined (ardent) && defined (titan) | 139 #if defined (ardent) && defined (titan) |
194 #define LOAD_AVE_TYPE long | 140 #define LOAD_AVE_TYPE long |
195 #endif | 141 #endif |
196 | 142 |
197 #ifdef tek4300 | |
198 #define LOAD_AVE_TYPE long | |
199 #endif | |
200 | |
201 #if defined(alliant) && defined(i860) /* Alliant FX/2800 */ | |
202 #define LOAD_AVE_TYPE long | |
203 #endif | |
204 | |
205 #ifdef _AIX | 143 #ifdef _AIX |
206 #define LOAD_AVE_TYPE long | 144 #define LOAD_AVE_TYPE long |
207 #endif | |
208 | |
209 #ifdef convex | |
210 #define LOAD_AVE_TYPE double | |
211 #ifndef LDAV_CVT | |
212 #define LDAV_CVT(n) (n) | |
213 #endif | |
214 #endif | 145 #endif |
215 | 146 |
216 #endif /* No LOAD_AVE_TYPE. */ | 147 #endif /* No LOAD_AVE_TYPE. */ |
217 | 148 |
218 #ifdef OSF_ALPHA | 149 #ifdef OSF_ALPHA |
220 according to ghazi@noc.rutgers.edu. */ | 151 according to ghazi@noc.rutgers.edu. */ |
221 #undef FSCALE | 152 #undef FSCALE |
222 #define FSCALE 1024.0 | 153 #define FSCALE 1024.0 |
223 #endif | 154 #endif |
224 | 155 |
225 #if defined(alliant) && defined(i860) /* Alliant FX/2800 */ | |
226 /* <sys/param.h> defines an incorrect value for FSCALE on an | |
227 Alliant FX/2800 Concentrix 2.2, according to ghazi@noc.rutgers.edu. */ | |
228 #undef FSCALE | |
229 #define FSCALE 100.0 | |
230 #endif | |
231 | |
232 | |
233 #ifndef FSCALE | 156 #ifndef FSCALE |
234 | 157 |
235 /* SunOS and some others define FSCALE in sys/param.h. */ | 158 /* SunOS and some others define FSCALE in sys/param.h. */ |
236 | |
237 #ifdef MORE_BSD | |
238 #define FSCALE 2048.0 | |
239 #endif | |
240 | 159 |
241 #if defined(MIPS) || defined(SVR4) || defined(decstation) | 160 #if defined(MIPS) || defined(SVR4) || defined(decstation) |
242 #define FSCALE 256 | 161 #define FSCALE 256 |
243 #endif | 162 #endif |
244 | 163 |
245 #if defined (sgi) || defined (sequent) | 164 #if defined (sgi) |
246 /* Sometimes both MIPS and sgi are defined, so FSCALE was just defined | 165 /* Sometimes both MIPS and sgi are defined, so FSCALE was just defined |
247 above under #ifdef MIPS. But we want the sgi value. */ | 166 above under #ifdef MIPS. But we want the sgi value. */ |
248 #undef FSCALE | 167 #undef FSCALE |
249 #define FSCALE 1000.0 | 168 #define FSCALE 1000.0 |
250 #endif | 169 #endif |
251 | 170 |
252 #if defined (ardent) && defined (titan) | 171 #if defined (ardent) && defined (titan) |
253 #define FSCALE 65536.0 | 172 #define FSCALE 65536.0 |
254 #endif | 173 #endif |
255 | 174 |
256 #ifdef tek4300 | |
257 #define FSCALE 100.0 | |
258 #endif | |
259 | |
260 #ifdef _AIX | 175 #ifdef _AIX |
261 #define FSCALE 65536.0 | 176 #define FSCALE 65536.0 |
262 #endif | 177 #endif |
263 | 178 |
264 #endif /* Not FSCALE. */ | 179 #endif /* Not FSCALE. */ |
268 #endif | 183 #endif |
269 | 184 |
270 /* VAX C can't handle multi-line #ifs, or lines longer that 256 characters. */ | 185 /* VAX C can't handle multi-line #ifs, or lines longer that 256 characters. */ |
271 #ifndef NLIST_STRUCT | 186 #ifndef NLIST_STRUCT |
272 | 187 |
273 #ifdef MORE_BSD | |
274 #define NLIST_STRUCT | |
275 #endif | |
276 | |
277 #ifdef sun | 188 #ifdef sun |
278 #define NLIST_STRUCT | 189 #define NLIST_STRUCT |
279 #endif | 190 #endif |
280 | 191 |
281 #ifdef decstation | 192 #ifdef decstation |
284 | 195 |
285 #ifdef hpux | 196 #ifdef hpux |
286 #define NLIST_STRUCT | 197 #define NLIST_STRUCT |
287 #endif | 198 #endif |
288 | 199 |
289 #if defined (_SEQUENT_) || defined (sequent) | |
290 #define NLIST_STRUCT | |
291 #endif | |
292 | |
293 #ifdef sgi | 200 #ifdef sgi |
294 #define NLIST_STRUCT | 201 #define NLIST_STRUCT |
295 #endif | 202 #endif |
296 | 203 |
297 #ifdef SVR4 | 204 #ifdef SVR4 |
308 | 215 |
309 #if defined (ardent) && defined (titan) | 216 #if defined (ardent) && defined (titan) |
310 #define NLIST_STRUCT | 217 #define NLIST_STRUCT |
311 #endif | 218 #endif |
312 | 219 |
313 #ifdef tek4300 | |
314 #define NLIST_STRUCT | |
315 #endif | |
316 | |
317 #ifdef butterfly | 220 #ifdef butterfly |
318 #define NLIST_STRUCT | |
319 #endif | |
320 | |
321 #if defined(alliant) && defined(i860) /* Alliant FX/2800 */ | |
322 #define NLIST_STRUCT | 221 #define NLIST_STRUCT |
323 #endif | 222 #endif |
324 | 223 |
325 #ifdef _AIX | 224 #ifdef _AIX |
326 #define NLIST_STRUCT | 225 #define NLIST_STRUCT |
331 | 230 |
332 #if defined(sgi) || (defined(mips) && !defined(BSD)) | 231 #if defined(sgi) || (defined(mips) && !defined(BSD)) |
333 #define FIXUP_KERNEL_SYMBOL_ADDR(nl) ((nl)[0].n_value &= ~(1 << 31)) | 232 #define FIXUP_KERNEL_SYMBOL_ADDR(nl) ((nl)[0].n_value &= ~(1 << 31)) |
334 #endif | 233 #endif |
335 | 234 |
336 | |
337 #if !defined (KERNEL_FILE) && defined (sequent) | |
338 #define KERNEL_FILE "/dynix" | |
339 #endif | |
340 | |
341 #if !defined (KERNEL_FILE) && defined (hpux) | 235 #if !defined (KERNEL_FILE) && defined (hpux) |
342 #define KERNEL_FILE "/hp-ux" | 236 #define KERNEL_FILE "/hp-ux" |
343 #endif | 237 #endif |
344 | 238 |
345 #if !defined(KERNEL_FILE) && (defined(_SEQUENT_) || defined(MIPS) || defined(SVR4) || defined(ISC) || defined (sgi) || defined(SVR4) || (defined (ardent) && defined (titan))) | 239 #if !defined(KERNEL_FILE) && (defined(MIPS) || defined(SVR4) || defined(ISC) || defined (sgi) || defined(SVR4) || (defined (ardent) && defined (titan))) |
346 #define KERNEL_FILE "/unix" | 240 #define KERNEL_FILE "/unix" |
347 #endif | 241 #endif |
348 | 242 |
349 | 243 #if !defined(LDAV_SYMBOL) && (defined(hpux) || defined(SVR4) || defined(ISC) || defined(sgi) || (defined (ardent) && defined (titan)) || defined (_AIX)) |
350 #if !defined (LDAV_SYMBOL) && defined (alliant) | |
351 #define LDAV_SYMBOL "_Loadavg" | |
352 #endif | |
353 | |
354 #if !defined(LDAV_SYMBOL) && ((defined(hpux) && !defined(hp9000s300)) || defined(_SEQUENT_) || defined(SVR4) || defined(ISC) || defined(sgi) || (defined (ardent) && defined (titan)) || defined (_AIX)) | |
355 #define LDAV_SYMBOL "avenrun" | 244 #define LDAV_SYMBOL "avenrun" |
356 #endif | 245 #endif |
357 | 246 |
358 #ifdef HAVE_UNISTD_H | 247 #ifdef HAVE_UNISTD_H |
359 #include <unistd.h> | 248 #include <unistd.h> |
392 #define LDAV_CVT(n) ((double) (n)) | 281 #define LDAV_CVT(n) ((double) (n)) |
393 #endif /* !LDAV_CVT */ | 282 #endif /* !LDAV_CVT */ |
394 | 283 |
395 #endif /* LOAD_AVE_TYPE */ | 284 #endif /* LOAD_AVE_TYPE */ |
396 | 285 |
397 #ifdef NeXT | |
398 #ifdef HAVE_MACH_MACH_H | |
399 #include <mach/mach.h> | |
400 #else | |
401 #include <mach.h> | |
402 #endif | |
403 #endif /* NeXT */ | |
404 | |
405 #ifdef sgi | 286 #ifdef sgi |
406 #include <sys/sysmp.h> | 287 #include <sys/sysmp.h> |
407 #endif /* sgi */ | 288 #endif /* sgi */ |
408 | 289 |
409 #ifdef UMAX | |
410 #include <stdio.h> | |
411 #include "syssignal.h" | |
412 #include <sys/time.h> | |
413 #include <sys/wait.h> | |
414 #include <sys/syscall.h> | |
415 | |
416 #ifdef UMAX_43 | |
417 #include <machine/cpu.h> | |
418 #include <inq_stats/statistics.h> | |
419 #include <inq_stats/sysstats.h> | |
420 #include <inq_stats/cpustats.h> | |
421 #include <inq_stats/procstats.h> | |
422 #else /* Not UMAX_43. */ | |
423 #include <sys/sysdefs.h> | |
424 #include <sys/statistics.h> | |
425 #include <sys/sysstats.h> | |
426 #include <sys/cpudefs.h> | |
427 #include <sys/cpustats.h> | |
428 #include <sys/procstats.h> | |
429 #endif /* Not UMAX_43. */ | |
430 #endif /* UMAX */ | |
431 | |
432 #ifdef DGUX | |
433 #include <sys/dg_sys_info.h> | |
434 #endif | |
435 | |
436 #if defined (HAVE_SYS_PSTAT_H) | 290 #if defined (HAVE_SYS_PSTAT_H) |
437 #include <sys/pstat.h> | 291 #include <sys/pstat.h> |
438 #endif /* HAVE_SYS_PSTAT_H (on HPUX) */ | 292 #endif /* HAVE_SYS_PSTAT_H (on HPUX) */ |
439 | 293 |
440 | 294 |
441 /* Avoid static vars inside a function since in HPUX they dump as pure. */ | 295 /* Avoid static vars inside a function since in HPUX they dump as pure. */ |
442 | |
443 #ifdef NeXT | |
444 static processor_set_t default_set; | |
445 static int getloadavg_initialized; | |
446 #endif /* NeXT */ | |
447 | |
448 #ifdef UMAX | |
449 static unsigned int cpus = 0; | |
450 static unsigned int samples; | |
451 #endif /* UMAX */ | |
452 | |
453 #ifdef DGUX | |
454 static struct dg_sys_info_load_info load_info; /* what-a-mouthful! */ | |
455 #endif /* DGUX */ | |
456 | 296 |
457 #ifdef LOAD_AVE_TYPE | 297 #ifdef LOAD_AVE_TYPE |
458 /* File descriptor open to /dev/kmem */ | 298 /* File descriptor open to /dev/kmem */ |
459 static int channel; | 299 static int channel; |
460 /* Nonzero iff channel is valid. */ | 300 /* Nonzero iff channel is valid. */ |
615 | 455 |
616 for (elem = 0; elem < nelem; elem++) | 456 for (elem = 0; elem < nelem; elem++) |
617 loadavg[elem] = (double) load_ave[elem] / (double) scale; | 457 loadavg[elem] = (double) load_ave[elem] / (double) scale; |
618 #endif /* __NetBSD__ or __OpenBSD__ */ | 458 #endif /* __NetBSD__ or __OpenBSD__ */ |
619 | 459 |
620 #if !defined (LDAV_DONE) && defined (NeXT) | |
621 #define LDAV_DONE | |
622 /* The NeXT code was adapted from iscreen 3.2. */ | |
623 | |
624 host_t host; | |
625 struct processor_set_basic_info info; | |
626 unsigned info_count; | |
627 | |
628 /* We only know how to get the 1-minute average for this system, | |
629 so even if the caller asks for more than 1, we only return 1. */ | |
630 | |
631 if (!getloadavg_initialized) | |
632 { | |
633 if (processor_set_default (host_self (), &default_set) == KERN_SUCCESS) | |
634 getloadavg_initialized = 1; | |
635 } | |
636 | |
637 if (getloadavg_initialized) | |
638 { | |
639 info_count = PROCESSOR_SET_BASIC_INFO_COUNT; | |
640 if (processor_set_info (default_set, PROCESSOR_SET_BASIC_INFO, &host, | |
641 (processor_set_info_t) &info, &info_count) | |
642 != KERN_SUCCESS) | |
643 getloadavg_initialized = 0; | |
644 else | |
645 { | |
646 if (nelem > 0) | |
647 loadavg[elem++] = (double) info.load_average / LOAD_SCALE; | |
648 } | |
649 } | |
650 | |
651 if (!getloadavg_initialized) | |
652 return -1; | |
653 #endif /* NeXT */ | |
654 | |
655 #if !defined (LDAV_DONE) && defined (UMAX) | |
656 #define LDAV_DONE | |
657 /* UMAX 4.2, which runs on the Encore Multimax multiprocessor, does not | |
658 have a /dev/kmem. Information about the workings of the running kernel | |
659 can be gathered with inq_stats system calls. | |
660 We only know how to get the 1-minute average for this system. */ | |
661 | |
662 struct proc_summary proc_sum_data; | |
663 struct stat_descr proc_info; | |
664 double load; | |
665 REGISTER unsigned int i, j; | |
666 | |
667 if (cpus == 0) | |
668 { | |
669 REGISTER unsigned int c, i; | |
670 struct cpu_config conf; | |
671 struct stat_descr desc; | |
672 | |
673 desc.sd_next = 0; | |
674 desc.sd_subsys = SUBSYS_CPU; | |
675 desc.sd_type = CPUTYPE_CONFIG; | |
676 desc.sd_addr = (char *) &conf; | |
677 desc.sd_size = sizeof (conf); | |
678 | |
679 if (inq_stats (1, &desc)) | |
680 return -1; | |
681 | |
682 c = 0; | |
683 for (i = 0; i < conf.config_maxclass; ++i) | |
684 { | |
685 struct class_stats stats; | |
686 memset ((char *) &stats, 0, sizeof (stats)); | |
687 | |
688 desc.sd_type = CPUTYPE_CLASS; | |
689 desc.sd_objid = i; | |
690 desc.sd_addr = (char *) &stats; | |
691 desc.sd_size = sizeof (stats); | |
692 | |
693 if (inq_stats (1, &desc)) | |
694 return -1; | |
695 | |
696 c += stats.class_numcpus; | |
697 } | |
698 cpus = c; | |
699 samples = cpus < 2 ? 3 : (2 * cpus / 3); | |
700 } | |
701 | |
702 proc_info.sd_next = 0; | |
703 proc_info.sd_subsys = SUBSYS_PROC; | |
704 proc_info.sd_type = PROCTYPE_SUMMARY; | |
705 proc_info.sd_addr = (char *) &proc_sum_data; | |
706 proc_info.sd_size = sizeof (struct proc_summary); | |
707 proc_info.sd_sizeused = 0; | |
708 | |
709 if (inq_stats (1, &proc_info) != 0) | |
710 return -1; | |
711 | |
712 load = proc_sum_data.ps_nrunnable; | |
713 j = 0; | |
714 for (i = samples - 1; i > 0; --i) | |
715 { | |
716 load += proc_sum_data.ps_nrun[j]; | |
717 if (j++ == PS_NRUNSIZE) | |
718 j = 0; | |
719 } | |
720 | |
721 if (nelem > 0) | |
722 loadavg[elem++] = load / samples / cpus; | |
723 #endif /* UMAX */ | |
724 | |
725 #if !defined (LDAV_DONE) && defined (DGUX) | |
726 #define LDAV_DONE | |
727 /* This call can return -1 for an error, but with good args | |
728 it's not supposed to fail. The first argument is for no | |
729 apparent reason of type `long int *'. */ | |
730 dg_sys_info ((long int *) &load_info, | |
731 DG_SYS_INFO_LOAD_INFO_TYPE, | |
732 DG_SYS_INFO_LOAD_VERSION_0); | |
733 | |
734 if (nelem > 0) | |
735 loadavg[elem++] = load_info.one_minute; | |
736 if (nelem > 1) | |
737 loadavg[elem++] = load_info.five_minute; | |
738 if (nelem > 2) | |
739 loadavg[elem++] = load_info.fifteen_minute; | |
740 #endif /* DGUX */ | |
741 | |
742 #if !defined (LDAV_DONE) && defined (OSF_MIPS) | |
743 #define LDAV_DONE | |
744 | |
745 struct tbl_loadavg load_ave; | |
746 table (TBL_LOADAVG, 0, &load_ave, 1, sizeof (load_ave)); | |
747 loadavg[elem++] | |
748 = (load_ave.tl_lscale == 0 | |
749 ? load_ave.tl_avenrun.d[0] | |
750 : (load_ave.tl_avenrun.l[0] / (double) load_ave.tl_lscale)); | |
751 #endif /* OSF_MIPS */ | |
752 | |
753 #if !defined (LDAV_DONE) && defined (WIN32_ANY) | 460 #if !defined (LDAV_DONE) && defined (WIN32_ANY) |
754 #define LDAV_DONE | 461 #define LDAV_DONE |
755 | 462 |
756 /* A faithful emulation is going to have to be saved for a rainy day. */ | 463 /* A faithful emulation is going to have to be saved for a rainy day. */ |
757 for ( ; elem < nelem; elem++) | 464 for ( ; elem < nelem; elem++) |
758 { | 465 { |
759 loadavg[elem] = 0.0; | 466 loadavg[elem] = 0.0; |
760 } | 467 } |
761 #endif /* WIN32_NATIVE or CYGWIN */ | 468 #endif /* WIN32_NATIVE or CYGWIN */ |
762 | |
763 #if !defined (LDAV_DONE) && defined (OSF_ALPHA) | |
764 #define LDAV_DONE | |
765 | |
766 struct tbl_loadavg load_ave; | |
767 table (TBL_LOADAVG, 0, &load_ave, 1, sizeof (load_ave)); | |
768 for (elem = 0; elem < nelem; elem++) | |
769 loadavg[elem] | |
770 = (load_ave.tl_lscale == 0 | |
771 ? load_ave.tl_avenrun.d[elem] | |
772 : (load_ave.tl_avenrun.l[elem] / (double) load_ave.tl_lscale)); | |
773 #endif /* OSF_ALPHA */ | |
774 | 469 |
775 #if !defined (LDAV_DONE) && defined(LOAD_AVE_TYPE) | 470 #if !defined (LDAV_DONE) && defined(LOAD_AVE_TYPE) |
776 | 471 |
777 /* UNIX-specific code -- read the average from /dev/kmem. */ | 472 /* UNIX-specific code -- read the average from /dev/kmem. */ |
778 | 473 |
786 #ifndef sgi | 481 #ifndef sgi |
787 #ifndef NLIST_STRUCT | 482 #ifndef NLIST_STRUCT |
788 strcpy (nl[0].n_name, LDAV_SYMBOL); | 483 strcpy (nl[0].n_name, LDAV_SYMBOL); |
789 strcpy (nl[1].n_name, ""); | 484 strcpy (nl[1].n_name, ""); |
790 #else /* NLIST_STRUCT */ | 485 #else /* NLIST_STRUCT */ |
791 #ifdef NLIST_NAME_UNION | |
792 nl[0].n_un.n_name = LDAV_SYMBOL; | |
793 nl[1].n_un.n_name = 0; | |
794 #else /* not NLIST_NAME_UNION */ | |
795 nl[0].n_name = (char *) LDAV_SYMBOL; | 486 nl[0].n_name = (char *) LDAV_SYMBOL; |
796 nl[1].n_name = 0; | 487 nl[1].n_name = 0; |
797 #endif /* not NLIST_NAME_UNION */ | |
798 #endif /* NLIST_STRUCT */ | 488 #endif /* NLIST_STRUCT */ |
799 | 489 |
800 #ifndef SUNOS_5 | 490 #ifndef SUNOS_5 |
801 if ( | 491 if ( |
802 #if !(defined (_AIX) && !defined (ps2)) | 492 #if !(defined (_AIX) && !defined (ps2)) |