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.
This commit is contained in:
Nihal Jere 2021-02-07 13:26:32 -06:00 committed by Oswald Buddenhagen
parent 062706fcbf
commit 7a0ea1f15c
3 changed files with 11 additions and 11 deletions

View File

@ -78,7 +78,7 @@ if test "x$ob_cv_strftime_z" = x"no"; then
AC_MSG_ERROR([libc lacks necessary feature]) AC_MSG_ERROR([libc lacks necessary feature])
fi 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_FUNCS(vasprintf strnlen memrchr timegm)
AC_CHECK_LIB(socket, socket, [SOCK_LIBS="-lsocket"]) AC_CHECK_LIB(socket, socket, [SOCK_LIBS="-lsocket"])

View File

@ -226,7 +226,7 @@ typedef struct notifier {
struct notifier *next; struct notifier *next;
void (*cb)( int what, void *aux ); void (*cb)( int what, void *aux );
void *aux; void *aux;
#ifdef HAVE_SYS_POLL_H #ifdef HAVE_POLL_H
uint index; uint index;
#else #else
int fd; int fd;
@ -234,8 +234,8 @@ typedef struct notifier {
#endif #endif
} notifier_t; } notifier_t;
#ifdef HAVE_SYS_POLL_H #ifdef HAVE_POLL_H
# include <sys/poll.h> # include <poll.h>
#else #else
# define POLLIN 1 # define POLLIN 1
# define POLLOUT 4 # define POLLOUT 4

View File

@ -665,7 +665,7 @@ list_unlink( list_head_t *head )
static notifier_t *notifiers; static notifier_t *notifiers;
static int changed; /* Iterator may be invalid now. */ static int changed; /* Iterator may be invalid now. */
#ifdef HAVE_SYS_POLL_H #ifdef HAVE_POLL_H
static struct pollfd *pollfds; static struct pollfd *pollfds;
static uint npolls, rpolls; static uint npolls, rpolls;
#else #else
@ -677,7 +677,7 @@ static uint npolls, rpolls;
void void
init_notifier( notifier_t *sn, int fd, void (*cb)( int, void * ), void *aux ) 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++; uint idx = npolls++;
if (rpolls < npolls) { if (rpolls < npolls) {
rpolls = npolls; rpolls = npolls;
@ -699,7 +699,7 @@ init_notifier( notifier_t *sn, int fd, void (*cb)( int, void * ), void *aux )
void void
conf_notifier( notifier_t *sn, short and_events, short or_events ) conf_notifier( notifier_t *sn, short and_events, short or_events )
{ {
#ifdef HAVE_SYS_POLL_H #ifdef HAVE_POLL_H
uint idx = sn->index; uint idx = sn->index;
pollfds[idx].events = (pollfds[idx].events & and_events) | or_events; pollfds[idx].events = (pollfds[idx].events & and_events) | or_events;
#else #else
@ -710,7 +710,7 @@ conf_notifier( notifier_t *sn, short and_events, short or_events )
short short
notifier_config( notifier_t *sn ) notifier_config( notifier_t *sn )
{ {
#ifdef HAVE_SYS_POLL_H #ifdef HAVE_POLL_H
return pollfds[sn->index].events; return pollfds[sn->index].events;
#else #else
return sn->events; return sn->events;
@ -721,7 +721,7 @@ void
wipe_notifier( notifier_t *sn ) wipe_notifier( notifier_t *sn )
{ {
notifier_t **snp; notifier_t **snp;
#ifdef HAVE_SYS_POLL_H #ifdef HAVE_POLL_H
uint idx; uint idx;
#endif #endif
@ -731,7 +731,7 @@ wipe_notifier( notifier_t *sn )
sn->next = NULL; sn->next = NULL;
changed = 1; changed = 1;
#ifdef HAVE_SYS_POLL_H #ifdef HAVE_POLL_H
idx = sn->index; idx = sn->index;
memmove( pollfds + idx, pollfds + idx + 1, (--npolls - idx) * sizeof(*pollfds) ); memmove( pollfds + idx, pollfds + idx + 1, (--npolls - idx) * sizeof(*pollfds) );
for (sn = notifiers; sn; sn = sn->next) { for (sn = notifiers; sn; sn = sn->next) {
@ -803,7 +803,7 @@ event_wait( void )
notifier_t *sn; notifier_t *sn;
int m; int m;
#ifdef HAVE_SYS_POLL_H #ifdef HAVE_POLL_H
int timeout = -1; int timeout = -1;
if ((head = timers.next) != &timers) { if ((head = timers.next) != &timers) {
wakeup_t *tmr = (wakeup_t *)head; wakeup_t *tmr = (wakeup_t *)head;