blob: f1ee5a93384a84584bc99c3219e074f640382a21 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
$NetBSD: patch-ac,v 1.2 2005/12/28 14:17:57 joerg Exp $
--- src/graph/graphunixx11.c.orig 2004-07-16 01:59:53.000000000 +0000
+++ src/graph/graphunixx11.c
@@ -3085,11 +3085,30 @@ void ewait(INTBIG process)
/*
* Routine to return the number of processors on this machine.
*/
+
+/* XXX there should really be some sort of autoconf test here... */
+#if defined(__NetBSD__) || defined(__DragonFly__)
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#endif
+
INTBIG enumprocessors(void)
{
INTBIG numproc;
+#if defined(__NetBSD__) || defined(__DragonFly__)
+ int mib[2], ncpu;
+ size_t len;
+
+ mib[0] = CTL_HW;
+ mib[1] = HW_NCPU;
+ len = sizeof(ncpu);
+ sysctl(mib, 2, &ncpu, &len, NULL, 0);
+ numproc = (INTBIG) ncpu;
+
+#else
numproc = sysconf(_SC_NPROCESSORS_ONLN);
+#endif
return(numproc);
}
|