From 48d96ced6ff6cea533d56d0d09129f6632a19e4d Mon Sep 17 00:00:00 2001 From: Maxim Dounin Date: Wed, 4 Sep 2013 20:48:28 +0400 Subject: Win32: MinGW GCC compatibility. Several warnings silenced, notably (ngx_socket_t) -1 is now checked on socket operations instead of -1, as ngx_socket_t is unsigned on win32 and gcc complains on comparison. With this patch, it's now possible to compile nginx using mingw gcc, with options we normally compile on win32. --- src/os/win32/ngx_atomic.h | 3 ++- src/os/win32/ngx_process_cycle.c | 4 ++-- src/os/win32/ngx_win32_config.h | 7 +++++++ src/os/win32/ngx_win32_init.c | 2 +- src/os/win32/ngx_wsarecv.c | 4 ++-- 5 files changed, 14 insertions(+), 6 deletions(-) (limited to 'src/os') diff --git a/src/os/win32/ngx_atomic.h b/src/os/win32/ngx_atomic.h index 78d7424f5..d89a0d3ca 100644 --- a/src/os/win32/ngx_atomic.h +++ b/src/os/win32/ngx_atomic.h @@ -21,7 +21,8 @@ typedef volatile ngx_atomic_uint_t ngx_atomic_t; #define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1) -#if defined( __WATCOMC__ ) || defined( __BORLANDC__ ) || ( _MSC_VER >= 1300 ) +#if defined( __WATCOMC__ ) || defined( __BORLANDC__ ) || defined(__GNUC__) \ + || ( _MSC_VER >= 1300 ) /* the new SDK headers */ diff --git a/src/os/win32/ngx_process_cycle.c b/src/os/win32/ngx_process_cycle.c index 3a14aad69..949ea85db 100644 --- a/src/os/win32/ngx_process_cycle.c +++ b/src/os/win32/ngx_process_cycle.c @@ -815,7 +815,7 @@ ngx_worker_thread(void *data) /* THREAD: lock */ - if (c[i].fd != -1 && c[i].idle) { + if (c[i].fd != (ngx_socket_t) -1 && c[i].idle) { c[i].close = 1; c[i].read->handler(c[i].read); } @@ -874,7 +874,7 @@ ngx_worker_process_exit(ngx_cycle_t *cycle) if (ngx_exiting) { c = cycle->connections; for (i = 0; i < cycle->connection_n; i++) { - if (c[i].fd != -1 + if (c[i].fd != (ngx_socket_t) -1 && c[i].read && !c[i].read->accept && !c[i].read->channel diff --git a/src/os/win32/ngx_win32_config.h b/src/os/win32/ngx_win32_config.h index 193079230..67105f1af 100644 --- a/src/os/win32/ngx_win32_config.h +++ b/src/os/win32/ngx_win32_config.h @@ -9,6 +9,7 @@ #define _NGX_WIN32_CONFIG_H_INCLUDED_ +#undef WIN32 #define WIN32 0x0400 #define _WIN32_WINNT 0x0501 @@ -35,6 +36,12 @@ #include #include #include /* offsetof() */ + +#ifdef __GNUC__ +/* GCC MinGW's stdio.h includes sys/types.h */ +#define _OFF_T_ +#endif + #include #include #include diff --git a/src/os/win32/ngx_win32_init.c b/src/os/win32/ngx_win32_init.c index cf73d8215..d2505ced4 100644 --- a/src/os/win32/ngx_win32_init.c +++ b/src/os/win32/ngx_win32_init.c @@ -141,7 +141,7 @@ ngx_os_init(ngx_log_t *log) */ s = ngx_socket(AF_INET, SOCK_STREAM, IPPROTO_IP); - if (s == -1) { + if (s == (ngx_socket_t) -1) { ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, ngx_socket_n " falied"); return NGX_ERROR; diff --git a/src/os/win32/ngx_wsarecv.c b/src/os/win32/ngx_wsarecv.c index dd74ae2cc..1925f0b17 100644 --- a/src/os/win32/ngx_wsarecv.c +++ b/src/os/win32/ngx_wsarecv.c @@ -17,7 +17,7 @@ ngx_wsarecv(ngx_connection_t *c, u_char *buf, size_t size) u_long bytes, flags; WSABUF wsabuf[1]; ngx_err_t err; - ngx_uint_t n; + ngx_int_t n; ngx_event_t *rev; wsabuf[0].buf = (char *) buf; @@ -70,7 +70,7 @@ ngx_overlapped_wsarecv(ngx_connection_t *c, u_char *buf, size_t size) u_long bytes, flags; WSABUF wsabuf[1]; ngx_err_t err; - ngx_uint_t n; + ngx_int_t n; ngx_event_t *rev; LPWSAOVERLAPPED ovlp; -- cgit