diff options
| author | Roy Marples <roy@marples.name> | 2020-06-03 23:30:08 +0100 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2020-06-03 23:30:08 +0100 |
| commit | 2f16f1f6245649b1784da9835ff580d280ede1bf (patch) | |
| tree | e6f8626eb44245b0ba7c81af6a5fcff2c9cbbd75 /configure | |
| parent | fbb2366d5f207118bfeab76413efe96d4fcfd6f8 (diff) | |
| download | dhcpcd-2f16f1f6245649b1784da9835ff580d280ede1bf.tar.xz | |
eloop: Just use ppoll(2)
epoll and kqueue are really too heavy weight.
With privsep, we now favour more processes for BPF and per address sockets.
As such, the number of fds to monitor will always be quite small.
All modern OS now have ppoll(2) (NetBSD has pollts, which is the same)
which works perfectly for us.
If neither are present, the a wrapper around pselect(2) is provided,
which can be found on all POSIX systems.
This makes the code a lot smaller and easier to follow.
The reduced binary size and memory usage is a nice win here.
Diffstat (limited to 'configure')
| -rwxr-xr-x | configure | 85 |
1 files changed, 26 insertions, 59 deletions
@@ -1211,65 +1211,42 @@ fi echo "#define HAVE_REALLOCARRAY" >>$CONFIG_H if [ -z "$POLL" ]; then - printf "Testing for kqueue1 ... " - cat <<EOF >_kqueue.c -#include <sys/types.h> -#include <sys/event.h> + printf "Testing for ppoll ... " + cat <<EOF >_ppoll.c +#include <poll.h> +#include <stddef.h> int main(void) { - return kqueue1(0); + struct pollfd fds; + return ppoll(&fds, 1, NULL, NULL); } EOF - if $XCC _kqueue.c -o _kqueue 2>&3; then - POLL=kqueue1 - echo "yes" - else - echo "no" - fi - rm -f _kqueue.c _kqueue + if $XCC _ppoll.c -o _ppoll 2>&3; then + POLL=ppoll + echo "#define HAVE_PPOLL" >>$CONFIG_MK + echo "yes" + else + echo "no" + fi + rm -f _ppoll.c _ppoll fi if [ -z "$POLL" ]; then - printf "Testing for kqueue ... " - cat <<EOF >_kqueue.c -#include <sys/types.h> -#include <sys/event.h> + printf "Testing for pollts ... " + cat <<EOF >_pollts.c +#include <poll.h> +#include <stddef.h> int main(void) { - return kqueue(); + struct pollfd fds; + return pollts(&fds, 1, NULL, NULL); } EOF - if $XCC _kqueue.c -o _kqueue 2>&3; then - POLL=kqueue - echo "yes" - else - echo "no" - fi - rm -f _kqueue.c _kqueue -fi -if [ -z "$POLL" ]; then - printf "Testing for epoll ... " - cat <<EOF >_epoll.c -#ifdef __linux__ -#include <linux/version.h> -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37) -#error kernel has buggy epoll_wait timeout -#endif -#endif - -#include <sys/epoll.h> -#include <unistd.h> -int main(void) { - epoll_create1(EPOLL_CLOEXEC); - epoll_pwait(-1, NULL, 0, 0, NULL); - return 0; -} -EOF - if $XCC _epoll.c -o _epoll 2>&3; then - POLL=epoll - echo "#define HAVE_EPOLL" >>$CONFIG_MK + if $XCC _pollts.c -o _pollts 2>&3; then + POLL=pollts + echo "#define HAVE_PPOLL" >>$CONFIG_MK echo "yes" else echo "no" fi - rm -f _epoll.c _epoll + rm -f _pollts.c _pollts fi if [ -z "$POLL" ]; then printf "Testing for pselect ... " @@ -1290,22 +1267,12 @@ EOF rm -f _pselect.c _pselect fi case "$POLL" in -kqueue1) - echo "#define HAVE_KQUEUE" >>$CONFIG_H - echo "#define HAVE_KQUEUE1" >>$CONFIG_H - ;; -kqueue) - echo "#define HAVE_KQUEUE" >>$CONFIG_H - ;; -epoll) - echo "#define HAVE_EPOLL" >>$CONFIG_H +ppoll) + echo "#define HAVE_PPOLL" >>$CONFIG_H ;; pollts) echo "#define HAVE_POLLTS" >>$CONFIG_H ;; -ppoll) - echo "#define HAVE_PPOLL" >>$CONFIG_H - ;; pselect) echo "#define HAVE_PSELECT" >>$CONFIG_H ;; |
