Track timer event sources in userspace
libwayland now uses only one file descriptor to keep track of all the timer event sources associated with an event loop. An array-based binary heap is used to determine which event source has the earliest deadline.
(Previously, each timer event source had its own timerfd, making it easy for the a process using many timer event sources to run out of file descriptors.)
This change is motivated by https://github.com/swaywm/sway/issues/4796 , a crash which occurs because enough timer event sources are created (by the function wl_event_loop_add_timer) that the compositor process runs out of file descriptors, making
wl_event_loop_add_timer return an unexpected NULL. It's possible to work around the limitation on the number of timers by writing a similar patch to this one at the compositor level, but if there's going to be a priority queue somewhere, it might as well be placed where everyone can take advantage of it.
This merge request is marked WIP, because some optimization work and much more testing are necessary. I also need to bring it further in line with the style conventions. Still, any feedback at this point would be appreciated. Edit: Most of the optimization and style fixes are done now. I've kept this as WIP, because more testing is still needed.