Reverted incorrect type change

pull/2141/head
murgatroid99 10 years ago
parent 04a0395670
commit 5912fb5ca0
  1. 7
      src/core/support/cpu_linux.c

@ -48,10 +48,11 @@
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/sync.h> #include <grpc/support/sync.h>
static unsigned ncpus = 0; static int ncpus = 0;
static void init_num_cpus() { static void init_num_cpus() {
ncpus = (unsigned)sysconf(_SC_NPROCESSORS_ONLN); // This must be signed. sysconf returns -1 when the number can't be determined
ncpus = (int)sysconf(_SC_NPROCESSORS_ONLN);
if (ncpus < 1) { if (ncpus < 1) {
gpr_log(GPR_ERROR, "Cannot determine number of CPUs: assuming 1"); gpr_log(GPR_ERROR, "Cannot determine number of CPUs: assuming 1");
ncpus = 1; ncpus = 1;
@ -61,7 +62,7 @@ static void init_num_cpus() {
unsigned gpr_cpu_num_cores(void) { unsigned gpr_cpu_num_cores(void) {
static gpr_once once = GPR_ONCE_INIT; static gpr_once once = GPR_ONCE_INIT;
gpr_once_init(&once, init_num_cpus); gpr_once_init(&once, init_num_cpus);
return ncpus; return (unsigned)ncpus;
} }
unsigned gpr_cpu_current_cpu(void) { unsigned gpr_cpu_current_cpu(void) {

Loading…
Cancel
Save