nginx-0.0.3-2004-06-06-23:49:18 import
diff --git a/src/os/unix/ngx_alloc.c b/src/os/unix/ngx_alloc.c
new file mode 100644
index 0000000..69925d1
--- /dev/null
+++ b/src/os/unix/ngx_alloc.c
@@ -0,0 +1,75 @@
+
+#include <ngx_config.h>
+#include <ngx_core.h>
+
+
+int ngx_pagesize;
+
+
+void *ngx_alloc(size_t size, ngx_log_t *log)
+{
+ void *p;
+
+ if (!(p = malloc(size))) {
+ ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
+ "malloc() " SIZE_T_FMT " bytes failed", size);
+ }
+
+ ngx_log_debug2(NGX_LOG_DEBUG_ALLOC, log, 0,
+ "malloc: " PTR_FMT ":" SIZE_T_FMT, p, size);
+
+ return p;
+}
+
+
+void *ngx_calloc(size_t size, ngx_log_t *log)
+{
+ void *p;
+
+ p = ngx_alloc(size, log);
+
+ if (p) {
+ ngx_memzero(p, size);
+ }
+
+ return p;
+}
+
+
+#if (HAVE_POSIX_MEMALIGN)
+
+void *ngx_memalign(size_t aligment, size_t size, ngx_log_t *log)
+{
+ void *p;
+
+ if (posix_memalign(&p, aligment, size) == -1) {
+ ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
+ "posix_memalign() " SIZE_T_FMT " bytes aligned to "
+ SIZE_T_FMT " failed", size, alignment);
+ }
+
+ ngx_log_debug2(NGX_LOG_DEBUG_ALLOC, log, 0,
+ "posix_memalign: " PTR_FMT ":" SIZE_T_FMT, p, size);
+
+ return p;
+}
+
+#esif (HAVE_MEMALIGN)
+
+void *ngx_memalign(size_t aligment, size_t size, ngx_log_t *log)
+{
+ void *p;
+
+ if (!(p = memalign(aligment, size))) {
+ ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
+ "memalign() " SIZE_T_FMT " bytes aligned to "
+ SIZE_T_FMT " failed", size, alignment);
+ }
+
+ ngx_log_debug2(NGX_LOG_DEBUG_ALLOC, log, 0,
+ "memalign: " PTR_FMT ":" SIZE_T_FMT, p, size);
+
+ return p;
+}
+
+#endif
diff --git a/src/os/unix/ngx_alloc.h b/src/os/unix/ngx_alloc.h
new file mode 100644
index 0000000..650f8be
--- /dev/null
+++ b/src/os/unix/ngx_alloc.h
@@ -0,0 +1,36 @@
+#ifndef _NGX_ALLOC_H_INCLUDED_
+#define _NGX_ALLOC_H_INCLUDED_
+
+
+#include <ngx_config.h>
+#include <ngx_core.h>
+
+
+void *ngx_alloc(size_t size, ngx_log_t *log);
+void *ngx_calloc(size_t size, ngx_log_t *log);
+
+#define ngx_free free
+
+
+/*
+ * Linux has memalign() or posix_memalign()
+ * Solaris has memalign()
+ * FreeBSD has not memalign() or posix_memalign() but its malloc() alignes
+ * allocations bigger than page size at page boundary.
+ */
+
+#if (HAVE_POSIX_MEMALIGN || HAVE_MEMALIGN)
+
+void *ngx_memalign(size_t alignment, size_t size, ngx_log_t *log);
+
+#else
+
+#define ngx_memalign(alignment, size, log) ngx_alloc(size, log)
+
+#endif
+
+
+extern int ngx_pagesize;
+
+
+#endif /* _NGX_ALLOC_H_INCLUDED_ */
diff --git a/src/os/unix/ngx_freebsd_rfork_thread.c b/src/os/unix/ngx_freebsd_rfork_thread.c
index 1cdfee4..740fb52 100644
--- a/src/os/unix/ngx_freebsd_rfork_thread.c
+++ b/src/os/unix/ngx_freebsd_rfork_thread.c
@@ -30,7 +30,7 @@
size_t ngx_thread_stack_size;
-static size_t rz_size = /* STUB: PAGE_SIZE */ 4096;
+static size_t rz_size;
static size_t usable_stack_size;
static char *last_stack;
@@ -187,6 +187,7 @@
}
/* the main thread stack red zone */
+ rz_size = ngx_pagesize;
red_zone = ngx_freebsd_kern_usrstack - (size + rz_size);
ngx_log_debug2(NGX_LOG_DEBUG_CORE, cycle->log, 0,
diff --git a/src/os/unix/ngx_posix_init.c b/src/os/unix/ngx_posix_init.c
index 65c04a9..dc96ddd 100644
--- a/src/os/unix/ngx_posix_init.c
+++ b/src/os/unix/ngx_posix_init.c
@@ -60,6 +60,8 @@
struct rlimit rlmt;
struct sigaction sa;
+ ngx_pagesize = getpagesize();
+
for (sig = signals; sig->signo != 0; sig++) {
ngx_memzero(&sa, sizeof(struct sigaction));
sa.sa_handler = sig->handler;
diff --git a/src/os/unix/ngx_socket.c b/src/os/unix/ngx_socket.c
index 69d3f45..443c93b 100644
--- a/src/os/unix/ngx_socket.c
+++ b/src/os/unix/ngx_socket.c
@@ -9,7 +9,9 @@
* a previous state using fcntl(F_GETFL).
*
* ioctl() and fcntl() are syscalls on at least FreeBSD 2.x, Linux 2.2
- * and Solaris 7
+ * and Solaris 7.
+ *
+ * ioctl() in Linux 2.4 and 2.6 uses BKL, however fcntl(F_SETFL) uses it too.
*/
diff --git a/src/os/unix/ngx_time.h b/src/os/unix/ngx_time.h
index 0b44c5a..dbb7a0a 100644
--- a/src/os/unix/ngx_time.h
+++ b/src/os/unix/ngx_time.h
@@ -38,7 +38,7 @@
#if (SOLARIS)
#define HAVE_TIMEZONE 1
-#define ngx_timezone() (-((daylight) ? altzone : timezone) / 60)
+#define ngx_timezone() (- (daylight ? altzone : timezone) / 60)
#elif defined __linux__
#define HAVE_TIMEZONE 1