Allow universal builds. This is only part of the solution; the config.h.ed
script is the other part. If new variables appear in the configure script
that are affected by endianness or bitness, remember to handle them both
here and in config.h.ed.
--- glib/glibconfig.h.in.orig	2023-03-22 19:28:01.000000000 +0800
+++ glib/glibconfig.h.in	2023-04-18 04:59:19.000000000 +0800
@@ -62,21 +62,43 @@
 
 #define G_HAVE_GINT64 1          /* deprecated, always true */
 
-@glib_extension@typedef signed @gint64@ gint64;
-@glib_extension@typedef unsigned @gint64@ guint64;
-
-#define G_GINT64_CONSTANT(val)	@gint64_constant@
-#define G_GUINT64_CONSTANT(val)	@guint64_constant@
+#ifdef __LP64__
+typedef signed long gint64;
+typedef unsigned long guint64;
+#else
+G_GNUC_EXTENSION typedef signed long long gint64;
+G_GNUC_EXTENSION typedef unsigned long long guint64;
+#endif
 
-#define G_GINT64_MODIFIER @gint64_modifier@
-#define G_GINT64_FORMAT @gint64_format@
-#define G_GUINT64_FORMAT @guint64_format@
+#ifdef __LP64__
+#define G_GINT64_CONSTANT(val)	(val##L)
+#define G_GUINT64_CONSTANT(val)	(val##UL)
+#else
+#define G_GINT64_CONSTANT(val)	(G_GNUC_EXTENSION (val##LL))
+#define G_GUINT64_CONSTANT(val)	(G_GNUC_EXTENSION (val##ULL))
+#endif
 
+#ifdef __LP64__
+#define G_GINT64_MODIFIER "l"
+#define G_GINT64_FORMAT "li"
+#define G_GUINT64_FORMAT "lu"
+#else
+#define G_GINT64_MODIFIER "ll"
+#define G_GINT64_FORMAT "lli"
+#define G_GUINT64_FORMAT "llu"
+#endif
 
-#define GLIB_SIZEOF_VOID_P @glib_void_p@
-#define GLIB_SIZEOF_LONG   @glib_long@
-#define GLIB_SIZEOF_SIZE_T @glib_size_t@
-#define GLIB_SIZEOF_SSIZE_T @glib_ssize_t@
+#ifdef __LP64__
+#define GLIB_SIZEOF_VOID_P 8
+#define GLIB_SIZEOF_LONG   8
+#define GLIB_SIZEOF_SIZE_T 8
+#define GLIB_SIZEOF_SSIZE_T 8
+#else
+#define GLIB_SIZEOF_VOID_P 4
+#define GLIB_SIZEOF_LONG   4
+#define GLIB_SIZEOF_SIZE_T 4
+#define GLIB_SIZEOF_SSIZE_T 4
+#endif
 
 typedef signed @glib_size_type_define@ gssize;
 typedef unsigned @glib_size_type_define@ gsize;
@@ -99,18 +121,39 @@
 
 #define G_POLLFD_FORMAT @g_pollfd_format@
 
-#define GPOINTER_TO_INT(p)	((gint)  @glib_gpi_cast@ (p))
-#define GPOINTER_TO_UINT(p)	((guint) @glib_gpui_cast@ (p))
+#ifdef __LP64__
+#define GPOINTER_TO_INT(p)	((gint)  (glong) (p))
+#define GPOINTER_TO_UINT(p)	((guint) (gulong) (p))
+#else
+#define GPOINTER_TO_INT(p)	((gint)  (gint) (p))
+#define GPOINTER_TO_UINT(p)	((guint) (guint) (p))
+#endif
 
-#define GINT_TO_POINTER(i)	((gpointer) @glib_gpi_cast@ (i))
-#define GUINT_TO_POINTER(u)	((gpointer) @glib_gpui_cast@ (u))
+#ifdef __LP64__
+#define GINT_TO_POINTER(i)	((gpointer) (glong) (i))
+#define GUINT_TO_POINTER(u)	((gpointer) (gulong) (u))
+#else
+#define GINT_TO_POINTER(i)	((gpointer) (gint) (i))
+#define GUINT_TO_POINTER(u)	((gpointer) (guint) (u))
+#endif
 
-typedef signed @glib_intptr_type_define@ gintptr;
-typedef unsigned @glib_intptr_type_define@ guintptr;
+#ifdef __LP64__
+typedef signed long gintptr;
+typedef unsigned long guintptr;
+#else
+typedef signed int gintptr;
+typedef unsigned int guintptr;
+#endif
 
