mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-10 04:50:37 -04:00
Trim 22 bytes from struct event on 32 bit platforms, more on 64-bit platforms.
svn:r1292
This commit is contained in:
parent
85b0a7a23f
commit
b4886ec80d
@ -24,6 +24,8 @@ Changes in 2.0.2-alpha:
|
|||||||
o Move the EVBUFFER_INPUT and EVBUFFER_OUTPUT macros to bufferevent_compat.h
|
o Move the EVBUFFER_INPUT and EVBUFFER_OUTPUT macros to bufferevent_compat.h
|
||||||
o Add a bufferevent_getfd() function to mirror bufferevent_setfd()
|
o Add a bufferevent_getfd() function to mirror bufferevent_setfd()
|
||||||
o Make bufferevent_setfd() return an error code if the operation is not successful.
|
o Make bufferevent_setfd() return an error code if the operation is not successful.
|
||||||
|
o Shave 22 bytes off struct event on 32-bit platforms by shrinking and re-ordering fields. The savings on 64-bit platforms is likely higher.
|
||||||
|
o Cap the maximum number of priorities at 256.
|
||||||
|
|
||||||
Changes in 2.0.1-alpha:
|
Changes in 2.0.1-alpha:
|
||||||
o free minheap on event_base_free(); from Christopher Layne
|
o free minheap on event_base_free(); from Christopher Layne
|
||||||
|
@ -50,6 +50,11 @@ extern "C" {
|
|||||||
#define ev_ncalls _ev.ev_signal.ev_ncalls
|
#define ev_ncalls _ev.ev_signal.ev_ncalls
|
||||||
#define ev_pncalls _ev.ev_signal.ev_pncalls
|
#define ev_pncalls _ev.ev_signal.ev_pncalls
|
||||||
|
|
||||||
|
/* Possible event closures. */
|
||||||
|
#define EV_CLOSURE_NONE 0
|
||||||
|
#define EV_CLOSURE_SIGNAL 1
|
||||||
|
#define EV_CLOSURE_PERSIST 2
|
||||||
|
|
||||||
/** Structure to define the backend of a given event_base. */
|
/** Structure to define the backend of a given event_base. */
|
||||||
struct eventop {
|
struct eventop {
|
||||||
/** The name of this backend. */
|
/** The name of this backend. */
|
||||||
|
26
event.c
26
event.c
@ -551,7 +551,8 @@ event_base_priority_init(struct event_base *base, int npriorities)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (base->event_count_active || npriorities < 1)
|
if (base->event_count_active || npriorities < 1
|
||||||
|
|| npriorities >= EVENT_MAX_PRIORITIES)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
if (npriorities == base->nactivequeues)
|
if (npriorities == base->nactivequeues)
|
||||||
@ -648,11 +649,20 @@ event_process_active_single_queue(struct event_base *base,
|
|||||||
EVBASE_RELEASE_LOCK(base,
|
EVBASE_RELEASE_LOCK(base,
|
||||||
EVTHREAD_WRITE, th_base_lock);
|
EVTHREAD_WRITE, th_base_lock);
|
||||||
|
|
||||||
if (ev->ev_closure != NULL)
|
switch (ev->ev_closure) {
|
||||||
(*ev->ev_closure)(base, ev);
|
case EV_CLOSURE_SIGNAL:
|
||||||
else
|
event_signal_closure(base, ev);
|
||||||
|
break;
|
||||||
|
case EV_CLOSURE_PERSIST:
|
||||||
|
event_persist_closure(base, ev);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
case EV_CLOSURE_NONE:
|
||||||
(*ev->ev_callback)(
|
(*ev->ev_callback)(
|
||||||
(int)ev->ev_fd, ev->ev_res, ev->ev_arg);
|
(int)ev->ev_fd, ev->ev_res, ev->ev_arg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (base->event_break)
|
if (base->event_break)
|
||||||
return -1;
|
return -1;
|
||||||
EVBASE_ACQUIRE_LOCK(base, EVTHREAD_WRITE, th_base_lock);
|
EVBASE_ACQUIRE_LOCK(base, EVTHREAD_WRITE, th_base_lock);
|
||||||
@ -969,13 +979,13 @@ event_set(struct event *ev, evutil_socket_t fd, short events,
|
|||||||
if ((events & (EV_READ|EV_WRITE)) != 0)
|
if ((events & (EV_READ|EV_WRITE)) != 0)
|
||||||
event_errx(1, "%s: EV_SIGNAL incompatible use",
|
event_errx(1, "%s: EV_SIGNAL incompatible use",
|
||||||
__func__);
|
__func__);
|
||||||
ev->ev_closure = event_signal_closure;
|
ev->ev_closure = EV_CLOSURE_SIGNAL;
|
||||||
} else {
|
} else {
|
||||||
if (events & EV_PERSIST) {
|
if (events & EV_PERSIST) {
|
||||||
timerclear(&ev->ev_io_timeout);
|
timerclear(&ev->ev_io_timeout);
|
||||||
ev->ev_closure = event_persist_closure;
|
ev->ev_closure = EV_CLOSURE_PERSIST;
|
||||||
} else {
|
} else {
|
||||||
ev->ev_closure = NULL;
|
ev->ev_closure = EV_CLOSURE_NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1198,7 +1208,7 @@ event_add_internal(struct event *ev, const struct timeval *tv)
|
|||||||
* for persistent timeout events, we remember the
|
* for persistent timeout events, we remember the
|
||||||
* timeout value and re-add the event.
|
* timeout value and re-add the event.
|
||||||
*/
|
*/
|
||||||
if (ev->ev_closure == event_persist_closure)
|
if (ev->ev_closure == EV_CLOSURE_PERSIST)
|
||||||
ev->ev_io_timeout = *tv;
|
ev->ev_io_timeout = *tv;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -546,6 +546,7 @@ ev_uint32_t event_get_version_number(void);
|
|||||||
* headers. */
|
* headers. */
|
||||||
#define LIBEVENT_VERSION_NUMBER _EVENT_NUMERIC_VERSION
|
#define LIBEVENT_VERSION_NUMBER _EVENT_NUMERIC_VERSION
|
||||||
|
|
||||||
|
#define EVENT_MAX_PRIORITIES 256
|
||||||
/**
|
/**
|
||||||
Set the number of different event priorities (threadsafe variant).
|
Set the number of different event priorities (threadsafe variant).
|
||||||
|
|
||||||
|
@ -80,10 +80,10 @@ struct event {
|
|||||||
TAILQ_ENTRY (event) (ev_active_next);
|
TAILQ_ENTRY (event) (ev_active_next);
|
||||||
TAILQ_ENTRY (event) (ev_next);
|
TAILQ_ENTRY (event) (ev_next);
|
||||||
int min_heap_idx; /* for managing timeouts */
|
int min_heap_idx; /* for managing timeouts */
|
||||||
|
evutil_socket_t ev_fd;
|
||||||
|
|
||||||
struct event_base *ev_base;
|
struct event_base *ev_base;
|
||||||
|
|
||||||
evutil_socket_t ev_fd;
|
|
||||||
union {
|
union {
|
||||||
/* used for io events */
|
/* used for io events */
|
||||||
struct {
|
struct {
|
||||||
@ -101,18 +101,15 @@ struct event {
|
|||||||
} _ev;
|
} _ev;
|
||||||
|
|
||||||
short ev_events;
|
short ev_events;
|
||||||
|
short ev_res; /* result passed to event callback */
|
||||||
|
short ev_flags;
|
||||||
|
ev_uint8_t ev_pri; /* smaller numbers are higher priority */
|
||||||
|
ev_uint8_t ev_closure;
|
||||||
struct timeval ev_timeout;
|
struct timeval ev_timeout;
|
||||||
|
|
||||||
int ev_pri; /* smaller numbers are higher priority */
|
|
||||||
|
|
||||||
/* allows us to adopt for different types of events */
|
/* allows us to adopt for different types of events */
|
||||||
void (*ev_closure)(struct event_base *, struct event *);
|
|
||||||
void (*ev_callback)(evutil_socket_t, short, void *arg);
|
void (*ev_callback)(evutil_socket_t, short, void *arg);
|
||||||
void *ev_arg;
|
void *ev_arg;
|
||||||
|
|
||||||
int ev_res; /* result passed to event callback */
|
|
||||||
int ev_flags;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef EVENT_FD
|
#ifdef EVENT_FD
|
||||||
|
Loading…
x
Reference in New Issue
Block a user