diff --git a/include/event2/event.h b/include/event2/event.h index 963dd6f5..69529e30 100644 --- a/include/event2/event.h +++ b/include/event2/event.h @@ -450,6 +450,14 @@ int _event_initialized(struct event *, int check_fd); */ evutil_socket_t event_get_fd(struct event *ev); +#ifndef EVENT_FD +/* We haven't included event_struct.h, so define these as function calls + * rather than as direct struct access. If we include event_struct.h later, + * these macros will be overridden. */ +#define EVENT_FD(ev) ((int)event_get_fd(ev)) +#define EVENT_SIGNAL(ev) ((int)event_get_fd(ev)) +#endif + /** Get the libevent version number. diff --git a/include/event2/event_struct.h b/include/event2/event_struct.h index 70be9072..17a89a85 100644 --- a/include/event2/event_struct.h +++ b/include/event2/event_struct.h @@ -119,8 +119,14 @@ struct event { int ev_flags; }; +#ifdef EVENT_FD +/* This was defined in event.h, but since we're including event_struct.h, we + * can use the faster versions. */ +#undef EVENT_FD +#undef EVENT_SIGNAL #define EVENT_SIGNAL(ev) ((int)(ev)->ev_fd) #define EVENT_FD(ev) ((int)(ev)->ev_fd) +#endif /* * Key-Value pairs. Can be used for HTTP headers but also for