-#define G_GINTPTR_MODIFIER      @gintptr_modifier@
-#define G_GINTPTR_FORMAT        @gintptr_format@
-#define G_GUINTPTR_FORMAT       @guintptr_format@
+#ifdef __LP64__
+#define G_GINTPTR_MODIFIER      "l"
+#define G_GINTPTR_FORMAT        "li"
+#define G_GUINTPTR_FORMAT       "lu"
+#else
+#define G_GINTPTR_MODIFIER      ""
+#define G_GINTPTR_FORMAT        "i"
+#define G_GUINTPTR_FORMAT       "u"
+#endif
 
 #define GLIB_MAJOR_VERSION @GLIB_MAJOR_VERSION@
 #define GLIB_MINOR_VERSION @GLIB_MINOR_VERSION@
@@ -119,7 +162,9 @@
 @glib_os@
 
 #define G_VA_COPY va_copy
-@glib_vacopy@
+#if defined(__ppc64__) || defined(__x86_64__)
+#define G_VA_COPY_AS_ARRAY 1
+#endif
 
 #define G_HAVE_ISO_VARARGS 1
 
@@ -152,34 +197,75 @@
 
 #mesondefine G_ATOMIC_LOCK_FREE
 
-#define GINT16_TO_@g_bs_native@(val)	((gint16) (val))
-#define GUINT16_TO_@g_bs_native@(val)	((guint16) (val))
-#define GINT16_TO_@g_bs_alien@(val)	((gint16) GUINT16_SWAP_LE_BE (val))
-#define GUINT16_TO_@g_bs_alien@(val)	(GUINT16_SWAP_LE_BE (val))
-
-#define GINT32_TO_@g_bs_native@(val)	((gint32) (val))
-#define GUINT32_TO_@g_bs_native@(val)	((guint32) (val))
-#define GINT32_TO_@g_bs_alien@(val)	((gint32) GUINT32_SWAP_LE_BE (val))
-#define GUINT32_TO_@g_bs_alien@(val)	(GUINT32_SWAP_LE_BE (val))
-
-#define GINT64_TO_@g_bs_native@(val)	((gint64) (val))
-#define GUINT64_TO_@g_bs_native@(val)	((guint64) (val))
-#define GINT64_TO_@g_bs_alien@(val)	((gint64) GUINT64_SWAP_LE_BE (val))
-#define GUINT64_TO_@g_bs_alien@(val)	(GUINT64_SWAP_LE_BE (val))
-
-#define GLONG_TO_LE(val)	((glong) GINT@glongbits@_TO_LE (val))
-#define GULONG_TO_LE(val)	((gulong) GUINT@glongbits@_TO_LE (val))
-#define GLONG_TO_BE(val)	((glong) GINT@glongbits@_TO_BE (val))
-#define GULONG_TO_BE(val)	((gulong) GUINT@glongbits@_TO_BE (val))
+#ifdef __BIG_ENDIAN__
+#define GINT16_TO_BE(val)	((gint16) (val))
+#define GUINT16_TO_BE(val)	((guint16) (val))
+#define GINT16_TO_LE(val)	((gint16) GUINT16_SWAP_LE_BE (val))
+#define GUINT16_TO_LE(val)	(GUINT16_SWAP_LE_BE (val))
+#else
+#define GINT16_TO_LE(val)	((gint16) (val))
+#define GUINT16_TO_LE(val)	((guint16) (val))
+#define GINT16_TO_BE(val)	((gint16) GUINT16_SWAP_LE_BE (val))
+#define GUINT16_TO_BE(val)	(GUINT16_SWAP_LE_BE (val))
+#endif
+
+#ifdef __BIG_ENDIAN__
+#define GINT32_TO_BE(val)	((gint32) (val))
+#define GUINT32_TO_BE(val)	((guint32) (val))
+#define GINT32_TO_LE(val)	((gint32) GUINT32_SWAP_LE_BE (val))
+#define GUINT32_TO_LE(val)	(GUINT32_SWAP_LE_BE (val))
+#else
+#define GINT32_TO_LE(val)	((gint32) (val))
+#define GUINT32_TO_LE(val)	((guint32) (val))
+#define GINT32_TO_BE(val)	((gint32) GUINT32_SWAP_LE_BE (val))
+#define GUINT32_TO_BE(val)	(GUINT32_SWAP_LE_BE (val))
+#endif
+
+#ifdef __BIG_ENDIAN__
+#define GINT64_TO_BE(val)	((gint64) (val))
+#define GUINT64_TO_BE(val)	((guint64) (val))
+#define GINT64_TO_LE(val)	((gint64) GUINT64_SWAP_LE_BE (val))
+#define GUINT64_TO_LE(val)	(GUINT64_SWAP_LE_BE (val))
+#else
+#define GINT64_TO_LE(val)	((gint64) (val))
+#define GUINT64_TO_LE(val)	((guint64) (val))
+#define GINT64_TO_BE(val)	((gint64) GUINT64_SWAP_LE_BE (val))
+#define GUINT64_TO_BE(val)	(GUINT64_SWAP_LE_BE (val))
+#endif
+
+#ifdef __LP64__
+#define GLONG_TO_LE(val)	((glong) GINT64_TO_LE (val))
+#define GULONG_TO_LE(val)	((gulong) GUINT64_TO_LE (val))
+#define GLONG_TO_BE(val)	((glong) GINT64_TO_BE (val))
+#define GULONG_TO_BE(val)	((gulong) GUINT64_TO_BE (val))
+#else
+#define GLONG_TO_LE(val)	((glong) GINT32_TO_LE (val))
+#define GULONG_TO_LE(val)	((gulong) GUINT32_TO_LE (val))
+#define GLONG_TO_BE(val)	((glong) GINT32_TO_BE (val))
+#define GULONG_TO_BE(val)	((gulong) GUINT32_TO_BE (val))
+#endif
 #define GINT_TO_LE(val)		((gint) GINT@gintbits@_TO_LE (val))
 #define GUINT_TO_LE(val)	((guint) GUINT@gintbits@_TO_LE (val))
 #define GINT_TO_BE(val)		((gint) GINT@gintbits@_TO_BE (val))
 #define GUINT_TO_BE(val)	((guint) GUINT@gintbits@_TO_BE (val))
