Klaus Demo nginx / 48d96ce
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. Maxim Dounin 8 years ago
19 changed file(s) with 83 addition(s) and 33 deletion(s). Raw diff Collapse all Expand all
3232 CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libssl.a"
3333 CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libcrypto.a"
3434 CORE_LIBS="$CORE_LIBS $NGX_LIBDL"
35
36 if [ "$NGX_PLATFORM" = win32 ]; then
37 CORE_LIBS="$CORE_LIBS -lgdi32 -lcrypt32 -lws2_32"
38 fi
3539 ;;
3640 esac
3741
7272
7373 *)
7474 have=NGX_PCRE . auto/have
75
76 if [ "$NGX_PLATFORM" = win32 ]; then
77 have=PCRE_STATIC . auto/have
78 fi
79
7580 CORE_DEPS="$CORE_DEPS $PCRE/pcre.h"
7681 LINK_DEPS="$LINK_DEPS $PCRE/.libs/libpcre.a"
7782 CORE_LIBS="$CORE_LIBS $PCRE/.libs/libpcre.a"
2222 ngx_pcre=`echo \-DPCRE=\"$PCRE\" | sed -e "s/\//$ngx_regex_dirsep/g"`
2323 ;;
2424
25 *)
26 ngx_makefile=
27 ;;
28
2529 esac
2630
2731
28 case "$NGX_PLATFORM" in
32 if [ -n "$ngx_makefile" ]; then
2933
30 win32)
31
32 cat << END >> $NGX_MAKEFILE
34 cat << END >> $NGX_MAKEFILE
3335
3436 `echo "$PCRE/pcre.lib: $PCRE/pcre.h $NGX_MAKEFILE" \
3537 | sed -e "s/\//$ngx_regex_dirsep/g"`
4042
4143 END
4244
43 ;;
45 else
4446
45 *)
46 cat << END >> $NGX_MAKEFILE
47 cat << END >> $NGX_MAKEFILE
4748
4849 $PCRE/pcre.h: $PCRE/Makefile
4950
5960
6061 END
6162
62 ;;
63
64 esac
63 fi
2323 ngx_zlib=`echo \-DZLIB=\"$ZLIB\" | sed -e "s/\//$ngx_regex_dirsep/g"`
2424 ;;
2525
26 *)
27 ngx_makefile=
28 ;;
29
2630 esac
2731
2832
3236 case "$NGX_PLATFORM" in
3337
3438 win32)
35 cat << END >> $NGX_MAKEFILE
39
40 if [ -n "$ngx_makefile" ]; then
41 cat << END >> $NGX_MAKEFILE
3642
3743 `echo "$ZLIB/zlib.lib: $NGX_MAKEFILE" | sed -e "s/\//$ngx_regex_dirsep/g"`
3844 \$(MAKE) -f auto/lib/zlib/$ngx_makefile $ngx_opt $ngx_zlib
3945
4046 END
47
48 else
49
50 cat << END >> $NGX_MAKEFILE
51
52 $ZLIB/libz.a: $NGX_MAKEFILE
53 cd $ZLIB \\
54 && \$(MAKE) distclean \\
55 && \$(MAKE) -f win32/Makefile.gcc \\
56 CFLAGS="$ZLIB_OPT" CC="\$(CC)" \\
57 libz.a
58
59 END
60
61 fi
4162
4263 done=YES
4364 ;;
88 CORE_DEPS="$WIN32_DEPS"
99 CORE_SRCS="$WIN32_SRCS $IOCP_SRCS"
1010 OS_CONFIG="$WIN32_CONFIG"
11 CORE_LIBS="$CORE_LIBS advapi32.lib ws2_32.lib"
1211 NGX_ICONS="$NGX_WIN32_ICONS"
1312 SELECT_SRCS=$WIN32_SELECT_SRCS
13
14 case "$NGX_CC_NAME" in
15
16 gcc)
17 CORE_LIBS="$CORE_LIBS -ladvapi32 -lws2_32"
18 ;;
19
20 *)
21 CORE_LIBS="$CORE_LIBS advapi32.lib ws2_32.lib"
22 ;;
23
24 esac
1425
1526 EVENT_MODULES="$EVENT_MODULES $IOCP_MODULE"
1627 EVENT_FOUND=YES
296296 continue;
297297 }
298298
299 if (ls[i].fd != -1) {
299 if (ls[i].fd != (ngx_socket_t) -1) {
300300 continue;
301301 }
302302
311311
312312 s = ngx_socket(ls[i].sockaddr->sa_family, ls[i].type, 0);
313313
314 if (s == -1) {
314 if (s == (ngx_socket_t) -1) {
315315 ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
316316 ngx_socket_n " %V failed", &ls[i].addr_text);
317317 return NGX_ERROR;
862862 ngx_uint_t log_error, level;
863863 ngx_socket_t fd;
864864
865 if (c->fd == -1) {
865 if (c->fd == (ngx_socket_t) -1) {
866866 ngx_log_error(NGX_LOG_ALERT, c->log, 0, "connection already closed");
867867 return;
868868 }
542542 }
543543 }
544544
545 if (nls[n].fd == -1) {
545 if (nls[n].fd == (ngx_socket_t) -1) {
546546 nls[n].open = 1;
547547 }
548548 }
648648 ls = old_cycle->listening.elts;
649649 for (i = 0; i < old_cycle->listening.nelts; i++) {
650650
651 if (ls[i].remain || ls[i].fd == -1) {
651 if (ls[i].remain || ls[i].fd == (ngx_socket_t) -1) {
652652 continue;
653653 }
654654
812812
813813 ls = cycle->listening.elts;
814814 for (i = 0; i < cycle->listening.nelts; i++) {
815 if (ls[i].fd == -1 || !ls[i].open) {
815 if (ls[i].fd == (ngx_socket_t) -1 || !ls[i].open) {
816816 continue;
817817 }
818818
22202220
22212221 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, &uc->log, 0, "UDP socket %d", s);
22222222
2223 if (s == -1) {
2223 if (s == (ngx_socket_t) -1) {
22242224 ngx_log_error(NGX_LOG_ALERT, &uc->log, ngx_socket_errno,
22252225 ngx_socket_n " failed");
22262226 return NGX_ERROR;
169169 #endif
170170 }
171171
172 #ifdef __WATCOMC__
172 #if defined(__WATCOMC__) || defined(__GNUC__)
173173 return 0;
174174 #endif
175175 }
147147 return NGX_ERROR;
148148 }
149149
150 if ((event == NGX_READ_EVENT) && (max_read >= FD_SETSIZE)
151 || (event == NGX_WRITE_EVENT) && (max_write >= FD_SETSIZE))
150 if ((event == NGX_READ_EVENT && max_read >= FD_SETSIZE)
151 || (event == NGX_WRITE_EVENT && max_write >= FD_SETSIZE))
152152 {
153153 ngx_log_error(NGX_LOG_ERR, ev->log, 0,
154154 "maximum number of descriptors "
6969 s = accept(lc->fd, (struct sockaddr *) sa, &socklen);
7070 #endif
7171
72 if (s == -1) {
72 if (s == (ngx_socket_t) -1) {
7373 err = ngx_socket_errno;
7474
7575 if (err == NGX_EAGAIN) {
107107 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, &ls->log, 0,
108108 ngx_socket_n " s:%d", s);
109109
110 if (s == -1) {
110 if (s == (ngx_socket_t) -1) {
111111 ngx_log_error(NGX_LOG_ALERT, &ls->log, ngx_socket_errno,
112112 ngx_socket_n " failed");
113113
3030
3131 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pc->log, 0, "socket %d", s);
3232
33 if (s == -1) {
33 if (s == (ngx_socket_t) -1) {
3434 ngx_log_error(NGX_LOG_ALERT, pc->log, ngx_socket_errno,
3535 ngx_socket_n " failed");
3636 return NGX_ERROR;
5656 do_write = 1;
5757 }
5858
59 if (p->upstream->fd != -1) {
59 if (p->upstream->fd != (ngx_socket_t) -1) {
6060 rev = p->upstream->read;
6161
6262 flags = (rev->eof || rev->error) ? NGX_CLOSE_EVENT : 0;
7373 }
7474 }
7575
76 if (p->downstream->fd != -1 && p->downstream->data == p->output_ctx) {
76 if (p->downstream->fd != (ngx_socket_t) -1
77 && p->downstream->data == p->output_ctx)
78 {
7779 wev = p->downstream->write;
7880 if (ngx_handle_write_event(wev, p->send_lowat) != NGX_OK) {
7981 return NGX_ABORT;
2020 #define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1)
2121
2222
23 #if defined( __WATCOMC__ ) || defined( __BORLANDC__ ) || ( _MSC_VER >= 1300 )
23 #if defined( __WATCOMC__ ) || defined( __BORLANDC__ ) || defined(__GNUC__) \
24 || ( _MSC_VER >= 1300 )
2425
2526 /* the new SDK headers */
2627
814814
815815 /* THREAD: lock */
816816
817 if (c[i].fd != -1 && c[i].idle) {
817 if (c[i].fd != (ngx_socket_t) -1 && c[i].idle) {
818818 c[i].close = 1;
819819 c[i].read->handler(c[i].read);
820820 }
873873 if (ngx_exiting) {
874874 c = cycle->connections;
875875 for (i = 0; i < cycle->connection_n; i++) {
876 if (c[i].fd != -1
876 if (c[i].fd != (ngx_socket_t) -1
877877 && c[i].read
878878 && !c[i].read->accept
879879 && !c[i].read->channel
88 #define _NGX_WIN32_CONFIG_H_INCLUDED_
99
1010
11 #undef WIN32
1112 #define WIN32 0x0400
1213 #define _WIN32_WINNT 0x0501
1314
3435 #include <mswsock.h>
3536 #include <shellapi.h>
3637 #include <stddef.h> /* offsetof() */
38
39 #ifdef __GNUC__
40 /* GCC MinGW's stdio.h includes sys/types.h */
41 #define _OFF_T_
42 #endif
43
3744 #include <stdio.h>
3845 #include <stdlib.h>
3946 #include <stdarg.h>
140140 */
141141
142142 s = ngx_socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
143 if (s == -1) {
143 if (s == (ngx_socket_t) -1) {
144144 ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
145145 ngx_socket_n " falied");
146146 return NGX_ERROR;
1616 u_long bytes, flags;
1717 WSABUF wsabuf[1];
1818 ngx_err_t err;
19 ngx_uint_t n;
19 ngx_int_t n;
2020 ngx_event_t *rev;
2121
2222 wsabuf[0].buf = (char *) buf;
6969 u_long bytes, flags;
7070 WSABUF wsabuf[1];
7171 ngx_err_t err;
72 ngx_uint_t n;
72 ngx_int_t n;
7373 ngx_event_t *rev;
7474 LPWSAOVERLAPPED ovlp;
7575