nginx-0.1.9-RELEASE import

    *) Bugfix: the proxied request was sent without arguments if the
       request contains "//", "/./", "/../" or "%XX".

    *) Bugfix: the large compressed responses may be transferred not
       completely.

    *) Bugfix: the files bigger than 2G was not transferred on Linux that
       does not support sendfile64().

    *) Bugfix: while the build configuration on Linux the
       --with-poll_module parameter was required; the bug had appeared in
       0.1.8.
diff --git a/src/os/unix/ngx_aio_read.c b/src/os/unix/ngx_aio_read.c
index d011054..2a66eb8 100644
--- a/src/os/unix/ngx_aio_read.c
+++ b/src/os/unix/ngx_aio_read.c
@@ -9,7 +9,7 @@
 #include <ngx_event.h>
 #include <ngx_aio.h>
 
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
 #include <ngx_kqueue_module.h>
 #endif
 
@@ -46,7 +46,7 @@
         rev->aiocb.aio_buf = buf;
         rev->aiocb.aio_nbytes = size;
 
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
         rev->aiocb.aio_sigevent.sigev_notify_kqueue = ngx_kqueue;
         rev->aiocb.aio_sigevent.sigev_notify = SIGEV_KEVENT;
         rev->aiocb.aio_sigevent.sigev_value.sigval_ptr = rev;
diff --git a/src/os/unix/ngx_aio_write.c b/src/os/unix/ngx_aio_write.c
index f102ba3..1d8c1aa 100644
--- a/src/os/unix/ngx_aio_write.c
+++ b/src/os/unix/ngx_aio_write.c
@@ -9,7 +9,7 @@
 #include <ngx_event.h>
 #include <ngx_aio.h>
 
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
 #include <ngx_kqueue_module.h>
 #endif
 
@@ -43,7 +43,7 @@
         wev->aiocb.aio_buf = buf;
         wev->aiocb.aio_nbytes = size;
 
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
         wev->aiocb.aio_sigevent.sigev_notify_kqueue = ngx_kqueue;
         wev->aiocb.aio_sigevent.sigev_notify = SIGEV_KEVENT;
         wev->aiocb.aio_sigevent.sigev_value.sigval_ptr = wev;
diff --git a/src/os/unix/ngx_alloc.c b/src/os/unix/ngx_alloc.c
index 7ec4f87..258a10f 100644
--- a/src/os/unix/ngx_alloc.c
+++ b/src/os/unix/ngx_alloc.c
@@ -40,7 +40,7 @@
 }
 
 
-#if (HAVE_POSIX_MEMALIGN)
+#if (NGX_HAVE_POSIX_MEMALIGN)
 
 void *ngx_memalign(size_t alignment, size_t size, ngx_log_t *log)
 {
@@ -58,7 +58,7 @@
     return p;
 }
 
