From 7a0ea1f15c414033c00dae36d46706930cdcdf01 Mon Sep 17 00:00:00 2001 From: Nihal Jere Date: Sun, 7 Feb 2021 13:26:32 -0600 Subject: [PATCH] use correct header In POSIX, poll() should be accessible using , although most implementations keep to avoid breakage. This fixes some warnings when building on musl. --- configure.ac | 2 +- src/common.h | 6 +++--- src/util.c | 14 +++++++------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/configure.ac b/configure.ac index ccab5cb..ae235d1 100644 --- a/configure.ac +++ b/configure.ac @@ -78,7 +78,7 @@ if test "x$ob_cv_strftime_z" = x"no"; then AC_MSG_ERROR([libc lacks necessary feature]) fi -AC_CHECK_HEADERS(sys/poll.h sys/select.h) +AC_CHECK_HEADERS(poll.h sys/select.h) AC_CHECK_FUNCS(vasprintf strnlen memrchr timegm) AC_CHECK_LIB(socket, socket, [SOCK_LIBS="-lsocket"]) diff --git a/src/common.h b/src/common.h index 5518f56..c840536 100644 --- a/src/common.h +++ b/src/common.h @@ -226,7 +226,7 @@ typedef struct notifier { struct notifier *next; void (*cb)( int what, void *aux ); void *aux; -#ifdef HAVE_SYS_POLL_H +#ifdef HAVE_POLL_H uint index; #else int fd; @@ -234,8 +234,8 @@ typedef struct notifier { #endif } notifier_t; -#ifdef HAVE_SYS_POLL_H -# include +#ifdef HAVE_POLL_H +# include #else # define POLLIN 1 # define POLLOUT 4 diff --git a/src/util.c b/src/util.c index dd6b12c..647a9f4 100644 --- a/src/util.c +++ b/src/util.c @@ -665,7 +665,7 @@ list_unlink( list_head_t *head ) static notifier_t *notifiers; static int changed; /* Iterator may be invalid now. */ -#ifdef HAVE_SYS_POLL_H +#ifdef HAVE_POLL_H static struct pollfd *pollfds; static uint npolls, rpolls; #else @@ -677,7 +677,7 @@ static uint npolls, rpolls; void init_notifier( notifier_t *sn, int fd, void (*cb)( int, void * ), void *aux ) { -#ifdef HAVE_SYS_POLL_H +#ifdef HAVE_POLL_H uint idx = npolls++; if (rpolls < npolls) { rpolls = npolls; @@ -699,7 +699,7 @@ init_notifier( notifier_t *sn, int fd, void (*cb)( int, void * ), void *aux ) void conf_notifier( notifier_t *sn, short and_events, short or_events ) { -#ifdef HAVE_SYS_POLL_H +#ifdef HAVE_POLL_H uint idx = sn->index; pollfds[idx].events = (pollfds[idx].events & and_events) | or_events; #else @@ -710,7 +710,7 @@ conf_notifier( notifier_t *sn, short and_events, short or_events ) short notifier_config( notifier_t *sn ) { -#ifdef HAVE_SYS_POLL_H +#ifdef HAVE_POLL_H return pollfds[sn->index].events; #else return sn->events; @@ -721,7 +721,7 @@ void wipe_notifier( notifier_t *sn ) { notifier_t **snp; -#ifdef HAVE_SYS_POLL_H +#ifdef HAVE_POLL_H uint idx; #endif @@ -731,7 +731,7 @@ wipe_notifier( notifier_t *sn ) sn->next = NULL; changed = 1; -#ifdef HAVE_SYS_POLL_H +#ifdef HAVE_POLL_H idx = sn->index; memmove( pollfds + idx, pollfds + idx + 1, (--npolls - idx) * sizeof(*pollfds) ); for (sn = notifiers; sn; sn = sn->next) { @@ -803,7 +803,7 @@ event_wait( void ) notifier_t *sn; int m; -#ifdef HAVE_SYS_POLL_H +#ifdef HAVE_POLL_H int timeout = -1; if ((head = timers.next) != &timers) { wakeup_t *tmr = (wakeup_t *)head;