From 0b22ca192991aa5fa95e958cd6b010d89915bdb3 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 22 May 2009 19:11:48 +0000 Subject: [PATCH] Use ev_ssize_t in place of ssize_t *everywhere*. svn:r1309 --- buffer.c | 20 ++++++++++---------- buffer_iocp.c | 6 +++--- bufferevent_filter.c | 6 +++--- evbuffer-internal.h | 2 +- include/event2/buffer.h | 2 +- iocp-internal.h | 4 ++-- signal.c | 7 ++----- test/regress_bufferevent.c | 4 ++-- test/regress_iocp.c | 6 +++--- test/regress_zlib.c | 4 ++-- util-internal.h | 3 --- 11 files changed, 29 insertions(+), 35 deletions(-) diff --git a/buffer.c b/buffer.c index 9cadf89d..187bef77 100644 --- a/buffer.c +++ b/buffer.c @@ -463,7 +463,7 @@ evbuffer_get_contiguous_space(const struct evbuffer *buf) } int -evbuffer_reserve_space(struct evbuffer *buf, ssize_t size, +evbuffer_reserve_space(struct evbuffer *buf, ev_ssize_t size, struct evbuffer_iovec *vec, int n_vecs) { struct evbuffer_chain *chain; @@ -863,11 +863,11 @@ done: } unsigned char * -evbuffer_pullup(struct evbuffer *buf, ssize_t size) +evbuffer_pullup(struct evbuffer *buf, ev_ssize_t size) { struct evbuffer_chain *chain, *next, *tmp; unsigned char *buffer, *result = NULL; - ssize_t remaining; + ev_ssize_t remaining; EVBUFFER_LOCK(buf, EVTHREAD_WRITE); @@ -1492,7 +1492,7 @@ _evbuffer_expand_fast(struct evbuffer *buf, size_t datlen) @return The number of buffers we're using. */ int -_evbuffer_read_setup_vecs(struct evbuffer *buf, ssize_t howmuch, +_evbuffer_read_setup_vecs(struct evbuffer *buf, ev_ssize_t howmuch, struct evbuffer_iovec *vecs, struct evbuffer_chain **chainp, int exact) { struct evbuffer_chain *chain; @@ -1541,7 +1541,7 @@ _evbuffer_read_setup_vecs(struct evbuffer *buf, ssize_t howmuch, return nvecs; } -/* TODO(niels): should this function return ssize_t and take ssize_t +/* TODO(niels): should this function return ev_ssize_t and take ev_ssize_t * as howmuch? */ int evbuffer_read(struct evbuffer *buf, evutil_socket_t fd, int howmuch) @@ -1667,7 +1667,7 @@ evbuffer_read(struct evbuffer *buf, evutil_socket_t fd, int howmuch) #ifdef USE_IOVEC_IMPL if (nvecs == 2) { - ssize_t space = CHAIN_SPACE_LEN(chain); + ev_ssize_t space = CHAIN_SPACE_LEN(chain); if (space < n) { chain->off += space; chain->next->off += n-space; @@ -1741,7 +1741,7 @@ ssize_t howmuch) #ifdef USE_SENDFILE static inline int evbuffer_write_sendfile(struct evbuffer *buffer, evutil_socket_t fd, - ssize_t howmuch) + ev_ssize_t howmuch) { struct evbuffer_chain *chain = buffer->first; struct evbuffer_chain_fd *info = @@ -1750,7 +1750,7 @@ evbuffer_write_sendfile(struct evbuffer *buffer, evutil_socket_t fd, int res; off_t len = chain->off; #elif SENDFILE_IS_LINUX - ssize_t res; + ev_ssize_t res; off_t offset = chain->misalign; #endif @@ -1782,7 +1782,7 @@ evbuffer_write_sendfile(struct evbuffer *buffer, evutil_socket_t fd, int evbuffer_write_atmost(struct evbuffer *buffer, evutil_socket_t fd, - ssize_t howmuch) + ev_ssize_t howmuch) { int n = -1; @@ -2233,7 +2233,7 @@ evbuffer_add_file(struct evbuffer *outbuf, int fd, { /* the default implementation */ struct evbuffer *tmp = evbuffer_new(); - ssize_t read; + ev_ssize_t read; if (tmp == NULL) return (-1); diff --git a/buffer_iocp.c b/buffer_iocp.c index 2b22d50a..565f232f 100644 --- a/buffer_iocp.c +++ b/buffer_iocp.c @@ -111,7 +111,7 @@ pin_release(struct event_overlapped *eo, unsigned flag) /** IOCP callback invoked when a read operation is finished. */ static void -read_completed(struct event_overlapped *eo, uintptr_t _, ssize_t nBytes) +read_completed(struct event_overlapped *eo, uintptr_t _, ev_ssize_t nBytes) { struct buffer_overlapped *buf_o = upcast_overlapped(eo); struct evbuffer_overlapped *buf = buf_o->buf; @@ -145,7 +145,7 @@ read_completed(struct event_overlapped *eo, uintptr_t _, ssize_t nBytes) /** IOCP callback invoked when a write operation is finished. */ static void -write_completed(struct event_overlapped *eo, uintptr_t _, ssize_t nBytes) +write_completed(struct event_overlapped *eo, uintptr_t _, ev_ssize_t nBytes) { struct buffer_overlapped *buf_o = upcast_overlapped(eo); struct evbuffer_overlapped *buf = buf_o->buf; @@ -177,7 +177,7 @@ evbuffer_overlapped_new(evutil_socket_t fd) } int -evbuffer_launch_write(struct evbuffer *buf, ssize_t at_most) +evbuffer_launch_write(struct evbuffer *buf, ev_ssize_t at_most) { struct evbuffer_overlapped *buf_o = upcast_evbuffer(buf); int r = -1; diff --git a/bufferevent_filter.c b/bufferevent_filter.c index 3c5a1d4a..3b51e500 100644 --- a/bufferevent_filter.c +++ b/bufferevent_filter.c @@ -152,7 +152,7 @@ be_readbuf_full(struct bufferevent_filtered *bevf, /* Filter to use when we're created with a NULL filter. */ static enum bufferevent_filter_result -be_null_filter(struct evbuffer *src, struct evbuffer *dst, ssize_t lim, +be_null_filter(struct evbuffer *src, struct evbuffer *dst, ev_ssize_t lim, enum bufferevent_flush_mode state, void *ctx) { (void)state; @@ -268,7 +268,7 @@ be_filter_process_input(struct bufferevent_filtered *bevf, } do { - ssize_t limit = -1; + ev_ssize_t limit = -1; if (state == BEV_NORMAL && bev->wm_read.high) limit = bev->wm_read.high - evbuffer_get_length(bev->input); @@ -317,7 +317,7 @@ be_filter_process_output(struct bufferevent_filtered *bevf, again = 0; do { - ssize_t limit = -1; + ev_ssize_t limit = -1; if (state == BEV_NORMAL && bevf->underlying->wm_write.high) limit = bevf->underlying->wm_write.high - diff --git a/evbuffer-internal.h b/evbuffer-internal.h index 10263cbe..8e94f607 100644 --- a/evbuffer-internal.h +++ b/evbuffer-internal.h @@ -263,7 +263,7 @@ int _evbuffer_expand_fast(struct evbuffer *, size_t); * extent, and *chainp to poitn to the first chain that we'll try to read into. * Returns the number of vecs used. */ -int _evbuffer_read_setup_vecs(struct evbuffer *buf, ssize_t howmuch, +int _evbuffer_read_setup_vecs(struct evbuffer *buf, ev_ssize_t howmuch, struct evbuffer_iovec *vecs, struct evbuffer_chain **chainp, int exact); /* Helper macro: copies an evbuffer_iovec in ei to a win32 WSABUF in i. */ diff --git a/include/event2/buffer.h b/include/event2/buffer.h index e9c83490..4e8eeec5 100644 --- a/include/event2/buffer.h +++ b/include/event2/buffer.h @@ -219,7 +219,7 @@ int evbuffer_expand(struct evbuffer *buf, size_t datlen); @see evbuffer_commit_space */ int -evbuffer_reserve_space(struct evbuffer *buf, ssize_t size, +evbuffer_reserve_space(struct evbuffer *buf, ev_ssize_t size, struct evbuffer_iovec *vec, int n_vecs); /** diff --git a/iocp-internal.h b/iocp-internal.h index ac76e848..f03409f1 100644 --- a/iocp-internal.h +++ b/iocp-internal.h @@ -34,7 +34,7 @@ extern "C" { struct event_overlapped; struct event_iocp_port; struct evbuffer; -typedef void (*iocp_callback)(struct event_overlapped *, uintptr_t, ssize_t); +typedef void (*iocp_callback)(struct event_overlapped *, uintptr_t, ev_ssize_t); /* This whole file is actually win32 only. We wrap the structures in a win32 * ifdef so that we can test-compile code that uses these interfaces on @@ -122,7 +122,7 @@ int evbuffer_launch_read(struct evbuffer *, size_t n); @param n The number of bytes to try to read. @return 0 on success, -1 on error. */ -int evbuffer_launch_write(struct evbuffer *, ssize_t n); +int evbuffer_launch_write(struct evbuffer *, ev_ssize_t n); /** Create an IOCP, and launch its worker threads. Internal use only. diff --git a/signal.c b/signal.c index f3531b86..188d6b00 100644 --- a/signal.c +++ b/signal.c @@ -87,11 +87,8 @@ static void evsig_cb(evutil_socket_t fd, short what, void *arg) { static char signals[1]; -#ifdef WIN32 - SSIZE_T n; -#else - ssize_t n; -#endif + ev_ssize_t n; + (void)arg; /* Suppress "unused variable" warning. */ n = recv(fd, signals, sizeof(signals), 0); diff --git a/test/regress_bufferevent.c b/test/regress_bufferevent.c index ce2a455d..4169ebfc 100644 --- a/test/regress_bufferevent.c +++ b/test/regress_bufferevent.c @@ -273,7 +273,7 @@ test_bufferevent_pair_watermarks(void) static enum bufferevent_filter_result bufferevent_input_filter(struct evbuffer *src, struct evbuffer *dst, - ssize_t lim, enum bufferevent_flush_mode state, void *ctx) + ev_ssize_t lim, enum bufferevent_flush_mode state, void *ctx) { const unsigned char *buffer; int i; @@ -295,7 +295,7 @@ bufferevent_input_filter(struct evbuffer *src, struct evbuffer *dst, static enum bufferevent_filter_result bufferevent_output_filter(struct evbuffer *src, struct evbuffer *dst, - ssize_t lim, enum bufferevent_flush_mode state, void *ctx) + ev_ssize_t lim, enum bufferevent_flush_mode state, void *ctx) { const unsigned char *buffer; int i; diff --git a/test/regress_iocp.c b/test/regress_iocp.c index ab31806d..d103c710 100644 --- a/test/regress_iocp.c +++ b/test/regress_iocp.c @@ -49,11 +49,11 @@ struct dummy_overlapped { void *lock; int call_count; uintptr_t keys[MAX_CALLS]; - ssize_t sizes[MAX_CALLS]; + ev_ssize_t sizes[MAX_CALLS]; }; static void -dummy_cb(struct event_overlapped *o, uintptr_t key, ssize_t n) +dummy_cb(struct event_overlapped *o, uintptr_t key, ev_ssize_t n) { struct dummy_overlapped *d_o = EVUTIL_UPCAST(o, struct dummy_overlapped, eo); @@ -68,7 +68,7 @@ dummy_cb(struct event_overlapped *o, uintptr_t key, ssize_t n) } static int -pair_is_in(struct dummy_overlapped *o, uintptr_t key, ssize_t n) +pair_is_in(struct dummy_overlapped *o, uintptr_t key, ev_ssize_t n) { int i; int result = 0; diff --git a/test/regress_zlib.c b/test/regress_zlib.c index d171b587..966bb147 100644 --- a/test/regress_zlib.c +++ b/test/regress_zlib.c @@ -104,7 +104,7 @@ getstate(enum bufferevent_flush_mode state) */ static enum bufferevent_filter_result zlib_input_filter(struct evbuffer *src, struct evbuffer *dst, - ssize_t lim, enum bufferevent_flush_mode state, void *ctx) + ev_ssize_t lim, enum bufferevent_flush_mode state, void *ctx) { struct evbuffer_iovec v_in[1]; struct evbuffer_iovec v_out[1]; @@ -158,7 +158,7 @@ zlib_input_filter(struct evbuffer *src, struct evbuffer *dst, static enum bufferevent_filter_result zlib_output_filter(struct evbuffer *src, struct evbuffer *dst, - ssize_t lim, enum bufferevent_flush_mode state, void *ctx) + ev_ssize_t lim, enum bufferevent_flush_mode state, void *ctx) { struct evbuffer_iovec v_in[1]; struct evbuffer_iovec v_out[1]; diff --git a/util-internal.h b/util-internal.h index cc61ea24..b2a371e0 100644 --- a/util-internal.h +++ b/util-internal.h @@ -40,9 +40,6 @@ extern "C" { #ifdef _EVENT___func__ #define __func__ _EVENT___func__ #endif -#ifdef _EVENT_ssize_t -#define ssize_t _EVENT_ssize_t -#endif /* A good no-op to use in macro definitions. */ #define _EVUTIL_NIL_STMT ((void)0) -- 2.40.0