diff --git a/test/benchmark-ping-pongs.c b/test/benchmark-ping-pongs.c index 7731c330..1bda3377 100644 --- a/test/benchmark-ping-pongs.c +++ b/test/benchmark-ping-pongs.c @@ -39,7 +39,7 @@ typedef struct { } pinger_t; typedef struct buf_s { - uv_buf uv_buf; + uv_buf_t uv_buf_t; struct buf_s* next; } buf_t; @@ -52,26 +52,26 @@ static int completed_pingers = 0; static int64_t start_time; -static uv_buf buf_alloc(uv_handle_t* handle, size_t size) { +static uv_buf_t buf_alloc(uv_handle_t* handle, size_t size) { buf_t* ab; ab = buf_freelist; if (ab != NULL) { buf_freelist = ab->next; - return ab->uv_buf; + return ab->uv_buf_t; } ab = (buf_t*) malloc(size + sizeof *ab); - ab->uv_buf.len = size; - ab->uv_buf.base = ((char*) ab) + sizeof *ab; + ab->uv_buf_t.len = size; + ab->uv_buf_t.base = ((char*) ab) + sizeof *ab; - return ab->uv_buf; + return ab->uv_buf_t; } -static void buf_free(uv_buf uv_buf) { - buf_t* ab = (buf_t*) (uv_buf.base - sizeof *ab); +static void buf_free(uv_buf_t uv_buf_t) { + buf_t* ab = (buf_t*) (uv_buf_t.base - sizeof *ab); ab->next = buf_freelist; buf_freelist = ab; @@ -101,7 +101,7 @@ static void pinger_write_cb(uv_req_t *req, int status) { static void pinger_write_ping(pinger_t* pinger) { uv_req_t *req; - uv_buf buf; + uv_buf_t buf; buf.base = (char*)&PING; buf.len = strlen(PING); @@ -120,7 +120,7 @@ static void pinger_shutdown_cb(uv_handle_t* handle, int status) { } -static void pinger_read_cb(uv_handle_t* handle, int nread, uv_buf buf) { +static void pinger_read_cb(uv_handle_t* handle, int nread, uv_buf_t buf) { unsigned int i; pinger_t* pinger; diff --git a/test/benchmark-pump.c b/test/benchmark-pump.c index 69773e13..7ac19f26 100644 --- a/test/benchmark-pump.c +++ b/test/benchmark-pump.c @@ -41,8 +41,8 @@ static void maybe_connect_some(); static uv_req_t* req_alloc(); static void req_free(uv_req_t* uv_req); -static uv_buf buf_alloc(uv_handle_t* handle, size_t size); -static void buf_free(uv_buf uv_buf); +static uv_buf_t buf_alloc(uv_handle_t* handle, size_t size); +static void buf_free(uv_buf_t uv_buf_t); static struct sockaddr_in server_addr; @@ -121,7 +121,7 @@ void close_cb(uv_handle_t* handle, int status) { } -static void read_cb(uv_handle_t* handle, int bytes, uv_buf buf) { +static void read_cb(uv_handle_t* handle, int bytes, uv_buf_t buf) { ASSERT(bytes >= 0); buf_free(buf); @@ -132,7 +132,7 @@ static void read_cb(uv_handle_t* handle, int bytes, uv_buf buf) { static void write_cb(uv_req_t *req, int status) { - uv_buf* buf = (uv_buf*) req->data; + uv_buf_t* buf = (uv_buf_t*) req->data; ASSERT(status == 0); @@ -147,7 +147,7 @@ static void write_cb(uv_req_t *req, int status) { static void do_write(uv_handle_t* handle) { uv_req_t* req; - uv_buf buf; + uv_buf_t buf; int r; buf.base = (char*) &write_buffer; @@ -298,7 +298,7 @@ static void req_free(uv_req_t* uv_req) { */ typedef struct buf_list_s { - uv_buf uv_buf; + uv_buf_t uv_buf_t; struct buf_list_s* next; } buf_list_t; @@ -306,25 +306,25 @@ typedef struct buf_list_s { static buf_list_t* buf_freelist = NULL; -static uv_buf buf_alloc(uv_handle_t* handle, size_t size) { +static uv_buf_t buf_alloc(uv_handle_t* handle, size_t size) { buf_list_t* buf; buf = buf_freelist; if (buf != NULL) { buf_freelist = buf->next; - return buf->uv_buf; + return buf->uv_buf_t; } buf = (buf_list_t*) malloc(size + sizeof *buf); - buf->uv_buf.len = (unsigned int)size; - buf->uv_buf.base = ((char*) buf) + sizeof *buf; + buf->uv_buf_t.len = (unsigned int)size; + buf->uv_buf_t.base = ((char*) buf) + sizeof *buf; - return buf->uv_buf; + return buf->uv_buf_t; } -static void buf_free(uv_buf uv_buf) { - buf_list_t* buf = (buf_list_t*) (uv_buf.base - sizeof *buf); +static void buf_free(uv_buf_t uv_buf_t) { + buf_list_t* buf = (buf_list_t*) (uv_buf_t.base - sizeof *buf); buf->next = buf_freelist; buf_freelist = buf; diff --git a/test/echo-server.c b/test/echo-server.c index 32a415c8..0fcc935f 100644 --- a/test/echo-server.c +++ b/test/echo-server.c @@ -27,7 +27,7 @@ typedef struct { uv_req_t req; - uv_buf buf; + uv_buf_t buf; } write_req_t; @@ -35,7 +35,7 @@ static uv_handle_t server; static void after_write(uv_req_t* req, int status); -static void after_read(uv_handle_t* handle, int nread, uv_buf buf); +static void after_read(uv_handle_t* handle, int nread, uv_buf_t buf); static void on_close(uv_handle_t* peer, int status); static void on_accept(uv_handle_t* handle); @@ -62,7 +62,7 @@ static void after_shutdown(uv_req_t* req, int status) { } -static void after_read(uv_handle_t* handle, int nread, uv_buf buf) { +static void after_read(uv_handle_t* handle, int nread, uv_buf_t buf) { write_req_t *wr; uv_req_t* req; @@ -156,8 +156,8 @@ static int echo_stop() { } -static uv_buf echo_alloc(uv_handle_t* handle, size_t suggested_size) { - uv_buf buf; +static uv_buf_t echo_alloc(uv_handle_t* handle, size_t suggested_size) { + uv_buf_t buf; buf.base = (char*) malloc(suggested_size); buf.len = suggested_size; return buf; diff --git a/test/test-async.c b/test/test-async.c index d43fdcca..7bedcf4a 100644 --- a/test/test-async.c +++ b/test/test-async.c @@ -120,8 +120,8 @@ static void close_cb(uv_handle_t* handle, int status) { } -static uv_buf alloc_cb(uv_handle_t* handle, size_t size) { - uv_buf buf = {0, 0}; +static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) { + uv_buf_t buf = {0, 0}; FATAL("alloc should not be called"); return buf; } diff --git a/test/test-bind-error.c b/test/test-bind-error.c index a29914a9..ca9ccc58 100644 --- a/test/test-bind-error.c +++ b/test/test-bind-error.c @@ -36,8 +36,8 @@ static void close_cb(uv_handle_t* handle, int status) { } -static uv_buf alloc_cb(uv_handle_t* handle, size_t size) { - uv_buf buf = {0, 0}; +static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) { + uv_buf_t buf = {0, 0}; FATAL("alloc should not be called"); return buf; } diff --git a/test/test-callback-stack.c b/test/test-callback-stack.c index 986f863d..5d843b4d 100644 --- a/test/test-callback-stack.c +++ b/test/test-callback-stack.c @@ -58,7 +58,7 @@ static void shutdown_cb(uv_req_t* req, int status) { } -static void read_cb(uv_handle_t* handle, int nread, uv_buf buf) { +static void read_cb(uv_handle_t* handle, int nread, uv_buf_t buf) { ASSERT(nested == 0 && "read_cb must be called from a fresh stack"); printf("Read. nread == %d\n", nread); @@ -138,7 +138,7 @@ static void write_cb(uv_req_t* req, int status) { static void connect_cb(uv_req_t* req, int status) { - uv_buf buf; + uv_buf_t buf; puts("Connected. Write some data to echo server..."); @@ -162,8 +162,8 @@ static void connect_cb(uv_req_t* req, int status) { } -static uv_buf alloc_cb(uv_handle_t* handle, size_t size) { - uv_buf buf; +static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) { + uv_buf_t buf; buf.len = size; buf.base = (char*) malloc(size); ASSERT(buf.base); diff --git a/test/test-connection-fail.c b/test/test-connection-fail.c index ef060d1d..e28c7c36 100644 --- a/test/test-connection-fail.c +++ b/test/test-connection-fail.c @@ -46,8 +46,8 @@ static void on_connect(uv_req_t *req, int status) { } -static uv_buf alloc_cb(uv_handle_t* handle, size_t size) { - uv_buf buf = {0, 0}; +static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) { + uv_buf_t buf = {0, 0}; FATAL("alloc should not be called"); return buf; } diff --git a/test/test-delayed-accept.c b/test/test-delayed-accept.c index 3c8a55f4..796ee19e 100644 --- a/test/test-delayed-accept.c +++ b/test/test-delayed-accept.c @@ -102,7 +102,7 @@ static void start_server() { } -static void read_cb(uv_handle_t* handle, int nread, uv_buf buf) { +static void read_cb(uv_handle_t* handle, int nread, uv_buf_t buf) { /* The server will not send anything, it should close gracefully. */ ASSERT(handle != NULL); ASSERT(nread == -1); @@ -151,8 +151,8 @@ static void client_connect() { } -static uv_buf alloc_cb(uv_handle_t* handle, size_t size) { - uv_buf buf; +static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) { + uv_buf_t buf; buf.base = (char*)malloc(size); buf.len = size; return buf; diff --git a/test/test-loop-handles.c b/test/test-loop-handles.c index 65c84b1b..ae95c036 100644 --- a/test/test-loop-handles.c +++ b/test/test-loop-handles.c @@ -313,8 +313,8 @@ static void prepare_1_close_cb(uv_handle_t* handle, int status){ } -static uv_buf alloc_cb(uv_handle_t* handle, size_t size) { - uv_buf rv = { 0, 0 }; +static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) { + uv_buf_t rv = { 0, 0 }; FATAL("alloc_cb should never be called in this test"); return rv; } diff --git a/test/test-ping-pong.c b/test/test-ping-pong.c index 56ea1db1..13d114e3 100644 --- a/test/test-ping-pong.c +++ b/test/test-ping-pong.c @@ -69,7 +69,7 @@ static void pinger_after_write(uv_req_t *req, int status) { static void pinger_write_ping(pinger_t* pinger) { uv_req_t *req; - uv_buf buf; + uv_buf_t buf; buf.base = (char*)&PING; buf.len = strlen(PING); @@ -85,7 +85,7 @@ static void pinger_write_ping(pinger_t* pinger) { } -static void pinger_read_cb(uv_handle_t* handle, int nread, uv_buf buf) { +static void pinger_read_cb(uv_handle_t* handle, int nread, uv_buf_t buf) { unsigned int i; pinger_t* pinger; @@ -156,8 +156,8 @@ static void pinger_new() { } -static uv_buf alloc_cb(uv_handle_t* handle, size_t size) { - uv_buf buf; +static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) { + uv_buf_t buf; buf.base = (char*)malloc(size); buf.len = size; return buf; diff --git a/test/test-tcp-writealot.c b/test/test-tcp-writealot.c index 99659997..15cc2d5b 100644 --- a/test/test-tcp-writealot.c +++ b/test/test-tcp-writealot.c @@ -72,7 +72,7 @@ static void shutdown_cb(uv_req_t* req, int status) { } -static void read_cb(uv_handle_t* handle, int nread, uv_buf buf) { +static void read_cb(uv_handle_t* handle, int nread, uv_buf_t buf) { ASSERT(handle != NULL); if (nread < 0) { @@ -110,7 +110,7 @@ static void write_cb(uv_req_t* req, int status) { static void connect_cb(uv_req_t* req, int status) { - uv_buf send_bufs[CHUNKS_PER_WRITE]; + uv_buf_t send_bufs[CHUNKS_PER_WRITE]; uv_handle_t* handle; int i, j, r; @@ -134,7 +134,7 @@ static void connect_cb(uv_req_t* req, int status) { ASSERT(req != NULL); uv_req_init(req, handle, write_cb); - r = uv_write(req, (uv_buf*)&send_bufs, CHUNKS_PER_WRITE); + r = uv_write(req, (uv_buf_t*)&send_bufs, CHUNKS_PER_WRITE); ASSERT(r == 0); } @@ -155,8 +155,8 @@ static void connect_cb(uv_req_t* req, int status) { } -static uv_buf alloc_cb(uv_handle_t* handle, size_t size) { - uv_buf buf; +static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) { + uv_buf_t buf; buf.base = (char*)malloc(size); buf.len = size; return buf; diff --git a/test/test-timeout.c b/test/test-timeout.c index ea984eb6..07c8f0fb 100644 --- a/test/test-timeout.c +++ b/test/test-timeout.c @@ -54,8 +54,8 @@ static void dummy_timeout_cb(uv_req_t *req, int64_t skew, int status) { } -static uv_buf alloc_cb(uv_handle_t* handle, size_t size) { - uv_buf buf = {0, 0}; +static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) { + uv_buf_t buf = {0, 0}; FATAL("alloc should not be called"); return buf; } diff --git a/uv-unix.c b/uv-unix.c index 873f6434..2bc54c33 100644 --- a/uv-unix.c +++ b/uv-unix.c @@ -509,10 +509,10 @@ void uv__write(uv_handle_t* handle) { assert(req->handle == handle); - /* Cast to iovec. We had to have our own uv_buf instead of iovec + /* Cast to iovec. We had to have our own uv_buf_t instead of iovec * because Windows's WSABUF is not an iovec. */ - assert(sizeof(uv_buf) == sizeof(struct iovec)); + assert(sizeof(uv_buf_t) == sizeof(struct iovec)); struct iovec* iov = (struct iovec*) &(req->bufs[req->write_index]); int iovcnt = req->bufcnt - req->write_index; @@ -541,7 +541,7 @@ void uv__write(uv_handle_t* handle) { /* The loop updates the counters. */ while (n > 0) { - uv_buf* buf = &(req->bufs[req->write_index]); + uv_buf_t* buf = &(req->bufs[req->write_index]); size_t len = buf->len; assert(req->write_index < req->bufcnt); @@ -607,7 +607,7 @@ void uv__read(uv_handle_t* handle) { */ while (handle->read_cb && uv_flag_is_set(handle, UV_READING)) { assert(alloc_cb); - uv_buf buf = alloc_cb(handle, 64 * 1024); + uv_buf_t buf = alloc_cb(handle, 64 * 1024); assert(buf.len > 0); assert(buf.base); @@ -813,7 +813,7 @@ int uv_connect(uv_req_t* req, struct sockaddr* addr) { } -static size_t uv__buf_count(uv_buf bufs[], int bufcnt) { +static size_t uv__buf_count(uv_buf_t bufs[], int bufcnt) { size_t total = 0; int i; @@ -826,9 +826,9 @@ static size_t uv__buf_count(uv_buf bufs[], int bufcnt) { /* The buffers to be written must remain valid until the callback is called. - * This is not required for the uv_buf array. + * This is not required for the uv_buf_t array. */ -int uv_write(uv_req_t* req, uv_buf bufs[], int bufcnt) { +int uv_write(uv_req_t* req, uv_buf_t bufs[], int bufcnt) { uv_handle_t* handle = req->handle; assert(handle->fd >= 0); @@ -836,8 +836,8 @@ int uv_write(uv_req_t* req, uv_buf bufs[], int bufcnt) { req->type = UV_WRITE; /* TODO: Don't malloc for each write... */ - req->bufs = malloc(sizeof(uv_buf) * bufcnt); - memcpy(req->bufs, bufs, bufcnt * sizeof(uv_buf)); + req->bufs = malloc(sizeof(uv_buf_t) * bufcnt); + memcpy(req->bufs, bufs, bufcnt * sizeof(uv_buf_t)); req->bufcnt = bufcnt; req->write_index = 0; diff --git a/uv-unix.h b/uv-unix.h index b247e583..eb5a5cfa 100644 --- a/uv-unix.h +++ b/uv-unix.h @@ -35,14 +35,14 @@ typedef struct { char* base; size_t len; -} uv_buf; +} uv_buf_t; #define uv_req_private_fields \ int write_index; \ ev_timer timer; \ ngx_queue_t queue; \ - uv_buf* bufs; \ + uv_buf_t* bufs; \ int bufcnt; diff --git a/uv-win.c b/uv-win.c index fc406517..ed2c6bed 100644 --- a/uv-win.c +++ b/uv-win.c @@ -751,7 +751,7 @@ static void uv_queue_accept(uv_handle_t* handle) { static void uv_queue_read(uv_handle_t* handle) { uv_req_t *req; - uv_buf buf; + uv_buf_t buf; int result; DWORD bytes, flags; @@ -926,7 +926,7 @@ int uv_connect(uv_req_t* req, struct sockaddr* addr) { } -static size_t uv_count_bufs(uv_buf bufs[], int count) { +static size_t uv_count_bufs(uv_buf_t bufs[], int count) { size_t bytes = 0; int i; @@ -938,7 +938,7 @@ static size_t uv_count_bufs(uv_buf bufs[], int count) { } -int uv_write(uv_req_t* req, uv_buf bufs[], int bufcnt) { +int uv_write(uv_req_t* req, uv_buf_t bufs[], int bufcnt) { int result; DWORD bytes, err; uv_handle_t* handle = req->handle; @@ -1021,7 +1021,7 @@ int uv_shutdown(uv_req_t* req) { static void uv_tcp_return_req(uv_handle_t* handle, uv_req_t* req) { BOOL success; DWORD bytes, flags, err; - uv_buf buf; + uv_buf_t buf; assert(handle->type == UV_TCP); diff --git a/uv-win.h b/uv-win.h index 2f16197e..45a72f3e 100644 --- a/uv-win.h +++ b/uv-win.h @@ -33,13 +33,13 @@ /** - * It should be possible to cast uv_buf[] to WSABUF[] + * It should be possible to cast uv_buf_t[] to WSABUF[] * see http://msdn.microsoft.com/en-us/library/ms741542(v=vs.85).aspx */ -typedef struct uv_buf { +typedef struct uv_buf_t { ULONG len; char* base; -} uv_buf; +} uv_buf_t; #define uv_req_private_fields \ union { \ diff --git a/uv.h b/uv.h index 93f865a7..e0e7430b 100644 --- a/uv.h +++ b/uv.h @@ -48,11 +48,11 @@ typedef struct uv_req_s uv_req_t; * For uv_close_cb, -1 means that the handle was closed due to an error. * Error details can be obtained by calling uv_last_error(). * - * In the case of uv_read_cb the uv_buf returned should be freed by the + * In the case of uv_read_cb the uv_buf_t returned should be freed by the * user. */ -typedef uv_buf (*uv_alloc_cb)(uv_handle_t* handle, size_t suggested_size); -typedef void (*uv_read_cb)(uv_handle_t *handle, int nread, uv_buf buf); +typedef uv_buf_t (*uv_alloc_cb)(uv_handle_t* handle, size_t suggested_size); +typedef void (*uv_read_cb)(uv_handle_t *handle, int nread, uv_buf_t buf); typedef void (*uv_write_cb)(uv_req_t* req, int status); typedef void (*uv_connect_cb)(uv_req_t* req, int status); typedef void (*uv_shutdown_cb)(uv_req_t* req, int status); @@ -219,7 +219,7 @@ int uv_accept(uv_handle_t* server, uv_handle_t* client, int uv_read_start(uv_handle_t* handle, uv_read_cb cb); int uv_read_stop(uv_handle_t* handle); -int uv_write(uv_req_t* req, uv_buf bufs[], int bufcnt); +int uv_write(uv_req_t* req, uv_buf_t bufs[], int bufcnt); /* Timer methods */ int uv_timeout(uv_req_t* req, int64_t timeout);