diff options
author | Craig Tiller <ctiller@google.com> | 2015-09-11 12:59:46 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2015-09-11 12:59:46 -0700 |
commit | 8648c0551fabb7ee49606d1157f95818704c7065 (patch) | |
tree | 2d1e2df58e0062aa53e059fcacea9002c1f8b191 /src/core/support/cpu_posix.c | |
parent | f29a38820735c332f1d16c5ae4b91e332a0ca5cc (diff) | |
parent | ebc7ef268ca9536af6a4c5be1c80bcc79665d4e9 (diff) |
Merge branch 'immolating-conversion' of github.com:ctiller/grpc into immolating-conversion
Diffstat (limited to 'src/core/support/cpu_posix.c')
-rw-r--r-- | src/core/support/cpu_posix.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/core/support/cpu_posix.c b/src/core/support/cpu_posix.c index 99484e37fb..55d92c0555 100644 --- a/src/core/support/cpu_posix.c +++ b/src/core/support/cpu_posix.c @@ -44,11 +44,11 @@ static __thread char magic_thread_local; -static int ncpus = 0; +static long ncpus = 0; static void init_ncpus() { ncpus = sysconf(_SC_NPROCESSORS_ONLN); - if (ncpus < 1) { + if (ncpus < 1 || ncpus > GPR_UINT32_MAX) { gpr_log(GPR_ERROR, "Cannot determine number of CPUs: assuming 1"); ncpus = 1; } @@ -57,7 +57,7 @@ static void init_ncpus() { unsigned gpr_cpu_num_cores(void) { static gpr_once once = GPR_ONCE_INIT; gpr_once_init(&once, init_ncpus); - return ncpus; + return (unsigned)ncpus; } /* This is a cheap, but good enough, pointer hash for sharding things: */ @@ -71,7 +71,7 @@ unsigned gpr_cpu_current_cpu(void) { most code that's using this is using it to shard across work queues though, so here we use thread identity instead to achieve a similar though not identical effect */ - return shard_ptr(&magic_thread_local); + return (unsigned)shard_ptr(&magic_thread_local); } #endif /* GPR_CPU_POSIX */ |