From 5b5b880be7452eaf42d401f3ad54474ae60a9dbf Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 28 Jul 2009 19:41:39 +0000 Subject: [PATCH] Various MSVC cleanups from Brodie Thiesfield. svn:r1385 --- WIN32-Code/event-config.h | 2 ++ WIN32-Code/win32.c | 3 ++- buffer_iocp.c | 1 + evdns.c | 1 + event.h | 1 + event_iocp.c | 1 + evmap.c | 3 ++- include/event2/event_struct.h | 1 + log.c | 3 ++- sample/event-test.c | 1 + sample/signal-test.c | 1 + test/regress_dns.c | 9 +++++---- test/regress_et.c | 4 +++- test/regress_http.c | 4 ++-- test/regress_main.c | 1 + test/tinytest.c | 7 +++++-- 16 files changed, 31 insertions(+), 12 deletions(-) diff --git a/WIN32-Code/event-config.h b/WIN32-Code/event-config.h index be1e4c56..6c85329b 100644 --- a/WIN32-Code/event-config.h +++ b/WIN32-Code/event-config.h @@ -334,4 +334,6 @@ /* Define to `int' if does not define. */ #define _EVENT_ssize_t intptr_t +#define ssize_t SSIZE_T + #endif diff --git a/WIN32-Code/win32.c b/WIN32-Code/win32.c index d809bf2e..6c8ba217 100644 --- a/WIN32-Code/win32.c +++ b/WIN32-Code/win32.c @@ -334,11 +334,12 @@ win32_dispatch(struct event_base *base, struct timeval *tv) } } if (win32op->writeset_out->fd_count) { + SOCKET s; i = rand() % win32op->writeset_out->fd_count; for (j=0; jwriteset_out->fd_count; ++j) { if (++i >= win32op->writeset_out->fd_count) i = 0; - SOCKET s = win32op->writeset_out->fd_array[i]; + s = win32op->writeset_out->fd_array[i]; evmap_io_active(base, s, EV_WRITE); } } diff --git a/buffer_iocp.c b/buffer_iocp.c index 565f232f..eb7635f6 100644 --- a/buffer_iocp.c +++ b/buffer_iocp.c @@ -42,6 +42,7 @@ #include "iocp-internal.h" #include "mm-internal.h" +#include #include #include #include diff --git a/evdns.c b/evdns.c index ffada0eb..9b255002 100644 --- a/evdns.c +++ b/evdns.c @@ -121,6 +121,7 @@ #include "evthread-internal.h" #ifdef WIN32 #include +#include #include #include #include diff --git a/event.h b/event.h index 9139296c..03c1394f 100644 --- a/event.h +++ b/event.h @@ -179,6 +179,7 @@ extern "C" { #ifdef WIN32 #define WIN32_LEAN_AND_MEAN +#include #include #undef WIN32_LEAN_AND_MEAN typedef unsigned char u_char; diff --git a/event_iocp.c b/event_iocp.c index 9aca3b89..4c144af6 100644 --- a/event_iocp.c +++ b/event_iocp.c @@ -24,6 +24,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include diff --git a/evmap.c b/evmap.c index 9648892b..47bea3ce 100644 --- a/evmap.c +++ b/evmap.c @@ -28,6 +28,7 @@ #endif #ifdef WIN32 +#include #define WIN32_LEAN_AND_MEAN #include #undef WIN32_LEAN_AND_MEAN @@ -35,7 +36,7 @@ #include #ifdef _EVENT_HAVE_SYS_TIME_H #include -#else +#elif !defined(WIN32) #include #endif #include diff --git a/include/event2/event_struct.h b/include/event2/event_struct.h index 2f0ff7a5..dd7042f4 100644 --- a/include/event2/event_struct.h +++ b/include/event2/event_struct.h @@ -50,6 +50,7 @@ extern "C" { #include #ifdef WIN32 +#include #define WIN32_LEAN_AND_MEAN #include #undef WIN32_LEAN_AND_MEAN diff --git a/log.c b/log.c index 67e24bef..db620990 100644 --- a/log.c +++ b/log.c @@ -42,6 +42,7 @@ #endif #ifdef WIN32 +#include #define WIN32_LEAN_AND_MEAN #include #undef WIN32_LEAN_AND_MEAN @@ -49,7 +50,7 @@ #include #ifdef _EVENT_HAVE_SYS_TIME_H #include -#else +#elif !defined(WIN32) #include #endif #include diff --git a/sample/event-test.c b/sample/event-test.c index 848cbc87..3a06d3bf 100644 --- a/sample/event-test.c +++ b/sample/event-test.c @@ -14,6 +14,7 @@ #include #include #else +#include #include #endif #include diff --git a/sample/signal-test.c b/sample/signal-test.c index 165883fb..4a3a738e 100644 --- a/sample/signal-test.c +++ b/sample/signal-test.c @@ -16,6 +16,7 @@ #include #include #else +#include #include #endif #include diff --git a/test/regress_dns.c b/test/regress_dns.c index 2ee544bf..5b74fc4a 100644 --- a/test/regress_dns.c +++ b/test/regress_dns.c @@ -61,6 +61,7 @@ #include "event2/event.h" #include "event2/event_compat.h" +#include #include "evdns.h" #include "log-internal.h" #include "regress.h" @@ -222,7 +223,7 @@ dns_server_request_cb(struct evdns_server_request *req, void *data) ans.s_addr = htonl(0xc0a80b0bUL); /* 192.168.11.11 */ if (req->questions[i]->type == EVDNS_TYPE_A && req->questions[i]->dns_question_class == EVDNS_CLASS_INET && - !strcasecmp(req->questions[i]->name, "zz.example.com")) { + !evutil_strcasecmp(req->questions[i]->name, "zz.example.com")) { r = evdns_server_request_add_a_reply(req, req->questions[i]->name, 1, &ans.s_addr, 12345); @@ -230,7 +231,7 @@ dns_server_request_cb(struct evdns_server_request *req, void *data) dns_ok = 0; } else if (req->questions[i]->type == EVDNS_TYPE_AAAA && req->questions[i]->dns_question_class == EVDNS_CLASS_INET && - !strcasecmp(req->questions[i]->name, "zz.example.com")) { + !evutil_strcasecmp(req->questions[i]->name, "zz.example.com")) { char addr6[17] = "abcdefghijklmnop"; r = evdns_server_request_add_aaaa_reply(req, req->questions[i]->name, @@ -239,7 +240,7 @@ dns_server_request_cb(struct evdns_server_request *req, void *data) dns_ok = 0; } else if (req->questions[i]->type == EVDNS_TYPE_PTR && req->questions[i]->dns_question_class == EVDNS_CLASS_INET && - !strcasecmp(req->questions[i]->name, TEST_ARPA)) { + !evutil_strcasecmp(req->questions[i]->name, TEST_ARPA)) { r = evdns_server_request_add_ptr_reply(req, NULL, req->questions[i]->name, "ZZ.EXAMPLE.COM", 54321); @@ -247,7 +248,7 @@ dns_server_request_cb(struct evdns_server_request *req, void *data) dns_ok = 0; } else if (req->questions[i]->type == EVDNS_TYPE_A && req->questions[i]->dns_question_class == EVDNS_CLASS_INET && - !strcasecmp(req->questions[i]->name, "drop.example.com")) { + !evutil_strcasecmp(req->questions[i]->name, "drop.example.com")) { if (evdns_server_request_drop(req)<0) dns_ok = 0; return; diff --git a/test/regress_et.c b/test/regress_et.c index f4762d9a..925209dd 100644 --- a/test/regress_et.c +++ b/test/regress_et.c @@ -31,7 +31,6 @@ #endif #include #include -#include #ifdef _EVENT_HAVE_SYS_SOCKET_H #include #endif @@ -39,7 +38,10 @@ #include #include #include +#ifndef WIN32 +#include #include +#endif #include #include diff --git a/test/regress_http.c b/test/regress_http.c index adcb2b57..1fb20aec 100644 --- a/test/regress_http.c +++ b/test/regress_http.c @@ -2102,7 +2102,7 @@ static void http_multi_line_header_test(void) { struct bufferevent *bev= NULL; - int fd = -1; + evutil_socket_t fd = -1; const char *http_start_request; short port = -1; @@ -2135,7 +2135,7 @@ http_multi_line_header_test(void) if (bev) bufferevent_free(bev); if (fd >= 0) - close(fd); + EVUTIL_CLOSESOCKET(fd); if (http) evhttp_free(http); } diff --git a/test/regress_main.c b/test/regress_main.c index 68dcdc4d..3f2a2391 100644 --- a/test/regress_main.c +++ b/test/regress_main.c @@ -28,6 +28,7 @@ #ifdef WIN32 #include #include +#define __func__ __FUNCTION__ #endif #ifdef HAVE_CONFIG_H diff --git a/test/tinytest.c b/test/tinytest.c index 19d75dd1..20f04933 100644 --- a/test/tinytest.c +++ b/test/tinytest.c @@ -29,6 +29,7 @@ #include #ifdef WIN32 +#include #include #else #include @@ -36,6 +37,8 @@ #include #endif +#include + #include "tinytest.h" #include "tinytest_macros.h" @@ -116,7 +119,7 @@ _testcase_run_forked(const struct testgroup_t *group, if (opt_verbosity>0) printf("[forking] "); - snprintf(buffer, sizeof(buffer), "%s --RUNNING-FORKED %s %s%s", + evutil_snprintf(buffer, sizeof(buffer), "%s --RUNNING-FORKED %s %s%s", commandname, verbosity_flag, group->prefix, testcase->name); memset(&si, 0, sizeof(si)); @@ -245,7 +248,7 @@ _tinytest_set_flag(struct testgroup_t *groups, const char *arg, unsigned long fl length = strstr(arg,"..")-arg; for (i=0; groups[i].prefix; ++i) { for (j=0; groups[i].cases[j].name; ++j) { - snprintf(fullname, sizeof(fullname), "%s%s", + evutil_snprintf(fullname, sizeof(fullname), "%s%s", groups[i].prefix, groups[i].cases[j].name); if (!flag) /* Hack! */ printf(" %s\n", fullname); -- 2.40.0