Mercurial > hg > xemacs-beta
comparison src/getloadavg.c @ 442:abe6d1db359e r21-2-36
Import from CVS: tag r21-2-36
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:35:02 +0200 |
parents | 8de8e3f6228a |
children | b39c14581166 |
comparison
equal
deleted
inserted
replaced
441:72a7cfa4a488 | 442:abe6d1db359e |
---|---|
42 apollo | 42 apollo |
43 BSD Real BSD, not just BSD-like. | 43 BSD Real BSD, not just BSD-like. |
44 convex | 44 convex |
45 DGUX | 45 DGUX |
46 hpux | 46 hpux |
47 MSDOS No-op for MSDOS. | |
48 NeXT | 47 NeXT |
49 sgi | 48 sgi |
50 sequent Sequent Dynix 3.x.x (BSD) | 49 sequent Sequent Dynix 3.x.x (BSD) |
51 _SEQUENT_ Sequent DYNIX/ptx 1.x.x (SYSV) | 50 _SEQUENT_ Sequent DYNIX/ptx 1.x.x (SYSV) |
52 sony_news NEWS-OS (works at least for 4.1C) | 51 sony_news NEWS-OS (works at least for 4.1C) |
53 UMAX | 52 UMAX |
54 UMAX4_3 | 53 UMAX4_3 |
55 WIN32 No-op for Windows95/NT. | 54 WIN32_NATIVE No-op for Windows9x/NT. |
55 CYGWIN No-op for Cygwin. | |
56 __linux__ Linux: assumes /proc filesystem mounted. | 56 __linux__ Linux: assumes /proc filesystem mounted. |
57 Support from Michael K. Johnson. | 57 Support from Michael K. Johnson. |
58 __NetBSD__ NetBSD: assumes /kern filesystem mounted. | 58 __NetBSD__ NetBSD: assumes /kern filesystem mounted. |
59 __OpenBSD__ OpenBSD: ditto. | 59 __OpenBSD__ OpenBSD: ditto. |
60 | 60 |
67 /* This should always be first. */ | 67 /* This should always be first. */ |
68 #ifdef HAVE_CONFIG_H | 68 #ifdef HAVE_CONFIG_H |
69 #include <config.h> | 69 #include <config.h> |
70 #endif | 70 #endif |
71 | 71 |
72 #ifndef WINDOWSNT | |
73 #ifndef __CYGWIN32__ | |
74 | |
75 #include <sys/types.h> | |
76 | |
77 /* Both the Emacs and non-Emacs sections want this. Some | |
78 configuration files' definitions for the LOAD_AVE_CVT macro (like | |
79 sparc.h's) use macros like FSCALE, defined here. */ | |
80 #ifdef unix | |
81 #include <sys/param.h> | |
82 #endif | |
83 | |
84 #ifdef XEMACS | |
85 #include "lisp.h" | 72 #include "lisp.h" |
86 #include "sysfile.h" /* for encapsulated open, close, read, write */ | 73 #include "sysfile.h" /* for encapsulated open, close, read, write */ |
87 #endif /* XEMACS */ | |
88 | |
89 /* Exclude all the code except the test program at the end | |
90 if the system has its own `getloadavg' function. | |
91 | |
92 The declaration of `errno' is needed by the test program | |
93 as well as the function itself, so it comes first. */ | |
94 | |
95 #include <errno.h> | |
96 | 74 |
97 #ifndef HAVE_GETLOADAVG | 75 #ifndef HAVE_GETLOADAVG |
98 | 76 |
99 /* The existing Emacs configuration files define a macro called | 77 /* The existing Emacs configuration files define a macro called |
100 LOAD_AVE_CVT, which accepts a value of type LOAD_AVE_TYPE, and | 78 LOAD_AVE_CVT, which accepts a value of type LOAD_AVE_TYPE, and |
108 | 86 |
109 #if !defined(LDAV_CVT) && defined(LOAD_AVE_CVT) | 87 #if !defined(LDAV_CVT) && defined(LOAD_AVE_CVT) |
110 #define LDAV_CVT(n) (LOAD_AVE_CVT (n) / 100.0) | 88 #define LDAV_CVT(n) (LOAD_AVE_CVT (n) / 100.0) |
111 #endif | 89 #endif |
112 | 90 |
113 #ifdef XEMACS | |
114 #if defined (HAVE_KSTAT_H) | 91 #if defined (HAVE_KSTAT_H) |
115 #include <kstat.h> | 92 #include <kstat.h> |
116 #endif /* HAVE_KSTAT_H */ | 93 #endif /* HAVE_KSTAT_H */ |
117 #endif /* XEMACS */ | |
118 | 94 |
119 #if !defined (BSD) && defined (ultrix) | 95 #if !defined (BSD) && defined (ultrix) |
120 /* Ultrix behaves like BSD on Vaxen. */ | 96 /* Ultrix behaves like BSD on Vaxen. */ |
121 #define BSD | 97 #define BSD |
122 #endif | 98 #endif |
455 | 431 |
456 #ifdef DGUX | 432 #ifdef DGUX |
457 #include <sys/dg_sys_info.h> | 433 #include <sys/dg_sys_info.h> |
458 #endif | 434 #endif |
459 | 435 |
460 #ifdef XEMACS | |
461 #if defined (HAVE_SYS_PSTAT_H) | 436 #if defined (HAVE_SYS_PSTAT_H) |
462 #include <sys/pstat.h> | 437 #include <sys/pstat.h> |
463 #endif /* HAVE_SYS_PSTAT_H (on HPUX) */ | 438 #endif /* HAVE_SYS_PSTAT_H (on HPUX) */ |
464 #endif /* XEMACS */ | 439 |
465 | |
466 #if defined(HAVE_FCNTL_H) || defined(_POSIX_VERSION) | |
467 #include <fcntl.h> | |
468 #else | |
469 #include <sys/file.h> | |
470 #endif | |
471 | 440 |
472 /* Avoid static vars inside a function since in HPUX they dump as pure. */ | 441 /* Avoid static vars inside a function since in HPUX they dump as pure. */ |
473 | 442 |
474 #ifdef NeXT | 443 #ifdef NeXT |
475 static processor_set_t default_set; | 444 static processor_set_t default_set; |
509 | 478 |
510 /* Put the 1 minute, 5 minute and 15 minute load averages | 479 /* Put the 1 minute, 5 minute and 15 minute load averages |
511 into the first NELEM elements of LOADAVG. | 480 into the first NELEM elements of LOADAVG. |
512 Return the number written (never more than 3, but may be less than NELEM), | 481 Return the number written (never more than 3, but may be less than NELEM), |
513 or -1 if an error occurred. */ | 482 or -1 if an error occurred. */ |
483 | |
484 int getloadavg (double loadavg[], int nelem); | |
514 | 485 |
515 int | 486 int |
516 getloadavg (double loadavg[], int nelem) | 487 getloadavg (double loadavg[], int nelem) |
517 { | 488 { |
518 int elem = 0; /* Return value. */ | 489 int elem = 0; /* Return value. */ |
777 = (load_ave.tl_lscale == 0 | 748 = (load_ave.tl_lscale == 0 |
778 ? load_ave.tl_avenrun.d[0] | 749 ? load_ave.tl_avenrun.d[0] |
779 : (load_ave.tl_avenrun.l[0] / (double) load_ave.tl_lscale)); | 750 : (load_ave.tl_avenrun.l[0] / (double) load_ave.tl_lscale)); |
780 #endif /* OSF_MIPS */ | 751 #endif /* OSF_MIPS */ |
781 | 752 |
782 #if !defined (LDAV_DONE) && (defined (MSDOS) || defined (WIN32)) | 753 #if !defined (LDAV_DONE) && (defined (WIN32_NATIVE) || defined (CYGWIN)) |
783 #define LDAV_DONE | 754 #define LDAV_DONE |
784 | 755 |
785 /* A faithful emulation is going to have to be saved for a rainy day. */ | 756 /* A faithful emulation is going to have to be saved for a rainy day. */ |
786 for ( ; elem < nelem; elem++) | 757 for ( ; elem < nelem; elem++) |
787 { | 758 { |
788 loadavg[elem] = 0.0; | 759 loadavg[elem] = 0.0; |
789 } | 760 } |
790 #endif /* MSDOS */ | 761 #endif /* WIN32_NATIVE or CYGWIN */ |
791 | 762 |
792 #if !defined (LDAV_DONE) && defined (OSF_ALPHA) | 763 #if !defined (LDAV_DONE) && defined (OSF_ALPHA) |
793 #define LDAV_DONE | 764 #define LDAV_DONE |
794 | 765 |
795 struct tbl_loadavg load_ave; | 766 struct tbl_loadavg load_ave; |
958 } | 929 } |
959 | 930 |
960 exit (0); | 931 exit (0); |
961 } | 932 } |
962 #endif /* TEST */ | 933 #endif /* TEST */ |
963 | |
964 #else | |
965 | |
966 /* Emulate getloadavg. */ | |
967 int | |
968 getloadavg (double loadavg[], int nelem) | |
969 { | |
970 int i; | |
971 | |
972 /* A faithful emulation is going to have to be saved for a rainy day. */ | |
973 for (i = 0; i < nelem; i++) | |
974 { | |
975 loadavg[i] = 0.0; | |
976 } | |
977 return i; | |
978 } | |
979 | |
980 #endif /*__GNUWIN32__*/ | |
981 #endif /* WINDOWSNT */ |