gmain: Include poll.h as early as possible

On AIX, the system poll.h redefines the names of struct members,
for example `#define events reqevents`. This means that accesses
to GPollFD will fail to compile if poll.h was included after
glib/gpoll.h.

We can't simply add `#include <poll.h>` in glib/gpoll.h, because
that wouldn't work on platforms where poll.h doesn't exist, and
GLib supports some platforms in that category.

Resolves: https://gitlab.gnome.org/GNOME/glib/-/issues/3500
This commit is contained in:
Parth Patel 2024-10-18 02:30:59 -05:00
parent 6cabc7bbf8
commit 0924a2e881

View File

@ -48,6 +48,15 @@
#define G_MAIN_POLL_DEBUG
#endif
/* We need to include this as early as possible, because on some
* platforms like AIX, <poll.h> redefines the names we use for
* GPollFD struct members.
* See https://gitlab.gnome.org/GNOME/glib/-/issues/3500 */
#ifdef HAVE_POLL_H
#include <poll.h>
#endif
#ifdef G_OS_UNIX
#include "glib-unix.h"
#include <pthread.h>
@ -69,10 +78,6 @@
#include <errno.h>
#include <string.h>
#ifdef HAVE_POLL_H
#include <poll.h>
#endif
#ifdef HAVE_PIDFD
#include <sys/syscall.h>
#include <sys/wait.h>