From ad5333f7a5e944399472b9308923b1809c775abf Mon Sep 17 00:00:00 2001
From: Aditya Kamath <Aditya.Kamath1@ibm.com>
Date: Tue, 3 Mar 2026 12:25:43 -0600
Subject: [PATCH v1 4/4] Include poll.h before gpoll.h

    This patch is to include poll.h before gpoll.h to avoid redefinitions
    in AIX 32 bit.

    This patch fixes the error below:

    prototypes -Werror=pointer-sign -maix32 -O2 -fsigned-char -mcmodel=large -maix32 -O2 -fsigned-char -fPIC -pthread '-DG_LOG_DOMAIN="GLib"' -DGLIB_COMPILATION -MD -MQ glib/libglib-2.0.so.0.8703.0.p/gmain.c.o -MF glib/libglib-2.0.so.0.8703.0.p/gmain.c.o.d -o glib/libglib-2.0.so.0.8703.0.p/gmain.c.o -c ../glib/gmain.c
    In file included from /usr/include/poll.h:30,
                     from ../glib/gmain.c:58:
    ../glib/gmain.c: In function 'g_source_add_unix_fd':
    ../glib/gmain.c:2849:12: error: 'GPollFD' {aka 'struct _GPollFD'} has no member named 'reqevents'; did you mean 'revents'?
     2849 |   poll_fd->events = events;
          |            ^~~~~~
    ../glib/gmain.c:2850:12: error: 'GPollFD' {aka 'struct _GPollFD'} has no member named 'rtnevents'; did you mean 'revents'?
     2850 |   poll_fd->revents = 0;
          |            ^~~~~~~
    ../glib/gmain.c: In function 'g_source_modify_unix_fd':
    ../glib/gmain.c:2905:12: error: 'GPollFD' {aka 'struct _GPollFD'} has no member named 'reqevents'; did you mean 'revents'?
---
 glib/gmain.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/glib/gmain.c b/glib/gmain.c
index 94dcb7c55..e47d89ce7 100644
--- a/glib/gmain.c
+++ b/glib/gmain.c
@@ -31,6 +31,15 @@
  * MT safe
  */
 
+/* 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
+
 #include "config.h"
 #include "glib.h"
 #include "glibconfig.h"
@@ -49,15 +58,6 @@
 #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>
-- 
2.51.2