-#elif (HAVE_MEMALIGN)
+#elif (NGX_HAVE_MEMALIGN)
 
 void *ngx_memalign(size_t alignment, size_t size, ngx_log_t *log)
 {
diff --git a/src/os/unix/ngx_alloc.h b/src/os/unix/ngx_alloc.h
index 0084c2c..66562a1 100644
--- a/src/os/unix/ngx_alloc.h
+++ b/src/os/unix/ngx_alloc.h
@@ -25,7 +25,7 @@
  * allocations bigger than page size at the page boundary.
  */
 
-#if (HAVE_POSIX_MEMALIGN || HAVE_MEMALIGN)
+#if (NGX_HAVE_POSIX_MEMALIGN || NGX_HAVE_MEMALIGN)
 
 void *ngx_memalign(size_t alignment, size_t size, ngx_log_t *log);
 
diff --git a/src/os/unix/ngx_channel.c b/src/os/unix/ngx_channel.c
index 0bfbd0d..b1b36c5 100644
--- a/src/os/unix/ngx_channel.c
+++ b/src/os/unix/ngx_channel.c
@@ -17,7 +17,7 @@
     struct iovec        iov[1];
     struct msghdr       msg;
 
-#if (HAVE_MSGHDR_MSG_CONTROL)
+#if (NGX_HAVE_MSGHDR_MSG_CONTROL)
 
     union {
         struct cmsghdr  cm;
@@ -83,7 +83,7 @@
     struct iovec        iov[1];
     struct msghdr       msg;
 
-#if (HAVE_MSGHDR_MSG_CONTROL)
+#if (NGX_HAVE_MSGHDR_MSG_CONTROL)
     union {
         struct cmsghdr  cm;
         char            space[CMSG_SPACE(sizeof(int))];
@@ -100,7 +100,7 @@
     msg.msg_iov = iov;
     msg.msg_iovlen = 1;
 
-#if (HAVE_MSGHDR_MSG_CONTROL)
+#if (NGX_HAVE_MSGHDR_MSG_CONTROL)
     msg.msg_control = (caddr_t) &cmsg;
     msg.msg_controllen = sizeof(cmsg);
 #else
@@ -131,7 +131,7 @@
         return NGX_ERROR;
     }
 
-#if (HAVE_MSGHDR_MSG_CONTROL)
+#if (NGX_HAVE_MSGHDR_MSG_CONTROL)
 
     if (ch->command == NGX_CMD_OPEN_CHANNEL) {
 
diff --git a/src/os/unix/ngx_errno.c b/src/os/unix/ngx_errno.c
index ced0eaf..607b361 100644
--- a/src/os/unix/ngx_errno.c
+++ b/src/os/unix/ngx_errno.c
@@ -8,7 +8,7 @@
 #include <ngx_core.h>
 
 
-#if (NGX_STRERROR_R)
+#if (NGX_HAVE_STRERROR_R)
 
 u_char *ngx_strerror_r(int err, u_char *errstr, size_t size)
 {
@@ -28,7 +28,7 @@
     return errstr;
 }
 
-#elif (NGX_GNU_STRERROR_R)
+#elif (NGX_HAVE_GNU_STRERROR_R)
 
 /* Linux strerror_r() */
 
diff --git a/src/os/unix/ngx_errno.h b/src/os/unix/ngx_errno.h
index e87ec5f..c1c5801 100644
--- a/src/os/unix/ngx_errno.h
+++ b/src/os/unix/ngx_errno.h
@@ -46,7 +46,7 @@
 #define ngx_set_socket_errno(err)  errno = err
 
 
-#if (HAVE_STRERROR_R || HAVE_GNU_STRERROR_R)
+#if (NGX_HAVE_STRERROR_R || NGX_HAVE_GNU_STRERROR_R)
 
 u_char *ngx_strerror_r(int err, u_char *errstr, size_t size);
 
diff --git a/src/os/unix/ngx_files.c b/src/os/unix/ngx_files.c
index 52aa9b6..e67b2ca 100644
--- a/src/os/unix/ngx_files.c
+++ b/src/os/unix/ngx_files.c
@@ -15,7 +15,7 @@
     ngx_log_debug4(NGX_LOG_DEBUG_CORE, file->log, 0,
                    "read: %d, %p, %uz, %O", file->fd, buf, size, offset);
 
-#if (NGX_PREAD)
+#if (NGX_HAVE_PREAD)
 
     n = pread(file->fd, buf, size, offset);
 
@@ -60,7 +60,7 @@
     ngx_log_debug4(NGX_LOG_DEBUG_CORE, file->log, 0,
                    "write: %d, %p, %uz, %O", file->fd, buf, size, offset);
 
-#if (NGX_PWRITE)
+#if (NGX_HAVE_PWRITE)
 
     n = pwrite(file->fd, buf, size, offset);
 
diff --git a/src/os/unix/ngx_freebsd_config.h b/src/os/unix/ngx_freebsd_config.h
index 7f3b286..35bf1f5 100644
--- a/src/os/unix/ngx_freebsd_config.h
+++ b/src/os/unix/ngx_freebsd_config.h
@@ -60,23 +60,23 @@
 #include <ngx_auto_config.h>
 
 
-#if (HAVE_POLL)
+#if (NGX_HAVE_POLL)
 #include <poll.h>
 #endif
 
 
-#if (HAVE_AIO)
+#if (NGX_HAVE_AIO)
 #include <aio.h>
 #endif
 
 
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
 #include <sys/event.h>
 #endif
 
 
-#if defined SO_ACCEPTFILTER && !defined HAVE_DEFERRED_ACCEPT
-#define HAVE_DEFERRED_ACCEPT  1
+#if defined SO_ACCEPTFILTER && !defined NGX_HAVE_DEFERRED_ACCEPT
+#define NGX_HAVE_DEFERRED_ACCEPT  1
 #endif
 
 
@@ -91,8 +91,8 @@
 #endif
 
 
-#ifndef HAVE_INHERITED_NONBLOCK
-#define HAVE_INHERITED_NONBLOCK  1
+#ifndef NGX_HAVE_INHERITED_NONBLOCK
+#define NGX_HAVE_INHERITED_NONBLOCK  1
 #endif
 
 
diff --git a/src/os/unix/ngx_freebsd_init.c b/src/os/unix/ngx_freebsd_init.c
index faf8e9f..b76dc0c 100644
--- a/src/os/unix/ngx_freebsd_init.c
+++ b/src/os/unix/ngx_freebsd_init.c
@@ -30,7 +30,7 @@
     ngx_unix_recv,
     ngx_readv_chain,
     ngx_unix_send,
-#if (HAVE_SENDFILE)
+#if (NGX_HAVE_SENDFILE)
     ngx_freebsd_sendfile_chain,
     NGX_IO_SENDFILE
 #else
@@ -128,7 +128,7 @@
     version = ngx_freebsd_kern_osreldate;
 
 
-#if (HAVE_SENDFILE)
+#if (NGX_HAVE_SENDFILE)
 
     /*
      * The determination of the sendfile() "nbytes bug" is complex enough.
@@ -161,7 +161,7 @@
 
 #endif
 
-#endif /* HAVE_SENDFILE */
+#endif /* NGX_HAVE_SENDFILE */
 
 
     if ((version < 500000 && version >= 440003) || version >= 500017) {
diff --git a/src/os/unix/ngx_freebsd_rfork_thread.c b/src/os/unix/ngx_freebsd_rfork_thread.c
index b64325b..5dfd468 100644
--- a/src/os/unix/ngx_freebsd_rfork_thread.c
+++ b/src/os/unix/ngx_freebsd_rfork_thread.c
@@ -381,7 +381,7 @@
                 return NGX_AGAIN;
             }
 
-            if (ngx_freebsd_hw_ncpu > 1 && tries++ < 1000) {
+            if (ngx_ncpu > 1 && tries++ < 1000) {
 
                 /* the spinlock is used only on the SMP system */
 
@@ -581,7 +581,7 @@
     }
 
     cv->signo = NGX_CV_SIGNAL;
-    cv->tid = 0;
+    cv->tid = -1;
     cv->log = log;
     cv->kq = -1;
 
@@ -640,6 +640,8 @@
             ngx_log_error(NGX_LOG_ALERT, cv->log, ngx_errno, "kevent() failed");
             return NGX_ERROR;
         }
+
+        cv->tid = ngx_thread_self();
     }
 
     if (ngx_mutex_unlock(m) == NGX_ERROR) {
@@ -714,6 +716,10 @@
                    "cv %p to signal %P %d",
                    cv, cv->tid, cv->signo);
 
+    if (cv->tid == -1) {
+        return NGX_OK;
+    }
+
     if (kill(cv->tid, cv->signo) == -1) {
 
         err = ngx_errno;
diff --git a/src/os/unix/ngx_freebsd_sendfile_chain.c b/src/os/unix/ngx_freebsd_sendfile_chain.c
index 192a1a1..f86e1c0 100644
--- a/src/os/unix/ngx_freebsd_sendfile_chain.c
+++ b/src/os/unix/ngx_freebsd_sendfile_chain.c
@@ -55,7 +55,7 @@
         return in;
     }
 
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
 
     if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT) && wev->pending_eof) {
         ngx_log_error(NGX_LOG_INFO, c->log, wev->kq_errno,
diff --git a/src/os/unix/ngx_linux_config.h b/src/os/unix/ngx_linux_config.h
index 57ee505..620b59d 100644
--- a/src/os/unix/ngx_linux_config.h
+++ b/src/os/unix/ngx_linux_config.h
@@ -56,35 +56,37 @@
 #include <sys/prctl.h>
 #endif
 
+
 #if (NGX_HAVE_SENDFILE64)
 #include <sys/sendfile.h>
 #else
 extern ssize_t sendfile(int s, int fd, int32_t *offset, size_t size);
+#define NGX_SENDFILE_LIMIT  (NGX_MAX_UINT32_VALUE + 1)
 #endif
 
 
-#if (HAVE_POLL)
+#if (NGX_HAVE_POLL)
 #include <poll.h>
 #endif
 
 
-#if (HAVE_EPOLL)
+#if (NGX_HAVE_EPOLL)
 #include <sys/epoll.h>
-#endif /* HAVE_EPOLL */
-
-
-#if defined TCP_DEFER_ACCEPT && !defined HAVE_DEFERRED_ACCEPT
-#define HAVE_DEFERRED_ACCEPT  1
 #endif
 
 
-#ifndef HAVE_INHERITED_NONBLOCK
-#define HAVE_INHERITED_NONBLOCK  0
+#if defined TCP_DEFER_ACCEPT && !defined NGX_HAVE_DEFERRED_ACCEPT
+#define NGX_HAVE_DEFERRED_ACCEPT  1
 #endif
 
 
-#ifndef HAVE_SELECT_CHANGE_TIMEOUT
-#define HAVE_SELECT_CHANGE_TIMEOUT   1
+#ifndef NGX_HAVE_INHERITED_NONBLOCK
+#define NGX_HAVE_INHERITED_NONBLOCK  0
+#endif
+
+
+#ifndef NGX_HAVE_SELECT_CHANGE_TIMEOUT
+#define NGX_HAVE_SELECT_CHANGE_TIMEOUT   1
 #endif
 
 #ifndef NGX_SETPROCTITLE_USES_ENV
diff --git a/src/os/unix/ngx_linux_init.c b/src/os/unix/ngx_linux_init.c
index 397d342..9c1c847 100644
--- a/src/os/unix/ngx_linux_init.c
+++ b/src/os/unix/ngx_linux_init.c
@@ -18,7 +18,7 @@
     ngx_unix_recv,
     ngx_readv_chain,
     ngx_unix_send,
-#if (HAVE_SENDFILE)
+#if (NGX_HAVE_SENDFILE)
     ngx_linux_sendfile_chain,
     NGX_IO_SENDFILE
 #else
diff --git a/src/os/unix/ngx_linux_sendfile_chain.c b/src/os/unix/ngx_linux_sendfile_chain.c
index ad40f55..bcf9d4c 100644
--- a/src/os/unix/ngx_linux_sendfile_chain.c
+++ b/src/os/unix/ngx_linux_sendfile_chain.c
@@ -13,7 +13,7 @@
  * On Linux up to 2.4.21 sendfile() (syscall #187) works with 32-bit
  * offsets only and the including <sys/sendfile.h> breaks the compiling
  * if off_t is 64 bit wide.  So we use own sendfile() definition where offset
- * parameter is int32_t and use sendfile() with the file parts below 2G.
+ * parameter is int32_t and use sendfile() for the file parts below 2G only.
  *
  * Linux 2.4.21 has a new sendfile64() syscall #239.
  */
diff --git a/src/os/unix/ngx_os.h b/src/os/unix/ngx_os.h
index dc9f7a8..ee91df3 100644
--- a/src/os/unix/ngx_os.h
+++ b/src/os/unix/ngx_os.h
@@ -15,18 +15,6 @@
 #define NGX_IO_SENDFILE    1
 #define NGX_IO_ZEROCOPY    2
 
-#if (HAVE_SENDFILE)
-#define NGX_HAVE_SENDFILE  NGX_IO_SENDFILE
-#else
-#define NGX_HAVE_SENDFILE  0
-#endif
-
-#if (HAVE_ZEROCOPY)
-#define NGX_HAVE_ZEROCOPY  NGX_IO_ZEROCOPY
-#else
-#define NGX_HAVE_ZEROCOPY  0
-#endif
-
 
 typedef ssize_t (*ngx_recv_pt)(ngx_connection_t *c, u_char *buf, size_t size);
 typedef ssize_t (*ngx_recv_chain_pt)(ngx_connection_t *c, ngx_chain_t *in);
diff --git a/src/os/unix/ngx_posix_config.h b/src/os/unix/ngx_posix_config.h
index b187236..f9c91a4 100644
--- a/src/os/unix/ngx_posix_config.h
+++ b/src/os/unix/ngx_posix_config.h
@@ -70,17 +70,17 @@
 #include <ngx_auto_config.h>
 
 
-#if (HAVE_POLL)
+#if (NGX_HAVE_POLL)
 #include <poll.h>
 #endif
 
 
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
 #include <sys/event.h>
 #endif
 
 
-#if (HAVE_DEVPOLL)
+#if (NGX_HAVE_DEVPOLL)
 #include <sys/ioctl.h>
 #include <sys/devpoll.h>
 #endif
diff --git a/src/os/unix/ngx_posix_init.c b/src/os/unix/ngx_posix_init.c
index 19d65a4..56be0ce 100644
--- a/src/os/unix/ngx_posix_init.c
+++ b/src/os/unix/ngx_posix_init.c
@@ -121,7 +121,7 @@
 
     ngx_max_sockets = rlmt.rlim_cur;
 
-#if (HAVE_INHERITED_NONBLOCK)
+#if (NGX_HAVE_INHERITED_NONBLOCK)
     ngx_inherited_nonblocking = 1;
 #else
     ngx_inherited_nonblocking = 0;
diff --git a/src/os/unix/ngx_process_cycle.c b/src/os/unix/ngx_process_cycle.c
index 37b2ef1..3d1c51b 100644
--- a/src/os/unix/ngx_process_cycle.c
+++ b/src/os/unix/ngx_process_cycle.c
@@ -607,6 +607,10 @@
 
 static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
 {
+    ngx_int_t          n;
+    ngx_err_t          err;
+    ngx_core_conf_t   *ccf;
+
     ngx_worker_process_init(cycle);
 
     ngx_setproctitle("worker process");
@@ -618,6 +622,8 @@
         exit(2);
     }
 
+    ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
+
     if (ngx_threads_n) {
         if (ngx_init_threads(ngx_threads_n,
                                    ccf->thread_stack_size, cycle) == NGX_ERROR)
@@ -914,10 +920,9 @@
 
         for (i = 0; i < ngx_threads_n; i++) {
             if (ngx_threads[i].state < NGX_THREAD_EXIT) {
-                ngx_cond_signal(ngx_threads[i].cv);
-
-                if (ngx_threads[i].cv->tid == (ngx_tid_t) -1) {
+                if (ngx_cond_signal(ngx_threads[i].cv) == NGX_ERROR) {
                     ngx_threads[i].state = NGX_THREAD_DONE;
+
                 } else {
                     live = 1;
                 }
@@ -955,8 +960,6 @@
     ngx_core_tls_t   *tls;
     ngx_cycle_t      *cycle;
 
-    thr->cv->tid = ngx_thread_self();
-
     cycle = (ngx_cycle_t *) ngx_cycle;
 
     sigemptyset(&set);
diff --git a/src/os/unix/ngx_readv_chain.c b/src/os/unix/ngx_readv_chain.c
index 2db998a..7c57b7a 100644
--- a/src/os/unix/ngx_readv_chain.c
+++ b/src/os/unix/ngx_readv_chain.c
@@ -9,7 +9,7 @@
 #include <ngx_event.h>
 
 
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
 
 ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
 {
@@ -136,7 +136,7 @@
     return n;
 }
 
-#else /* ! NAVE_KQUEUE */
+#else /* ! NGX_HAVE_KQUEUE */
 
 ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
 {
@@ -216,4 +216,4 @@
     return n;
 }
 
-#endif /* NAVE_KQUEUE */
+#endif /* NGX_HAVE_KQUEUE */
diff --git a/src/os/unix/ngx_recv.c b/src/os/unix/ngx_recv.c
index d58ca9e..369be66 100644
--- a/src/os/unix/ngx_recv.c
+++ b/src/os/unix/ngx_recv.c
@@ -9,7 +9,7 @@
 #include <ngx_event.h>
 
 
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
 
 ssize_t ngx_unix_recv(ngx_connection_t *c, u_char *buf, size_t size)
 {
@@ -115,7 +115,7 @@
     return n;
 }
 
-#else /* ! NAVE_KQUEUE */
+#else /* ! NGX_HAVE_KQUEUE */
 
 ssize_t ngx_unix_recv(ngx_connection_t *c, u_char *buf, size_t size)
 {
@@ -170,4 +170,4 @@
     return n;
 }
 
-#endif /* NAVE_KQUEUE */
+#endif /* NGX_HAVE_KQUEUE */
diff --git a/src/os/unix/ngx_send.c b/src/os/unix/ngx_send.c
index ff501c3..ecd1362 100644
--- a/src/os/unix/ngx_send.c
+++ b/src/os/unix/ngx_send.c
@@ -17,7 +17,7 @@
 
     wev = c->write;
 
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
 
     if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT) && wev->pending_eof) {
         ngx_log_error(NGX_LOG_INFO, c->log, wev->kq_errno,
diff --git a/src/os/unix/ngx_shared.c b/src/os/unix/ngx_shared.c
index 0edc8cb..80b5f60 100644
--- a/src/os/unix/ngx_shared.c
+++ b/src/os/unix/ngx_shared.c
@@ -8,7 +8,7 @@
 #include <ngx_core.h>
 
 
-#if (HAVE_MAP_ANON)
+#if (NGX_HAVE_MAP_ANON)
 
 void *ngx_create_shared_memory(size_t size, ngx_log_t *log)
 {
@@ -25,7 +25,7 @@
     return p;
 }
 
-#elif (HAVE_MAP_DEVZERO)
+#elif (NGX_HAVE_MAP_DEVZERO)
 
 void *ngx_create_shared_memory(size_t size, ngx_log_t *log)
 {
@@ -56,7 +56,7 @@
     return p;
 }
 
-#elif (HAVE_SYSVSHM)
+#elif (NGX_HAVE_SYSVSHM)
 
 #include <sys/ipc.h>
 #include <sys/shm.h>
diff --git a/src/os/unix/ngx_socket.c b/src/os/unix/ngx_socket.c
index da936b2..523f1f4 100644
--- a/src/os/unix/ngx_socket.c
+++ b/src/os/unix/ngx_socket.c
@@ -20,7 +20,7 @@
  */
 
 
-#if (HAVE_FIONBIO)
+#if (NGX_HAVE_FIONBIO)
 
 int ngx_nonblocking(ngx_socket_t s)
 {
diff --git a/src/os/unix/ngx_socket.h b/src/os/unix/ngx_socket.h
index 4dcf924..b381967 100644
--- a/src/os/unix/ngx_socket.h
+++ b/src/os/unix/ngx_socket.h
@@ -19,7 +19,7 @@
 #define ngx_socket_n        "socket()"
 
 
-#if (HAVE_FIONBIO)
+#if (NGX_HAVE_FIONBIO)
 
 int ngx_nonblocking(ngx_socket_t s);
 int ngx_blocking(ngx_socket_t s);
diff --git a/src/os/unix/ngx_solaris_config.h b/src/os/unix/ngx_solaris_config.h
index 8f18417..452850c 100644
--- a/src/os/unix/ngx_solaris_config.h
+++ b/src/os/unix/ngx_solaris_config.h
@@ -49,35 +49,35 @@
 #include <ngx_auto_config.h>
 
 
-#if (HAVE_POLL)
+#if (NGX_HAVE_POLL)
 #include <poll.h>
 #endif
 
 
-#if (HAVE_SENDFILE)
+#if (NGX_HAVE_SENDFILE)
 #include <sys/sendfile.h>
 #endif
 
 
-#if (HAVE_AIO)
+#if (NGX_HAVE_AIO)
 #include <aio.h>
 #endif
 
 
-#if (HAVE_DEVPOLL)
+#if (NGX_HAVE_DEVPOLL)
 #include <sys/ioctl.h>
 #include <sys/devpoll.h>
 #endif
 
 
-#ifndef HAVE_INHERITED_NONBLOCK
-#define HAVE_INHERITED_NONBLOCK  1
+#ifndef NGX_HAVE_INHERITED_NONBLOCK
+#define NGX_HAVE_INHERITED_NONBLOCK  1
 #endif
 
 
-#ifndef HAVE_SO_SNDLOWAT
+#ifndef NGX_HAVE_SO_SNDLOWAT
 /* setsockopt(SO_SNDLOWAT) returns error "Option not supported by protocol" */
-#define HAVE_SO_SNDLOWAT         0
+#define NGX_HAVE_SO_SNDLOWAT         0
 #endif
 
 
diff --git a/src/os/unix/ngx_solaris_init.c b/src/os/unix/ngx_solaris_init.c
index c671197..03072ed 100644
--- a/src/os/unix/ngx_solaris_init.c
+++ b/src/os/unix/ngx_solaris_init.c
@@ -17,7 +17,7 @@
     ngx_unix_recv,
     ngx_readv_chain,
     ngx_unix_send,
-#if (HAVE_SENDFILE)
+#if (NGX_HAVE_SENDFILE)
     ngx_solaris_sendfilev_chain,
     NGX_IO_SENDFILE
 #else
diff --git a/src/os/unix/ngx_thread.h b/src/os/unix/ngx_thread.h
index ac7cfad..e630b35 100644
--- a/src/os/unix/ngx_thread.h
+++ b/src/os/unix/ngx_thread.h
@@ -53,7 +53,6 @@
 
 typedef struct {
     pthread_cond_t    cond;
-    ngx_tid_t         tid;
     ngx_log_t        *log;
 } ngx_cond_t;
 
diff --git a/src/os/unix/ngx_time.c b/src/os/unix/ngx_time.c
index c438950..20ec464 100644
--- a/src/os/unix/ngx_time.c
+++ b/src/os/unix/ngx_time.c
@@ -10,7 +10,7 @@
 
 void ngx_localtime(ngx_tm_t *tm)
 {
-#if (HAVE_LOCALTIME_R)
+#if (NGX_HAVE_LOCALTIME_R)
     time_t     now;
 
     now = ngx_time();
diff --git a/src/os/unix/ngx_time.h b/src/os/unix/ngx_time.h
index a6acf59..f257325 100644
--- a/src/os/unix/ngx_time.h
+++ b/src/os/unix/ngx_time.h
@@ -36,7 +36,7 @@
 #define ngx_tm_wday_t  int
 
 
-#if (HAVE_GMTOFF)
+#if (NGX_HAVE_GMTOFF)
 #define ngx_tm_gmtoff  tm_gmtoff
 #define ngx_tm_zone    tm_zone
 #endif
diff --git a/src/os/unix/ngx_writev_chain.c b/src/os/unix/ngx_writev_chain.c
index e389322..2af6469 100644
--- a/src/os/unix/ngx_writev_chain.c
+++ b/src/os/unix/ngx_writev_chain.c
@@ -30,7 +30,7 @@
         return in;
     }
 
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
 
     if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT) && wev->pending_eof) {
         ngx_log_error(NGX_LOG_INFO, c->log, wev->kq_errno,
diff --git a/src/os/win32/ngx_os.h b/src/os/win32/ngx_os.h
index c27f8a8..6d720fa 100644
--- a/src/os/win32/ngx_os.h
+++ b/src/os/win32/ngx_os.h
@@ -15,18 +15,6 @@
 #define NGX_IO_SENDFILE    1
 #define NGX_IO_ZEROCOPY    2
 
-#if (HAVE_SENDFILE)
-#define NGX_HAVE_SENDFILE  NGX_IO_SENDFILE
-#else
-#define NGX_HAVE_SENDFILE  0
-#endif
-
-#if (HAVE_ZEROCOPY)
-#define NGX_HAVE_ZEROCOPY  NGX_IO_ZEROCOPY
-#else
-#define NGX_HAVE_ZEROCOPY  0
-#endif
-
 
 typedef ssize_t (*ngx_recv_pt)(ngx_connection_t *c, u_char *buf, size_t size);
 typedef ssize_t (*ngx_recv_chain_pt)(ngx_connection_t *c, ngx_chain_t *in);
diff --git a/src/os/win32/ngx_time.h b/src/os/win32/ngx_time.h
index 665976d..4cb9841 100644
--- a/src/os/win32/ngx_time.h
+++ b/src/os/win32/ngx_time.h
@@ -39,7 +39,7 @@
 
 #define ngx_msleep       Sleep
 
-#define HAVE_GETTIMEZONE  1
+#define NGX_HAVE_GETTIMEZONE  1
 
 ngx_int_t ngx_gettimezone(void);
 void ngx_gettimeofday(struct timeval *tp);
diff --git a/src/os/win32/ngx_win32_config.h b/src/os/win32/ngx_win32_config.h
index e7d3086..c7703c2 100644
--- a/src/os/win32/ngx_win32_config.h
+++ b/src/os/win32/ngx_win32_config.h
@@ -115,37 +115,31 @@
 
 
 #define TIME_T_LEN        sizeof("-2147483648") - 1
+#define OFF_T_MAX_VALUE   9223372036854775807
+#define NGX_HAVE_LITTLE_ENDIAN  1
+
+#define NGX_THREADS       1
 
 
 #define NGX_WIN_NT        200000
 
 
-#define NGX_THREADS       1
-
-
-#ifndef HAVE_INHERITED_NONBLOCK
-#define HAVE_INHERITED_NONBLOCK  1
+#ifndef NGX_HAVE_INHERITED_NONBLOCK
+#define NGX_HAVE_INHERITED_NONBLOCK  1
 #endif
 
-#ifndef HAVE_WIN32_TRANSMITPACKETS
-#define HAVE_WIN32_TRANSMITPACKETS  1
-#define HAVE_WIN32_TRANSMITFILE     0
+#ifndef NGX_HAVE_WIN32_TRANSMITPACKETS
+#define NGX_HAVE_WIN32_TRANSMITPACKETS  1
+#define NGX_HAVE_WIN32_TRANSMITFILE     0
 #endif
 
-#ifndef HAVE_WIN32_TRANSMITFILE
-#define HAVE_WIN32_TRANSMITFILE  1
+#ifndef NGX_HAVE_WIN32_TRANSMITFILE
+#define NGX_HAVE_WIN32_TRANSMITFILE  1
 #endif
 
-#if (HAVE_WIN32_TRANSMITPACKETS) || (HAVE_WIN32_TRANSMITFILE)
-#define HAVE_SENDFILE  1
+#if (NGX_HAVE_WIN32_TRANSMITPACKETS) || (NGX_HAVE_WIN32_TRANSMITFILE)
+#define NGX_HAVE_SENDFILE  1
 #endif
 
 
-#define OFF_T_MAX_VALUE  9223372036854775807
-
-
-/* STUB */
-#define HAVE_LITTLE_ENDIAN  1
-
-
 #endif /* _NGX_WIN32_CONFIG_H_INCLUDED_ */