diff --git a/include/grpc/support/time.h b/include/grpc/support/time.h index 1fd3181859f584e92168b71e10f63990fd6d1a3e..3e40f2b81e07689d524204c9085d571f787b6fdd 100644 --- a/include/grpc/support/time.h +++ b/include/grpc/support/time.h @@ -47,7 +47,11 @@ extern "C" { typedef struct gpr_timespec { time_t tv_sec; +#if defined(GPR_WIN32) && defined(GPR_ARCH_64) + __int64 tv_nsec; +#else int tv_nsec; +#endif } gpr_timespec; /* Time constants. */ diff --git a/src/core/support/alloc.c b/src/core/support/alloc.c index a19a0141d45fe8ffa959b2aa60257ecd87a0463f..acd2432efb55518fb2f909be23e52383ae8da024 100644 --- a/src/core/support/alloc.c +++ b/src/core/support/alloc.c @@ -55,7 +55,12 @@ void *gpr_realloc(void *p, size_t size) { } void *gpr_malloc_aligned(size_t size, size_t alignment_log) { +#if defined(GPR_WIN32) && defined(GPR_ARCH_64) + size_t alignment = 1ULL << alignment_log; +#else size_t alignment = 1 << alignment_log; +#endif + size_t extra = alignment - 1 + sizeof(void *); void *p = gpr_malloc(size + extra); void **ret = (void **)(((gpr_uintptr)p + extra) & ~(alignment - 1)); diff --git a/src/core/support/slice_buffer.c b/src/core/support/slice_buffer.c index 3b1daa07c54e5b4baf50aba04e382cb4636b4216..a26dc1eefb8f359540bd9a7e125372f75168b832 100644 --- a/src/core/support/slice_buffer.c +++ b/src/core/support/slice_buffer.c @@ -117,7 +117,7 @@ void gpr_slice_buffer_add(gpr_slice_buffer *sb, gpr_slice s) { s.data.inlined.bytes, s.data.inlined.length); back->data.inlined.length += s.data.inlined.length; } else { - size_t cp1 = GPR_SLICE_INLINED_SIZE - back->data.inlined.length; + gpr_uint32 cp1 = GPR_SLICE_INLINED_SIZE - back->data.inlined.length; memcpy(back->data.inlined.bytes + back->data.inlined.length, s.data.inlined.bytes, cp1); back->data.inlined.length = GPR_SLICE_INLINED_SIZE; diff --git a/src/core/support/time.c b/src/core/support/time.c index 7dbf95059f5280799cc58f8c3178912131e6afbb..9af81b742d45cafcb23005b4b5063c2586d4795d 100644 --- a/src/core/support/time.c +++ b/src/core/support/time.c @@ -237,7 +237,7 @@ int gpr_time_similar(gpr_timespec a, gpr_timespec b, gpr_timespec threshold) { gpr_int32 gpr_time_to_millis(gpr_timespec t) { if (t.tv_sec >= 2147483) { if (t.tv_sec == 2147483 && t.tv_nsec < 648 * GPR_NS_PER_MS) { - return 2147483 * GPR_MS_PER_SEC + t.tv_nsec / GPR_NS_PER_MS; + return 2147483 * GPR_MS_PER_SEC + (gpr_int32)t.tv_nsec / GPR_NS_PER_MS; } return 2147483647; } else if (t.tv_sec <= -2147483) { @@ -245,7 +245,7 @@ gpr_int32 gpr_time_to_millis(gpr_timespec t) { care?) */ return -2147483647; } else { - return t.tv_sec * GPR_MS_PER_SEC + t.tv_nsec / GPR_NS_PER_MS; + return (gpr_int32)t.tv_sec * GPR_MS_PER_SEC + (gpr_int32)t.tv_nsec / GPR_NS_PER_MS; } } diff --git a/src/core/support/time_win32.c b/src/core/support/time_win32.c index 539470bccfe073da448a9649f74a251a650b10a3..0ca84565a25205c7d9e53dcdf7e732a476195b78 100644 --- a/src/core/support/time_win32.c +++ b/src/core/support/time_win32.c @@ -64,7 +64,7 @@ void gpr_sleep_until(gpr_timespec until) { } delta = gpr_time_sub(until, now); - sleep_millis = delta.tv_sec * GPR_MS_PER_SEC + delta.tv_nsec / GPR_NS_PER_MS; + sleep_millis = (DWORD)delta.tv_sec * GPR_MS_PER_SEC + (DWORD)delta.tv_nsec / GPR_NS_PER_MS; Sleep(sleep_millis); } }