libev and libevent

Andy Green andy at warmcat.com
Mon Feb 19 13:10:49 CET 2018


Hi -

I maintain libwebsockets (https://libwebsockets.org / 
https://github.com/warmcat/libwebsockets ).  Thanks to user contribution 
over the years it now supports libuv, libev and libevent.

Libevent was the most recent addition; until then lws supports the idea 
of building the library with bindings to both libuv and libev, and 
choose which one to use at runtime.  So libevent was added to the happy 
coexistence merry-go-round.

However now I get a big headache, because both libev and libevent define 
EV_READ / EV_WRITE, to different things.

libevent says

/usr/include/event2/event.h:#define EV_READ		0x02
/usr/include/event2/event.h:#define EV_WRITE	0x04

and libev says

   EV_READ     =            0x01, /* ev_io detected read will not block */
   EV_WRITE    =            0x02, /* ev_io detected write will not block */

Since libevent uses the preprocessor, it gets the final say; in other 
words since it defines EV_READ etc to a different value, building some 
software that can operate with both libevent and libev results in 
nothing working or not even build completing if you include the libevent 
bits first.

This is basically an interoperability problem between libevent and 
libev, or libev and libevent, it would be great if there is something 
that can be done to allow the happy coexistence merry-go-round to spin 
once more for these two libraries.

I opened a github issue at

https://github.com/libevent/libevent/issues/596

for libevent, but I learned there the situation is more complex than I 
expected, with libev providing some libevent compatibility by design.

For downstream maintainers like me whose users wish to be able to use 
both, and where distro consumers should be able to tick all the boxes 
and choose at runtime, are there any ideas what can be done to improve 
the situation?

-Andy



More information about the libev mailing list