Project import generated by Copybara.
GitOrigin-RevId: dee85689ae386c5256ad71a077b2474bda15cb45
diff --git a/glib/NOTICE b/glib/NOTICE
new file mode 120000
index 0000000..012065c
--- /dev/null
+++ b/glib/NOTICE
@@ -0,0 +1 @@
+../COPYING
\ No newline at end of file
diff --git a/glib/glibconfig.h b/glib/glibconfig.h
index c0974df..4135462 100644
--- a/glib/glibconfig.h
+++ b/glib/glibconfig.h
@@ -10,6 +10,47 @@
#include <limits.h>
#include <float.h>
+#include <stdint.h>
+#include <bits/wordsize.h>
+
+#if __WORDSIZE == 64
+
+#define THIRD_PARTY_GLIB_INT64_TYPE long
+#define THIRD_PARTY_GLIB_LONG_SIZE 8
+#define THIRD_PARTY_GLIB_LONG_TO_LE GINT64_TO_LE
+#define THIRD_PARTY_GLIB_LONG_TO_BE GINT64_TO_BE
+#define THIRD_PARTY_GLIB_ULONG_TO_LE GUINT64_TO_LE
+#define THIRD_PARTY_GLIB_ULONG_TO_BE GUINT64_TO_BE
+#define THIRD_PARTY_GLIB_64_PREFIX "l"
+#define THIRD_PARTY_GLIB_SIZE_SIZE 8
+#define THIRD_PARTY_GLIB_SIZE_TYPE long
+#define THIRD_PARTY_GLIB_SIZE_MAX G_MAXULONG
+#define THIRD_PARTY_GLIB_SSIZE_MIN G_MINLONG
+#define THIRD_PARTY_GLIB_SSIZE_MAX G_MAXLONG
+#define THIRD_PARTY_GLIB_SIZE_PREFIX "l"
+
+#elif __WORDSIZE == 32
+
+#define THIRD_PARTY_GLIB_INT64_TYPE long long
+#define THIRD_PARTY_GLIB_LONG_SIZE 4
+#define THIRD_PARTY_GLIB_LONG_TO_LE GINT32_TO_LE
+#define THIRD_PARTY_GLIB_LONG_TO_BE GINT32_TO_BE
+#define THIRD_PARTY_GLIB_ULONG_TO_LE GUINT32_TO_LE
+#define THIRD_PARTY_GLIB_ULONG_TO_BE GUINT32_TO_BE
+#define THIRD_PARTY_GLIB_64_PREFIX "ll"
+#define THIRD_PARTY_GLIB_SIZE_SIZE 4
+#define THIRD_PARTY_GLIB_SIZE_TYPE int
+#define THIRD_PARTY_GLIB_SIZE_MAX G_MAXUINT
+#define THIRD_PARTY_GLIB_SSIZE_MIN G_MININT
+#define THIRD_PARTY_GLIB_SSIZE_MAX G_MAXINT
+#define THIRD_PARTY_GLIB_SIZE_PREFIX ""
+
+#else
+
+#error "Unknown 64bit integer type"
+
+#endif
+
#define GLIB_HAVE_ALLOCA_H
/* Specifies that GLib's g_print*() functions wrap the
@@ -58,32 +99,32 @@
#define G_HAVE_GINT64 1 /* deprecated, always true */
-typedef signed long gint64;
-typedef unsigned long guint64;
+typedef THIRD_PARTY_GLIB_INT64_TYPE gint64;
+typedef unsigned THIRD_PARTY_GLIB_INT64_TYPE guint64;
-#define G_GINT64_CONSTANT(val) (val##L)
-#define G_GUINT64_CONSTANT(val) (val##UL)
+#define G_GINT64_CONSTANT(val) ((gint64)val)
+#define G_GUINT64_CONSTANT(val) ((guint64)val)
-#define G_GINT64_MODIFIER "l"
-#define G_GINT64_FORMAT "li"
-#define G_GUINT64_FORMAT "lu"
+#define G_GINT64_MODIFIER THIRD_PARTY_GLIB_64_PREFIX
+#define G_GINT64_FORMAT THIRD_PARTY_GLIB_64_PREFIX "i"
+#define G_GUINT64_FORMAT THIRD_PARTY_GLIB_64_PREFIX "u"
-#define GLIB_SIZEOF_VOID_P 8
-#define GLIB_SIZEOF_LONG 8
-#define GLIB_SIZEOF_SIZE_T 8
-#define GLIB_SIZEOF_SSIZE_T 8
+#define GLIB_SIZEOF_VOID_P THIRD_PARTY_GLIB_SIZE_SIZE
+#define GLIB_SIZEOF_LONG THIRD_PARTY_GLIB_LONG_SIZE
+#define GLIB_SIZEOF_SIZE_T THIRD_PARTY_GLIB_SIZE_SIZE
+#define GLIB_SIZEOF_SSIZE_T THIRD_PARTY_GLIB_SIZE_SIZE
-typedef signed long gssize;
-typedef unsigned long gsize;
-#define G_GSIZE_MODIFIER "l"
-#define G_GSSIZE_MODIFIER "l"
-#define G_GSIZE_FORMAT "lu"
-#define G_GSSIZE_FORMAT "li"
+typedef signed THIRD_PARTY_GLIB_SIZE_TYPE gssize;
+typedef unsigned THIRD_PARTY_GLIB_SIZE_TYPE gsize;
+#define G_GSIZE_MODIFIER THIRD_PARTY_GLIB_SIZE_PREFIX
+#define G_GSSIZE_MODIFIER THIRD_PARTY_GLIB_SIZE_PREFIX
+#define G_GSIZE_FORMAT THIRD_PARTY_GLIB_SIZE_PREFIX "u"
+#define G_GSSIZE_FORMAT THIRD_PARTY_GLIB_SIZE_PREFIX "i"
-#define G_MAXSIZE G_MAXULONG
-#define G_MINSSIZE G_MINLONG
-#define G_MAXSSIZE G_MAXLONG
+#define G_MAXSIZE THIRD_PARTY_GLIB_SIZE_MAX
+#define G_MINSSIZE THIRD_PARTY_GLIB_SSIZE_MIN
+#define G_MAXSSIZE THIRD_PARTY_GLIB_SSIZE_MAX
typedef gint64 goffset;
#define G_MINOFFSET G_MININT64
@@ -95,18 +136,18 @@
#define G_POLLFD_FORMAT "%d"
-#define GPOINTER_TO_INT(p) ((gint) (glong) (p))
-#define GPOINTER_TO_UINT(p) ((guint) (gulong) (p))
+#define GPOINTER_TO_INT(p) ((gint) (gintptr) (p))
+#define GPOINTER_TO_UINT(p) ((guint) (guintptr) (p))
-#define GINT_TO_POINTER(i) ((gpointer) (glong) (i))
-#define GUINT_TO_POINTER(u) ((gpointer) (gulong) (u))
+#define GINT_TO_POINTER(i) ((gpointer) (gintptr) (i))
+#define GUINT_TO_POINTER(u) ((gpointer) (guintptr) (u))
-typedef signed long gintptr;
-typedef unsigned long guintptr;
+typedef signed THIRD_PARTY_GLIB_SIZE_TYPE gintptr;
+typedef unsigned THIRD_PARTY_GLIB_SIZE_TYPE guintptr;
-#define G_GINTPTR_MODIFIER "l"
-#define G_GINTPTR_FORMAT "li"
-#define G_GUINTPTR_FORMAT "lu"
+#define G_GINTPTR_MODIFIER THIRD_PARTY_GLIB_SIZE_PREFIX
+#define G_GINTPTR_FORMAT THIRD_PARTY_GLIB_SIZE_PREFIX "i"
+#define G_GUINTPTR_FORMAT THIRD_PARTY_GLIB_SIZE_PREFIX "u"
#define GLIB_MAJOR_VERSION 2
#define GLIB_MINOR_VERSION 65
@@ -171,18 +212,18 @@
#define GINT64_TO_BE(val) ((gint64) GUINT64_SWAP_LE_BE (val))
#define GUINT64_TO_BE(val) (GUINT64_SWAP_LE_BE (val))
-#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))
+#define GLONG_TO_LE(val) ((glong) THIRD_PARTY_GLIB_LONG_TO_LE (val))
+#define GULONG_TO_LE(val) ((gulong) THIRD_PARTY_GLIB_ULONG_TO_LE (val))
+#define GLONG_TO_BE(val) ((glong) THIRD_PARTY_GLIB_LONG_TO_BE (val))
+#define GULONG_TO_BE(val) ((gulong) THIRD_PARTY_GLIB_ULONG_TO_BE (val))
#define GINT_TO_LE(val) ((gint) GINT32_TO_LE (val))
#define GUINT_TO_LE(val) ((guint) GUINT32_TO_LE (val))
#define GINT_TO_BE(val) ((gint) GINT32_TO_BE (val))
#define GUINT_TO_BE(val) ((guint) GUINT32_TO_BE (val))
-#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))
+#define GSIZE_TO_LE(val) ((gsize) THIRD_PARTY_GLIB_LONG_TO_LE (val))
+#define GSSIZE_TO_LE(val) ((gssize) THIRD_PARTY_GLIB_ULONG_TO_LE (val))
+#define GSIZE_TO_BE(val) ((gsize) THIRD_PARTY_GLIB_LONG_TO_BE (val))
+#define GSSIZE_TO_BE(val) ((gssize) THIRD_PARTY_GLIB_ULONG_TO_BE (val))
#define G_BYTE_ORDER G_LITTLE_ENDIAN
#define GLIB_SYSDEF_POLLIN =1