aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/support
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/support')
-rw-r--r--src/core/support/alloc.c2
-rw-r--r--src/core/support/cpu_posix.c2
-rw-r--r--src/core/support/histogram.c10
-rw-r--r--src/core/support/log_posix.c2
-rw-r--r--src/core/support/murmur_hash.c22
-rw-r--r--src/core/support/murmur_hash.h2
-rw-r--r--src/core/support/slice.c22
-rw-r--r--src/core/support/slice_buffer.c12
-rw-r--r--src/core/support/stack_lockfree.c10
-rw-r--r--src/core/support/string.c30
-rw-r--r--src/core/support/string.h10
-rw-r--r--src/core/support/sync.c8
-rw-r--r--src/core/support/sync_win32.c6
-rw-r--r--src/core/support/time.c20
-rw-r--r--src/core/support/time_posix.c8
-rw-r--r--src/core/support/time_precise.c4
-rw-r--r--src/core/support/time_win32.c6
-rw-r--r--src/core/support/tls_pthread.c2
18 files changed, 89 insertions, 89 deletions
diff --git a/src/core/support/alloc.c b/src/core/support/alloc.c
index ca72379b1d..0a064b2c18 100644
--- a/src/core/support/alloc.c
+++ b/src/core/support/alloc.c
@@ -82,7 +82,7 @@ void *gpr_malloc_aligned(size_t size, size_t alignment_log) {
size_t alignment = ((size_t)1) << alignment_log;
size_t extra = alignment - 1 + sizeof(void *);
void *p = gpr_malloc(size + extra);
- void **ret = (void **)(((gpr_uintptr)p + extra) & ~(alignment - 1));
+ void **ret = (void **)(((uintptr_t)p + extra) & ~(alignment - 1));
ret[-1] = p;
return (void *)ret;
}
diff --git a/src/core/support/cpu_posix.c b/src/core/support/cpu_posix.c
index 55d92c0555..5edb87d67f 100644
--- a/src/core/support/cpu_posix.c
+++ b/src/core/support/cpu_posix.c
@@ -48,7 +48,7 @@ static long ncpus = 0;
static void init_ncpus() {
ncpus = sysconf(_SC_NPROCESSORS_ONLN);
- if (ncpus < 1 || ncpus > GPR_UINT32_MAX) {
+ if (ncpus < 1 || ncpus > UINT32_MAX) {
gpr_log(GPR_ERROR, "Cannot determine number of CPUs: assuming 1");
ncpus = 1;
}
diff --git a/src/core/support/histogram.c b/src/core/support/histogram.c
index 77b48af996..20ed2b14b1 100644
--- a/src/core/support/histogram.c
+++ b/src/core/support/histogram.c
@@ -66,7 +66,7 @@ struct gpr_histogram {
/* number of buckets */
size_t num_buckets;
/* the buckets themselves */
- gpr_uint32 *buckets;
+ uint32_t *buckets;
};
/* determine a bucket index given a value - does no bounds checking */
@@ -102,8 +102,8 @@ gpr_histogram *gpr_histogram_create(double resolution,
h->num_buckets = bucket_for_unchecked(h, max_bucket_start) + 1;
GPR_ASSERT(h->num_buckets > 1);
GPR_ASSERT(h->num_buckets < 100000000);
- h->buckets = gpr_malloc(sizeof(gpr_uint32) * h->num_buckets);
- memset(h->buckets, 0, sizeof(gpr_uint32) * h->num_buckets);
+ h->buckets = gpr_malloc(sizeof(uint32_t) * h->num_buckets);
+ memset(h->buckets, 0, sizeof(uint32_t) * h->num_buckets);
return h;
}
@@ -137,7 +137,7 @@ int gpr_histogram_merge(gpr_histogram *dst, const gpr_histogram *src) {
return 1;
}
-void gpr_histogram_merge_contents(gpr_histogram *dst, const gpr_uint32 *data,
+void gpr_histogram_merge_contents(gpr_histogram *dst, const uint32_t *data,
size_t data_count, double min_seen,
double max_seen, double sum,
double sum_of_squares, double count) {
@@ -238,7 +238,7 @@ double gpr_histogram_sum_of_squares(gpr_histogram *h) {
return h->sum_of_squares;
}
-const gpr_uint32 *gpr_histogram_get_contents(gpr_histogram *h, size_t *size) {
+const uint32_t *gpr_histogram_get_contents(gpr_histogram *h, size_t *size) {
*size = h->num_buckets;
return h->buckets;
}
diff --git a/src/core/support/log_posix.c b/src/core/support/log_posix.c
index 8986254e4e..3ff171f99c 100644
--- a/src/core/support/log_posix.c
+++ b/src/core/support/log_posix.c
@@ -45,7 +45,7 @@
#include <time.h>
#include <pthread.h>
-static gpr_intptr gettid(void) { return (gpr_intptr)pthread_self(); }
+static intptr_t gettid(void) { return (intptr_t)pthread_self(); }
void gpr_log(const char *file, int line, gpr_log_severity severity,
const char *format, ...) {
diff --git a/src/core/support/murmur_hash.c b/src/core/support/murmur_hash.c
index 37fdca82ba..a5261c0cc0 100644
--- a/src/core/support/murmur_hash.c
+++ b/src/core/support/murmur_hash.c
@@ -46,19 +46,19 @@
handle aligned reads, do the conversion here */
#define GETBLOCK32(p, i) (p)[(i)]
-gpr_uint32 gpr_murmur_hash3(const void *key, size_t len, gpr_uint32 seed) {
- const gpr_uint8 *data = (const gpr_uint8 *)key;
+uint32_t gpr_murmur_hash3(const void *key, size_t len, uint32_t seed) {
+ const uint8_t *data = (const uint8_t *)key;
const size_t nblocks = len / 4;
int i;
- gpr_uint32 h1 = seed;
- gpr_uint32 k1;
+ uint32_t h1 = seed;
+ uint32_t k1;
- const gpr_uint32 c1 = 0xcc9e2d51;
- const gpr_uint32 c2 = 0x1b873593;
+ const uint32_t c1 = 0xcc9e2d51;
+ const uint32_t c2 = 0x1b873593;
- const gpr_uint32 *blocks = ((const gpr_uint32 *)key) + nblocks;
- const gpr_uint8 *tail = (const gpr_uint8 *)(data + nblocks * 4);
+ const uint32_t *blocks = ((const uint32_t *)key) + nblocks;
+ const uint8_t *tail = (const uint8_t *)(data + nblocks * 4);
/* body */
for (i = -(int)nblocks; i; i++) {
@@ -78,9 +78,9 @@ gpr_uint32 gpr_murmur_hash3(const void *key, size_t len, gpr_uint32 seed) {
/* tail */
switch (len & 3) {
case 3:
- k1 ^= ((gpr_uint32)tail[2]) << 16;
+ k1 ^= ((uint32_t)tail[2]) << 16;
case 2:
- k1 ^= ((gpr_uint32)tail[1]) << 8;
+ k1 ^= ((uint32_t)tail[1]) << 8;
case 1:
k1 ^= tail[0];
k1 *= c1;
@@ -90,7 +90,7 @@ gpr_uint32 gpr_murmur_hash3(const void *key, size_t len, gpr_uint32 seed) {
};
/* finalization */
- h1 ^= (gpr_uint32)len;
+ h1 ^= (uint32_t)len;
FMIX32(h1);
return h1;
}
diff --git a/src/core/support/murmur_hash.h b/src/core/support/murmur_hash.h
index 343fcb99f7..0bf04f731a 100644
--- a/src/core/support/murmur_hash.h
+++ b/src/core/support/murmur_hash.h
@@ -39,6 +39,6 @@
#include <stddef.h>
/* compute the hash of key (length len) */
-gpr_uint32 gpr_murmur_hash3(const void *key, size_t len, gpr_uint32 seed);
+uint32_t gpr_murmur_hash3(const void *key, size_t len, uint32_t seed);
#endif /* GRPC_INTERNAL_CORE_SUPPORT_MURMUR_HASH_H */
diff --git a/src/core/support/slice.c b/src/core/support/slice.c
index 9f0ded4932..b9a7c77bda 100644
--- a/src/core/support/slice.c
+++ b/src/core/support/slice.c
@@ -67,7 +67,7 @@ static gpr_slice_refcount noop_refcount = {noop_ref_or_unref,
gpr_slice gpr_slice_from_static_string(const char *s) {
gpr_slice slice;
slice.refcount = &noop_refcount;
- slice.data.refcounted.bytes = (gpr_uint8 *)s;
+ slice.data.refcounted.bytes = (uint8_t *)s;
slice.data.refcounted.length = strlen(s);
return slice;
}
@@ -203,13 +203,13 @@ gpr_slice gpr_slice_malloc(size_t length) {
/* The slices refcount points back to the allocated block. */
slice.refcount = &rc->base;
/* The data bytes are placed immediately after the refcount struct */
- slice.data.refcounted.bytes = (gpr_uint8 *)(rc + 1);
+ slice.data.refcounted.bytes = (uint8_t *)(rc + 1);
/* And the length of the block is set to the requested length */
slice.data.refcounted.length = length;
} else {
/* small slice: just inline the data */
slice.refcount = NULL;
- slice.data.inlined.length = (gpr_uint8)length;
+ slice.data.inlined.length = (uint8_t)length;
}
return slice;
}
@@ -232,7 +232,7 @@ gpr_slice gpr_slice_sub_no_ref(gpr_slice source, size_t begin, size_t end) {
/* Enforce preconditions */
GPR_ASSERT(source.data.inlined.length >= end);
subset.refcount = NULL;
- subset.data.inlined.length = (gpr_uint8)(end - begin);
+ subset.data.inlined.length = (uint8_t)(end - begin);
memcpy(subset.data.inlined.bytes, source.data.inlined.bytes + begin,
end - begin);
}
@@ -244,7 +244,7 @@ gpr_slice gpr_slice_sub(gpr_slice source, size_t begin, size_t end) {
if (end - begin <= sizeof(subset.data.inlined.bytes)) {
subset.refcount = NULL;
- subset.data.inlined.length = (gpr_uint8)(end - begin);
+ subset.data.inlined.length = (uint8_t)(end - begin);
memcpy(subset.data.inlined.bytes, GPR_SLICE_START_PTR(source) + begin,
end - begin);
} else {
@@ -262,17 +262,17 @@ gpr_slice gpr_slice_split_tail(gpr_slice *source, size_t split) {
/* inlined data, copy it out */
GPR_ASSERT(source->data.inlined.length >= split);
tail.refcount = NULL;
- tail.data.inlined.length = (gpr_uint8)(source->data.inlined.length - split);
+ tail.data.inlined.length = (uint8_t)(source->data.inlined.length - split);
memcpy(tail.data.inlined.bytes, source->data.inlined.bytes + split,
tail.data.inlined.length);
- source->data.inlined.length = (gpr_uint8)split;
+ source->data.inlined.length = (uint8_t)split;
} else {
size_t tail_length = source->data.refcounted.length - split;
GPR_ASSERT(source->data.refcounted.length >= split);
if (tail_length < sizeof(tail.data.inlined.bytes)) {
/* Copy out the bytes - it'll be cheaper than refcounting */
tail.refcount = NULL;
- tail.data.inlined.length = (gpr_uint8)tail_length;
+ tail.data.inlined.length = (uint8_t)tail_length;
memcpy(tail.data.inlined.bytes, source->data.refcounted.bytes + split,
tail_length);
} else {
@@ -297,17 +297,17 @@ gpr_slice gpr_slice_split_head(gpr_slice *source, size_t split) {
GPR_ASSERT(source->data.inlined.length >= split);
head.refcount = NULL;
- head.data.inlined.length = (gpr_uint8)split;
+ head.data.inlined.length = (uint8_t)split;
memcpy(head.data.inlined.bytes, source->data.inlined.bytes, split);
source->data.inlined.length =
- (gpr_uint8)(source->data.inlined.length - split);
+ (uint8_t)(source->data.inlined.length - split);
memmove(source->data.inlined.bytes, source->data.inlined.bytes + split,
source->data.inlined.length);
} else if (split < sizeof(head.data.inlined.bytes)) {
GPR_ASSERT(source->data.refcounted.length >= split);
head.refcount = NULL;
- head.data.inlined.length = (gpr_uint8)split;
+ head.data.inlined.length = (uint8_t)split;
memcpy(head.data.inlined.bytes, source->data.refcounted.bytes, split);
source->data.refcounted.bytes += split;
source->data.refcounted.length -= split;
diff --git a/src/core/support/slice_buffer.c b/src/core/support/slice_buffer.c
index 856d3a2439..66f111d767 100644
--- a/src/core/support/slice_buffer.c
+++ b/src/core/support/slice_buffer.c
@@ -70,9 +70,9 @@ void gpr_slice_buffer_destroy(gpr_slice_buffer *sb) {
}
}
-gpr_uint8 *gpr_slice_buffer_tiny_add(gpr_slice_buffer *sb, size_t n) {
+uint8_t *gpr_slice_buffer_tiny_add(gpr_slice_buffer *sb, size_t n) {
gpr_slice *back;
- gpr_uint8 *out;
+ uint8_t *out;
sb->length += n;
@@ -82,7 +82,7 @@ gpr_uint8 *gpr_slice_buffer_tiny_add(gpr_slice_buffer *sb, size_t n) {
if ((back->data.inlined.length + n) > sizeof(back->data.inlined.bytes))
goto add_new;
out = back->data.inlined.bytes + back->data.inlined.length;
- back->data.inlined.length = (gpr_uint8)(back->data.inlined.length + n);
+ back->data.inlined.length = (uint8_t)(back->data.inlined.length + n);
return out;
add_new:
@@ -90,7 +90,7 @@ add_new:
back = &sb->slices[sb->count];
sb->count++;
back->refcount = NULL;
- back->data.inlined.length = (gpr_uint8)n;
+ back->data.inlined.length = (uint8_t)n;
return back->data.inlined.bytes;
}
@@ -118,7 +118,7 @@ void gpr_slice_buffer_add(gpr_slice_buffer *sb, gpr_slice s) {
memcpy(back->data.inlined.bytes + back->data.inlined.length,
s.data.inlined.bytes, s.data.inlined.length);
back->data.inlined.length =
- (gpr_uint8)(back->data.inlined.length + s.data.inlined.length);
+ (uint8_t)(back->data.inlined.length + s.data.inlined.length);
} else {
size_t cp1 = GPR_SLICE_INLINED_SIZE - back->data.inlined.length;
memcpy(back->data.inlined.bytes + back->data.inlined.length,
@@ -128,7 +128,7 @@ void gpr_slice_buffer_add(gpr_slice_buffer *sb, gpr_slice s) {
back = &sb->slices[n];
sb->count = n + 1;
back->refcount = NULL;
- back->data.inlined.length = (gpr_uint8)(s.data.inlined.length - cp1);
+ back->data.inlined.length = (uint8_t)(s.data.inlined.length - cp1);
memcpy(back->data.inlined.bytes, s.data.inlined.bytes + cp1,
s.data.inlined.length - cp1);
}
diff --git a/src/core/support/stack_lockfree.c b/src/core/support/stack_lockfree.c
index fc934d404c..cd0afddf9d 100644
--- a/src/core/support/stack_lockfree.c
+++ b/src/core/support/stack_lockfree.c
@@ -45,13 +45,13 @@
word that allows for an atomic CAS to set it up. */
struct lockfree_node_contents {
/* next thing to look at. Actual index for head, next index otherwise */
- gpr_uint16 index;
+ uint16_t index;
#ifdef GPR_ARCH_64
- gpr_uint16 pad;
- gpr_uint32 aba_ctr;
+ uint16_t pad;
+ uint32_t aba_ctr;
#else
#ifdef GPR_ARCH_32
- gpr_uint16 aba_ctr;
+ uint16_t aba_ctr;
#else
#error Unsupported bit width architecture
#endif
@@ -114,7 +114,7 @@ int gpr_stack_lockfree_push(gpr_stack_lockfree *stack, int entry) {
lockfree_node newent;
/* First fill in the entry's index and aba ctr for new head */
- newhead.contents.index = (gpr_uint16)entry;
+ newhead.contents.index = (uint16_t)entry;
/* Also post-increment the aba_ctr */
curent.atm = gpr_atm_no_barrier_load(&stack->entries[entry].atm);
newhead.contents.aba_ctr = ++curent.contents.aba_ctr;
diff --git a/src/core/support/string.c b/src/core/support/string.c
index 46a7ca3d46..1f541de40f 100644
--- a/src/core/support/string.c
+++ b/src/core/support/string.c
@@ -80,9 +80,9 @@ static void dump_out_append(dump_out *out, char c) {
static void hexdump(dump_out *out, const char *buf, size_t len) {
static const char hex[16] = "0123456789abcdef";
- const gpr_uint8 *const beg = (const gpr_uint8 *)buf;
- const gpr_uint8 *const end = beg + len;
- const gpr_uint8 *cur;
+ const uint8_t *const beg = (const uint8_t *)buf;
+ const uint8_t *const end = beg + len;
+ const uint8_t *cur;
for (cur = beg; cur != end; ++cur) {
if (cur != beg) dump_out_append(out, ' ');
@@ -92,9 +92,9 @@ static void hexdump(dump_out *out, const char *buf, size_t len) {
}
static void asciidump(dump_out *out, const char *buf, size_t len) {
- const gpr_uint8 *const beg = (const gpr_uint8 *)buf;
- const gpr_uint8 *const end = beg + len;
- const gpr_uint8 *cur;
+ const uint8_t *const beg = (const uint8_t *)buf;
+ const uint8_t *const end = beg + len;
+ const uint8_t *cur;
int out_was_empty = (out->length == 0);
if (!out_was_empty) {
dump_out_append(out, ' ');
@@ -108,7 +108,7 @@ static void asciidump(dump_out *out, const char *buf, size_t len) {
}
}
-char *gpr_dump(const char *buf, size_t len, gpr_uint32 flags) {
+char *gpr_dump(const char *buf, size_t len, uint32_t flags) {
dump_out out = dump_out_create();
if (flags & GPR_DUMP_HEX) {
hexdump(&out, buf, len);
@@ -120,21 +120,21 @@ char *gpr_dump(const char *buf, size_t len, gpr_uint32 flags) {
return out.data;
}
-char *gpr_dump_slice(gpr_slice s, gpr_uint32 flags) {
+char *gpr_dump_slice(gpr_slice s, uint32_t flags) {
return gpr_dump((const char *)GPR_SLICE_START_PTR(s), GPR_SLICE_LENGTH(s),
flags);
}
-int gpr_parse_bytes_to_uint32(const char *buf, size_t len, gpr_uint32 *result) {
- gpr_uint32 out = 0;
- gpr_uint32 new;
+int gpr_parse_bytes_to_uint32(const char *buf, size_t len, uint32_t *result) {
+ uint32_t out = 0;
+ uint32_t new;
size_t i;
if (len == 0) return 0; /* must have some bytes */
for (i = 0; i < len; i++) {
if (buf[i] < '0' || buf[i] > '9') return 0; /* bad char */
- new = 10 * out + (gpr_uint32)(buf[i] - '0');
+ new = 10 * out + (uint32_t)(buf[i] - '0');
if (new < out) return 0; /* overflow */
out = new;
}
@@ -173,8 +173,8 @@ int gpr_ltoa(long value, char *string) {
return i;
}
-int gpr_int64toa(gpr_int64 value, char *string) {
- gpr_int64 sign;
+int int64_ttoa(int64_t value, char *string) {
+ int64_t sign;
int i = 0;
if (value == 0) {
@@ -238,7 +238,7 @@ static int slice_find_separator_offset(const gpr_slice str, const char *sep,
const size_t read_offset, size_t *begin,
size_t *end) {
size_t i;
- const gpr_uint8 *str_ptr = GPR_SLICE_START_PTR(str) + read_offset;
+ const uint8_t *str_ptr = GPR_SLICE_START_PTR(str) + read_offset;
const size_t str_len = GPR_SLICE_LENGTH(str) - read_offset;
const size_t sep_len = strlen(sep);
if (str_len < sep_len) {
diff --git a/src/core/support/string.h b/src/core/support/string.h
index 9b604ac5bf..e6755de106 100644
--- a/src/core/support/string.h
+++ b/src/core/support/string.h
@@ -52,15 +52,15 @@ extern "C" {
/* Converts array buf, of length len, into a C string according to the flags.
Result should be freed with gpr_free() */
-char *gpr_dump(const char *buf, size_t len, gpr_uint32 flags);
+char *gpr_dump(const char *buf, size_t len, uint32_t flags);
/* Calls gpr_dump on a slice. */
-char *gpr_dump_slice(gpr_slice slice, gpr_uint32 flags);
+char *gpr_dump_slice(gpr_slice slice, uint32_t flags);
/* Parses an array of bytes into an integer (base 10). Returns 1 on success,
0 on failure. */
int gpr_parse_bytes_to_uint32(const char *data, size_t length,
- gpr_uint32 *result);
+ uint32_t *result);
/* Minimum buffer size for calling ltoa */
#define GPR_LTOA_MIN_BUFSIZE (3 * sizeof(long))
@@ -71,14 +71,14 @@ int gpr_parse_bytes_to_uint32(const char *data, size_t length,
int gpr_ltoa(long value, char *output);
/* Minimum buffer size for calling int64toa */
-#define GPR_INT64TOA_MIN_BUFSIZE (3 * sizeof(gpr_int64))
+#define GPR_INT64TOA_MIN_BUFSIZE (3 * sizeof(int64_t))
/* Convert an int64 to a string in base 10; returns the length of the
output string (or 0 on failure).
output must be at least GPR_INT64TOA_MIN_BUFSIZE bytes long.
NOTE: This function ensures sufficient bit width even on Win x64,
where long is 32bit is size.*/
-int gpr_int64toa(gpr_int64 value, char *output);
+int int64_ttoa(int64_t value, char *output);
/* Reverse a run of bytes */
void gpr_reverse_bytes(char *str, int len);
diff --git a/src/core/support/sync.c b/src/core/support/sync.c
index d3cf77faea..d368422d9e 100644
--- a/src/core/support/sync.c
+++ b/src/core/support/sync.c
@@ -59,7 +59,7 @@ static void event_initialize(void) {
/* Hash ev into an element of sync_array[]. */
static struct sync_array_s *hash(gpr_event *ev) {
- return &sync_array[((gpr_uintptr)ev) % event_sync_partitions];
+ return &sync_array[((uintptr_t)ev) % event_sync_partitions];
}
void gpr_event_init(gpr_event *ev) {
@@ -108,15 +108,15 @@ int gpr_unref(gpr_refcount *r) {
return prior == 1;
}
-void gpr_stats_init(gpr_stats_counter *c, gpr_intptr n) {
+void gpr_stats_init(gpr_stats_counter *c, intptr_t n) {
gpr_atm_rel_store(&c->value, n);
}
-void gpr_stats_inc(gpr_stats_counter *c, gpr_intptr inc) {
+void gpr_stats_inc(gpr_stats_counter *c, intptr_t inc) {
gpr_atm_no_barrier_fetch_add(&c->value, inc);
}
-gpr_intptr gpr_stats_read(const gpr_stats_counter *c) {
+intptr_t gpr_stats_read(const gpr_stats_counter *c) {
/* don't need acquire-load, but we have no no-barrier load yet */
return gpr_atm_acq_load(&c->value);
}
diff --git a/src/core/support/sync_win32.c b/src/core/support/sync_win32.c
index 69dd46399a..51a082b29e 100644
--- a/src/core/support/sync_win32.c
+++ b/src/core/support/sync_win32.c
@@ -88,9 +88,9 @@ int gpr_cv_wait(gpr_cv *cv, gpr_mu *mu, gpr_timespec abs_deadline) {
SleepConditionVariableCS(cv, &mu->cs, INFINITE);
} else {
gpr_timespec now = gpr_now(abs_deadline.clock_type);
- gpr_int64 now_ms = (gpr_int64)now.tv_sec * 1000 + now.tv_nsec / 1000000;
- gpr_int64 deadline_ms =
- (gpr_int64)abs_deadline.tv_sec * 1000 + abs_deadline.tv_nsec / 1000000;
+ int64_t now_ms = (int64_t)now.tv_sec * 1000 + now.tv_nsec / 1000000;
+ int64_t deadline_ms =
+ (int64_t)abs_deadline.tv_sec * 1000 + abs_deadline.tv_nsec / 1000000;
if (now_ms >= deadline_ms) {
timeout = 1;
} else {
diff --git a/src/core/support/time.c b/src/core/support/time.c
index 197fa9ad44..ac8c3bcde5 100644
--- a/src/core/support/time.c
+++ b/src/core/support/time.c
@@ -92,11 +92,11 @@ gpr_timespec gpr_time_from_nanos(long ns, gpr_clock_type type) {
result = gpr_inf_past(type);
} else if (ns >= 0) {
result.tv_sec = ns / GPR_NS_PER_SEC;
- result.tv_nsec = (gpr_int32)(ns - result.tv_sec * GPR_NS_PER_SEC);
+ result.tv_nsec = (int32_t)(ns - result.tv_sec * GPR_NS_PER_SEC);
} else {
/* Calculation carefully formulated to avoid any possible under/overflow. */
result.tv_sec = (-(999999999 - (ns + GPR_NS_PER_SEC)) / GPR_NS_PER_SEC) - 1;
- result.tv_nsec = (gpr_int32)(ns - result.tv_sec * GPR_NS_PER_SEC);
+ result.tv_nsec = (int32_t)(ns - result.tv_sec * GPR_NS_PER_SEC);
}
return result;
}
@@ -110,11 +110,11 @@ gpr_timespec gpr_time_from_micros(long us, gpr_clock_type type) {
result = gpr_inf_past(type);
} else if (us >= 0) {
result.tv_sec = us / 1000000;
- result.tv_nsec = (gpr_int32)((us - result.tv_sec * 1000000) * 1000);
+ result.tv_nsec = (int32_t)((us - result.tv_sec * 1000000) * 1000);
} else {
/* Calculation carefully formulated to avoid any possible under/overflow. */
result.tv_sec = (-(999999 - (us + 1000000)) / 1000000) - 1;
- result.tv_nsec = (gpr_int32)((us - result.tv_sec * 1000000) * 1000);
+ result.tv_nsec = (int32_t)((us - result.tv_sec * 1000000) * 1000);
}
return result;
}
@@ -128,11 +128,11 @@ gpr_timespec gpr_time_from_millis(long ms, gpr_clock_type type) {
result = gpr_inf_past(type);
} else if (ms >= 0) {
result.tv_sec = ms / 1000;
- result.tv_nsec = (gpr_int32)((ms - result.tv_sec * 1000) * 1000000);
+ result.tv_nsec = (int32_t)((ms - result.tv_sec * 1000) * 1000000);
} else {
/* Calculation carefully formulated to avoid any possible under/overflow. */
result.tv_sec = (-(999 - (ms + 1000)) / 1000) - 1;
- result.tv_nsec = (gpr_int32)((ms - result.tv_sec * 1000) * 1000000);
+ result.tv_nsec = (int32_t)((ms - result.tv_sec * 1000) * 1000000);
}
return result;
}
@@ -181,7 +181,7 @@ gpr_timespec gpr_time_from_hours(long h, gpr_clock_type type) {
gpr_timespec gpr_time_add(gpr_timespec a, gpr_timespec b) {
gpr_timespec sum;
- gpr_int64 inc = 0;
+ int64_t inc = 0;
GPR_ASSERT(b.clock_type == GPR_TIMESPAN);
sum.clock_type = a.clock_type;
sum.tv_nsec = a.tv_nsec + b.tv_nsec;
@@ -210,7 +210,7 @@ gpr_timespec gpr_time_add(gpr_timespec a, gpr_timespec b) {
gpr_timespec gpr_time_sub(gpr_timespec a, gpr_timespec b) {
gpr_timespec diff;
- gpr_int64 dec = 0;
+ int64_t dec = 0;
if (b.clock_type == GPR_TIMESPAN) {
diff.clock_type = a.clock_type;
} else {
@@ -256,7 +256,7 @@ int gpr_time_similar(gpr_timespec a, gpr_timespec b, gpr_timespec threshold) {
}
}
-gpr_int32 gpr_time_to_millis(gpr_timespec t) {
+int32_t 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;
@@ -267,7 +267,7 @@ gpr_int32 gpr_time_to_millis(gpr_timespec t) {
care?) */
return -2147483647;
} else {
- return (gpr_int32)(t.tv_sec * GPR_MS_PER_SEC + t.tv_nsec / GPR_NS_PER_MS);
+ return (int32_t)(t.tv_sec * GPR_MS_PER_SEC + t.tv_nsec / GPR_NS_PER_MS);
}
}
diff --git a/src/core/support/time_posix.c b/src/core/support/time_posix.c
index ba72572e05..06bb78c913 100644
--- a/src/core/support/time_posix.c
+++ b/src/core/support/time_posix.c
@@ -45,7 +45,7 @@
static struct timespec timespec_from_gpr(gpr_timespec gts) {
struct timespec rv;
- if (sizeof(time_t) < sizeof(gpr_int64)) {
+ if (sizeof(time_t) < sizeof(int64_t)) {
/* fine to assert, as this is only used in gpr_sleep_until */
GPR_ASSERT(gts.tv_sec <= INT32_MAX && gts.tv_sec >= INT32_MIN);
}
@@ -64,7 +64,7 @@ static gpr_timespec gpr_from_timespec(struct timespec ts,
*/
gpr_timespec rv;
rv.tv_sec = ts.tv_sec;
- rv.tv_nsec = (gpr_int32)ts.tv_nsec;
+ rv.tv_nsec = (int32_t)ts.tv_nsec;
rv.clock_type = clock_type;
return rv;
}
@@ -119,8 +119,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 = (gpr_int64)(now_dbl * 1e-9);
- now.tv_nsec = (gpr_int32)(now_dbl - ((double)now.tv_sec) * 1e9);
+ now.tv_sec = (int64_t)(now_dbl * 1e-9);
+ now.tv_nsec = (int32_t)(now_dbl - ((double)now.tv_sec) * 1e9);
break;
case GPR_CLOCK_PRECISE:
gpr_precise_clock_now(&now);
diff --git a/src/core/support/time_precise.c b/src/core/support/time_precise.c
index 4de1d9b071..a2cf74bc84 100644
--- a/src/core/support/time_precise.c
+++ b/src/core/support/time_precise.c
@@ -75,8 +75,8 @@ void gpr_precise_clock_now(gpr_timespec *clk) {
gpr_get_cycle_counter(&counter);
secs = (double)(counter - start_cycle) / cycles_per_second;
clk->clock_type = GPR_CLOCK_PRECISE;
- clk->tv_sec = (gpr_int64)secs;
- clk->tv_nsec = (gpr_int32)(1e9 * (secs - (double)clk->tv_sec));
+ clk->tv_sec = (int64_t)secs;
+ clk->tv_nsec = (int32_t)(1e9 * (secs - (double)clk->tv_sec));
}
#else /* GRPC_TIMERS_RDTSC */
diff --git a/src/core/support/time_win32.c b/src/core/support/time_win32.c
index 7ccaaa248d..2bed0f6a9c 100644
--- a/src/core/support/time_win32.c
+++ b/src/core/support/time_win32.c
@@ -62,15 +62,15 @@ gpr_timespec gpr_now(gpr_clock_type clock) {
switch (clock) {
case GPR_CLOCK_REALTIME:
_ftime_s(&now_tb);
- now_tv.tv_sec = (gpr_int64)now_tb.time;
+ now_tv.tv_sec = (int64_t)now_tb.time;
now_tv.tv_nsec = now_tb.millitm * 1000000;
break;
case GPR_CLOCK_MONOTONIC:
case GPR_CLOCK_PRECISE:
QueryPerformanceCounter(&timestamp);
now_dbl = (timestamp.QuadPart - g_start_time.QuadPart) * g_time_scale;
- now_tv.tv_sec = (gpr_int64)now_dbl;
- now_tv.tv_nsec = (gpr_int32)((now_dbl - (double)now_tv.tv_sec) * 1e9);
+ now_tv.tv_sec = (int64_t)now_dbl;
+ now_tv.tv_nsec = (int32_t)((now_dbl - (double)now_tv.tv_sec) * 1e9);
break;
}
return now_tv;
diff --git a/src/core/support/tls_pthread.c b/src/core/support/tls_pthread.c
index 2d28226fc4..9683a6e547 100644
--- a/src/core/support/tls_pthread.c
+++ b/src/core/support/tls_pthread.c
@@ -37,7 +37,7 @@
#include <grpc/support/tls.h>
-gpr_intptr gpr_tls_set(struct gpr_pthread_thread_local *tls, gpr_intptr value) {
+intptr_t gpr_tls_set(struct gpr_pthread_thread_local *tls, intptr_t value) {
GPR_ASSERT(0 == pthread_setspecific(tls->key, (void *)value));
return value;
}