Skip to content

Commit

Permalink
Fix cpu count on Windows
Browse files Browse the repository at this point in the history
We cannot choose between OSes using macros,
because the binaries built on one system must
work on another.

Closes #77.
  • Loading branch information
gaborcsardi committed Aug 11, 2020
1 parent 31b0c9c commit 62dfb14
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/api-windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -586,17 +586,10 @@ SEXP ps__boot_time() {
* Return the number of logical, active CPUs. Return 0 if undetermined.
* See discussion at: https://bugs.python.org/issue33166#msg314631
*/
#if (_WIN32_WINNT < 0x0601) // < Windows 7 (namely Vista and XP)

SEXP ps__cpu_count_logical() {
return ScalarInteger(NA_INTEGER);
}

SEXP ps__cpu_count_physical() {
return ScalarInteger(NA_INTEGER);
}

#else // Windows >= 7
#ifndef ALL_PROCESSOR_GROUPS
#define ALL_PROCESSOR_GROUPS 0xffff
#endif

unsigned int ps__get_num_cpus(int fail_on_err) {
unsigned int ncpus = 0;
Expand Down Expand Up @@ -721,7 +714,6 @@ SEXP ps__cpu_count_physical() {
return ScalarInteger(NA_INTEGER);
}
}
#endif

SEXP ps__kill_if_env(SEXP marker, SEXP after, SEXP pid, SEXP sig) {
const char *cmarker = CHAR(STRING_ELT(marker, 0));
Expand Down
1 change: 1 addition & 0 deletions src/windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include <stdlib.h>

#include "windows.h"

/*
* ============================================================================
* Utilities
Expand Down

0 comments on commit 62dfb14

Please sign in to comment.