aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/support
diff options
context:
space:
mode:
authorGravatar David Garcia Quintas <dgq@google.com>2015-09-11 13:33:57 -0700
committerGravatar David Garcia Quintas <dgq@google.com>2015-09-11 18:37:59 -0700
commita4c43a6cbb6554fe180e0d64dfa27f6b868b65d5 (patch)
treef18b8159289ec0652a219a016eefaaa86b600270 /src/core/support
parent3924fcb1c0d0c2ae9fd2995da4ce79e903766fef (diff)
parent35fea62432d7a41b5b3bc96d9af7975310553fe7 (diff)
Merge branch 'master' of github.com:grpc/grpc into rr_with_registry
Diffstat (limited to 'src/core/support')
-rw-r--r--src/core/support/cpu_posix.c8
-rw-r--r--src/core/support/log_posix.c2
-rw-r--r--src/core/support/slice_buffer.c2
-rw-r--r--src/core/support/stack_lockfree.c10
-rw-r--r--src/core/support/stack_lockfree.h4
-rw-r--r--src/core/support/time_posix.c4
6 files changed, 16 insertions, 14 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 */
diff --git a/src/core/support/log_posix.c b/src/core/support/log_posix.c
index 940ee20f15..021c4666d4 100644
--- a/src/core/support/log_posix.c
+++ b/src/core/support/log_posix.c
@@ -62,7 +62,7 @@ void gpr_log(const char *file, int line, gpr_log_severity severity,
} else if ((size_t)ret <= sizeof(buf) - 1) {
message = buf;
} else {
- message = allocated = gpr_malloc(ret + 1);
+ message = allocated = gpr_malloc((size_t)ret + 1);
va_start(args, format);
vsnprintf(message, ret + 1, format, args);
va_end(args);
diff --git a/src/core/support/slice_buffer.c b/src/core/support/slice_buffer.c
index 6482ef9c9f..8873d459d5 100644
--- a/src/core/support/slice_buffer.c
+++ b/src/core/support/slice_buffer.c
@@ -69,7 +69,7 @@ void gpr_slice_buffer_destroy(gpr_slice_buffer *sb) {
}
}
-gpr_uint8 *gpr_slice_buffer_tiny_add(gpr_slice_buffer *sb, unsigned n) {
+gpr_uint8 *gpr_slice_buffer_tiny_add(gpr_slice_buffer *sb, size_t n) {
gpr_slice *back;
gpr_uint8 *out;
diff --git a/src/core/support/stack_lockfree.c b/src/core/support/stack_lockfree.c
index 27ecf62280..180ba19c68 100644
--- a/src/core/support/stack_lockfree.c
+++ b/src/core/support/stack_lockfree.c
@@ -79,7 +79,7 @@ struct gpr_stack_lockfree {
#endif
};
-gpr_stack_lockfree *gpr_stack_lockfree_create(int entries) {
+gpr_stack_lockfree *gpr_stack_lockfree_create(size_t entries) {
gpr_stack_lockfree *stack;
stack = gpr_malloc(sizeof(*stack));
/* Since we only allocate 16 bits to represent an entry number,
@@ -123,13 +123,13 @@ int gpr_stack_lockfree_push(gpr_stack_lockfree *stack, int entry) {
#ifndef NDEBUG
/* Check for double push */
{
- int pushed_index = entry / (8 * sizeof(gpr_atm));
- int pushed_bit = entry % (8 * sizeof(gpr_atm));
+ int pushed_index = entry / (int)(8 * sizeof(gpr_atm));
+ int pushed_bit = entry % (int)(8 * sizeof(gpr_atm));
gpr_atm old_val;
old_val = gpr_atm_no_barrier_fetch_add(&stack->pushed[pushed_index],
(gpr_atm)(1UL << pushed_bit));
- GPR_ASSERT((old_val & (1UL << pushed_bit)) == 0);
+ GPR_ASSERT((old_val & (gpr_atm)(1UL << pushed_bit)) == 0);
}
#endif
@@ -167,7 +167,7 @@ int gpr_stack_lockfree_pop(gpr_stack_lockfree *stack) {
old_val = gpr_atm_no_barrier_fetch_add(&stack->pushed[pushed_index],
-(gpr_atm)(1UL << pushed_bit));
- GPR_ASSERT((old_val & (1UL << pushed_bit)) != 0);
+ GPR_ASSERT((old_val & (gpr_atm)(1UL << pushed_bit)) != 0);
}
#endif
diff --git a/src/core/support/stack_lockfree.h b/src/core/support/stack_lockfree.h
index eec960fbb0..2bbbe3bd95 100644
--- a/src/core/support/stack_lockfree.h
+++ b/src/core/support/stack_lockfree.h
@@ -34,11 +34,13 @@
#ifndef GRPC_INTERNAL_CORE_SUPPORT_STACK_LOCKFREE_H
#define GRPC_INTERNAL_CORE_SUPPORT_STACK_LOCKFREE_H
+#include <stddef.h>
+
typedef struct gpr_stack_lockfree gpr_stack_lockfree;
/* This stack must specify the maximum number of entries to track.
The current implementation only allows up to 65534 entries */
-gpr_stack_lockfree* gpr_stack_lockfree_create(int entries);
+gpr_stack_lockfree* gpr_stack_lockfree_create(size_t entries);
void gpr_stack_lockfree_destroy(gpr_stack_lockfree* stack);
/* Pass in a valid entry number for the next stack entry */
diff --git a/src/core/support/time_posix.c b/src/core/support/time_posix.c
index a274400243..dcecff0d05 100644
--- a/src/core/support/time_posix.c
+++ b/src/core/support/time_posix.c
@@ -108,8 +108,8 @@ gpr_timespec gpr_now(gpr_clock_type clock) {
break;
case GPR_CLOCK_MONOTONIC:
now_dbl = (mach_absolute_time() - g_time_start) * g_time_scale;
- now.tv_sec = now_dbl * 1e-9;
- now.tv_nsec = now_dbl - now.tv_sec * 1e9;
+ now.tv_sec = (time_t)(now_dbl * 1e-9);
+ now.tv_nsec = (int)(now_dbl - ((double)now.tv_sec) * 1e9);
break;
case GPR_CLOCK_PRECISE:
gpr_precise_clock_now(&now);