aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/iomgr
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2015-12-22 13:49:30 -0800
committerGravatar Craig Tiller <ctiller@google.com>2015-12-22 13:49:30 -0800
commit7536af02cf218f8dcb1368bec6d86c65db95c9b4 (patch)
treecd560e1321aed28504aca5358dabbf49692a0956 /src/core/iomgr
parent2d2963e5e919128929e8a62a17fbbc9f3fd684d9 (diff)
Eliminate gpr_ int types - and insist on C99 variants instead
Diffstat (limited to 'src/core/iomgr')
-rw-r--r--src/core/iomgr/closure.c6
-rw-r--r--src/core/iomgr/closure.h2
-rw-r--r--src/core/iomgr/exec_ctx.c2
-rw-r--r--src/core/iomgr/fd_posix.c8
-rw-r--r--src/core/iomgr/fd_posix.h6
-rw-r--r--src/core/iomgr/iocp_windows.c2
-rw-r--r--src/core/iomgr/pollset_posix.c15
-rw-r--r--src/core/iomgr/pollset_posix.h2
-rw-r--r--src/core/iomgr/sockaddr_utils.c12
-rw-r--r--src/core/iomgr/tcp_server_posix.c2
-rw-r--r--src/core/iomgr/tcp_server_windows.c2
-rw-r--r--src/core/iomgr/timer.c10
-rw-r--r--src/core/iomgr/timer.h2
-rw-r--r--src/core/iomgr/timer_heap.c20
-rw-r--r--src/core/iomgr/timer_heap.h4
-rw-r--r--src/core/iomgr/udp_server.c2
16 files changed, 48 insertions, 49 deletions
diff --git a/src/core/iomgr/closure.c b/src/core/iomgr/closure.c
index 4aae52a454..7646a88ac5 100644
--- a/src/core/iomgr/closure.c
+++ b/src/core/iomgr/closure.c
@@ -49,7 +49,7 @@ void grpc_closure_list_add(grpc_closure_list *closure_list,
if (closure_list->head == NULL) {
closure_list->head = closure;
} else {
- closure_list->tail->final_data |= (gpr_uintptr)closure;
+ closure_list->tail->final_data |= (uintptr_t)closure;
}
closure_list->tail = closure;
}
@@ -65,7 +65,7 @@ void grpc_closure_list_move(grpc_closure_list *src, grpc_closure_list *dst) {
if (dst->head == NULL) {
*dst = *src;
} else {
- dst->tail->final_data |= (gpr_uintptr)src->head;
+ dst->tail->final_data |= (uintptr_t)src->head;
dst->tail = src->tail;
}
src->head = src->tail = NULL;
@@ -94,5 +94,5 @@ grpc_closure *grpc_closure_create(grpc_iomgr_cb_func cb, void *cb_arg) {
}
grpc_closure *grpc_closure_next(grpc_closure *closure) {
- return (grpc_closure *)(closure->final_data & ~(gpr_uintptr)1);
+ return (grpc_closure *)(closure->final_data & ~(uintptr_t)1);
}
diff --git a/src/core/iomgr/closure.h b/src/core/iomgr/closure.h
index a1d738bf5a..98ef91e1db 100644
--- a/src/core/iomgr/closure.h
+++ b/src/core/iomgr/closure.h
@@ -67,7 +67,7 @@ struct grpc_closure {
/** Once enqueued, contains in the lower bit the success of the closure,
and in the upper bits the pointer to the next closure in the list.
Before enqueing for execution, this is usable for scratch data. */
- gpr_uintptr final_data;
+ uintptr_t final_data;
};
/** Initializes \a closure with \a cb and \a cb_arg. */
diff --git a/src/core/iomgr/exec_ctx.c b/src/core/iomgr/exec_ctx.c
index e95eaf267a..6059a6031c 100644
--- a/src/core/iomgr/exec_ctx.c
+++ b/src/core/iomgr/exec_ctx.c
@@ -45,7 +45,7 @@ int grpc_exec_ctx_flush(grpc_exec_ctx *exec_ctx) {
exec_ctx->closure_list.head = exec_ctx->closure_list.tail = NULL;
while (c != NULL) {
int success = (int)(c->final_data & 1);
- grpc_closure *next = (grpc_closure *)(c->final_data & ~(gpr_uintptr)1);
+ grpc_closure *next = (grpc_closure *)(c->final_data & ~(uintptr_t)1);
did_something++;
GPR_TIMER_BEGIN("grpc_exec_ctx_flush.cb", 0);
c->cb(exec_ctx, c->cb_arg, success);
diff --git a/src/core/iomgr/fd_posix.c b/src/core/iomgr/fd_posix.c
index 00710d83bd..3e28f0ffb4 100644
--- a/src/core/iomgr/fd_posix.c
+++ b/src/core/iomgr/fd_posix.c
@@ -318,10 +318,10 @@ void grpc_fd_notify_on_write(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
gpr_mu_unlock(&fd->mu);
}
-gpr_uint32 grpc_fd_begin_poll(grpc_fd *fd, grpc_pollset *pollset,
- grpc_pollset_worker *worker, gpr_uint32 read_mask,
- gpr_uint32 write_mask, grpc_fd_watcher *watcher) {
- gpr_uint32 mask = 0;
+uint32_t grpc_fd_begin_poll(grpc_fd *fd, grpc_pollset *pollset,
+ grpc_pollset_worker *worker, uint32_t read_mask,
+ uint32_t write_mask, grpc_fd_watcher *watcher) {
+ uint32_t mask = 0;
grpc_closure *cur;
int requested;
/* keep track of pollers that have requested our events, in case they change
diff --git a/src/core/iomgr/fd_posix.h b/src/core/iomgr/fd_posix.h
index df4eb64d4c..d088749408 100644
--- a/src/core/iomgr/fd_posix.h
+++ b/src/core/iomgr/fd_posix.h
@@ -126,9 +126,9 @@ void grpc_fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd, grpc_closure *on_done,
Polling strategies that do not need to alter their behavior depending on the
fd's current interest (such as epoll) do not need to call this function.
MUST NOT be called with a pollset lock taken */
-gpr_uint32 grpc_fd_begin_poll(grpc_fd *fd, grpc_pollset *pollset,
- grpc_pollset_worker *worker, gpr_uint32 read_mask,
- gpr_uint32 write_mask, grpc_fd_watcher *rec);
+uint32_t grpc_fd_begin_poll(grpc_fd *fd, grpc_pollset *pollset,
+ grpc_pollset_worker *worker, uint32_t read_mask,
+ uint32_t write_mask, grpc_fd_watcher *rec);
/* Complete polling previously started with grpc_fd_begin_poll
MUST NOT be called with a pollset lock taken
if got_read or got_write are 1, also does the become_{readable,writable} as
diff --git a/src/core/iomgr/iocp_windows.c b/src/core/iomgr/iocp_windows.c
index 65da3a9d2d..d3868ce62c 100644
--- a/src/core/iomgr/iocp_windows.c
+++ b/src/core/iomgr/iocp_windows.c
@@ -160,7 +160,7 @@ void grpc_iocp_add_socket(grpc_winsocket *socket) {
HANDLE ret;
if (socket->added_to_iocp) return;
ret = CreateIoCompletionPort((HANDLE)socket->socket, g_iocp,
- (gpr_uintptr)socket, 0);
+ (uintptr_t)socket, 0);
if (!ret) {
char *utf8_message = gpr_format_message(WSAGetLastError());
gpr_log(GPR_ERROR, "Unable to add socket to iocp: %s", utf8_message);
diff --git a/src/core/iomgr/pollset_posix.c b/src/core/iomgr/pollset_posix.c
index 9195344758..c325b634ae 100644
--- a/src/core/iomgr/pollset_posix.c
+++ b/src/core/iomgr/pollset_posix.c
@@ -100,7 +100,7 @@ static void push_front_worker(grpc_pollset *p, grpc_pollset_worker *worker) {
void grpc_pollset_kick_ext(grpc_pollset *p,
grpc_pollset_worker *specific_worker,
- gpr_uint32 flags) {
+ uint32_t flags) {
GPR_TIMER_BEGIN("grpc_pollset_kick_ext", 0);
/* pollset->mu already held */
@@ -116,7 +116,7 @@ void grpc_pollset_kick_ext(grpc_pollset *p,
p->kicked_without_pollers = 1;
GPR_TIMER_END("grpc_pollset_kick_ext.broadcast", 0);
} else if (gpr_tls_get(&g_current_thread_worker) !=
- (gpr_intptr)specific_worker) {
+ (intptr_t)specific_worker) {
GPR_TIMER_MARK("different_thread_worker", 0);
if ((flags & GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP) != 0) {
specific_worker->reevaluate_polling_on_wakeup = 1;
@@ -131,19 +131,18 @@ void grpc_pollset_kick_ext(grpc_pollset *p,
specific_worker->kicked_specifically = 1;
grpc_wakeup_fd_wakeup(&specific_worker->wakeup_fd->fd);
}
- } else if (gpr_tls_get(&g_current_thread_poller) != (gpr_intptr)p) {
+ } else if (gpr_tls_get(&g_current_thread_poller) != (intptr_t)p) {
GPR_ASSERT((flags & GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP) == 0);
GPR_TIMER_MARK("kick_anonymous", 0);
specific_worker = pop_front_worker(p);
if (specific_worker != NULL) {
- if (gpr_tls_get(&g_current_thread_worker) ==
- (gpr_intptr)specific_worker) {
+ if (gpr_tls_get(&g_current_thread_worker) == (intptr_t)specific_worker) {
GPR_TIMER_MARK("kick_anonymous_not_self", 0);
push_back_worker(p, specific_worker);
specific_worker = pop_front_worker(p);
if ((flags & GRPC_POLLSET_CAN_KICK_SELF) == 0 &&
gpr_tls_get(&g_current_thread_worker) ==
- (gpr_intptr)specific_worker) {
+ (intptr_t)specific_worker) {
push_back_worker(p, specific_worker);
specific_worker = NULL;
}
@@ -307,9 +306,9 @@ void grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
if (!added_worker) {
push_front_worker(pollset, worker);
added_worker = 1;
- gpr_tls_set(&g_current_thread_worker, (gpr_intptr)worker);
+ gpr_tls_set(&g_current_thread_worker, (intptr_t)worker);
}
- gpr_tls_set(&g_current_thread_poller, (gpr_intptr)pollset);
+ gpr_tls_set(&g_current_thread_poller, (intptr_t)pollset);
GPR_TIMER_BEGIN("maybe_work_and_unlock", 0);
pollset->vtable->maybe_work_and_unlock(exec_ctx, pollset, worker,
deadline, now);
diff --git a/src/core/iomgr/pollset_posix.h b/src/core/iomgr/pollset_posix.h
index 29de4a2026..78fc27d2b3 100644
--- a/src/core/iomgr/pollset_posix.h
+++ b/src/core/iomgr/pollset_posix.h
@@ -122,7 +122,7 @@ int grpc_poll_deadline_to_millis_timeout(gpr_timespec deadline,
-- mostly for fd_posix's use. */
void grpc_pollset_kick_ext(grpc_pollset *p,
grpc_pollset_worker *specific_worker,
- gpr_uint32 flags);
+ uint32_t flags);
/* turn a pollset into a multipoller: platform specific */
typedef void (*grpc_platform_become_multipoller_type)(grpc_exec_ctx *exec_ctx,
diff --git a/src/core/iomgr/sockaddr_utils.c b/src/core/iomgr/sockaddr_utils.c
index 511a5d5c59..61006d7a7a 100644
--- a/src/core/iomgr/sockaddr_utils.c
+++ b/src/core/iomgr/sockaddr_utils.c
@@ -48,8 +48,8 @@
#include "src/core/support/string.h"
-static const gpr_uint8 kV4MappedPrefix[] = {0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xff, 0xff};
+static const uint8_t kV4MappedPrefix[] = {0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xff, 0xff};
int grpc_sockaddr_is_v4mapped(const struct sockaddr *addr,
struct sockaddr_in *addr4_out) {
@@ -126,14 +126,14 @@ void grpc_sockaddr_make_wildcard4(int port, struct sockaddr_in *wild_out) {
GPR_ASSERT(port >= 0 && port < 65536);
memset(wild_out, 0, sizeof(*wild_out));
wild_out->sin_family = AF_INET;
- wild_out->sin_port = htons((gpr_uint16)port);
+ wild_out->sin_port = htons((uint16_t)port);
}
void grpc_sockaddr_make_wildcard6(int port, struct sockaddr_in6 *wild_out) {
GPR_ASSERT(port >= 0 && port < 65536);
memset(wild_out, 0, sizeof(*wild_out));
wild_out->sin6_family = AF_INET6;
- wild_out->sin6_port = htons((gpr_uint16)port);
+ wild_out->sin6_port = htons((uint16_t)port);
}
int grpc_sockaddr_to_string(char **out, const struct sockaddr *addr,
@@ -220,11 +220,11 @@ int grpc_sockaddr_set_port(const struct sockaddr *addr, int port) {
switch (addr->sa_family) {
case AF_INET:
GPR_ASSERT(port >= 0 && port < 65536);
- ((struct sockaddr_in *)addr)->sin_port = htons((gpr_uint16)port);
+ ((struct sockaddr_in *)addr)->sin_port = htons((uint16_t)port);
return 1;
case AF_INET6:
GPR_ASSERT(port >= 0 && port < 65536);
- ((struct sockaddr_in6 *)addr)->sin6_port = htons((gpr_uint16)port);
+ ((struct sockaddr_in6 *)addr)->sin6_port = htons((uint16_t)port);
return 1;
default:
gpr_log(GPR_ERROR, "Unknown socket family %d in grpc_sockaddr_set_port",
diff --git a/src/core/iomgr/tcp_server_posix.c b/src/core/iomgr/tcp_server_posix.c
index 835675c390..49e83cf6ae 100644
--- a/src/core/iomgr/tcp_server_posix.c
+++ b/src/core/iomgr/tcp_server_posix.c
@@ -78,7 +78,7 @@ struct grpc_tcp_listener {
grpc_fd *emfd;
grpc_tcp_server *server;
union {
- gpr_uint8 untyped[GRPC_MAX_SOCKADDR_SIZE];
+ uint8_t untyped[GRPC_MAX_SOCKADDR_SIZE];
struct sockaddr sockaddr;
struct sockaddr_un un;
} addr;
diff --git a/src/core/iomgr/tcp_server_windows.c b/src/core/iomgr/tcp_server_windows.c
index 583cab4890..d38fd8860a 100644
--- a/src/core/iomgr/tcp_server_windows.c
+++ b/src/core/iomgr/tcp_server_windows.c
@@ -58,7 +58,7 @@
struct grpc_tcp_listener {
/* This seemingly magic number comes from AcceptEx's documentation. each
address buffer needs to have at least 16 more bytes at their end. */
- gpr_uint8 addresses[(sizeof(struct sockaddr_in6) + 16) * 2];
+ uint8_t addresses[(sizeof(struct sockaddr_in6) + 16) * 2];
/* This will hold the socket for the next accept. */
SOCKET new_socket;
/* The listener winsocket. */
diff --git a/src/core/iomgr/timer.c b/src/core/iomgr/timer.c
index bbf9800049..24d6204e07 100644
--- a/src/core/iomgr/timer.c
+++ b/src/core/iomgr/timer.c
@@ -55,7 +55,7 @@ typedef struct {
gpr_timespec queue_deadline_cap;
gpr_timespec min_deadline;
/* Index in the g_shard_queue */
- gpr_uint32 shard_queue_index;
+ uint32_t shard_queue_index;
/* This holds all timers with deadlines < queue_deadline_cap. Timers in this
list have the top bit of their deadline set to 0. */
grpc_timer_heap heap;
@@ -82,7 +82,7 @@ static gpr_timespec compute_min_deadline(shard_type *shard) {
}
void grpc_timer_list_init(gpr_timespec now) {
- gpr_uint32 i;
+ uint32_t i;
gpr_mu_init(&g_mu);
gpr_mu_init(&g_checker_mu);
@@ -126,8 +126,8 @@ static double ts_to_dbl(gpr_timespec ts) {
static gpr_timespec dbl_to_ts(double d) {
gpr_timespec ts;
- ts.tv_sec = (gpr_int64)d;
- ts.tv_nsec = (gpr_int32)(1e9 * (d - (double)ts.tv_sec));
+ ts.tv_sec = (int64_t)d;
+ ts.tv_nsec = (int32_t)(1e9 * (d - (double)ts.tv_sec));
ts.clock_type = GPR_TIMESPAN;
return ts;
}
@@ -143,7 +143,7 @@ static void list_remove(grpc_timer *timer) {
timer->prev->next = timer->next;
}
-static void swap_adjacent_shards_in_queue(gpr_uint32 first_shard_queue_index) {
+static void swap_adjacent_shards_in_queue(uint32_t first_shard_queue_index) {
shard_type *temp;
temp = g_shard_queue[first_shard_queue_index];
g_shard_queue[first_shard_queue_index] =
diff --git a/src/core/iomgr/timer.h b/src/core/iomgr/timer.h
index 9abe58133d..720c9d5ab9 100644
--- a/src/core/iomgr/timer.h
+++ b/src/core/iomgr/timer.h
@@ -41,7 +41,7 @@
typedef struct grpc_timer {
gpr_timespec deadline;
- gpr_uint32 heap_index; /* INVALID_HEAP_INDEX if not in heap */
+ uint32_t heap_index; /* INVALID_HEAP_INDEX if not in heap */
int triggered;
struct grpc_timer *next;
struct grpc_timer *prev;
diff --git a/src/core/iomgr/timer_heap.c b/src/core/iomgr/timer_heap.c
index 31d41d6750..9d8be5c1fc 100644
--- a/src/core/iomgr/timer_heap.c
+++ b/src/core/iomgr/timer_heap.c
@@ -43,9 +43,9 @@
position. This functor is called each time immediately after modifying a
value in the underlying container, with the offset of the modified element as
its argument. */
-static void adjust_upwards(grpc_timer **first, gpr_uint32 i, grpc_timer *t) {
+static void adjust_upwards(grpc_timer **first, uint32_t i, grpc_timer *t) {
while (i > 0) {
- gpr_uint32 parent = (gpr_uint32)(((int)i - 1) / 2);
+ uint32_t parent = (uint32_t)(((int)i - 1) / 2);
if (gpr_time_cmp(first[parent]->deadline, t->deadline) >= 0) break;
first[i] = first[parent];
first[i]->heap_index = i;
@@ -58,12 +58,12 @@ static void adjust_upwards(grpc_timer **first, gpr_uint32 i, grpc_timer *t) {
/* Adjusts a heap so as to move a hole at position i farther away from the root,
until a suitable position is found for element t. Then, copies t into that
position. */
-static void adjust_downwards(grpc_timer **first, gpr_uint32 i,
- gpr_uint32 length, grpc_timer *t) {
+static void adjust_downwards(grpc_timer **first, uint32_t i, uint32_t length,
+ grpc_timer *t) {
for (;;) {
- gpr_uint32 left_child = 1u + 2u * i;
- gpr_uint32 right_child;
- gpr_uint32 next_i;
+ uint32_t left_child = 1u + 2u * i;
+ uint32_t right_child;
+ uint32_t next_i;
if (left_child >= length) break;
right_child = left_child + 1;
next_i = right_child < length &&
@@ -93,8 +93,8 @@ static void maybe_shrink(grpc_timer_heap *heap) {
}
static void note_changed_priority(grpc_timer_heap *heap, grpc_timer *timer) {
- gpr_uint32 i = timer->heap_index;
- gpr_uint32 parent = (gpr_uint32)(((int)i - 1) / 2);
+ uint32_t i = timer->heap_index;
+ uint32_t parent = (uint32_t)(((int)i - 1) / 2);
if (gpr_time_cmp(heap->timers[parent]->deadline, timer->deadline) < 0) {
adjust_upwards(heap->timers, i, timer);
} else {
@@ -122,7 +122,7 @@ int grpc_timer_heap_add(grpc_timer_heap *heap, grpc_timer *timer) {
}
void grpc_timer_heap_remove(grpc_timer_heap *heap, grpc_timer *timer) {
- gpr_uint32 i = timer->heap_index;
+ uint32_t i = timer->heap_index;
if (i == heap->timer_count - 1) {
heap->timer_count--;
maybe_shrink(heap);
diff --git a/src/core/iomgr/timer_heap.h b/src/core/iomgr/timer_heap.h
index cd5258f93e..2d220f1677 100644
--- a/src/core/iomgr/timer_heap.h
+++ b/src/core/iomgr/timer_heap.h
@@ -38,8 +38,8 @@
typedef struct {
grpc_timer **timers;
- gpr_uint32 timer_count;
- gpr_uint32 timer_capacity;
+ uint32_t timer_count;
+ uint32_t timer_capacity;
} grpc_timer_heap;
/* return 1 if the new timer is the first timer in the heap */
diff --git a/src/core/iomgr/udp_server.c b/src/core/iomgr/udp_server.c
index 28f1bfae26..a1a6b04cad 100644
--- a/src/core/iomgr/udp_server.c
+++ b/src/core/iomgr/udp_server.c
@@ -75,7 +75,7 @@ typedef struct {
grpc_fd *emfd;
grpc_udp_server *server;
union {
- gpr_uint8 untyped[GRPC_MAX_SOCKADDR_SIZE];
+ uint8_t untyped[GRPC_MAX_SOCKADDR_SIZE];
struct sockaddr sockaddr;
struct sockaddr_un un;
} addr;