Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix jl_cpu_cores on FreeBSD

  • Loading branch information...
commit 0b7b0be5884fcce06f4ac2fb567952e59967c747 1 parent 8e37ccc
@nolta nolta authored
Showing with 7 additions and 6 deletions.
  1. +7 −6 src/sys.c
View
13 src/sys.c
@@ -190,7 +190,7 @@ typedef DWORD (WINAPI *GAPC)(WORD);
#endif
DLLEXPORT int jl_cpu_cores(void) {
-#if defined(__APPLE__)
+#if defined(HW_AVAILCPU) && defined(HW_NCPU)
size_t len = 4;
int32_t count;
int nm[2] = {CTL_HW, HW_AVAILCPU};
@@ -201,13 +201,12 @@ DLLEXPORT int jl_cpu_cores(void) {
if (count < 1) { count = 1; }
}
return count;
-#elif defined(__linux)
+#elif defined(_SC_NPROCESSORS_ONLN)
return sysconf(_SC_NPROCESSORS_ONLN);
-#else
- // test for Windows!
- //Try to get WIN7 API method
+#elif defined(__WIN32__)
+ //Try to get WIN7 API method
GAPC gapc = (GAPC) jl_dlsym(
- jl_kernel32_handle,
+ jl_kernel32_handle,
"GetActiveProcessorCount"
);
@@ -218,6 +217,8 @@ DLLEXPORT int jl_cpu_cores(void) {
GetSystemInfo(&info);
return info.dwNumberOfProcessors;
}
+#else
+ return 1;
#endif
}
Please sign in to comment.
Something went wrong with that request. Please try again.