]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
build: work with glibc that lacks CPU_COUNT
authorEric Blake <eblake@redhat.com>
Tue, 21 Aug 2012 17:10:14 +0000 (11:10 -0600)
committerEric Blake <eblake@redhat.com>
Tue, 21 Aug 2012 18:07:03 +0000 (12:07 -0600)
Building on RHEL 5 warned:

nodeinfo.c: 305: warning: implicit declaration of function 'CPU_COUNT'

This extension macro in <sched.h> was not added until later glibc.

* src/nodeinfo.c (CPU_COUNT): Add fallback implementation.

src/nodeinfo.c

index 84a5d666e3aa60b8bfff6c35bfd7ef6cec1321fd..e3d4a242dd6d0159a8313e99bcc43cfb84cc20fe 100644 (file)
@@ -184,6 +184,19 @@ virNodeParseSocket(const char *dir, unsigned int cpu)
     return ret;
 }
 
+# ifndef CPU_COUNT
+static int
+CPU_COUNT(cpu_set_t *set)
+{
+    int i, count = 0;
+
+    for (i = 0; i < CPU_SETSIZE; i++)
+        if (CPU_ISSET(i, set))
+            count++;
+    return count;
+}
+# endif /* !CPU_COUNT */
+
 /* parses a node entry, returning number of processors in the node and
  * filling arguments */
 static int