commit 7a0ea1f15c414033c00dae36d46706930cdcdf01
parent 062706fcbf39bcee536ea4b5c690e2f30e122faa
Author: Nihal Jere <nihal@nihaljere.xyz>
Date: Sun, 7 Feb 2021 13:26:32 -0600
use correct <poll.h> header
In POSIX, poll() should be accessible using <poll.h>, although most
implementations keep <sys/poll.h> to avoid breakage. This fixes some
warnings when building on musl.
Diffstat:
3 files changed, 11 insertions(+), 11 deletions(-)
diff --git 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
@@ -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 <sys/poll.h>
+#ifdef HAVE_POLL_H
+# include <poll.h>
#else
# define POLLIN 1
# define POLLOUT 4
diff --git 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;