# We have the new, three-parameter version
AC_MSG_RESULT(no)
])
-
+ AC_TRY_COMPILE([#include <sched.h>], [
+ CPU_COUNT((void *) 0);
+ ], [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(GLIBC_HAS_CPU_COUNT, 1, [GLIBC has CPU_COUNT macro in sched.h])
+ ], [
+ # We have the new, three-parameter version
+ AC_MSG_RESULT(no)
+ ])
dnl ******************************************************************
dnl *** Check for large file support ***
#include <zlib.h>
#endif
+#ifdef HAVE_SCHED_GETAFFINITY
+# ifndef GLIBC_HAS_CPU_COUNT
+static int
+CPU_COUNT(cpu_set_t *set)
+{
+ int i, count = 0;
+
+ for (int i = 0; i < CPU_SETSIZE; i++)
+ if (CPU_ISSET(i, set))
+ count++;
+ return count;
+}
+# endif
+#endif
+
#define BUFFER_SIZE (4096 * 16)
/* Worst-case size in bytes of a 64-bit value encoded with LEB128. */
#define USE_SYSCTL 1
#endif
+#ifdef HAVE_SCHED_GETAFFINITY
+# ifndef GLIBC_HAS_CPU_COUNT
+static int
+CPU_COUNT(cpu_set_t *set)
+{
+ int i, count = 0;
+
+ for (int i = 0; i < CPU_SETSIZE; i++)
+ if (CPU_ISSET(i, set))
+ count++;
+ return count;
+}
+# endif
+#endif
+
/**
* mono_process_list:
* @size: a pointer to a location where the size of the returned array is stored