summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2019-01-21 19:08:16 +0100
committerDimitri Sokolyuk <demon@dim13.org>2019-01-21 19:08:16 +0100
commit151394174a7b0c59f77c7ec34ed6845f1cbbaac8 (patch)
tree9a37e902f7c72c7f6f8b2328b09cd679861b06ba
parentc615ba7bdc7d0181f0e24f19d70e4697f863f69f (diff)
use sysconfHEADmaster
-rw-r--r--lavg/lavg.c26
1 files changed, 2 insertions, 24 deletions
diff --git a/lavg/lavg.c b/lavg/lavg.c
index ee5b1a2..693f5a1 100644
--- a/lavg/lavg.c
+++ b/lavg/lavg.c
@@ -15,16 +15,10 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#ifndef lint
-static const char rcsid[] = "$Id$";
-#endif /* not lint */
-
-#include <sys/param.h>
-#include <sys/sysctl.h>
-#include <err.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
+#include <unistd.h>
static const struct {
char *name;
@@ -40,28 +34,12 @@ static const struct {
int factor[3] = { 2, 1, 1 };
int
-ncpu(void)
-{
- int mib[2], n;
- size_t len;
-
- mib[0] = CTL_HW;
- mib[1] = HW_NCPU;
- len = sizeof(n);
-
- if (sysctl(mib, 2, &n, &len, NULL, 0) == -1)
- err(1, "sysctl");
-
- return n;
-}
-
-int
main(void)
{
double avg[3], threshold;
int i, n, cpu;
- cpu = ncpu();
+ cpu = sysconf(_SC_NPROCESSORS_CONF);
threshold = log(cpu) + 1;
printf("Content-Type: text/html\n\n<html>\n");