Skip to content
Snippets Groups Projects
Commit 81f750e7 authored by zeliard's avatar zeliard
Browse files

undo time_t type casting

parent 2cade59b
Branches
Tags
No related merge requests found
...@@ -47,11 +47,7 @@ extern "C" { ...@@ -47,11 +47,7 @@ extern "C" {
typedef struct gpr_timespec { typedef struct gpr_timespec {
time_t tv_sec; time_t tv_sec;
#if defined(GPR_WIN32) && defined(GPR_ARCH_64)
__int64 tv_nsec;
#else
int tv_nsec; int tv_nsec;
#endif
} gpr_timespec; } gpr_timespec;
/* Time constants. */ /* Time constants. */
......
...@@ -55,12 +55,7 @@ void *gpr_realloc(void *p, size_t size) { ...@@ -55,12 +55,7 @@ void *gpr_realloc(void *p, size_t size) {
} }
void *gpr_malloc_aligned(size_t size, size_t alignment_log) { void *gpr_malloc_aligned(size_t size, size_t alignment_log) {
#if defined(GPR_WIN32) && defined(GPR_ARCH_64) size_t alignment = ((size_t)1) << alignment_log;
size_t alignment = 1ULL << alignment_log;
#else
size_t alignment = 1 << alignment_log;
#endif
size_t extra = alignment - 1 + sizeof(void *); size_t extra = alignment - 1 + sizeof(void *);
void *p = gpr_malloc(size + extra); void *p = gpr_malloc(size + extra);
void **ret = (void **)(((gpr_uintptr)p + extra) & ~(alignment - 1)); void **ret = (void **)(((gpr_uintptr)p + extra) & ~(alignment - 1));
......
...@@ -117,7 +117,7 @@ void gpr_slice_buffer_add(gpr_slice_buffer *sb, gpr_slice s) { ...@@ -117,7 +117,7 @@ void gpr_slice_buffer_add(gpr_slice_buffer *sb, gpr_slice s) {
s.data.inlined.bytes, s.data.inlined.length); s.data.inlined.bytes, s.data.inlined.length);
back->data.inlined.length += s.data.inlined.length; back->data.inlined.length += s.data.inlined.length;
} else { } else {
gpr_uint32 cp1 = GPR_SLICE_INLINED_SIZE - back->data.inlined.length; size_t cp1 = GPR_SLICE_INLINED_SIZE - back->data.inlined.length;
memcpy(back->data.inlined.bytes + back->data.inlined.length, memcpy(back->data.inlined.bytes + back->data.inlined.length,
s.data.inlined.bytes, cp1); s.data.inlined.bytes, cp1);
back->data.inlined.length = GPR_SLICE_INLINED_SIZE; back->data.inlined.length = GPR_SLICE_INLINED_SIZE;
......
...@@ -237,7 +237,7 @@ int gpr_time_similar(gpr_timespec a, gpr_timespec b, gpr_timespec threshold) { ...@@ -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) { gpr_int32 gpr_time_to_millis(gpr_timespec t) {
if (t.tv_sec >= 2147483) { if (t.tv_sec >= 2147483) {
if (t.tv_sec == 2147483 && t.tv_nsec < 648 * GPR_NS_PER_MS) { if (t.tv_sec == 2147483 && t.tv_nsec < 648 * GPR_NS_PER_MS) {
return 2147483 * GPR_MS_PER_SEC + (gpr_int32)t.tv_nsec / GPR_NS_PER_MS; return 2147483 * GPR_MS_PER_SEC + t.tv_nsec / GPR_NS_PER_MS;
} }
return 2147483647; return 2147483647;
} else if (t.tv_sec <= -2147483) { } else if (t.tv_sec <= -2147483) {
......
...@@ -64,7 +64,7 @@ void gpr_sleep_until(gpr_timespec until) { ...@@ -64,7 +64,7 @@ void gpr_sleep_until(gpr_timespec until) {
} }
delta = gpr_time_sub(until, now); delta = gpr_time_sub(until, now);
sleep_millis = (DWORD)delta.tv_sec * GPR_MS_PER_SEC + (DWORD)delta.tv_nsec / GPR_NS_PER_MS; sleep_millis = (DWORD)delta.tv_sec * GPR_MS_PER_SEC + delta.tv_nsec / GPR_NS_PER_MS;
Sleep(sleep_millis); Sleep(sleep_millis);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment