nginx-0.0.1-2003-11-13-19:16:33 import
diff --git a/src/os/unix/ngx_freebsd.h b/src/os/unix/ngx_freebsd.h
new file mode 100644
index 0000000..f666a6f
--- /dev/null
+++ b/src/os/unix/ngx_freebsd.h
@@ -0,0 +1,16 @@
+#ifndef _NGX_FREEBSD_H_INCLUDED_
+#define _NGX_FREEBSD_H_INCLUDED_
+
+
+ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in);
+
+
+extern int ngx_freebsd_kern_osreldate;
+extern int ngx_freebsd_hw_ncpu;
+extern int ngx_freebsd_net_inet_tcp_sendspace;
+extern int ngx_freebsd_sendfile_nbytes_bug;
+extern int ngx_freebsd_kern_ipc_zero_copy_send;
+extern int ngx_freebsd_use_tcp_nopush;
+
+
+#endif /* _NGX_FREEBSD_H_INCLUDED_ */
diff --git a/src/os/unix/ngx_freebsd_config.h b/src/os/unix/ngx_freebsd_config.h
index 233cae5..d53339f 100644
--- a/src/os/unix/ngx_freebsd_config.h
+++ b/src/os/unix/ngx_freebsd_config.h
@@ -24,23 +24,35 @@
#include <osreldate.h>
+/* TODO: autoconf */
+#if __FreeBSD_version < 300007
+typedef u_int64_t uint64_t;
+typedef u_int32_t uintptr_t;
+#endif
+
+
+#if __FreeBSD_version < 330002 /* exactly */
+typedef uint32_t socklen_t;
+#endif
+
+
#if (i386)
#define OFF_FMT "%lld"
#define SIZE_FMT "%d"
#define SIZEX_FMT "%x"
-#define TIME_FMT "%lu"
#else /* amd64, alpha, sparc64, ia64 */
#define OFF_FMT "%ld"
#define SIZE_FMT "%ld"
#define SIZEX_FMT "%lx"
-#define TIME_FMT "%lu"
#endif
+#define TIME_FMT "%lu"
#define PID_FMT "%d"
+#define RLIM_FMT "%lld"
#ifndef HAVE_SELECT
diff --git a/src/os/unix/ngx_freebsd_init.c b/src/os/unix/ngx_freebsd_init.c
index 8bf25d0..4f3146d 100644
--- a/src/os/unix/ngx_freebsd_init.c
+++ b/src/os/unix/ngx_freebsd_init.c
@@ -1,5 +1,6 @@
-#include <ngx_freebsd_init.h>
+#include <ngx_config.h>
+#include <ngx_core.h>
/* FreeBSD 3.4 at least */
diff --git a/src/os/unix/ngx_freebsd_init.h b/src/os/unix/ngx_freebsd_init.h
deleted file mode 100644
index d77bf81..0000000
--- a/src/os/unix/ngx_freebsd_init.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef _NGX_FREEBSD_INIT_H_INCLUDED_
-#define _NGX_FREEBSD_INIT_H_INCLUDED_
-
-
-#include <ngx_config.h>
-#include <ngx_core.h>
-
-
-/* STUB */
-int ngx_posix_init(ngx_log_t *log);
-ssize_t ngx_unix_recv(ngx_connection_t *c, char *buf, size_t size);
-ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *entry);
-/* */
-
-ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in);
-
-
-extern int ngx_freebsd_kern_osreldate;
-extern int ngx_freebsd_hw_ncpu;
-extern int ngx_freebsd_net_inet_tcp_sendspace;
-extern int ngx_freebsd_sendfile_nbytes_bug;
-extern int ngx_freebsd_kern_ipc_zero_copy_send;
-extern int ngx_freebsd_use_tcp_nopush;
-
-
-#endif /* _NGX_FREEBSD_INIT_H_INCLUDED_ */
diff --git a/src/os/unix/ngx_freebsd_sendfile_chain.c b/src/os/unix/ngx_freebsd_sendfile_chain.c
index 65dfc03..71368c7 100644
--- a/src/os/unix/ngx_freebsd_sendfile_chain.c
+++ b/src/os/unix/ngx_freebsd_sendfile_chain.c
@@ -2,7 +2,6 @@
#include <ngx_config.h>
#include <ngx_core.h>
#include <ngx_event.h>
-#include <ngx_freebsd_init.h>
/*
diff --git a/src/os/unix/ngx_linux_config.h b/src/os/unix/ngx_linux_config.h
index ca53a23..962d17e 100644
--- a/src/os/unix/ngx_linux_config.h
+++ b/src/os/unix/ngx_linux_config.h
@@ -34,8 +34,9 @@
#define OFF_FMT "%lld"
#define SIZE_FMT "%d"
#define SIZEX_FMT "%x"
-#define PID_FMT "%d"
#define TIME_FMT "%lu"
+#define PID_FMT "%d"
+#define RLIM_FMT "%lu"
diff --git a/src/os/unix/ngx_linux_init.c b/src/os/unix/ngx_linux_init.c
index 64bdce4..86b98aa 100644
--- a/src/os/unix/ngx_linux_init.c
+++ b/src/os/unix/ngx_linux_init.c
@@ -3,12 +3,6 @@
#include <ngx_core.h>
-/* STUB */
-ssize_t ngx_unix_recv(ngx_connection_t *c, char *buf, size_t size);
-ngx_chain_t *ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in);
-int ngx_posix_init(ngx_log_t *log);
-
-
char ngx_linux_kern_ostype[50];
char ngx_linux_kern_osrelease[20];
diff --git a/src/os/unix/ngx_os.h b/src/os/unix/ngx_os.h
new file mode 100644
index 0000000..33e3943
--- /dev/null
+++ b/src/os/unix/ngx_os.h
@@ -0,0 +1,58 @@
+#ifndef _NGX_OS_H_INCLUDED_
+#define _NGX_OS_H_INCLUDED_
+
+
+#include <ngx_config.h>
+#include <ngx_core.h>
+
+
+#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 struct {
+ ssize_t (*recv)(ngx_connection_t *c, char *buf, size_t size);
+ ssize_t (*recv_chain)(ngx_connection_t *c, ngx_chain_t *in);
+ ssize_t (*send)(ngx_connection_t *c, char *buf, size_t size);
+ ngx_chain_t *(*send_chain)(ngx_connection_t *c, ngx_chain_t *in);
+ int flags;
+} ngx_os_io_t;
+
+
+int ngx_os_init(ngx_log_t *log);
+int ngx_daemon(ngx_log_t *log);
+int ngx_posix_init(ngx_log_t *log);
+
+ssize_t ngx_unix_recv(ngx_connection_t *c, char *buf, size_t size);
+ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *entry);
+ngx_chain_t *ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in);
+
+
+extern ngx_os_io_t ngx_os_io;
+extern int ngx_max_sockets;
+extern int ngx_inherited_nonblocking;
+
+
+extern int restart;
+extern int rotate;
+
+
+#ifdef __FreeBSD__
+#include <ngx_freebsd.h>
+#endif
+
+
+#endif /* _NGX_OS_H_INCLUDED_ */
diff --git a/src/os/unix/ngx_posix_init.c b/src/os/unix/ngx_posix_init.c
index fe91408..c970833 100644
--- a/src/os/unix/ngx_posix_init.c
+++ b/src/os/unix/ngx_posix_init.c
@@ -47,7 +47,7 @@
}
ngx_log_error(NGX_LOG_INFO, log, 0,
- "getrlimit(RLIMIT_NOFILE): %qd:%qd",
+ "getrlimit(RLIMIT_NOFILE): " RLIM_FMT ":" RLIM_FMT,
rlmt.rlim_cur, rlmt.rlim_max);
ngx_max_sockets = rlmt.rlim_cur;
diff --git a/src/os/unix/ngx_solaris_config.h b/src/os/unix/ngx_solaris_config.h
index 21724f8..fe680b8 100644
--- a/src/os/unix/ngx_solaris_config.h
+++ b/src/os/unix/ngx_solaris_config.h
@@ -22,6 +22,7 @@
#include <sys/filio.h> /* FIONBIO */
#include <sys/stropts.h> /* INFTIM */
#include <sys/socket.h>
+#include <sys/systeminfo.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
@@ -32,8 +33,9 @@
#define OFF_FMT "%lld"
#define SIZE_FMT "%d"
#define SIZEX_FMT "%x"
-#define PID_FMT "%ld"
#define TIME_FMT "%lu"
+#define PID_FMT "%ld"
+#define RLIM_FMT "%lu"
#ifndef HAVE_SELECT
diff --git a/src/os/unix/ngx_solaris_init.c b/src/os/unix/ngx_solaris_init.c
new file mode 100644
index 0000000..c593ed9
--- /dev/null
+++ b/src/os/unix/ngx_solaris_init.c
@@ -0,0 +1,51 @@
+
+#include <ngx_config.h>
+#include <ngx_core.h>
+
+
+char ngx_solaris_sysname[20];
+char ngx_solaris_release[10];
+char ngx_solaris_version[50];
+
+
+ngx_os_io_t ngx_os_io = {
+ ngx_unix_recv,
+ NULL,
+ NULL,
+ ngx_writev_chain,
+ NGX_HAVE_ZEROCOPY
+};
+
+
+int ngx_os_init(ngx_log_t *log)
+{
+ if (sysinfo(SI_SYSNAME, ngx_solaris_sysname, sizeof(ngx_solaris_sysname))
+ == -1)
+ {
+ ngx_log_error(NGX_LOG_ALERT, log, errno, "sysinfo(SI_SYSNAME) failed");
+ return NGX_ERROR;
+ }
+
+ if (sysinfo(SI_RELEASE, ngx_solaris_release, sizeof(ngx_solaris_release))
+ == -1)
+ {
+ ngx_log_error(NGX_LOG_ALERT, log, errno, "sysinfo(SI_RELEASE) failed");
+ return NGX_ERROR;
+ }
+
+ if (sysinfo(SI_VERSION, ngx_solaris_version, sizeof(ngx_solaris_version))
+ == -1)
+ {
+ ngx_log_error(NGX_LOG_ALERT, log, errno, "sysinfo(SI_SYSNAME) failed");
+ return NGX_ERROR;
+ }
+
+ ngx_log_error(NGX_LOG_INFO, log, 0, "OS: %s %s"
+ ngx_solaris_sysname, ngx_solaris_release);
+
+ ngx_log_error(NGX_LOG_INFO, log, 0, "version: %s",
+ ngx_solaris_version);
+
+
+ return ngx_posix_init(log);
+}
diff --git a/src/os/unix/ngx_time.h b/src/os/unix/ngx_time.h
index d942900..b8c6422 100644
--- a/src/os/unix/ngx_time.h
+++ b/src/os/unix/ngx_time.h
@@ -20,7 +20,10 @@
#define ngx_tm_mon tm_mon
#define ngx_tm_year tm_year
#define ngx_tm_wday tm_wday
+
+#ifndef SOLARIS
#define ngx_tm_zone tm_zone
+#endif
void ngx_localtime(ngx_tm_t *tm);