diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index dc0418c..694f069 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -2752,41 +2752,14 @@ _dbus_poll (DBusPollFD *fds, int timeout_milliseconds) { #if defined(HAVE_POLL) && !defined(BROKEN_POLL) - /* This big thing is a constant expression and should get optimized - * out of existence. So it's more robust than a configure check at - * no cost. - */ - if (_DBUS_POLLIN == POLLIN && - _DBUS_POLLPRI == POLLPRI && - _DBUS_POLLOUT == POLLOUT && - _DBUS_POLLERR == POLLERR && - _DBUS_POLLHUP == POLLHUP && - _DBUS_POLLNVAL == POLLNVAL && - sizeof (DBusPollFD) == sizeof (struct pollfd) && - _DBUS_STRUCT_OFFSET (DBusPollFD, fd) == - _DBUS_STRUCT_OFFSET (struct pollfd, fd) && - _DBUS_STRUCT_OFFSET (DBusPollFD, events) == - _DBUS_STRUCT_OFFSET (struct pollfd, events) && - _DBUS_STRUCT_OFFSET (DBusPollFD, revents) == - _DBUS_STRUCT_OFFSET (struct pollfd, revents)) - { - if (timeout_milliseconds < -1) - { - timeout_milliseconds = -1; - } - - return poll ((struct pollfd*) fds, - n_fds, - timeout_milliseconds); - } - else + if (timeout_milliseconds < -1) { - /* We have to convert the DBusPollFD to an array of - * struct pollfd, poll, and convert back. - */ - _dbus_warn ("didn't implement poll() properly for this system yet\n"); - return -1; + timeout_milliseconds = -1; } + + return poll ((struct pollfd*) fds, + n_fds, + timeout_milliseconds); #else /* ! HAVE_POLL */ fd_set read_set, write_set, err_set; diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h index 7043a45..ae855cc 100644 --- a/dbus/dbus-sysdeps.h +++ b/dbus/dbus-sysdeps.h @@ -300,48 +300,33 @@ dbus_int32_t _dbus_atomic_dec (DBusAtomic *atomic); dbus_int32_t _dbus_atomic_get (DBusAtomic *atomic); -/* AIX uses different values for poll */ +/** + * A portable struct pollfd wrapper. + */ +#if defined(HAVE_POLL) && !defined(BROKEN_POLL) +typedef struct pollfd DBusPollFD; -#ifdef _AIX -/** There is data to read */ -#define _DBUS_POLLIN 0x0001 -/** There is urgent data to read */ -#define _DBUS_POLLPRI 0x0004 -/** Writing now will not block */ -#define _DBUS_POLLOUT 0x0002 -/** Error condition */ -#define _DBUS_POLLERR 0x4000 -/** Hung up */ -#define _DBUS_POLLHUP 0x2000 -/** Invalid request: fd not open */ -#define _DBUS_POLLNVAL 0x8000 -#elif defined(__HAIKU__) /** There is data to read */ -#define _DBUS_POLLIN 0x0001 -/** Writing now will not block */ -#define _DBUS_POLLOUT 0x0002 -/** Error condition */ -#define _DBUS_POLLERR 0x0004 +#define _DBUS_POLLIN POLLIN /** There is urgent data to read */ -#define _DBUS_POLLPRI 0x0020 -/** Hung up */ -#define _DBUS_POLLHUP 0x0080 -/** Invalid request: fd not open */ -#define _DBUS_POLLNVAL 0x1000 -#elif defined(__QNX__) +#define _DBUS_POLLPRI POLLPRI /** Writing now will not block */ -#define _DBUS_POLLOUT 0x0002 -/** There is data to read */ -#define _DBUS_POLLIN 0x0005 -/** There is urgent data to read */ -#define _DBUS_POLLPRI 0x0008 +#define _DBUS_POLLOUT POLLOUT /** Error condition */ -#define _DBUS_POLLERR 0x0020 +#define _DBUS_POLLERR POLLERR /** Hung up */ -#define _DBUS_POLLHUP 0x0040 +#define _DBUS_POLLHUP POLLHUP /** Invalid request: fd not open */ -#define _DBUS_POLLNVAL 0x1000 +#define _DBUS_POLLNVAL POLLNVAL #else +/* Fallback */ +typedef struct +{ + DBusPollable fd; /**< File descriptor */ + short events; /**< Events to poll for */ + short revents; /**< Events that occurred */ +} DBusPollFD; + /** There is data to read */ #define _DBUS_POLLIN 0x0001 /** There is urgent data to read */ @@ -407,16 +392,6 @@ _dbus_pollable_equals (DBusPollable a, DBusPollable b) { return a == b; } #endif /* !DBUS_WIN */ -/** - * A portable struct pollfd wrapper. - */ -typedef struct -{ - DBusPollable fd; /**< File descriptor */ - short events; /**< Events to poll for */ - short revents; /**< Events that occurred */ -} DBusPollFD; - DBUS_PRIVATE_EXPORT int _dbus_poll (DBusPollFD *fds, int n_fds,