diff options
| author | Maxim Dounin <mdounin@mdounin.ru> | 2013-09-04 20:48:28 +0400 |
|---|---|---|
| committer | Maxim Dounin <mdounin@mdounin.ru> | 2013-09-04 20:48:28 +0400 |
| commit | 48d96ced6ff6cea533d56d0d09129f6632a19e4d (patch) | |
| tree | f3196223e3dd9173aaf91dff959498799c0e3ea2 /src/os | |
| parent | 74b7a910137a99b5fb073e7c27858c019f96a8cc (diff) | |
| download | nginx-48d96ced6ff6cea533d56d0d09129f6632a19e4d.tar.gz nginx-48d96ced6ff6cea533d56d0d09129f6632a19e4d.tar.bz2 | |
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.
Diffstat (limited to 'src/os')
| -rw-r--r-- | src/os/win32/ngx_atomic.h | 3 | ||||
| -rw-r--r-- | src/os/win32/ngx_process_cycle.c | 4 | ||||
| -rw-r--r-- | src/os/win32/ngx_win32_config.h | 7 | ||||
| -rw-r--r-- | src/os/win32/ngx_win32_init.c | 2 | ||||
| -rw-r--r-- | src/os/win32/ngx_wsarecv.c | 4 |
5 files changed, 14 insertions, 6 deletions
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 <mswsock.h> #include <shellapi.h> #include <stddef.h> /* offsetof() */ + +#ifdef __GNUC__ +/* GCC MinGW's stdio.h includes sys/types.h */ +#define _OFF_T_ +#endif + #include <stdio.h> #include <stdlib.h> #include <stdarg.h> 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; |
