From ab9d5fdfd55c879611d69998fc58cbb39f25e73a Mon Sep 17 00:00:00 2001 From: Igor Sysoev Date: Fri, 5 Mar 2004 08:34:24 +0000 Subject: [PATCH] nginx-0.0.2-2004-03-05-11:34:24 import --- auto/cc | 50 ++++++ auto/init | 6 + auto/make | 264 +++++++++++++++++++--------- auto/modules | 25 +++ src/event/modules/ngx_iocp_module.c | 2 +- src/event/ngx_event.h | 4 +- src/event/ngx_event_acceptex.c | 4 +- src/http/ngx_http_log_handler.c | 2 +- src/os/win32/ngx_files.c | 4 +- src/os/win32/ngx_process.c | 2 +- src/os/win32/ngx_win32_config.h | 15 ++ src/os/win32/ngx_wsarecv.c | 6 +- src/os/win32/ngx_wsarecv_chain.c | 4 +- src/os/win32/ngx_wsasend_chain.c | 6 +- 14 files changed, 299 insertions(+), 95 deletions(-) diff --git a/auto/cc b/auto/cc index bb2a3bf94..0fb96322e 100644 --- a/auto/cc +++ b/auto/cc @@ -2,6 +2,7 @@ case $CC in *gcc) + # gcc 2.95.4, 3.3.2 # optimization #CFLAGS="$CFLAGS -O2 -fomit-frame-pointer" @@ -31,6 +32,7 @@ case $CC in have=HAVE_GCC_VARIADIC_MACROS . auto/have OBJEXT=o + COMPILEONLY="-c " OBJOUT="-o " BINOUT="-o " @@ -57,6 +59,7 @@ case $CC in have=HAVE_C99_VARIADIC_MACROS . auto/have OBJEXT=o + COMPILEONLY="-c " OBJOUT="-o " BINOUT="-o " @@ -113,6 +116,7 @@ case $CC in CORE_LINK="$CORE_LINK -debug -debugtype:coff" OBJEXT=obj + COMPILEONLY="-c " OBJOUT="-Fo" BINOUT="-Fe" @@ -122,6 +126,52 @@ case $CC in wcc386) # Open Watcom 1.0 + + # optimization + + # maximize speed + CFLAGS="$CFLAGS -ot" + # reorder instructions for best pipeline usage + CFLAGS="$CFLAGS -op" + # inline intrinsic functions + CFLAGS="$CFLAGS -oi" + # inline expansion + CFLAGS="$CFLAGS -oe" + # disable stack checking calls + CFLAGS="$CFLAGS -s" + # optimize for Pentium Pro + #CFLAGS="$CFLAGS -6r" + CFLAGS="$CFLAGS -6s" + + # warnings + #CFLAGS="$CFLAGS -w3" + CFLAGS="$CFLAGS -wx" + + # stop on warning + #CFLAGS="$CFLAGS -we" + + # built target is NT + CFLAGS="$CFLAGS -bt=nt" + + # multithreaded + CFLAGS="$CFLAGS -bm" + + # debug + CFLAGS="$CFLAGS -d2" + + # quiet + CFLAGS="$CFLAGS -zq" + + # link traget is NT + CORE_LINK="$CORE_LINK -l=nt" + + OBJEXT=obj + COMPILEONLY= + OBJOUT="-fo" + BINOUT="-fo" + INC_EQ=YES + MAKE_BS=YES + MAKE_SL=YES ;; esac diff --git a/auto/init b/auto/init index 8bd4b8b07..03e8a2b2d 100644 --- a/auto/init +++ b/auto/init @@ -10,6 +10,12 @@ NGX_ERR=$OBJS/autoconf.err CC_WARN=$CC +INC_EQ=NO +MAKE_BS=NO +MAKE_SL=NO +MAKE_BL=YES + + # checking echo's "-n" option and "\c" capabilties if echo "test\c" | grep c >/dev/null; then diff --git a/auto/make b/auto/make index 31c414c26..e4e1a2661 100644 --- a/auto/make +++ b/auto/make @@ -4,155 +4,261 @@ mkdir -p $OBJS/src/core $OBJS/src/event $OBJS/src/event/modules \ $OBJS/src/http $OBJS/src/http/modules $OBJS/src/http/modules/proxy -modules="$CORE_MODULES $EVENT_MODULES $HTTP_MODULES \ - $HTTP_FILTER_MODULES $HTTP_NOT_MODIFIED_FILTER_MODULE" +echo "CC = $CC" > $MAKEFILE +echo "CFLAGS = $CFLAGS" >> $MAKEFILE +echo >> $MAKEFILE -echo "#include " > $NGX_MODULES_C -echo "#include " >> $NGX_MODULES_C -echo >> $NGX_MODULES_C +# CORE_DEPS -for mod in $modules -do - echo "extern ngx_module_t $mod;" >> $NGX_MODULES_C -done +if [ $MAKE_SL = YES ]; then + echo $ngx_n "CORE_DEPS =" $ngx_c >> $MAKEFILE +else + echo "CORE_DEPS = \\" >> $MAKEFILE +fi -echo >> $NGX_MODULES_C -echo 'ngx_module_t *ngx_modules[] = {' >> $NGX_MODULES_C - -for mod in $modules -do - echo " &$mod," >> $NGX_MODULES_C -done - -echo " NULL" >> $NGX_MODULES_C -echo "};" >> $NGX_MODULES_C - - -echo "CC = $CC" > $MAKEFILE -echo "CFLAGS = $CFLAGS" >> $MAKEFILE -echo >> $MAKEFILE - -echo "CORE_DEPS = \\" >> $MAKEFILE for dep in $CORE_DEPS do - if [ $PLATFORM = win32 ]; then + if [ $MAKE_BS = YES ]; then dep=`echo $dep | sed -e "s/\//\\\\\\/g"` fi - echo " $dep \\" >> $MAKEFILE + + if [ $MAKE_SL = YES ]; then + echo $ngx_n " $dep" $ngx_c >> $MAKEFILE + else + echo " $dep \\" >> $MAKEFILE + fi done -echo >> $MAKEFILE +echo >> $MAKEFILE + + +# CORE_INCS + +if [ $MAKE_SL = YES ]; then + echo >> $MAKEFILE +fi inc="$CORE_INCS -I $OBJS" -if [ $PLATFORM = win32 ]; then +if [ $INC_EQ = YES ]; then + inc=`echo $inc | sed -e "s/-I /-i=/g"` +fi + +if [ $MAKE_BS = YES ]; then inc=`echo $inc | sed -e "s/\//\\\\\\/g"` fi -echo "CORE_INCS = $inc" >> $MAKEFILE -echo >> $MAKEFILE -echo "HTTP_DEPS = \\" >> $MAKEFILE -for inc in $HTTP_DEPS +echo "CORE_INCS = $inc" >> $MAKEFILE +echo >> $MAKEFILE + + +# HTTP_DEPS + +if [ $MAKE_SL = YES ]; then + echo $ngx_n "HTTP_DEPS =" $ngx_c >> $MAKEFILE +else + echo "HTTP_DEPS = \\" >> $MAKEFILE +fi + +for dep in $HTTP_DEPS do - if [ $PLATFORM = win32 ]; then - inc=`echo $inc | sed -e "s/\//\\\\\\/g"` + if [ $MAKE_BS = YES ]; then + dep=`echo $dep | sed -e "s/\//\\\\\\/g"` fi - echo " $inc \\" >> $MAKEFILE -done -echo >> $MAKEFILE -inc="$HTTP_INCS" -if [ $PLATFORM = win32 ]; then + if [ $MAKE_SL = YES ]; then + echo $ngx_n " $dep" $ngx_c >> $MAKEFILE + else + echo " $dep \\" >> $MAKEFILE + fi +done +echo >> $MAKEFILE + + +# HTTP_INCS + +if [ $MAKE_SL = YES ]; then + echo >> $MAKEFILE +fi + +inc="$HTTP_INCS -I $OBJS" +if [ $INC_EQ = YES ]; then + inc=`echo $inc | sed -e "s/-I /-i=/g"` +fi + +if [ $MAKE_BS = YES ]; then inc=`echo $inc | sed -e "s/\//\\\\\\/g"` fi -echo "HTTP_INCS = $inc" >> $MAKEFILE -echo >> $MAKEFILE + +echo "HTTP_INCS = $inc" >> $MAKEFILE +echo >> $MAKEFILE +# nginx -echo "nginx: \\" >> $MAKEFILE +if [ $MAKE_SL = YES ]; then + echo $ngx_n "nginx: " $ngx_c >> $MAKEFILE +else + echo "nginx: \\" >> $MAKEFILE +fi + + +# nginx deps for src in $CORE_SRCS $HTTP_SRCS do obj=`echo $src | sed -e "s/\.c\$/.$OBJEXT/" -e "s/\.S\$/.$OBJEXT/"` obj="$OBJS/$obj" - if [ $PLATFORM = win32 ]; then + + if [ $MAKE_BS = YES ]; then obj=`echo $obj | sed -e "s/\//\\\\\\/g"` fi - echo " $obj \\" >> $MAKEFILE + if [ $MAKE_SL = YES ]; then + echo $ngx_n " $obj" $ngx_c >> $MAKEFILE + else + echo " $obj \\" >> $MAKEFILE + fi done for src in $NGX_MODULES_C $LINK_DEPS do obj=`echo $src | sed -e "s/\.c\$/.$OBJEXT/"` - if [ $PLATFORM = win32 ]; then + + if [ $MAKE_BS = YES ]; then obj=`echo $obj | sed -e "s/\//\\\\\\/g"` fi - echo " $obj \\" >> $MAKEFILE + if [ $MAKE_SL = YES ]; then + echo $ngx_n " $obj" $ngx_c >> $MAKEFILE + else + echo " $obj \\" >> $MAKEFILE + fi done +echo >> $MAKEFILE -echo >> $MAKEFILE -echo " \$(CC) ${BINOUT}nginx \\" >> $MAKEFILE + +# nginx build + +if [ $MAKE_SL = YES ]; then + echo $ngx_n " \$(CC) ${BINOUT}nginx" $ngx_c >> $MAKEFILE +else + echo " \$(CC) ${BINOUT}nginx \\" >> $MAKEFILE +fi + + +# nginx build sources for src in $CORE_SRCS $HTTP_SRCS do obj=`echo $src | sed -e "s/\.c\$/.$OBJEXT/" -e "s/\.S\$/.$OBJEXT/"` obj="$OBJS/$obj" - if [ $PLATFORM = win32 ]; then + + if [ $MAKE_BS = YES ]; then obj=`echo $obj | sed -e "s/\//\\\\\\/g"` fi - echo " $obj \\" >> $MAKEFILE + if [ $MAKE_SL = YES ]; then + echo $ngx_n " $obj," $ngx_c >> $MAKEFILE + else + echo " $obj \\" >> $MAKEFILE + fi done -obj=`echo $NGX_MODULES_C | sed -e "s/\.c\$/.$OBJEXT/"` -if [ $PLATFORM = win32 ]; then - obj=`echo $obj | sed -e "s/\//\\\\\\/g"` -fi -echo " $obj \\" >> $MAKEFILE -echo " $CORE_LIBS \\" >> $MAKEFILE -echo " $CORE_LINK" >> $MAKEFILE -echo >> $MAKEFILE +# nginx build ngx_modules.c and libs + +obj=`echo $NGX_MODULES_C | sed -e "s/\.c\$/.$OBJEXT/"` +libs=`echo $CORE_LIBS | sed -e "s/\.c\$/.$OBJEXT/"` +src=$NGX_MODULES_C +if [ $MAKE_BS = YES ]; then + obj=`echo $obj | sed -e "s/\//\\\\\\/g"` + src=`echo $src | sed -e "s/\//\\\\\\/g"` + libs=`echo $libs | sed -e "s/\//\\\\\\/g"` +fi + +if [ $MAKE_SL = YES ]; then + echo " $obj $libs $CORE_LINK" >> $MAKEFILE + echo >> $MAKEFILE +else + echo " $obj \\" >> $MAKEFILE + echo " $CORE_LIBS \\" >> $MAKEFILE + echo " $CORE_LINK" >> $MAKEFILE + echo >> $MAKEFILE +fi + + +# ngx_modules.c deps="\$(CORE_DEPS)" args="\$(CFLAGS) \$(CORE_INCS)" -echo "$obj: \\" >> $MAKEFILE -echo " $NGX_MODULES_C $deps" >> $MAKEFILE -echo " \$(CC) -c $args \\" >> $MAKEFILE -echo " $OBJOUT$obj \\" >> $MAKEFILE -echo " $NGX_MODULES_C" >> $MAKEFILE -echo >> $MAKEFILE - +if [ $MAKE_SL = YES ]; then + echo "$obj: $NGX_MODULES_C $deps" >> $MAKEFILE + echo $ngx_n " \$(CC) $COMPILEONLY $args" $ngx_c >> $MAKEFILE + echo " $OBJOUT$obj $src" >> $MAKEFILE + echo >> $MAKEFILE +else + echo "$obj: \\" >> $MAKEFILE + echo " $NGX_MODULES_C $deps" >> $MAKEFILE + echo " \$(CC) $COMPILEONLY $args \\" >> $MAKEFILE + echo " $OBJOUT$obj \\" >> $MAKEFILE + echo " $src" >> $MAKEFILE + echo >> $MAKEFILE +fi +# core sources for src in $CORE_SRCS do obj=`echo $src | sed -e "s/\.c\$/.$OBJEXT/" -e "s/\.S\$/.$OBJEXT/"` + obj="$OBJS/$obj" - echo "$OBJS/$obj: \\" >> $MAKEFILE - echo " $src $deps" >> $MAKEFILE - echo " \$(CC) -c $args \\" >> $MAKEFILE - echo " $OBJOUT$OBJS/$obj \\" >> $MAKEFILE - echo " $src" >> $MAKEFILE - echo >> $MAKEFILE + if [ $MAKE_BS = YES ]; then + obj=`echo $obj | sed -e "s/\//\\\\\\/g"` + src=`echo $src | sed -e "s/\//\\\\\\/g"` + fi + + if [ $MAKE_SL = YES ]; then + echo "$obj: $src $deps" >> $MAKEFILE + echo " \$(CC) $COMPILEONLY $args $OBJOUT$obj $src" >> $MAKEFILE + echo >> $MAKEFILE + else + echo "$obj: \\" >> $MAKEFILE + echo " $src $deps" >> $MAKEFILE + echo " \$(CC) $COMPILEONLY $args \\" >> $MAKEFILE + echo " $OBJOUT$obj \\" >> $MAKEFILE + echo " $src" >> $MAKEFILE + echo >> $MAKEFILE + fi done +# http sources + deps="\$(CORE_DEPS) \$(HTTP_DEPS)" args="\$(CFLAGS) \$(CORE_INCS) \$(HTTP_INCS)" for src in $HTTP_SRCS do obj=`echo $src | sed -e "s/\.c\$/.$OBJEXT/"` + obj="$OBJS/$obj" - echo "$OBJS/$obj: \\" >> $MAKEFILE - echo " $src $deps" >> $MAKEFILE - echo " \$(CC) -c $args \\" >> $MAKEFILE - echo " $OBJOUT$OBJS/$obj \\" >> $MAKEFILE - echo " $src" >> $MAKEFILE - echo >> $MAKEFILE + if [ $MAKE_BS = YES ]; then + obj=`echo $obj | sed -e "s/\//\\\\\\/g"` + src=`echo $src | sed -e "s/\//\\\\\\/g"` + fi + + if [ $MAKE_SL = YES ]; then + echo "$obj: $src $deps" >> $MAKEFILE + echo " \$(CC) $COMPILEONLY $args $OBJOUT$obj $src" >> $MAKEFILE + echo >> $MAKEFILE + else + echo "$obj: \\" >> $MAKEFILE + echo " $src $deps" >> $MAKEFILE + echo " \$(CC) $COMPILEONLY $args \\" >> $MAKEFILE + echo " $OBJOUT$obj \\" >> $MAKEFILE + echo " $src" >> $MAKEFILE + echo >> $MAKEFILE + fi done diff --git a/auto/modules b/auto/modules index 1af94969c..ccd4d9af9 100644 --- a/auto/modules +++ b/auto/modules @@ -78,3 +78,28 @@ if [ $HTTP_PROXY = YES ]; then HTTP_DEPS="$HTTP_DEPS $HTTP_PROXY_DEPS" HTTP_SRCS="$HTTP_SRCS $HTTP_PROXY_SRCS" fi + + +modules="$CORE_MODULES $EVENT_MODULES $HTTP_MODULES \ + $HTTP_FILTER_MODULES $HTTP_NOT_MODIFIED_FILTER_MODULE" + + +echo "#include " > $NGX_MODULES_C +echo "#include " >> $NGX_MODULES_C +echo >> $NGX_MODULES_C + +for mod in $modules +do + echo "extern ngx_module_t $mod;" >> $NGX_MODULES_C +done + +echo >> $NGX_MODULES_C +echo 'ngx_module_t *ngx_modules[] = {' >> $NGX_MODULES_C + +for mod in $modules +do + echo " &$mod," >> $NGX_MODULES_C +done + +echo " NULL" >> $NGX_MODULES_C +echo "};" >> $NGX_MODULES_C diff --git a/src/event/modules/ngx_iocp_module.c b/src/event/modules/ngx_iocp_module.c index 0adc0c74c..e0a042c9c 100644 --- a/src/event/modules/ngx_iocp_module.c +++ b/src/event/modules/ngx_iocp_module.c @@ -164,7 +164,7 @@ static ngx_int_t ngx_iocp_process_events(ngx_log_t *log) { int rc; u_int key; - size_t bytes; + u_long bytes; ngx_err_t err; ngx_msec_t timer; ngx_event_t *ev; diff --git a/src/event/ngx_event.h b/src/event/ngx_event.h index 71fa5d47d..8ca468efa 100644 --- a/src/event/ngx_event.h +++ b/src/event/ngx_event.h @@ -122,11 +122,13 @@ struct ngx_event_s { * write: available space in buffer when event is ready * or lowat when event is set with NGX_LOWAT_EVENT flag * + * iocp: TODO + * * otherwise: * accept: 1 if accept many, 0 otherwise */ -#if (HAVE_KQUEUE) +#if (HAVE_KQUEUE) || (HAVE_IOCP) int available; #else unsigned short available:1; diff --git a/src/event/ngx_event_acceptex.c b/src/event/ngx_event_acceptex.c index 164db0ed4..7923a022b 100644 --- a/src/event/ngx_event_acceptex.c +++ b/src/event/ngx_event_acceptex.c @@ -58,8 +58,8 @@ void ngx_event_acceptex(ngx_event_t *rev) int ngx_event_post_acceptex(ngx_listening_t *ls, int n) { - int i; - u_int rcvd; + u_long rcvd; + ngx_int_t i; ngx_err_t err; ngx_event_t *rev, *wev; ngx_socket_t s; diff --git a/src/http/ngx_http_log_handler.c b/src/http/ngx_http_log_handler.c index 8b4c76358..b34bd1bf2 100644 --- a/src/http/ngx_http_log_handler.c +++ b/src/http/ngx_http_log_handler.c @@ -129,7 +129,7 @@ int ngx_http_log_handler(ngx_http_request_t *r) ngx_http_log_op_t *op; ngx_http_log_loc_conf_t *lcf; #if (WIN32) - u_int written; + u_long written; #endif ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, diff --git a/src/os/win32/ngx_files.c b/src/os/win32/ngx_files.c index 3906ddc49..df0d865c1 100644 --- a/src/os/win32/ngx_files.c +++ b/src/os/win32/ngx_files.c @@ -5,8 +5,8 @@ ssize_t ngx_read_file(ngx_file_t *file, char *buf, size_t size, off_t offset) { - size_t n; long high_offset; + DWORD n; ngx_err_t err; OVERLAPPED ovlp, *povlp; @@ -67,8 +67,8 @@ ssize_t ngx_read_file(ngx_file_t *file, char *buf, size_t size, off_t offset) ssize_t ngx_write_file(ngx_file_t *file, char *buf, size_t size, off_t offset) { - size_t n; long high_offset; + DWORD n; ngx_err_t err; OVERLAPPED ovlp, *povlp; diff --git a/src/os/win32/ngx_process.c b/src/os/win32/ngx_process.c index e3a278647..6d78c1c13 100644 --- a/src/os/win32/ngx_process.c +++ b/src/os/win32/ngx_process.c @@ -3,7 +3,7 @@ #include -ngx_pid_t ngx_exec(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx) +ngx_pid_t ngx_execute(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx) { return /* STUB */ 0; } diff --git a/src/os/win32/ngx_win32_config.h b/src/os/win32/ngx_win32_config.h index 2af600d5e..b1d7d5781 100644 --- a/src/os/win32/ngx_win32_config.h +++ b/src/os/win32/ngx_win32_config.h @@ -7,6 +7,10 @@ #define STRICT #define WIN32_LEAN_AND_MEAN +#ifdef __WATCOMC__ +#pragma disable_message(107) +#endif + /* * we need to include windows.h explicity before winsock2.h because * warning 4201 is enabled in windows.h @@ -34,6 +38,17 @@ #pragma warning(disable:4127) #endif + +#ifdef __WATCOMC__ +#pragma enable_message(107) +#if 0 +/* Symbol 'ngx_rbtree_min' has been defined, but not referenced */ +#pragma disable_message(202) +#endif +/* No prototype found for 'stricmp' */ +#pragma disable_message(301) +#endif + #include diff --git a/src/os/win32/ngx_wsarecv.c b/src/os/win32/ngx_wsarecv.c index 96fa0ff4c..2de1110c0 100644 --- a/src/os/win32/ngx_wsarecv.c +++ b/src/os/win32/ngx_wsarecv.c @@ -7,8 +7,7 @@ ssize_t ngx_wsarecv(ngx_connection_t *c, char *buf, size_t size) { int rc; - u_int flags; - size_t bytes; + u_long bytes, flags; WSABUF wsabuf[1]; ngx_err_t err; ngx_event_t *rev; @@ -56,8 +55,7 @@ ssize_t ngx_wsarecv(ngx_connection_t *c, char *buf, size_t size) ssize_t ngx_overlapped_wsarecv(ngx_connection_t *c, char *buf, size_t size) { int rc; - u_int flags; - size_t bytes; + u_long bytes, flags; WSABUF wsabuf[1]; ngx_err_t err; ngx_event_t *rev; diff --git a/src/os/win32/ngx_wsarecv_chain.c b/src/os/win32/ngx_wsarecv_chain.c index afdfa05c0..4bdc5d6d8 100644 --- a/src/os/win32/ngx_wsarecv_chain.c +++ b/src/os/win32/ngx_wsarecv_chain.c @@ -8,8 +8,8 @@ ssize_t ngx_wsarecv_chain(ngx_connection_t *c, ngx_chain_t *chain) { int rc; char *prev; - u_int flags; - size_t bytes, size; + u_long bytes, flags; + size_t size; WSABUF *wsabuf; ngx_err_t err; ngx_array_t io; diff --git a/src/os/win32/ngx_wsasend_chain.c b/src/os/win32/ngx_wsasend_chain.c index a52296a09..9d1812d4b 100644 --- a/src/os/win32/ngx_wsasend_chain.c +++ b/src/os/win32/ngx_wsasend_chain.c @@ -8,7 +8,8 @@ ngx_chain_t *ngx_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in) { int rc; char *prev; - size_t size, sent; + size_t size; + u_long sent; LPWSABUF wsabuf; ngx_err_t err; ngx_event_t *wev; @@ -102,7 +103,8 @@ ngx_chain_t *ngx_overlapped_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in) { int rc; char *prev; - size_t size, sent; + size_t size; + u_long sent; LPWSABUF wsabuf; ngx_err_t err; ngx_event_t *wev;