Commit 69430806 authored by Edward Z. Yang's avatar Edward Z. Yang
Browse files

Axe getnumcores, as we don't support pre-6.12 anymore.


Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
parent feba77bf
......@@ -263,13 +263,9 @@ executable cabal
else
build-depends: unix >= 2.5 && < 2.8
if arch(arm) && impl(ghc < 7.6)
-- older ghc on arm does not support -threaded
cc-options: -DCABAL_NO_THREADED
else
ghc-options: -threaded
if !(arch(arm) && impl(ghc < 7.6))
ghc-options: -threaded
c-sources: cbits/getnumcores.c
default-language: Haskell2010
-- Small, fast running tests.
......@@ -336,9 +332,7 @@ Test-Suite unit-tests
else
build-depends: unix
if arch(arm)
cc-options: -DCABAL_NO_THREADED
else
if !(arch(arm) && impl(ghc < 7.6))
ghc-options: -threaded
default-language: Haskell2010
......@@ -392,9 +386,7 @@ Test-Suite solver-quickcheck
else
build-depends: unix
if arch(arm)
cc-options: -DCABAL_NO_THREADED
else
if !(arch(arm) && impl(ghc < 7.6))
ghc-options: -threaded
default-language: Haskell2010
......@@ -419,9 +411,7 @@ test-suite integration-tests
else
build-depends: unix >= 2.5 && < 2.8
if arch(arm)
cc-options: -DCABAL_NO_THREADED
else
if !(arch(arm) && impl(ghc < 7.6))
ghc-options: -threaded
ghc-options: -Wall
......
#if defined(__GLASGOW_HASKELL__) && (__GLASGOW_HASKELL__ >= 612) && !defined(CABAL_NO_THREADED)
/* Since version 6.12, GHC's threaded RTS includes a getNumberOfProcessors
function, so we try to use that if available. cabal-install is always built
with -threaded nowadays. */
#define HAS_GET_NUMBER_OF_PROCESSORS
#endif
#ifndef HAS_GET_NUMBER_OF_PROCESSORS
#if defined(_WIN32) && !defined(__CYGWIN__)
#include <windows.h>
#elif MACOS
#include <sys/param.h>
#include <sys/sysctl.h>
#elif __linux__
#include <unistd.h>
#endif
int getNumberOfProcessors() {
#if defined(_WIN32) && !defined(__CYGWIN__)
SYSTEM_INFO sysinfo;
GetSystemInfo(&sysinfo);
return sysinfo.dwNumberOfProcessors;
#elif MACOS
int nm[2];
size_t len = 4;
uint32_t count;
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; }
}
return count;
#elif __linux__
return sysconf(_SC_NPROCESSORS_ONLN);
#else
return 1;
#endif
}
#endif /* HAS_GET_NUMBER_OF_PROCESSORS */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment