make 64-bit ngx_int_t on 64-bit platforms

This commit is contained in:
Igor Sysoev 2007-07-29 18:24:53 +00:00
parent 8889b65711
commit 83a6851b28
23 changed files with 183 additions and 169 deletions

View File

@ -36,5 +36,6 @@ if [ $found = no ]; then
found="uint`expr 8 \* $ngx_ptr_size`_t"
echo ", $found used"
echo "typedef $found uintptr_t;" >> $NGX_AUTO_CONFIG_H
echo "typedef $found uintptr_t;" >> $NGX_AUTO_CONFIG_H
echo "typedef $found intptr_t;" | sed -e 's/u//g' >> $NGX_AUTO_CONFIG_H
fi

View File

@ -70,31 +70,20 @@
#endif
typedef intptr_t ngx_int_t;
typedef uintptr_t ngx_uint_t;
typedef intptr_t ngx_flag_t;
/* TODO: platform specific: array[NGX_INVALID_ARRAY_INDEX] must cause SIGSEGV */
#define NGX_INVALID_ARRAY_INDEX 0x80000000
#if 1
/* STUB: autoconf */
typedef int ngx_int_t;
typedef u_int ngx_uint_t;
typedef int ngx_flag_t;
#define NGX_INT_T_LEN sizeof("-2147483648") - 1
#else
typedef long ngx_int_t;
typedef u_long ngx_uint_t;
typedef long ngx_flag_t;
#define NGX_INT_T_LEN sizeof("-9223372036854775808") - 1
#endif
#define NGX_INT32_LEN sizeof("-2147483648") - 1
#define NGX_INT64_LEN sizeof("-9223372036854775808") - 1
#if (NGX_PTR_SIZE == 4)
#define NGX_INT_T_LEN NGX_INT32_LEN
#else
#define NGX_INT_T_LEN NGX_INT64_LEN
#endif
#ifndef NGX_ALIGNMENT
#define NGX_ALIGNMENT sizeof(unsigned long) /* platform word */
@ -108,6 +97,10 @@ typedef long ngx_flag_t;
#define ngx_abort abort
/* TODO: platform specific: array[NGX_INVALID_ARRAY_INDEX] must cause SIGSEGV */
#define NGX_INVALID_ARRAY_INDEX 0x80000000
/* TODO: auto_conf: ngx_inline inline __inline __inline__ */
#ifndef ngx_inline
#define ngx_inline inline

View File