-#define GSIZE_TO_LE(val)	((gsize) GUINT@gsizebits@_TO_LE (val))
-#define GSSIZE_TO_LE(val)	((gssize) GINT@gsizebits@_TO_LE (val))
-#define GSIZE_TO_BE(val)	((gsize) GUINT@gsizebits@_TO_BE (val))
-#define GSSIZE_TO_BE(val)	((gssize) GINT@gsizebits@_TO_BE (val))
-#define G_BYTE_ORDER @g_byte_order@
+#ifdef __LP64__
+#define GSIZE_TO_LE(val)	((gsize) GUINT64_TO_LE (val))
+#define GSSIZE_TO_LE(val)	((gssize) GINT64_TO_LE (val))
+#define GSIZE_TO_BE(val)	((gsize) GUINT64_TO_BE (val))
+#define GSSIZE_TO_BE(val)	((gssize) GINT64_TO_BE (val))
+#else
+#define GSIZE_TO_LE(val)	((gsize) GUINT32_TO_LE (val))
+#define GSSIZE_TO_LE(val)	((gssize) GINT32_TO_LE (val))
+#define GSIZE_TO_BE(val)	((gsize) GUINT32_TO_BE (val))
+#define GSSIZE_TO_BE(val)	((gssize) GINT32_TO_BE (val))
+#endif
+#ifdef __BIG_ENDIAN__
+#define G_BYTE_ORDER G_BIG_ENDIAN
+#else
+#define G_BYTE_ORDER G_LITTLE_ENDIAN
+#endif
+
+@glib_is_powerpc@
 
 #define GLIB_SYSDEF_POLLIN =@g_pollin@
 #define GLIB_SYSDEF_POLLOUT =@g_pollout@

--- meson.build.orig	2022-09-18 08:59:25.000000000 -0400
+++ meson.build	2022-09-18 09:02:33.000000000 -0400
@@ -1851,6 +1851,9 @@
   glibconfig_conf.set(d[1], val)
 endforeach
 
+glib_is_powerpc = '#if (defined(__PPC__) || defined(__PPC64__) || defined(__powerpc__) || defined(__powerpc64__) || defined(_ARCH_PPC)  || defined(_ARCH_PPC64))\n#ifdef G_ATOMIC_OP_MEMORY_BARRIER_NEEDED\n#undef G_ATOMIC_OP_MEMORY_BARRIER_NEEDED\n#endif\n#define G_ATOMIC_OP_MEMORY_BARRIER_NEEDED 1\n#else\n#ifdef G_ATOMIC_OP_MEMORY_BARRIER_NEEDED\n#undef G_ATOMIC_OP_MEMORY_BARRIER_NEEDED\n#endif\n#endif'
+glibconfig_conf.set('glib_is_powerpc', glib_is_powerpc)
+
 if host_system == 'windows'
   have_ipv6 = true
 else
