Defining _DBUS_POLL* in dbus-sysdeps.h
Schmottlach, Glenn
GSchmott at harmanbecker.com
Fri Nov 7 08:18:33 PST 2008
I ran across this code in dbus/dbus-sysdeps.h while trying to debug an
issue with the poll() implementation on QNX.
/* AIX uses different values for poll */
#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
#else
/** There is data to read */
#define _DBUS_POLLIN 0x0001
/** There is urgent data to read */
#define _DBUS_POLLPRI 0x0002
/** Writing now will not block */
#define _DBUS_POLLOUT 0x0004
/** Error condition */
#define _DBUS_POLLERR 0x0008
/** Hung up */
#define _DBUS_POLLHUP 0x0010
/** Invalid request: fd not open */
#define _DBUS_POLLNVAL 0x0020
#endif
I wonder, if "HAVE_POLL" is already defined, then why not use the actual
POLL* values defined in the header sys/poll.h instead of hard-coding
values? The code would then look like this and be much more portable to
other OSes (namely QNX ;-):
#ifdef HAVE_POLL
/** There is data to read */
#define _DBUS_POLLIN POLLIN
/** There is urgent data to read */
#define _DBUS_POLLPRI POLLPRI
/** Writing now will not block */
#define _DBUS_POLLOUT POLLOUT
/** Error condition */
#define _DBUS_POLLERR POLLERR
/** Hung up */
#define _DBUS_POLLHUP POLLHUP
/** Invalid request: fd not open */
#define _DBUS_POLLNVAL POLLNVAL
#elif defined(_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
#else
/** There is data to read */
#define _DBUS_POLLIN 0x0001
/** There is urgent data to read */
#define _DBUS_POLLPRI 0x0002
/** Writing now will not block */
#define _DBUS_POLLOUT 0x0004
/** Error condition */
#define _DBUS_POLLERR 0x0008
/** Hung up */
#define _DBUS_POLLHUP 0x0010
/** Invalid request: fd not open */
#define _DBUS_POLLNVAL 0x0020
#endif
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freedesktop.org/archives/dbus/attachments/20081107/418ab7b7/attachment.html
More information about the dbus
mailing list