@ -16,9 +16,11 @@
static ngx_int_t ngx_aio_init(ngx_cycle_t *cycle, ngx_msec_t timer);
static void ngx_aio_done(ngx_cycle_t *cycle);
static ngx_int_t ngx_aio_add_event(ngx_event_t *ev, int event, u_int flags);
static ngx_int_t ngx_aio_del_event(ngx_event_t *ev, int event, u_int flags);
static ngx_int_t ngx_aio_del_connection(ngx_connection_t *c, u_int flags);
static ngx_int_t ngx_aio_add_event(ngx_event_t *ev, ngx_int_t event,
ngx_uint_t flags);
static ngx_int_t ngx_aio_del_event(ngx_event_t *ev, ngx_int_t event,
ngx_uint_t flags);
static ngx_int_t ngx_aio_del_connection(ngx_connection_t *c, ngx_uint_t flags);
static ngx_int_t ngx_aio_process_events(ngx_cycle_t *cycle, ngx_msec_t timer,
ngx_uint_t flags);
@ -100,21 +102,21 @@ ngx_aio_done(ngx_cycle_t *cycle)
/* the event adding and deleting are needed for the listening sockets */
static ngx_int_t
ngx_aio_add_event(ngx_event_t *ev, int event, u_int flags)
ngx_aio_add_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags)
{
return ngx_kqueue_module_ctx.actions.add(ev, event, flags);
}
static ngx_int_t
ngx_aio_del_event(ngx_event_t *ev, int event, u_int flags)
ngx_aio_del_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags)
{
return ngx_kqueue_module_ctx.actions.del(ev, event, flags);
}
static ngx_int_t
ngx_aio_del_connection(ngx_connection_t *c, u_int flags)
ngx_aio_del_connection(ngx_connection_t *c, ngx_uint_t flags)
{
int rc;

View File

@ -13,8 +13,8 @@
/* Solaris declarations */
#define POLLREMOVE 0x0800
#define DP_POLL 0xD001
#define POLLREMOVE 0x0800
#define DP_POLL 0xD001
struct dvpoll {
struct pollfd *dp_fds;
@ -26,16 +26,19 @@ struct dvpoll {
typedef struct {
u_int changes;
u_int events;
ngx_uint_t changes;
ngx_uint_t events;
} ngx_devpoll_conf_t;
static ngx_int_t ngx_devpoll_init(ngx_cycle_t *cycle, ngx_msec_t timer);
static void ngx_devpoll_done(ngx_cycle_t *cycle);
static ngx_int_t ngx_devpoll_add_event(ngx_event_t *ev, int event, u_int flags);
static ngx_int_t ngx_devpoll_del_event(ngx_event_t *ev, int event, u_int flags);
static ngx_int_t ngx_devpoll_set_event(ngx_event_t *ev, int event, u_int flags);
static ngx_int_t ngx_devpoll_add_event(ngx_event_t *ev, ngx_int_t event,
ngx_uint_t flags);
static ngx_int_t ngx_devpoll_del_event(ngx_event_t *ev, ngx_int_t event,
ngx_uint_t flags);
static ngx_int_t ngx_devpoll_set_event(ngx_event_t *ev, ngx_int_t event,
ngx_uint_t flags);
static ngx_int_t ngx_devpoll_process_events(ngx_cycle_t *cycle,
ngx_msec_t timer, ngx_uint_t flags);
@ -44,7 +47,7 @@ static char *ngx_devpoll_init_conf(ngx_cycle_t *cycle, void *conf);
static int dp = -1;
static struct pollfd *change_list, *event_list;
static u_int nchanges, max_changes, nevents;
static ngx_uint_t nchanges, max_changes, nevents;
static ngx_event_t **change_index;
@ -208,7 +211,7 @@ ngx_devpoll_done(ngx_cycle_t *cycle)
static ngx_int_t
ngx_devpoll_add_event(ngx_event_t *ev, int event, u_int flags)
ngx_devpoll_add_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags)
{
#if (NGX_DEBUG)
ngx_connection_t *c;
@ -221,7 +224,7 @@ ngx_devpoll_add_event(ngx_event_t *ev, int event, u_int flags)
#if (NGX_DEBUG)
c = ev->data;
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0,
"devpoll add event: fd:%d ev:%04Xd", c->fd, event);
"devpoll add event: fd:%d ev:%04Xi", c->fd, event);
#endif
ev->active = 1;
@ -231,7 +234,7 @@ ngx_devpoll_add_event(ngx_event_t *ev, int event, u_int flags)
static ngx_int_t
ngx_devpoll_del_event(ngx_event_t *ev, int event, u_int flags)
ngx_devpoll_del_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags)
{
ngx_event_t *e;
ngx_connection_t *c;
@ -243,7 +246,7 @@ ngx_devpoll_del_event(ngx_event_t *ev, int event, u_int flags)
#endif
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0,
"devpoll del event: fd:%d ev:%04Xd", c->fd, event);
"devpoll del event: fd:%d ev:%04Xi", c->fd, event);
if (ngx_devpoll_set_event(ev, POLLREMOVE, flags) == NGX_ERROR) {
return NGX_ERROR;
@ -275,7 +278,7 @@ ngx_devpoll_del_event(ngx_event_t *ev, int event, u_int flags)
static ngx_int_t
ngx_devpoll_set_event(ngx_event_t *ev, int event, u_int flags)
ngx_devpoll_set_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags)
{
size_t n;
ngx_connection_t *c;
@ -283,7 +286,7 @@ ngx_devpoll_set_event(ngx_event_t *ev, int event, u_int flags)
c = ev->data;
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, ev->log, 0,
"devpoll fd:%d ev:%04Xd fl:%04Xd", c->fd, event, flags);
"devpoll fd:%d ev:%04Xi fl:%04Xi", c->fd, event, flags);
if (nchanges >= max_changes) {
ngx_log_error(NGX_LOG_WARN, ev->log, 0,
@ -300,7 +303,7 @@ ngx_devpoll_set_event(ngx_event_t *ev, int event, u_int flags)
}
change_list[nchanges].fd = c->fd;
change_list[nchanges].events = event;
change_list[nchanges].events = (short) event;
change_list[nchanges].revents = 0;
change_index[nchanges] = ev;
@ -353,7 +356,7 @@ ngx_devpoll_process_events(ngx_cycle_t *cycle, ngx_msec_t timer,
}
dvp.dp_fds = event_list;
dvp.dp_nfds = nevents;
dvp.dp_nfds = (int) nevents;
dvp.dp_timeout = timer;
events = ioctl(dp, DP_POLL, &dvp);

View File

@ -66,16 +66,19 @@ int epoll_wait(int epfd, struct epoll_event *events, int nevents, int timeout)
typedef struct {
u_int events;
ngx_uint_t events;
} ngx_epoll_conf_t;
static ngx_int_t ngx_epoll_init(ngx_cycle_t *cycle, ngx_msec_t timer);
static void ngx_epoll_done(ngx_cycle_t *cycle);
static ngx_int_t ngx_epoll_add_event(ngx_event_t *ev, int event, u_int flags);
static ngx_int_t ngx_epoll_del_event(ngx_event_t *ev, int event, u_int flags);
static ngx_int_t ngx_epoll_add_event(ngx_event_t *ev, ngx_int_t event,
ngx_uint_t flags);
static ngx_int_t ngx_epoll_del_event(ngx_event_t *ev, ngx_int_t event,
ngx_uint_t flags);
static ngx_int_t ngx_epoll_add_connection(ngx_connection_t *c);
static ngx_int_t ngx_epoll_del_connection(ngx_connection_t *c, u_int flags);
static ngx_int_t ngx_epoll_del_connection(ngx_connection_t *c,
ngx_uint_t flags);
static ngx_int_t ngx_epoll_process_events(ngx_cycle_t *cycle, ngx_msec_t timer,
ngx_uint_t flags);
@ -84,7 +87,7 @@ static char *ngx_epoll_init_conf(ngx_cycle_t *cycle, void *conf);
static int ep = -1;
static struct epoll_event *event_list;
static u_int nevents;
static ngx_uint_t nevents;
static ngx_str_t epoll_name = ngx_string("epoll");
@ -205,7 +208,7 @@ ngx_epoll_done(ngx_cycle_t *cycle)
static ngx_int_t
ngx_epoll_add_event(ngx_event_t *ev, int event, u_int flags)
ngx_epoll_add_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags)
{
int op;
uint32_t events, prev;
@ -240,7 +243,7 @@ ngx_epoll_add_event(ngx_event_t *ev, int event, u_int flags)
op = EPOLL_CTL_ADD;
}
ee.events = events | flags;
ee.events = events | (uint32_t) flags;
ee.data.ptr = (void *) ((uintptr_t) c | ev->instance);
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, ev->log, 0,
@ -263,7 +266,7 @@ ngx_epoll_add_event(ngx_event_t *ev, int event, u_int flags)
static ngx_int_t
ngx_epoll_del_event(ngx_event_t *ev, int event, u_int flags)
ngx_epoll_del_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags)
{
int op;
uint32_t prev;
@ -295,7 +298,7 @@ ngx_epoll_del_event(ngx_event_t *ev, int event, u_int flags)
if (e->active) {
op = EPOLL_CTL_MOD;
ee.events = prev | flags;
ee.events = prev | (uint32_t) flags;
ee.data.ptr = (void *) ((uintptr_t) c | ev->instance);
} else {
@ -345,10 +348,10 @@ ngx_epoll_add_connection(ngx_connection_t *c)
static ngx_int_t
ngx_epoll_del_connection(ngx_connection_t *c, u_int flags)
ngx_epoll_del_connection(ngx_connection_t *c, ngx_uint_t flags)
{
int op;
struct epoll_event ee;
int op;
struct epoll_event ee;
/*
* when the file descriptor is closed the epoll automatically deletes
@ -399,7 +402,7 @@ ngx_epoll_process_events(ngx_cycle_t *cycle, ngx_msec_t timer, ngx_uint_t flags)
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
"epoll timer: %M", timer);
events = epoll_wait(ep, event_list, nevents, timer);
events = epoll_wait(ep, event_list, (int) nevents, timer);
if (events == -1) {
err = ngx_errno;

View File

@ -40,9 +40,9 @@ typedef struct port_notify {
void *portnfy_user; /* user defined */
} port_notify_t;
typedef struct itimerspec { /* definition per POSIX.4 */
struct timespec it_interval; /* timer period */
struct timespec it_value; /* timer expiration */
typedef struct itimerspec { /* definition per POSIX.4 */
struct timespec it_interval;/* timer period */
struct timespec it_value; /* timer expiration */
} itimerspec_t;
int port_create(void)
@ -87,16 +87,16 @@ int timer_delete(timer_t timerid)
typedef struct {
u_int events;
ngx_uint_t events;
} ngx_eventport_conf_t;
static ngx_int_t ngx_eventport_init(ngx_cycle_t *cycle, ngx_msec_t timer);
static void ngx_eventport_done(ngx_cycle_t *cycle);
static ngx_int_t ngx_eventport_add_event(ngx_event_t *ev, int event,
u_int flags);
static ngx_int_t ngx_eventport_del_event(ngx_event_t *ev, int event,
u_int flags);
static ngx_int_t ngx_eventport_add_event(ngx_event_t *ev, ngx_int_t event,
ngx_uint_t flags);
static ngx_int_t ngx_eventport_del_event(ngx_event_t *ev, ngx_int_t event,
ngx_uint_t flags);
static ngx_int_t ngx_eventport_process_events(ngx_cycle_t *cycle,
ngx_msec_t timer, ngx_uint_t flags);
@ -105,7 +105,7 @@ static char *ngx_eventport_init_conf(ngx_cycle_t *cycle, void *conf);
static int ep = -1;
static port_event_t *event_list;
static u_int nevents;
static ngx_uint_t nevents;
static timer_t event_timer = -1;
static ngx_str_t eventport_name = ngx_string("eventport");
@ -261,9 +261,9 @@ ngx_eventport_done(ngx_cycle_t *cycle)
static ngx_int_t
ngx_eventport_add_event(ngx_event_t *ev, int event, u_int flags)
ngx_eventport_add_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags)
{
int events, prev;
ngx_int_t events, prev;
ngx_event_t *e;
ngx_connection_t *c;
@ -291,7 +291,7 @@ ngx_eventport_add_event(ngx_event_t *ev, int event, u_int flags)
}
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0,
"eventport add event: fd:%d ev:%04Xd", c->fd, events);
"eventport add event: fd:%d ev:%04Xi", c->fd, events);
if (port_associate(ep, PORT_SOURCE_FD, c->fd, events,
(void *) ((uintptr_t) ev | ev->instance))
@ -310,7 +310,7 @@ ngx_eventport_add_event(ngx_event_t *ev, int event, u_int flags)
static ngx_int_t
ngx_eventport_del_event(ngx_event_t *ev, int event, u_int flags)
ngx_eventport_del_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags)
{
ngx_event_t *e;
ngx_connection_t *c;
@ -340,7 +340,7 @@ ngx_eventport_del_event(ngx_event_t *ev, int event, u_int flags)
if (e->oneshot) {
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0,
"eventport change event: fd:%d ev:%04Xd", c->fd, event);
"eventport change event: fd:%d ev:%04Xi", c->fd, event);
if (port_associate(ep, PORT_SOURCE_FD, c->fd, event,
(void *) ((uintptr_t) ev | ev->instance))
@ -396,7 +396,7 @@ ngx_eventport_process_events(ngx_cycle_t *cycle, ngx_msec_t timer,
events = 1;
n = port_getn(ep, event_list, nevents, &events, tp);
n = port_getn(ep, event_list, (u_int) nevents, &events, tp);
err = ngx_errno;

View File

@ -13,8 +13,9 @@
static ngx_int_t ngx_iocp_init(ngx_cycle_t *cycle, ngx_msec_t timer);
static ngx_thread_value_t __stdcall ngx_iocp_timer(void *data);
static void ngx_iocp_done(ngx_cycle_t *cycle);
static ngx_int_t ngx_iocp_add_event(ngx_event_t *ev, int event, u_int key);
static ngx_int_t ngx_iocp_del_connection(ngx_connection_t *c, u_int flags);
static ngx_int_t ngx_iocp_add_event(ngx_event_t *ev, ngx_int_t event,
ngx_uint_t key);
static ngx_int_t ngx_iocp_del_connection(ngx_connection_t *c, ngx_uint_t flags);
static ngx_int_t ngx_iocp_process_events(ngx_cycle_t *cycle, ngx_msec_t timer,
ngx_uint_t flags);
static void *ngx_iocp_create_conf(ngx_cycle_t *cycle);
@ -186,7 +187,7 @@ ngx_iocp_done(ngx_cycle_t *cycle)
static ngx_int_t
ngx_iocp_add_event(ngx_event_t *ev, int event, u_int key)
ngx_iocp_add_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t key)
{
ngx_connection_t *c;
@ -196,7 +197,7 @@ ngx_iocp_add_event(ngx_event_t *ev, int event, u_int key)
c->write->active = 1;
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, ev->log, 0,
"iocp add: fd:%d k:%d ov:%p", c->fd, key, &ev->ovlp);
"iocp add: fd:%d k:%ui ov:%p", c->fd, key, &ev->ovlp);
if (CreateIoCompletionPort((HANDLE) c->fd, iocp, key, 0) == NULL) {
ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno,
@ -209,7 +210,7 @@ ngx_iocp_add_event(ngx_event_t *ev, int event, u_int key)
static ngx_int_t
ngx_iocp_del_connection(ngx_connection_t *c, u_int flags)
ngx_iocp_del_connection(ngx_connection_t *c, ngx_uint_t flags)
{
#if 0
if (flags & NGX_CLOSE_EVENT) {

View File

@ -11,16 +11,19 @@
typedef struct {
int changes;
int events;
ngx_uint_t changes;
ngx_uint_t events;
} ngx_kqueue_conf_t;
static ngx_int_t ngx_kqueue_init(ngx_cycle_t *cycle, ngx_msec_t timer);
static void ngx_kqueue_done(ngx_cycle_t *cycle);
static ngx_int_t ngx_kqueue_add_event(ngx_event_t *ev, int event, u_int flags);
static ngx_int_t ngx_kqueue_del_event(ngx_event_t *ev, int event, u_int flags);
static ngx_int_t ngx_kqueue_set_event(ngx_event_t *ev, int filter, u_int flags);
static ngx_int_t ngx_kqueue_add_event(ngx_event_t *ev, ngx_int_t event,
ngx_uint_t flags);
static ngx_int_t ngx_kqueue_del_event(ngx_event_t *ev, ngx_int_t event,
ngx_uint_t flags);
static ngx_int_t ngx_kqueue_set_event(ngx_event_t *ev, ngx_int_t filter,
ngx_uint_t flags);
static ngx_int_t ngx_kqueue_process_changes(ngx_cycle_t *cycle, ngx_uint_t try);
static ngx_int_t ngx_kqueue_process_events(ngx_cycle_t *cycle, ngx_msec_t timer,
ngx_uint_t flags);
@ -43,7 +46,7 @@ int ngx_kqueue = -1;
static struct kevent *change_list, *change_list0, *change_list1;
static struct kevent *event_list;
static int max_changes, nchanges, nevents;
static ngx_uint_t max_changes, nchanges, nevents;
#if (NGX_THREADS)
static ngx_mutex_t *list_mutex;
@ -151,7 +154,9 @@ ngx_kqueue_init(ngx_cycle_t *cycle, ngx_msec_t timer)
ts.tv_sec = 0;
ts.tv_nsec = 0;
if (kevent(ngx_kqueue, change_list, nchanges, NULL, 0, &ts) == -1) {
if (kevent(ngx_kqueue, change_list, (int) nchanges, NULL, 0, &ts)
== -1)
{
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
"kevent() failed");
return NGX_ERROR;
@ -273,7 +278,7 @@ ngx_kqueue_done(ngx_cycle_t *cycle)
static ngx_int_t
ngx_kqueue_add_event(ngx_event_t *ev, int event, u_int flags)
ngx_kqueue_add_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags)
{
ngx_int_t rc;
#if 0
@ -289,7 +294,7 @@ ngx_kqueue_add_event(ngx_event_t *ev, int event, u_int flags)
#if 0
if (ev->index < (u_int) nchanges
if (ev->index < nchanges
&& ((uintptr_t) change_list[ev->index].udata & (uintptr_t) ~1)
== (uintptr_t) ev)
{
@ -301,10 +306,10 @@ ngx_kqueue_add_event(ngx_event_t *ev, int event, u_int flags)
*/
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0,
"kevent activated: %d: ft:%d",
"kevent activated: %d: ft:%i",
ngx_event_ident(ev->data), event);
if (ev->index < (u_int) --nchanges) {
if (ev->index < --nchanges) {
e = (ngx_event_t *)
((uintptr_t) change_list[nchanges].udata & (uintptr_t) ~1);
change_list[ev->index] = change_list[nchanges];
@ -337,7 +342,7 @@ ngx_kqueue_add_event(ngx_event_t *ev, int event, u_int flags)
static ngx_int_t
ngx_kqueue_del_event(ngx_event_t *ev, int event, u_int flags)
ngx_kqueue_del_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags)
{
ngx_int_t rc;
ngx_event_t *e;
@ -347,19 +352,19 @@ ngx_kqueue_del_event(ngx_event_t *ev, int event, u_int flags)
ngx_mutex_lock(list_mutex);
if (ev->index < (u_int) nchanges
if (ev->index < nchanges
&& ((uintptr_t) change_list[ev->index].udata & (uintptr_t) ~1)
== (uintptr_t) ev)
{
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0,
"kevent deleted: %d: ft:%d",
"kevent deleted: %d: ft:%i",
ngx_event_ident(ev->data), event);
/* if the event is still not passed to a kernel we will not pass it */
nchanges--;
if (ev->index < (u_int) nchanges) {
if (ev->index < nchanges) {
e = (ngx_event_t *)
((uintptr_t) change_list[nchanges].udata & (uintptr_t) ~1);
change_list[ev->index] = change_list[nchanges];
@ -396,7 +401,7 @@ ngx_kqueue_del_event(ngx_event_t *ev, int event, u_int flags)
static ngx_int_t
ngx_kqueue_set_event(ngx_event_t *ev, int filter, u_int flags)
ngx_kqueue_set_event(ngx_event_t *ev, ngx_int_t filter, ngx_uint_t flags)
{
struct kevent *kev;
struct timespec ts;
@ -405,7 +410,7 @@ ngx_kqueue_set_event(ngx_event_t *ev, int filter, u_int flags)
c = ev->data;
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0,
"kevent set event: %d: ft:%d fl:%04Xd",
"kevent set event: %d: ft:%i fl:%04Xi",
c->fd, filter, flags);
if (nchanges >= max_changes) {
@ -415,7 +420,9 @@ ngx_kqueue_set_event(ngx_event_t *ev, int filter, u_int flags)
ts.tv_sec = 0;
ts.tv_nsec = 0;
if (kevent(ngx_kqueue, change_list, nchanges, NULL, 0, &ts) == -1) {
if (kevent(ngx_kqueue, change_list, (int) nchanges, NULL, 0, &ts)
== -1)
{
ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_errno, "kevent() failed");
return NGX_ERROR;
}
@ -426,8 +433,8 @@ ngx_kqueue_set_event(ngx_event_t *ev, int filter, u_int flags)
kev = &change_list[nchanges];
kev->ident = c->fd;
kev->filter = filter;
kev->flags = flags;
kev->filter = (short) filter;
kev->flags = (u_short) flags;
kev->udata = NGX_KQUEUE_UDATA_T ((uintptr_t) ev | ev->instance);
if (filter == EVFILT_VNODE) {
@ -482,7 +489,7 @@ ngx_kqueue_process_events(ngx_cycle_t *cycle, ngx_msec_t timer,
n = 0;
} else {
n = nchanges;
n = (int) nchanges;
nchanges = 0;
}
@ -510,7 +517,7 @@ ngx_kqueue_process_events(ngx_cycle_t *cycle, ngx_msec_t timer,
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
"kevent timer: %M, changes: %d", timer, n);
events = kevent(ngx_kqueue, change_list, n, event_list, nevents, tp);
events = kevent(ngx_kqueue, change_list, n, event_list, (int) nevents, tp);
if (events == -1) {
err = ngx_errno;
@ -696,7 +703,7 @@ ngx_kqueue_process_changes(ngx_cycle_t *cycle, ngx_uint_t try)
change_list = change_list0;
}
n = nchanges;
n = (int) nchanges;
nchanges = 0;
ngx_mutex_unlock(list_mutex);
@ -758,8 +765,8 @@ ngx_kqueue_init_conf(ngx_cycle_t *cycle, void *conf)
{
ngx_kqueue_conf_t *kcf = conf;
ngx_conf_init_value(kcf->changes, 512);
ngx_conf_init_value(kcf->events, 512);
ngx_conf_init_uint_value(kcf->changes, 512);
ngx_conf_init_uint_value(kcf->events, 512);
return NGX_CONF_OK;
}

View File

@ -13,5 +13,4 @@ extern ngx_module_t ngx_kqueue_module;
extern ngx_event_module_t ngx_kqueue_module_ctx;
#endif /* _NGX_KQUEUE_MODULE_H_INCLUDED_ */

View File

@ -11,15 +11,17 @@
static ngx_int_t ngx_poll_init(ngx_cycle_t *cycle, ngx_msec_t timer);
static void ngx_poll_done(ngx_cycle_t *cycle);
static ngx_int_t ngx_poll_add_event(ngx_event_t *ev, int event, u_int flags);
static ngx_int_t ngx_poll_del_event(ngx_event_t *ev, int event, u_int flags);
static ngx_int_t ngx_poll_add_event(ngx_event_t *ev, ngx_int_t event,
ngx_uint_t flags);
static ngx_int_t ngx_poll_del_event(ngx_event_t *ev, ngx_int_t event,
ngx_uint_t flags);
static ngx_int_t ngx_poll_process_events(ngx_cycle_t *cycle, ngx_msec_t timer,
ngx_uint_t flags);
static char *ngx_poll_init_conf(ngx_cycle_t *cycle, void *conf);
static struct pollfd *event_list;
static int nevents;
static ngx_int_t nevents;
static ngx_str_t poll_name = ngx_string("poll");
@ -108,7 +110,7 @@ ngx_poll_done(ngx_cycle_t *cycle)
static ngx_int_t
ngx_poll_add_event(ngx_event_t *ev, int event, u_int flags)
ngx_poll_add_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags)
{
ngx_event_t *e;
ngx_connection_t *c;
@ -119,7 +121,7 @@ ngx_poll_add_event(ngx_event_t *ev, int event, u_int flags)
if (ev->index != NGX_INVALID_INDEX) {
ngx_log_error(NGX_LOG_ALERT, ev->log, 0,
"poll event fd:%d ev:%d is already set", c->fd, event);
"poll event fd:%d ev:%i is already set", c->fd, event);
return NGX_OK;
}
@ -137,11 +139,11 @@ ngx_poll_add_event(ngx_event_t *ev, int event, u_int flags)
}
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0,
"poll add event: fd:%d ev:%d", c->fd, event);
"poll add event: fd:%d ev:%i", c->fd, event);
if (e == NULL || e->index == NGX_INVALID_INDEX) {
event_list[nevents].fd = c->fd;
event_list[nevents].events = event;
event_list[nevents].events = (short) event;
event_list[nevents].revents = 0;
ev->index = nevents;
@ -149,9 +151,9 @@ ngx_poll_add_event(ngx_event_t *ev, int event, u_int flags)
} else {
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, ev->log, 0,
"poll add index: %d", e->index);
"poll add index: %i", e->index);
event_list[e->index].events |= event;
event_list[e->index].events |= (short) event;
ev->index = e->index;
}
@ -160,7 +162,7 @@ ngx_poll_add_event(ngx_event_t *ev, int event, u_int flags)
static ngx_int_t
ngx_poll_del_event(ngx_event_t *ev, int event, u_int flags)
ngx_poll_del_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags)
{
ngx_event_t *e;
ngx_connection_t *c;
@ -171,7 +173,7 @@ ngx_poll_del_event(ngx_event_t *ev, int event, u_int flags)
if (ev->index == NGX_INVALID_INDEX) {
ngx_log_error(NGX_LOG_ALERT, ev->log, 0,
"poll event fd:%d ev:%d is already deleted",
"poll event fd:%d ev:%i is already deleted",
c->fd, event);
return NGX_OK;
}
@ -190,15 +192,15 @@ ngx_poll_del_event(ngx_event_t *ev, int event, u_int flags)
}
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0,
"poll del event: fd:%d ev:%d", c->fd, event);
"poll del event: fd:%d ev:%i", c->fd, event);
if (e == NULL || e->index == NGX_INVALID_INDEX) {
nevents--;
if (ev->index < (u_int) nevents) {
if (ev->index < (ngx_uint_t) nevents) {
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0,
"index: copy event %d to %d", nevents, ev->index);
"index: copy event %ui to %i", nevents, ev->index);
event_list[ev->index] = event_list[nevents];
@ -209,11 +211,11 @@ ngx_poll_del_event(ngx_event_t *ev, int event, u_int flags)
"unexpected last event");
} else {
if (c->read->index == (u_int) nevents) {
if (c->read->index == (ngx_uint_t) nevents) {
c->read->index = ev->index;
}
if (c->write->index == (u_int) nevents) {
if (c->write->index == (ngx_uint_t) nevents) {
c->write->index = ev->index;
}
}
@ -221,9 +223,9 @@ ngx_poll_del_event(ngx_event_t *ev, int event, u_int flags)
} else {
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, ev->log, 0,
"poll del index: %d", e->index);
"poll del index: %i", e->index);
event_list[e->index].events &= ~event;
event_list[e->index].events &= (short) ~event;
}
ev->index = NGX_INVALID_INDEX;

View File

@ -29,10 +29,10 @@ int ngx_linux_rtsig_max;
typedef struct {
int signo;
ngx_int_t overflow_events;
ngx_int_t overflow_test;
ngx_int_t overflow_threshold;
ngx_uint_t signo;
ngx_uint_t overflow_events;
ngx_uint_t overflow_test;
ngx_uint_t overflow_threshold;
} ngx_rtsig_conf_t;
@ -41,7 +41,8 @@ extern ngx_event_module_t ngx_poll_module_ctx;
static ngx_int_t ngx_rtsig_init(ngx_cycle_t *cycle, ngx_msec_t timer);
static void ngx_rtsig_done(ngx_cycle_t *cycle);
static ngx_int_t ngx_rtsig_add_connection(ngx_connection_t *c);
static ngx_int_t ngx_rtsig_del_connection(ngx_connection_t *c, u_int flags);
static ngx_int_t ngx_rtsig_del_connection(ngx_connection_t *c,
ngx_uint_t flags);
static ngx_int_t ngx_rtsig_process_events(ngx_cycle_t *cycle,
ngx_msec_t timer, ngx_uint_t flags);
static ngx_int_t ngx_rtsig_process_overflow(ngx_cycle_t *cycle,
@ -143,8 +144,8 @@ ngx_rtsig_init(ngx_cycle_t *cycle, ngx_msec_t timer)
rtscf = ngx_event_get_conf(cycle->conf_ctx, ngx_rtsig_module);
sigemptyset(&set);
sigaddset(&set, rtscf->signo);
sigaddset(&set, rtscf->signo + 1);
sigaddset(&set, (int) rtscf->signo);
sigaddset(&set, (int) rtscf->signo + 1);
sigaddset(&set, SIGIO);
sigaddset(&set, SIGALRM);
@ -188,7 +189,7 @@ ngx_rtsig_done(ngx_cycle_t *cycle)
static ngx_int_t
ngx_rtsig_add_connection(ngx_connection_t *c)
{
int signo;
ngx_uint_t signo;
ngx_rtsig_conf_t *rtscf;
if (c->read->accept && c->read->disabled) {
@ -211,7 +212,7 @@ ngx_rtsig_add_connection(ngx_connection_t *c)
signo = rtscf->signo + c->read->instance;
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
"rtsig add connection: fd:%d signo:%d", c->fd, signo);
"rtsig add connection: fd:%d signo:%ui", c->fd, signo);
if (fcntl(c->fd, F_SETFL, O_RDWR|O_NONBLOCK|O_ASYNC) == -1) {
ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno,
@ -219,7 +220,7 @@ ngx_rtsig_add_connection(ngx_connection_t *c)
return NGX_ERROR;
}
if (fcntl(c->fd, F_SETSIG, signo) == -1) {
if (fcntl(c->fd, F_SETSIG, (int) signo) == -1) {
ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno,
"fcntl(F_SETSIG) failed");
return NGX_ERROR;
@ -247,7 +248,7 @@ ngx_rtsig_add_connection(ngx_connection_t *c)
static ngx_int_t
ngx_rtsig_del_connection(ngx_connection_t *c, u_int flags)
ngx_rtsig_del_connection(ngx_connection_t *c, ngx_uint_t flags)
{
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
"rtsig del connection: fd:%d", c->fd);
@ -348,7 +349,7 @@ ngx_rtsig_process_events(ngx_cycle_t *cycle, ngx_msec_t timer, ngx_uint_t flags)
rtscf = ngx_event_get_conf(ngx_cycle->conf_ctx, ngx_rtsig_module);
if (signo == rtscf->signo || signo == rtscf->signo + 1) {
if (signo == (int) rtscf->signo || signo == (int) rtscf->signo + 1) {
if (overflow && (ngx_uint_t) si.si_fd > overflow_current) {
return NGX_OK;
@ -363,7 +364,7 @@ ngx_rtsig_process_events(ngx_cycle_t *cycle, ngx_msec_t timer, ngx_uint_t flags)
return NGX_OK;
}
instance = signo - rtscf->signo;
instance = signo - (int) rtscf->signo;
rev = c->read;
@ -459,8 +460,8 @@ ngx_rtsig_process_overflow(ngx_cycle_t *cycle, ngx_msec_t timer,
{
int name[2], rtsig_max, rtsig_nr, events, ready;
size_t len;
ngx_int_t tested, n, i;
ngx_err_t err;
ngx_uint_t tested, n, i;
ngx_event_t *rev, *wev, **queue;
ngx_connection_t *c;
ngx_rtsig_conf_t *rtscf;
@ -638,7 +639,7 @@ ngx_rtsig_process_overflow(ngx_cycle_t *cycle, ngx_msec_t timer,
* "/proc/sys/kernel/rtsig-max" / "rtsig_overflow_threshold"
*/
if (rtsig_max / rtscf->overflow_threshold < rtsig_nr) {
if (rtsig_max / (int) rtscf->overflow_threshold < rtsig_nr) {
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
"rtsig queue state: %d/%d",
rtsig_nr, rtsig_max);
@ -703,19 +704,18 @@ ngx_rtsig_init_conf(ngx_cycle_t *cycle, void *conf)
ngx_rtsig_conf_t *rtscf = conf;
/* LinuxThreads use the first 3 RT signals */
ngx_conf_init_value(rtscf->signo, SIGRTMIN + 10);
ngx_conf_init_uint_value(rtscf->signo, SIGRTMIN + 10);
ngx_conf_init_value(rtscf->overflow_events, 16);
ngx_conf_init_value(rtscf->overflow_test, 32);
ngx_conf_init_value(rtscf->overflow_threshold, 10);
ngx_conf_init_uint_value(rtscf->overflow_events, 16);
ngx_conf_init_uint_value(rtscf->overflow_test, 32);
ngx_conf_init_uint_value(rtscf->overflow_threshold, 10);
return NGX_CONF_OK;
}
static char *
ngx_check_ngx_overflow_threshold_bounds(ngx_conf_t *cf,
void *post, void *data)
ngx_check_ngx_overflow_threshold_bounds(ngx_conf_t *cf, void *post, void *data)
{
if (ngx_linux_rtsig_max) {
return ngx_conf_check_num_bounds(cf, post, data);

View File

@ -12,8 +12,10 @@
static ngx_int_t ngx_select_init(ngx_cycle_t *cycle, ngx_msec_t timer);
static void ngx_select_done(ngx_cycle_t *cycle);
static ngx_int_t ngx_select_add_event(ngx_event_t *ev, int event, u_int flags);
static ngx_int_t ngx_select_del_event(ngx_event_t *ev, int event, u_int flags);
static ngx_int_t ngx_select_add_event(ngx_event_t *ev, ngx_int_t event,
ngx_uint_t flags);
static ngx_int_t ngx_select_del_event(ngx_event_t *ev, ngx_int_t event,
ngx_uint_t flags);
static ngx_int_t ngx_select_process_events(ngx_cycle_t *cycle, ngx_msec_t timer,
ngx_uint_t flags);
static char *ngx_select_init_conf(ngx_cycle_t *cycle, void *conf);
@ -25,10 +27,10 @@ static fd_set work_read_fd_set;
static fd_set work_write_fd_set;
#if (NGX_WIN32)
static int max_read;
static int max_write;
static ngx_uint_t max_read;
static ngx_uint_t max_write;
#else
static int max_fd;
static ngx_int_t max_fd;
#endif
static ngx_uint_t nevents;
@ -129,18 +131,18 @@ ngx_select_done(ngx_cycle_t *cycle)
static ngx_int_t
ngx_select_add_event(ngx_event_t *ev, int event, u_int flags)
ngx_select_add_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags)
{
ngx_connection_t *c;
c = ev->data;
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0,
"select add event fd:%d ev:%d", c->fd, event);
"select add event fd:%d ev:%i", c->fd, event);
if (ev->index != NGX_INVALID_INDEX) {
ngx_log_error(NGX_LOG_ALERT, ev->log, 0,
"select event fd:%d ev:%d is already set", c->fd, event);
"select event fd:%d ev:%i is already set", c->fd, event);
return NGX_OK;
}
@ -190,7 +192,7 @@ ngx_select_add_event(ngx_event_t *ev, int event, u_int flags)
static ngx_int_t
ngx_select_del_event(ngx_event_t *ev, int event, u_int flags)
ngx_select_del_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags)
{
ngx_connection_t *c;
@ -203,7 +205,7 @@ ngx_select_del_event(ngx_event_t *ev, int event, u_int flags)
}
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0,
"select del event fd:%d ev:%d", c->fd, event);
"select del event fd:%d ev:%i", c->fd, event);
#if (NGX_WIN32)
@ -231,7 +233,7 @@ ngx_select_del_event(ngx_event_t *ev, int event, u_int flags)
#endif
if (ev->index < (u_int) --nevents) {
if (ev->index < --nevents) {
event_index[ev->index] = event_index[nevents];
event_index[ev->index]->index = ev->index;
}

View File

@ -276,7 +276,7 @@ ngx_process_events_and_timers(ngx_cycle_t *cycle)
ngx_int_t
ngx_handle_read_event(ngx_event_t *rev, u_int flags)
ngx_handle_read_event(ngx_event_t *rev, ngx_uint_t flags)
{
if (ngx_event_flags & NGX_USE_CLEAR_EVENT) {

View File

@ -126,7 +126,7 @@ struct ngx_event_s {
#endif
u_int index;
ngx_uint_t index;
ngx_log_t *log;
@ -182,7 +182,7 @@ struct ngx_event_s {
/* event should not cross cache line in SMP */
int padding[NGX_EVENT_T_PADDING];
uint32_t padding[NGX_EVENT_T_PADDING];
#endif
#endif
};
@ -195,14 +195,14 @@ typedef struct {
typedef struct {
ngx_int_t (*add)(ngx_event_t *ev, int event, u_int flags);
ngx_int_t (*del)(ngx_event_t *ev, int event, u_int flags);
ngx_int_t (*add)(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags);
ngx_int_t (*del)(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags);
ngx_int_t (*enable)(ngx_event_t *ev, int event, u_int flags);
ngx_int_t (*disable)(ngx_event_t *ev, int event, u_int flags);
ngx_int_t (*enable)(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags);
ngx_int_t (*disable)(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags);
ngx_int_t (*add_conn)(ngx_connection_t *c);
ngx_int_t (*del_conn)(ngx_connection_t *c, u_int flags);
ngx_int_t (*del_conn)(ngx_connection_t *c, ngx_uint_t flags);
ngx_int_t (*process_changes)(ngx_cycle_t *cycle, ngx_uint_t nowait);
ngx_int_t (*process_events)(ngx_cycle_t *cycle, ngx_msec_t timer,
@ -489,7 +489,7 @@ u_char *ngx_accept_log_error(ngx_log_t *log, u_char *buf, size_t len);
void ngx_process_events_and_timers(ngx_cycle_t *cycle);
ngx_int_t ngx_handle_read_event(ngx_event_t *rev, u_int flags);
ngx_int_t ngx_handle_read_event(ngx_event_t *rev, ngx_uint_t flags);
ngx_int_t ngx_handle_write_event(ngx_event_t *wev, size_t lowat);

View File

@ -9,7 +9,7 @@
#include <ngx_event.h>
static int ngx_event_busy_lock_look_cachable(ngx_event_busy_lock_t *bl,
static ngx_int_t ngx_event_busy_lock_look_cachable(ngx_event_busy_lock_t *bl,
ngx_event_busy_lock_ctx_t *ctx);
static void ngx_event_busy_lock_handler(ngx_event_t *ev);
static void ngx_event_busy_lock_posted_handler(ngx_event_t *ev);

View File

@ -784,7 +784,7 @@ ngx_ssl_send_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
/* the maximum limit size is the maximum uint32_t value - the page size */
if (limit == 0 || limit > NGX_MAX_UINT32_VALUE - ngx_pagesize) {
if (limit == 0 || limit > (off_t) (NGX_MAX_UINT32_VALUE - ngx_pagesize)) {
limit = NGX_MAX_UINT32_VALUE - ngx_pagesize;
}

View File

@ -21,7 +21,7 @@ ngx_aio_write_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
/* the maximum limit size is the maximum size_t value - the page size */
if (limit == 0 || limit > NGX_MAX_SIZE_T_VALUE - ngx_pagesize) {
if (limit == 0 || limit > (off_t) (NGX_MAX_SIZE_T_VALUE - ngx_pagesize)) {
limit = NGX_MAX_SIZE_T_VALUE - ngx_pagesize;
}

View File

@ -102,7 +102,7 @@ pid_t rfork_thread(int flags, void *stack, int (*func)(void *arg), void *arg);
extern char **environ;
extern char *malloc_options;
extern char *malloc_options;
#endif /* _NGX_FREEBSD_CONFIG_H_INCLUDED_ */

View File

@ -72,7 +72,7 @@ ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
/* the maximum limit size is the maximum size_t value - the page size */
if (limit == 0 || limit > NGX_MAX_SIZE_T_VALUE - ngx_pagesize) {
if (limit == 0 || limit > (off_t) (NGX_MAX_SIZE_T_VALUE - ngx_pagesize)) {
limit = NGX_MAX_SIZE_T_VALUE - ngx_pagesize;
}

View File

@ -62,7 +62,7 @@ ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
/* the maximum limit size is 2G-1 - the page size */
if (limit == 0 || limit > NGX_SENDFILE_LIMIT - ngx_pagesize) {
if (limit == 0 || limit > (off_t) (NGX_SENDFILE_LIMIT - ngx_pagesize)) {
limit = NGX_SENDFILE_LIMIT - ngx_pagesize;
}

View File

@ -67,7 +67,7 @@ ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
/* the maximum limit size is the maximum size_t value - the page size */
if (limit == 0 || limit > NGX_MAX_SIZE_T_VALUE - ngx_pagesize) {
if (limit == 0 || limit > (off_t) (NGX_MAX_SIZE_T_VALUE - ngx_pagesize)) {
limit = NGX_MAX_SIZE_T_VALUE - ngx_pagesize;
}

View File

@ -48,7 +48,7 @@ ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
/* the maximum limit size is the maximum size_t value - the page size */
if (limit == 0 || limit > NGX_MAX_SIZE_T_VALUE - ngx_pagesize) {
if (limit == 0 || limit > (off_t) (NGX_MAX_SIZE_T_VALUE - ngx_pagesize)) {
limit = NGX_MAX_SIZE_T_VALUE - ngx_pagesize;
}

View File

@ -120,6 +120,7 @@ typedef unsigned short int uint16_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
typedef int intptr_t;
typedef u_int uintptr_t;
typedef int ssize_t;