CFLAGS="$CFLAGS_SAVED"
])
])
+
+dnl #
+dnl # Determine the number of system cores we have
+dnl #
+AC_DEFUN([AX_SYSTEM_CORES],[
+ AC_CACHE_CHECK([number of system cores], [ax_cv_system_cores],
+ [
+ AC_LANG_PUSH(C)
+
+ AC_TRY_RUN(
+ [
+ #include <stdio.h>
+ #include <stdint.h>
+ #ifdef _WIN32
+ # include <windows.h>
+ #elif MACOS
+ # include <sys/param.h>
+ # include <sys/sysctl.h>
+ #else
+ # include <unistd.h>
+ #endif
+
+ int main (int argc, char *argv[])
+ {
+ uint32_t count;
+
+ #ifdef WIN32
+ SYSTEM_INFO sysinfo;
+ GetSystemInfo(&sysinfo);
+
+ count = sysinfo.dwNumberOfProcessors;
+ #elif MACOS
+
+ int nm[2];
+ size_t len = 4;
+
+ nm[0] = CTL_HW;
+ nm[1] = HW_AVAILCPU;
+ sysctl(nm, 2, &count, &len, NULL, 0);
+
+ if(count < 1) {
+ nm[1] = HW_NCPU;
+ sysctl(nm, 2, &count, &len, NULL, 0);
+ if(count < 1) {
+ count = 1;
+ }
+ }
+ #else
+
+ count = sysconf(_SC_NPROCESSORS_ONLN);
+ #endif
+
+ return count;
+ }
+ ],
+ [ax_cv_system_cores=$?],
+ [ax_cv_system_cores=$?],
+ [ax_cv_system_cores=]
+ )
+ AC_LANG_POP
+ ])
+])
+